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

Side by Side Diff: webrtc/voice_engine/monitor_module.cc

Issue 1607353002: Swap use of CriticalSectionWrapper with rtc::CriticalSection in voice_engine/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 "webrtc/system_wrappers/include/critical_section_wrapper.h"
12 #include "webrtc/system_wrappers/include/tick_util.h" 11 #include "webrtc/system_wrappers/include/tick_util.h"
13 #include "webrtc/voice_engine/monitor_module.h" 12 #include "webrtc/voice_engine/monitor_module.h"
14 13
15 namespace webrtc { 14 namespace webrtc {
16 15
17 namespace voe { 16 namespace voe {
18 17
19 MonitorModule::MonitorModule() : 18 MonitorModule::MonitorModule() :
20 _observerPtr(NULL), 19 _observerPtr(NULL),
21 _callbackCritSect(*CriticalSectionWrapper::CreateCriticalSection()),
22 _lastProcessTime(TickTime::MillisecondTimestamp()) 20 _lastProcessTime(TickTime::MillisecondTimestamp())
23 { 21 {
24 } 22 }
25 23
26 MonitorModule::~MonitorModule() 24 MonitorModule::~MonitorModule()
27 { 25 {
28 delete &_callbackCritSect;
29 } 26 }
30 27
31 int32_t 28 int32_t
32 MonitorModule::RegisterObserver(MonitorObserver& observer) 29 MonitorModule::RegisterObserver(MonitorObserver& observer)
33 { 30 {
34 CriticalSectionScoped lock(&_callbackCritSect); 31 rtc::CritScope lock(&_callbackCritSect);
35 if (_observerPtr) 32 if (_observerPtr)
36 { 33 {
37 return -1; 34 return -1;
38 } 35 }
39 _observerPtr = &observer; 36 _observerPtr = &observer;
40 return 0; 37 return 0;
41 } 38 }
42 39
43 int32_t 40 int32_t
44 MonitorModule::DeRegisterObserver() 41 MonitorModule::DeRegisterObserver()
45 { 42 {
46 CriticalSectionScoped lock(&_callbackCritSect); 43 rtc::CritScope lock(&_callbackCritSect);
47 if (!_observerPtr) 44 if (!_observerPtr)
48 { 45 {
49 return 0; 46 return 0;
50 } 47 }
51 _observerPtr = NULL; 48 _observerPtr = NULL;
52 return 0; 49 return 0;
53 } 50 }
54 51
55 int64_t 52 int64_t
56 MonitorModule::TimeUntilNextProcess() 53 MonitorModule::TimeUntilNextProcess()
57 { 54 {
58 int64_t now = TickTime::MillisecondTimestamp(); 55 int64_t now = TickTime::MillisecondTimestamp();
59 const int64_t kAverageProcessUpdateTimeMs = 1000; 56 const int64_t kAverageProcessUpdateTimeMs = 1000;
60 return kAverageProcessUpdateTimeMs - (now - _lastProcessTime); 57 return kAverageProcessUpdateTimeMs - (now - _lastProcessTime);
61 } 58 }
62 59
63 int32_t 60 int32_t
64 MonitorModule::Process() 61 MonitorModule::Process()
65 { 62 {
66 _lastProcessTime = TickTime::MillisecondTimestamp(); 63 _lastProcessTime = TickTime::MillisecondTimestamp();
67 if (_observerPtr) 64 if (_observerPtr)
68 { 65 {
69 CriticalSectionScoped lock(&_callbackCritSect); 66 rtc::CritScope lock(&_callbackCritSect);
70 _observerPtr->OnPeriodicProcess(); 67 _observerPtr->OnPeriodicProcess();
71 } 68 }
72 return 0; 69 return 0;
73 } 70 }
74 71
75 } // namespace voe 72 } // namespace voe
76 73
77 } // namespace webrtc 74 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698