From 1da76815702d10481adda659ac743c8771ea2f6c Mon Sep 17 00:00:00 2001 From: badaix Date: Wed, 9 Dec 2020 09:21:52 +0100 Subject: [PATCH] Add null sink to file player --- client/player/file_player.cpp | 9 ++++++--- client/snapclient.cpp | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/player/file_player.cpp b/client/player/file_player.cpp index bb266ff1..9c11db3f 100644 --- a/client/player/file_player.cpp +++ b/client/player/file_player.cpp @@ -47,7 +47,7 @@ FilePlayer::FilePlayer(boost::asio::io_context& io_context, const ClientSettings { file_.reset(stderr, [](auto p) { std::ignore = p; }); } - else + else if (filename != "null") { std::string mode = "w"; if (params.find("mode") != params.end()) @@ -91,8 +91,11 @@ void FilePlayer::requestAudio() { adjustVolume(static_cast(buffer_.data()), numFrames); } - fwrite(buffer_.data(), 1, needed, file_.get()); - fflush(file_.get()); + if (file_) + { + fwrite(buffer_.data(), 1, needed, file_.get()); + fflush(file_.get()); + } loop(); } diff --git a/client/snapclient.cpp b/client/snapclient.cpp index 38095426..f02b4177 100644 --- a/client/snapclient.cpp +++ b/client/snapclient.cpp @@ -335,7 +335,7 @@ int main(int argc, char** argv) if (settings.player.player_name == "file") { cout << "Options are a comma separated list of:\n" - << " \"filename=\" - with = \"stdout\", \"stderr\" or a filename\n" + << " \"filename=\" - with = \"stdout\", \"stderr\", \"null\" or a filename\n" << " \"mode=[w|a]\" - w: write (discarding the content), a: append (keeping the content)\n"; } else if (settings.player.player_name == "pulse")