diff --git a/src/Stats.cxx b/src/Stats.cxx index 0ba5d6b85..d62025c82 100644 --- a/src/Stats.cxx +++ b/src/Stats.cxx @@ -31,6 +31,7 @@ #include "util/ChronoUtil.hxx" #include +#include #ifndef _WIN32 /** @@ -120,7 +121,7 @@ stats_print(Response &r, const Partition &partition) #else (unsigned)std::chrono::duration_cast(std::chrono::steady_clock::now() - start_time).count(), #endif - (unsigned long)(partition.pc.GetTotalPlayTime().count() + 0.5)); + std::lround(partition.pc.GetTotalPlayTime().count())); #ifdef ENABLE_DATABASE const Database *db = partition.instance.database; diff --git a/src/command/PlayerCommands.cxx b/src/command/PlayerCommands.cxx index 570bc75b8..27147f373 100644 --- a/src/command/PlayerCommands.cxx +++ b/src/command/PlayerCommands.cxx @@ -39,6 +39,8 @@ #include "db/update/Service.hxx" #endif +#include + #define COMMAND_STATUS_STATE "state" #define COMMAND_STATUS_REPEAT "repeat" #define COMMAND_STATUS_SINGLE "single" @@ -151,8 +153,8 @@ handle_status(Client &client, gcc_unused Request args, Response &r) state); if (pc.GetCrossFade() > 0) - r.Format(COMMAND_STATUS_CROSSFADE ": %i\n", - int(pc.GetCrossFade() + 0.5)); + r.Format(COMMAND_STATUS_CROSSFADE ": %lu\n", + std::lround(pc.GetCrossFade())); if (pc.GetMixRampDelay() > 0) r.Format(COMMAND_STATUS_MIXRAMPDELAY ": %f\n", diff --git a/src/decoder/plugins/FaadDecoderPlugin.cxx b/src/decoder/plugins/FaadDecoderPlugin.cxx index 7fc56b6a0..403feeabc 100644 --- a/src/decoder/plugins/FaadDecoderPlugin.cxx +++ b/src/decoder/plugins/FaadDecoderPlugin.cxx @@ -31,6 +31,7 @@ #include +#include #include #include @@ -386,9 +387,9 @@ faad_stream_decode(DecoderClient &client, InputStream &is, /* update bit rate and position */ if (frame_info.samples > 0) { - bit_rate = frame_info.bytesconsumed * 8.0 * - frame_info.channels * audio_format.sample_rate / - frame_info.samples / 1000 + 0.5; + bit_rate = lround(frame_info.bytesconsumed * 8.0 * + frame_info.channels * audio_format.sample_rate / + frame_info.samples / 1000); } /* send PCM samples to MPD */ diff --git a/src/output/plugins/HaikuOutputPlugin.cxx b/src/output/plugins/HaikuOutputPlugin.cxx index 578d701f6..a18aa34f4 100644 --- a/src/output/plugins/HaikuOutputPlugin.cxx +++ b/src/output/plugins/HaikuOutputPlugin.cxx @@ -38,6 +38,8 @@ #include #include +#include + #include #define UTF8_PLAY "\xE2\x96\xB6" @@ -439,7 +441,7 @@ haiku_output_get_volume(HaikuOutput &haiku) if (soundPlayer == NULL || soundPlayer->InitCheck() != B_OK) return 0; - return (int)(soundPlayer->Volume() * 100 + 0.5); + return lround(soundPlayer->Volume() * 100); } bool diff --git a/src/pcm/PcmMix.cxx b/src/pcm/PcmMix.cxx index 2af4f3dac..8f0291667 100644 --- a/src/pcm/PcmMix.cxx +++ b/src/pcm/PcmMix.cxx @@ -26,8 +26,9 @@ #include "PcmDither.cxx" // including the .cxx file to get inlined templates +#include + #include -#include template> static typename Traits::value_type @@ -225,7 +226,7 @@ pcm_mix(PcmDither &dither, void *buffer1, const void *buffer2, size_t size, s = sin(M_PI_2 * portion1); s *= s; - int vol1 = s * PCM_VOLUME_1S + 0.5; + int vol1 = std::lround(s * PCM_VOLUME_1S); vol1 = Clamp(vol1, 0, PCM_VOLUME_1S); return pcm_add_vol(dither, buffer1, buffer2, size, diff --git a/src/player/CrossFade.cxx b/src/player/CrossFade.cxx index 903adf410..82c11223c 100644 --- a/src/player/CrossFade.cxx +++ b/src/player/CrossFade.cxx @@ -26,6 +26,8 @@ #include "util/Domain.hxx" #include "Log.hxx" +#include + #include static constexpr Domain cross_fade_domain("cross_fade"); @@ -108,7 +110,7 @@ CrossFadeSettings::Calculate(SignedSongTime total_time, chunks_f = (float)af.GetTimeToSize() / (float)sizeof(MusicChunk::data); if (mixramp_delay <= 0 || !mixramp_start || !mixramp_prev_end) { - chunks = (chunks_f * duration + 0.5); + chunks = std::lround(chunks_f * duration); } else { /* Calculate mixramp overlap. */ const float mixramp_overlap_current =