handle eof

This commit is contained in:
filifa 2024-08-24 13:51:27 -05:00
parent 5bba14b556
commit 59bebc7e00
1 changed files with 5 additions and 1 deletions

View File

@ -11,6 +11,7 @@ import "C"
import ( import (
"encoding/binary" "encoding/binary"
"io"
"os" "os"
"time" "time"
) )
@ -61,7 +62,10 @@ func main() {
audioData := make([]int16, bufSize) audioData := make([]int16, bufSize)
err = binary.Read(os.Stdin, binary.LittleEndian, audioData) err = binary.Read(os.Stdin, binary.LittleEndian, audioData)
if err != nil { if err == io.ErrUnexpectedEOF {
running = false
break
} else if err != nil {
panic(err) panic(err)
} }