We tracked the source of the problem with bad data in the sound buffer that was sent to Core Audio. In particular, one of the stages of sound processing outputs data that was NaN (Not a Number), instead of float in the allowable range +/- 1.0.
It seems that on some devices, if the data contains NaN, it kills the sound of the entire device.
We worked on this by sorting through the audio data, checking the NaN values, and instead converting them to 0.0. Please note that checking if the float is NaN is a weird check (or it seems strange to me). NaN is not equal to anything, including itself.
Some pseudo codes to get around the problem until we get new libraries that have the correct fix:
float *interleavedAudio; // pointer to a buffer of the audio data unsigned int numberOfSamples; // number of left/right samples in the audio buffer unsigned int numberOfLeftRightSamples = numberOfSamples * 2; // number of float values in the audio buffer // loop through each float in the audio data for (unsigned int i = 0; i < numberOfLeftRightSamples; i++) { float *sample = interleavedAudio + i; // NaN is never equal to anything, including itself if( *sample != *sample ) { // This sample is NaN - force it to 0.0 so it doesn't corrupt the audio *sample = 0.0; } }
source share