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

Unified Diff: webrtc/modules/audio_processing/echo_control_mobile_impl.h

Issue 1424663003: Lock scheme #8: Introduced the new locking scheme (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@add_threadcheckers_CL
Patch Set: Major general updates, completing the locking scheme, and increasing readability Created 5 years, 1 month 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
Index: webrtc/modules/audio_processing/echo_control_mobile_impl.h
diff --git a/webrtc/modules/audio_processing/echo_control_mobile_impl.h b/webrtc/modules/audio_processing/echo_control_mobile_impl.h
index f8e0a32b8a3cdd37df5e896be00eece6d9f8b0f8..dcdc2d9b05ceed64501668ba8572f3ef6a1c368f 100644
--- a/webrtc/modules/audio_processing/echo_control_mobile_impl.h
+++ b/webrtc/modules/audio_processing/echo_control_mobile_impl.h
@@ -1,3 +1,4 @@
+
hlundin-webrtc 2015/11/05 16:11:22 No
peah-webrtc 2015/11/06 09:54:32 Done.
/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
@@ -12,6 +13,7 @@
#define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CONTROL_MOBILE_IMPL_H_
#include "webrtc/base/scoped_ptr.h"
+#include "webrtc/base/thread_annotations.h"
hlundin-webrtc 2015/11/05 16:11:22 Not used.
peah-webrtc 2015/11/06 09:54:32 Done.
#include "webrtc/base/thread_checker.h"
#include "webrtc/common_audio/swap_queue.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
@@ -43,24 +45,31 @@ class CriticalSectionWrapper;
class EchoControlMobileImpl : public EchoControlMobile,
public ProcessingComponent {
public:
+ // Called holding both the render and capture locks.
EchoControlMobileImpl(const AudioProcessing* apm,
- CriticalSectionWrapper* crit,
+ rtc::CriticalSection* crit_render,
+ rtc::CriticalSection* crit_capture,
rtc::ThreadChecker* render_thread_checker);
- virtual ~EchoControlMobileImpl();
- int ProcessRenderAudio(const AudioBuffer* audio);
- int ProcessCaptureAudio(AudioBuffer* audio);
+ virtual ~EchoControlMobileImpl(); // Called holding both the render and
+ // capture locks.
+
+ int ProcessRenderAudio(
hlundin-webrtc 2015/11/05 16:11:22 Again, please restore the one-line definitions whe
peah-webrtc 2015/11/06 09:54:32 Done.
+ const AudioBuffer* audio); // Called holding the render lock.
+ int ProcessCaptureAudio(
+ AudioBuffer* audio); // Called holding the capture lock.
// EchoControlMobile implementation.
- bool is_enabled() const override;
- RoutingMode routing_mode() const override;
- bool is_comfort_noise_enabled() const override;
+ bool is_enabled() const override; // Aquires the capture lock.
+ RoutingMode routing_mode() const override; // Aquires the capture lock.
+ bool is_comfort_noise_enabled() const override; // Aquires the capture lock.
// ProcessingComponent implementation.
- int Initialize() override;
+ int Initialize()
+ override; // Called holding both the render and capture locks.
// Reads render side data that has been queued on the render call.
- void ReadQueuedRenderData();
+ void ReadQueuedRenderData(); // Called holding the capture lock.
private:
static const size_t kAllowedValuesOfSamplesPerFrame1 = 80;
@@ -70,24 +79,35 @@ class EchoControlMobileImpl : public EchoControlMobile,
static const size_t kMaxNumFramesToBuffer = 100;
// EchoControlMobile implementation.
- int Enable(bool enable) override;
- int set_routing_mode(RoutingMode mode) override;
- int enable_comfort_noise(bool enable) override;
- int SetEchoPath(const void* echo_path, size_t size_bytes) override;
- int GetEchoPath(void* echo_path, size_t size_bytes) const override;
+ int Enable(
+ bool enable) override; // Aquires both the render and capture locks.
+ int set_routing_mode(RoutingMode mode) override; // Aquires the capture lock.
+ int enable_comfort_noise(bool enable) override; // Aquires the capture lock.
+ int SetEchoPath(const void* echo_path, size_t size_bytes)
+ override; // Aquires both the capture and render locks.
+ int GetEchoPath(void* echo_path, size_t size_bytes)
+ const override; // Aquires the capture lock.
// ProcessingComponent implementation.
- void* CreateHandle() const override;
- int InitializeHandle(void* handle) const override;
- int ConfigureHandle(void* handle) const override;
- void DestroyHandle(void* handle) const override;
- int num_handles_required() const override;
- int GetHandleError(void* handle) const override;
-
- void AllocateRenderQueue();
+ void* CreateHandle()
+ const override; // Called holding both the render and capture locks.
+ int InitializeHandle(void* handle)
+ const override; // Called holding both the render and capture locks.
+ int ConfigureHandle(void* handle)
+ const override; // Called holding both the render and capture locks.
+ void DestroyHandle(void* handle)
+ const override; // Called holding both the render and capture locks.
+ int num_handles_required()
+ const override; // Called holding both the render and capture locks.
+ int GetHandleError(void* handle)
+ const override; // Called holding both the render and capture locks.
+
+ void
+ AllocateRenderQueue(); // Called holding both the render and capture locks.
const AudioProcessing* apm_;
- CriticalSectionWrapper* crit_;
+ rtc::CriticalSection* const crit_render_;
+ rtc::CriticalSection* const crit_capture_;
const rtc::ThreadChecker* const render_thread_checker_;
RoutingMode routing_mode_;
bool comfort_noise_enabled_;
@@ -96,8 +116,8 @@ class EchoControlMobileImpl : public EchoControlMobile,
size_t render_queue_element_max_size_;
std::vector<int16_t> render_queue_buffer_;
std::vector<int16_t> capture_queue_buffer_;
- rtc::scoped_ptr<SwapQueue<std::vector<int16_t>, AecmRenderQueueItemVerifier>>
- render_signal_queue_;
+ rtc::scoped_ptr<SwapQueue<std::vector<int16_t>, AecmRenderQueueItemVerifier> >
+ render_signal_queue_; // Lock protection not needed.
};
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698