API update

This commit is contained in:
Glenn Maynard
2004-01-20 01:00:01 +00:00
parent 7df49d29b6
commit 808b95a1cf
8 changed files with 32 additions and 31 deletions
+1 -1
View File
@@ -303,7 +303,7 @@ bool Alsa9Buf::Recover( int r )
return false; return false;
} }
int Alsa9Buf::GetPosition() const int64_t Alsa9Buf::GetPosition() const
{ {
if( dsnd_pcm_state(pcm) == SND_PCM_STATE_PREPARED ) if( dsnd_pcm_state(pcm) == SND_PCM_STATE_PREPARED )
return last_cursor_pos; return last_cursor_pos;
+4 -3
View File
@@ -11,7 +11,8 @@ class Alsa9Buf
{ {
private: private:
int channels, samplerate, samplebits; int channels, samplerate, samplebits;
int buffersize, last_cursor_pos; int buffersize;
int64_t last_cursor_pos;
bool samplerate_set_explicitly; bool samplerate_set_explicitly;
snd_pcm_sframes_t total_frames; snd_pcm_sframes_t total_frames;
@@ -45,7 +46,7 @@ public:
void SetSampleRate(int hz); void SetSampleRate(int hz);
int GetSampleRate() const { return samplerate; } int GetSampleRate() const { return samplerate; }
int GetPosition() const; int64_t GetPosition() const;
int GetPlayPos() const { return last_cursor_pos; } int64_t GetPlayPos() const { return last_cursor_pos; }
}; };
#endif #endif
@@ -68,8 +68,8 @@ bool RageSound_ALSA9::stream::GetData(bool init)
buf = new Sint16[max_writeahead*samples_per_frame]; buf = new Sint16[max_writeahead*samples_per_frame];
char *cbuf = (char*) buf; char *cbuf = (char*) buf;
const int play_pos = pcm->GetPlayPos(); const int64_t play_pos = pcm->GetPlayPos();
const int cur_play_pos = pcm->GetPosition(); const int64_t cur_play_pos = pcm->GetPosition();
int len = frames_to_fill*bytes_per_frame; int len = frames_to_fill*bytes_per_frame;
/* It might be INACTIVE, when we're prebuffering. We just don't want to /* 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( !start_time.IsZero() )
{ {
/* If the sound is supposed to start at a time past this buffer, insert silence. */ /* 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 float fSecondsBeforeStart = -start_time.Ago();
const int iFramesBeforeStart = int(fSecondsBeforeStart * pcm->GetSampleRate()); const int64_t iFramesBeforeStart = int64_t(fSecondsBeforeStart * pcm->GetSampleRate());
const int iSilentFramesInThisBuffer = iFramesBeforeStart-iFramesUntilThisBuffer; const int64_t iSilentFramesInThisBuffer = iFramesBeforeStart-iFramesUntilThisBuffer;
const int iSilentBytesInThisBuffer = clamp( iSilentFramesInThisBuffer * bytes_per_frame, 0, bytes_left ); const int iSilentBytesInThisBuffer = clamp( int(iSilentFramesInThisBuffer * bytes_per_frame), 0, bytes_left );
memset( cbuf+bytes_read, 0, iSilentBytesInThisBuffer ); memset( cbuf+bytes_read, 0, iSilentBytesInThisBuffer );
bytes_read += 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); LockMutex L(SOUNDMAN->lock);
@@ -26,7 +26,7 @@ private:
STOPPING STOPPING
} state; } state;
int flush_pos; /* state == STOPPING only */ int64_t flush_pos; /* state == STOPPING only */
bool GetData( bool init ); bool GetData( bool init );
@@ -51,7 +51,7 @@ public:
/* virtuals: */ /* virtuals: */
void StartMixing(RageSoundBase *snd); void StartMixing(RageSoundBase *snd);
void StopMixing(RageSoundBase *snd); void StopMixing(RageSoundBase *snd);
int GetPosition(const RageSoundBase *snd) const; int64_t GetPosition( const RageSoundBase *snd ) const;
int GetSampleRate( int rate ) const; int GetSampleRate( int rate ) const;
void Update(float delta); void Update(float delta);
@@ -75,8 +75,8 @@ bool RageSound_ALSA9_Software::GetData()
static SoundMixBuffer mix; static SoundMixBuffer mix;
mix.SetVolume( SOUNDMAN->GetMixVolume() ); mix.SetVolume( SOUNDMAN->GetMixVolume() );
const int play_pos = pcm->GetPlayPos(); const int64_t play_pos = pcm->GetPlayPos();
const int cur_play_pos = pcm->GetPosition(); const int64_t cur_play_pos = pcm->GetPosition();
LockMutex L(SOUNDMAN->lock); LockMutex L(SOUNDMAN->lock);
for(unsigned i = 0; i < sounds.size(); ++i) for(unsigned i = 0; i < sounds.size(); ++i)
@@ -91,11 +91,11 @@ bool RageSound_ALSA9_Software::GetData()
if( !sounds[i]->start_time.IsZero() ) if( !sounds[i]->start_time.IsZero() )
{ {
/* If the sound is supposed to start at a time past this buffer, insert silence. */ /* 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 float fSecondsBeforeStart = -sounds[i]->start_time.Ago();
const int iFramesBeforeStart = int( fSecondsBeforeStart * samplerate ); const int64_t iFramesBeforeStart = int64_t( fSecondsBeforeStart * samplerate );
const int iSilentFramesInThisBuffer = iFramesBeforeStart-iFramesUntilThisBuffer; const int64_t iSilentFramesInThisBuffer = iFramesBeforeStart-iFramesUntilThisBuffer;
const int iSilentBytesInThisBuffer = clamp( iSilentFramesInThisBuffer * bytes_per_frame, 0, bytes_left ); const int iSilentBytesInThisBuffer = clamp( int(iSilentFramesInThisBuffer * bytes_per_frame), 0, bytes_left );
memset( buf+bytes_read, 0, iSilentBytesInThisBuffer ); memset( buf+bytes_read, 0, iSilentBytesInThisBuffer );
bytes_read += 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(); return pcm->GetPosition();
} }
@@ -15,7 +15,7 @@ private:
RageSoundBase *snd; RageSoundBase *snd;
RageTimer start_time; RageTimer start_time;
bool stopping; bool stopping;
int flush_pos; /* state == STOPPING only */ int64_t flush_pos; /* state == STOPPING only */
sound() { snd = NULL; stopping=false; } sound() { snd = NULL; stopping=false; }
}; };
@@ -36,7 +36,7 @@ public:
/* virtuals: */ /* virtuals: */
void StartMixing(RageSoundBase *snd); void StartMixing(RageSoundBase *snd);
void StopMixing(RageSoundBase *snd); void StopMixing(RageSoundBase *snd);
int GetPosition(const RageSoundBase *snd) const; int64_t GetPosition( const RageSoundBase *snd ) const;
float GetPlayLatency() const; float GetPlayLatency() const;
int GetSampleRate( int rate ) const; int GetSampleRate( int rate ) const;
@@ -78,8 +78,8 @@ bool RageSound_OSS::GetData()
static SoundMixBuffer mix; static SoundMixBuffer mix;
mix.SetVolume( SOUNDMAN->GetMixVolume() ); mix.SetVolume( SOUNDMAN->GetMixVolume() );
const int play_pos = last_cursor_pos; const int64_t play_pos = last_cursor_pos;
const int cur_play_pos = GetPosition( NULL /* doesn't care */); const int64_t cur_play_pos = GetPosition( NULL /* doesn't care */);
for(unsigned i = 0; i < sounds.size(); ++i) for(unsigned i = 0; i < sounds.size(); ++i)
{ {
@@ -92,11 +92,11 @@ bool RageSound_OSS::GetData()
if( !sounds[i]->start_time.IsZero() ) if( !sounds[i]->start_time.IsZero() )
{ {
/* If the sound is supposed to start at a time past this buffer, insert silence. */ /* 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 float fSecondsBeforeStart = -sounds[i]->start_time.Ago();
const int iFramesBeforeStart = int(fSecondsBeforeStart * samplerate); const int64_t iFramesBeforeStart = int64_t(fSecondsBeforeStart * samplerate);
const int iSilentFramesInThisBuffer = iFramesBeforeStart-iFramesUntilThisBuffer; const int64_t iSilentFramesInThisBuffer = iFramesBeforeStart-iFramesUntilThisBuffer;
const int iSilentBytesInThisBuffer = clamp( iSilentFramesInThisBuffer * bytes_per_frame, 0, bytes_left ); const int iSilentBytesInThisBuffer = clamp( int(iSilentFramesInThisBuffer * bytes_per_frame), 0, bytes_left );
memset( buf+bytes_read, 0, iSilentBytesInThisBuffer ); memset( buf+bytes_read, 0, iSilentBytesInThisBuffer );
bytes_read += iSilentBytesInThisBuffer; bytes_read += iSilentBytesInThisBuffer;
@@ -180,7 +180,7 @@ void RageSound_OSS::StopMixing(RageSoundBase *snd)
sounds.erase(sounds.begin()+i, sounds.begin()+i+1); 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); LockMutex L(SOUNDMAN->lock);
@@ -15,7 +15,7 @@ class RageSound_OSS: public RageSoundDriver
bool stopping; bool stopping;
int flush_pos; /* state == STOPPING only */ int64_t flush_pos; /* stopping == true only */
sound() { snd = NULL; stopping=false; } sound() { snd = NULL; stopping=false; }
}; };
@@ -39,7 +39,7 @@ public:
/* virtuals: */ /* virtuals: */
void StartMixing(RageSoundBase *snd); /* used by RageSoundBase */ void StartMixing(RageSoundBase *snd); /* used by RageSoundBase */
void StopMixing(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; float GetPlayLatency() const;
RageSound_OSS(); RageSound_OSS();