Ios 核心音频编解码器错误,未使用“kAudioFormatLinearPCM”`
我遇到了一个错误 我只想要kAudioFormatXXX而不是PCM,但是有错误Ios 核心音频编解码器错误,未使用“kAudioFormatLinearPCM”`,ios,core-audio,codec,Ios,Core Audio,Codec,我遇到了一个错误 我只想要kAudioFormatXXX而不是PCM,但是有错误 Error: Error Domain=NSOSStatusErrorDomain Code=1718449215 "The operation couldn’t be completed. (OSStatus error 1718449215.)" Error Code responded 1718449215 in file /Users/breaklee/Documents/project/ginav/g
Error: Error Domain=NSOSStatusErrorDomain Code=1718449215 "The operation
couldn’t be completed. (OSStatus error 1718449215.)"
Error Code responded 1718449215 in file
/Users/breaklee/Documents/project/ginav/ginav-
mobile/ginav-mobile/AudioProcessor.m on line 281
281行是代码的结尾
如何正确初始化此代码
我想使用iLBC或其他编解码器,而不是PCM
音频流基本描述音频格式
audioFormat.mSampleRate = SAMPLE_RATE;
audioFormat.mFormatID = kAudioFormatAC3;
audioFormat.mFormatFlags = kAudioFormatFlagIsPacked |
kAudioFormatFlagIsSignedInteger;
audioFormat.mFramesPerPacket = 1;
audioFormat.mChannelsPerFrame = 1;
audioFormat.mBitsPerChannel = 8;
audioFormat.mBytesPerPacket = 1;
audioFormat.mBytesPerFrame = 1;
// set the format on the output stream
status = AudioUnitSetProperty(_audioUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output,
kInputBus,
&audioFormat,
sizeof(audioFormat));
[self hasError:status file:__FILE__ line:__LINE__];
// set the format on the input stream
status = AudioUnitSetProperty(_audioUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input,
kOutputBus,
&audioFormat,
sizeof(audioFormat));
[self hasError:status file:__FILE__ line:__LINE__];
/**
We need to define a callback structure which holds
a pointer to the recordingCallback and a reference to
the audio processor object
*/
AURenderCallbackStruct callbackStruct;
// set recording callback
callbackStruct.inputProc = recordingCallback; // recordingCallback pointer
callbackStruct.inputProcRefCon = (__bridge void*)(self);
// set input callback to recording callback on the input bus
status = AudioUnitSetProperty(_audioUnit,
kAudioOutputUnitProperty_SetInputCallback,
kAudioUnitScope_Global,
kInputBus,
&callbackStruct,
sizeof(callbackStruct));
[self hasError:status file:__FILE__ line:__LINE__];
/*
We do the same on the output stream to hear what is coming
from the input stream
*/
callbackStruct.inputProc = playbackCallback;
callbackStruct.inputProcRefCon = (__bridge void*)(self);
// set playbackCallback as callback on our renderer for the output bus
status = AudioUnitSetProperty(_audioUnit,
kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Global,
kOutputBus,
&callbackStruct,
sizeof(callbackStruct));
[self hasError:status file:__FILE__ line:__LINE__];
// reset flag to 0
flag = 0;
/*
we need to tell the audio unit to allocate the render buffer,
that we can directly write into it.
*/
status = AudioUnitSetProperty(_audioUnit,
kAudioUnitProperty_ShouldAllocateBuffer,
kAudioUnitScope_Output,
kInputBus,
&flag,
sizeof(flag));
// kAudioFormatUnsupportedDataFormatError
// Initialize the Audio Unit and cross fingers =)
status = AudioUnitInitialize(_audioUnit);
NSError *error = [NSError errorWithDomain:NSOSStatusErrorDomain
code:status
userInfo:nil];
NSLog(@"Error: %@", [error description]);
[self hasError:status file:__FILE__ line:__LINE__];
NSLog(@"Started");
如果您的目标是iOS,那么device.ah上不支持AC3,但我改为iLBC。也有同样的错误。如何在我的应用程序中使用iLBC编解码器@卡恩西。如果你的编解码器不受iOS支持,你应该使用第三方库。找到:。@cahn谢谢。这是不受支持的编码流。