Skip to content

Commit

Permalink
don't stream nothing
Browse files Browse the repository at this point in the history
stop trying to get music that isn't there
  • Loading branch information
lachlan-00 committed Apr 18, 2024
1 parent 4971b38 commit 6ea91a7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/Module/Application/Playback/Play2Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -1147,21 +1147,32 @@ public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gat
ob_flush();
flush();
}
// end output buffering
ob_end_flush();

// Need to make sure enough bytes were sent.
if ($bytes_streamed < $stream_size && (connection_status() == 0)) {
// This stop's a client requesting the same content-range repeatedly
print(str_repeat(' ', $stream_size - $bytes_streamed));
}

// end output buffering
ob_end_flush();

// close any leftover handle and processes
fclose($filepointer);
if ($transcode && isset($transcoder)) {
Stream::kill_process($transcoder);
}

if ($bytes_streamed === 0 && $stream_size === 0) {
http_response_code(416);
$this->logger->debug(
'Stream ended: No bytes left to stream',
[LegacyLogger::CONTEXT_TYPE => __CLASS__]
);

return null;
}

$this->logger->debug(
'Stream ended at ' . $bytes_streamed . ' bytes out of ' . $stream_size,
[LegacyLogger::CONTEXT_TYPE => __CLASS__]
Expand Down
15 changes: 13 additions & 2 deletions src/Module/Application/Playback/PlayAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -1130,8 +1130,6 @@ public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gat
ob_flush();
flush();
}
// end output buffering
ob_end_flush();

$real_bytes_streamed = $bytes_streamed;
// Need to make sure enough bytes were sent.
Expand All @@ -1141,12 +1139,25 @@ public function run(ServerRequestInterface $request, GuiGatekeeperInterface $gat
$bytes_streamed = $stream_size;
}

// end output buffering
ob_end_flush();

// close any leftover handle and processes
fclose($filepointer);
if ($transcode && isset($transcoder)) {
Stream::kill_process($transcoder);
}

if ($bytes_streamed === 0 && $stream_size === 0) {
http_response_code(416);
$this->logger->debug(
'Stream ended: No bytes left to stream',
[LegacyLogger::CONTEXT_TYPE => __CLASS__]
);

return null;
}

$this->logger->debug(
'Stream ended at ' . $bytes_streamed . ' (' . $real_bytes_streamed . ') bytes out of ' . $stream_size,
[LegacyLogger::CONTEXT_TYPE => __CLASS__]
Expand Down

0 comments on commit 6ea91a7

Please sign in to comment.