From 004fcc0ccd2768dfdef89d7912043f81da43b726 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Sat, 24 Nov 2007 23:10:11 +0000 Subject: [PATCH] Don't try to set the device's sample rate if it already matches. This fixes an annoying pause in playing audio whenever the game is started. --- .../src/arch/Sound/RageSoundDriver_AU.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/stepmania/src/arch/Sound/RageSoundDriver_AU.cpp b/stepmania/src/arch/Sound/RageSoundDriver_AU.cpp index 9643658c2b..edd7b78875 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_AU.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_AU.cpp @@ -113,10 +113,23 @@ RString RageSoundDriver_AU::Init() { LOG->Warn( WERROR("No output device", error) ); } - else if( (error = AudioDeviceSetProperty(OutputDevice, NULL, 0, false, kAudioDevicePropertyNominalSampleRate, - sizeof(Float64), &streamFormat.mSampleRate)) ) + else { - LOG->Warn( WERROR("Couldn't set the device's sample rate", error) ); + Float64 rate = 0.0; + size = sizeof( Float64 ); + if( (error = AudioDeviceGetProperty(OutputDevice, 0, false, kAudioDevicePropertyNominalSampleRate, + &size, &rate)) ) + { + LOG->Warn( WERROR("Couldn't get the device's sample rate", error) ); + } + else if( rate != streamFormat.mSampleRate ) + { + if( (error = AudioDeviceSetProperty(OutputDevice, NULL, 0, false, kAudioDevicePropertyNominalSampleRate, + sizeof(Float64), &streamFormat.mSampleRate)) ) + { + LOG->Warn( WERROR("Couldn't set the device's sample rate", error) ); + } + } } }