]> git.sesse.net Git - ffmpeg/commitdiff
avdevice/alsa: fix indefinite stop on closing PCM capture
authorTakayuki 'January June' Suwa <jjsuwa@sys3175.com>
Thu, 18 Apr 2019 01:56:40 +0000 (10:56 +0900)
committerLou Logan <lou@lrcd.com>
Tue, 23 Apr 2019 22:01:23 +0000 (14:01 -0800)
Fixes: https://bugs.archlinux.org/task/58619
Found-by: Elias (Bleuzen) https://bugs.archlinux.org/user/26956
Signed-off-by: Nicolas George <george@nsup.org>
libavdevice/alsa.c

index 1b21beb6d51e7416dc7c8bca2d0abfbc82acadf3..117b2ea144eac4e52d07985cc0074ec4f9f36307 100644 (file)
@@ -300,8 +300,10 @@ av_cold int ff_alsa_close(AVFormatContext *s1)
 {
     AlsaData *s = s1->priv_data;
 
-    snd_pcm_nonblock(s->h, 0);
-    snd_pcm_drain(s->h);
+    if (snd_pcm_stream(s->h) == SND_PCM_STREAM_PLAYBACK) {
+        snd_pcm_nonblock(s->h, 0);
+        snd_pcm_drain(s->h);
+    }
     av_freep(&s->reorder_buf);
     if (CONFIG_ALSA_INDEV)
         ff_timefilter_destroy(s->timefilter);