s/str_ds/pcm/
This commit is contained in:
@@ -67,7 +67,7 @@ void RageSound_DSound::MixerThread()
|
|||||||
* 90ms (our buffer size) longer to close. */
|
* 90ms (our buffer size) longer to close. */
|
||||||
for(unsigned i = 0; i < stream_pool.size(); ++i)
|
for(unsigned i = 0; i < stream_pool.size(); ++i)
|
||||||
if(stream_pool[i]->state != stream_pool[i]->INACTIVE)
|
if(stream_pool[i]->state != stream_pool[i]->INACTIVE)
|
||||||
stream_pool[i]->str_ds->Stop();
|
stream_pool[i]->pcm->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageSound_DSound::Update(float delta)
|
void RageSound_DSound::Update(float delta)
|
||||||
@@ -82,7 +82,7 @@ void RageSound_DSound::Update(float delta)
|
|||||||
{
|
{
|
||||||
if(str[i]->state != str[i]->STOPPING) continue;
|
if(str[i]->state != str[i]->STOPPING) continue;
|
||||||
|
|
||||||
int ps = str[i]->str_ds->GetPosition();
|
int ps = str[i]->pcm->GetPosition();
|
||||||
if(ps < str[i]->flush_pos)
|
if(ps < str[i]->flush_pos)
|
||||||
continue; /* stopping but still flushing */
|
continue; /* stopping but still flushing */
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ void RageSound_DSound::Update(float delta)
|
|||||||
str[i]->snd->StopPlaying();
|
str[i]->snd->StopPlaying();
|
||||||
str[i]->snd = NULL;
|
str[i]->snd = NULL;
|
||||||
|
|
||||||
str[i]->str_ds->Stop();
|
str[i]->pcm->Stop();
|
||||||
str[i]->state = str[i]->INACTIVE;
|
str[i]->state = str[i]->INACTIVE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,17 +105,17 @@ bool RageSound_DSound::stream::GetData(bool init)
|
|||||||
|
|
||||||
char *locked_buf;
|
char *locked_buf;
|
||||||
unsigned len;
|
unsigned len;
|
||||||
const int play_pos = str_ds->GetOutputPosition();
|
const int play_pos = pcm->GetOutputPosition();
|
||||||
const int cur_play_pos = str_ds->GetPosition();
|
const int cur_play_pos = pcm->GetPosition();
|
||||||
|
|
||||||
if(init) {
|
if(init) {
|
||||||
/* We're initializing; fill the entire buffer. The buffer is supposed to
|
/* We're initializing; fill the entire buffer. The buffer is supposed to
|
||||||
* be empty, so this should never fail. */
|
* be empty, so this should never fail. */
|
||||||
if(!str_ds->get_output_buf(&locked_buf, &len, buffersize))
|
if(!pcm->get_output_buf(&locked_buf, &len, buffersize))
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
} else {
|
} else {
|
||||||
/* Just fill one chunk. */
|
/* Just fill one chunk. */
|
||||||
if(!str_ds->get_output_buf(&locked_buf, &len, chunksize))
|
if(!pcm->get_output_buf(&locked_buf, &len, chunksize))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,7 +132,7 @@ bool RageSound_DSound::stream::GetData(bool init)
|
|||||||
/* 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 int iFramesUntilThisBuffer = play_pos - cur_play_pos;
|
||||||
const float fSecondsBeforeStart = -start_time.Ago();
|
const float fSecondsBeforeStart = -start_time.Ago();
|
||||||
const int iFramesBeforeStart = int(fSecondsBeforeStart * str_ds->GetSampleRate());
|
const int iFramesBeforeStart = int(fSecondsBeforeStart * pcm->GetSampleRate());
|
||||||
const int iSilentFramesInThisBuffer = iFramesBeforeStart-iFramesUntilThisBuffer;
|
const int iSilentFramesInThisBuffer = iFramesBeforeStart-iFramesUntilThisBuffer;
|
||||||
const int iSilentBytesInThisBuffer = clamp( iSilentFramesInThisBuffer * bytes_per_frame, 0, bytes_left );
|
const int iSilentBytesInThisBuffer = clamp( iSilentFramesInThisBuffer * bytes_per_frame, 0, bytes_left );
|
||||||
|
|
||||||
@@ -157,21 +157,21 @@ bool RageSound_DSound::stream::GetData(bool init)
|
|||||||
state = STOPPING;
|
state = STOPPING;
|
||||||
|
|
||||||
/* Keep playing until the data we currently have locked has played. */
|
/* Keep playing until the data we currently have locked has played. */
|
||||||
flush_pos = str_ds->GetOutputPosition();
|
flush_pos = pcm->GetOutputPosition();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Silence the buffer. */
|
/* Silence the buffer. */
|
||||||
memset(locked_buf, 0, len);
|
memset(locked_buf, 0, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
str_ds->release_output_buf(locked_buf, len);
|
pcm->release_output_buf(locked_buf, len);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
RageSound_DSound::stream::~stream()
|
RageSound_DSound::stream::~stream()
|
||||||
{
|
{
|
||||||
delete str_ds;
|
delete pcm;
|
||||||
}
|
}
|
||||||
|
|
||||||
RageSound_DSound::RageSound_DSound()
|
RageSound_DSound::RageSound_DSound()
|
||||||
@@ -208,7 +208,7 @@ RageSound_DSound::RageSound_DSound()
|
|||||||
}
|
}
|
||||||
|
|
||||||
stream *s = new stream;
|
stream *s = new stream;
|
||||||
s->str_ds = newbuf;
|
s->pcm = newbuf;
|
||||||
stream_pool.push_back(s);
|
stream_pool.push_back(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ void RageSound_DSound::VolumeChanged()
|
|||||||
{
|
{
|
||||||
for(unsigned i = 0; i < stream_pool.size(); ++i)
|
for(unsigned i = 0; i < stream_pool.size(); ++i)
|
||||||
{
|
{
|
||||||
stream_pool[i]->str_ds->SetVolume(SOUNDMAN->GetMixVolume());
|
stream_pool[i]->pcm->SetVolume(SOUNDMAN->GetMixVolume());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,14 +265,14 @@ void RageSound_DSound::StartMixing(RageSound *snd)
|
|||||||
|
|
||||||
/* Give the stream to the playing sound and remove it from the pool. */
|
/* Give the stream to the playing sound and remove it from the pool. */
|
||||||
stream_pool[i]->snd = snd;
|
stream_pool[i]->snd = snd;
|
||||||
stream_pool[i]->str_ds->SetSampleRate(snd->GetSampleRate());
|
stream_pool[i]->pcm->SetSampleRate(snd->GetSampleRate());
|
||||||
stream_pool[i]->start_time = snd->GetStartTime();
|
stream_pool[i]->start_time = snd->GetStartTime();
|
||||||
|
|
||||||
/* Pre-buffer the stream. */
|
/* Pre-buffer the stream. */
|
||||||
/* There are two buffers of data; fill them both ahead of time so the
|
/* There are two buffers of data; fill them both ahead of time so the
|
||||||
* sound can start almost immediately. */
|
* sound can start almost immediately. */
|
||||||
stream_pool[i]->GetData(true);
|
stream_pool[i]->GetData(true);
|
||||||
stream_pool[i]->str_ds->Play();
|
stream_pool[i]->pcm->Play();
|
||||||
|
|
||||||
/* Normally, at this point we should still be INACTIVE, in which case,
|
/* Normally, at this point we should still be INACTIVE, in which case,
|
||||||
* tell the mixer thread to start mixing this channel. However, if it's
|
* tell the mixer thread to start mixing this channel. However, if it's
|
||||||
@@ -312,7 +312,7 @@ void RageSound_DSound::StopMixing(RageSound *snd)
|
|||||||
stream_pool[i]->state = stream_pool[i]->STOPPING;
|
stream_pool[i]->state = stream_pool[i]->STOPPING;
|
||||||
|
|
||||||
/* Flush two buffers worth of data. */
|
/* Flush two buffers worth of data. */
|
||||||
stream_pool[i]->flush_pos = stream_pool[i]->str_ds->GetOutputPosition();
|
stream_pool[i]->flush_pos = stream_pool[i]->pcm->GetOutputPosition();
|
||||||
|
|
||||||
/* This function is called externally (by RageSound) to stop immediately.
|
/* This function is called externally (by RageSound) to stop immediately.
|
||||||
* We need to prevent SoundStopped from being called; it should only be
|
* We need to prevent SoundStopped from being called; it should only be
|
||||||
@@ -333,7 +333,7 @@ int RageSound_DSound::GetPosition(const RageSound *snd) const
|
|||||||
|
|
||||||
ASSERT(i != stream_pool.size());
|
ASSERT(i != stream_pool.size());
|
||||||
|
|
||||||
return stream_pool[i]->str_ds->GetPosition();
|
return stream_pool[i]->pcm->GetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class RageSound_DSound: public RageSoundDriver
|
|||||||
{
|
{
|
||||||
struct stream {
|
struct stream {
|
||||||
/* Actual audio stream: */
|
/* Actual audio stream: */
|
||||||
DSoundBuf *str_ds;
|
DSoundBuf *pcm;
|
||||||
|
|
||||||
/* 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: */
|
||||||
@@ -30,7 +30,7 @@ class RageSound_DSound: public RageSoundDriver
|
|||||||
RageTimer start_time;
|
RageTimer start_time;
|
||||||
bool GetData(bool init);
|
bool GetData(bool init);
|
||||||
|
|
||||||
stream() { str_ds = NULL; snd = NULL; state=INACTIVE; }
|
stream() { pcm = NULL; snd = NULL; state=INACTIVE; }
|
||||||
~stream();
|
~stream();
|
||||||
};
|
};
|
||||||
friend struct stream;
|
friend struct stream;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ void RageSound_DSound_Software::MixerThread()
|
|||||||
;
|
;
|
||||||
|
|
||||||
/* Start playing. */
|
/* Start playing. */
|
||||||
str_ds->Play();
|
pcm->Play();
|
||||||
|
|
||||||
while(!shutdown) {
|
while(!shutdown) {
|
||||||
Sleep(10);
|
Sleep(10);
|
||||||
@@ -54,7 +54,7 @@ void RageSound_DSound_Software::MixerThread()
|
|||||||
|
|
||||||
/* I'm not sure why, but if we don't stop the stream now, then the thread will take
|
/* I'm not sure why, but if we don't stop the stream now, then the thread will take
|
||||||
* 90ms (our buffer size) longer to close. */
|
* 90ms (our buffer size) longer to close. */
|
||||||
str_ds->Stop();
|
pcm->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RageSound_DSound_Software::GetData()
|
bool RageSound_DSound_Software::GetData()
|
||||||
@@ -63,10 +63,10 @@ bool RageSound_DSound_Software::GetData()
|
|||||||
|
|
||||||
char *locked_buf;
|
char *locked_buf;
|
||||||
unsigned len;
|
unsigned len;
|
||||||
const int play_pos = str_ds->GetOutputPosition();
|
const int play_pos = pcm->GetOutputPosition();
|
||||||
const int cur_play_pos = str_ds->GetPosition();
|
const int cur_play_pos = pcm->GetPosition();
|
||||||
|
|
||||||
if(!str_ds->get_output_buf(&locked_buf, &len, chunksize))
|
if(!pcm->get_output_buf(&locked_buf, &len, chunksize))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Silence the buffer. */
|
/* Silence the buffer. */
|
||||||
@@ -119,13 +119,13 @@ bool RageSound_DSound_Software::GetData()
|
|||||||
{
|
{
|
||||||
/* This sound is finishing. */
|
/* This sound is finishing. */
|
||||||
sounds[i]->stopping = true;
|
sounds[i]->stopping = true;
|
||||||
sounds[i]->flush_pos = str_ds->GetOutputPosition();
|
sounds[i]->flush_pos = pcm->GetOutputPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mix.read((Sint16 *) locked_buf);
|
mix.read((Sint16 *) locked_buf);
|
||||||
|
|
||||||
str_ds->release_output_buf(locked_buf, len);
|
pcm->release_output_buf(locked_buf, len);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -181,13 +181,13 @@ void RageSound_DSound_Software::StopMixing(RageSound *snd)
|
|||||||
/* If nothing is playing, reset the frame count; this is just to
|
/* If nothing is playing, reset the frame count; this is just to
|
||||||
* prevent eventual overflow. */
|
* prevent eventual overflow. */
|
||||||
if(sounds.empty())
|
if(sounds.empty())
|
||||||
str_ds->Reset();
|
pcm->Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
int RageSound_DSound_Software::GetPosition(const RageSound *snd) const
|
int RageSound_DSound_Software::GetPosition(const RageSound *snd) const
|
||||||
{
|
{
|
||||||
LockMut(SOUNDMAN->lock);
|
LockMut(SOUNDMAN->lock);
|
||||||
return str_ds->GetPosition();
|
return pcm->GetPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
RageSound_DSound_Software::RageSound_DSound_Software()
|
RageSound_DSound_Software::RageSound_DSound_Software()
|
||||||
@@ -200,7 +200,7 @@ RageSound_DSound_Software::RageSound_DSound_Software()
|
|||||||
RageException::ThrowNonfatal("Driver unusable (emulated device)");
|
RageException::ThrowNonfatal("Driver unusable (emulated device)");
|
||||||
|
|
||||||
/* Create a DirectSound stream, but don't force it into hardware. */
|
/* Create a DirectSound stream, but don't force it into hardware. */
|
||||||
str_ds = new DSoundBuf(ds,
|
pcm = new DSoundBuf(ds,
|
||||||
DSoundBuf::HW_DONT_CARE,
|
DSoundBuf::HW_DONT_CARE,
|
||||||
channels, samplerate, 16, buffersize);
|
channels, samplerate, 16, buffersize);
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ RageSound_DSound_Software::~RageSound_DSound_Software()
|
|||||||
LOG->Trace("Mixer thread shut down.");
|
LOG->Trace("Mixer thread shut down.");
|
||||||
LOG->Flush();
|
LOG->Flush();
|
||||||
|
|
||||||
delete str_ds;
|
delete pcm;
|
||||||
}
|
}
|
||||||
|
|
||||||
float RageSound_DSound_Software::GetPlayLatency() const
|
float RageSound_DSound_Software::GetPlayLatency() const
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class RageSound_DSound_Software: public RageSoundDriver
|
|||||||
bool shutdown;
|
bool shutdown;
|
||||||
|
|
||||||
DSound ds;
|
DSound ds;
|
||||||
DSoundBuf *str_ds;
|
DSoundBuf *pcm;
|
||||||
|
|
||||||
bool GetData();
|
bool GetData();
|
||||||
void Update(float delta);
|
void Update(float delta);
|
||||||
|
|||||||
Reference in New Issue
Block a user