From 7185d90a5376fb1642abe9491aa412f9f6b49003 Mon Sep 17 00:00:00 2001 From: fearlessTobi Date: Sat, 26 Jan 2019 14:53:58 +0100 Subject: [PATCH] dsp_interface: fix sound being played while volume is 0 According to documentation, if the argument of std::exp is zero, one is returned. However we want the return value to be also zero in this case so no audio is played. --- src/audio_core/stream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp index 874673c4e5..4ce2d374e6 100644 --- a/src/audio_core/stream.cpp +++ b/src/audio_core/stream.cpp @@ -68,7 +68,7 @@ static void VolumeAdjustSamples(std::vector& samples) { } // Implementation of a volume slider with a dynamic range of 60 dB - const float volume_scale_factor{std::exp(6.90775f * volume) * 0.001f}; + const float volume_scale_factor = volume == 0 ? 0 : std::exp(6.90775f * volume) * 0.001f; for (auto& sample : samples) { sample = static_cast(sample * volume_scale_factor); }