Windows uses std::system instead of bp::child

This commit is contained in:
badaix 2020-05-04 15:43:14 +02:00
parent 89679de108
commit 8de5a7a069
2 changed files with 23 additions and 10 deletions

View file

@ -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

View file

@ -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;
try
double dparam = -1.;
if (!param.empty())
{
if (!param.empty())
try
{
dparam = cpt::stod(param);
}
catch(...)
{
throw SnapException("Invalid mixer param: " + param);
if (dparam < 0)
throw SnapException("must be a positive number");
}
catch (const std::exception& e)
{
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)
{