Пример #1
0
void ca_close(phastream_t *as) {
	ca_dev *cadev = (ca_dev *) as->drvinfo;

	DBG_DYNA_AUDIO_DRV("** Closing audio stream\n");


	verify_noerr(AudioDeviceStop(get_audiodeviceid(cadev->inputID), input_proc));

	clean_input_device(as);

	verify_noerr(AudioOutputUnitStop(cadev->outputAU));
	verify_noerr(AudioUnitUninitialize (cadev->outputAU));

	printf("phad_coreaudio:ca_close:cleaning cadev\n"); // power pc hack 2/2
	
	if (cadev) {
		if (cadev->convertedInputBuffer) {
			free(cadev->convertedInputBuffer);
		}
		cadev->convertedInputBuffer = NULL;
		if (cadev->inputConverter) {
			AudioConverterDispose(cadev->inputConverter);
			cadev->inputConverter = NULL;
		}
		free(cadev);
		as->drvinfo = 0;
	}
}
Пример #2
0
static int close_coreaudio(audio_output_t *ao)
{
	mpg123_coreaudio_t* ca = (mpg123_coreaudio_t*)ao->userptr;

	if (ca) {
		ca->decode_done = 1;
		while(!ca->play_done && ca->play) usleep(10000);
		
		/* No matter the error code, we want to close it (by brute force if necessary) */
		AudioConverterDispose(ca->converter);
		AudioOutputUnitStop(ca->outputUnit);
		AudioUnitUninitialize(ca->outputUnit);
		CloseComponent(ca->outputUnit);
	
	    /* Free the ring buffer */
		sfifo_close( &ca->fifo );
		
		/* Free the conversion buffer */
		if (ca->buffer) {
			free( ca->buffer );
			ca->buffer = NULL;
		}
		
	}
	
	return 0;
}
Пример #3
0
void CoreAudioDriver::disconnect()
{
	OSStatus err = noErr;
	err = AudioOutputUnitStop( m_outputUnit );
	err = AudioUnitUninitialize( m_outputUnit );
	err = AudioComponentInstanceDispose( m_outputUnit );
}
Пример #4
0
gboolean
gst_core_audio_close (GstCoreAudio * core_audio)
{
  OSStatus status;

  /* Uninitialize the AudioUnit */
  status = AudioUnitUninitialize (core_audio->audiounit);
  if (status) {
    GST_ERROR_OBJECT (core_audio, "Failed to uninitialize AudioUnit: %d",
        (int) status);
    return FALSE;
  }

  AudioUnitRemovePropertyListenerWithUserData (core_audio->audiounit,
      kAudioUnitProperty_AudioChannelLayout, _audio_unit_property_listener,
      core_audio);
  AudioUnitRemovePropertyListenerWithUserData (core_audio->audiounit,
      kAudioUnitProperty_StreamFormat, _audio_unit_property_listener,
      core_audio);

  /* core_audio->osxbuf is already locked at this point */
  core_audio->cached_caps_valid = FALSE;
  gst_caps_replace (&core_audio->cached_caps, NULL);

  AudioComponentInstanceDispose (core_audio->audiounit);
  core_audio->audiounit = NULL;
  return TRUE;
}
Пример #5
0
CoreAudioOutput::~CoreAudioOutput()
{
	OSSpinLockLock(_spinlockAU);
	
	if(_au != NULL)
	{
		AudioOutputUnitStop(_au);
		AudioUnitUninitialize(_au);
#if defined(MAC_OS_X_VERSION_10_6) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
		if (IsOSXVersionSupported(10, 6, 0))
		{
			AudioComponentInstanceDispose(_au);
		}
		else
		{
			CloseComponent(_au);
		}
#else
		CloseComponent(_au);
#endif
		_au = NULL;
	}
	
	OSSpinLockUnlock(_spinlockAU);
	
	delete _buffer;
	_buffer = NULL;
	
	free(_spinlockAU);
	_spinlockAU = NULL;
}
Пример #6
0
void CoreAudioDriver::disconnect()
{
	OSStatus err = noErr;
	err = AudioOutputUnitStop( m_outputUnit );
	err = AudioUnitUninitialize( m_outputUnit );
	err = CloseComponent( m_outputUnit );
}
Пример #7
0
/** free all memory allocated by a driver instance
*/
static void coreaudio_driver_delete(coreaudio_driver_t * driver)
{
 	AudioDeviceRemovePropertyListener(driver->device_id, 0, true, kAudioDeviceProcessorOverload, notification);
    free(driver->input_list);
 	AudioUnitUninitialize(driver->au_hal);
	CloseComponent(driver->au_hal);
    free(driver);
}
Пример #8
0
static void au_unconfigure(AUData *d) {
	if (d->write_started==FALSE && d->read_started==FALSE) {
		AudioUnitUninitialize(d->io_unit);
		AudioOutputUnitStop(d->io_unit);
		AudioComponentInstanceDispose (d->io_unit);
		d->started=FALSE;
	}
}
Пример #9
0
void iOSCoreAudioShutdown()
{
    if (audioInstance) {
        AudioOutputUnitStop(audioInstance);
        AudioUnitUninitialize(audioInstance);
        AudioComponentInstanceDispose(audioInstance);
        audioInstance = nil;
    }
}
Пример #10
0
void CCoreAudioUnit::Close()
{
  if (m_Initialized)
    AudioUnitUninitialize(m_Component);
  if (m_Component)
    CloseComponent(m_Component);
  m_Initialized = false;
  m_Component = 0;
}
void AudioLoopImplCocoa::shutdown()
{
    if (initialized)
    {
        AudioOutputUnitStop(audioUnit);
        AudioUnitUninitialize(audioUnit);
        AudioComponentInstanceDispose(audioUnit);
        audioUnit = NULL;
    }
}
Пример #12
0
static void ca_stop_playback(ALCdevice *device)
{
    ca_data *data = (ca_data*)device->ExtraData;
    OSStatus err;

    AudioOutputUnitStop(data->audioUnit);
    err = AudioUnitUninitialize(data->audioUnit);
    if(err != noErr)
        ERR("-- AudioUnitUninitialize failed.\n");
}
Пример #13
0
static void ca_close_playback(ALCdevice *device)
{
    ca_data *data = (ca_data*)device->ExtraData;

    AudioUnitUninitialize(data->audioUnit);
    CloseComponent(data->audioUnit);

    free(data);
    device->ExtraData = NULL;
}
Пример #14
0
void
gst_core_audio_unitialize (GstCoreAudio * core_audio)
{
  AudioUnitUninitialize (core_audio->audiounit);

  if (core_audio->recBufferList) {
    buffer_list_free (core_audio->recBufferList);
    core_audio->recBufferList = NULL;
  }
}
Пример #15
0
static void
osx_output_close(struct audio_output *ao)
{
	struct osx_output *od = (struct osx_output *)ao;

	AudioOutputUnitStop(od->au);
	AudioUnitUninitialize(od->au);

	fifo_buffer_free(od->buffer);
}
Пример #16
0
void AudioDriverCoreAudio::finish() {
	capture_finish();

	if (audio_unit) {
		OSStatus result;

		lock();

		AURenderCallbackStruct callback;
		zeromem(&callback, sizeof(AURenderCallbackStruct));
		result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, kOutputBus, &callback, sizeof(callback));
		if (result != noErr) {
			ERR_PRINT("AudioUnitSetProperty failed");
		}

		if (active) {
			result = AudioOutputUnitStop(audio_unit);
			if (result != noErr) {
				ERR_PRINT("AudioOutputUnitStop failed");
			}

			active = false;
		}

		result = AudioUnitUninitialize(audio_unit);
		if (result != noErr) {
			ERR_PRINT("AudioUnitUninitialize failed");
		}

#ifdef OSX_ENABLED
		AudioObjectPropertyAddress prop;
		prop.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
		prop.mScope = kAudioObjectPropertyScopeGlobal;
		prop.mElement = kAudioObjectPropertyElementMaster;

		result = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &prop, &output_device_address_cb, this);
		if (result != noErr) {
			ERR_PRINT("AudioObjectRemovePropertyListener failed");
		}
#endif

		result = AudioComponentInstanceDispose(audio_unit);
		if (result != noErr) {
			ERR_PRINT("AudioComponentInstanceDispose failed");
		}

		audio_unit = NULL;
		unlock();
	}

	if (mutex) {
		memdelete(mutex);
		mutex = NULL;
	}
}
Пример #17
0
sint_t aubio_audio_unit_stop(aubio_audio_unit_t *o)
{
  if (o->audio_unit == NULL) return -1;
  OSStatus err = AudioOutputUnitStop (o->audio_unit);
  if (err) { AUBIO_WRN("audio_unit: failed stopping audio unit (%d)\n", (int)err); }
  err = AudioUnitUninitialize (o->audio_unit);
  if (err) { AUBIO_WRN("audio_unit: failed unitializing audio unit (%d)\n", (int)err); }
  err = AudioSessionSetActive(false);
  if (err) { AUBIO_WRN("audio_unit: failed stopping audio session (%d)\n", (int)err); }
  return err;
}
Пример #18
0
static void Audio_close(Audio *audio, const char *alias)
{
   /* uninitialize audio device */
   AudioUnitUninitialize(audio->device);

   /* close audio device */
   CloseComponent(audio->device);

   /* close audio file */
   ExtAudioFileDispose(audio->file);
}
Пример #19
0
void
coreaudio_object_close(struct audio_object *object)
{
	struct coreaudio_object *self = to_coreaudio_object(object);
	if(self->initialized) {
		AudioUnitUninitialize(self->outputUnit);
		AudioComponentInstanceDispose(self->outputUnit);
		TPCircularBufferCleanup(&(self->circularBuffer));
		self->initialized = FALSE;
	}

}
Пример #20
0
void CloseDefaultAU () {
	OSStatus err = noErr;

	err = AudioOutputUnitStop (gOutputUnit);
	if (err) { printf ("AudioOutputUnitStop=%ld\n", (long int)err); }

	err = AudioUnitUninitialize (gOutputUnit);
	if (err) { printf ("AudioUnitUninitialize=%ld\n", (long int)err); }

	AudioComponentInstanceDispose (gOutputUnit);

	if (inputBuffer) deallocAudioBufferList(inputBuffer);
}
Пример #21
0
bool coreAudioDevice::localStop(void) 
{
    if (_inUse)
    {
        verify_noerr(AudioOutputUnitStop(theOutputUnit));
        // Clean up
        verify_noerr(AudioUnitUninitialize(theOutputUnit));
        verify_noerr(AudioComponentInstanceDispose(theOutputUnit));
    }
	_inUse=0;
        ADM_usleep(10*1000);
	return 1;
}
Пример #22
0
static void osx_output_close(void *data)
{
	struct osx_output *od = data;

	g_mutex_lock(od->mutex);
	while (od->len) {
		g_cond_wait(od->condition, od->mutex);
	}
	g_mutex_unlock(od->mutex);

	AudioOutputUnitStop(od->au);
	AudioUnitUninitialize(od->au);
	CloseComponent(od->au);
}
Пример #23
0
int sound_close_AudioUnit(){
    
	if( soundInit == 1 )
	{
		OSStatus status = AudioOutputUnitStop(audioUnit);
		checkStatus(status);
        
		AudioUnitUninitialize(audioUnit);
		soundInit = 0;
        head = 0;
        tail = 0;
	}
    
	return 1;
}
Пример #24
0
static tsk_object_t* tdav_audiounit_instance_dtor(tsk_object_t * self)
{ 
	tdav_audiounit_instance_t* inst = self;
	if(inst){
        tsk_safeobj_lock(inst);
		if(inst->audioUnit){
            AudioUnitUninitialize(inst->audioUnit);
            AudioComponentInstanceDispose(inst->audioUnit);
            inst->audioUnit = tsk_null;
		}
        tsk_safeobj_unlock(inst);
        
		tsk_safeobj_deinit(inst);
	}
	return self;
}
Пример #25
0
void CoreAudioSound::Stop()
{
	OSStatus err;

	err = AudioOutputUnitStop(audioUnit);
	if (err != noErr)
		ERROR_LOG(AUDIO, "error stopping audiounit");

	err = AudioUnitUninitialize(audioUnit);
	if (err != noErr)
		ERROR_LOG(AUDIO, "error uninitializing audiounit");

	err = CloseComponent(audioUnit);
	if (err != noErr)
		ERROR_LOG(AUDIO, "error closing audio component");
}
Пример #26
0
void
otMacAudioStreamBase::FreeData()
{
  if (mAudioUnit) {
    AudioUnitUninitialize(mAudioUnit);
    //CloseComponent(mAudioUnit);
    mAudioUnit = nsnull;
  }

  if (mBuffer) {
    for (UInt32 i = 0; i < mBuffer->mNumberBuffers; i++)
      if (mBuffer->mBuffers[i].mData)
        nsMemory::Free(mBuffer->mBuffers[i].mData);
    nsMemory::Free(mBuffer);
    mBuffer = nsnull;
  }
}
int
sa_stream_destroy(sa_stream_t *s) {

  int result = SA_SUCCESS;

  if (s == NULL) {
    return SA_SUCCESS;
  }

  /*
   * Shut down the audio output device.  Don't hold the mutex when stopping
   * the audio device, because it is possible to deadlock with this thread
   * holding mutex then waiting on an internal Core Audio lock, and with the
   * callback thread holding the Core Audio lock and waiting on the mutex.
   * This does not need to be protected by the mutex anyway because
   * AudioOutputUnitStop, when called from the non-callback thread, blocks
   * until in-flight callbacks complete and the HAL shuts down.  See:
   * http://lists.apple.com/archives/coreaudio-api/2005/Dec/msg00055.html
   */
  if (s->output_unit != NULL) {
    if (s->playing && AudioOutputUnitStop(s->output_unit) != 0) {
      result = SA_ERROR_SYSTEM;
    }
    if (AudioUnitUninitialize(s->output_unit) != 0) {
      result = SA_ERROR_SYSTEM;
    }
    if (CloseComponent(s->output_unit) != noErr) {
      result = SA_ERROR_SYSTEM;
    }
  }

  /*
   * Release resources.
   */
  if (pthread_mutex_destroy(&s->mutex) != 0) {
    result = SA_ERROR_SYSTEM;
  }
  while (s->bl_head != NULL) {
    sa_buf  * next = s->bl_head->next;
    free(s->bl_head);
    s->bl_head = next;
  }
  free(s);

  return result;
}
Пример #28
0
static void ca_stop_w(CAData *d){
	OSErr err;
	if(d->write_started == TRUE) {
		if(AudioOutputUnitStop(d->caOutAudioUnit) == noErr)
			d->write_started=FALSE;
	}
	if (d->caOutConverter!=NULL)
	{
		AudioConverterDispose(d->caOutConverter);
		d->caOutConverter=NULL;
	}
	if (d->caOutAudioUnit!=NULL)
	{
		AudioUnitUninitialize(d->caOutAudioUnit);
		d->caOutAudioUnit=NULL;
	}	
}
Пример #29
0
void CAPlayThrough::Cleanup()
{
	//clean up
	Stop();
									
	delete mBuffer;
	mBuffer = 0;
	if(mInputBuffer){
		for(UInt32 i = 0; i<mInputBuffer->mNumberBuffers; i++)
			free(mInputBuffer->mBuffers[i].mData);
		free(mInputBuffer);
		mInputBuffer = 0;
	}
	
	AudioUnitUninitialize(mInputUnit);
	AUGraphClose(mGraph);
	DisposeAUGraph(mGraph);
}
Пример #30
0
void
sound_lowlevel_end( void )
{
  OSStatus err;

  if( audio_output_started )
    verify_noerr( AudioOutputUnitStop( gOutputUnit ) );

  err = AudioUnitUninitialize( gOutputUnit );
  if( err ) {
    printf( "AudioUnitUninitialize=%ld", err );
  }

  CloseComponent( gOutputUnit );

  sfifo_flush( &sound_fifo );
  sfifo_close( &sound_fifo );
}