16 lines
382 B
Go
16 lines
382 B
Go
package mic
|
|||
|
|
|
||
|
|
// ponytail: cap listen buffer at 5s; excess dropped from front (slow poll won't OOM agent).
|
||
|
|
const maxChunkPCM = SampleRate * BytesPerSample * 5
|
||
|
|
|
||
|
|
func appendChunkPCM(buf []byte, pcm []byte) []byte {
|
||
|
|
if len(pcm) == 0 {
|
||
|
|
return buf
|
||
|
|
}
|
||
|
|
buf = append(buf, pcm...)
|
||
|
|
if len(buf) <= maxChunkPCM {
|
||
|
|
return buf
|
||
|
|
}
|
||
|
|
return append([]byte(nil), buf[len(buf)-maxChunkPCM:]...)
|
||
|
|
}
|