Index: webrtc/modules/audio_device/audio_device_buffer.h |
diff --git a/webrtc/modules/audio_device/audio_device_buffer.h b/webrtc/modules/audio_device/audio_device_buffer.h |
index 7e9f3e3eec30105a5971727002fe9b8bb39d87eb..864fb95d0a44e8e58e3dc246ff7b900b0e9cd11d 100644 |
--- a/webrtc/modules/audio_device/audio_device_buffer.h |
+++ b/webrtc/modules/audio_device/audio_device_buffer.h |
@@ -13,7 +13,9 @@ |
#include "webrtc/base/buffer.h" |
#include "webrtc/base/criticalsection.h" |
+#include "webrtc/base/race_checker.h" |
#include "webrtc/base/task_queue.h" |
+#include "webrtc/base/thread_annotations.h" |
#include "webrtc/base/thread_checker.h" |
#include "webrtc/modules/audio_device/include/audio_device.h" |
#include "webrtc/system_wrappers/include/file_wrapper.h" |
@@ -47,27 +49,27 @@ class AudioDeviceBuffer { |
void StopPlayout(); |
void StopRecording(); |
- int32_t SetRecordingSampleRate(uint32_t fsHz); |
- int32_t SetPlayoutSampleRate(uint32_t fsHz); |
+ int32_t SetRecordingSampleRate(uint32_t fsHz) LOCKS_EXCLUDED(lock_); |
+ int32_t SetPlayoutSampleRate(uint32_t fsHz) LOCKS_EXCLUDED(lock_); |
int32_t RecordingSampleRate() const; |
int32_t PlayoutSampleRate() const; |
- int32_t SetRecordingChannels(size_t channels); |
- int32_t SetPlayoutChannels(size_t channels); |
+ int32_t SetRecordingChannels(size_t channels) LOCKS_EXCLUDED(lock_); |
+ int32_t SetPlayoutChannels(size_t channels) LOCKS_EXCLUDED(lock_); |
size_t RecordingChannels() const; |
size_t PlayoutChannels() const; |
int32_t SetRecordingChannel(const AudioDeviceModule::ChannelType channel); |
int32_t RecordingChannel(AudioDeviceModule::ChannelType& channel) const; |
virtual int32_t SetRecordedBuffer(const void* audio_buffer, |
- size_t num_samples); |
+ size_t num_samples) LOCKS_EXCLUDED(lock_); |
int32_t SetCurrentMicLevel(uint32_t level); |
virtual void SetVQEData(int play_delay_ms, int rec_delay_ms, int clock_drift); |
- virtual int32_t DeliverRecordedData(); |
+ virtual int32_t DeliverRecordedData() LOCKS_EXCLUDED(lock_); |
uint32_t NewMicLevel() const; |
- virtual int32_t RequestPlayoutData(size_t num_samples); |
- virtual int32_t GetPlayoutData(void* audio_buffer); |
+ virtual int32_t RequestPlayoutData(size_t num_samples) LOCKS_EXCLUDED(lock_); |
+ virtual int32_t GetPlayoutData(void* audio_buffer) LOCKS_EXCLUDED(lock_); |
// TODO(henrika): these methods should not be used and does not contain any |
// valid implementation. Investigate the possibility to either remove them |
@@ -107,14 +109,18 @@ class AudioDeviceBuffer { |
// creates this object. |
rtc::ThreadChecker thread_checker_; |
kwiberg-webrtc
2016/11/01 15:53:50
No member variable is annotated as being protected
henrika_webrtc
2016/11/02 10:29:18
As we discussed. Will try to fix that.
|
- // Raw pointer to AudioTransport instance. Supplied to RegisterAudioCallback() |
- // and it must outlive this object. |
- AudioTransport* audio_transport_cb_; |
+ // Verifies that access to some members are serialized. |
+ rtc::RaceChecker race_checker_; |
- // TODO(henrika): given usage of thread checker, it should be possible to |
- // remove all locks in this class. |
rtc::CriticalSection lock_; |
- rtc::CriticalSection lock_cb_; |
+ |
+ // Raw pointer to AudioTransport instance. Supplied to RegisterAudioCallback() |
+ // and it must outlive this object. It is not possible to change this member |
+ // while any media is active. It is possible to start media without calling |
+ // RegisterAudioCallback() but that will lead to ignored audio callbacks in |
+ // both directions where native audio will be acive but no audio samples will |
+ // be transported. |
+ AudioTransport* audio_transport_cb_ GUARDED_BY(race_checker_); |
// Task queue used to invoke LogStats() periodically. Tasks are executed on a |
// worker thread but it does not necessarily have to be the same thread for |
@@ -128,24 +134,20 @@ class AudioDeviceBuffer { |
bool recording_; |
kwiberg-webrtc
2016/11/01 15:53:50
These are not annotated. It's usually good to make
henrika_webrtc
2016/11/02 10:29:18
Acknowledged.
|
// Sample rate in Hertz. |
- uint32_t rec_sample_rate_; |
- uint32_t play_sample_rate_; |
+ uint32_t rec_sample_rate_ GUARDED_BY(lock_); |
+ uint32_t play_sample_rate_ GUARDED_BY(lock_); |
// Number of audio channels. |
- size_t rec_channels_; |
- size_t play_channels_; |
- |
- // Number of bytes per audio sample (2 or 4). |
- size_t rec_bytes_per_sample_; |
- size_t play_bytes_per_sample_; |
+ size_t rec_channels_ GUARDED_BY(lock_); |
+ size_t play_channels_ GUARDED_BY(lock_); |
// Byte buffer used for recorded audio samples. Size can be changed |
// dynamically. |
- rtc::Buffer rec_buffer_; |
+ rtc::Buffer rec_buffer_ GUARDED_BY(race_checker_); |
// Buffer used for audio samples to be played out. Size can be changed |
// dynamically. |
- rtc::Buffer play_buffer_; |
+ rtc::Buffer play_buffer_ GUARDED_BY(race_checker_); |
// AGC parameters. |
uint32_t current_mic_level_; |