每当我运行以下代码时,它就会在AudioConverterNew()上崩溃。但是,如果我更改为pathForResource行中的PCM文件(例如Test02.aif),它运行良好,并能够播放该文件。有人可以建议我尝试一下吗?
NSString *filePath = [[NSBundle mainBundle] pathForResource: @"Test01" ofType:@"m4a"];
CFURLRef audioURL = (__bridge CFURLRef) [NSURL fileURLWithPath:filePath];
// open the input audio file
AudioFileOpenURL(audioURL, kAudioFileReadPermission, 0, &gSourceAudioFileID);
AudioConverterRef myConverter;
// get file's asbd
UInt32 size;
AudioStreamBasicDescription fileASBD = {0};
size = sizeof(AudioStreamBasicDescription);
AudioFileGetProperty(gSourceAudioFileID,
kAudioFilePropertyDataFormat,
&size,
&fileASBD);
if (fileASBD.mFormatID == kAudioFormatMPEGLayer3) NSLog(@"its mp3");
NSLog(@"fileASDB formatId: %d", (unsigned int)fileASBD.mBytesPerFrame);
//NSLog(@"file formatId: %d", (unsigned int)fileASBD.mFormatID);
OSStatus error= AudioConverterNew(&fileASBD,
&thruFormat ,
&(myConverter));
NSLog(@"error: %d", (int)error);