diff --git a/libs/audio/renderer/snd_channels.c b/libs/audio/renderer/snd_channels.c index a34b88b4c..9f2aff704 100644 --- a/libs/audio/renderer/snd_channels.c +++ b/libs/audio/renderer/snd_channels.c @@ -686,7 +686,7 @@ SND_StaticSound (sfx_t *sfx, const vec3_t origin, float vol, VectorCopy (origin, ss->origin); ss->master_vol = vol; ss->dist_mult = (attenuation / 64) / sound_nominal_clip_dist; - ss->end = snd_paintedtime + osfx->length; + ss->end = 0; s_spatialize (ss); ss->oldphase = ss->phase; diff --git a/libs/audio/renderer/snd_mem.c b/libs/audio/renderer/snd_mem.c index 9a5f7c0fb..6c63d598a 100644 --- a/libs/audio/renderer/snd_mem.c +++ b/libs/audio/renderer/snd_mem.c @@ -98,6 +98,8 @@ SND_CacheRetain (sfx_t *sfx) { sfxblock_t *block = (sfxblock_t *) sfx->data; block->buffer = Cache_TryGet (&block->cache); + if (!block->buffer) + Sys_Printf ("failed to cache sound!\n"); return block->buffer; } @@ -105,7 +107,6 @@ void SND_CacheRelease (sfx_t *sfx) { sfxblock_t *block = (sfxblock_t *) sfx->data; - block->buffer = 0; // due to the possibly asynchronous nature of the mixer, the cache // may have been flushed behind our backs if (block->cache.data) { @@ -115,6 +116,8 @@ SND_CacheRelease (sfx_t *sfx) return; } Cache_Release (&block->cache); + if (!Cache_ReadLock (&block->cache)) + block->buffer = 0; } } diff --git a/libs/audio/renderer/snd_mix.c b/libs/audio/renderer/snd_mix.c index 1999935b9..0588372ce 100644 --- a/libs/audio/renderer/snd_mix.c +++ b/libs/audio/renderer/snd_mix.c @@ -84,7 +84,7 @@ snd_paint_channel (channel_t *ch, sfxbuffer_t *sc, int count) ch->pos += count; if ((int) ch->pos <= 0) return; - offs = ch->pos; + offs = count - ch->pos; count -= offs; ch->pos = 0; } @@ -135,11 +135,13 @@ SND_PaintChannels (unsigned endtime) if (ch->pause) continue; sc = sfx->getbuffer (sfx); - if (!sc) // something went wrong with the sfx + if (!sc) { // something went wrong with the sfx + printf ("XXXX sfx blew up!!!!\n"); continue; + } if (!ch->end) - ch->end = snd_paintedtime + sfx->length; + ch->end = snd_paintedtime + sfx->length - ch->pos; ltime = snd_paintedtime;