mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
fix(tracker): do not close Broker but rather just close the detector
This commit is contained in:
parent
943073d0cc
commit
94058c2603
@ -70,6 +70,7 @@ func main() {
|
|||||||
go func() {
|
go func() {
|
||||||
trackerUi.Main()
|
trackerUi.Main()
|
||||||
audioCloser.Close()
|
audioCloser.Close()
|
||||||
|
detector.Close()
|
||||||
if *cpuprofile != "" {
|
if *cpuprofile != "" {
|
||||||
pprof.StopCPUProfile()
|
pprof.StopCPUProfile()
|
||||||
f.Close()
|
f.Close()
|
||||||
|
@ -135,6 +135,7 @@ func init() {
|
|||||||
CloseFunc: func() {
|
CloseFunc: func() {
|
||||||
t.Exec() <- func() { t.ForceQuit().Do() }
|
t.Exec() <- func() { t.ForceQuit().Do() }
|
||||||
t.WaitQuitted()
|
t.WaitQuitted()
|
||||||
|
detector.Close()
|
||||||
},
|
},
|
||||||
GetChunkFunc: func(isPreset bool) []byte {
|
GetChunkFunc: func(isPreset bool) []byte {
|
||||||
retChn := make(chan []byte)
|
retChn := make(chan []byte)
|
||||||
|
@ -49,6 +49,7 @@ type (
|
|||||||
// which gets executed in the detector goroutine.
|
// which gets executed in the detector goroutine.
|
||||||
MsgToDetector struct {
|
MsgToDetector struct {
|
||||||
Reset bool
|
Reset bool
|
||||||
|
Quit bool
|
||||||
Data any // TODO: consider using a sum type here, for a bit more type safety. See: https://www.jerf.org/iri/post/2917/
|
Data any // TODO: consider using a sum type here, for a bit more type safety. See: https://www.jerf.org/iri/post/2917/
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -62,12 +63,6 @@ func NewBroker() *Broker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Broker) Close() {
|
|
||||||
close(b.ToPlayer)
|
|
||||||
close(b.ToModel)
|
|
||||||
close(b.ToDetector)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetAudioBuffer returns an audio buffer from the buffer pool. The buffer is
|
// GetAudioBuffer returns an audio buffer from the buffer pool. The buffer is
|
||||||
// guaranteed to be empty. After using the buffer, it should be returned to the
|
// guaranteed to be empty. After using the buffer, it should be returned to the
|
||||||
// pool with PutAudioBuffer.
|
// pool with PutAudioBuffer.
|
||||||
|
@ -106,6 +106,9 @@ func (s *Detector) Run() {
|
|||||||
s.loudnessDetector.reset()
|
s.loudnessDetector.reset()
|
||||||
s.peakDetector.reset()
|
s.peakDetector.reset()
|
||||||
}
|
}
|
||||||
|
if msg.Quit {
|
||||||
|
return
|
||||||
|
}
|
||||||
switch data := msg.Data.(type) {
|
switch data := msg.Data.(type) {
|
||||||
case *sointu.AudioBuffer:
|
case *sointu.AudioBuffer:
|
||||||
buf := *data
|
buf := *data
|
||||||
@ -144,6 +147,11 @@ func (s *Detector) Run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Close may theoretically block if the broker is full, but it should not happen in practice
|
||||||
|
func (s *Detector) Close() {
|
||||||
|
s.broker.ToDetector <- MsgToDetector{Quit: true}
|
||||||
|
}
|
||||||
|
|
||||||
func makeLoudnessDetector(weighting WeightingType) loudnessDetector {
|
func makeLoudnessDetector(weighting WeightingType) loudnessDetector {
|
||||||
return loudnessDetector{
|
return loudnessDetector{
|
||||||
weighting: weightings[weighting],
|
weighting: weightings[weighting],
|
||||||
|
@ -166,7 +166,6 @@ func (t *Tracker) Main() {
|
|||||||
w.Perform(system.ActionClose)
|
w.Perform(system.ActionClose)
|
||||||
t.SaveRecovery()
|
t.SaveRecovery()
|
||||||
t.quitWG.Done()
|
t.quitWG.Done()
|
||||||
t.Broker().Close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func eventLoop(w *app.Window, events chan<- event.Event, acks <-chan struct{}) {
|
func eventLoop(w *app.Window, events chan<- event.Event, acks <-chan struct{}) {
|
||||||
|
@ -265,7 +265,6 @@ func FuzzModel(f *testing.F) {
|
|||||||
reader := bytes.NewReader(slice)
|
reader := bytes.NewReader(slice)
|
||||||
synther := vm.GoSynther{}
|
synther := vm.GoSynther{}
|
||||||
broker := tracker.NewBroker()
|
broker := tracker.NewBroker()
|
||||||
defer broker.Close()
|
|
||||||
model, player := tracker.NewModelPlayer(broker, synther, NullContext{}, "")
|
model, player := tracker.NewModelPlayer(broker, synther, NullContext{}, "")
|
||||||
buf := make([][2]float32, 2048)
|
buf := make([][2]float32, 2048)
|
||||||
closeChan := make(chan struct{})
|
closeChan := make(chan struct{})
|
||||||
@ -309,5 +308,6 @@ func FuzzModel(f *testing.F) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
closeChan <- struct{}{}
|
closeChan <- struct{}{}
|
||||||
|
broker.ToDetector <- tracker.MsgToDetector{Quit: true}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user