Commit 333a08eb authored by Max Kellermann's avatar Max Kellermann

replay_gain_info, ...: use cmath instead of math.h in C++ mode

Fixes build problems with mingw32.
parent 989c9a73
......@@ -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);
......
......@@ -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)
{
}
......
......@@ -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 {
......
......@@ -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;
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment