alsa: removed use of pool buffer chunk, Read closes the chunk for us since it's a fully consuming read

This commit is contained in:
Trek H 2022-02-09 15:00:04 +10:30
parent fa8fdfdd46
commit 1abca8cd7e
1 changed files with 1 additions and 4 deletions

View File

@ -414,7 +414,7 @@ func (d *ALSA) input() {
func (d *ALSA) Read(p []byte) (int, error) { func (d *ALSA) Read(p []byte) (int, error) {
// Ready ringbuffer for read. // Ready ringbuffer for read.
d.l.Log(logger.Debug, pkg+"getting next chunk ready") d.l.Log(logger.Debug, pkg+"getting next chunk ready")
chunk, err := d.buf.Next(rbNextTimeout) _, err := d.buf.Next(rbNextTimeout)
if err != nil { if err != nil {
switch err { switch err {
case nil, io.EOF: case nil, io.EOF:
@ -436,16 +436,13 @@ func (d *ALSA) Read(p []byte) (int, error) {
switch err { switch err {
case nil, io.EOF: case nil, io.EOF:
d.l.Log(logger.Debug, pkg+"EOF") d.l.Log(logger.Debug, pkg+"EOF")
chunk.Close()
return 0, nil return 0, nil
default: default:
d.l.Log(logger.Error, pkg+"unexpected error from Read", "error", err.Error()) d.l.Log(logger.Error, pkg+"unexpected error from Read", "error", err.Error())
chunk.Close()
return 0, nil return 0, nil
} }
} }
d.l.Log(logger.Debug, fmt.Sprintf("%v read %v bytes", pkg, n)) d.l.Log(logger.Debug, fmt.Sprintf("%v read %v bytes", pkg, n))
chunk.Close()
return n, nil return n, nil
} }