From: dmitrykos Date: Thu, 18 Mar 2010 11:26:47 +0000 (+0000) Subject: maccore: fixed MacOSX "Snow Leopard" 10.6+ deadlock on sample-rate change submitted... X-Git-Tag: pa_stable_v19_20110326_r1647~146 X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=4f26695b77113a0ca700ca42a42a38772f02d100;p=portaudio maccore: fixed MacOSX "Snow Leopard" 10.6+ deadlock on sample-rate change submitted by Olivier Tristan and Stephane Letz with the following details: "When using paMacCoreChangeDeviceParameters option of PaMacCore_SetupStreamInfo, if the sample rate used in PortAudio do not match the one on the hardware, it automatically switches the hardware samplerate. This functionality stopped working on 10.6 and was blocking the application when trying to change the hardware samplerate (infinite wait) It now works fine on 10.6 as it used to on previous OSX version." --- diff --git a/src/hostapi/coreaudio/pa_mac_core.c b/src/hostapi/coreaudio/pa_mac_core.c index 0da5dc5..bd50973 100644 --- a/src/hostapi/coreaudio/pa_mac_core.c +++ b/src/hostapi/coreaudio/pa_mac_core.c @@ -530,12 +530,27 @@ PaError PaMacCore_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIn { PaError result = paNoError; int i; - PaMacAUHAL *auhalHostApi; + PaMacAUHAL *auhalHostApi = NULL; PaDeviceInfo *deviceInfoArray; int unixErr; VVDBUG(("PaMacCore_Initialize(): hostApiIndex=%d\n", hostApiIndex)); - + + SInt32 major; + SInt32 minor; + Gestalt(gestaltSystemVersionMajor, &major); + Gestalt(gestaltSystemVersionMinor, &minor); + + // Starting with 10.6 systems, the HAL notification thread is created internally + if (major == 10 && minor >= 6) { + CFRunLoopRef theRunLoop = NULL; + AudioObjectPropertyAddress theAddress = { kAudioHardwarePropertyRunLoop, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; + OSStatus osErr = AudioObjectSetPropertyData (kAudioObjectSystemObject, &theAddress, 0, NULL, sizeof(CFRunLoopRef), &theRunLoop); + if (osErr != noErr) { + goto error; + } + } + unixErr = initializeXRunListenerList(); if( 0 != unixErr ) { return UNIX_ERR(unixErr);