[FFmpeg-devel] [PATCH] lavd/alsa: add workarounds for ALSA cleanup problem
Takayuki 'January June' Suwa
jjsuwa.sys3175 at gmail.com
Tue May 9 14:07:15 EEST 2017
- 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 --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;
}
More information about the ffmpeg-devel
mailing list