From ddd068491c9e8f7f77b6bba61269f867bdad204b Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 16 Jul 2017 12:51:48 +0200 Subject: Replace remaining avcodec_close() calls This API isn't deprecated (yet?), but it's still inferior and harder to use than avcodec_free_context(). Leave the call only in 1 case in af_lavcac3enc.c, where we apparently seriously close and reopen the encoder for whatever reason. --- audio/decode/ad_spdif.c | 5 +---- audio/filter/af_lavcac3enc.c | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) (limited to 'audio') diff --git a/audio/decode/ad_spdif.c b/audio/decode/ad_spdif.c index 78e4c4e976..4b3e8149ec 100644 --- a/audio/decode/ad_spdif.c +++ b/audio/decode/ad_spdif.c @@ -137,11 +137,8 @@ static void determine_codec_params(struct dec_audio *da, AVPacket *pkt, if (!ctx) goto done; - if (avcodec_open2(ctx, codec, NULL) < 0) { - av_free(ctx); // don't attempt to avcodec_close() an unopened ctx - ctx = NULL; + if (avcodec_open2(ctx, codec, NULL) < 0) goto done; - } if (avcodec_send_packet(ctx, pkt) < 0) goto done; diff --git a/audio/filter/af_lavcac3enc.c b/audio/filter/af_lavcac3enc.c index d5c2d25ad2..33e685eddb 100644 --- a/audio/filter/af_lavcac3enc.c +++ b/audio/filter/af_lavcac3enc.c @@ -192,10 +192,7 @@ static void uninit(struct af_instance* af) af_ac3enc_t *s = af->priv; if (s) { - if(s->lavc_actx) { - avcodec_close(s->lavc_actx); - av_free(s->lavc_actx); - } + avcodec_free_context(&s->lavc_actx); talloc_free(s->pending); } } -- cgit v1.2.3