OSystem_IPHONE::~OSystem_IPHONE() { AudioQueueDispose(s_AudioQueue.queue, true); delete _mixer; free(_gameScreenRaw); free(_gameScreenConverted); }
void Audio_Queue::cleanup() { if (!initialized()) { AQ_TRACE("%s: warning: attempt to cleanup an uninitialized audio queue. return.\n", __PRETTY_FUNCTION__); return; } if (AudioQueueDispose(m_outAQ, true) != 0) { AQ_TRACE("%s: AudioQueueDispose failed!\n", __PRETTY_FUNCTION__); } m_outAQ = 0; m_fillBufferIndex = m_bytesFilled = m_packetsFilled = m_buffersUsed = m_processedPacketsSizeTotal = m_processedPacketsCount = 0; for (size_t i=0; i < AQ_BUFFERS; i++) { m_bufferInUse[i] = false; } queued_packet_t *cur = m_queuedHead; while (cur) { queued_packet_t *tmp = cur->next; free(cur); cur = tmp; } m_queuedHead = m_queuedHead = 0; for (size_t i=0; i < m_cbrPacketDescriptions.size(); i++) { delete[] m_cbrPacketDescriptions[i]; } m_cbrPacketDescriptions.clear(); m_waitingOnBuffer = false; m_lastError = noErr; }
static void auplay_destructor(void *arg) { struct auplay_st *st = arg; uint32_t i; pthread_mutex_lock(&st->mutex); st->wh = NULL; pthread_mutex_unlock(&st->mutex); audio_session_disable(); if (st->queue) { AudioQueuePause(st->queue); AudioQueueStop(st->queue, true); for (i=0; i<ARRAY_SIZE(st->buf); i++) if (st->buf[i]) AudioQueueFreeBuffer(st->queue, st->buf[i]); AudioQueueDispose(st->queue, true); } mem_deref(st->ap); pthread_mutex_destroy(&st->mutex); }
static void gst_atdec_destroy_queue (GstATDec * atdec, gboolean drain) { AudioQueueStop (atdec->queue, drain); AudioQueueDispose (atdec->queue, true); atdec->queue = NULL; }
void free_aqData() { AudioQueueDispose (aqData.mQueue, true); AudioFileClose (aqData.mAudioFile); free (aqData.mPacketDescs); }
/* destructor */ static tsk_object_t* tdav_consumer_audioqueue_dtor(tsk_object_t * self) { tdav_consumer_audioqueue_t *consumer = self; if(consumer){ // Stop the consumer if not done if(consumer->started){ tdav_consumer_audioqueue_stop(self); } // Free all buffers and dispose the queue if (consumer->queue) { tsk_size_t i; for(i=0; i<CoreAudioPlayBuffers; i++){ AudioQueueFreeBuffer(consumer->queue, consumer->buffers[i]); } AudioQueueDispose(consumer->queue, true); } /* deinit base */ tdav_consumer_audio_deinit(TDAV_CONSUMER_AUDIO(consumer)); } return self; }
void app_CloseSound(void) { if( soundInit == 1 ) { AudioQueueDispose(in.queue, true); soundInit = 0; } }
QueueAudioData::~QueueAudioData() { if (running) stop(); if (initialized) AudioQueueDispose(audioQueue, false); }
void Audio_Queue::cleanup() { if (!initialized()) { AQ_TRACE("%s: warning: attempt to cleanup an uninitialized audio queue. return.\n", __PRETTY_FUNCTION__); return; } Stream_Configuration *config = Stream_Configuration::configuration(); if (m_state != IDLE) { AQ_TRACE("%s: attemping to cleanup the audio queue when it is still playing, force stopping\n", __PRETTY_FUNCTION__); AudioQueueRemovePropertyListener(m_outAQ, kAudioQueueProperty_IsRunning, audioQueueIsRunningCallback, this); AudioQueueStop(m_outAQ, true); setState(IDLE); } if (AudioQueueDispose(m_outAQ, true) != 0) { AQ_TRACE("%s: AudioQueueDispose failed!\n", __PRETTY_FUNCTION__); } m_outAQ = 0; m_fillBufferIndex = m_bytesFilled = m_packetsFilled = m_buffersUsed = 0; for (size_t i=0; i < config->bufferCount; i++) { m_bufferInUse[i] = false; } m_lastError = noErr; }
/*auDestroy-----------------------------------------------*/ Audio* auDestroy(Audio* self) { if(self != NULL) { if(self->isPlaying) auPause(self); #if defined __APPLE__ int i; for(i=0; i<AU_NUM_AUDIO_BUFFERS; i++) if(self->buffers[i] != NULL) AudioQueueFreeBuffer(self->queue, self->buffers[i]); if(self->queue != NULL) AudioQueueDispose(self->queue, YES); #elif defined __linux__ if(self->device != NULL) { snd_pcm_close(self->device); self->device = NULL; } if(self->sampleBuffer) free(self->sampleBuffer); //if(self->thread != NULL) //pthread_detach(self->thread); #endif free(self); } return (Audio*)NULL; }
void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB) { AQCallbackStruct *aqc; short *coreAudioBuffer; short sample; int i; aqc = (AQCallbackStruct *) in; coreAudioBuffer = (short*) outQB->mAudioData; printf("Sync: %ld / %ld\n", aqc->playPtr, aqc->sampleLen); if (aqc->playPtr >= aqc->sampleLen) { AudioQueueDispose(aqc->queue, true); return; } if (aqc->frameCount > 0) { outQB->mAudioDataByteSize = 4 * aqc->frameCount; for(i=0; i<aqc->frameCount*2; i+=2) { if (aqc->playPtr > aqc->sampleLen) sample = 0; else sample = (aqc->pcmBuffer[aqc->playPtr]); coreAudioBuffer[i] = sample; coreAudioBuffer[i+1] = sample; aqc->playPtr++; } AudioQueueEnqueueBuffer(inQ, outQB, 0, NULL); } }
/* destructor */ static tsk_object_t* tdav_producer_audioqueue_dtor(tsk_object_t * self) { tdav_producer_audioqueue_t *producer = self; if(producer){ // Stop the producer if not done if(producer->started){ tdav_producer_audioqueue_stop(self); } // Free all buffers and dispose the queue if (producer->queue) { tsk_size_t i; for(i=0; i<CoreAudioRecordBuffers; i++){ AudioQueueFreeBuffer(producer->queue, producer->buffers[i]); } AudioQueueDispose(producer->queue, true); } /* deinit base */ tdav_producer_audio_deinit(TDAV_PRODUCER_AUDIO(producer)); } return self; }
OSStatus darwin_free_context ( darwin_context* io_context ) { OSStatus result = kAudio_ParamError; if( NULL != io_context ) { CPC_LOG_STRING( CPC_LOG_LEVEL_DEBUG, "Stopping audio queue..." ); result = AudioQueueStop( io_context->audio_queue, true ); CPC_LOG_STRING( CPC_LOG_LEVEL_DEBUG, "Stopped audio queue." ); if( noErr == result ) { for( UINT32 i = 0; i < io_context->number_of_buffers; i++ ) { if( NULL != io_context->audio_buffers[ i ] ) { result = AudioQueueFreeBuffer ( io_context->audio_queue, io_context->audio_buffers[ i ] ); if( result ) { CPC_ERROR ( "Could not free queue buffer: 0x%x.", result ); CPC_PRINT_CODE( CPC_LOG_LEVEL_ERROR, result ); } } } result = AudioQueueDispose( io_context->audio_queue, true ); if( result ) { CPC_ERROR( "Could not dispose of queue: 0x%x.", result ); CPC_PRINT_CODE( CPC_LOG_LEVEL_ERROR, result ); } } else { CPC_ERROR( "Could not stop audio queue: 0x%x.", result ); CPC_PRINT_CODE( CPC_LOG_LEVEL_ERROR, result ); } } return( result ); }
void app_CloseSound(void) { LOGDEBUG("app_CloseSound.AudioQueueDispose()"); soundInit = 0; #if 1 AudioQueueDispose(in.queue, true); #endif }
void Audio_Queue::init() { OSStatus err = noErr; cleanup(); // create the audio queue err = AudioQueueNewOutput(&m_streamDesc, audioQueueOutputCallback, this, CFRunLoopGetCurrent(), NULL, 0, &m_outAQ); if (err) { AQ_TRACE("%s: error in AudioQueueNewOutput\n", __PRETTY_FUNCTION__); m_lastError = err; if (m_delegate) { m_delegate->audioQueueInitializationFailed(); } return; } Stream_Configuration *configuration = Stream_Configuration::configuration(); // allocate audio queue buffers for (unsigned int i = 0; i < configuration->bufferCount; ++i) { err = AudioQueueAllocateBuffer(m_outAQ, configuration->bufferSize, &m_audioQueueBuffer[i]); if (err) { /* If allocating the buffers failed, everything else will fail, too. * Dispose the queue so that we can later on detect that this * queue in fact has not been initialized. */ AQ_TRACE("%s: error in AudioQueueAllocateBuffer\n", __PRETTY_FUNCTION__); (void)AudioQueueDispose(m_outAQ, true); m_outAQ = 0; m_lastError = err; if (m_delegate) { m_delegate->audioQueueInitializationFailed(); } return; } } // listen for kAudioQueueProperty_IsRunning err = AudioQueueAddPropertyListener(m_outAQ, kAudioQueueProperty_IsRunning, audioQueueIsRunningCallback, this); if (err) { AQ_TRACE("%s: error in AudioQueueAddPropertyListener\n", __PRETTY_FUNCTION__); m_lastError = err; return; } if (m_initialOutputVolume != 1.0) { setVolume(m_initialOutputVolume); } }
void app_CloseSound(void) { LOGDEBUG("app_CloseSound.AudioQueueDispose()"); if( soundInit == 1 ) { AudioQueueDispose(in.queue, true); soundInit = 0; } }
AudioOutputDeviceCoreAudio::~AudioOutputDevice() { atomic_set(&(aqPlayerState.mIsRunning), 0); destroyMutex.Lock(); AudioQueueDispose(aqPlayerState.mQueue, true); destroyMutex.Unlock(); delete [] aqPlayerState.mBuffers; CurrentDevice.RemoveListener(this); }
void SICloseSound(void) { if( SI_SoundIsInit == 1 ) { AudioQueueDispose(SI_AQCallbackStruct.queue, true); SI_SoundIsInit = 0; SI_AudioIsOnHold = 1; } }
int sound_close_AudioQueue(){ if( soundInit == 1 ) { AudioQueueDispose(in.queue, true); soundInit = 0; } }
long AudioStreamDecoder::Stop() { long err = 0; if (mStream) { err = AudioFileStreamClose(mStream); CARP_IF(err, "AudioFileStreamClose returned %ld\n", err); mStream = NULL; } if (mStarted) { err = AudioQueueFlush(mQueue); BAIL_IF(err, "AudioQueueFlush returned %ld\n", err); err = AudioQueueStop(mQueue, true); BAIL_IF(err, "AudioQueueStop returned %ld\n", err); err = pthread_mutex_lock(&mMutex); BAIL_IF(err, "pthread_mutex_lock returned %ld\n", err); if (!mFinished) { err = pthread_cond_wait(&mCond, &mMutex); BAIL_IF(err, "pthread_cond_wait returned %ld\n", err); } err = pthread_mutex_unlock(&mMutex); BAIL_IF(err, "pthread_mutex_unlock returned %ld\n", err); mStarted = false; mFinished = false; } if (mQueue) { for (int i = 0; i < kBufferCount; i++) { if (mBuffers[i]) { err = AudioQueueFreeBuffer(mQueue, mBuffers[i]); CARP_IF(err, "AudioQueueFreeBuffer returned %ld\n", err); } } err = AudioQueueDispose(mQueue, true); CARP_IF(err, "AudioQueueDispose returned %ld\n", err); mQueue = NULL; } bail: return err; }
OSystem_IPHONE::~OSystem_IPHONE() { AudioQueueDispose(s_AudioQueue.queue, true); delete _mixer; // Prevent accidental freeing of the screen texture here. This needs to be // checked since we might use the screen texture as framebuffer in the case // of hi-color games for example. Otherwise this can lead to a double free. if (_framebuffer.getPixels() != _videoContext->screenTexture.getPixels()) _framebuffer.free(); _mouseBuffer.free(); }
void Teardown() { if (mQueue) AudioQueueDispose(mQueue, true); for (UInt32 i=0; i < mBGFileInfo.size(); i++) if (mBGFileInfo[i]->mAFID) AudioFileClose(mBGFileInfo[i]->mAFID); if (mPacketDescs) delete mPacketDescs; }
/***************************************************************************** * Close: close the audio device *****************************************************************************/ static void Close ( vlc_object_t *p_this ) { aout_instance_t *p_aout = (aout_instance_t *)p_this; struct aout_sys_t * p_sys = p_aout->output.p_sys; msg_Dbg(p_aout, "Stopping AudioQueue"); AudioQueueStop(p_sys->audioQueue, false); msg_Dbg(p_aout, "Disposing of AudioQueue"); AudioQueueDispose(p_sys->audioQueue, false); free (p_sys); }
int sound_close_AudioQueue(){ if( soundInit == 1 ) { AudioQueueDispose(in.queue, true); soundInit = 0; head = 0; tail = 0; } return 1; }
void StateDestroy(State *state) { if (state->audioQueue) { AudioQueueDispose(state->audioQueue, false); } if (state->audioFile) { AudioFileClose(state->audioFile); } free(state); }
/***************************************************************************** * Close: close the audio device *****************************************************************************/ static void Close ( vlc_object_t *p_this ) { audio_output_t *p_aout = (audio_output_t *)p_this; struct aout_sys_t * p_sys = p_aout->sys; msg_Dbg(p_aout, "Stopping AudioQueue"); AudioQueueStop(p_sys->audioQueue, false); msg_Dbg(p_aout, "Disposing of AudioQueue"); AudioQueueDispose(p_sys->audioQueue, false); aout_PacketDestroy(p_aout); free (p_sys); }
/** @internal @This destroys the current audioqueue * @param upipe description structure of the pipe */ static void upipe_osx_audioqueue_sink_remove(struct upipe *upipe) { struct upipe_osx_audioqueue_sink *osx_audioqueue = upipe_osx_audioqueue_sink_from_upipe(upipe); if (unlikely(!osx_audioqueue->queue)) { return; } AudioQueueStop(osx_audioqueue->queue, true); AudioQueueDispose(osx_audioqueue->queue, true); osx_audioqueue->queue = NULL; upipe_notice(upipe, "audioqueue destroyed"); }
void Recorder::stop() { AudioQueueStop ( // 6 aqData.mQueue, // 7 true // 8 ); aqData.mIsRunning = false; // 9 AudioQueueDispose ( // 1 aqData.mQueue, // 2 true // 3 ); AudioFileClose (aqData.mAudioFile); // 4 }
DZAudioQueuePlayer::~DZAudioQueuePlayer() { // AudioQueueDispose will free its audio queue buffers. if (this->_queue != NULL) { AudioQueueDispose(this->_queue, true); } if (this->_parser != NULL) { AudioFileStreamClose(this->_parser); } // Destructor of DZAudioQueueBufferList shall not free any // audio queue buffers allocated by the audio queue. delete this->_bufferList; }
static void aq_stop_w(MSFilter * f) { AQData *d = (AQData *) f->data; if (d->write_started == TRUE) { ms_mutex_lock(&d->mutex); d->write_started = FALSE; /* avoid a deadlock related to buffer conversion in callback */ ms_mutex_unlock(&d->mutex); #if 0 AudioConverterDispose(d->writeAudioConverter); #endif AudioQueueStop(d->writeQueue, true); AudioQueueDispose(d->writeQueue, true); } }