Пример #1
0
// this is called by the audio queue when it has finished decoding our data. 
// The buffer is now free to be reused.
void Audio_Queue::audioQueueOutputCallback(void *inClientData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer)
{
    Audio_Queue *audioQueue = static_cast<Audio_Queue*>(inClientData);
    unsigned int bufIndex = audioQueue->findQueueBuffer(inBuffer);
    
    AQ_TRACE("signaling buffer free for inuse %i....\n", bufIndex);
    
    // signal waiting thread that the buffer is free.
    pthread_mutex_lock(audioQueue->m_bufferInUseMutex);
    audioQueue->m_bufferInUse[bufIndex] = false;
    pthread_cond_signal(audioQueue->m_bufferFreeCondition);
    pthread_mutex_unlock(audioQueue->m_bufferInUseMutex);
    
    AQ_TRACE("signal sent!\n");
}
Пример #2
0
// this is called by the audio queue when it has finished decoding our data. 
// The buffer is now free to be reused.
void Audio_Queue::audioQueueOutputCallback(void *inClientData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer)
{
    Audio_Queue *audioQueue = static_cast<Audio_Queue*>(inClientData);    
    unsigned int bufIndex = audioQueue->findQueueBuffer(inBuffer);
    
    assert(audioQueue->m_bufferInUse[bufIndex]);
    
    audioQueue->m_bufferInUse[bufIndex] = false;
    audioQueue->m_buffersUsed--;
    
    if (audioQueue->m_buffersUsed == 0 && !audioQueue->m_queuedHead && audioQueue->m_delegate) {
        audioQueue->m_delegate->audioQueueBuffersEmpty();
    } else if (audioQueue->m_waitingOnBuffer) {
        audioQueue->m_waitingOnBuffer = false;
        audioQueue->enqueueCachedData();
    }
}