diff --git a/libs/audio/renderer/snd_mem.c b/libs/audio/renderer/snd_mem.c index ca884a339..14dfe6069 100644 --- a/libs/audio/renderer/snd_mem.c +++ b/libs/audio/renderer/snd_mem.c @@ -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; } diff --git a/libs/audio/renderer/vorbis.c b/libs/audio/renderer/vorbis.c index 70a840aee..a12a06637 100644 --- a/libs/audio/renderer/vorbis.c +++ b/libs/audio/renderer/vorbis.c @@ -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); diff --git a/libs/audio/renderer/wav.c b/libs/audio/renderer/wav.c index 34dd8b1ba..22b3869c1 100644 --- a/libs/audio/renderer/wav.c +++ b/libs/audio/renderer/wav.c @@ -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); }