blob: 5c4953a16ee3e0cc2e1b2ec5db66fc777e843721 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
changeset: 560838:7a5a1784b5d1
tag: tip
parent: 560835:7184fb5a42fb
user: Martin Stransky <stransky@redhat.com>
date: Fri Nov 27 17:29:07 2020 +0100
files: third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.h
description:
Bug 1678680 [PipeWire] Lock current_frame_ access as it can be used from multiple threads, r?dminor
Differential Revision: https://phabricator.services.mozilla.com/D98080
diff --git a/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc b/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc
--- a/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc
+++ b/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.cc
@@ -396,16 +396,17 @@ void BaseCapturerPipeWire::HandleBuffer(
DesktopSize video_size_prev = video_size_;
if (video_metadata_use_) {
video_size_ = DesktopSize(video_metadata->region.size.width,
video_metadata->region.size.height);
} else {
video_size_ = desktop_size_;
}
+ rtc::CritScope lock(¤t_frame_lock_);
if (!current_frame_ ||
(video_metadata_use_ && !video_size_.equals(video_size_prev))) {
current_frame_ =
std::make_unique<uint8_t[]>
(video_size_.width() * video_size_.height() * kBytesPerPixel);
}
const int32_t dstStride = video_size_.width() * kBytesPerPixel;
@@ -872,16 +873,17 @@ void BaseCapturerPipeWire::Start(Callbac
}
void BaseCapturerPipeWire::CaptureFrame() {
if (portal_init_failed_) {
callback_->OnCaptureResult(Result::ERROR_PERMANENT, nullptr);
return;
}
+ rtc::CritScope lock(¤t_frame_lock_);
if (!current_frame_) {
callback_->OnCaptureResult(Result::ERROR_TEMPORARY, nullptr);
return;
}
DesktopSize frame_size = desktop_size_;
if (video_metadata_use_) {
frame_size = video_size_;
diff --git a/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.h b/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.h
--- a/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.h
+++ b/third_party/libwebrtc/webrtc/modules/desktop_capture/linux/base_capturer_pipewire.h
@@ -79,16 +79,17 @@ class BaseCapturerPipeWire : public Desk
guint sources_request_signal_id_ = 0;
guint start_request_signal_id_ = 0;
bool video_metadata_use_ = false;
DesktopSize video_size_;
DesktopSize desktop_size_ = {};
DesktopCaptureOptions options_ = {};
+ rtc::CriticalSection current_frame_lock_;
std::unique_ptr<uint8_t[]> current_frame_;
Callback* callback_ = nullptr;
bool portal_init_failed_ = false;
void InitPortal();
void InitPipeWire();
|