From 28a0006b6a6335eb5f5e6e670da0a369fb8ee901 Mon Sep 17 00:00:00 2001 From: "5684185+vsariola@users.noreply.github.com" <5684185+vsariola@users.noreply.github.com> Date: Fri, 20 Jun 2025 14:57:12 +0300 Subject: [PATCH] docs(tracker): improve comments and formatting --- tracker/broker.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tracker/broker.go b/tracker/broker.go index 2f99066..c6d8f98 100644 --- a/tracker/broker.go +++ b/tracker/broker.go @@ -32,7 +32,6 @@ type ( // case <-FinishedXXX: // case <-time.After(3 * time.Second): // } - Broker struct { ToModel chan MsgToModel ToPlayer chan any // TODO: consider using a sum type here, for a bit more type safety. See: https://www.jerf.org/iri/post/2917/ @@ -85,6 +84,10 @@ type ( HasOversampling bool } + // MsgToGUI is a message sent to the GUI, as GUI stores part of the state. + // In particular, GUI knows about where lists / tables are centered, so the + // kind of messages we send to the GUI are about centering the view on a + // specific row, or ensuring that the cursor is visible. MsgToGUI struct { Kind GUIMessageKind Param int @@ -101,7 +104,7 @@ const ( func NewBroker() *Broker { return &Broker{ - ToPlayer: make(chan interface{}, 1024), + ToPlayer: make(chan any, 1024), ToModel: make(chan MsgToModel, 1024), ToDetector: make(chan MsgToDetector, 1024), ToGUI: make(chan any, 1024), @@ -109,7 +112,7 @@ func NewBroker() *Broker { CloseGUI: make(chan struct{}, 1), FinishedGUI: make(chan struct{}), FinishedDetector: make(chan struct{}), - bufferPool: sync.Pool{New: func() interface{} { return &sointu.AudioBuffer{} }}, + bufferPool: sync.Pool{New: func() any { return &sointu.AudioBuffer{} }}, } } @@ -143,10 +146,10 @@ func (b *Broker) PutAudioBuffer(buf *sointu.AudioBuffer) { func TrySend[T any](c chan<- T, v T) bool { select { case c <- v: + return true default: return false } - return true } // TimeoutReceive is a helper function to block until a value is received from a