From a33c9479a59a7eeaaf6522b0ecaa713a5a3b6d4c Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 29 Jun 2020 16:41:42 +0400 Subject: [PATCH] Revert pausing in processQueuedPackets. --- .../media/streaming/media_streaming_file.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/media/streaming/media_streaming_file.cpp b/Telegram/SourceFiles/media/streaming/media_streaming_file.cpp index 799be9e94f..2c693225f3 100644 --- a/Telegram/SourceFiles/media/streaming/media_streaming_file.cpp +++ b/Telegram/SourceFiles/media/streaming/media_streaming_file.cpp @@ -59,7 +59,15 @@ int File::Context::read(bytes::span buffer) { if (result == Reader::FillState::Success) { break; } else if (result == Reader::FillState::WaitingRemote) { - processQueuedPackets(SleepPolicy::Allowed); + // Perhaps for the correct sleeping in case of enough packets + // being read already we require SleepPolicy::Allowed here. + // Otherwise if we wait for the remote frequently and + // _queuedPackets never get to kMaxQueuedPackets and we don't call + // processQueuedPackets(SleepPolicy::Allowed) ever. + // + // But right now we can't simply pass SleepPolicy::Allowed here, + // it freezes because of two _semaphore.acquire one after another. + processQueuedPackets(SleepPolicy::Disallowed); _delegate->fileWaitingForData(); } _semaphore.acquire();