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.

This commit is contained in:
Steve Checkoway
2007-11-24 23:10:11 +00:00
parent 92e41d40da
commit 004fcc0ccd
@@ -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) );
}
}
}
}