From 808b95a1cfa3019ad591181909fbe61bbf73c28d Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 20 Jan 2004 01:00:01 +0000 Subject: [PATCH] API update --- stepmania/src/arch/Sound/ALSA9Helpers.cpp | 2 +- stepmania/src/arch/Sound/ALSA9Helpers.h | 7 ++++--- stepmania/src/arch/Sound/RageSoundDriver_ALSA9.cpp | 14 +++++++------- stepmania/src/arch/Sound/RageSoundDriver_ALSA9.h | 4 ++-- .../arch/Sound/RageSoundDriver_ALSA9_Software.cpp | 14 +++++++------- .../arch/Sound/RageSoundDriver_ALSA9_Software.h | 4 ++-- stepmania/src/arch/Sound/RageSoundDriver_OSS.cpp | 14 +++++++------- stepmania/src/arch/Sound/RageSoundDriver_OSS.h | 4 ++-- 8 files changed, 32 insertions(+), 31 deletions(-) diff --git a/stepmania/src/arch/Sound/ALSA9Helpers.cpp b/stepmania/src/arch/Sound/ALSA9Helpers.cpp index 30448aa670..0f53f94b28 100644 --- a/stepmania/src/arch/Sound/ALSA9Helpers.cpp +++ b/stepmania/src/arch/Sound/ALSA9Helpers.cpp @@ -303,7 +303,7 @@ bool Alsa9Buf::Recover( int r ) return false; } -int Alsa9Buf::GetPosition() const +int64_t Alsa9Buf::GetPosition() const { if( dsnd_pcm_state(pcm) == SND_PCM_STATE_PREPARED ) return last_cursor_pos; diff --git a/stepmania/src/arch/Sound/ALSA9Helpers.h b/stepmania/src/arch/Sound/ALSA9Helpers.h index df56c3e911..73f1ea34a6 100644 --- a/stepmania/src/arch/Sound/ALSA9Helpers.h +++ b/stepmania/src/arch/Sound/ALSA9Helpers.h @@ -11,7 +11,8 @@ class Alsa9Buf { private: int channels, samplerate, samplebits; - int buffersize, last_cursor_pos; + int buffersize; + int64_t last_cursor_pos; bool samplerate_set_explicitly; snd_pcm_sframes_t total_frames; @@ -45,7 +46,7 @@ public: void SetSampleRate(int hz); int GetSampleRate() const { return samplerate; } - int GetPosition() const; - int GetPlayPos() const { return last_cursor_pos; } + int64_t GetPosition() const; + int64_t GetPlayPos() const { return last_cursor_pos; } }; #endif diff --git a/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.cpp b/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.cpp index 561108c768..544cf3aa35 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.cpp @@ -68,8 +68,8 @@ bool RageSound_ALSA9::stream::GetData(bool init) buf = new Sint16[max_writeahead*samples_per_frame]; char *cbuf = (char*) buf; - const int play_pos = pcm->GetPlayPos(); - const int cur_play_pos = pcm->GetPosition(); + const int64_t play_pos = pcm->GetPlayPos(); + const int64_t cur_play_pos = pcm->GetPosition(); int len = frames_to_fill*bytes_per_frame; /* It might be INACTIVE, when we're prebuffering. We just don't want to @@ -83,11 +83,11 @@ bool RageSound_ALSA9::stream::GetData(bool init) if( !start_time.IsZero() ) { /* If the sound is supposed to start at a time past this buffer, insert silence. */ - const int iFramesUntilThisBuffer = play_pos - cur_play_pos; + const int64_t iFramesUntilThisBuffer = play_pos - cur_play_pos; const float fSecondsBeforeStart = -start_time.Ago(); - const int iFramesBeforeStart = int(fSecondsBeforeStart * pcm->GetSampleRate()); - const int iSilentFramesInThisBuffer = iFramesBeforeStart-iFramesUntilThisBuffer; - const int iSilentBytesInThisBuffer = clamp( iSilentFramesInThisBuffer * bytes_per_frame, 0, bytes_left ); + const int64_t iFramesBeforeStart = int64_t(fSecondsBeforeStart * pcm->GetSampleRate()); + const int64_t iSilentFramesInThisBuffer = iFramesBeforeStart-iFramesUntilThisBuffer; + const int iSilentBytesInThisBuffer = clamp( int(iSilentFramesInThisBuffer * bytes_per_frame), 0, bytes_left ); memset( cbuf+bytes_read, 0, iSilentBytesInThisBuffer ); bytes_read += iSilentBytesInThisBuffer; @@ -222,7 +222,7 @@ void RageSound_ALSA9::StopMixing(RageSoundBase *snd) } -int RageSound_ALSA9::GetPosition(const RageSoundBase *snd) const +int64_t RageSound_ALSA9::GetPosition(const RageSoundBase *snd) const { LockMutex L(SOUNDMAN->lock); diff --git a/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.h b/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.h index 22173816a1..519bce7e5f 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.h +++ b/stepmania/src/arch/Sound/RageSoundDriver_ALSA9.h @@ -26,7 +26,7 @@ private: STOPPING } state; - int flush_pos; /* state == STOPPING only */ + int64_t flush_pos; /* state == STOPPING only */ bool GetData( bool init ); @@ -51,7 +51,7 @@ public: /* virtuals: */ void StartMixing(RageSoundBase *snd); void StopMixing(RageSoundBase *snd); - int GetPosition(const RageSoundBase *snd) const; + int64_t GetPosition( const RageSoundBase *snd ) const; int GetSampleRate( int rate ) const; void Update(float delta); diff --git a/stepmania/src/arch/Sound/RageSoundDriver_ALSA9_Software.cpp b/stepmania/src/arch/Sound/RageSoundDriver_ALSA9_Software.cpp index 6f0844ce6a..9ad7dc9cfa 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_ALSA9_Software.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_ALSA9_Software.cpp @@ -75,8 +75,8 @@ bool RageSound_ALSA9_Software::GetData() static SoundMixBuffer mix; mix.SetVolume( SOUNDMAN->GetMixVolume() ); - const int play_pos = pcm->GetPlayPos(); - const int cur_play_pos = pcm->GetPosition(); + const int64_t play_pos = pcm->GetPlayPos(); + const int64_t cur_play_pos = pcm->GetPosition(); LockMutex L(SOUNDMAN->lock); for(unsigned i = 0; i < sounds.size(); ++i) @@ -91,11 +91,11 @@ bool RageSound_ALSA9_Software::GetData() if( !sounds[i]->start_time.IsZero() ) { /* If the sound is supposed to start at a time past this buffer, insert silence. */ - const int iFramesUntilThisBuffer = play_pos - cur_play_pos; + const int64_t iFramesUntilThisBuffer = play_pos - cur_play_pos; const float fSecondsBeforeStart = -sounds[i]->start_time.Ago(); - const int iFramesBeforeStart = int( fSecondsBeforeStart * samplerate ); - const int iSilentFramesInThisBuffer = iFramesBeforeStart-iFramesUntilThisBuffer; - const int iSilentBytesInThisBuffer = clamp( iSilentFramesInThisBuffer * bytes_per_frame, 0, bytes_left ); + const int64_t iFramesBeforeStart = int64_t( fSecondsBeforeStart * samplerate ); + const int64_t iSilentFramesInThisBuffer = iFramesBeforeStart-iFramesUntilThisBuffer; + const int iSilentBytesInThisBuffer = clamp( int(iSilentFramesInThisBuffer * bytes_per_frame), 0, bytes_left ); memset( buf+bytes_read, 0, iSilentBytesInThisBuffer ); bytes_read += iSilentBytesInThisBuffer; @@ -185,7 +185,7 @@ void RageSound_ALSA9_Software::StopMixing(RageSoundBase *snd) } -int RageSound_ALSA9_Software::GetPosition(const RageSoundBase *snd) const +int64_t RageSound_ALSA9_Software::GetPosition(const RageSoundBase *snd) const { return pcm->GetPosition(); } diff --git a/stepmania/src/arch/Sound/RageSoundDriver_ALSA9_Software.h b/stepmania/src/arch/Sound/RageSoundDriver_ALSA9_Software.h index 06d6ec4757..45c5bf0cff 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_ALSA9_Software.h +++ b/stepmania/src/arch/Sound/RageSoundDriver_ALSA9_Software.h @@ -15,7 +15,7 @@ private: RageSoundBase *snd; RageTimer start_time; bool stopping; - int flush_pos; /* state == STOPPING only */ + int64_t flush_pos; /* state == STOPPING only */ sound() { snd = NULL; stopping=false; } }; @@ -36,7 +36,7 @@ public: /* virtuals: */ void StartMixing(RageSoundBase *snd); void StopMixing(RageSoundBase *snd); - int GetPosition(const RageSoundBase *snd) const; + int64_t GetPosition( const RageSoundBase *snd ) const; float GetPlayLatency() const; int GetSampleRate( int rate ) const; diff --git a/stepmania/src/arch/Sound/RageSoundDriver_OSS.cpp b/stepmania/src/arch/Sound/RageSoundDriver_OSS.cpp index be2632ece7..fae7d8623f 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_OSS.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_OSS.cpp @@ -78,8 +78,8 @@ bool RageSound_OSS::GetData() static SoundMixBuffer mix; mix.SetVolume( SOUNDMAN->GetMixVolume() ); - const int play_pos = last_cursor_pos; - const int cur_play_pos = GetPosition( NULL /* doesn't care */); + const int64_t play_pos = last_cursor_pos; + const int64_t cur_play_pos = GetPosition( NULL /* doesn't care */); for(unsigned i = 0; i < sounds.size(); ++i) { @@ -92,11 +92,11 @@ bool RageSound_OSS::GetData() if( !sounds[i]->start_time.IsZero() ) { /* If the sound is supposed to start at a time past this buffer, insert silence. */ - const int iFramesUntilThisBuffer = play_pos - cur_play_pos; + const int64_t iFramesUntilThisBuffer = play_pos - cur_play_pos; const float fSecondsBeforeStart = -sounds[i]->start_time.Ago(); - const int iFramesBeforeStart = int(fSecondsBeforeStart * samplerate); - const int iSilentFramesInThisBuffer = iFramesBeforeStart-iFramesUntilThisBuffer; - const int iSilentBytesInThisBuffer = clamp( iSilentFramesInThisBuffer * bytes_per_frame, 0, bytes_left ); + const int64_t iFramesBeforeStart = int64_t(fSecondsBeforeStart * samplerate); + const int64_t iSilentFramesInThisBuffer = iFramesBeforeStart-iFramesUntilThisBuffer; + const int iSilentBytesInThisBuffer = clamp( int(iSilentFramesInThisBuffer * bytes_per_frame), 0, bytes_left ); memset( buf+bytes_read, 0, iSilentBytesInThisBuffer ); bytes_read += iSilentBytesInThisBuffer; @@ -180,7 +180,7 @@ void RageSound_OSS::StopMixing(RageSoundBase *snd) sounds.erase(sounds.begin()+i, sounds.begin()+i+1); } -int RageSound_OSS::GetPosition(const RageSoundBase *snd) const +int64_t RageSound_OSS::GetPosition(const RageSoundBase *snd) const { LockMutex L(SOUNDMAN->lock); diff --git a/stepmania/src/arch/Sound/RageSoundDriver_OSS.h b/stepmania/src/arch/Sound/RageSoundDriver_OSS.h index 0a50a5086e..a1bf172847 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_OSS.h +++ b/stepmania/src/arch/Sound/RageSoundDriver_OSS.h @@ -15,7 +15,7 @@ class RageSound_OSS: public RageSoundDriver bool stopping; - int flush_pos; /* state == STOPPING only */ + int64_t flush_pos; /* stopping == true only */ sound() { snd = NULL; stopping=false; } }; @@ -39,7 +39,7 @@ public: /* virtuals: */ void StartMixing(RageSoundBase *snd); /* used by RageSoundBase */ void StopMixing(RageSoundBase *snd); /* used by RageSoundBase */ - int GetPosition(const RageSoundBase *snd) const; + int64_t GetPosition( const RageSoundBase *snd ) const; float GetPlayLatency() const; RageSound_OSS();