mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +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,
|
||||
sfxblock_t *block, cache_allocator_t allocator)
|
||||
{
|
||||
int size;
|
||||
int len, size;
|
||||
int width;
|
||||
float stepscale;
|
||||
sfxbuffer_t *sc;
|
||||
|
@ -168,12 +168,13 @@ SND_GetCache (long samples, int rate, int inwidth, int channels,
|
|||
|
||||
width = snd_loadas8bit->int_val ? 1 : 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);
|
||||
size *= width * channels;
|
||||
sc = allocator (&block->cache, sizeof (sfxbuffer_t) + size, sfx->name);
|
||||
if (!sc)
|
||||
return 0;
|
||||
sc->length = len;
|
||||
memcpy (sc->data + size, "\xde\xad\xbe\xef", 4);
|
||||
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)
|
||||
goto bail;
|
||||
resample (sc, data, info->samples);
|
||||
sc->length = sc->head = sfx->length;
|
||||
sc->head = sc->length;
|
||||
bail:
|
||||
if (data)
|
||||
free (data);
|
||||
|
|
|
@ -75,7 +75,7 @@ wav_callback_load (void *object, cache_allocator_t allocator)
|
|||
SND_ResampleStereo (buffer, data, info->samples);
|
||||
else
|
||||
SND_ResampleMono (buffer, data, info->samples);
|
||||
buffer->length = buffer->head = sfx->length;
|
||||
buffer->head = buffer->length;
|
||||
free (data);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue