Audio
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
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:]...)
|
||||
}
|
||||
Reference in New Issue
Block a user