From b9ba65308b10801a8d5f8ae4e2ce53ac830a2db4 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 27 Oct 2000 14:38:43 +0000 Subject: [PATCH] still fiddling and it still doesn't work --- source/.gdbinit | 2 +- source/snd_alsa_0_6.c | 71 ++++++++++++++++++++----------------------- 2 files changed, 34 insertions(+), 39 deletions(-) diff --git a/source/.gdbinit b/source/.gdbinit index ce85e44..c8ea07e 100644 --- a/source/.gdbinit +++ b/source/.gdbinit @@ -1 +1 @@ -set args -nosound +set _windowed_mouse 0 +set args +set _windowed_mouse 0 diff --git a/source/snd_alsa_0_6.c b/source/snd_alsa_0_6.c index 92e986b..a912f23 100644 --- a/source/snd_alsa_0_6.c +++ b/source/snd_alsa_0_6.c @@ -28,40 +28,17 @@ */ #ifdef HAVE_CONFIG_H -# include +# include "config.h" #endif -#include -#include -#include -#include - #include -#include -#ifdef HAVE_UNISTD_H -#include -#endif -#include -#include -#ifdef HAVE_SYS_IOCTL_H -# include -#endif -#ifdef HAVE_SYS_MMAN_H -# include -#endif -#if defined HAVE_SYS_SOUNDCARD_H -# include -#elif defined HAVE_LINUX_SOUNDCARD_H -# include -#elif HAVE_MACHINE_SOUNDCARD_H -# include -#endif #include -#ifndef MAP_FAILED -# define MAP_FAILED ((void*)-1) -#endif +#include "qtypes.h" +#include "sound.h" +#include "qargs.h" +#include "console.h" static int snd_inited; @@ -314,25 +291,43 @@ Send sound to device if buffer isn't really the dma buffer */ void SNDDMA_Submit(void) { + int delay; int count = paintedtime - soundtime; - int avail = snd_pcm_avail_update(pcm_handle); + int avail; + int offset; + int missed; int state; state = snd_pcm_state (pcm_handle); - printf("%d %d %d\n", state, count, avail); - - //count -= delay; - - if (count > avail) { - snd_pcm_mmap_forward (pcm_handle, avail); - count -= avail; - } - snd_pcm_mmap_forward (pcm_handle, count); switch (state) { case SND_PCM_STATE_PREPARED: + snd_pcm_mmap_forward (pcm_handle, count); printf ("%d\n", snd_pcm_start (pcm_handle)); break; + case SND_PCM_STATE_RUNNING: + printf ("%4d ", snd_pcm_delay (pcm_handle, &delay)); + if (delay < 0) + delay += setup.buffer_size; + printf ("delay: %d\n", delay); + offset = snd_pcm_mmap_offset (pcm_handle); + printf ("offset: %d\n", offset); + missed = offset - shm->samplepos / shm->channels; + printf ("missed: %d\n", missed); + count -= missed; + snd_pcm_rewind (pcm_handle, count - delay); + avail = snd_pcm_avail_update(pcm_handle); + printf ("avail: %d\n", avail); + if (count > avail) { + snd_pcm_mmap_forward (pcm_handle, avail); + count -= avail; + } + printf ("count: %d\n", count); + snd_pcm_mmap_forward (pcm_handle, count); + break; + default: + printf ("Unexpected state: %d\n", state); + break; } }