diff --git a/Plugins/CoreAudio/CoreAudioDecoder.h b/Plugins/CoreAudio/CoreAudioDecoder.h index 9fae5e922..a13d47e43 100644 --- a/Plugins/CoreAudio/CoreAudioDecoder.h +++ b/Plugins/CoreAudio/CoreAudioDecoder.h @@ -21,6 +21,7 @@ #import #include +#include #include #import "Plugin.h" @@ -43,6 +44,8 @@ int channels; float frequency; long totalFrames; + + NSString* codec; } @end diff --git a/Plugins/CoreAudio/CoreAudioDecoder.m b/Plugins/CoreAudio/CoreAudioDecoder.m index ec9ab2f9d..a83f3576b 100644 --- a/Plugins/CoreAudio/CoreAudioDecoder.m +++ b/Plugins/CoreAudio/CoreAudioDecoder.m @@ -133,12 +133,13 @@ static SInt64 getSizeProc(void* clientData) { { OSStatus err; UInt32 size; + UInt32 asbdSize; AudioStreamBasicDescription asbd; AudioFileID afi; // Get input file information - size = sizeof(asbd); - err = ExtAudioFileGetProperty(_in, kExtAudioFileProperty_FileDataFormat, &size, &asbd); + asbdSize = sizeof(asbd); + err = ExtAudioFileGetProperty(_in, kExtAudioFileProperty_FileDataFormat, &asbdSize, &asbd); if(err != noErr) { err = ExtAudioFileDispose(_in); return NO; @@ -183,6 +184,23 @@ static SInt64 getSizeProc(void* clientData) { bitrate = (_bitrate + 500) / 1000; + CFStringRef formatName; + size = sizeof(formatName); + err = AudioFormatGetProperty(kAudioFormatProperty_FormatName, asbdSize, &asbd, &size, &formatName); + if(err != noErr) { + err = ExtAudioFileDispose(_in); + return NO; + } + + codec = (__bridge NSString *)formatName; + + CFRelease(formatName); + + NSRange range = [codec rangeOfString:@","]; + if (range.location != NSNotFound) { + codec = [codec substringToIndex:range.location]; + } + // Set our properties bitsPerSample = formatBitsPerSample; channels = asbd.mChannelsPerFrame; @@ -307,6 +325,7 @@ static SInt64 getSizeProc(void* clientData) { [NSNumber numberWithFloat:frequency],@"sampleRate", [NSNumber numberWithLong:totalFrames],@"totalFrames", [NSNumber numberWithBool:YES], @"seekable", + codec, @"codec", floatingPoint ? @"host" : @"big", @"endian", nil]; }