From d9def1e48c3e5073707a5b708353d8a4dcb3652d Mon Sep 17 00:00:00 2001 From: sletz Date: Thu, 29 Oct 2009 15:36:02 +0000 Subject: [PATCH] In JackCoreAudioDriver::Start, wait for the audio driver to effectively start (use the MeasureCallback). git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3681 0c269be4-1314-0410-8aa9-9f06e86f4224 --- ChangeLog | 4 ++++ macosx/coreaudio/JackCoreAudioDriver.cpp | 23 ++++++++++++++++++++--- macosx/coreaudio/JackCoreAudioDriver.h | 2 ++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c11273f4..1de114eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,10 @@ Paul Davis Jackdmp changes log --------------------------- +2009-10-29 Stephane Letz + + * In JackCoreAudioDriver::Start, wait for the audio driver to effectively start (use the MeasureCallback). + 2009-10-28 Stephane Letz * In JackCoreAudioDriver, force the SR value to the wanted one *before* creating aggregate device (otherwise creation will fail). diff --git a/macosx/coreaudio/JackCoreAudioDriver.cpp b/macosx/coreaudio/JackCoreAudioDriver.cpp index a6609792..69c16a0a 100644 --- a/macosx/coreaudio/JackCoreAudioDriver.cpp +++ b/macosx/coreaudio/JackCoreAudioDriver.cpp @@ -227,6 +227,9 @@ OSStatus JackCoreAudioDriver::MeasureCallback(AudioDeviceID inDevice, driver->fEngineControl->fComputation = driver->fEngineControl->fPeriod * driver->fComputationGrain; } + // Signal waiting start function... + driver->fState = true; + // Setup threadded based log function set_threaded_log_function(); return noErr; @@ -824,7 +827,7 @@ int JackCoreAudioDriver::SetupSampleRateAux(AudioDeviceID inDevice, jack_nframes // Waiting for SR change notification int count = 0; - while (!fState && count++ < 100) { + while (!fState && count++ < WAIT_COUNTER) { usleep(100000); jack_log("Wait count = %d", count); } @@ -1376,8 +1379,22 @@ int JackCoreAudioDriver::Start() printError(err); return -1; } - - return 0; + + // Waiting for Measure callback to be called ( = driver has started) + fState = false; + int count = 0; + while (!fState && count++ < WAIT_COUNTER) { + usleep(100000); + jack_log("JackCoreAudioDriver::Start wait count = %d", count); + } + + if (count < WAIT_COUNTER) { + jack_info("CoreAudio driver is running..."); + return 0; + } else { + jack_error("CoreAudio driver cannot start..."); + return -1; + } } int JackCoreAudioDriver::Stop() diff --git a/macosx/coreaudio/JackCoreAudioDriver.h b/macosx/coreaudio/JackCoreAudioDriver.h index 247d470b..e0dedcbd 100644 --- a/macosx/coreaudio/JackCoreAudioDriver.h +++ b/macosx/coreaudio/JackCoreAudioDriver.h @@ -36,6 +36,8 @@ typedef UInt8 CAAudioHardwareDeviceSectionID; #define kAudioDeviceSectionOutput ((CAAudioHardwareDeviceSectionID)0x00) #define kAudioDeviceSectionGlobal ((CAAudioHardwareDeviceSectionID)0x00) #define kAudioDeviceSectionWildcard ((CAAudioHardwareDeviceSectionID)0xFF) + +#define WAIT_COUNTER 60 /*! \brief The CoreAudio driver. -- 2.11.4.GIT