From b2b6db3a5be493e9d890a0df5e77e8fa61068d6e Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 12 Jan 2004 04:00:34 +0000 Subject: [PATCH] stop saying samples when we mean frames latency tweak --- stepmania/src/arch/Sound/RageSoundDriver_WaveOut.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/stepmania/src/arch/Sound/RageSoundDriver_WaveOut.cpp b/stepmania/src/arch/Sound/RageSoundDriver_WaveOut.cpp index 09cbcd8056..55c4925c1b 100644 --- a/stepmania/src/arch/Sound/RageSoundDriver_WaveOut.cpp +++ b/stepmania/src/arch/Sound/RageSoundDriver_WaveOut.cpp @@ -11,12 +11,11 @@ #include "SDL.h" -/* samples */ const int channels = 2; -const int samplesize = channels*2; /* 16-bit */ +const int bytes_per_frame = channels*2; /* 16-bit */ const int samplerate = 44100; const int buffersize_frames = 1024*8; /* in frames */ -const int buffersize = buffersize_frames * samplesize; /* in bytes */ +const int buffersize = buffersize_frames * bytes_per_frame; /* in bytes */ const int num_chunks = 8; const int chunksize_frames = buffersize_frames / num_chunks; @@ -95,7 +94,7 @@ bool RageSound_WaveOut::GetData() { /* This sound is finishing. */ sounds[i]->stopping = true; - sounds[i]->flush_pos = last_cursor_pos + (got / samplesize); + sounds[i]->flush_pos = last_cursor_pos + (got / bytes_per_frame); } } @@ -228,7 +227,9 @@ RageSound_WaveOut::~RageSound_WaveOut() float RageSound_WaveOut::GetPlayLatency() const { - return (1.0f / samplerate) * (buffersize_frames - chunksize_frames); + /* If we have a 1000-byte buffer, and we fill 100 bytes at a time, we + * almost always have between 900 and 1000 bytes filled; on average, 950. */ + return (buffersize_frames - chunksize_frames/2) * (1.0f / samplerate); } /*