We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fcf6253 commit f49dff1Copy full SHA for f49dff1
internal/mux/mux.go
@@ -156,7 +156,8 @@ func (m *Mux) ReadFloat32s(buf []float32) {
156
}
157
158
type Player struct {
159
- p *playerImpl
+ p *playerImpl
160
+ cleanup runtime.Cleanup
161
162
163
type playerState int
@@ -191,7 +192,9 @@ func (m *Mux) NewPlayer(src io.Reader) *Player {
191
192
bufferSize: m.defaultBufferSize(),
193
},
194
- runtime.SetFinalizer(pl, (*Player).Close)
195
+ pl.cleanup = runtime.AddCleanup(pl, func(p *playerImpl) {
196
+ _ = p.Close()
197
+ }, pl.p)
198
return pl
199
200
@@ -432,7 +435,7 @@ func (p *playerImpl) BufferedSize() int {
432
435
433
436
434
437
func (p *Player) Close() error {
- runtime.SetFinalizer(p, nil)
438
+ p.cleanup.Stop()
439
return p.p.Close()
440
441
0 commit comments