AudioQueue не выводит звук

У меня проблемы со звуком в моем эксперименте с iPhone, и у меня нет идей.

Вот мой обратный вызов для заполнения буфера аудио очереди

void AudioOutputCallback(void *user, AudioQueueRef refQueue, AudioQueueBufferRef inBuffer)
{
     NSLog(@"callback called");
     inBuffer->mAudioDataByteSize = 1024;

     gme_play((Music_Emu*)user, 1024, (short *)inBuffer->mAudioData);

     AudioQueueEnqueueBuffer(refQueue, inBuffer, 0, NULL);
}

Я настраиваю очередь аудио, используя следующий фрагмент

    // Create stream description
    AudioStreamBasicDescription streamDescription;
    streamDescription.mSampleRate = 44100;
    streamDescription.mFormatID = kAudioFormatLinearPCM;
    streamDescription.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
    streamDescription.mBytesPerPacket = 1024;
    streamDescription.mFramesPerPacket = 1024 / 4;
    streamDescription.mBytesPerFrame = 2 * sizeof(short);
    streamDescription.mChannelsPerFrame = 2;
    streamDescription.mBitsPerChannel = 16;

    AudioQueueNewOutput(&streamDescription, AudioOutputCallback, theEmu, NULL, NULL, 0, &theAudioQueue);

    OSStatus errorCode = AudioQueueAllocateBuffer(theAudioQueue, 1024, &someBuffer);

    if( errorCode )
    {
        NSLog(@"Cannot allocate buffer");
    }

    AudioOutputCallback(theEmu, theAudioQueue, someBuffer);

    AudioQueueSetParameter(theAudioQueue, kAudioQueueParam_Volume, 1.0);

    AudioQueueStart(theAudioQueue, NULL);

Библиотека, которую я использую, выводит линейный PCM 16 бит 44 Гц.


person Michaël Larouche    schedule 01.08.2010    source источник


Ответы (1)


Я обычно использую 3 буфера. Вам нужно как минимум 2, потому что, когда один играется, другой заполняется вашим кодом. Если у вас есть только один, у вас не будет достаточно времени, чтобы заполнить тот же буфер и повторно поставить его в очередь, чтобы воспроизведение было бесшовным. Так что это, вероятно, просто останавливает вашу очередь, потому что у нее закончились буферы.

person lucius    schedule 05.08.2010