2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Keep track of fully cached media files.

This commit is contained in:
John Preston
2019-05-31 19:45:03 +03:00
parent 2255eb2c68
commit 04e3b250e7
20 changed files with 342 additions and 54 deletions

View File

@@ -60,6 +60,9 @@ int File::Context::read(bytes::span buffer) {
return -1;
}
}
sendFullInCache();
_offset += amount;
return amount;
}
@@ -244,6 +247,9 @@ void File::Context::start(crl::time position) {
}
_reader->headerDone();
if (_reader->isRemoteLoader()) {
sendFullInCache(true);
}
if (video.codec || audio.codec) {
seekToPosition(format.get(), video.codec ? video : audio, position);
}
@@ -258,6 +264,17 @@ void File::Context::start(crl::time position) {
_format = std::move(format);
}
void File::Context::sendFullInCache(bool force) {
const auto started = _fullInCache.has_value();
if (force || started) {
const auto nowFullInCache = _reader->fullInCache();
if (!started || *_fullInCache != nowFullInCache) {
_fullInCache = nowFullInCache;
_delegate->fileFullInCache(nowFullInCache);
}
}
}
void File::Context::readNextPacket() {
auto result = readPacket();
if (unroll()) {