From d455c1e7e14d0579f6a70b51b572505268e4dc6f Mon Sep 17 00:00:00 2001 From: Alessandro Simovic <alessandro@yuneecresearch.com> Date: Tue, 23 Jan 2018 12:12:06 +0100 Subject: [PATCH] libtunes: Repeating tunes can be interrupted without override Otherwise the only way of interrupting a repeated tune would be with the override flag, which should only be used rarely. Now repeating tunes have lowest priority, followed by one-shot tunes, followed by anything with an override flag. --- src/lib/tunes/tunes.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/tunes/tunes.cpp b/src/lib/tunes/tunes.cpp index 90e1d4226b..86c65631cf 100644 --- a/src/lib/tunes/tunes.cpp +++ b/src/lib/tunes/tunes.cpp @@ -88,7 +88,15 @@ void Tunes::config_tone(bool repeat_flag) int Tunes::set_control(const tune_control_s &tune_control) { bool reset_playing_tune = false; - _repeat = false; + + // Only reset these flags if the new tune will actually be played. + // Note that repeated tunes can always be interrupted, even without the + // override flag. + if (_repeat || _tune == nullptr || tune_control.tune_override) { + _repeat = false; + _using_custom_msg = false; + _tune = nullptr; + } if (tune_control.tune_id < _default_tunes_size) { switch (tune_control.tune_id) { -- GitLab