void MyAudioQueueOutputCallback( void* inClientData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer) { // this is called by the audio queue when it has finished decoding our data. // The buffer is now free to be reused. MyData* myData = (MyData*)inClientData; unsigned int bufIndex = MyFindQueueBuffer(myData, inBuffer); // signal waiting thread that the buffer is free. pthread_mutex_lock(&myData->mutex); myData->inuse[bufIndex] = false; pthread_cond_signal(&myData->cond); pthread_mutex_unlock(&myData->mutex); }
void PianobarAudioQueueOutputCallback(void* inClientData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer) { // this is called by the audio queue when it has finished decoding our data. // The buffer is now free to be reused. struct audioPlayer* player = (struct audioPlayer*)inClientData; if (player->mode != PLAYER_FREED) { unsigned int bufIndex = MyFindQueueBuffer(player, inBuffer); // signal waiting thread that the buffer is free. pthread_mutex_lock(&player->mutex); player->inuse[bufIndex] = false; player->songDuration = EstimatedDuration(player); pthread_cond_signal(&player->cond); pthread_mutex_unlock(&player->mutex); } }