From 945352a3700ed2736c27a88cdd1f39e97ecb1ae1 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 10 Feb 2019 20:04:09 +0100 Subject: use mute state of voice channel to disable automatic switching for this language --- cmd/dolmetschctld/statemachine.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'cmd') diff --git a/cmd/dolmetschctld/statemachine.go b/cmd/dolmetschctld/statemachine.go index afe2ac0..7e37af1 100644 --- a/cmd/dolmetschctld/statemachine.go +++ b/cmd/dolmetschctld/statemachine.go @@ -152,8 +152,13 @@ func (sm *StateMachine) selectLang(l Language) error { } } sm.targetLang = l + log.Printf("new target language: '%s'", sm.targetLang) + return nil +} + +func (sm *StateMachine) reconcile() { for lang, mcs := range sm.languages { - if sm.targetLang == "" || lang == sm.targetLang { + if sm.targetLang == "" || lang == sm.targetLang || mcs.voice.current.mute == mixer.MuteMuted { mcs.main.target.level = mixer.FaderLevel0db mcs.voice.target.level = mixer.FaderLevelOff } else { @@ -161,17 +166,16 @@ func (sm *StateMachine) selectLang(l Language) error { mcs.voice.target.level = mixer.FaderLevel0db } } - log.Printf("new target language: '%s'", sm.targetLang) - return nil -} -func (sm *StateMachine) reconcile() { + sm.currentState = StateSettled for _, mcs := range sm.languages { if mcs.main.target.level != mcs.main.current.level { sm.mixer.SetLevel(mcs.main.num, mcs.main.target.level) // TODO: implement smooth fading!! + sm.currentState = StateSettling } if mcs.voice.target.level != mcs.voice.current.level { sm.mixer.SetLevel(mcs.voice.num, mcs.voice.target.level) // TODO: implement smooth fading!! + sm.currentState = StateSettling } } } -- cgit v1.2.3