From 4f63a812de6ed8a76dde2a3739513933748ac2af Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Wed, 12 Nov 2014 12:16:07 +0100 Subject: ao_lavc, vo_lavc: Fix crashes in case of multiple init attempts. When initialization failed, vo_lavc may cause an irrecoverable state in the ffmpeg-related structs. Therefore, we reject additional initialization attempts at least until we know a better way to clean up the mess. ao_lavc currently cannot be initialized more than once, yet it's good to do consistent changes there as well. Also, clean up uninit-after-failure handling to be less spammy. --- audio/out/ao_lavc.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'audio') diff --git a/audio/out/ao_lavc.c b/audio/out/ao_lavc.c index 357c34763d..9f2179e8f7 100644 --- a/audio/out/ao_lavc.c +++ b/audio/out/ao_lavc.c @@ -56,6 +56,8 @@ struct priv { AVRational worst_time_base; int worst_time_base_is_stream; + + bool shutdown; }; static void select_format(struct ao *ao, AVCodec *codec) @@ -174,6 +176,7 @@ static int init(struct ao *ao) fail: pthread_mutex_unlock(&ao->encode_lavc_ctx->lock); + ac->shutdown = true; return -1; } @@ -184,6 +187,9 @@ static void uninit(struct ao *ao) struct priv *ac = ao->priv; struct encode_lavc_context *ectx = ao->encode_lavc_ctx; + if (!ac || ac->shutdown) + return; + pthread_mutex_lock(&ectx->lock); if (!encode_lavc_start(ectx)) { @@ -201,6 +207,8 @@ static void uninit(struct ao *ao) } pthread_mutex_unlock(&ectx->lock); + + ac->shutdown = true; } // return: how many bytes can be played without blocking -- cgit v1.2.3