Source code

Revision control

Copy as Markdown

Other Tools

From: Dan Minor <dminor@mozilla.com>
Date: Tue, 31 Jul 2018 13:32:00 -0400
Subject: Bug 1376873 - OS X desktop capture fixes; r=pehrsons
---
modules/desktop_capture/mac/screen_capturer_mac.h | 7 +++++++
modules/desktop_capture/mac/screen_capturer_mac.mm | 4 +++-
modules/desktop_capture/mouse_cursor_monitor_mac.mm | 2 +-
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/modules/desktop_capture/mac/screen_capturer_mac.h b/modules/desktop_capture/mac/screen_capturer_mac.h
index 7e38b5bd08..e4a2cc2fc9 100644
--- a/modules/desktop_capture/mac/screen_capturer_mac.h
+++ b/modules/desktop_capture/mac/screen_capturer_mac.h
@@ -113,6 +113,13 @@ class ScreenCapturerMac final : public DesktopCapturer {
// Start, CaptureFrame and destructor have to called in the same thread.
SequenceChecker thread_checker_;
+
+ // Used to force CaptureFrame to update it's screen configuration
+ // and reregister event handlers. This ensure that this
+ // occurs on the ScreenCapture thread. Read and written from
+ // both the VideoCapture thread and ScreenCapture thread.
+ // Protected by desktop_config_monitor_.
+ bool update_screen_configuration_ = false;
};
} // namespace webrtc
diff --git a/modules/desktop_capture/mac/screen_capturer_mac.mm b/modules/desktop_capture/mac/screen_capturer_mac.mm
index e6746578ad..3b4edd230b 100644
--- a/modules/desktop_capture/mac/screen_capturer_mac.mm
+++ b/modules/desktop_capture/mac/screen_capturer_mac.mm
@@ -185,6 +185,7 @@ void ScreenCapturerMac::Start(Callback* callback) {
current_display_);
callback_ = callback;
+ update_screen_configuration_ = false;
// Start and operate CGDisplayStream handler all from capture thread.
if (!RegisterRefreshAndMoveHandlers()) {
RTC_LOG(LS_ERROR) << "Failed to register refresh and move handlers.";
@@ -205,7 +206,8 @@ void ScreenCapturerMac::CaptureFrame() {
}
MacDesktopConfiguration new_config = desktop_config_monitor_->desktop_configuration();
- if (!desktop_config_.Equals(new_config)) {
+ if (update_screen_configuration_ || !desktop_config_.Equals(new_config)) {
+ update_screen_configuration_ = false;
desktop_config_ = new_config;
// If the display configuraiton has changed then refresh capturer data
// structures. Occasionally, the refresh and move handlers are lost when
diff --git a/modules/desktop_capture/mouse_cursor_monitor_mac.mm b/modules/desktop_capture/mouse_cursor_monitor_mac.mm
index 3db4332cd1..512103ab5e 100644
--- a/modules/desktop_capture/mouse_cursor_monitor_mac.mm
+++ b/modules/desktop_capture/mouse_cursor_monitor_mac.mm
@@ -133,7 +133,7 @@ void MouseCursorMonitorMac::CaptureImage(float scale) {
NSSize nssize = [nsimage size]; // DIP size
// No need to caputre cursor image if it's unchanged since last capture.
- if ([[nsimage TIFFRepresentation] isEqual:[last_cursor_ TIFFRepresentation]]) return;
+ if (last_cursor_ && [[nsimage TIFFRepresentation] isEqual:[last_cursor_ TIFFRepresentation]]) return;
last_cursor_ = nsimage;
DesktopSize size(round(nssize.width * scale),