GetPosition(pSound) -> GetPosition(); one hardware sound position

per driver
This commit is contained in:
Glenn Maynard
2006-12-13 09:10:08 +00:00
parent fb9639f52c
commit f75a281c18
18 changed files with 26 additions and 26 deletions
+1 -1
View File
@@ -108,7 +108,7 @@ int64_t RageSoundManager::GetPosition( const RageSoundBase *pSound ) const
{ {
if( m_pDriver == NULL ) if( m_pDriver == NULL )
return 0; return 0;
return m_pDriver->GetPosition( pSound ); return m_pDriver->GetPosition();
} }
void RageSoundManager::Update() void RageSoundManager::Update()
+3 -3
View File
@@ -30,9 +30,9 @@ public:
* playing the sound, either). */ * playing the sound, either). */
virtual bool PauseMixing( RageSoundBase *snd, bool bStop ) = 0; virtual bool PauseMixing( RageSoundBase *snd, bool bStop ) = 0;
/* Get the current position of a given buffer, in the same units and time base /* Get the current hardware frame position, in the same time base as passed to
* as passed to RageSound::GetPCM. */ * RageSound::CommitPlayingPosition. */
virtual int64_t GetPosition( const RageSoundBase *snd ) const = 0; virtual int64_t GetPosition() const = 0;
/* When a sound is finished playing (GetPCM returns less than requested) and /* When a sound is finished playing (GetPCM returns less than requested) and
* the sound has been completely flushed (so GetPosition is no longer meaningful), * the sound has been completely flushed (so GetPosition is no longer meaningful),
@@ -67,7 +67,7 @@ bool RageSoundDriver_ALSA9_Software::GetData()
} }
int64_t RageSoundDriver_ALSA9_Software::GetPosition( const RageSoundBase *pSound ) const int64_t RageSoundDriver_ALSA9_Software::GetPosition() const
{ {
return m_pPCM->GetPosition(); return m_pPCM->GetPosition();
} }
@@ -15,7 +15,7 @@ public:
RString Init(); RString Init();
/* virtuals: */ /* virtuals: */
int64_t GetPosition( const RageSoundBase *pSound ) const; int64_t GetPosition() const;
float GetPlayLatency() const; float GetPlayLatency() const;
int GetSampleRate( int iRate ) const { return m_iSampleRate; } int GetSampleRate( int iRate ) const { return m_iSampleRate; }
@@ -184,7 +184,7 @@ RageSoundDriver_AU::~RageSoundDriver_AU()
delete m_pNotificationThread; delete m_pNotificationThread;
} }
int64_t RageSoundDriver_AU::GetPosition( const RageSoundBase *sound ) const int64_t RageSoundDriver_AU::GetPosition() const
{ {
double scale = m_iSampleRate / AudioGetHostClockFrequency(); double scale = m_iSampleRate / AudioGetHostClockFrequency();
return int64_t( scale * AudioGetCurrentHostTime() ); return int64_t( scale * AudioGetCurrentHostTime() );
@@ -13,7 +13,7 @@ public:
~RageSoundDriver_AU(); ~RageSoundDriver_AU();
float GetPlayLatency() const; float GetPlayLatency() const;
int GetSampleRate( int rate ) const { return m_iSampleRate; } int GetSampleRate( int rate ) const { return m_iSampleRate; }
int64_t GetPosition( const RageSoundBase *sound ) const; int64_t GetPosition() const;
protected: protected:
void SetupDecodingThread(); void SetupDecodingThread();
@@ -373,7 +373,7 @@ void RageSoundDriver_CA::RemoveListeners()
} }
} }
int64_t RageSoundDriver_CA::GetPosition( const RageSoundBase *sound ) const int64_t RageSoundDriver_CA::GetPosition() const
{ {
AudioTimeStamp time; AudioTimeStamp time;
OSStatus error; OSStatus error;
@@ -17,7 +17,7 @@ public:
~RageSoundDriver_CA(); ~RageSoundDriver_CA();
float GetPlayLatency() const { return m_fLatency; } float GetPlayLatency() const { return m_fLatency; }
int GetSampleRate( int rate ) const { return m_iSampleRate; } int GetSampleRate( int rate ) const { return m_iSampleRate; }
int64_t GetPosition( const RageSoundBase *sound ) const; int64_t GetPosition() const;
void SetupDecodingThread(); void SetupDecodingThread();
private: private:
@@ -60,7 +60,7 @@ void RageSoundDriver_DSound_Software::MixerThread()
m_pPCM->Stop(); m_pPCM->Stop();
} }
int64_t RageSoundDriver_DSound_Software::GetPosition( const RageSoundBase *pSound ) const int64_t RageSoundDriver_DSound_Software::GetPosition() const
{ {
return m_pPCM->GetPosition(); return m_pPCM->GetPosition();
} }
@@ -12,7 +12,7 @@ public:
virtual ~RageSoundDriver_DSound_Software(); virtual ~RageSoundDriver_DSound_Software();
RString Init(); RString Init();
int64_t GetPosition( const RageSoundBase *pSound ) const; int64_t GetPosition() const;
float GetPlayLatency() const; float GetPlayLatency() const;
int GetSampleRate( int rate ) const; int GetSampleRate( int rate ) const;
@@ -11,17 +11,17 @@ const int channels = 2;
void RageSoundDriver_Null::Update() void RageSoundDriver_Null::Update()
{ {
/* "Play" frames. */ /* "Play" frames. */
while( m_iLastCursorPos < GetPosition(NULL)+1024*4 ) while( m_iLastCursorPos < GetPosition()+1024*4 )
{ {
int16_t buf[256*channels]; int16_t buf[256*channels];
this->Mix( buf, 256, m_iLastCursorPos, GetPosition(NULL) ); this->Mix( buf, 256, m_iLastCursorPos, GetPosition() );
m_iLastCursorPos += 256; m_iLastCursorPos += 256;
} }
RageSound_Generic_Software::Update(); RageSound_Generic_Software::Update();
} }
int64_t RageSoundDriver_Null::GetPosition( const RageSoundBase *snd ) const int64_t RageSoundDriver_Null::GetPosition() const
{ {
return int64_t( RageTimer::GetTimeSinceStart() * m_iSampleRate ); return int64_t( RageTimer::GetTimeSinceStart() * m_iSampleRate );
} }
@@ -31,7 +31,7 @@ RageSoundDriver_Null::RageSoundDriver_Null()
m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate; m_iSampleRate = PREFSMAN->m_iSoundPreferredSampleRate;
if( m_iSampleRate == 0 ) if( m_iSampleRate == 0 )
m_iSampleRate = 44100; m_iSampleRate = 44100;
m_iLastCursorPos = GetPosition( NULL ); m_iLastCursorPos = GetPosition();
StartDecodeThread(); StartDecodeThread();
} }
@@ -7,7 +7,7 @@ class RageSoundDriver_Null: public RageSound_Generic_Software
{ {
public: public:
RageSoundDriver_Null(); RageSoundDriver_Null();
int64_t GetPosition( const RageSoundBase *snd ) const; int64_t GetPosition() const;
int GetSampleRate( int iRate ) const; int GetSampleRate( int iRate ) const;
void Update(); void Update();
@@ -73,7 +73,7 @@ bool RageSoundDriver_OSS::GetData()
if(!buf) if(!buf)
buf = new int16_t[chunksize / sizeof(int16_t)]; buf = new int16_t[chunksize / sizeof(int16_t)];
this->Mix( buf, chunksize/bytes_per_frame, last_cursor_pos, GetPosition( NULL ) ); this->Mix( buf, chunksize/bytes_per_frame, last_cursor_pos, GetPosition() );
int wrote = write( fd, buf, chunksize ); int wrote = write( fd, buf, chunksize );
if( wrote != chunksize ) if( wrote != chunksize )
@@ -87,7 +87,7 @@ bool RageSoundDriver_OSS::GetData()
/* XXX: There's a race on last_cursor_pos here: new data might be written after the /* XXX: There's a race on last_cursor_pos here: new data might be written after the
* ioctl returns, incrementing last_cursor_pos. */ * ioctl returns, incrementing last_cursor_pos. */
int64_t RageSoundDriver_OSS::GetPosition(const RageSoundBase *snd) const int64_t RageSoundDriver_OSS::GetPosition() const
{ {
ASSERT( fd != -1 ); ASSERT( fd != -1 );
@@ -24,7 +24,7 @@ public:
int GetSampleRate( int rate ) const { return samplerate; } int GetSampleRate( int rate ) const { return samplerate; }
/* virtuals: */ /* virtuals: */
int64_t GetPosition( const RageSoundBase *snd ) const; int64_t GetPosition() const;
float GetPlayLatency() const; float GetPlayLatency() const;
void SetupDecodingThread(); void SetupDecodingThread();
@@ -1152,7 +1152,7 @@ void RageSoundDriver_WDMKS::Read( void *pData, int iFrames, int iLastCursorPos,
bool RageSoundDriver_WDMKS::Fill( int iPacket, RString &sError ) bool RageSoundDriver_WDMKS::Fill( int iPacket, RString &sError )
{ {
uint64_t iCurrentFrame = GetPosition( NULL ); uint64_t iCurrentFrame = GetPosition();
// if( iCurrentFrame == m_iLastCursorPos ) // if( iCurrentFrame == m_iLastCursorPos )
// LOG->Trace( "underrun" ); // LOG->Trace( "underrun" );
@@ -1246,7 +1246,7 @@ void RageSoundDriver_WDMKS::SetupDecodingThread()
LOG->Warn( werr_ssprintf(GetLastError(), "Failed to set sound thread priority") ); LOG->Warn( werr_ssprintf(GetLastError(), "Failed to set sound thread priority") );
} }
int64_t RageSoundDriver_WDMKS::GetPosition( const RageSoundBase *pSound ) const int64_t RageSoundDriver_WDMKS::GetPosition() const
{ {
KSAUDIO_POSITION pos; KSAUDIO_POSITION pos;
@@ -15,7 +15,7 @@ public:
~RageSoundDriver_WDMKS(); ~RageSoundDriver_WDMKS();
RString Init(); RString Init();
int64_t GetPosition( const RageSoundBase *pSound ) const; int64_t GetPosition() const;
float GetPlayLatency() const; float GetPlayLatency() const;
int GetSampleRate( int iRate ) const; int GetSampleRate( int iRate ) const;
@@ -70,7 +70,7 @@ bool RageSoundDriver_WaveOut::GetData()
return false; return false;
/* Call the callback. */ /* Call the callback. */
this->Mix( (int16_t *) m_aBuffers[b].lpData, chunksize_frames, m_iLastCursorPos, GetPosition( NULL ) ); this->Mix( (int16_t *) m_aBuffers[b].lpData, chunksize_frames, m_iLastCursorPos, GetPosition() );
MMRESULT ret = waveOutWrite( m_hWaveOut, &m_aBuffers[b], sizeof(m_aBuffers[b]) ); MMRESULT ret = waveOutWrite( m_hWaveOut, &m_aBuffers[b], sizeof(m_aBuffers[b]) );
if(ret != MMSYSERR_NOERROR) if(ret != MMSYSERR_NOERROR)
@@ -88,7 +88,7 @@ void RageSoundDriver_WaveOut::SetupDecodingThread()
LOG->Warn( werr_ssprintf(GetLastError(), "Failed to set sound thread priority") ); LOG->Warn( werr_ssprintf(GetLastError(), "Failed to set sound thread priority") );
} }
int64_t RageSoundDriver_WaveOut::GetPosition( const RageSoundBase *pSound ) const int64_t RageSoundDriver_WaveOut::GetPosition() const
{ {
MMTIME tm; MMTIME tm;
tm.wType = TIME_SAMPLES; tm.wType = TIME_SAMPLES;
@@ -13,7 +13,7 @@ public:
~RageSoundDriver_WaveOut(); ~RageSoundDriver_WaveOut();
RString Init(); RString Init();
int64_t GetPosition( const RageSoundBase *pSound ) const; int64_t GetPosition() const;
float GetPlayLatency() const; float GetPlayLatency() const;
int GetSampleRate( int rate ) const { return m_iSampleRate; } int GetSampleRate( int rate ) const { return m_iSampleRate; }