2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Improve working with cache in streaming.

This commit is contained in:
John Preston
2019-02-26 19:31:33 +04:00
parent b6a757842a
commit 44df10d6cb
3 changed files with 49 additions and 24 deletions

View File

@@ -137,6 +137,7 @@ void Player::trackReceivedTill(
}
}
static auto wakes = 0;
template <typename Track>
void Player::trackPlayedTill(
const Track &track,
@@ -152,6 +153,7 @@ void Player::trackPlayedTill(
if (_pauseReading && !bothReceivedEnough(kLoadInAdvanceFor)) {
_pauseReading = false;
_file->wake();
++wakes;
}
}
@@ -417,7 +419,8 @@ bool Player::trackReceivedEnough(
const TrackState &state,
crl::time amount) const {
return FullTrackReceived(state)
|| (state.position + amount <= state.receivedTill);
|| (state.position != kTimeUnknown
&& state.position + amount <= state.receivedTill);
}
bool Player::bothReceivedEnough(crl::time amount) const {
@@ -569,6 +572,7 @@ Player::~Player() {
//
// So instead of maintaining it in the class definition as well we
// simply call stop() here, after that the destruction is trivial.
LOG(("WAKES: %1").arg(wakes));
stop();
}