summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorRudolf Polzer <divVerent@xonotic.org>2014-11-12 12:16:07 +0100
committerRudolf Polzer <divVerent@xonotic.org>2014-11-12 12:16:07 +0100
commit4f63a812de6ed8a76dde2a3739513933748ac2af (patch)
tree0eacb6575a0b3054295ec357fc83be1b69d2dc06 /audio
parent88762cd6a7adfe3c9fb70fb3fcdb85b254119bf9 (diff)
downloadmpv-4f63a812de6ed8a76dde2a3739513933748ac2af.tar.bz2
mpv-4f63a812de6ed8a76dde2a3739513933748ac2af.tar.xz
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.
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_lavc.c8
1 files changed, 8 insertions, 0 deletions
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