diff --git a/stepmania/src/RageSound.cpp b/stepmania/src/RageSound.cpp index a31a0f0598..7586e6a89b 100644 --- a/stepmania/src/RageSound.cpp +++ b/stepmania/src/RageSound.cpp @@ -607,6 +607,27 @@ void RageSound::StopPlaying() pos_map.clear(); } +/* This is similar to StopPlaying, except it's called by sound drivers when we're done + * playing, rather than by users to as us to stop. (The only difference is that this + * doesn't call SOUNDMAN->StopMixing; there's no reason to tell the sound driver to + * stop mixing, since they're the one telling us we're done.) */ +void RageSound::SoundIsFinishedPlaying() +{ + if(!playing) + return; + + stopped_position = (int) GetPositionSecondsInternal(); + + SOUNDMAN->lock.Lock(); + SOUNDMAN->playing_sounds.erase( this ); + SOUNDMAN->lock.Unlock(); + + playing = false; + playing_thread = 0; + + pos_map.clear(); +} + RageSound *RageSound::Play( const RageSoundParams *params ) { return SOUNDMAN->PlaySound( *this, params ); diff --git a/stepmania/src/RageSound.h b/stepmania/src/RageSound.h index 7e0d7af2b5..7be6aca478 100644 --- a/stepmania/src/RageSound.h +++ b/stepmania/src/RageSound.h @@ -12,7 +12,8 @@ class RageSoundBase { public: virtual ~RageSoundBase() { } - virtual void StopPlaying() = 0; + virtual void StopPlaying() = 0; // deprecated + virtual void SoundIsFinishedPlaying() = 0; virtual bool GetDataToPlay( int16_t *buffer, int size, int &pos, int &got_bytes ) = 0; virtual int GetPCM( char *buffer, int size, int64_t frameno ) = 0; virtual int GetSampleRate() const = 0; @@ -174,6 +175,8 @@ private: int Bytes_Available() const; RageSoundParams::StopMode_t GetStopMode() const; /* resolves M_AUTO */ + void SoundIsFinishedPlaying(); // called by sound drivers + static void RateChange(char *buf, int &cnt, int speed_input_samples, int speed_output_samples, int channels); public: