From 3d99f1d8a6c6abad3dca2cd7b066df04f09e90cd Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 30 Oct 2024 22:46:20 +0100 Subject: [PATCH] filter/ffmpeg: use `if` with initializer --- src/filter/plugins/FfmpegFilter.cxx | 6 ++---- src/filter/plugins/FfmpegFilterPlugin.cxx | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/filter/plugins/FfmpegFilter.cxx b/src/filter/plugins/FfmpegFilter.cxx index de01fc012..816f56648 100644 --- a/src/filter/plugins/FfmpegFilter.cxx +++ b/src/filter/plugins/FfmpegFilter.cxx @@ -53,16 +53,14 @@ FfmpegFilter::FilterPCM(std::span src) memcpy(frame.GetData(0), src.data(), src.size()); - int err = av_buffersrc_add_frame(&buffer_src, frame.get()); - if (err < 0) + if (int err = av_buffersrc_add_frame(&buffer_src, frame.get()); err < 0) throw MakeFfmpegError(err, "av_buffersrc_write_frame() failed"); /* collect filtered data from the FFmpeg audio buffer sink */ frame.Unref(); - err = av_buffersink_get_frame(&buffer_sink, frame.get()); - if (err < 0) { + if (int err = av_buffersink_get_frame(&buffer_sink, frame.get()); err < 0) { if (err == AVERROR(EAGAIN) || err == AVERROR_EOF) return {}; diff --git a/src/filter/plugins/FfmpegFilterPlugin.cxx b/src/filter/plugins/FfmpegFilterPlugin.cxx index fbcbd010b..65b7af3c5 100644 --- a/src/filter/plugins/FfmpegFilterPlugin.cxx +++ b/src/filter/plugins/FfmpegFilterPlugin.cxx @@ -41,8 +41,7 @@ OpenWithAformat(const char *graph_string, AudioFormat &in_audio_format) AudioFormat out_audio_format = in_audio_format; auto &aformat = Ffmpeg::MakeAformat(out_audio_format, *graph); - int error = avfilter_link(&aformat, 0, &buffer_sink, 0); - if (error < 0) + if (int error = avfilter_link(&aformat, 0, &buffer_sink, 0); error < 0) throw MakeFfmpegError(error, "avfilter_link() failed"); graph.ParseSingleInOut(graph_string, aformat, buffer_src); @@ -70,8 +69,7 @@ PreparedFfmpegFilter::Open(AudioFormat &in_audio_format) the required conversion */ auto &aformat = Ffmpeg::MakeAutoAformat(*graph); - int error = avfilter_link(&aformat, 0, &buffer_sink, 0); - if (error < 0) + if (int error = avfilter_link(&aformat, 0, &buffer_sink, 0); error < 0) throw MakeFfmpegError(error, "avfilter_link() failed"); graph.ParseSingleInOut(graph_string, aformat, buffer_src);