From 68c4853a40ea83038a8ab8698e9094c3a35f3cc2 Mon Sep 17 00:00:00 2001 From: badaix Date: Sun, 31 Mar 2024 18:45:25 +0200 Subject: [PATCH] Use boost process v2 for boost >= 1.80.0 --- .github/workflows/ci.yml | 2 +- client/player/player.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11bcf047..96239a4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -268,7 +268,7 @@ jobs: key: ${{ runner.os }}-dependencies - name: dependencies if: steps.cache-dependencies.outputs.cache-hit != 'true' - run: vcpkg.exe install libflac libvorbis soxr opus boost-asio --triplet x64-windows + run: vcpkg.exe install libflac libvorbis soxr opus boost-asio boost-process --triplet x64-windows - name: configure run: | echo vcpkg installation root: ${env:VCPKG_INSTALLATION_ROOT} diff --git a/client/player/player.cpp b/client/player/player.cpp index d9c7c31e..9a0e654e 100644 --- a/client/player/player.cpp +++ b/client/player/player.cpp @@ -28,11 +28,22 @@ // 3rd party headers #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" +#if BOOST_VERSION >= 108000 #if defined(__clang__) && (__clang_major__ >= 13) && !((__clang_major__ == 13) && (__clang_minor__ == 0) && (__clang_patchlevel__ == 0)) #pragma GCC diagnostic ignored "-Wunused-but-set-variable" #endif #pragma GCC diagnostic ignored "-Wpedantic" #include +#else +#pragma GCC diagnostic ignored "-Wpragmas" +#pragma GCC diagnostic ignored "-Wunused-result" +#pragma GCC diagnostic ignored "-Wmissing-braces" +#pragma GCC diagnostic ignored "-Wnarrowing" +#pragma GCC diagnostic ignored "-Wc++11-narrowing" +#include +#include +#include +#endif #pragma GCC diagnostic pop // standard headers @@ -233,6 +244,8 @@ void Player::setVolume(const Volume& volume) } else if (settings_.mixer.mode == ClientSettings::Mixer::Mode::script) { +#if BOOST_VERSION >= 108000 + // Use Boost process v2 if Boost >= 1.80.0 is available static std::optional pending_volume_setting; static bool script_running = false; if (script_running) @@ -268,6 +281,19 @@ void Player::setVolume(const Volume& volume) LOG(ERROR, LOG_TAG) << "Failed to run script '" + settings_.mixer.parameter + "', error: " << e.what() << "\n"; } } +#else + // Use Boost process v1 + try + { + using namespace boost::process; + child c(exe = settings_.mixer.parameter, args = {"--volume", cpt::to_string(volume), "--mute", mute ? "true" : "false"}); + c.detach(); + } + catch (const std::exception& e) + { + LOG(ERROR, LOG_TAG) << "Failed to run script '" + settings_.mixer.parameter + "', error: " << e.what() << "\n"; + } +#endif } }