I am using EZAudio framework (https://github.com/syedhali/EZAudio) and when trying to initialize my output with a custom AudioStreamBasicDescription like so...
- (void)openMediaPlayer {
// Initialize the EZOutput instance and assign it a delegate to provide the output audio data
AudioStreamBasicDescription audioDesc;
audioDesc.mFormatID = kAudioFormatLinearPCM;
audioDesc.mSampleRate = 44100;
audioDesc.mChannelsPerFrame = 2;
audioDesc.mBytesPerFrame = 4;
audioDesc.mFramesPerPacket = 1;
audioDesc.mBytesPerPacket = 4;
audioDesc.mBitsPerChannel = 16;
audioDesc.mReserved = 0;
self.output = [EZOutput outputWithDataSource:self withAudioStreamBasicDescription:audioDesc];
self.currentAudioPieceIndex = 0;
}
I get the error "Error: Couldn't initialize output unit ('fmt?')"
What does this mean? AudioDesc is set with sane defaults for PCM 16 bit stereo audio.
Update: When I use the debugger I found I was getting OSStatus 1718449215.
It turns out you have to set
audioDesc.mFormatFlags = kAudioFormatFlagIsPacked | kAudioFormatFlagIsSignedInteger;
When your audio format is PCM.