mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-09-10 07:29:25 +00:00
rework module shutdown process to cancel module context in defer
This commit is contained in:
@@ -86,6 +86,7 @@ func (mo *MIDIOutput) Start(ctx context.Context, inputHandler common.InputHandle
|
||||
mo.sendFuncMu.Unlock()
|
||||
|
||||
<-mo.ctx.Done()
|
||||
mo.logger.Debug("done")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -107,8 +108,7 @@ func (mo *MIDIOutput) Output(ctx context.Context, payload any) error {
|
||||
|
||||
func (mo *MIDIOutput) Stop() {
|
||||
if mo.cancel != nil {
|
||||
mo.cancel()
|
||||
defer mo.cancel()
|
||||
}
|
||||
midi.CloseDriver()
|
||||
mo.logger.Debug("done")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user