[vlc-commits] alsa: put pcm device back into running state after snd_pcm_recover() returned.

Jean-Paul Saman git at videolan.org
Wed Aug 20 15:18:59 CEST 2014


vlc | branch: master | Jean-Paul Saman <jean-paul.saman at m2x.nl> | Wed Aug 20 13:59:35 2014 +0200| [331b0d20610f632d3139d80cce74fa6930b61a63] | committer: Jean-Paul Saman

alsa: put pcm device back into running state after snd_pcm_recover() returned.

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().

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=331b0d20610f632d3139d80cce74fa6930b61a63
---

 modules/access/alsa.c |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/modules/access/alsa.c b/modules/access/alsa.c
index edb8fd7..c2716cf 100644
--- a/modules/access/alsa.c
+++ b/modules/access/alsa.c
@@ -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));



More information about the vlc-commits mailing list