mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-08-30 18:28:59 +00:00
rework module shutdown process to cancel module context in defer
This commit is contained in:
@@ -83,17 +83,16 @@ func (mi *MIDIInput) Start(ctx context.Context, inputHandler common.InputHandler
|
||||
mi.stop = stop
|
||||
|
||||
<-mi.ctx.Done()
|
||||
mi.logger.Debug("done")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mi *MIDIInput) Stop() {
|
||||
if mi.cancel != nil {
|
||||
mi.cancel()
|
||||
defer mi.cancel()
|
||||
}
|
||||
if mi.stop != nil {
|
||||
mi.stop()
|
||||
mi.stop = nil
|
||||
}
|
||||
midi.CloseDriver()
|
||||
mi.logger.Debug("done")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user