From f9d9708f6b8e8219b35abfb1a292cd37defbc83a Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Fri, 2 Sep 2016 13:11:28 -0400 Subject: [PATCH] coreaudio: Move some variable declarations to the top of the scope. --- src/audio/coreaudio/SDL_coreaudio.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/audio/coreaudio/SDL_coreaudio.c b/src/audio/coreaudio/SDL_coreaudio.c index 83a66a339..4819fcb32 100644 --- a/src/audio/coreaudio/SDL_coreaudio.c +++ b/src/audio/coreaudio/SDL_coreaudio.c @@ -437,17 +437,18 @@ static void COREAUDIO_CloseDevice(_THIS) { const int iscapture = this->iscapture; + if (this->hidden->audioUnitOpened) { + const AudioUnitElement output_bus = 0; + const AudioUnitElement input_bus = 1; + const AudioUnitElement bus = ((iscapture) ? input_bus : output_bus); + AURenderCallbackStruct callback; + #if MACOSX_COREAUDIO /* Unregister our disconnect callback. */ AudioObjectRemovePropertyListener(this->hidden->deviceID, &alive_address, device_unplugged, this); #endif - AURenderCallbackStruct callback; - const AudioUnitElement output_bus = 0; - const AudioUnitElement input_bus = 1; - const AudioUnitElement bus = ((iscapture) ? input_bus : output_bus); - /* stop processing the audio unit */ AudioOutputUnitStop(this->hidden->audioUnit);