Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Unified Diff: media/capture/content/screen_capture_device_core.cc

Issue 2692393002: Tab/Desktop capture: Fix for super-old frame after resume. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/capture/content/screen_capture_device_core.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/capture/content/screen_capture_device_core.cc
diff --git a/media/capture/content/screen_capture_device_core.cc b/media/capture/content/screen_capture_device_core.cc
index 88513f08003eec8bdaa4370178466f33a4728e9a..e68982b2eb7a4dded4b37c331ec5da3f4d0900d7 100644
--- a/media/capture/content/screen_capture_device_core.cc
+++ b/media/capture/content/screen_capture_device_core.cc
@@ -69,9 +69,19 @@ void ScreenCaptureDeviceCore::AllocateAndStart(
void ScreenCaptureDeviceCore::RequestRefreshFrame() {
DCHECK(thread_checker_.CalledOnValidThread());
- if (state_ != kCapturing && state_ != kSuspended)
+ if (state_ != kCapturing)
return;
+ // Try to use the less resource-intensive "passive" refresh mechanism, unless
+ // this is the first refresh following a Resume().
+ if (force_active_refresh_once_) {
+ capture_machine_->MaybeCaptureForRefresh();
+ force_active_refresh_once_ = false;
+ return;
+ }
+
+ // Make a best-effort attempt at a passive refresh, but fall-back to an active
+ // refresh if that fails.
if (oracle_proxy_->AttemptPassiveRefresh())
return;
capture_machine_->MaybeCaptureForRefresh();
@@ -94,6 +104,7 @@ void ScreenCaptureDeviceCore::Resume() {
if (state_ != kSuspended)
return;
+ force_active_refresh_once_ = true;
TransitionStateTo(kCapturing);
capture_machine_->Resume();
@@ -129,7 +140,9 @@ void ScreenCaptureDeviceCore::CaptureStarted(bool success) {
ScreenCaptureDeviceCore::ScreenCaptureDeviceCore(
std::unique_ptr<VideoCaptureMachine> capture_machine)
- : state_(kIdle), capture_machine_(std::move(capture_machine)) {
+ : state_(kIdle),
+ capture_machine_(std::move(capture_machine)),
+ force_active_refresh_once_(false) {
DCHECK(capture_machine_.get());
}
« no previous file with comments | « media/capture/content/screen_capture_device_core.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698