Update readers to be memory pool friendly

This commit is contained in:
Lukas Herman
2020-10-28 23:12:59 -07:00
parent f4a4edcabd
commit 559c6a13a1
50 changed files with 273 additions and 271 deletions
+3 -3
View File
@@ -97,11 +97,11 @@ func (m *microphone) AudioRecord(p prop.Media) (audio.Reader, error) {
return nil, err
}
reader := audio.ReaderFunc(func() (wave.Audio, error) {
reader := audio.ReaderFunc(func() (wave.Audio, func(), error) {
buff, ok := <-samplesChan
if !ok {
stream.Close()
return nil, io.EOF
return nil, func() {}, io.EOF
}
a := wave.NewInt16Interleaved(
@@ -112,7 +112,7 @@ func (m *microphone) AudioRecord(p prop.Media) (audio.Reader, error) {
)
copy(a.Data, buff)
return a, nil
return a, func() {}, nil
})
stream.Start()