OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <windows.h> | 11 #include <windows.h> |
12 | 12 |
13 #include <memory> | 13 #include <memory> |
14 | 14 |
15 #include "webrtc/modules/desktop_capture/screen_drawer.h" | 15 #include "webrtc/modules/desktop_capture/screen_drawer.h" |
16 #include "webrtc/system_wrappers/include/sleep.h" | 16 #include "webrtc/system_wrappers/include/sleep.h" |
17 | 17 |
18 namespace webrtc { | 18 namespace webrtc { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 static constexpr TCHAR kMutexName[] = | 22 static constexpr TCHAR kMutexName[] = |
23 TEXT("Local\\ScreenDrawerWin-da834f82-8044-11e6-ac81-73dcdd1c1869"); | 23 TEXT("Local\\ScreenDrawerWin-da834f82-8044-11e6-ac81-73dcdd1c1869"); |
24 | 24 |
25 class ScreenDrawerLockWin : public ScreenDrawerLock { | 25 class ScreenDrawerLockWin : public ScreenDrawerLock { |
26 public: | 26 public: |
27 ScreenDrawerLockWin(); | 27 ScreenDrawerLockWin(); |
28 ~ScreenDrawerLockWin(); | 28 ~ScreenDrawerLockWin() override; |
29 | 29 |
30 private: | 30 private: |
31 HANDLE mutex_; | 31 HANDLE mutex_; |
32 }; | 32 }; |
33 | 33 |
34 ScreenDrawerLockWin::ScreenDrawerLockWin() { | 34 ScreenDrawerLockWin::ScreenDrawerLockWin() { |
35 while (true) { | 35 while (true) { |
36 mutex_ = CreateMutex(NULL, FALSE, kMutexName); | 36 mutex_ = CreateMutex(NULL, FALSE, kMutexName); |
37 if (GetLastError() != ERROR_ALREADY_EXISTS && mutex_ != NULL) { | 37 if (GetLastError() != ERROR_ALREADY_EXISTS && mutex_ != NULL) { |
38 break; | 38 break; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 std::unique_ptr<ScreenDrawerLock> ScreenDrawerLock::Create() { | 194 std::unique_ptr<ScreenDrawerLock> ScreenDrawerLock::Create() { |
195 return std::unique_ptr<ScreenDrawerLock>(new ScreenDrawerLockWin()); | 195 return std::unique_ptr<ScreenDrawerLock>(new ScreenDrawerLockWin()); |
196 } | 196 } |
197 | 197 |
198 // static | 198 // static |
199 std::unique_ptr<ScreenDrawer> ScreenDrawer::Create() { | 199 std::unique_ptr<ScreenDrawer> ScreenDrawer::Create() { |
200 return std::unique_ptr<ScreenDrawer>(new ScreenDrawerWin()); | 200 return std::unique_ptr<ScreenDrawer>(new ScreenDrawerWin()); |
201 } | 201 } |
202 | 202 |
203 } // namespace webrtc | 203 } // namespace webrtc |
OLD | NEW |