Skip to content

Commit 0b76095

Browse files
nehebMaxKellermann
authored andcommitted
Math.hxx: remove
This no longer serves any useful purpose. In addition, std::lround is used in several places directly. Signed-off-by: Rosen Penev <rosenp@gmail.com>
1 parent 7932faf commit 0b76095

File tree

9 files changed

+14
-38
lines changed

9 files changed

+14
-38
lines changed

src/Stats.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "db/Stats.hxx"
1313
#include "Log.hxx"
1414
#include "time/ChronoUtil.hxx"
15-
#include "util/Math.hxx"
1615

1716
#ifdef _WIN32
1817
#include "system/Clock.hxx"
@@ -112,7 +111,7 @@ stats_print(Response &r, const Partition &partition)
112111
r.Fmt("uptime: {}\n"
113112
"playtime: {}\n",
114113
std::chrono::duration_cast<std::chrono::seconds>(uptime).count(),
115-
lround(partition.pc.GetTotalPlayTime().count()));
114+
std::lround(partition.pc.GetTotalPlayTime().count()));
116115

117116
#ifdef ENABLE_DATABASE
118117
const Database *db = partition.instance.GetDatabase();

src/command/PlayerCommands.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "util/StringBuffer.hxx"
1717
#include "util/ScopeExit.hxx"
1818
#include "util/Exception.hxx"
19-
#include "util/Math.hxx"
2019

2120
#include "db/Features.hxx" // for ENABLE_DATABASE
2221
#ifdef ENABLE_DATABASE
@@ -152,7 +151,7 @@ handle_status(Client &client, [[maybe_unused]] Request args, Response &r)
152151

153152
if (pc.GetCrossFade() > FloatDuration::zero())
154153
r.Fmt(COMMAND_STATUS_CROSSFADE ": {}\n",
155-
lround(pc.GetCrossFade().count()));
154+
std::lround(pc.GetCrossFade().count()));
156155

157156
if (pc.GetMixRampDelay() > FloatDuration::zero())
158157
r.Fmt(COMMAND_STATUS_MIXRAMPDELAY ": {}\n",

src/decoder/plugins/FaadDecoderPlugin.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
#include "tag/Handler.hxx"
1010
#include "util/ScopeExit.hxx"
1111
#include "util/Domain.hxx"
12-
#include "util/Math.hxx"
1312
#include "util/SpanCast.hxx"
1413
#include "Log.hxx"
1514

1615
#include <cassert>
16+
#include <cmath>
1717
#include <cstring>
1818

1919
#include <neaacdec.h>
@@ -368,7 +368,7 @@ faad_stream_decode(DecoderClient &client, InputStream &is,
368368
/* update bit rate and position */
369369

370370
if (frame_info.samples > 0) {
371-
bit_rate = lround(frame_info.bytesconsumed * 8.0 *
371+
bit_rate = std::lround(frame_info.bytesconsumed * 8.0 *
372372
frame_info.channels * audio_format.sample_rate /
373373
frame_info.samples / 1000);
374374
}

src/decoder/plugins/WavpackDecoderPlugin.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "fs/Path.hxx"
1212
#include "lib/fmt/PathFormatter.hxx"
1313
#include "lib/fmt/RuntimeError.hxx"
14-
#include "util/Math.hxx"
1514
#include "util/ScopeExit.hxx"
1615

1716
#include <wavpack/wavpack.h>
@@ -218,7 +217,7 @@ wavpack_decode(DecoderClient &client, WavpackContext *wpc, bool can_seek)
218217
if (n_frames == 0)
219218
break;
220219

221-
int bitrate = lround(WavpackGetInstantBitrate(wpc) / 1000);
220+
int bitrate = std::lround(WavpackGetInstantBitrate(wpc) / 1000);
222221
format_samples(buffer, n_frames * audio_format.channels);
223222

224223
cmd = client.SubmitAudio(nullptr,

src/mixer/plugins/AlsaMixerPlugin.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
#include "event/Call.hxx"
1616
#include "util/ASCII.hxx"
1717
#include "util/Domain.hxx"
18-
#include "util/Math.hxx"
1918
#include "Log.hxx"
2019

2120
#include <alsa/asoundlib.h>
21+
#include <cmath>
2222

2323
#define VOLUME_MIXER_ALSA_DEFAULT "default"
2424
#define VOLUME_MIXER_ALSA_CONTROL_DEFAULT "PCM"
@@ -107,7 +107,7 @@ class AlsaMixer final : public Mixer {
107107
private:
108108
[[gnu::const]]
109109
static unsigned NormalizedToPercent(double normalized) noexcept {
110-
return lround(100 * normalized);
110+
return std::lround(100 * normalized);
111111
}
112112

113113
[[gnu::pure]]

src/mixer/plugins/WinmmMixerPlugin.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
#include "output/Features.h"
77
#include "output/OutputAPI.hxx"
88
#include "output/plugins/WinmmOutputPlugin.hxx"
9-
#include "util/Math.hxx"
109

1110
#include <mmsystem.h>
1211

1312
#include <cassert>
13+
#include <cmath>
1414
#include <stdexcept>
1515

1616
#include <windows.h>
@@ -38,13 +38,13 @@ class WinmmMixer final : public Mixer {
3838
static inline int
3939
winmm_volume_decode(DWORD volume)
4040
{
41-
return lround((volume & 0xFFFF) / 655.35);
41+
return std::lround((volume & 0xFFFF) / 655.35);
4242
}
4343

4444
static inline DWORD
4545
winmm_volume_encode(int volume)
4646
{
47-
int value = lround(volume * 655.35);
47+
int value = std::lround(volume * 655.35);
4848
return MAKELONG(value, value);
4949
}
5050

src/pcm/Mix.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "Clamp.hxx"
77
#include "Traits.hxx"
88
#include "util/Clamp.hxx"
9-
#include "util/Math.hxx"
109

1110
#include "Dither.cxx" // including the .cxx file to get inlined templates
1211

@@ -208,7 +207,7 @@ pcm_mix(PcmDither &dither, void *buffer1, const void *buffer2, size_t size,
208207
s = std::sin((float)M_PI_2 * portion1);
209208
s *= s;
210209

211-
int vol1 = lround(s * PCM_VOLUME_1S);
210+
int vol1 = std::lround(s * PCM_VOLUME_1S);
212211
vol1 = Clamp<int>(vol1, 0, PCM_VOLUME_1S);
213212

214213
return pcm_add_vol(dither, buffer1, buffer2, size,

src/player/CrossFade.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
#include "pcm/AudioFormat.hxx"
88
#include "util/CNumberParser.hxx"
99
#include "util/Domain.hxx"
10-
#include "util/Math.hxx"
1110
#include "Log.hxx"
1211

1312
#include <cassert>
13+
#include <cmath>
1414

1515
static constexpr Domain cross_fade_domain("cross_fade");
1616

@@ -109,7 +109,7 @@ CrossFadeSettings::Calculate(float replay_gain_db, float replay_gain_prev_db,
109109

110110
if (!IsMixRampEnabled() ||
111111
!mixramp_start || !mixramp_prev_end) {
112-
chunks = lround(duration / chunk_duration);
112+
chunks = std::lround(duration / chunk_duration);
113113
} else {
114114
/* Calculate mixramp overlap. */
115115
const auto mixramp_overlap_current =
@@ -124,7 +124,7 @@ CrossFadeSettings::Calculate(float replay_gain_db, float replay_gain_prev_db,
124124
if (mixramp_overlap_current >= FloatDuration::zero() &&
125125
mixramp_overlap_prev >= FloatDuration::zero() &&
126126
mixramp_delay <= mixramp_overlap) {
127-
chunks = lround((mixramp_overlap - mixramp_delay)
127+
chunks = std::lround((mixramp_overlap - mixramp_delay)
128128
/ chunk_duration);
129129
FmtDebug(cross_fade_domain,
130130
"will overlap {} chunks, {}s", chunks,

src/util/Math.hxx

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)