From 45288a1a7f1ee338e354ca8bad0feede81647c6e Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 8 Dec 2011 11:02:19 +0900 Subject: [PATCH] Fix the ghastly sound quality. Due to quake's original sound engine using a push model, the actual place to which the sound data should be written is not necessarily where the "hardware" dma cursor is, but rather where the last write finished off. Thus, the correct output location is indicated by snd_paintedtime rather than snd_shm->framepos. --- libs/audio/renderer/snd_dma.c | 2 +- libs/audio/targets/snd_alsa.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/audio/renderer/snd_dma.c b/libs/audio/renderer/snd_dma.c index 727664112..f687140d7 100644 --- a/libs/audio/renderer/snd_dma.c +++ b/libs/audio/renderer/snd_dma.c @@ -82,7 +82,7 @@ s_xfer_paint_buffer (portable_samplepair_t *paintbuffer, int count, p = (float *) paintbuffer; count *= snd_shm->channels; out_max = (snd_shm->frames * snd_shm->channels) - 1; - out_idx = snd_shm->framepos * snd_shm->channels; + out_idx = snd_paintedtime * snd_shm->channels; while (out_idx > out_max) out_idx -= out_max + 1; step = 3 - snd_shm->channels; diff --git a/libs/audio/targets/snd_alsa.c b/libs/audio/targets/snd_alsa.c index 19af26ad3..55f0369ea 100644 --- a/libs/audio/targets/snd_alsa.c +++ b/libs/audio/targets/snd_alsa.c @@ -150,7 +150,7 @@ SNDDMA_ni_xfer (portable_samplepair_t *paintbuffer, int count, float volume) p = (float *) paintbuffer; out_max = sn.frames - 1; - out_idx = sn.framepos; + out_idx = *plugin_info_snd_output_data.paintedtime; while (out_idx > out_max) out_idx -= out_max + 1;