mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 03:02:49 +01:00
audio: Adjust buffer size
This commit is contained in:
parent
f3997cf5ae
commit
00d8d61795
@ -477,12 +477,14 @@ func (p *Player) readLoop() {
|
|||||||
break
|
break
|
||||||
|
|
||||||
case <-t:
|
case <-t:
|
||||||
|
// If the buffer has 1 second, that's enough.
|
||||||
if len(p.buf) >= p.sampleRate*4 {
|
if len(p.buf) >= p.sampleRate*4 {
|
||||||
t = time.After(100 * time.Millisecond)
|
t = time.After(100 * time.Millisecond)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
l := p.sampleRate * 4 / 60
|
// Try to read the buffer for 1/15[s].
|
||||||
|
l := p.sampleRate * 4 / 15
|
||||||
l &= mask
|
l &= mask
|
||||||
buf := make([]byte, l)
|
buf := make([]byte, l)
|
||||||
n, err := p.src.Read(buf)
|
n, err := p.src.Read(buf)
|
||||||
@ -500,7 +502,7 @@ func (p *Player) readLoop() {
|
|||||||
t = nil
|
t = nil
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
t = time.After(time.Millisecond)
|
t = time.After(10 * time.Millisecond)
|
||||||
|
|
||||||
case buf := <-p.proceedCh:
|
case buf := <-p.proceedCh:
|
||||||
if readErr != nil {
|
if readErr != nil {
|
||||||
@ -513,7 +515,7 @@ func (p *Player) readLoop() {
|
|||||||
|
|
||||||
// Buffer size needs to be much more than the actual required length
|
// Buffer size needs to be much more than the actual required length
|
||||||
// so that noise caused by empty buffer can be avoided.
|
// so that noise caused by empty buffer can be avoided.
|
||||||
if len(p.buf) < lengthInBytes*4 && !p.srcEOF {
|
if len(p.buf) < lengthInBytes*15 && !p.srcEOF {
|
||||||
p.proceededCh <- proceededValues{buf, nil}
|
p.proceededCh <- proceededValues{buf, nil}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user