log error if avcodec_parameters_to_context fails. Mostly to quiet cppcheck. Remove duplicated assignment to sample_fmt.

This commit is contained in:
Isaac Connor 2022-01-10 17:35:57 -05:00
parent 78a10b6095
commit 376d7fd7e5
1 changed files with 5 additions and 2 deletions

View File

@ -401,6 +401,10 @@ bool VideoStore::open() {
} else { } else {
audio_in_ctx = avcodec_alloc_context3(audio_out_codec); audio_in_ctx = avcodec_alloc_context3(audio_out_codec);
ret = avcodec_parameters_to_context(audio_in_ctx, audio_in_stream->codecpar); 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_in_ctx->time_base = audio_in_stream->time_base;
audio_out_ctx = avcodec_alloc_context3(audio_out_codec); 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->sample_fmt = audio_in_ctx->sample_fmt;
audio_out_ctx->channels = audio_in_ctx->channels; audio_out_ctx->channels = audio_in_ctx->channels;
audio_out_ctx->channel_layout = audio_in_ctx->channel_layout; 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) { if (!audio_out_ctx->channel_layout) {
Debug(3, "Correcting channel layout from (%" PRIi64 ") to (%" PRIi64 ")", Debug(3, "Correcting channel layout from (%" PRIi64 ") to (%" PRIi64 ")",
audio_out_ctx->channel_layout, audio_out_ctx->channel_layout,
@ -852,7 +855,7 @@ bool VideoStore::setup_resampler() {
return false; return false;
} }
if ((ret = swr_init(resample_ctx)) < 0) { 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(&in_frame);
av_frame_free(&out_frame); av_frame_free(&out_frame);
swr_free(&resample_ctx); swr_free(&resample_ctx);