diff options
author | wm4 <wm4@nowhere> | 2017-07-10 16:40:52 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-07-10 16:40:52 +0200 |
commit | b016760a286a190e5134c177672472aa8f2e42d8 (patch) | |
tree | db42a8d1e1142e2195172396093bf9bafe8579b8 | |
parent | 02468dcbde8081fc79ba7b7832fe37cb3b52bb16 (diff) | |
download | mpv-b016760a286a190e5134c177672472aa8f2e42d8.tar.bz2 mpv-b016760a286a190e5134c177672472aa8f2e42d8.tar.xz |
ad_spdif: minor cleanups
Use avcodec_free_context() unstead of random other calls. Actually it
was already used in the second case, but calling avcodec_close() is
redundant.
Don't crash if allocating a codec context fails.
-rw-r--r-- | audio/decode/ad_spdif.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c index 6919a21ebc..78e4c4e976 100644 --- a/audio/decode/ad_spdif.c +++ b/audio/decode/ad_spdif.c @@ -107,6 +107,10 @@ static void determine_codec_params(struct dec_audio *da, AVPacket *pkt, parser->flags |= PARSER_FLAG_COMPLETE_FRAMES; ctx = avcodec_alloc_context3(NULL); + if (!ctx) { + av_parser_close(parser); + goto done; + } uint8_t *d = NULL; int s = 0; @@ -114,7 +118,7 @@ static void determine_codec_params(struct dec_audio *da, AVPacket *pkt, *out_profile = profile = ctx->profile; *out_rate = ctx->sample_rate; - av_free(ctx); + avcodec_free_context(&ctx); av_parser_close(parser); } @@ -149,8 +153,6 @@ static void determine_codec_params(struct dec_audio *da, AVPacket *pkt, done: av_frame_free(&frame); - if (ctx) - avcodec_close(ctx); avcodec_free_context(&ctx); if (profile == FF_PROFILE_UNKNOWN) |