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

Use ready parts from loader in streaming.

This commit is contained in:
John Preston
2019-04-12 13:25:00 +04:00
parent 8704f6efd0
commit cca906d383
15 changed files with 207 additions and 86 deletions

View File

@@ -1091,14 +1091,17 @@ void Session::requestDocumentViewRepaint(
std::shared_ptr<::Media::Streaming::Reader> Session::documentStreamedReader(
not_null<DocumentData*> document,
FileOrigin origin) {
FileOrigin origin,
bool forceRemoteLoader) {
const auto i = _streamedReaders.find(document);
if (i != end(_streamedReaders)) {
if (auto result = i->second.lock()) {
return result;
if (!forceRemoteLoader || result->isRemoteLoader()) {
return result;
}
}
}
auto loader = document->createStreamingLoader(origin);
auto loader = document->createStreamingLoader(origin, forceRemoteLoader);
if (!loader) {
return nullptr;
}
@@ -1106,7 +1109,7 @@ std::shared_ptr<::Media::Streaming::Reader> Session::documentStreamedReader(
this,
std::move(loader));
if (!PruneDestroyedAndSet(_streamedReaders, document, result)) {
_streamedReaders.emplace(document, result);
_streamedReaders.emplace_or_assign(document, result);
}
return result;
}