Explorar o código

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.
fearlessTobi %!s(int64=7) %!d(string=hai) anos
pai
achega
7185d90a53
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      src/audio_core/stream.cpp

+ 1 - 1
src/audio_core/stream.cpp

@@ -68,7 +68,7 @@ static void VolumeAdjustSamples(std::vector<s16>& 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<s16>(sample * volume_scale_factor);
     }