filter/ffmpeg: use `if` with initializer
This commit is contained in:
parent
2ef36af68d
commit
3d99f1d8a6
|
@ -53,16 +53,14 @@ FfmpegFilter::FilterPCM(std::span<const std::byte> src)
|
||||||
|
|
||||||
memcpy(frame.GetData(0), src.data(), src.size());
|
memcpy(frame.GetData(0), src.data(), src.size());
|
||||||
|
|
||||||
int err = av_buffersrc_add_frame(&buffer_src, frame.get());
|
if (int err = av_buffersrc_add_frame(&buffer_src, frame.get()); err < 0)
|
||||||
if (err < 0)
|
|
||||||
throw MakeFfmpegError(err, "av_buffersrc_write_frame() failed");
|
throw MakeFfmpegError(err, "av_buffersrc_write_frame() failed");
|
||||||
|
|
||||||
/* collect filtered data from the FFmpeg audio buffer sink */
|
/* collect filtered data from the FFmpeg audio buffer sink */
|
||||||
|
|
||||||
frame.Unref();
|
frame.Unref();
|
||||||
|
|
||||||
err = av_buffersink_get_frame(&buffer_sink, frame.get());
|
if (int err = av_buffersink_get_frame(&buffer_sink, frame.get()); err < 0) {
|
||||||
if (err < 0) {
|
|
||||||
if (err == AVERROR(EAGAIN) || err == AVERROR_EOF)
|
if (err == AVERROR(EAGAIN) || err == AVERROR_EOF)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,7 @@ OpenWithAformat(const char *graph_string, AudioFormat &in_audio_format)
|
||||||
AudioFormat out_audio_format = in_audio_format;
|
AudioFormat out_audio_format = in_audio_format;
|
||||||
auto &aformat = Ffmpeg::MakeAformat(out_audio_format, *graph);
|
auto &aformat = Ffmpeg::MakeAformat(out_audio_format, *graph);
|
||||||
|
|
||||||
int error = avfilter_link(&aformat, 0, &buffer_sink, 0);
|
if (int error = avfilter_link(&aformat, 0, &buffer_sink, 0); error < 0)
|
||||||
if (error < 0)
|
|
||||||
throw MakeFfmpegError(error, "avfilter_link() failed");
|
throw MakeFfmpegError(error, "avfilter_link() failed");
|
||||||
|
|
||||||
graph.ParseSingleInOut(graph_string, aformat, buffer_src);
|
graph.ParseSingleInOut(graph_string, aformat, buffer_src);
|
||||||
|
@ -70,8 +69,7 @@ PreparedFfmpegFilter::Open(AudioFormat &in_audio_format)
|
||||||
the required conversion */
|
the required conversion */
|
||||||
auto &aformat = Ffmpeg::MakeAutoAformat(*graph);
|
auto &aformat = Ffmpeg::MakeAutoAformat(*graph);
|
||||||
|
|
||||||
int error = avfilter_link(&aformat, 0, &buffer_sink, 0);
|
if (int error = avfilter_link(&aformat, 0, &buffer_sink, 0); error < 0)
|
||||||
if (error < 0)
|
|
||||||
throw MakeFfmpegError(error, "avfilter_link() failed");
|
throw MakeFfmpegError(error, "avfilter_link() failed");
|
||||||
|
|
||||||
graph.ParseSingleInOut(graph_string, aformat, buffer_src);
|
graph.ParseSingleInOut(graph_string, aformat, buffer_src);
|
||||||
|
|
Loading…
Reference in New Issue