mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-19 07:20:50 +00:00
[sound] Rename sndbuffer objects from sc to sb
I don't know why I called them sc. Might be a holdover from before the streamed sound support.
This commit is contained in:
parent
5b38117689
commit
56cd0f3f1d
5 changed files with 60 additions and 60 deletions
|
@ -282,29 +282,29 @@ static sfxbuffer_t *
|
|||
flac_load (flacfile_t *ff, sfxblock_t *block, cache_allocator_t allocator)
|
||||
{
|
||||
float *data;
|
||||
sfxbuffer_t *sc = 0;
|
||||
sfxbuffer_t *sb = 0;
|
||||
sfx_t *sfx = block->sfx;
|
||||
wavinfo_t *info = &block->wavinfo;
|
||||
|
||||
data = malloc (info->datalen);
|
||||
if (!data)
|
||||
goto bail;
|
||||
sc = SND_GetCache (info->frames, info->rate, info->channels,
|
||||
sb = SND_GetCache (info->frames, info->rate, info->channels,
|
||||
block, allocator);
|
||||
if (!sc)
|
||||
if (!sb)
|
||||
goto bail;
|
||||
sc->sfx = sfx;
|
||||
sb->sfx = sfx;
|
||||
if (flac_read (ff, data, info->frames) < 0)
|
||||
goto bail;
|
||||
SND_SetPaint (sc);
|
||||
SND_SetupResampler (sc, 0);
|
||||
SND_Resample (sc, data, info->frames);
|
||||
sc->head = sc->length;
|
||||
SND_SetPaint (sb);
|
||||
SND_SetupResampler (sb, 0);
|
||||
SND_Resample (sb, data, info->frames);
|
||||
sb->head = sb->length;
|
||||
bail:
|
||||
if (data)
|
||||
free (data);
|
||||
flac_close (ff);
|
||||
return sc;
|
||||
return sb;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -351,18 +351,18 @@ SND_GetCache (long frames, int rate, int channels,
|
|||
{
|
||||
int len, size;
|
||||
float stepscale;
|
||||
sfxbuffer_t *sc;
|
||||
sfxbuffer_t *sb;
|
||||
sfx_t *sfx = block->sfx;
|
||||
snd_t *snd = sfx->snd;
|
||||
|
||||
stepscale = (float) rate / snd->speed;
|
||||
len = size = frames / stepscale;
|
||||
size *= sizeof (float) * channels;
|
||||
sc = allocator (&block->cache, sizeof (sfxbuffer_t) + size, sfx->name);
|
||||
if (!sc)
|
||||
sb = allocator (&block->cache, sizeof (sfxbuffer_t) + size, sfx->name);
|
||||
if (!sb)
|
||||
return 0;
|
||||
memset (sc, 0, sizeof (sfxbuffer_t) + size);
|
||||
sc->length = len;
|
||||
memcpy (sc->data + len * channels, "\xde\xad\xbe\xef", 4);
|
||||
return sc;
|
||||
memset (sb, 0, sizeof (sfxbuffer_t) + size);
|
||||
sb->length = len;
|
||||
memcpy (sb->data + len * channels, "\xde\xad\xbe\xef", 4);
|
||||
return sb;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ check_channel_end (channel_t *ch, sfx_t *sfx, int count, unsigned ltime)
|
|||
}
|
||||
|
||||
static inline void
|
||||
snd_paint_channel (channel_t *ch, sfxbuffer_t *sc, int count)
|
||||
snd_paint_channel (channel_t *ch, sfxbuffer_t *sb, int count)
|
||||
{
|
||||
unsigned pos;
|
||||
int offs = 0;
|
||||
|
@ -82,17 +82,17 @@ snd_paint_channel (channel_t *ch, sfxbuffer_t *sc, int count)
|
|||
count -= offs;
|
||||
ch->pos = 0;
|
||||
}
|
||||
if (ch->pos < sc->pos || ch->pos - sc->pos >= sc->length)
|
||||
sc->setpos (sc, ch->pos);
|
||||
pos = (ch->pos - sc->pos + sc->tail) % sc->length;
|
||||
samps = sc->data + pos * sc->channels;
|
||||
if (ch->pos < sb->pos || ch->pos - sb->pos >= sb->length)
|
||||
sb->setpos (sb, ch->pos);
|
||||
pos = (ch->pos - sb->pos + sb->tail) % sb->length;
|
||||
samps = sb->data + pos * sb->channels;
|
||||
|
||||
if (pos + count > sc->length) {
|
||||
unsigned sub = sc->length - pos;
|
||||
sc->paint (offs, ch, samps, sub);
|
||||
sc->paint (offs + sub, ch, sc->data, count - sub);
|
||||
if (pos + count > sb->length) {
|
||||
unsigned sub = sb->length - pos;
|
||||
sb->paint (offs, ch, samps, sub);
|
||||
sb->paint (offs + sub, ch, sb->data, count - sub);
|
||||
} else {
|
||||
sc->paint (offs, ch, samps, count);
|
||||
sb->paint (offs, ch, samps, count);
|
||||
}
|
||||
ch->pos += count;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ SND_PaintChannels (snd_t *snd, unsigned endtime)
|
|||
int i, count;
|
||||
channel_t *ch;
|
||||
sfx_t *sfx;
|
||||
sfxbuffer_t *sc;
|
||||
sfxbuffer_t *sb;
|
||||
|
||||
// clear the paint buffer
|
||||
for (i = 0; i < PAINTBUFFER_SIZE * 2; i++) {
|
||||
|
@ -131,8 +131,8 @@ SND_PaintChannels (snd_t *snd, unsigned endtime)
|
|||
}
|
||||
if (ch->pause)
|
||||
continue;
|
||||
sc = sfx->getbuffer (sfx);
|
||||
if (!sc) { // something went wrong with the sfx
|
||||
sb = sfx->getbuffer (sfx);
|
||||
if (!sb) { // something went wrong with the sfx
|
||||
printf ("XXXX sfx blew up!!!!\n");
|
||||
continue;
|
||||
}
|
||||
|
@ -146,9 +146,9 @@ SND_PaintChannels (snd_t *snd, unsigned endtime)
|
|||
count = ((ch->end < end) ? ch->end : end) - ltime;
|
||||
if (count > 0) {
|
||||
if (ch->leftvol || ch->rightvol) {
|
||||
snd_paint_channel (ch, sc, count);
|
||||
if (sc->advance) {
|
||||
if (!sc->advance (sc, count)) {
|
||||
snd_paint_channel (ch, sb, count);
|
||||
if (sb->advance) {
|
||||
if (!sb->advance (sb, count)) {
|
||||
// this channel can no longer be used as its
|
||||
// source has died.
|
||||
ch->done = 1;
|
||||
|
@ -457,7 +457,7 @@ snd_paint_8 (int offs, channel_t *ch, float *samp, unsigned count)
|
|||
}
|
||||
|
||||
void
|
||||
SND_SetPaint (sfxbuffer_t *sc)
|
||||
SND_SetPaint (sfxbuffer_t *sb)
|
||||
{
|
||||
static sfxpaint_t *painters[] = {
|
||||
0,
|
||||
|
@ -471,8 +471,8 @@ SND_SetPaint (sfxbuffer_t *sc)
|
|||
snd_paint_8,
|
||||
};
|
||||
|
||||
wavinfo_t *info = sc->sfx->wavinfo (sc->sfx);
|
||||
wavinfo_t *info = sb->sfx->wavinfo (sb->sfx);
|
||||
if (info->channels > 8)
|
||||
Sys_Error ("illegal channel count %d", info->channels);
|
||||
sc->paint = painters[info->channels];
|
||||
sb->paint = painters[info->channels];
|
||||
}
|
||||
|
|
|
@ -54,21 +54,21 @@ typedef struct {
|
|||
} snd_null_state_t;
|
||||
|
||||
static void
|
||||
check_buffer_integrity (sfxbuffer_t *sc, int width, const char *func)
|
||||
check_buffer_integrity (sfxbuffer_t *sb, int width, const char *func)
|
||||
{
|
||||
byte *x = (byte *) sc->data + sc->length * width;
|
||||
byte *x = (byte *) sb->data + sb->length * 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]);
|
||||
}
|
||||
|
||||
void
|
||||
SND_Resample (sfxbuffer_t *sc, float *data, int length)
|
||||
SND_Resample (sfxbuffer_t *sb, float *data, int length)
|
||||
{
|
||||
int outcount;
|
||||
double stepscale;
|
||||
wavinfo_t *info = sc->sfx->wavinfo (sc->sfx);
|
||||
snd_t *snd = sc->sfx->snd;
|
||||
wavinfo_t *info = sb->sfx->wavinfo (sb->sfx);
|
||||
snd_t *snd = sb->sfx->snd;
|
||||
int inrate = info->rate;
|
||||
int outwidth;
|
||||
SRC_DATA src_data;
|
||||
|
@ -77,15 +77,15 @@ SND_Resample (sfxbuffer_t *sc, float *data, int length)
|
|||
outcount = length * stepscale;
|
||||
|
||||
src_data.data_in = data;
|
||||
src_data.data_out = sc->data + sc->head * sc->channels;
|
||||
src_data.data_out = sb->data + sb->head * sb->channels;
|
||||
src_data.input_frames = length;
|
||||
src_data.output_frames = outcount;
|
||||
src_data.src_ratio = stepscale;
|
||||
|
||||
src_simple (&src_data, SRC_LINEAR, sc->channels);
|
||||
src_simple (&src_data, SRC_LINEAR, sb->channels);
|
||||
|
||||
outwidth = info->channels * sizeof (float);
|
||||
check_buffer_integrity (sc, outwidth, __FUNCTION__);
|
||||
check_buffer_integrity (sb, outwidth, __FUNCTION__);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -140,26 +140,26 @@ snd_seek (sfxstream_t *stream, int pos)
|
|||
}
|
||||
|
||||
void
|
||||
SND_SetupResampler (sfxbuffer_t *sc, int streamed)
|
||||
SND_SetupResampler (sfxbuffer_t *sb, int streamed)
|
||||
{
|
||||
double stepscale;
|
||||
wavinfo_t *info = sc->sfx->wavinfo (sc->sfx);
|
||||
snd_t *snd = sc->sfx->snd;
|
||||
wavinfo_t *info = sb->sfx->wavinfo (sb->sfx);
|
||||
snd_t *snd = sb->sfx->snd;
|
||||
int inrate = info->rate;
|
||||
|
||||
stepscale = (double) snd->speed / inrate;
|
||||
|
||||
sc->sfx->length = info->frames * stepscale;
|
||||
sb->sfx->length = info->frames * stepscale;
|
||||
if (info->loopstart != (unsigned int)-1)
|
||||
sc->sfx->loopstart = info->loopstart * stepscale;
|
||||
sb->sfx->loopstart = info->loopstart * stepscale;
|
||||
else
|
||||
sc->sfx->loopstart = (unsigned int)-1;
|
||||
sb->sfx->loopstart = (unsigned int)-1;
|
||||
|
||||
sc->channels = info->channels;
|
||||
sb->channels = info->channels;
|
||||
|
||||
if (streamed) {
|
||||
int err;
|
||||
sfxstream_t *stream = sc->sfx->data.stream;
|
||||
sfxstream_t *stream = sb->sfx->data.stream;
|
||||
|
||||
if (snd->speed == inrate) {
|
||||
stream->state = calloc (sizeof (snd_null_state_t), 1);
|
||||
|
|
|
@ -163,29 +163,29 @@ static sfxbuffer_t *
|
|||
vorbis_load (OggVorbis_File *vf, sfxblock_t *block, cache_allocator_t allocator)
|
||||
{
|
||||
float *data;
|
||||
sfxbuffer_t *sc = 0;
|
||||
sfxbuffer_t *sb = 0;
|
||||
sfx_t *sfx = block->sfx;
|
||||
wavinfo_t *info = &block->wavinfo;
|
||||
|
||||
data = malloc (info->datalen);
|
||||
if (!data)
|
||||
goto bail;
|
||||
sc = SND_GetCache (info->frames, info->rate, info->channels,
|
||||
sb = SND_GetCache (info->frames, info->rate, info->channels,
|
||||
block, allocator);
|
||||
if (!sc)
|
||||
if (!sb)
|
||||
goto bail;
|
||||
sc->sfx = sfx;
|
||||
sb->sfx = sfx;
|
||||
if (vorbis_read (vf, data, info->frames, info) < 0)
|
||||
goto bail;
|
||||
SND_SetPaint (sc);
|
||||
SND_SetupResampler (sc, 0);
|
||||
SND_Resample (sc, data, info->frames);
|
||||
sc->head = sc->length;
|
||||
SND_SetPaint (sb);
|
||||
SND_SetupResampler (sb, 0);
|
||||
SND_Resample (sb, data, info->frames);
|
||||
sb->head = sb->length;
|
||||
bail:
|
||||
if (data)
|
||||
free (data);
|
||||
ov_clear (vf);
|
||||
return sc;
|
||||
return sb;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue