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

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: '' 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 111890)
+++ 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_);
@@ -121,6 +124,11 @@
// Store the reported audio delay locally.
input_delay_ms_ = audio_delay_milliseconds;
+ int output_delay_ms = 0;
+ {
+ base::AutoLock auto_lock(lock_);
+ 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
@@ -597,8 +605,9 @@
// webrtc::VoiceEngine assumes that it is OK to call Stop() just in case.
return 0;
}
- playing_ = !audio_output_device_->Stop();
- return (!playing_ ? 0 : -1);
+ audio_output_device_->Stop();
+ playing_ = false;
+ return 0;
}
bool WebRtcAudioDeviceImpl::Playing() const {
@@ -641,13 +650,21 @@
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;
+ }
}
- recording_ = !audio_input_device_->Stop();
- return (!recording_ ? 0 : -1);
+
+ audio_input_device_->Stop();
+
+ {
tommi (sloooow) - chröme 2011/12/05 13:41:04 nit: no need for this scope
no longer working on chromium 2011/12/09 09:48:19 Done.
+ base::AutoLock auto_lock(lock_);
+ recording_ = false;
+ }
+ return 0;
}
bool WebRtcAudioDeviceImpl::Recording() const {
@@ -888,6 +905,7 @@
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;
}

Powered by Google App Engine
This is Rietveld 408576698