summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2020-04-13 00:13:05 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2020-04-13 00:13:05 (GMT)
commitcdd3c33b87617a249781be289d6228e859cb6e26 (patch)
tree6eaa1433cc0b0c4f332ff489a57bfb9b0729dfad
parent52d35abf317beec142c002a07e88fde756246014 (diff)
statemachine: current vs target vs real
-rw-r--r--cmd/dolmetschctld/statemachine.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/cmd/dolmetschctld/statemachine.go b/cmd/dolmetschctld/statemachine.go
index 21b38e2..1abb5fd 100644
--- a/cmd/dolmetschctld/statemachine.go
+++ b/cmd/dolmetschctld/statemachine.go
@@ -42,6 +42,7 @@ type MixerChannel struct {
num mixer.Channel
target MixerChannelState
current MixerChannelState
+ real MixerChannelState
}
type MixerChannels struct {
@@ -168,10 +169,10 @@ func (sm *StateMachine) handleMixerEvent(ev mixer.Event) {
}
switch ev.Type {
- // case mixer.EventFaderChange:
- // mc.current.level = ev.Level
+ case mixer.EventFaderChange:
+ mc.real.level = ev.Level
case mixer.EventMute:
- mc.current.mute = ev.Mute
+ mc.real.mute = ev.Mute
}
}
@@ -229,7 +230,7 @@ func calcNextLevel(target, current mixer.FaderLevel) mixer.FaderLevel {
func (sm *StateMachine) reconcile(ticker bool) {
for lang, mcs := range sm.languages {
- if sm.language == "" || lang == sm.language || mcs.interpreter.current.mute == mixer.MuteMuted {
+ if sm.language == "" || lang == sm.language {
mcs.original.target.level = mixer.FaderLevel0db
mcs.interpreter.target.level = mixer.FaderLevelOff
} else {
@@ -244,6 +245,7 @@ func (sm *StateMachine) reconcile(ticker bool) {
if sm.state != types.StateSettled && !ticker {
return
}
+
sm.state = types.StateSettled
for _, mcs := range sm.languages {
if mcs.original.target.level != mcs.original.current.level {
@@ -342,8 +344,8 @@ func (sm *StateMachine) AddLanguage(name types.Language, original, interpreter m
}
unknown := MixerChannelState{level: mixer.FaderLevelUnknown, mute: mixer.MuteUnknown}
- chOriginal := MixerChannel{num: original, current: unknown, target: unknown}
- chInterpreter := MixerChannel{num: interpreter, current: unknown, target: unknown}
+ chOriginal := MixerChannel{num: original, target: unknown, current: unknown, real: unknown}
+ chInterpreter := MixerChannel{num: interpreter, target: unknown, current: unknown, real: unknown}
sm.languages[name] = &MixerChannels{chOriginal, chInterpreter}
sm.channel2lang[original] = name