From 3d668d871beca3d22bc2c1dd77238733766955d1 Mon Sep 17 00:00:00 2001
From: Alessandro Simovic <alessandro@yuneecresearch.com>
Date: Fri, 29 Mar 2019 14:27:22 +0100
Subject: [PATCH] tunes: don't let tune interrupt itself

---
 src/lib/tunes/tunes.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/lib/tunes/tunes.cpp b/src/lib/tunes/tunes.cpp
index ea81d04033..4457ab8f2a 100644
--- a/src/lib/tunes/tunes.cpp
+++ b/src/lib/tunes/tunes.cpp
@@ -94,6 +94,12 @@ int Tunes::set_control(const tune_control_s &tune_control)
 	    tune_control.tune_override ||  // Override interrupts everything
 	    _default_tunes_interruptable[_current_tune_id]) {
 
+		// Check if this exact tune is already being played back
+		if (tune_control.tune_id != static_cast<int>(TuneID::CUSTOM) &&
+		    _tune == _default_tunes[tune_control.tune_id]) {
+			return OK; // Nothing to do
+		}
+
 		// Reset repeat flag. Can jump to true again while tune is being parsed later
 		_repeat = false;
 
-- 
GitLab