s/str_ds/pcm/

This commit is contained in:
Glenn Maynard
2004-01-12 23:10:14 +00:00
parent e10c8da4b6
commit dc5cfb53a8
4 changed files with 31 additions and 31 deletions
@@ -67,7 +67,7 @@ void RageSound_DSound::MixerThread()
* 90ms (our buffer size) longer to close. */
for(unsigned i = 0; i < stream_pool.size(); ++i)
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)
@@ -82,7 +82,7 @@ void RageSound_DSound::Update(float delta)
{
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)
continue; /* stopping but still flushing */
@@ -91,7 +91,7 @@ void RageSound_DSound::Update(float delta)
str[i]->snd->StopPlaying();
str[i]->snd = NULL;
str[i]->str_ds->Stop();
str[i]->pcm->Stop();
str[i]->state = str[i]->INACTIVE;
}
}
@@ -105,17 +105,17 @@ bool RageSound_DSound::stream::GetData(bool init)
char *locked_buf;
unsigned len;
const int play_pos = str_ds->GetOutputPosition();
const int cur_play_pos = str_ds->GetPosition();
const int play_pos = pcm->GetOutputPosition();
const int cur_play_pos = pcm->GetPosition();
if(init) {
/* We're initializing; fill the entire buffer. The buffer is supposed to
* 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);
} else {
/* 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;
}
@@ -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. */
const int iFramesUntilThisBuffer = play_pos - cur_play_pos;
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 iSilentBytesInThisBuffer = clamp( iSilentFramesInThisBuffer * bytes_per_frame, 0, bytes_left );
@@ -157,21 +157,21 @@ bool RageSound_DSound::stream::GetData(bool init)
state = STOPPING;
/* Keep playing until the data we currently have locked has played. */
flush_pos = str_ds->GetOutputPosition();
flush_pos = pcm->GetOutputPosition();
}
} else {
/* Silence the buffer. */
memset(locked_buf, 0, len);
}
str_ds->release_output_buf(locked_buf, len);
pcm->release_output_buf(locked_buf, len);
return true;
}
RageSound_DSound::stream::~stream()
{
delete str_ds;
delete pcm;
}
RageSound_DSound::RageSound_DSound()
@@ -208,7 +208,7 @@ RageSound_DSound::RageSound_DSound()
}
stream *s = new stream;
s->str_ds = newbuf;
s->pcm = newbuf;
stream_pool.push_back(s);
}
@@ -242,7 +242,7 @@ void RageSound_DSound::VolumeChanged()
{
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. */
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();
/* Pre-buffer the stream. */
/* There are two buffers of data; fill them both ahead of time so the
* sound can start almost immediately. */
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,
* 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;
/* 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.
* 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());
return stream_pool[i]->str_ds->GetPosition();
return stream_pool[i]->pcm->GetPosition();
}
/*
@@ -13,7 +13,7 @@ class RageSound_DSound: public RageSoundDriver
{
struct stream {
/* Actual audio stream: */
DSoundBuf *str_ds;
DSoundBuf *pcm;
/* Sound object that's playing on this stream, or NULL if this
* channel is available: */
@@ -30,7 +30,7 @@ class RageSound_DSound: public RageSoundDriver
RageTimer start_time;
bool GetData(bool init);
stream() { str_ds = NULL; snd = NULL; state=INACTIVE; }
stream() { pcm = NULL; snd = NULL; state=INACTIVE; }
~stream();
};
friend struct stream;
@@ -44,7 +44,7 @@ void RageSound_DSound_Software::MixerThread()
;
/* Start playing. */
str_ds->Play();
pcm->Play();
while(!shutdown) {
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
* 90ms (our buffer size) longer to close. */
str_ds->Stop();
pcm->Stop();
}
bool RageSound_DSound_Software::GetData()
@@ -63,10 +63,10 @@ bool RageSound_DSound_Software::GetData()
char *locked_buf;
unsigned len;
const int play_pos = str_ds->GetOutputPosition();
const int cur_play_pos = str_ds->GetPosition();
const int play_pos = pcm->GetOutputPosition();
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;
/* Silence the buffer. */
@@ -119,13 +119,13 @@ bool RageSound_DSound_Software::GetData()
{
/* This sound is finishing. */
sounds[i]->stopping = true;
sounds[i]->flush_pos = str_ds->GetOutputPosition();
sounds[i]->flush_pos = pcm->GetOutputPosition();
}
}
mix.read((Sint16 *) locked_buf);
str_ds->release_output_buf(locked_buf, len);
pcm->release_output_buf(locked_buf, len);
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
* prevent eventual overflow. */
if(sounds.empty())
str_ds->Reset();
pcm->Reset();
}
int RageSound_DSound_Software::GetPosition(const RageSound *snd) const
{
LockMut(SOUNDMAN->lock);
return str_ds->GetPosition();
return pcm->GetPosition();
}
RageSound_DSound_Software::RageSound_DSound_Software()
@@ -200,7 +200,7 @@ RageSound_DSound_Software::RageSound_DSound_Software()
RageException::ThrowNonfatal("Driver unusable (emulated device)");
/* Create a DirectSound stream, but don't force it into hardware. */
str_ds = new DSoundBuf(ds,
pcm = new DSoundBuf(ds,
DSoundBuf::HW_DONT_CARE,
channels, samplerate, 16, buffersize);
@@ -218,7 +218,7 @@ RageSound_DSound_Software::~RageSound_DSound_Software()
LOG->Trace("Mixer thread shut down.");
LOG->Flush();
delete str_ds;
delete pcm;
}
float RageSound_DSound_Software::GetPlayLatency() const
@@ -28,7 +28,7 @@ class RageSound_DSound_Software: public RageSoundDriver
bool shutdown;
DSound ds;
DSoundBuf *str_ds;
DSoundBuf *pcm;
bool GetData();
void Update(float delta);