diff options
author | Justin McPherson <justin.mcpherson@nokia.com> | 2010-02-25 06:06:58 (GMT) |
---|---|---|
committer | Justin McPherson <justin.mcpherson@nokia.com> | 2010-02-25 06:17:15 (GMT) |
commit | 40ee581661e07e522a2852b32a25337d13ca25f9 (patch) | |
tree | 5be54bd139fc37aec412e7f93bd30199ddfdc364 /src/plugins/mediaservices/qt7 | |
parent | f3abaf5ee7cdef1c963df383885668abd55427c3 (diff) | |
download | Qt-40ee581661e07e522a2852b32a25337d13ca25f9.zip Qt-40ee581661e07e522a2852b32a25337d13ca25f9.tar.gz Qt-40ee581661e07e522a2852b32a25337d13ca25f9.tar.bz2 |
QT7; Fix warnings.
Reviewed-by: Dmytro Poplavskiy
Diffstat (limited to 'src/plugins/mediaservices/qt7')
-rw-r--r-- | src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm | 74 |
1 files changed, 43 insertions, 31 deletions
diff --git a/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm b/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm index a14981a..b046672 100644 --- a/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm +++ b/src/plugins/mediaservices/qt7/mediaplayer/qt7playermetadata.mm @@ -132,15 +132,19 @@ static OSStatus readMetaValue(QTMetaDataRef metaDataRef, QTMetaDataItem item, QT UInt32 propFlags; OSStatus err = QTMetaDataGetItemPropertyInfo(metaDataRef, item, propClass, id, &type, &propSize, &propFlags); - - *value = malloc(propSize); - - err = QTMetaDataGetItemProperty(metaDataRef, item, propClass, id, propSize, *value, size); - - if (type == 'code' || type == 'itsk' || type == 'itlk') { - // convert from native endian to big endian - OSTypePtr pType = (OSTypePtr)*value; - *pType = EndianU32_NtoB(*pType); + if (err == noErr) { + *value = malloc(propSize); + if (*value != 0) { + err = QTMetaDataGetItemProperty(metaDataRef, item, propClass, id, propSize, *value, size); + + if (err == noErr && (type == 'code' || type == 'itsk' || type == 'itlk')) { + // convert from native endian to big endian + OSTypePtr pType = (OSTypePtr)*value; + *pType = EndianU32_NtoB(*pType); + } + } + else + return -1; } return err; @@ -153,10 +157,14 @@ static UInt32 getMetaType(QTMetaDataRef metaDataRef, QTMetaDataItem item) OSStatus err = readMetaValue( metaDataRef, item, kPropertyClass_MetaDataItem, kQTMetaDataItemPropertyID_DataType, &value, &ignore); - UInt32 type = *((UInt32 *) value); - if (value) - free(value); - return type; + if (err == noErr) { + UInt32 type = *((UInt32 *) value); + if (value) + free(value); + return type; + } + + return 0; } static QString cFStringToQString(CFStringRef str) @@ -179,23 +187,26 @@ static QString getMetaValue(QTMetaDataRef metaDataRef, QTMetaDataItem item, SInt QTPropertyValuePtr value = 0; ByteCount size = 0; OSStatus err = readMetaValue(metaDataRef, item, kPropertyClass_MetaDataItem, id, &value, &size); - QString string; - UInt32 dataType = getMetaType(metaDataRef, item); - switch (dataType){ - case kQTMetaDataTypeUTF8: - case kQTMetaDataTypeMacEncodedText: - string = cFStringToQString(CFStringCreateWithBytes(0, (UInt8*)value, size, kCFStringEncodingUTF8, false)); - break; - case kQTMetaDataTypeUTF16BE: - string = cFStringToQString(CFStringCreateWithBytes(0, (UInt8*)value, size, kCFStringEncodingUTF16BE, false)); - break; - default: - break; + + if (err == noErr) { + UInt32 dataType = getMetaType(metaDataRef, item); + switch (dataType){ + case kQTMetaDataTypeUTF8: + case kQTMetaDataTypeMacEncodedText: + string = cFStringToQString(CFStringCreateWithBytes(0, (UInt8*)value, size, kCFStringEncodingUTF8, false)); + break; + case kQTMetaDataTypeUTF16BE: + string = cFStringToQString(CFStringCreateWithBytes(0, (UInt8*)value, size, kCFStringEncodingUTF16BE, false)); + break; + default: + break; + } + + if (value) + free(value); } - if (value) - free(value); return string; } @@ -234,10 +245,11 @@ void QT7PlayerMetaDataControl::updateTags() #ifdef QUICKTIME_C_API_AVAILABLE QTMetaDataRef metaDataRef; OSStatus err = QTCopyMovieMetaData([movie quickTimeMovie], &metaDataRef); - - readFormattedData(metaDataRef, kQTMetaDataStorageFormatUserData, metaMap); - readFormattedData(metaDataRef, kQTMetaDataStorageFormatQuickTime, metaMap); - readFormattedData(metaDataRef, kQTMetaDataStorageFormatiTunes, metaMap); + if (err == noErr) { + readFormattedData(metaDataRef, kQTMetaDataStorageFormatUserData, metaMap); + readFormattedData(metaDataRef, kQTMetaDataStorageFormatQuickTime, metaMap); + readFormattedData(metaDataRef, kQTMetaDataStorageFormatiTunes, metaMap); + } #else NSString *name = [movie attributeForKey:@"QTMovieDisplayNameAttribute"]; metaMap.insert(QLatin1String("nam"), QString::fromUtf8([name UTF8String])); |