0

In the new iOS 9.1 when sets the AudioSession requesting a fix buffer size, the OS returns a smaller buffer. Why does that happen?? In the early versions <9.1 it worked as a charm

// Create a new audio input queue
OSStatus result = AudioQueueNewInput(&mAudioFormat,
                                     IOSAudioRecorder::RecorderCallback,
                                     this,                  // userData
                                     nullptr,               // run loop
                                     kCFRunLoopCommonModes, // run loop mode
                                     0,                     // flags
                                     &mAudioQueue);
if (result != 0)
{
    Logger::Error(this, "Failed to create new audio input queue, result: ", result);
    mAudioQueue = nullptr;
}
else
{
    // Allocate memory for the buffers
    for (unsigned int i = 0; i < mNumBuffers; i++)
    {
        AudioQueueAllocateBuffer(mAudioQueue, mBufferFrames * sizeof(short), &mInputBuffer[i]);
        mOutputBuffer[i] = new short[mBufferFrames];
    }
}

And in the "RecorderCallback" I receive buffers smaller than the requested.

Any clue why does that happen?

4

1 回答 1

1

此音频队列分配调用指定的缓冲区大小是可以返回的最大值。iOS 设备硬件可以自由地返回更少的数据。如果您需要固定长度的数据块,您的应用程序必须适应这种可能较小的大小,并且/或者可能必须连接多个返回的缓冲区(例如在无锁循环 FIFO 中)。

于 2015-11-06T19:35:12.507 回答