s/RageSound/RageSoundBase/
linux/mac in a moment
This commit is contained in:
@@ -1,30 +1,29 @@
|
|||||||
#ifndef RAGE_SOUND_DRIVER
|
#ifndef RAGE_SOUND_DRIVER
|
||||||
#define RAGE_SOUND_DRIVER
|
#define RAGE_SOUND_DRIVER
|
||||||
|
|
||||||
|
class RageSoundBase;
|
||||||
class RageSoundDriver
|
class RageSoundDriver
|
||||||
{
|
{
|
||||||
friend class RageSound;
|
public:
|
||||||
|
|
||||||
protected:
|
|
||||||
friend class RageSoundManager;
|
friend class RageSoundManager;
|
||||||
/* A RageSound calls this to request to be played.
|
/* A RageSound calls this to request to be played.
|
||||||
* XXX: define what we should do when it can't be played (eg. out of
|
* XXX: define what we should do when it can't be played (eg. out of
|
||||||
* channels) */
|
* 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
|
/* 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
|
* returns, snd is no longer valid; ensure no running threads are still
|
||||||
* accessing it before returning. This must handle gracefully the case where
|
* accessing it before returning. This must handle gracefully the case where
|
||||||
* snd was not actually being played, though it may print a warning. */
|
* 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
|
/* Get the current position of a given buffer, in the same units and time base
|
||||||
* as passed to RageSound::GetPCM. */
|
* 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
|
/* 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),
|
||||||
* 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: */
|
/* Optional, if needed: */
|
||||||
virtual void Update(float delta) { }
|
virtual void Update(float delta) { }
|
||||||
@@ -39,7 +38,6 @@ protected:
|
|||||||
|
|
||||||
virtual int GetSampleRate( int rate ) const { return 44100; }
|
virtual int GetSampleRate( int rate ) const { return 44100; }
|
||||||
|
|
||||||
public:
|
|
||||||
virtual ~RageSoundDriver() { }
|
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);
|
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
|
* call completes, snd->GetPCM (which runs in a separate thread) will
|
||||||
* not be running and will not be called unless StartMixing is called
|
* not be running and will not be called unless StartMixing is called
|
||||||
* again. */
|
* again. */
|
||||||
void RageSound_DSound::StopMixing(RageSound *snd)
|
void RageSound_DSound::StopMixing( RageSoundBase *snd )
|
||||||
{
|
{
|
||||||
ASSERT(snd != NULL);
|
ASSERT(snd != NULL);
|
||||||
LockMutex L(SOUNDMAN->lock);
|
LockMutex L(SOUNDMAN->lock);
|
||||||
@@ -321,7 +321,7 @@ void RageSound_DSound::StopMixing(RageSound *snd)
|
|||||||
stream_pool[i]->snd = NULL;
|
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);
|
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
|
/* Sound object that's playing on this stream, or NULL if this
|
||||||
* channel is available: */
|
* channel is available: */
|
||||||
RageSound *snd;
|
RageSoundBase *snd;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
INACTIVE,
|
INACTIVE,
|
||||||
@@ -47,9 +47,9 @@ class RageSound_DSound: public RageSoundDriver
|
|||||||
RageThread MixingThread;
|
RageThread MixingThread;
|
||||||
|
|
||||||
/* virtuals: */
|
/* virtuals: */
|
||||||
void StartMixing(RageSound *snd); /* used by RageSound */
|
void StartMixing( RageSoundBase *snd ); /* used by RageSound */
|
||||||
void StopMixing(RageSound *snd); /* used by RageSound */
|
void StopMixing( RageSoundBase *snd ); /* used by RageSound */
|
||||||
int GetPosition(const RageSound *snd) const;
|
int GetPosition( const RageSoundBase *snd ) const;
|
||||||
void Update(float delta);
|
void Update(float delta);
|
||||||
void VolumeChanged();
|
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;
|
sound *s = new sound;
|
||||||
s->snd = snd;
|
s->snd = snd;
|
||||||
@@ -146,7 +146,7 @@ void RageSound_DSound_Software::Update(float delta)
|
|||||||
ASSERT(SOUNDMAN);
|
ASSERT(SOUNDMAN);
|
||||||
LockMut(SOUNDMAN->lock);
|
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. */
|
* of the sound list. */
|
||||||
vector<sound *> snds = sounds;
|
vector<sound *> snds = sounds;
|
||||||
for(unsigned i = 0; i < snds.size(); ++i)
|
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);
|
LockMut(SOUNDMAN->lock);
|
||||||
|
|
||||||
@@ -184,7 +184,7 @@ void RageSound_DSound_Software::StopMixing(RageSound *snd)
|
|||||||
pcm->Reset();
|
pcm->Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
int RageSound_DSound_Software::GetPosition(const RageSound *snd) const
|
int RageSound_DSound_Software::GetPosition( const RageSoundBase *snd ) const
|
||||||
{
|
{
|
||||||
LockMut(SOUNDMAN->lock);
|
LockMut(SOUNDMAN->lock);
|
||||||
return pcm->GetPosition();
|
return pcm->GetPosition();
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ struct IDirectSoundBuffer;
|
|||||||
class RageSound_DSound_Software: public RageSoundDriver
|
class RageSound_DSound_Software: public RageSoundDriver
|
||||||
{
|
{
|
||||||
struct sound {
|
struct sound {
|
||||||
RageSound *snd;
|
RageSoundBase *snd;
|
||||||
RageTimer start_time;
|
RageTimer start_time;
|
||||||
|
|
||||||
bool stopping;
|
bool stopping;
|
||||||
@@ -38,9 +38,9 @@ class RageSound_DSound_Software: public RageSoundDriver
|
|||||||
RageThread MixingThread;
|
RageThread MixingThread;
|
||||||
|
|
||||||
/* virtuals: */
|
/* virtuals: */
|
||||||
void StartMixing(RageSound *snd); /* used by RageSound */
|
void StartMixing( RageSoundBase *snd ); /* used by RageSound */
|
||||||
void StopMixing(RageSound *snd); /* used by RageSound */
|
void StopMixing( RageSoundBase *snd ); /* used by RageSound */
|
||||||
int GetPosition(const RageSound *snd) const;
|
int GetPosition( const RageSoundBase *snd ) const;
|
||||||
float GetPlayLatency() const;
|
float GetPlayLatency() const;
|
||||||
int GetSampleRate( int rate ) const;
|
int GetSampleRate( int rate ) const;
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ bool RageSound_Null::GetData()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageSound_Null::StartMixing(RageSound *snd)
|
void RageSound_Null::StartMixing( RageSoundBase *snd )
|
||||||
{
|
{
|
||||||
sound *s = new sound;
|
sound *s = new sound;
|
||||||
s->snd = snd;
|
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);
|
LockMutex L(SOUNDMAN->lock);
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ void RageSound_Null::StopMixing(RageSound *snd)
|
|||||||
sounds.erase(sounds.begin()+i, sounds.begin()+i+1);
|
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);
|
return int(RageTimer::GetTimeSinceStart() * samplerate);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class RageSound_Null: public RageSoundDriver
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
struct sound {
|
struct sound {
|
||||||
RageSound *snd;
|
RageSoundBase *snd;
|
||||||
bool stopping;
|
bool stopping;
|
||||||
int samples_buffered; /* fake */
|
int samples_buffered; /* fake */
|
||||||
sound() { snd = NULL; stopping=false; samples_buffered = 0; }
|
sound() { snd = NULL; stopping=false; samples_buffered = 0; }
|
||||||
@@ -37,9 +37,9 @@ private:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* virtuals: */
|
/* virtuals: */
|
||||||
virtual void StartMixing(RageSound *snd);
|
virtual void StartMixing( RageSoundBase *snd );
|
||||||
virtual void StopMixing(RageSound *snd);
|
virtual void StopMixing( RageSoundBase *snd );
|
||||||
virtual int GetPosition(const RageSound *snd) const;
|
virtual int GetPosition( const RageSoundBase *snd ) const;
|
||||||
virtual float GetPlayLatency() const;
|
virtual float GetPlayLatency() const;
|
||||||
virtual void Update(float delta);
|
virtual void Update(float delta);
|
||||||
virtual bool GetData();
|
virtual bool GetData();
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ bool RageSound_WaveOut::GetData()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageSound_WaveOut::StartMixing(RageSound *snd)
|
void RageSound_WaveOut::StartMixing( RageSoundBase *snd )
|
||||||
{
|
{
|
||||||
sound *s = new sound;
|
sound *s = new sound;
|
||||||
s->snd = snd;
|
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);
|
LockMutex L(SOUNDMAN->lock);
|
||||||
|
|
||||||
@@ -181,7 +181,7 @@ void RageSound_WaveOut::StopMixing(RageSound *snd)
|
|||||||
sounds.erase(sounds.begin()+i, sounds.begin()+i+1);
|
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);
|
LockMutex L(SOUNDMAN->lock);
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
class RageSound_WaveOut: public RageSoundDriver
|
class RageSound_WaveOut: public RageSoundDriver
|
||||||
{
|
{
|
||||||
struct sound {
|
struct sound {
|
||||||
RageSound *snd;
|
RageSoundBase *snd;
|
||||||
RageTimer start_time;
|
RageTimer start_time;
|
||||||
|
|
||||||
bool stopping;
|
bool stopping;
|
||||||
@@ -37,9 +37,9 @@ class RageSound_WaveOut: public RageSoundDriver
|
|||||||
void Update(float delta);
|
void Update(float delta);
|
||||||
|
|
||||||
/* virtuals: */
|
/* virtuals: */
|
||||||
void StartMixing(RageSound *snd); /* used by RageSound */
|
void StartMixing( RageSoundBase *snd ); /* used by RageSound */
|
||||||
void StopMixing(RageSound *snd); /* used by RageSound */
|
void StopMixing( RageSoundBase *snd ); /* used by RageSound */
|
||||||
int GetPosition(const RageSound *snd) const;
|
int GetPosition( const RageSoundBase *snd ) const;
|
||||||
float GetPlayLatency() const;
|
float GetPlayLatency() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user