mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 06:51:47 +00:00
set the buffer length as early as possible for cached sounds
This commit is contained in:
parent
11e2f0d16a
commit
38ef81ca78
3 changed files with 5 additions and 4 deletions
|
@ -160,7 +160,7 @@ sfxbuffer_t *
|
||||||
SND_GetCache (long samples, int rate, int inwidth, int channels,
|
SND_GetCache (long samples, int rate, int inwidth, int channels,
|
||||||
sfxblock_t *block, cache_allocator_t allocator)
|
sfxblock_t *block, cache_allocator_t allocator)
|
||||||
{
|
{
|
||||||
int size;
|
int len, size;
|
||||||
int width;
|
int width;
|
||||||
float stepscale;
|
float stepscale;
|
||||||
sfxbuffer_t *sc;
|
sfxbuffer_t *sc;
|
||||||
|
@ -168,12 +168,13 @@ SND_GetCache (long samples, int rate, int inwidth, int channels,
|
||||||
|
|
||||||
width = snd_loadas8bit->int_val ? 1 : 2;
|
width = snd_loadas8bit->int_val ? 1 : 2;
|
||||||
stepscale = (float) rate / shm->speed; // usually 0.5, 1, or 2
|
stepscale = (float) rate / shm->speed; // usually 0.5, 1, or 2
|
||||||
size = samples / stepscale;
|
len = size = samples / stepscale;
|
||||||
//printf ("%ld %d\n", samples, size);
|
//printf ("%ld %d\n", samples, size);
|
||||||
size *= width * channels;
|
size *= width * channels;
|
||||||
sc = allocator (&block->cache, sizeof (sfxbuffer_t) + size, sfx->name);
|
sc = allocator (&block->cache, sizeof (sfxbuffer_t) + size, sfx->name);
|
||||||
if (!sc)
|
if (!sc)
|
||||||
return 0;
|
return 0;
|
||||||
|
sc->length = len;
|
||||||
memcpy (sc->data + size, "\xde\xad\xbe\xef", 4);
|
memcpy (sc->data + size, "\xde\xad\xbe\xef", 4);
|
||||||
return sc;
|
return sc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,7 +182,7 @@ load_ogg (OggVorbis_File *vf, sfxblock_t *block, cache_allocator_t allocator)
|
||||||
if (read_ogg (vf, data, info->datalen) < 0)
|
if (read_ogg (vf, data, info->datalen) < 0)
|
||||||
goto bail;
|
goto bail;
|
||||||
resample (sc, data, info->samples);
|
resample (sc, data, info->samples);
|
||||||
sc->length = sc->head = sfx->length;
|
sc->head = sc->length;
|
||||||
bail:
|
bail:
|
||||||
if (data)
|
if (data)
|
||||||
free (data);
|
free (data);
|
||||||
|
|
|
@ -75,7 +75,7 @@ wav_callback_load (void *object, cache_allocator_t allocator)
|
||||||
SND_ResampleStereo (buffer, data, info->samples);
|
SND_ResampleStereo (buffer, data, info->samples);
|
||||||
else
|
else
|
||||||
SND_ResampleMono (buffer, data, info->samples);
|
SND_ResampleMono (buffer, data, info->samples);
|
||||||
buffer->length = buffer->head = sfx->length;
|
buffer->head = buffer->length;
|
||||||
free (data);
|
free (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue