mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
[sound] Rename sfxbuffer_t's length to size
The field is the size of the buffer, while "length" is a bit ambiguous between buffer length or sfx length.
This commit is contained in:
parent
da90d93135
commit
632226dd32
8 changed files with 20 additions and 20 deletions
|
@ -143,7 +143,7 @@ struct wavinfo_s {
|
|||
struct sfxbuffer_s {
|
||||
unsigned head; //!< ring buffer head position in sampels
|
||||
unsigned tail; //!< ring buffer tail position in sampels
|
||||
unsigned length; //!< length of buffer in frames
|
||||
unsigned size; //!< size of buffer in frames
|
||||
unsigned pos; //!< position of tail within full stream
|
||||
unsigned channels; //!< number of channels per frame
|
||||
sfxpaint_t *paint; //!< channel count specific paint function
|
||||
|
|
|
@ -299,7 +299,7 @@ flac_load (flacfile_t *ff, sfxblock_t *block, cache_allocator_t allocator)
|
|||
SND_SetPaint (sb);
|
||||
SND_SetupResampler (sb, 0);
|
||||
SND_Resample (sb, data, info->frames);
|
||||
sb->head = sb->length;
|
||||
sb->head = sb->size;
|
||||
bail:
|
||||
if (data)
|
||||
free (data);
|
||||
|
|
|
@ -147,9 +147,9 @@ static void
|
|||
read_samples (sfxbuffer_t *buffer, int count)
|
||||
{
|
||||
|
||||
if (buffer->head + count > buffer->length) {
|
||||
count -= buffer->length - buffer->head;
|
||||
read_samples (buffer, buffer->length - buffer->head);
|
||||
if (buffer->head + count > buffer->size) {
|
||||
count -= buffer->size - buffer->head;
|
||||
read_samples (buffer, buffer->size - buffer->head);
|
||||
read_samples (buffer, count);
|
||||
} else {
|
||||
sfx_t *sfx = buffer->sfx;
|
||||
|
@ -163,8 +163,8 @@ read_samples (sfxbuffer_t *buffer, int count)
|
|||
|
||||
if (c > 0) {
|
||||
buffer->head += count;
|
||||
if (buffer->head >= buffer->length)
|
||||
buffer->head -= buffer->length;
|
||||
if (buffer->head >= buffer->size)
|
||||
buffer->head -= buffer->size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ fill_buffer (sfx_t *sfx, sfxstream_t *stream, sfxbuffer_t *buffer,
|
|||
// find out how many samples can be read into the buffer
|
||||
samples = buffer->tail - buffer->head - SAMPLE_GAP;
|
||||
if (buffer->tail <= buffer->head)
|
||||
samples += buffer->length;
|
||||
samples += buffer->size;
|
||||
|
||||
if (headpos + samples > sfx->length) {
|
||||
if (sfx->loopstart == (unsigned int)-1) {
|
||||
|
@ -233,7 +233,7 @@ SND_StreamAdvance (sfxbuffer_t *buffer, unsigned int count)
|
|||
// find out how many samples the buffer currently holds
|
||||
samples = buffer->head - buffer->tail;
|
||||
if (buffer->head < buffer->tail)
|
||||
samples += buffer->length;
|
||||
samples += buffer->size;
|
||||
|
||||
// find out where head points to in the stream
|
||||
headpos = buffer->pos + samples;
|
||||
|
@ -276,8 +276,8 @@ SND_StreamAdvance (sfxbuffer_t *buffer, unsigned int count)
|
|||
}
|
||||
|
||||
buffer->tail += count;
|
||||
if (buffer->tail >= buffer->length)
|
||||
buffer->tail -= buffer->length;
|
||||
if (buffer->tail >= buffer->size)
|
||||
buffer->tail -= buffer->size;
|
||||
}
|
||||
fill_buffer (sfx, stream, buffer, info, headpos);
|
||||
return !stream->error;
|
||||
|
@ -362,7 +362,7 @@ SND_GetCache (long frames, int rate, int channels,
|
|||
if (!sb)
|
||||
return 0;
|
||||
memset (sb, 0, sizeof (sfxbuffer_t) + size);
|
||||
sb->length = len;
|
||||
sb->size = len;
|
||||
memcpy (sb->data + len * channels, "\xde\xad\xbe\xef", 4);
|
||||
return sb;
|
||||
}
|
||||
|
|
|
@ -82,13 +82,13 @@ snd_paint_channel (channel_t *ch, sfxbuffer_t *sb, int count)
|
|||
count -= offs;
|
||||
ch->pos = 0;
|
||||
}
|
||||
if (ch->pos < sb->pos || ch->pos - sb->pos >= sb->length)
|
||||
if (ch->pos < sb->pos || ch->pos - sb->pos >= sb->size)
|
||||
sb->setpos (sb, ch->pos);
|
||||
pos = (ch->pos - sb->pos + sb->tail) % sb->length;
|
||||
pos = (ch->pos - sb->pos + sb->tail) % sb->size;
|
||||
samps = sb->data + pos * sb->channels;
|
||||
|
||||
if (pos + count > sb->length) {
|
||||
unsigned sub = sb->length - pos;
|
||||
if (pos + count > sb->size) {
|
||||
unsigned sub = sb->size - pos;
|
||||
sb->paint (offs, ch, samps, sub);
|
||||
sb->paint (offs + sub, ch, sb->data, count - sub);
|
||||
} else {
|
||||
|
|
|
@ -56,7 +56,7 @@ typedef struct {
|
|||
static void
|
||||
check_buffer_integrity (sfxbuffer_t *sb, int width, const char *func)
|
||||
{
|
||||
byte *x = (byte *) sb->data + sb->length * width;
|
||||
byte *x = (byte *) sb->data + sb->size * width;
|
||||
if (memcmp (x, "\xde\xad\xbe\xef", 4))
|
||||
Sys_Error ("%s screwed the pooch %02x%02x%02x%02x", func,
|
||||
x[0], x[1], x[2], x[3]);
|
||||
|
|
|
@ -156,7 +156,7 @@ SND_SFX_StreamOpen (sfx_t *sfx, void *file,
|
|||
|
||||
stream->wavinfo = *sfx->wavinfo (sfx);
|
||||
|
||||
stream->buffer.length = frames;
|
||||
stream->buffer.size = frames;
|
||||
stream->buffer.advance = SND_StreamAdvance;
|
||||
stream->buffer.setpos = SND_StreamSetPos;
|
||||
stream->buffer.sfx = new_sfx;
|
||||
|
|
|
@ -180,7 +180,7 @@ vorbis_load (OggVorbis_File *vf, sfxblock_t *block, cache_allocator_t allocator)
|
|||
SND_SetPaint (sb);
|
||||
SND_SetupResampler (sb, 0);
|
||||
SND_Resample (sb, data, info->frames);
|
||||
sb->head = sb->length;
|
||||
sb->head = sb->size;
|
||||
bail:
|
||||
if (data)
|
||||
free (data);
|
||||
|
|
|
@ -87,7 +87,7 @@ wav_callback_load (void *object, cache_allocator_t allocator)
|
|||
SND_SetPaint (buffer);
|
||||
SND_SetupResampler (buffer, 0);
|
||||
SND_Resample (buffer, fdata, info->frames);
|
||||
buffer->head = buffer->length;
|
||||
buffer->head = buffer->size;
|
||||
free (data);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue