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() p.m.Lock()
l := lengthInBytes l := lengthInBytes
if len(p.buf) < lengthInBytes {
if !p.srcEOF { // Buffer size needs to be much more than the actual required length
p.m.Unlock() // so that noise due to empty buffer can be avoided.
return r if len(p.buf) < lengthInBytes*4 && !p.srcEOF {
} p.m.Unlock()
return r
}
if l > len(p.buf) {
l = len(p.buf) l = len(p.buf)
} }
for i := 0; i < l/2; i++ { for i := 0; i < l/2; i++ {