treewide: get rid of C math function usage
Boost does not seem to offer an overload for lrint. Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
a78841d6a9
commit
177371a003
@ -20,12 +20,12 @@
|
|||||||
#include "ReplayGainGlobal.hxx"
|
#include "ReplayGainGlobal.hxx"
|
||||||
#include "ReplayGainConfig.hxx"
|
#include "ReplayGainConfig.hxx"
|
||||||
#include "config/Data.hxx"
|
#include "config/Data.hxx"
|
||||||
|
#include "util/Math.hxx"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
static float
|
static float
|
||||||
ParsePreamp(const char *s)
|
ParsePreamp(const char *s)
|
||||||
|
@ -19,8 +19,7 @@
|
|||||||
|
|
||||||
#include "ReplayGainInfo.hxx"
|
#include "ReplayGainInfo.hxx"
|
||||||
#include "ReplayGainConfig.hxx"
|
#include "ReplayGainConfig.hxx"
|
||||||
|
#include "util/Math.hxx"
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
float
|
float
|
||||||
ReplayGainTuple::CalculateScale(const ReplayGainConfig &config) const noexcept
|
ReplayGainTuple::CalculateScale(const ReplayGainConfig &config) const noexcept
|
||||||
|
@ -37,9 +37,9 @@
|
|||||||
#include "util/StringBuffer.hxx"
|
#include "util/StringBuffer.hxx"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
DecoderBridge::DecoderBridge(DecoderControl &_dc, bool _initial_seek_pending,
|
DecoderBridge::DecoderBridge(DecoderControl &_dc, bool _initial_seek_pending,
|
||||||
std::unique_ptr<Tag> _tag) noexcept
|
std::unique_ptr<Tag> _tag) noexcept
|
||||||
@ -611,7 +611,7 @@ DecoderBridge::SubmitReplayGain(const ReplayGainInfo *new_replay_gain_info) noex
|
|||||||
const auto &tuple = new_replay_gain_info->Get(rgm);
|
const auto &tuple = new_replay_gain_info->Get(rgm);
|
||||||
const auto scale =
|
const auto scale =
|
||||||
tuple.CalculateScale(dc.replay_gain_config);
|
tuple.CalculateScale(dc.replay_gain_config);
|
||||||
dc.replay_gain_db = 20.0 * log10f(scale);
|
dc.replay_gain_db = 20.0 * std::log10(scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
replay_gain_info = *new_replay_gain_info;
|
replay_gain_info = *new_replay_gain_info;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "tag/Handler.hxx"
|
#include "tag/Handler.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "util/Clamp.hxx"
|
#include "util/Clamp.hxx"
|
||||||
|
#include "util/Math.hxx"
|
||||||
#include "util/ScopeExit.hxx"
|
#include "util/ScopeExit.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
@ -32,8 +33,6 @@
|
|||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
struct mpc_decoder_data {
|
struct mpc_decoder_data {
|
||||||
InputStream &is;
|
InputStream &is;
|
||||||
DecoderClient *client;
|
DecoderClient *client;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "event/Call.hxx"
|
#include "event/Call.hxx"
|
||||||
#include "util/ASCII.hxx"
|
#include "util/ASCII.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
|
#include "util/Math.hxx"
|
||||||
#include "util/RuntimeError.hxx"
|
#include "util/RuntimeError.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
@ -35,8 +36,6 @@ extern "C" {
|
|||||||
|
|
||||||
#include <alsa/asoundlib.h>
|
#include <alsa/asoundlib.h>
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#define VOLUME_MIXER_ALSA_DEFAULT "default"
|
#define VOLUME_MIXER_ALSA_DEFAULT "default"
|
||||||
#define VOLUME_MIXER_ALSA_CONTROL_DEFAULT "PCM"
|
#define VOLUME_MIXER_ALSA_CONTROL_DEFAULT "PCM"
|
||||||
static constexpr unsigned VOLUME_MIXER_ALSA_INDEX_DEFAULT = 0;
|
static constexpr unsigned VOLUME_MIXER_ALSA_INDEX_DEFAULT = 0;
|
||||||
|
@ -23,8 +23,9 @@
|
|||||||
#include "pcm/Volume.hxx"
|
#include "pcm/Volume.hxx"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include <math.h>
|
#include <assert.h>
|
||||||
|
|
||||||
class SoftwareMixer final : public Mixer {
|
class SoftwareMixer final : public Mixer {
|
||||||
Filter *filter = nullptr;
|
Filter *filter = nullptr;
|
||||||
@ -74,7 +75,7 @@ PercentVolumeToSoftwareVolume(unsigned volume) noexcept
|
|||||||
if (volume >= 100)
|
if (volume >= 100)
|
||||||
return PCM_VOLUME_1;
|
return PCM_VOLUME_1;
|
||||||
else if (volume > 0)
|
else if (volume > 0)
|
||||||
return pcm_float_to_volume((exp(volume / 25.0) - 1) /
|
return pcm_float_to_volume((std::exp(volume / 25.0) - 1) /
|
||||||
(54.5981500331F - 1));
|
(54.5981500331F - 1));
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -31,10 +31,16 @@
|
|||||||
#define MATH_HXX
|
#define MATH_HXX
|
||||||
|
|
||||||
#ifdef __UCLIBC__
|
#ifdef __UCLIBC__
|
||||||
|
#include <boost/math/special_functions/pow.hpp>
|
||||||
#include <boost/math/special_functions/round.hpp>
|
#include <boost/math/special_functions/round.hpp>
|
||||||
|
using boost::math::iround;
|
||||||
|
using boost::math::pow;
|
||||||
using boost::math::lround;
|
using boost::math::lround;
|
||||||
|
#define lrint iround
|
||||||
#else
|
#else
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
using std::pow;
|
||||||
|
using std::lrint;
|
||||||
using std::lround;
|
using std::lround;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user