I was working on streaming audio live using the Audio Streaming Services library (based on Matt Ghallager's tutorial) and I kept on crashing at this part:
err = AudioQueueStart(audioQueue, NULL);
if (err)
{
[self failWithErrorCode:AS_AUDIO_QUEUE_START_FAILED];
return;
}
the error code is: kAudioDeviceUnsupportedFormatError.. this guy is defined in CoreAudio/AudioHardware.h, which seems to be a hardware related problem. I couldn't find much useful information about this error on the web.
The interesting part is that earlier on I faced a similar problem while attempting this:
// create the audio
err = AudioQueueNewOutput(&asbd, MyAudioQueueOutputCallback, self, NULL, NULL, 0, &
if (err)
{
[self failWithErrorCode:AS_AUDIO_QUEUE_CREATION_FAILED];
return;
}
(the same problem faced in this post, but the author of the post mistakenly attributed their error code to AudioQueueStart rather than AudioQueueNewOutput)
I got this error code: kAudioFormatUnsupportedDataFormatError.. and my remedy was manually adding this code:
asbd.mFormatID = kAudioFormatMPEGLayer3;
since I discovered that calling
AudioFileStreamGetProperty(inAudioFileStream, kAudioFileStreamProperty_DataFormat, &asbdSize, &asbd);
initially gave me kAudioFormatMPEGLayer1 as the mFormatID rather than kAudioFormatMPEGLayer3, which is .mp3 which is what the audio file i'm playing actually is.
Finally.. probably the first time I noticed something was wrong was when I initially called this function:
AudioFileStreamOpen((__bridge void*)streamer, ASPropertyListenerProc, ASPacketsProc,
0, &(streamer->audioFileStream));
the first time I didn't provide the inFileTypeHint to the function it resulted in the
AudioFileStreamParseBytes(streamer->audioFileStream, inDataByteSize, inData, 0);
call to fail to parse the bytes.. (specifically.. I got the Parse bytes failed. err: typ? 1954115647 error message, which is kAudioFileUnsupportedFileTypeError)..
the way I got around that was by (you guessed it) manually adding the file type hint:
streamer->err = AudioFileStreamOpen((__bridge void*)streamer, ASPropertyListenerProc, ASPacketsProc,
kAudioFileMP3Type, &(streamer->audioFileStream));
so you can see.. a problem i've pushed under the rug is finally coming around to bite me.. but i'm not sure why the parser is failing to recognize my audio file type manually.. and why I have to keep on hardcoding that value.. only to have it fail at the end.