From 732b036343510c720f96bd89a2ff2086e0b8a42f Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 17 Dec 2018 02:34:10 +0900 Subject: [PATCH] Revert "examples/pcm: Bug fix: audio.Player refs should be held not to be GCed" This reverts commit 52f0bd7e214e9c40cba3c7424243218a69934527. --- examples/pcm/main.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/examples/pcm/main.go b/examples/pcm/main.go index 505bf5f45..1c0f54878 100644 --- a/examples/pcm/main.go +++ b/examples/pcm/main.go @@ -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 }