diff mbox

[FFmpeg-devel] lavd/alsa: add workarounds for ALSA cleanup problem

Message ID 1494328035-1450-1-git-send-email-jjsuwa.sys3175@gmail.com
State New
Headers show

Commit Message

Takayuki 'January June' Suwa May 9, 2017, 11:07 a.m. UTC
- Add snd_config_update_free_global() after closing ALSA PCM handle, as aplay does.
- Add snd_pcm_hw_free(h) before closing the handle. see https://www.google.com/search?q=Without+the+snd_pcm_hw_free,+snd_pcm_close+sometimes+fails
---
 libavdevice/alsa.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox

Patch

diff --git a/libavdevice/alsa.c b/libavdevice/alsa.c
index 1bbff30..202b481 100644
--- a/libavdevice/alsa.c
+++ b/libavdevice/alsa.c
@@ -292,7 +292,9 @@  av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode,
 fail:
     snd_pcm_hw_params_free(hw_params);
 fail1:
+    snd_pcm_hw_free(h);
     snd_pcm_close(h);
+    snd_config_update_free_global();
     return AVERROR(EIO);
 }
 
@@ -302,10 +304,12 @@  av_cold int ff_alsa_close(AVFormatContext *s1)
 
     snd_pcm_nonblock(s->h, 0);
     snd_pcm_drain(s->h);
+    snd_pcm_hw_free(s->h);
     av_freep(&s->reorder_buf);
     if (CONFIG_ALSA_INDEV)
         ff_timefilter_destroy(s->timefilter);
     snd_pcm_close(s->h);
+    snd_config_update_free_global();
     return 0;
 }