]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Fix timer read in non-TREAD mode
authorTakashi Iwai <tiwai@suse.de>
Fri, 15 Apr 2005 09:22:48 +0000 (09:22 +0000)
committerTakashi Iwai <tiwai@suse.de>
Fri, 15 Apr 2005 09:22:48 +0000 (09:22 +0000)
Fix timer read in non-TREAD mode.  (the struct is different.)

src/pcm/pcm_direct.c
src/pcm/pcm_direct.h

index 4991a83863b8fabba7020a5f83bd224299b4cc38..5ec13e73bb9f9d75640f4ce679a8255808b201c5 100644 (file)
@@ -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(&params);
        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<<SND_TIMER_EVENT_TICK)|(1<<SND_TIMER_EVENT_MPAUSE));
        ret = snd_timer_params(dmix->timer, params);
        if (ret < 0) {
index 126bacdb4c5ae67fe398e9719c08e16d9ce2ba95..26de01877aa25c2bf1e03d8213898f40a218fcd1 100644 (file)
@@ -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 */