From 376d7fd7e530a66293c7b932ef2404388028d39e Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 10 Jan 2022 17:35:57 -0500 Subject: [PATCH] log error if avcodec_parameters_to_context fails. Mostly to quiet cppcheck. Remove duplicated assignment to sample_fmt. --- src/zm_videostore.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/zm_videostore.cpp b/src/zm_videostore.cpp index ad401b22c..abd541535 100644 --- a/src/zm_videostore.cpp +++ b/src/zm_videostore.cpp @@ -401,6 +401,10 @@ bool VideoStore::open() { } else { audio_in_ctx = avcodec_alloc_context3(audio_out_codec); ret = avcodec_parameters_to_context(audio_in_ctx, audio_in_stream->codecpar); + if (ret < 0) + Error("Failure from avcodec_parameters_to_context %s", + av_make_error_string(ret).c_str()); + audio_in_ctx->time_base = audio_in_stream->time_base; audio_out_ctx = avcodec_alloc_context3(audio_out_codec); @@ -729,7 +733,6 @@ bool VideoStore::setup_resampler() { audio_out_ctx->sample_fmt = audio_in_ctx->sample_fmt; audio_out_ctx->channels = audio_in_ctx->channels; audio_out_ctx->channel_layout = audio_in_ctx->channel_layout; - audio_out_ctx->sample_fmt = audio_in_ctx->sample_fmt; if (!audio_out_ctx->channel_layout) { Debug(3, "Correcting channel layout from (%" PRIi64 ") to (%" PRIi64 ")", audio_out_ctx->channel_layout, @@ -852,7 +855,7 @@ bool VideoStore::setup_resampler() { return false; } if ((ret = swr_init(resample_ctx)) < 0) { - Error("Could not open resampler"); + Error("Could not open resampler %d", ret); av_frame_free(&in_frame); av_frame_free(&out_frame); swr_free(&resample_ctx);