mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
audio/internal/readerdriver: Experimental increase of buffers
Also, this change reduces goroutine uses for efficiency. Updates #1768
This commit is contained in:
parent
045b14ba21
commit
ded679c071
@ -22,7 +22,7 @@ import (
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
const headerBufferSize = 4096
|
||||
const headerBufferSize = 8192
|
||||
|
||||
func IsAvailable() bool {
|
||||
return true
|
||||
@ -117,7 +117,7 @@ func NewContext(sampleRate, channelNum, bitDepthInBytes int) (Context, chan stru
|
||||
}
|
||||
|
||||
c.waveOut = w
|
||||
c.headers = make([]*header, 0, 4)
|
||||
c.headers = make([]*header, 0, 3)
|
||||
for len(c.headers) < cap(c.headers) {
|
||||
h, err := newHeader(c.waveOut, headerBufferSize)
|
||||
if err != nil {
|
||||
|
@ -156,15 +156,23 @@ func (p *player) Play() {
|
||||
}
|
||||
|
||||
func (p *playerImpl) Play() {
|
||||
ch := make(chan struct{})
|
||||
go func() {
|
||||
// Goroutines don't work effiently on Windows. Avoid using them (#1768).
|
||||
if runtime.GOOS == "windows" {
|
||||
p.m.Lock()
|
||||
defer p.m.Unlock()
|
||||
|
||||
close(ch)
|
||||
p.playImpl()
|
||||
}()
|
||||
<-ch
|
||||
} else {
|
||||
ch := make(chan struct{})
|
||||
go func() {
|
||||
p.m.Lock()
|
||||
defer p.m.Unlock()
|
||||
|
||||
close(ch)
|
||||
p.playImpl()
|
||||
}()
|
||||
<-ch
|
||||
}
|
||||
}
|
||||
|
||||
func (p *playerImpl) playImpl() {
|
||||
|
Loading…
Reference in New Issue
Block a user