From 5e93cfdd9e23ee8a2e611f31eca057cf407b6766 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 23 Jan 2017 17:55:04 +0100 Subject: [PATCH] output/Source: reset the ReplayGain serials ion OpenFilter() Each close/open cycle resets the Filter's state, because a new Filter instance is being created. That results in the serials (replay_gain_serial and other_replay_gain_serial) being out of sync with the internal ReplayGainFilter state. So instead of initializing those serials once, we need to initialize them each time we create new ReplayGainFilter instances, i.e. in OpenFilter(). https://bugs.musicpd.org/view.php?id=4632 --- NEWS | 1 + src/output/Source.cxx | 8 ++++++-- src/output/Source.hxx | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 951914d2e..b203e1d0b 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ ver 0.20.3 (not yet released) * protocol - "playlistadd" creates new playlist if it does not exist, as documented +* replay gain: don't reset ReplayGain levels when unpausing playback * silence surround channels when converting from stereo * use shortcuts such as "dsd64" in log messages diff --git a/src/output/Source.cxx b/src/output/Source.cxx index fbaa9ff80..e5a67f1bd 100644 --- a/src/output/Source.cxx +++ b/src/output/Source.cxx @@ -95,13 +95,17 @@ try { assert(audio_format.IsValid()); /* the replay_gain filter cannot fail here */ - if (prepared_replay_gain_filter != nullptr) + if (prepared_replay_gain_filter != nullptr) { + replay_gain_serial = 0; replay_gain_filter_instance = prepared_replay_gain_filter->Open(audio_format); + } - if (prepared_other_replay_gain_filter != nullptr) + if (prepared_other_replay_gain_filter != nullptr) { + other_replay_gain_serial = 0; other_replay_gain_filter_instance = prepared_other_replay_gain_filter->Open(audio_format); + } filter_instance = prepared_filter->Open(audio_format); } catch (...) { diff --git a/src/output/Source.hxx b/src/output/Source.hxx index e15c2c3fb..c9bbd45f6 100644 --- a/src/output/Source.hxx +++ b/src/output/Source.hxx @@ -64,13 +64,13 @@ class AudioOutputSource { * The serial number of the last replay gain info. 0 means no * replay gain info was available. */ - unsigned replay_gain_serial = 0; + unsigned replay_gain_serial; /** * The serial number of the last replay gain info by the * "other" chunk during cross-fading. */ - unsigned other_replay_gain_serial = 0; + unsigned other_replay_gain_serial; /** * The replay_gain_filter_plugin instance of this audio