diff options
| author | Omar Roth <omarroth@hotmail.com> | 2018-07-15 22:10:29 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2018-07-15 22:10:29 -0500 |
| commit | f189cd7c480d1c48a004042295d3fa1b4d0bddc3 (patch) | |
| tree | 9d442bf12ba3b2426dfdf6e3f952ab4d492f45c4 | |
| parent | 73247d75caa470b7c68cb117f252d3583b8b8d48 (diff) | |
| download | invidious-f189cd7c480d1c48a004042295d3fa1b4d0bddc3.tar.gz invidious-f189cd7c480d1c48a004042295d3fa1b4d0bddc3.tar.bz2 invidious-f189cd7c480d1c48a004042295d3fa1b4d0bddc3.zip | |
Speed up /videoplayback streaming
| -rw-r--r-- | src/invidious.cr | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index dacefad4..01759a62 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -1051,17 +1051,16 @@ get "/videoplayback*" do |env| env.response.headers["Access-Control-Allow-Origin"] = "*" - chunk = Bytes[8] - - loop do - count = response.body_io.read(chunk) - - begin - env.response.write(chunk) + begin + chunk_size = 4096 + size = 1 + while size > 0 + size = IO.copy(response.body_io, env.response.output, chunk_size) env.response.flush - rescue ex - break + Fiber.yield end + rescue ex + break end end end |
