mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +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 (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
@ -63,9 +64,17 @@ func (p *dummyPlayer) Play() {
|
|||||||
p.playing = true
|
p.playing = true
|
||||||
p.m.Unlock()
|
p.m.Unlock()
|
||||||
go func() {
|
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)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
time.Sleep(time.Millisecond)
|
||||||
|
}
|
||||||
p.m.Lock()
|
p.m.Lock()
|
||||||
p.playing = false
|
p.playing = false
|
||||||
p.m.Unlock()
|
p.m.Unlock()
|
||||||
|
Loading…
Reference in New Issue
Block a user