mirror of
https://github.com/pion/mediadevices.git
synced 2026-04-23 00:07:29 +08:00
Update readers to be memory pool friendly
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user