mirror of
https://github.com/badaix/snapcast.git
synced 2025-04-29 10:17:16 +02:00
Windows uses std::system instead of bp::child
This commit is contained in:
parent
89679de108
commit
8de5a7a069
2 changed files with 23 additions and 10 deletions
|
@ -178,7 +178,7 @@ before_install:
|
|||
if [ ! -f "vcpkg/vcpkg.exe" ]; then # if not in cache from a previous run
|
||||
git clone https://github.com/Microsoft/vcpkg.git
|
||||
./vcpkg/bootstrap-vcpkg.bat
|
||||
travis-wait-enhanced --interval=1m --timeout=30m -- ./vcpkg/vcpkg.exe install libflac libvorbis soxr opus boost-asio boost-process --triplet x64-windows
|
||||
travis-wait-enhanced --interval=1m --timeout=30m -- ./vcpkg/vcpkg.exe install libflac libvorbis soxr opus boost-asio --triplet x64-windows
|
||||
else
|
||||
./vcpkg/vcpkg.exe update # make sure dependencies are up to date
|
||||
fi
|
||||
|
|
|
@ -19,7 +19,11 @@
|
|||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef WINDOWS
|
||||
#include <cstdlib>
|
||||
#else
|
||||
#include <boost/process.hpp>
|
||||
#endif
|
||||
|
||||
#include "common/aixlog.hpp"
|
||||
#include "common/snap_exception.hpp"
|
||||
|
@ -156,27 +160,36 @@ void Player::setVolume(double volume, bool mute)
|
|||
{
|
||||
string param;
|
||||
string mode = utils::string::split_left(settings_.mixer.parameter, ':', param);
|
||||
double dparam;
|
||||
double dparam = -1.;
|
||||
if (!param.empty())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!param.empty())
|
||||
dparam = cpt::stod(param);
|
||||
if (dparam < 0)
|
||||
throw SnapException("must be a positive number");
|
||||
}
|
||||
catch(...)
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
throw SnapException("Invalid mixer param: " + param);
|
||||
throw SnapException("Invalid mixer param: " + param + ", error: " + string(e.what()));
|
||||
}
|
||||
}
|
||||
if (mode == "poly")
|
||||
setVolume_poly(volume, param.empty() ? 3. : dparam);
|
||||
setVolume_poly(volume, (dparam < 0) ? 3. : dparam);
|
||||
else
|
||||
setVolume_exp(volume, param.empty() ? 10. : dparam);
|
||||
setVolume_exp(volume, (dparam < 0) ? 10. : dparam);
|
||||
}
|
||||
else if (settings_.mixer.mode == ClientSettings::Mixer::Mode::script)
|
||||
{
|
||||
try
|
||||
{
|
||||
#ifdef WINDOWS
|
||||
string cmd = settings_.mixer.parameter + " --volume " + cpt::to_string(volume) + " --mute " + (mute ? "true" : "false");
|
||||
std::system(cmd.c_str());
|
||||
#else
|
||||
child c(exe = settings_.mixer.parameter, args = {"--volume", cpt::to_string(volume), "--mute", mute ? "true" : "false"});
|
||||
c.detach();
|
||||
#endif
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue