alsa: put pcm device back into running state after snd_pcm_recover() returned.
authorJean-Paul Saman <jean-paul.saman@m2x.nl>
Wed, 20 Aug 2014 11:59:35 +0000 (13:59 +0200)
committerJean-Paul Saman <jean-paul.saman@m2x.nl>
Wed, 20 Aug 2014 11:59:35 +0000 (13:59 +0200)
After recovery the pcm device can be in prepared state. To continue capturing data
the device must be put into running state again, hence the call to snd_pcm_start().

modules/access/alsa.c

index edb8fd7..c2716cf 100644 (file)
@@ -194,7 +194,23 @@ static void *Thread (void *data)
             {
                 msg_Warn (demux, "cannot read samples: %s",
                           snd_strerror (frames));
-                continue;
+                snd_pcm_state_t state = snd_pcm_state (pcm);
+                switch (state)
+                {
+                case SND_PCM_STATE_PREPARED:
+                    val = snd_pcm_start (pcm);
+                    if (val < 0)
+                    {
+                        msg_Err (demux, "cannot prepare device: %s",
+                                 snd_strerror (val));
+                        return NULL;
+                    }
+                    continue;
+                case SND_PCM_STATE_RUNNING:
+                    continue;
+                default:
+                    break;
+                }
             }
             msg_Err (demux, "cannot recover record stream: %s",
                      snd_strerror (val));