From da3de68fb8028785bfb69c357b8a573bb69828b8 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 10 Feb 2019 20:41:18 +0100 Subject: improved fader movement --- cmd/dolmetschctld/statemachine.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/dolmetschctld/statemachine.go b/cmd/dolmetschctld/statemachine.go index 1fe4023..d094875 100644 --- a/cmd/dolmetschctld/statemachine.go +++ b/cmd/dolmetschctld/statemachine.go @@ -169,17 +169,20 @@ func calcNextLevel(target, current mixer.FaderLevel) mixer.FaderLevel { return next } -func (sm *StateMachine) reconcile() { +func (sm *StateMachine) reconcile(ticker bool) { for lang, mcs := range sm.languages { 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 { - mcs.main.target.level = 30 // TODO: hardcoded Value!! + mcs.main.target.level = mixer.FaderLevel(float32(mixer.FaderLevel0db) * 0.5) // TODO: hardcoded Value!! mcs.voice.target.level = mixer.FaderLevel0db } } + if sm.currentState != StateSettled && !ticker { + return + } sm.currentState = StateSettled for _, mcs := range sm.languages { if mcs.main.target.level != mcs.main.current.level { @@ -202,14 +205,14 @@ func (sm *StateMachine) run() { select { case <-t.C: if sm.currentState == StateSettling { - sm.reconcile() + sm.reconcile(true) } case req := <-sm.selectLangCh: req.resultCh <- sm.selectLang(req.l) - sm.reconcile() + sm.reconcile(false) case ev := <-sm.mixerEventCh: sm.handleMixerEvent(ev) - sm.reconcile() + sm.reconcile(false) case <-sm.quitCh: return } -- cgit v1.2.3