diff options
author | Rudolf Polzer <divverent@xonotic.org> | 2012-11-01 12:25:50 +0100 |
---|---|---|
committer | Rudolf Polzer <divverent@xonotic.org> | 2012-11-01 12:29:55 +0100 |
commit | 538baaef6e22f1ecb2fb9d6035a6992e22c89ed4 (patch) | |
tree | 8aff70363dcae82a5f0688a33e4cf6b382220b8e /encode_lavc.c | |
parent | 84829a4ea1903e5db5782b72861fabc503a589cb (diff) | |
download | mpv-538baaef6e22f1ecb2fb9d6035a6992e22c89ed4.tar.bz2 mpv-538baaef6e22f1ecb2fb9d6035a6992e22c89ed4.tar.xz |
encode: bail out on missing A or V stream
In mplayer2, it was valid to try to start encoding before all streams
were initialized. mpv avoids this situation and thus allows us to
properly bail out on some kinds of failures.
Also, this commit fixes a missing check in ao uninit which could cause
heap corruption when ao initialization did not complete.
Diffstat (limited to 'encode_lavc.c')
-rw-r--r-- | encode_lavc.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/encode_lavc.c b/encode_lavc.c index e38ca5bca8..66f434410a 100644 --- a/encode_lavc.c +++ b/encode_lavc.c @@ -233,15 +233,21 @@ int encode_lavc_start(struct encode_lavc_context *ctx) for (i = 0; i < ctx->avc->nb_streams; ++i) if (ctx->avc->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) break; - if (i >= ctx->avc->nb_streams) + if (i >= ctx->avc->nb_streams) { + encode_lavc_fail(ctx, + "encode-lavc: video stream missing, invalid codec?\n"); return 0; + } } if (ctx->expect_audio) { for (i = 0; i < ctx->avc->nb_streams; ++i) if (ctx->avc->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) break; - if (i >= ctx->avc->nb_streams) + if (i >= ctx->avc->nb_streams) { + encode_lavc_fail(ctx, + "encode-lavc: audio stream missing, invalid codec?\n"); return 0; + } } ctx->header_written = -1; |