From 9a0f2817bb56c1bbf72cf8c3c2ec998f1c8f3c35 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Fri, 15 Apr 2005 09:22:48 +0000 Subject: [PATCH] Fix timer read in non-TREAD mode Fix timer read in non-TREAD mode. (the struct is different.) --- src/pcm/pcm_direct.c | 22 ++++++++++++++-------- src/pcm/pcm_direct.h | 1 + 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c index 4991a838..5ec13e73 100644 --- a/src/pcm/pcm_direct.c +++ b/src/pcm/pcm_direct.c @@ -420,9 +420,15 @@ void snd_pcm_direct_clear_timer_queue(snd_pcm_direct_t *dmix) { /* rbuf might be overwriten by multiple plugins */ /* we don't need the value */ - snd_timer_tread_t rbuf; - while (snd_timer_read(dmix->timer, &rbuf, sizeof(rbuf)) == sizeof(rbuf)) - ; + if (dmix->tread) { + snd_timer_tread_t rbuf; + while (snd_timer_read(dmix->timer, &rbuf, sizeof(rbuf)) == sizeof(rbuf)) + ; + } else { + snd_timer_read_t rbuf; + while (snd_timer_read(dmix->timer, &rbuf, sizeof(rbuf)) == sizeof(rbuf)) + ; + } } int snd_pcm_direct_timer_stop(snd_pcm_direct_t *dmix) @@ -849,10 +855,10 @@ int snd_pcm_direct_initialize_poll_fd(snd_pcm_direct_t *dmix) snd_pcm_info_t *info; snd_timer_params_t *params; char name[128]; - int tread = 0; struct pollfd fd; int capture = dmix->type == SND_PCM_TYPE_DSNOOP ? 1 : 0; + dmix->tread = 0; snd_pcm_info_alloca(&info); snd_timer_params_alloca(¶ms); ret = snd_pcm_info(dmix->spcm, info); @@ -888,16 +894,16 @@ int snd_pcm_direct_initialize_poll_fd(snd_pcm_direct_t *dmix) int ver = 0; ioctl(dmix->poll_fd, SNDRV_TIMER_IOCTL_PVERSION, &ver); if (ver >= SNDRV_PROTOCOL_VERSION(2, 0, 3)) { - tread = 1; - if (ioctl(dmix->poll_fd, SNDRV_TIMER_IOCTL_TREAD, &tread) < 0) - tread = 0; + dmix->tread = 1; + if (ioctl(dmix->poll_fd, SNDRV_TIMER_IOCTL_TREAD, &dmix->tread) < 0) + dmix->tread = 0; } } snd_timer_params_set_auto_start(params, 1); snd_timer_params_set_early_event(params, 1); snd_timer_params_set_ticks(params, 1); - if (tread) + if (dmix->tread) snd_timer_params_set_filter(params, (1<timer, params); if (ret < 0) { diff --git a/src/pcm/pcm_direct.h b/src/pcm/pcm_direct.h index 126bacdb..26de0187 100644 --- a/src/pcm/pcm_direct.h +++ b/src/pcm/pcm_direct.h @@ -96,6 +96,7 @@ struct snd_pcm_direct { int comm_fd; /* communication file descriptor (socket) */ int hw_fd; /* hardware file descriptor */ int poll_fd; + int tread; int server_fd; pid_t server_pid; snd_timer_t *timer; /* timer used as poll_fd */ -- 2.47.1