Update RageSoundDriver_AU.cpp

The Yosemite crash happens when we call CFRunLoopAddObserver. It doesn't seem to like runLoopRef. Replacing the first argument to this call with CFRunLoopGetCurrent() avoids the crash, but the app then hangs because CFRunLoopWakeUp doesn't cause observerRef (NameHALThread) to fire, so the semaphore is not posted. Commenting the semaphore wait line allows the game to boot in Yosemite, and seems to play totally normally. This doesn't really fix our problem (we are trying to name the HAL thread, and a catastrophic error occurs), but it shows us what the problem is.

We are obtaining runLoopRef using an API call that was deprecated years ago. However, the Apple-approved replacement code doesn't produce a runLoopRef that avoids the crash, either. So I'm not sure how we get the correct runLoopRef so we can name the thread.

This is my first time looking at the code base, but I don't see the value of naming the thread. In the interest of keeping Stepmania compatible with the upcoming operating system, I propose we just remove the thread-naming logic.
This commit is contained in:
Jonathan Berney
2014-10-07 19:48:58 -07:00
parent 4629bdef5c
commit 218c10ef97
+21 -47
View File
@@ -41,20 +41,10 @@ static inline RString FourCCToString( uint32_t num )
} }
RageSoundDriver_AU::RageSoundDriver_AU() : m_OutputUnit(NULL), m_iSampleRate(0), m_bDone(false), m_bStarted(false), RageSoundDriver_AU::RageSoundDriver_AU() : m_OutputUnit(NULL), m_iSampleRate(0), m_bDone(false), m_bStarted(false),
m_pIOThread(NULL), m_pNotificationThread(NULL), m_Semaphore("Sound") m_pIOThread(NULL), m_pNotificationThread(NULL), m_Semaphore("Sound")
{ {
} }
void RageSoundDriver_AU::NameHALThread( CFRunLoopObserverRef observer, CFRunLoopActivity activity, void *inRefCon )
{
RageSoundDriver_AU *This = (RageSoundDriver_AU *)inRefCon;
CFRunLoopObserverInvalidate( observer );
CFRelease( observer );
This->m_pNotificationThread = new RageThreadRegister( "HAL notification thread" );
This->m_Semaphore.Post();
}
static void SetSampleRate( AudioUnit au, Float64 desiredRate ) static void SetSampleRate( AudioUnit au, Float64 desiredRate )
{ {
AudioDeviceID OutputDevice; AudioDeviceID OutputDevice;
@@ -147,11 +137,11 @@ RString RageSoundDriver_AU::Init()
input.inputProcRefCon = this; input.inputProcRefCon = this;
error = AudioUnitSetProperty( m_OutputUnit, error = AudioUnitSetProperty( m_OutputUnit,
kAudioUnitProperty_SetRenderCallback, kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Input, kAudioUnitScope_Input,
0, 0,
&input, &input,
sizeof(input) ); sizeof(input) );
if( error != noErr ) if( error != noErr )
return ERROR( "Failed to set render callback", error ); return ERROR( "Failed to set render callback", error );
@@ -176,21 +166,21 @@ RString RageSoundDriver_AU::Init()
error = AudioUnitSetProperty( m_OutputUnit, error = AudioUnitSetProperty( m_OutputUnit,
kAudioUnitProperty_StreamFormat, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input, kAudioUnitScope_Input,
0, 0,
&streamFormat, &streamFormat,
sizeof(AudioStreamBasicDescription) ); sizeof(AudioStreamBasicDescription) );
if( error != noErr ) if( error != noErr )
return ERROR( "Failed to set AU stream format", error ); return ERROR( "Failed to set AU stream format", error );
UInt32 renderQuality = kRenderQuality_Max; UInt32 renderQuality = kRenderQuality_Max;
error = AudioUnitSetProperty( m_OutputUnit, error = AudioUnitSetProperty( m_OutputUnit,
kAudioUnitProperty_RenderQuality, kAudioUnitProperty_RenderQuality,
kAudioUnitScope_Global, kAudioUnitScope_Global,
0, 0,
&renderQuality, &renderQuality,
sizeof(renderQuality) ); sizeof(renderQuality) );
if( error != noErr ) if( error != noErr )
LOG->Warn( WERROR("Failed to set the maximum render quality", error) ); LOG->Warn( WERROR("Failed to set the maximum render quality", error) );
@@ -200,22 +190,6 @@ RString RageSoundDriver_AU::Init()
StartDecodeThread(); StartDecodeThread();
// Get the HAL's runloop and attach an observer.
{
CFRunLoopObserverRef observerRef;
CFRunLoopRef runLoopRef;
CFRunLoopObserverContext context = { 0, this, NULL, NULL, NULL };
UInt32 size = sizeof( CFRunLoopRef );
if( (error = AudioHardwareGetProperty(kAudioHardwarePropertyRunLoop, &size, &runLoopRef)) )
return ERROR( "Couldn't get the HAL's run loop", error);
observerRef = CFRunLoopObserverCreate( kCFAllocatorDefault, kCFRunLoopAllActivities, false, 0, NameHALThread, &context );
CFRunLoopAddObserver( runLoopRef, observerRef, kCFRunLoopDefaultMode );
CFRunLoopWakeUp( runLoopRef );
m_Semaphore.Wait();
}
if( (error = AudioOutputUnitStart(m_OutputUnit)) ) if( (error = AudioOutputUnitStart(m_OutputUnit)) )
return ERROR( "Could not start the AudioUnit", error ); return ERROR( "Could not start the AudioUnit", error );
m_bStarted = true; m_bStarted = true;
@@ -333,11 +307,11 @@ float RageSoundDriver_AU::GetPlayLatency() const
OSStatus RageSoundDriver_AU::Render( void *inRefCon, OSStatus RageSoundDriver_AU::Render( void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags, AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp, const AudioTimeStamp *inTimeStamp,
UInt32 inBusNumber, UInt32 inBusNumber,
UInt32 inNumberFrames, UInt32 inNumberFrames,
AudioBufferList *ioData ) AudioBufferList *ioData )
{ {
RageSoundDriver_AU *This = (RageSoundDriver_AU *)inRefCon; RageSoundDriver_AU *This = (RageSoundDriver_AU *)inRefCon;