stop saying samples when we mean frames
This commit is contained in:
@@ -20,11 +20,6 @@ BOOL CALLBACK DSound::EnumCallback(LPGUID lpGuid, LPCSTR lpcstrDescription, LPCS
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The PortAudio directsound code does this. I'm not sure if it actually matters;
|
|
||||||
* it's an experiment based on some recent reports. (The default primary buffer
|
|
||||||
* mode is 22050 8-bit. However, we mix through secondary buffers, and I'm not sure
|
|
||||||
* when the primary buffer mode matters there--I'm certainly not getting 22050 8-bit
|
|
||||||
* sound.) */
|
|
||||||
void DSound::SetPrimaryBufferMode()
|
void DSound::SetPrimaryBufferMode()
|
||||||
{
|
{
|
||||||
#ifndef _XBOX
|
#ifndef _XBOX
|
||||||
@@ -397,7 +392,7 @@ bool DSoundBuf::get_output_buf(char **buffer, unsigned *bufsiz, int chunksize)
|
|||||||
|
|
||||||
/* Increment last_cursor_pos to point at where the data we're about to
|
/* Increment last_cursor_pos to point at where the data we're about to
|
||||||
* ask for will actually be played. */
|
* ask for will actually be played. */
|
||||||
last_cursor_pos += num_bytes_empty / samplesize();
|
last_cursor_pos += num_bytes_empty / bytes_per_frame();
|
||||||
|
|
||||||
buffer_locked = true;
|
buffer_locked = true;
|
||||||
|
|
||||||
@@ -414,8 +409,8 @@ int DSoundBuf::GetPosition() const
|
|||||||
{
|
{
|
||||||
DWORD cursor, junk;
|
DWORD cursor, junk;
|
||||||
buf->GetCurrentPosition(&cursor, &junk);
|
buf->GetCurrentPosition(&cursor, &junk);
|
||||||
int cursor_frames = int(cursor) / samplesize();
|
int cursor_frames = int(cursor) / bytes_per_frame();
|
||||||
int write_cursor_frames = write_cursor / samplesize();
|
int write_cursor_frames = write_cursor / bytes_per_frame();
|
||||||
|
|
||||||
int frames_behind = write_cursor_frames - cursor_frames;
|
int frames_behind = write_cursor_frames - cursor_frames;
|
||||||
if(frames_behind <= 0)
|
if(frames_behind <= 0)
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ class DSoundBuf
|
|||||||
|
|
||||||
int buffersize;
|
int buffersize;
|
||||||
|
|
||||||
int buffersize_frames() const { return buffersize / samplesize(); }
|
int buffersize_frames() const { return buffersize / bytes_per_frame(); }
|
||||||
int samplesize() const { return channels*samplebits/8; }
|
int bytes_per_frame() const { return channels*samplebits/8; }
|
||||||
|
|
||||||
int write_cursor, buffer_bytes_filled; /* bytes */
|
int write_cursor, buffer_bytes_filled; /* bytes */
|
||||||
int last_cursor_pos; /* frames */
|
int last_cursor_pos; /* frames */
|
||||||
|
|||||||
@@ -12,10 +12,10 @@
|
|||||||
|
|
||||||
/* samples */
|
/* samples */
|
||||||
const int channels = 2;
|
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 samplerate = 44100;
|
||||||
const int buffersize_frames = 1024*4; /* in frames */
|
const int buffersize_frames = 1024*4; /* in frames */
|
||||||
const int buffersize = buffersize_frames * samplesize; /* in bytes */
|
const int buffersize = buffersize_frames * bytes_per_frame; /* in bytes */
|
||||||
|
|
||||||
/* We'll fill the buffer in chunks this big. This should evenly divide the
|
/* We'll fill the buffer in chunks this big. This should evenly divide the
|
||||||
* buffer size. */
|
* buffer size. */
|
||||||
@@ -154,7 +154,7 @@ void RageSound_DSound_Software::StopMixing(RageSound *snd)
|
|||||||
delete sounds[i];
|
delete sounds[i];
|
||||||
sounds.erase(sounds.begin()+i, sounds.begin()+i+1);
|
sounds.erase(sounds.begin()+i, sounds.begin()+i+1);
|
||||||
|
|
||||||
/* If nothing is playing, reset the sample 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();
|
str_ds->Reset();
|
||||||
|
|||||||
Reference in New Issue
Block a user