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

Unified Diff: content/renderer/media/webrtc_audio_device_impl.cc

Issue 8799011: remove the race related to output_delay_ms_ in ADM and races in the unittests. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: rebase Created 9 years 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: content/renderer/media/webrtc_audio_device_impl.cc
===================================================================
--- content/renderer/media/webrtc_audio_device_impl.cc (revision 113802)
+++ content/renderer/media/webrtc_audio_device_impl.cc (working copy)
@@ -65,8 +65,11 @@
size_t audio_delay_milliseconds) {
DCHECK_LE(number_of_frames, output_buffer_size_);
- // Store the reported audio delay locally.
- output_delay_ms_ = audio_delay_milliseconds;
+ {
+ base::AutoLock auto_lock(lock_);
+ // Store the reported audio delay locally.
+ output_delay_ms_ = audio_delay_milliseconds;
+ }
const int channels = audio_data.size();
DCHECK_LE(channels, output_channels_);
@@ -119,8 +122,13 @@
size_t audio_delay_milliseconds) {
DCHECK_LE(number_of_frames, input_buffer_size_);
- // Store the reported audio delay locally.
- input_delay_ms_ = audio_delay_milliseconds;
+ int output_delay_ms = 0;
+ {
+ base::AutoLock auto_lock(lock_);
+ // Store the reported audio delay locally.
+ input_delay_ms_ = audio_delay_milliseconds;
+ output_delay_ms = output_delay_ms_;
+ }
const int channels = audio_data.size();
DCHECK_LE(channels, input_channels_);
@@ -156,7 +164,7 @@
bytes_per_sample_,
channels,
samples_per_sec,
- input_delay_ms_ + output_delay_ms_,
+ input_delay_ms_ + output_delay_ms,
0, // clock_drift
0, // current_mic_level
new_mic_level); // not used
@@ -642,12 +650,17 @@
DVLOG(1) << "StopRecording()";
DCHECK(audio_input_device_);
- base::AutoLock auto_lock(lock_);
- if (!recording_) {
- // webrtc::VoiceEngine assumes that it is OK to call Stop() just in case.
- return 0;
+ {
+ base::AutoLock auto_lock(lock_);
+ if (!recording_) {
+ // webrtc::VoiceEngine assumes that it is OK to call Stop() just in case.
+ return 0;
+ }
}
+
audio_input_device_->Stop();
+
+ base::AutoLock auto_lock(lock_);
recording_ = false;
return 0;
}
@@ -890,12 +903,14 @@
int32_t WebRtcAudioDeviceImpl::PlayoutDelay(uint16_t* delay_ms) const {
// Report the cached output delay value.
+ base::AutoLock auto_lock(lock_);
*delay_ms = static_cast<uint16_t>(output_delay_ms_);
return 0;
}
int32_t WebRtcAudioDeviceImpl::RecordingDelay(uint16_t* delay_ms) const {
// Report the cached output delay value.
+ base::AutoLock auto_lock(lock_);
*delay_ms = static_cast<uint16_t>(input_delay_ms_);
return 0;
}
« no previous file with comments | « content/renderer/media/webrtc_audio_device_impl.h ('k') | content/renderer/media/webrtc_audio_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698