s/RageSound/RageSoundBase/

linux/mac in a moment
This commit is contained in:
Glenn Maynard
2004-01-15 02:59:44 +00:00
parent 97d088db50
commit 92684a90db
9 changed files with 35 additions and 37 deletions
+6 -8
View File
@@ -1,30 +1,29 @@
#ifndef RAGE_SOUND_DRIVER
#define RAGE_SOUND_DRIVER
class RageSoundBase;
class RageSoundDriver
{
friend class RageSound;
protected:
public:
friend class RageSoundManager;
/* A RageSound calls this to request to be played.
* XXX: define what we should do when it can't be played (eg. out of
* channels) */
virtual void StartMixing(RageSound *snd) = 0;
virtual void StartMixing( RageSoundBase *snd ) = 0;
/* A RageSound calls this to request it not be played. When this function
* returns, snd is no longer valid; ensure no running threads are still
* accessing it before returning. This must handle gracefully the case where
* snd was not actually being played, though it may print a warning. */
virtual void StopMixing(RageSound *snd) = 0;
virtual void StopMixing( RageSoundBase *snd ) = 0;
/* Get the current position of a given buffer, in the same units and time base
* as passed to RageSound::GetPCM. */
virtual int GetPosition(const RageSound *snd) const = 0;
virtual int GetPosition( const RageSoundBase *snd ) const = 0;
/* When a sound is finished playing (GetPCM returns less than requested) and
* the sound has been completely flushed (so GetPosition is no longer meaningful),
* call RageSound::StopPlaying(). Do *not* call it when StopMixing is called. */
* call RageSoundBase::StopPlaying(). Do *not* call it when StopMixing is called. */
/* Optional, if needed: */
virtual void Update(float delta) { }
@@ -39,7 +38,6 @@ protected:
virtual int GetSampleRate( int rate ) const { return 44100; }
public:
virtual ~RageSoundDriver() { }
};
@@ -246,7 +246,7 @@ void RageSound_DSound::VolumeChanged()
}
}
void RageSound_DSound::StartMixing(RageSound *snd)
void RageSound_DSound::StartMixing( RageSoundBase *snd )
{
LockMutex L(SOUNDMAN->lock);
@@ -294,7 +294,7 @@ void RageSound_DSound::StartMixing(RageSound *snd)
* call completes, snd->GetPCM (which runs in a separate thread) will
* not be running and will not be called unless StartMixing is called
* again. */
void RageSound_DSound::StopMixing(RageSound *snd)
void RageSound_DSound::StopMixing( RageSoundBase *snd )
{
ASSERT(snd != NULL);
LockMutex L(SOUNDMAN->lock);
@@ -321,7 +321,7 @@ void RageSound_DSound::StopMixing(RageSound *snd)
stream_pool[i]->snd = NULL;
}
int RageSound_DSound::GetPosition(const RageSound *snd) const
int RageSound_DSound::GetPosition( const RageSoundBase *snd ) const
{
LockMutex L(SOUNDMAN->lock);
@@ -17,7 +17,7 @@ class RageSound_DSound: public RageSoundDriver
/* Sound object that's playing on this stream, or NULL if this
* channel is available: */
RageSound *snd;
RageSoundBase *snd;
enum {
INACTIVE,
@@ -47,9 +47,9 @@ class RageSound_DSound: public RageSoundDriver
RageThread MixingThread;
/* virtuals: */
void StartMixing(RageSound *snd); /* used by RageSound */
void StopMixing(RageSound *snd); /* used by RageSound */
int GetPosition(const RageSound *snd) const;
void StartMixing( RageSoundBase *snd ); /* used by RageSound */
void StopMixing( RageSoundBase *snd ); /* used by RageSound */
int GetPosition( const RageSoundBase *snd ) const;
void Update(float delta);
void VolumeChanged();
@@ -131,7 +131,7 @@ bool RageSound_DSound_Software::GetData()
}
void RageSound_DSound_Software::StartMixing(RageSound *snd)
void RageSound_DSound_Software::StartMixing( RageSoundBase *snd )
{
sound *s = new sound;
s->snd = snd;
@@ -146,7 +146,7 @@ void RageSound_DSound_Software::Update(float delta)
ASSERT(SOUNDMAN);
LockMut(SOUNDMAN->lock);
/* SoundStopped might erase sounds out from under us, so make a copy
/* StopPlaying might erase sounds out from under us, so make a copy
* of the sound list. */
vector<sound *> snds = sounds;
for(unsigned i = 0; i < snds.size(); ++i)
@@ -161,7 +161,7 @@ void RageSound_DSound_Software::Update(float delta)
}
}
void RageSound_DSound_Software::StopMixing(RageSound *snd)
void RageSound_DSound_Software::StopMixing( RageSoundBase *snd )
{
LockMut(SOUNDMAN->lock);
@@ -184,7 +184,7 @@ void RageSound_DSound_Software::StopMixing(RageSound *snd)
pcm->Reset();
}
int RageSound_DSound_Software::GetPosition(const RageSound *snd) const
int RageSound_DSound_Software::GetPosition( const RageSoundBase *snd ) const
{
LockMut(SOUNDMAN->lock);
return pcm->GetPosition();
@@ -12,7 +12,7 @@ struct IDirectSoundBuffer;
class RageSound_DSound_Software: public RageSoundDriver
{
struct sound {
RageSound *snd;
RageSoundBase *snd;
RageTimer start_time;
bool stopping;
@@ -38,9 +38,9 @@ class RageSound_DSound_Software: public RageSoundDriver
RageThread MixingThread;
/* virtuals: */
void StartMixing(RageSound *snd); /* used by RageSound */
void StopMixing(RageSound *snd); /* used by RageSound */
int GetPosition(const RageSound *snd) const;
void StartMixing( RageSoundBase *snd ); /* used by RageSound */
void StopMixing( RageSoundBase *snd ); /* used by RageSound */
int GetPosition( const RageSoundBase *snd ) const;
float GetPlayLatency() const;
int GetSampleRate( int rate ) const;
@@ -85,7 +85,7 @@ bool RageSound_Null::GetData()
return true;
}
void RageSound_Null::StartMixing(RageSound *snd)
void RageSound_Null::StartMixing( RageSoundBase *snd )
{
sound *s = new sound;
s->snd = snd;
@@ -113,7 +113,7 @@ void RageSound_Null::Update(float delta)
}
}
void RageSound_Null::StopMixing(RageSound *snd)
void RageSound_Null::StopMixing( RageSoundBase *snd )
{
LockMutex L(SOUNDMAN->lock);
@@ -131,7 +131,7 @@ void RageSound_Null::StopMixing(RageSound *snd)
sounds.erase(sounds.begin()+i, sounds.begin()+i+1);
}
int RageSound_Null::GetPosition(const RageSound *snd) const
int RageSound_Null::GetPosition( const RageSoundBase *snd ) const
{
return int(RageTimer::GetTimeSinceStart() * samplerate);
}
@@ -20,7 +20,7 @@ class RageSound_Null: public RageSoundDriver
{
private:
struct sound {
RageSound *snd;
RageSoundBase *snd;
bool stopping;
int samples_buffered; /* fake */
sound() { snd = NULL; stopping=false; samples_buffered = 0; }
@@ -37,9 +37,9 @@ private:
protected:
/* virtuals: */
virtual void StartMixing(RageSound *snd);
virtual void StopMixing(RageSound *snd);
virtual int GetPosition(const RageSound *snd) const;
virtual void StartMixing( RageSoundBase *snd );
virtual void StopMixing( RageSoundBase *snd );
virtual int GetPosition( const RageSoundBase *snd ) const;
virtual float GetPlayLatency() const;
virtual void Update(float delta);
virtual bool GetData();
@@ -134,7 +134,7 @@ bool RageSound_WaveOut::GetData()
return true;
}
void RageSound_WaveOut::StartMixing(RageSound *snd)
void RageSound_WaveOut::StartMixing( RageSoundBase *snd )
{
sound *s = new sound;
s->snd = snd;
@@ -163,7 +163,7 @@ void RageSound_WaveOut::Update(float delta)
}
}
void RageSound_WaveOut::StopMixing(RageSound *snd)
void RageSound_WaveOut::StopMixing( RageSoundBase *snd )
{
LockMutex L(SOUNDMAN->lock);
@@ -181,7 +181,7 @@ void RageSound_WaveOut::StopMixing(RageSound *snd)
sounds.erase(sounds.begin()+i, sounds.begin()+i+1);
}
int RageSound_WaveOut::GetPosition(const RageSound *snd) const
int RageSound_WaveOut::GetPosition( const RageSoundBase *snd ) const
{
LockMutex L(SOUNDMAN->lock);
@@ -10,7 +10,7 @@
class RageSound_WaveOut: public RageSoundDriver
{
struct sound {
RageSound *snd;
RageSoundBase *snd;
RageTimer start_time;
bool stopping;
@@ -37,9 +37,9 @@ class RageSound_WaveOut: public RageSoundDriver
void Update(float delta);
/* virtuals: */
void StartMixing(RageSound *snd); /* used by RageSound */
void StopMixing(RageSound *snd); /* used by RageSound */
int GetPosition(const RageSound *snd) const;
void StartMixing( RageSoundBase *snd ); /* used by RageSound */
void StopMixing( RageSoundBase *snd ); /* used by RageSound */
int GetPosition( const RageSoundBase *snd ) const;
float GetPlayLatency() const;
public: