Core Audio input: Added Codec info reporting

CQTexperiment
Christopher Snowhill 2021-10-01 20:22:26 -07:00
parent cb70b066d7
commit 0ec1ae4c47
2 changed files with 24 additions and 2 deletions

View File

@ -21,6 +21,7 @@
#import <Cocoa/Cocoa.h>
#include <AudioToolbox/AudioFile.h>
#include <AudioToolbox/AudioFormat.h>
#include <AudioToolbox/ExtendedAudioFile.h>
#import "Plugin.h"
@ -43,6 +44,8 @@
int channels;
float frequency;
long totalFrames;
NSString* codec;
}
@end

View File

@ -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];
}