mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
Revert "examples/pcm: Bug fix: audio.Player refs should be held not to be GCed"
This reverts commit 52f0bd7e21
.
This commit is contained in:
parent
52f0bd7e21
commit
732b036343
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user