From 234f0783a052ab848dec747fefc4bf7279d4a036 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Sat, 10 Jan 2015 21:49:58 -0500 Subject: [PATCH] OSX crash-on-exit fix --- src/CubicSDR.cpp | 9 +++++---- src/audio/AudioThread.cpp | 7 +++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/CubicSDR.cpp b/src/CubicSDR.cpp index 396b9dc..407f591 100644 --- a/src/CubicSDR.cpp +++ b/src/CubicSDR.cpp @@ -74,10 +74,6 @@ int CubicSDR::OnExit() { demodMgr.terminateAll(); -#ifdef __APPLE__ - AudioThread::deviceCleanup(); -#endif - delete threadCmdQueueSDR; delete iqVisualQueue; @@ -86,6 +82,11 @@ int CubicSDR::OnExit() { delete m_glContext; + +#ifdef __APPLE__ + AudioThread::deviceCleanup(); +#endif + return wxApp::OnExit(); } diff --git a/src/audio/AudioThread.cpp b/src/audio/AudioThread.cpp index 9dc4c77..701ca66 100644 --- a/src/audio/AudioThread.cpp +++ b/src/audio/AudioThread.cpp @@ -51,6 +51,11 @@ static int audioCallback(void *outputBuffer, void *inputBuffer, unsigned int nBu AudioThread *src = (AudioThread *) userData; float *out = (float*) outputBuffer; memset(out, 0, nBufferFrames * 2 * sizeof(float)); + + if (src->terminated) { + return 1; + } + if (status) { std::cout << "Audio buffer underflow.." << (src->underflowCount++) << std::endl; } @@ -383,8 +388,10 @@ void AudioThread::threadMain() { } } +#if !__APPLE__ AudioThreadInput dummy; inputQueue->push(&dummy); +#endif #ifdef __APPLE__ if (deviceController[parameters.deviceId] != this) {