mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
audio: bug fix: test out of memory on browsers
This commit is contained in:
parent
6f74e03cb3
commit
bf3ded2a55
@ -17,6 +17,7 @@ package audio
|
||||
import (
|
||||
"io"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
@ -63,9 +64,17 @@ func (p *dummyPlayer) Play() {
|
||||
p.playing = true
|
||||
p.m.Unlock()
|
||||
go func() {
|
||||
if _, err := io.ReadAll(p.r); err != nil {
|
||||
var buf [4096]byte
|
||||
for {
|
||||
_, err := p.r.Read(buf[:])
|
||||
if err != nil {
|
||||
if err != io.EOF {
|
||||
panic(err)
|
||||
}
|
||||
break
|
||||
}
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
p.m.Lock()
|
||||
p.playing = false
|
||||
p.m.Unlock()
|
||||
|
Loading…
Reference in New Issue
Block a user