diff mbox

[FFmpeg-devel] avdevice/alsa: fix indefinite stop on closing PCM capture

Message ID 20190419105426.35da27e9@jagoff.localdomain
State Accepted
Headers show

Commit Message

Lou Logan April 19, 2019, 6:54 p.m. UTC
Attached patch resolves the issue mentioned within.

Comments

Lou Logan April 22, 2019, 6:44 p.m. UTC | #1
On Fri, 19 Apr 2019 10:54:26 -0800
Lou Logan <lou@lrcd.com> wrote:

> From 10800493523b9274e7cc8784b65cc183a94b7281 Mon Sep 17 00:00:00 2001
> From: Takayuki 'January June' Suwa <jjsuwa@sys3175.com>
> Date: Thu, 18 Apr 2019 10:56:40 +0900
> Subject: [PATCH] avdevice/alsa: fix indefinite stop on closing PCM capture
> 
> Sorry, I forgot to take recording into account...
> 
> Fixes:  https://bugs.archlinux.org/task/58619
> 
> Found-by: Elias (Bleuzen) https://bugs.archlinux.org/user/26956
> ---
>  libavdevice/alsa.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavdevice/alsa.c b/libavdevice/alsa.c
> index 1b21beb6d5..117b2ea144 100644
> --- a/libavdevice/alsa.c
> +++ b/libavdevice/alsa.c
> @@ -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);

Will push after 24 hours.
Nicolas George April 22, 2019, 6:47 p.m. UTC | #2
Lou Logan (12019-04-19):
> Attached patch resolves the issue mentioned within.

> >From 10800493523b9274e7cc8784b65cc183a94b7281 Mon Sep 17 00:00:00 2001
> From: Takayuki 'January June' Suwa <jjsuwa@sys3175.com>
> Date: Thu, 18 Apr 2019 10:56:40 +0900
> Subject: [PATCH] avdevice/alsa: fix indefinite stop on closing PCM capture
> 
> Sorry, I forgot to take recording into account...
> 
> Fixes:  https://bugs.archlinux.org/task/58619
> 
> Found-by: Elias (Bleuzen) https://bugs.archlinux.org/user/26956
> ---
>  libavdevice/alsa.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Sorry, missed it. LGTM.

Regards,
Lou Logan April 23, 2019, 10:03 p.m. UTC | #3
On Mon, Apr 22, 2019, at 10:47 AM, Nicolas George wrote:
> 
> Sorry, missed it. LGTM.

Pushed.
f9a061a31c3d2d81b3ec1e1b9b37187a358cdd9e
diff mbox

Patch

From 10800493523b9274e7cc8784b65cc183a94b7281 Mon Sep 17 00:00:00 2001
From: Takayuki 'January June' Suwa <jjsuwa@sys3175.com>
Date: Thu, 18 Apr 2019 10:56:40 +0900
Subject: [PATCH] avdevice/alsa: fix indefinite stop on closing PCM capture

Sorry, I forgot to take recording into account...

Fixes:  https://bugs.archlinux.org/task/58619

Found-by: Elias (Bleuzen) https://bugs.archlinux.org/user/26956
---
 libavdevice/alsa.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavdevice/alsa.c b/libavdevice/alsa.c
index 1b21beb6d5..117b2ea144 100644
--- a/libavdevice/alsa.c
+++ b/libavdevice/alsa.c
@@ -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);
-- 
2.11.0