From 4f26695b77113a0ca700ca42a42a38772f02d100 Mon Sep 17 00:00:00 2001 From: dmitrykos Date: Thu, 18 Mar 2010 11:26:47 +0000 Subject: [PATCH] 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." --- src/hostapi/coreaudio/pa_mac_core.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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); -- 2.43.0