summaryrefslogtreecommitdiff
path: root/soundbox/streaming.go
diff options
context:
space:
mode:
Diffstat (limited to 'soundbox/streaming.go')
-rw-r--r--soundbox/streaming.go27
1 files changed, 8 insertions, 19 deletions
diff --git a/soundbox/streaming.go b/soundbox/streaming.go
index 2686f47..1a2d89e 100644
--- a/soundbox/streaming.go
+++ b/soundbox/streaming.go
@@ -2,7 +2,6 @@ package soundbox
import (
"context"
- "errors"
"io"
"net"
"time"
@@ -27,24 +26,14 @@ func streamContext(ctx context.Context, r io.Reader, targets []net.HardwareAddr)
}
}()
- for {
- buffer := make([]byte, bufferSize)
- i, readErr := r.Read(buffer)
- for _, conn := range conns {
- conn.SetDeadline(time.Now().Add(writeTimeout))
- _, writeErr := conn.Write(buffer[:i])
- if writeErr != nil {
- return writeErr
- }
- }
- if readErr != nil {
- if errors.Is(readErr, io.EOF) {
- break
- } else {
- return readErr
- }
- }
+ writers := make([]io.Writer, 0)
+ for _, conn := range conns {
+ writers = append(writers, conn)
}
- return nil
+ mw := io.MultiWriter(writers...)
+
+ _, err := io.Copy(mw, r)
+
+ return err
}