diff options
author | Christian Pointner <equinox@spreadspace.org> | 2019-02-10 00:10:37 +0100 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2019-02-10 00:10:37 +0100 |
commit | 2eb9fddf09f0b398a60c3a39940b58f8c295f4a2 (patch) | |
tree | 857fead041103128861c7fe097cbe1aa046530b2 /cmd/dolmetschctld | |
parent | parsing midi packet works now (diff) |
mixer event subscription works now
Diffstat (limited to 'cmd/dolmetschctld')
-rw-r--r-- | cmd/dolmetschctld/statemachine.go | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/cmd/dolmetschctld/statemachine.go b/cmd/dolmetschctld/statemachine.go index 97f29c0..c5e5707 100644 --- a/cmd/dolmetschctld/statemachine.go +++ b/cmd/dolmetschctld/statemachine.go @@ -80,6 +80,7 @@ type StateMachine struct { selectLangCh chan selectLangRequest quitCh chan bool exitedCh chan struct{} + mixerEventCh chan mixer.Event languages map[Language]LanguageChannels channel2lang map[mixer.Channel]Language @@ -115,6 +116,9 @@ func (sm *StateMachine) run() { select { case req := <-sm.selectLangCh: req.resultCh <- sm.selectLang(req.l) + case ev := <-sm.mixerEventCh: + log.Printf("got event from mixer: %v", ev) + // TODO: update mixer channel states... case <-sm.quitCh: return } @@ -132,6 +136,7 @@ func NewStateMachine(m *mixer.Mixer) (*StateMachine, error) { sm.selectLangCh = make(chan selectLangRequest, 10) sm.quitCh = make(chan bool, 1) sm.exitedCh = make(chan struct{}) + sm.mixerEventCh = make(chan mixer.Event, 3) sm.languages = make(map[Language]LanguageChannels) sm.channel2lang = make(map[mixer.Channel]Language) @@ -161,6 +166,9 @@ func (sm *StateMachine) AddLanguage(name Language, main, voice mixer.Channel) er sm.languages[name] = LanguageChannels{chMain, chVoice} sm.channel2lang[main] = name sm.channel2lang[voice] = name + + sm.mixer.Subscribe(main, sm.mixerEventCh) + sm.mixer.Subscribe(voice, sm.mixerEventCh) return nil } |