filter/ffmpeg: move code to ReadOutput()
This commit is contained in:
parent
3d99f1d8a6
commit
acb9ee9792
|
@ -34,6 +34,21 @@ FfmpegFilter::FfmpegFilter(const AudioFormat &in_audio_format,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::span<const std::byte>
|
||||||
|
FfmpegFilter::ReadOutput()
|
||||||
|
{
|
||||||
|
frame.Unref();
|
||||||
|
|
||||||
|
if (int err = av_buffersink_get_frame(&buffer_sink, frame.get()); err < 0) {
|
||||||
|
if (err == AVERROR(EAGAIN) || err == AVERROR_EOF)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
throw MakeFfmpegError(err, "av_buffersink_get_frame() failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ffmpeg::InterleaveFrame(*frame, interleave_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
std::span<const std::byte>
|
std::span<const std::byte>
|
||||||
FfmpegFilter::FilterPCM(std::span<const std::byte> src)
|
FfmpegFilter::FilterPCM(std::span<const std::byte> src)
|
||||||
{
|
{
|
||||||
|
@ -58,17 +73,8 @@ FfmpegFilter::FilterPCM(std::span<const std::byte> src)
|
||||||
|
|
||||||
/* collect filtered data from the FFmpeg audio buffer sink */
|
/* collect filtered data from the FFmpeg audio buffer sink */
|
||||||
|
|
||||||
frame.Unref();
|
|
||||||
|
|
||||||
if (int err = av_buffersink_get_frame(&buffer_sink, frame.get()); err < 0) {
|
|
||||||
if (err == AVERROR(EAGAIN) || err == AVERROR_EOF)
|
|
||||||
return {};
|
|
||||||
|
|
||||||
throw MakeFfmpegError(err, "av_buffersink_get_frame() failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO: call av_buffersink_get_frame() repeatedly? Not
|
/* TODO: call av_buffersink_get_frame() repeatedly? Not
|
||||||
possible with MPD's current Filter API */
|
possible with MPD's current Filter API */
|
||||||
|
|
||||||
return Ffmpeg::InterleaveFrame(*frame, interleave_buffer);
|
return ReadOutput();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,9 @@ public:
|
||||||
|
|
||||||
/* virtual methods from class Filter */
|
/* virtual methods from class Filter */
|
||||||
std::span<const std::byte> FilterPCM(std::span<const std::byte> src) override;
|
std::span<const std::byte> FilterPCM(std::span<const std::byte> src) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::span<const std::byte> ReadOutput();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue