mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
audio/internal/cbackend: adjust the defalut buffer size to Oto's
This commit is contained in:
parent
e2de758160
commit
d74a627f41
@ -62,6 +62,6 @@ func (c *Context) Err() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Context) bufferSize() int {
|
||||
return c.sampleRate * c.channelNum * c.bitDepthInBytes / 4 // 0.25[s]
|
||||
func (c *Context) defaultBufferSize() int {
|
||||
return c.sampleRate * c.channelNum * c.bitDepthInBytes / 2 // 0.5[s]
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ func (p *playerImpl) Play() {
|
||||
|
||||
func (p *playerImpl) ensureTmpBuf() []byte {
|
||||
if p.tmpbuf == nil {
|
||||
p.tmpbuf = make([]byte, p.context.bufferSize())
|
||||
p.tmpbuf = make([]byte, p.context.defaultBufferSize())
|
||||
}
|
||||
return p.tmpbuf
|
||||
}
|
||||
@ -193,7 +193,7 @@ func (p *playerImpl) playImpl() {
|
||||
|
||||
if !p.eof {
|
||||
buf := p.ensureTmpBuf()
|
||||
for len(p.buf) < p.context.bufferSize() {
|
||||
for len(p.buf) < p.context.defaultBufferSize() {
|
||||
n, err := p.src.Read(buf)
|
||||
if err != nil && err != io.EOF {
|
||||
p.setErrorImpl(err)
|
||||
@ -360,7 +360,7 @@ func (p *playerImpl) canReadSourceToBuffer() bool {
|
||||
if p.eof {
|
||||
return false
|
||||
}
|
||||
return len(p.buf) < p.context.bufferSize()
|
||||
return len(p.buf) < p.context.defaultBufferSize()
|
||||
}
|
||||
|
||||
func (p *playerImpl) readSourceToBuffer() {
|
||||
@ -374,7 +374,7 @@ func (p *playerImpl) readSourceToBuffer() {
|
||||
return
|
||||
}
|
||||
|
||||
if len(p.buf) >= p.context.bufferSize() {
|
||||
if len(p.buf) >= p.context.defaultBufferSize() {
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user