summaryrefslogtreecommitdiff
path: root/src/pcm
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2020-03-15 23:33:21 -0700
committerMax Kellermann <max@musicpd.org>2020-09-21 09:13:51 +0200
commit7715311117972984459dfbc1a4d8be9a83205b8c (patch)
tree6a70c524a72df0323748d5c66306add9b8dc66a2 /src/pcm
parent4c1cfca95b8a6dd2c0d9a7b6df065912eb8b4231 (diff)
fix double promotions
Found with -Wdouble-promotion Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'src/pcm')
-rw-r--r--src/pcm/FloatConvert.hxx2
-rw-r--r--src/pcm/PcmMix.cxx4
-rw-r--r--src/pcm/SoxrResampler.cxx2
-rw-r--r--src/pcm/Volume.hxx2
4 files changed, 6 insertions, 4 deletions
diff --git a/src/pcm/FloatConvert.hxx b/src/pcm/FloatConvert.hxx
index 28f923c7a..17fcd27ce 100644
--- a/src/pcm/FloatConvert.hxx
+++ b/src/pcm/FloatConvert.hxx
@@ -53,7 +53,7 @@ struct IntegerToFloatSampleConvert {
typedef typename SrcTraits::value_type SV;
typedef typename DstTraits::value_type DV;
- static constexpr DV factor = 1.0 / FloatToIntegerSampleConvert<F, Traits>::factor;
+ static constexpr DV factor = 1.0f / FloatToIntegerSampleConvert<F, Traits>::factor;
static_assert(factor > 0, "Wrong factor");
static constexpr DV Convert(SV src) noexcept {
diff --git a/src/pcm/PcmMix.cxx b/src/pcm/PcmMix.cxx
index bbb26d1c4..11d201c3e 100644
--- a/src/pcm/PcmMix.cxx
+++ b/src/pcm/PcmMix.cxx
@@ -26,6 +26,8 @@
#include "PcmDither.cxx" // including the .cxx file to get inlined templates
+#include <cmath>
+
#include <assert.h>
template<SampleFormat F, class Traits=SampleTraits<F>>
@@ -221,7 +223,7 @@ pcm_mix(PcmDither &dither, void *buffer1, const void *buffer2, size_t size,
if (portion1 < 0)
return pcm_add(buffer1, buffer2, size, format);
- s = sin(M_PI_2 * portion1);
+ s = std::sin((float)M_PI_2 * portion1);
s *= s;
int vol1 = lround(s * PCM_VOLUME_1S);
diff --git a/src/pcm/SoxrResampler.cxx b/src/pcm/SoxrResampler.cxx
index 411e79b43..2dcb507e0 100644
--- a/src/pcm/SoxrResampler.cxx
+++ b/src/pcm/SoxrResampler.cxx
@@ -122,7 +122,7 @@ SoxrPcmResampler::Open(AudioFormat &af, unsigned new_sample_rate)
ratio = float(new_sample_rate) / float(af.sample_rate);
FormatDebug(soxr_domain,
"samplerate conversion ratio to %.2lf",
- ratio);
+ double(ratio));
/* libsoxr works with floating point samples */
af.format = SampleFormat::FLOAT;
diff --git a/src/pcm/Volume.hxx b/src/pcm/Volume.hxx
index ddc6cb854..52a63d819 100644
--- a/src/pcm/Volume.hxx
+++ b/src/pcm/Volume.hxx
@@ -48,7 +48,7 @@ static constexpr int PCM_VOLUME_1S = PCM_VOLUME_1;
static constexpr inline int
pcm_float_to_volume(float volume) noexcept
{
- return volume * PCM_VOLUME_1 + 0.5;
+ return int(volume * PCM_VOLUME_1 + 0.5f);
}
static constexpr inline float