So oddly, this error happens only once in a while, when we are setting up the audio queue (even though I'm doing everything the same way). Device iPhone 5, iOS8.3:
mediaserverd[37] <Error>: 15:14:24.594 ERROR: [0x2883000] >aq> 323: AudioConverterNew from AudioQueueNew returned 'fmt?'
io: 0 ch, 44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved
client: 0 ch, 44100 Hz, 'lpcm' (0x0000000C) 16-bit signed integer
Here's the code that triggers it.
SetupAudioFormat(kAudioFormatLinearPCM);
// create the queue
XThrowIfError(AudioQueueNewInput(
&mRecordFormat,
MyInputBufferHandler,
this /* userData */,
NULL /* run loop */, NULL /* run loop mode */,
0 /* flags */, &mQueue), "AudioQueueNewInput failed");
where mRecordFormat is setup like:
void AQRecorder::SetupAudioFormat(UInt32 inFormatID)
{
memset(&mRecordFormat, 0, sizeof(mRecordFormat));
UInt32 size = sizeof(mRecordFormat.mSampleRate);
mRecordFormat.mSampleRate=[AVAudioSession sharedInstance].sampleRate;
size = sizeof(mRecordFormat.mChannelsPerFrame);
mRecordFormat.mChannelsPerFrame=(UInt32)[AVAudioSession sharedInstance].inputNumberOfChannels;
mRecordFormat.mFormatID = inFormatID;
mRecordFormat.mBytesPerFrame =mRecordFormat.mChannelsPerFrame * sizeof (SInt16);
if (inFormatID == kAudioFormatLinearPCM)
{
// if we want pcm, default to signed 16-bit little-endian
mRecordFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
mRecordFormat.mBitsPerChannel = 16;
mRecordFormat.mBytesPerPacket = mRecordFormat.mBytesPerFrame = (mRecordFormat.mBitsPerChannel / 8) * mRecordFormat.mChannelsPerFrame;
mRecordFormat.mFramesPerPacket = 1;
} else if(inFormatID==kAudioFileAIFFType) {
mRecordFormat.mFramesPerPacket = 1;
mRecordFormat.mFormatFlags =
kLinearPCMFormatFlagIsBigEndian
| kLinearPCMFormatFlagIsSignedInteger
| kLinearPCMFormatFlagIsPacked;
}
}
My interpretation of the error is that the phone is recording as 32-bit little-endian float, deinterleaved and I'm trying to setup a queue with a format that is 16-bit signed integer. But why don't I get the error everytime? How to fix it?