]> git.alsa-project.org Git - alsa-utils.git/commitdiff
alsaloop: rework the ctl event handling routine
authorJaroslav Kysela <perex@perex.cz>
Thu, 21 Oct 2010 18:38:06 +0000 (20:38 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 21 Oct 2010 18:38:06 +0000 (20:38 +0200)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
alsaloop/pcmjob.c

index 23270a0331a64a7d37924b4a6680af9f1c5f0a59..0b84803d2f55022a9218a6658595830b4c0517a9 100644 (file)
@@ -1650,7 +1650,7 @@ static int handle_ctl_events(struct loopback_handle *lhandle,
 {
        struct loopback *loop = lhandle->loopback;
        snd_ctl_event_t *ev;
-       int err;
+       int err, restart = 0;
 
        snd_ctl_event_alloca(&ev);
        while ((err = snd_ctl_read(lhandle->ctl, ev)) != 0 && err != -EAGAIN) {
@@ -1663,42 +1663,45 @@ static int handle_ctl_events(struct loopback_handle *lhandle,
                if (verbose > 6)
                        snd_output_printf(loop->output, "%s: ctl event!!!! %s\n", lhandle->id, snd_ctl_event_elem_get_name(ev));
                if (ctl_event_check(lhandle->ctl_active, ev)) {
-                       err = get_active(lhandle);
-                       if (verbose > 7)
-                               snd_output_printf(loop->output, "%s: ctl event active %i\n", lhandle->id, err);
-                       if (!err) {
-                               if (lhandle->loopback->running) {
-                                       loop->stop_pending = 1;
-                                       loop->stop_count = 0;
-                               }
-                       } else {
-                               loop->stop_pending = 0;
-                               if (loop->running == 0)
-                                       goto __restart;
-                       }
+                       continue;
                } else if (ctl_event_check(lhandle->ctl_format, ev)) {
                        err = get_format(lhandle);
                        if (lhandle->format != err)
-                               goto __restart;
+                               restart = 1;
+                       continue;
                } else if (ctl_event_check(lhandle->ctl_rate, ev)) {
                        err = get_rate(lhandle);
                        if (lhandle->rate != err)
-                               goto __restart;
+                               restart = 1;
+                       continue;
                } else if (ctl_event_check(lhandle->ctl_channels, ev)) {
                        err = get_channels(lhandle);
                        if (lhandle->channels != err)
-                               goto __restart;
+                               restart = 1;
+                       continue;
                }
              __ctl_check:
                control_event(lhandle, ev);
        }
-       return 0;
-
-      __restart:
-       pcmjob_stop(loop);
-       err = pcmjob_start(loop);
-       if (err < 0)
-               return err;
+       err = get_active(lhandle);
+       if (verbose > 7)
+               snd_output_printf(loop->output, "%s: ctl event active %i\n", lhandle->id, err);
+       if (!err) {
+               if (lhandle->loopback->running) {
+                       loop->stop_pending = 1;
+                       loop->stop_count = 0;
+               }
+       } else {
+               loop->stop_pending = 0;
+               if (loop->running == 0)
+                       restart = 1;
+       }
+       if (restart) {
+               pcmjob_stop(loop);
+               err = pcmjob_start(loop);
+               if (err < 0)
+                       return err;
+       }
        return 1;
 }