From 812dd48169ac61b1fa392e405f1243e43adbe18d Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Sun, 25 Mar 2007 23:51:53 +0000 Subject: [PATCH] Handle race condition more intelligently by invalidating in the callback itself. --- stepmania/src/arch/Sound/RageSoundDriver_AU.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/stepmania/src/arch/Sound/RageSoundDriver_AU.cpp b/stepmania/src/arch/Sound/RageSoundDriver_AU.cpp index 76b1e58b4b..a399a74b82 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_AU.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_AU.cpp @@ -47,11 +47,10 @@ RageSoundDriver_AU::RageSoundDriver_AU() : m_OutputUnit(NULL), m_iSampleRate(0), void RageSoundDriver_AU::NameHALThread( CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *inRefCon ) { RageSoundDriver_AU *This = (RageSoundDriver_AU *)inRefCon; - if( This->m_pNotificationThread == NULL ) - { - This->m_pNotificationThread = new RageThreadRegister( "HAL notification thread" ); - This->m_Semaphore.Post(); - } + CFRunLoopObserverInvalidate( observer ); + CFRelease( observer ); + This->m_pNotificationThread = new RageThreadRegister( "HAL notification thread" ); + This->m_Semaphore.Post(); } RString RageSoundDriver_AU::Init() @@ -160,8 +159,6 @@ RString RageSoundDriver_AU::Init() CFRunLoopAddObserver( runLoopRef, observerRef, kCFRunLoopDefaultMode ); CFRunLoopWakeUp( runLoopRef ); m_Semaphore.Wait(); - CFRunLoopObserverInvalidate( observerRef ); - CFRelease( observerRef ); } if( (error = AudioOutputUnitStart(m_OutputUnit)) )