Revert "examples/pcm: Bug fix: audio.Player refs should be held not to be GCed"

This reverts commit 38133b2d43.
This commit is contained in:
Hajime Hoshi 2018-12-17 02:34:16 +09:00
parent 38133b2d43
commit 6afdeee66b

View File

@ -83,9 +83,6 @@ func square(out []int16, volume float64, freq float64, sequence float64) {
}
}
// players holds audio.Player objects not to be GCed.
var players = map[*audio.Player]struct{}{}
// toBytes returns the 2ch little endian 16bit byte sequence with the given left/right sequence.
func toBytes(l, r []int16) []byte {
if len(l) != len(r) {
@ -130,7 +127,6 @@ func playNote(scoreIndex int) rune {
p, _ := audio.NewPlayerFromBytes(audioContext, toBytes(l, r))
p.Play()
players[p] = struct{}{}
return rune(note)
}
@ -150,18 +146,6 @@ func update(screen *ebiten.Image) error {
}
frames++
// Close players that alrady finish.
closed := []*audio.Player{}
for p := range players {
if p.IsPlaying() {
continue
}
closed = append(closed, p)
}
for _, p := range closed {
delete(players, p)
}
if ebiten.IsDrawingSkipped() {
return nil
}