diff mbox

[FFmpeg-devel] avdevice/alsa: wait until playback buffers are drained before closing

Message ID 1494070976-26505-1-git-send-email-jjsuwa.sys3175@gmail.com
State Accepted
Commit ea93b74074c509f59942c7ed4112ed3d64c3af33
Headers show

Commit Message

Takayuki 'January June' Suwa May 6, 2017, 11:42 a.m. UTC
This fixes early abort on ALSA playback

---
 libavdevice/alsa.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Nicolas George May 6, 2017, 6:40 p.m. UTC | #1
Le septidi 17 floréal, an CCXXV, Takayuki 'January June' Suwa a écrit :
> This fixes early abort on ALSA playback
> 
> ---
>  libavdevice/alsa.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavdevice/alsa.c b/libavdevice/alsa.c
> index 8d27913..1bbff30 100644
> --- a/libavdevice/alsa.c
> +++ b/libavdevice/alsa.c
> @@ -300,6 +300,8 @@ av_cold int ff_alsa_close(AVFormatContext *s1)
>  {
>      AlsaData *s = s1->priv_data;
>  
> +    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);

I guess I it ok. There are no provisions for non-blocking close for now.
I do not officially maintain the ALSA code, though.

Regards,
Michael Niedermayer May 6, 2017, 11:01 p.m. UTC | #2
On Sat, May 06, 2017 at 08:40:46PM +0200, Nicolas George wrote:
> Le septidi 17 floréal, an CCXXV, Takayuki 'January June' Suwa a écrit :
> > This fixes early abort on ALSA playback
> > 
> > ---
> >  libavdevice/alsa.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/libavdevice/alsa.c b/libavdevice/alsa.c
> > index 8d27913..1bbff30 100644
> > --- a/libavdevice/alsa.c
> > +++ b/libavdevice/alsa.c
> > @@ -300,6 +300,8 @@ av_cold int ff_alsa_close(AVFormatContext *s1)
> >  {
> >      AlsaData *s = s1->priv_data;
> >  
> > +    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);
> 
> I guess I it ok. There are no provisions for non-blocking close for now.

> I do not officially maintain the ALSA code, though.

but you looked at the code and noone is listed in MAINTAINERs for it

applied

thanks to all

[...]
diff mbox

Patch

diff --git a/libavdevice/alsa.c b/libavdevice/alsa.c
index 8d27913..1bbff30 100644
--- a/libavdevice/alsa.c
+++ b/libavdevice/alsa.c
@@ -300,6 +300,8 @@  av_cold int ff_alsa_close(AVFormatContext *s1)
 {
     AlsaData *s = s1->priv_data;
 
+    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);