Fix streaming receivedTill reporting.

It was incorrect in case audio and video had different durations.
This commit is contained in:
John Preston 2019-03-24 10:06:55 +04:00
parent a0b3b1affd
commit d1cf43f9a4
1 changed files with 7 additions and 2 deletions

View File

@ -805,10 +805,15 @@ Media::Player::TrackState Player::prepareLegacyState() const {
}
crl::time Player::getCurrentReceivedTill(crl::time duration) const {
const auto forTrack = [&](const TrackState &state) {
return (state.duration > 0 && state.receivedTill == state.duration)
? std::max(state.receivedTill, duration)
: state.receivedTill;
};
const auto previous = std::max(_previousReceivedTill, crl::time(0));
const auto result = std::min(
std::max(_information.audio.state.receivedTill, previous),
std::max(_information.video.state.receivedTill, previous));
std::max(forTrack(_information.audio.state), previous),
std::max(forTrack(_information.video.state), previous));
return (result >= 0 && duration > 1 && _options.loop)
? (result % duration)
: result;