audio: Reduce noise (#443)

This commit is contained in:
Hajime Hoshi 2017-12-23 04:25:48 +09:00
parent 3addbfce8a
commit 7cc6154de6

View File

@ -418,11 +418,14 @@ func (p *Player) bufferToInt16(lengthInBytes int) []int16 {
p.m.Lock()
l := lengthInBytes
if len(p.buf) < lengthInBytes {
if !p.srcEOF {
p.m.Unlock()
return r
}
// Buffer size needs to be much more than the actual required length
// so that noise due to empty buffer can be avoided.
if len(p.buf) < lengthInBytes*4 && !p.srcEOF {
p.m.Unlock()
return r
}
if l > len(p.buf) {
l = len(p.buf)
}
for i := 0; i < l/2; i++ {