filter/ffmpeg: detect the output sample format

Some FFmpeg filters change the sample format, and since MPD assumes
this never happens, this results in loud noise instead of music.  This
commit finally implements the TODO comment by sending one frame of
silence to the filter and checking the output frame's format.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1009
This commit is contained in:
Max Kellermann
2020-11-16 09:08:27 +01:00
parent 394f69bee1
commit 38b41fc3fd
5 changed files with 132 additions and 2 deletions

View File

@@ -23,6 +23,7 @@
#include "filter/Filter.hxx"
#include "filter/Prepared.hxx"
#include "lib/ffmpeg/Filter.hxx"
#include "lib/ffmpeg/DetectFilterFormat.hxx"
#include "config/Block.hxx"
class PreparedFfmpegFilter final : public PreparedFilter {
@@ -60,7 +61,9 @@ PreparedFfmpegFilter::Open(AudioFormat &in_audio_format)
graph.CheckAndConfigure();
auto out_audio_format = in_audio_format; // TODO
const auto out_audio_format =
Ffmpeg::DetectFilterOutputFormat(in_audio_format, *buffer_src,
*buffer_sink);
return std::make_unique<FfmpegFilter>(in_audio_format,
out_audio_format,