aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaveTBlake <oak99sky@yahoo.co.uk>2017-03-19 11:55:51 +0000
committerDaveTBlake <oak99sky@yahoo.co.uk>2017-03-19 11:55:51 +0000
commite413504ad1f6882d61f69d1f9eddd87cc5a8af01 (patch)
treeac37b7759edb251de52315b74ae13d20d891d78d
parent58145684538c94cd76bda3e5b3249c273f4caede (diff)
Fix replaygain so clipping check works when peak not 1.0. Allow amplification to be < 1.0 to provide clipping protection when replaygain < 1.0 and peak > 1.0 (headroom on mp3 decoding).
-rw-r--r--xbmc/cores/AudioEngine/Utils/AELimiter.h2
-rw-r--r--xbmc/cores/paplayer/PAPlayer.cpp4
2 files changed, 4 insertions, 2 deletions
diff --git a/xbmc/cores/AudioEngine/Utils/AELimiter.h b/xbmc/cores/AudioEngine/Utils/AELimiter.h
index 4918b56a16..6c4226a67c 100644
--- a/xbmc/cores/AudioEngine/Utils/AELimiter.h
+++ b/xbmc/cores/AudioEngine/Utils/AELimiter.h
@@ -36,7 +36,7 @@ class CAELimiter
void SetAmplification(float amplify)
{
- m_amplify = std::max(std::min(amplify, 1000.0f), 1.0f);
+ m_amplify = std::max(std::min(amplify, 1000.0f), 0.0f);
}
float GetAmplification()
diff --git a/xbmc/cores/paplayer/PAPlayer.cpp b/xbmc/cores/paplayer/PAPlayer.cpp
index 87c43a5553..780399f2dc 100644
--- a/xbmc/cores/paplayer/PAPlayer.cpp
+++ b/xbmc/cores/paplayer/PAPlayer.cpp
@@ -488,9 +488,11 @@ inline bool PAPlayer::PrepareStream(StreamInfo *si)
si->m_stream->SetVolume (si->m_volume);
float peak = 1.0;
float gain = si->m_decoder.GetReplayGain(peak);
- if (peak == 1.0)
+ if (peak * gain <= 1.0)
+ // No clipping protection needed
si->m_stream->SetReplayGain(gain);
else
+ // Clipping protecton provided as audio limiting
si->m_stream->SetAmplification(gain);
/* if its not the first stream and crossfade is not enabled */