aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/CrossFade.cxx10
-rw-r--r--src/PlayerControl.cxx5
-rw-r--r--src/PlayerThread.cxx4
-rw-r--r--src/ReplayGainConfig.cxx1
-rw-r--r--src/replay_gain_info.h8
5 files changed, 20 insertions, 8 deletions
diff --git a/src/CrossFade.cxx b/src/CrossFade.cxx
index fe937e4ca..0bdcc43d6 100644
--- a/src/CrossFade.cxx
+++ b/src/CrossFade.cxx
@@ -23,6 +23,8 @@
#include "audio_format.h"
#include "tag.h"
+#include <cmath>
+
#include <assert.h>
#include <string.h>
#include <stdlib.h>
@@ -82,9 +84,8 @@ static float mixramp_interpolate(char *ramp_list, float required_db)
}
/* If required db < any stored value, use the least. */
- if (isnan(last_db)) {
+ if (std::isnan(last_db))
return secs;
- }
/* Finally, interpolate linearly. */
secs = last_secs + (required_db - last_db) * (secs - last_secs) / (db - last_db);
@@ -114,13 +115,14 @@ unsigned cross_fade_calc(float duration, float total_time,
chunks_f = (float)audio_format_time_to_size(af) / (float)CHUNK_SIZE;
- if (isnan(mixramp_delay) || !(mixramp_start) || !(mixramp_prev_end)) {
+ if (std::isnan(mixramp_delay) || !mixramp_start || !mixramp_prev_end) {
chunks = (chunks_f * duration + 0.5);
} else {
/* Calculate mixramp overlap. */
mixramp_overlap = mixramp_interpolate(mixramp_start, mixramp_db - replay_gain_db)
+ mixramp_interpolate(mixramp_prev_end, mixramp_db - replay_gain_prev_db);
- if (!isnan(mixramp_overlap) && (mixramp_delay <= mixramp_overlap)) {
+ if (!std::isnan(mixramp_overlap) &&
+ mixramp_delay <= mixramp_overlap) {
chunks = (chunks_f * (mixramp_overlap - mixramp_delay));
g_debug("will overlap %d chunks, %fs", chunks,
mixramp_overlap - mixramp_delay);
diff --git a/src/PlayerControl.cxx b/src/PlayerControl.cxx
index 275556fe8..4fa9f75b2 100644
--- a/src/PlayerControl.cxx
+++ b/src/PlayerControl.cxx
@@ -28,9 +28,10 @@ extern "C" {
#include "DecoderControl.hxx"
#include "Main.hxx"
+#include <cmath>
+
#include <assert.h>
#include <stdio.h>
-#include <math.h>
static void
pc_enqueue_song_locked(struct player_control *pc, struct song *song);
@@ -49,7 +50,7 @@ player_control::player_control(unsigned _buffer_chunks,
next_song(nullptr),
cross_fade_seconds(0),
mixramp_db(0),
- mixramp_delay_seconds(nanf("")),
+ mixramp_delay_seconds(std::nanf("")),
total_play_time(0)
{
}
diff --git a/src/PlayerThread.cxx b/src/PlayerThread.cxx
index 6b05dd97c..44534a7d8 100644
--- a/src/PlayerThread.cxx
+++ b/src/PlayerThread.cxx
@@ -37,6 +37,8 @@ extern "C" {
#include "idle.h"
}
+#include <cmath>
+
#include <glib.h>
#undef G_LOG_DOMAIN
@@ -759,7 +761,7 @@ play_next_chunk(struct player *player)
other_chunk->tag);
other_chunk->tag = NULL;
- if (isnan(pc->mixramp_delay_seconds)) {
+ if (std::isnan(pc->mixramp_delay_seconds)) {
chunk->mix_ratio = ((float)cross_fade_position)
/ player->cross_fade_chunks;
} else {
diff --git a/src/ReplayGainConfig.cxx b/src/ReplayGainConfig.cxx
index df07e43c5..d2fe309ca 100644
--- a/src/ReplayGainConfig.cxx
+++ b/src/ReplayGainConfig.cxx
@@ -33,7 +33,6 @@ extern "C" {
#include <assert.h>
#include <stdlib.h>
#include <string.h>
-#include <math.h>
enum replay_gain_mode replay_gain_mode = REPLAY_GAIN_OFF;
diff --git a/src/replay_gain_info.h b/src/replay_gain_info.h
index 53e2451a3..b06dc6cf0 100644
--- a/src/replay_gain_info.h
+++ b/src/replay_gain_info.h
@@ -22,8 +22,12 @@
#include "check.h"
+#ifdef __cplusplus
+#include <cmath>
+#else
#include <stdbool.h>
#include <math.h>
+#endif
enum replay_gain_mode {
REPLAY_GAIN_AUTO = -2,
@@ -58,7 +62,11 @@ replay_gain_info_init(struct replay_gain_info *info)
static inline bool
replay_gain_tuple_defined(const struct replay_gain_tuple *tuple)
{
+#ifdef __cplusplus
+ return !std::isinf(tuple->gain);
+#else
return !isinf(tuple->gain);
+#endif
}
#ifdef __cplusplus