-
Notifications
You must be signed in to change notification settings - Fork 238
Handle ranges more correctly when streaming #1035
Conversation
Cleaned up the logging and experimental things I added, I think it's good now. |
airsonic-main/src/main/java/org/airsonic/player/controller/StreamController.java
Outdated
Show resolved
Hide resolved
airsonic-main/src/main/java/org/airsonic/player/io/RangeOutputStream.java
Show resolved
Hide resolved
Also looks like you'll need to add an explicit depdency for the following:
Should just be able to put it in the airsonic-main/pom.xml. |
I'll pull that and leave it running on my server for a while, I'll let you guys know if I see something going bad! |
Wrote some tests for this in #1026. With this PR the responses now actually line up with ffmpeg's generated output. Well done! Besides getting travis to be happy, I'd like to see this PR reduced to the minimum amount of changes possible. I.e. no line changes, no refactoring, etc. Those can be done separately if really needed. The reason for this is two fold:
@tari let me know your thoughts on simplifying. I'd also be more than happy to send a PR against your PR to help. |
I mentioned I had been getting this issue lately in #685 (comment), but the current PR unfortunately doesn't appear to fix it, it just makes it appear 100% of the time on one specific album/song.
The player looks like this when this happens (note the "Live Broadcast"): The Firefox logs contain this message (and the stream request appears incomplete in the Network panel):
Here are file sizes and durations (as reported by
|
@fxthomas can you send me your example file? |
Sure, in your mailbox! In the mean time, it seems that I'm just a poor dumb human making mistakes. I restarted Firefox, which made the issue go away with your PR. I also happened to take the wrong notes for the stream size/duration after PR, edited my earlier comment to reflect that. All I can say is... great job on the PR! 😄 |
As for reducing the impact of these changes overall, I think the refactoring is necessary for everything to make sense (without it, it's very difficult to follow what should happen) but much of the reformatting and other changes could be split up. I'll do some rebasing so refactoring and reformatting are more separate, but if you have further opinions on simplification I'm happy to see them. |
There's no reason to wrap a stream in an output that will do nothing, as when the requested range is 0-; eg the entire stream.
Making it easier to tell where API contracts allow nulls, where it's otherwise unclear without reading the implementation.
Mostly just whitespace changes, shortening lines for readability. Adds a few comments that outline what's supposed to happen.
The core loop was put together confusingly; this encapsulates the process of constructing an OutputStream and reformats some.
When transcoding, always use chunked transfers and report that ranges are not supported. When not transcoding, support returning ranges but only if requested.
This workaround is obsolete with correct handling of ranges when requested.
..and now it's been split into a number of smaller commits. |
How exciting! Thanks team! |
Most excellent 👌 |
Significant refactoring of the stream controller, to correctly handle Range requests by including a header as to the support for ranges in a given request (supported iff not transcoding) if a range is requested, and use chunked encoding when transcoding.
I believe this fixes #685 (it appears to on my system).