|
@@ -286,10 +286,10 @@ func (drh *DefaultRequestHandler) defaultServeRequest(c net.Conn, path string, m
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
-writeFrame writes a frame to a client.
|
|
|
+prepareFrame prepares a frame before it can be written to a client.
|
|
|
*/
|
|
|
-func (drh *DefaultRequestHandler) writeFrame(c net.Conn, pl Playlist, frameOffset int,
|
|
|
- writtenBytes uint64, metaDataSupport bool) (int, uint64, error) {
|
|
|
+func (drh *DefaultRequestHandler) prepareFrame(c net.Conn, pl Playlist, frameOffset int,
|
|
|
+ writtenBytes uint64, metaDataSupport bool) ([]byte, int, error) {
|
|
|
|
|
|
frame, err := pl.Frame()
|
|
|
|
|
@@ -318,8 +318,6 @@ func (drh *DefaultRequestHandler) writeFrame(c net.Conn, pl Playlist, frameOffse
|
|
|
Print(fmt.Sprintf("Empty frame for: %v - %v (Error: %v)", pl.Title(), pl.Artist(), err))
|
|
|
}
|
|
|
|
|
|
- return frameOffset, writtenBytes, err
|
|
|
-
|
|
|
} else if err != nil {
|
|
|
|
|
|
if err != ErrPlaylistEnd {
|
|
@@ -329,6 +327,20 @@ func (drh *DefaultRequestHandler) writeFrame(c net.Conn, pl Playlist, frameOffse
|
|
|
err = nil
|
|
|
}
|
|
|
|
|
|
+ return frame, frameOffset, err
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+writeFrame writes a frame to a client.
|
|
|
+*/
|
|
|
+func (drh *DefaultRequestHandler) writeFrame(c net.Conn, pl Playlist, frameOffset int,
|
|
|
+ writtenBytes uint64, metaDataSupport bool) (int, uint64, error) {
|
|
|
+
|
|
|
+ frame, frameOffset, err := drh.prepareFrame(c, pl, frameOffset, writtenBytes, metaDataSupport)
|
|
|
+ if frame == nil {
|
|
|
+ return frameOffset, writtenBytes, err
|
|
|
+ }
|
|
|
+
|
|
|
// Check if meta data should be send
|
|
|
|
|
|
if metaDataSupport && writtenBytes+uint64(len(frame)) >= MetaDataInterval {
|
|
@@ -448,7 +460,7 @@ func (drh *DefaultRequestHandler) writeUnauthorized(c net.Conn) error {
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
-debug will print additional debug output if `DebugOutput` is enabled.
|
|
|
+printDebug will print additional debug output if `DebugOutput` is enabled.
|
|
|
*/
|
|
|
func printDebug(v ...interface{}) {
|
|
|
if DebugOutput {
|