mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-27 04:08:53 +01:00
audio: More often reading (decoding) audio source to reduce noise
This commit is contained in:
parent
7ce87a6c82
commit
18c6890d96
@ -488,8 +488,8 @@ func (p *Player) readLoop() {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to read the buffer for 1/15[s].
|
// Try to read the buffer for 1/60[s].
|
||||||
l := p.sampleRate * bytesPerSample * channelNum / 15
|
l := p.sampleRate * bytesPerSample * channelNum / 60
|
||||||
l &= mask
|
l &= mask
|
||||||
buf := make([]byte, l)
|
buf := make([]byte, l)
|
||||||
n, err := p.src.Read(buf)
|
n, err := p.src.Read(buf)
|
||||||
@ -507,7 +507,7 @@ func (p *Player) readLoop() {
|
|||||||
t = nil
|
t = nil
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
t = time.After(10 * time.Millisecond)
|
t = time.After(time.Millisecond)
|
||||||
|
|
||||||
case buf := <-p.proceedCh:
|
case buf := <-p.proceedCh:
|
||||||
if readErr != nil {
|
if readErr != nil {
|
||||||
@ -518,9 +518,7 @@ func (p *Player) readLoop() {
|
|||||||
lengthInBytes := len(buf) * 2
|
lengthInBytes := len(buf) * 2
|
||||||
l := lengthInBytes
|
l := lengthInBytes
|
||||||
|
|
||||||
// Buffer size needs to be much more than the actual required length
|
if len(p.buf) < lengthInBytes && !p.srcEOF {
|
||||||
// so that noise caused by empty buffer can be avoided.
|
|
||||||
if len(p.buf) < lengthInBytes*8 && !p.srcEOF {
|
|
||||||
p.proceededCh <- proceededValues{buf, nil}
|
p.proceededCh <- proceededValues{buf, nil}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user