diff --git a/stepmania/src/RageSound.cpp b/stepmania/src/RageSound.cpp index e9d7947245..2eaf63c7d2 100644 --- a/stepmania/src/RageSound.cpp +++ b/stepmania/src/RageSound.cpp @@ -47,7 +47,6 @@ const int channels = 2; const int samplesize = 2 * channels; /* 16-bit */ -// inline int samplerate() { return SOUNDMAN->GetDriverSampleRate(); } #define samplerate() Sample->GetSampleRate() /* The most data to buffer when streaming. This should generally be at least as large @@ -173,12 +172,14 @@ bool RageSound::Load(CString sSoundFilePath, int precache) RageException::Throw( "RageSoundManager::RageSoundManager: error opening sound '%s': '%s'", m_sFilePath.c_str(), error.c_str()); - if(SOUNDMAN->GetDriverSampleRate() != -1 && - Sample->GetSampleRate() != SOUNDMAN->GetDriverSampleRate()) + /* SOUNDMAN->GetDriverSampleRate() returns a sample rate, -1 meaning "any", + * or 0 meaning "ask". */ + const int NeededRate = SOUNDMAN->GetDriverSampleRate( Sample->GetSampleRate() ); + if( NeededRate != Sample->GetSampleRate() ) { RageSoundReader_Resample *Resample = RageSoundReader_Resample::MakeResampler( (RageSoundReader_Resample::ResampleQuality) PREFSMAN->m_iSoundResampleQuality ); Resample->Open(Sample); - Resample->SetSampleRate(SOUNDMAN->GetDriverSampleRate()); + Resample->SetSampleRate( NeededRate ); Sample = Resample; } diff --git a/stepmania/src/RageSoundManager.cpp b/stepmania/src/RageSoundManager.cpp index 7262b5172c..42377a9c38 100644 --- a/stepmania/src/RageSoundManager.cpp +++ b/stepmania/src/RageSoundManager.cpp @@ -148,9 +148,9 @@ float RageSoundManager::GetPlayLatency() const return driver->GetPlayLatency(); } -int RageSoundManager::GetDriverSampleRate() const +int RageSoundManager::GetDriverSampleRate( int rate ) const { - return driver->GetSampleRate(); + return driver->GetSampleRate( rate ); } RageSound *RageSoundManager::PlaySound(RageSound &snd) diff --git a/stepmania/src/RageSoundManager.h b/stepmania/src/RageSoundManager.h index 204966a9d8..0a2dd68e2d 100644 --- a/stepmania/src/RageSoundManager.h +++ b/stepmania/src/RageSoundManager.h @@ -48,7 +48,7 @@ public: int GetPosition(const RageSound *snd) const; /* used by RageSound */ void AddFakeSound(RageSound *snd); /* used by drivers */ float GetPlayLatency() const; - int GetDriverSampleRate() const; + int GetDriverSampleRate( int rate ) const; const set &GetPlayingSounds() const { return playing_sounds; } void PlayOnce( CString sPath );