summaryrefslogtreecommitdiff
path: root/soundbox
diff options
context:
space:
mode:
Diffstat (limited to 'soundbox')
-rw-r--r--soundbox/streaming.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/soundbox/streaming.go b/soundbox/streaming.go
index 5852dcf..2686f47 100644
--- a/soundbox/streaming.go
+++ b/soundbox/streaming.go
@@ -29,19 +29,19 @@ func streamContext(ctx context.Context, r io.Reader, targets []net.HardwareAddr)
for {
buffer := make([]byte, bufferSize)
- i, err := r.Read(buffer)
- if err != nil {
- if errors.Is(err, io.EOF) {
- break
- } else {
- return err
- }
- }
+ i, readErr := r.Read(buffer)
for _, conn := range conns {
conn.SetDeadline(time.Now().Add(writeTimeout))
- _, err = conn.Write(buffer[:i])
- if err != nil {
- return err
+ _, writeErr := conn.Write(buffer[:i])
+ if writeErr != nil {
+ return writeErr
+ }
+ }
+ if readErr != nil {
+ if errors.Is(readErr, io.EOF) {
+ break
+ } else {
+ return readErr
}
}
}