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

Side by Side Diff: media/audio/audio_input_device.cc

Issue 2941773002: Added initial muted state to stream creation callback, to avoid races. (Closed)
Patch Set: Added mute information to DoCompleteCreation log message. Created 3 years, 6 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
« no previous file with comments | « media/audio/audio_input_device.h ('k') | media/audio/audio_input_device_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/audio_input_device.h" 5 #include "media/audio/audio_input_device.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 base::Bind(&AudioInputDevice::SetVolumeOnIOThread, this, volume)); 142 base::Bind(&AudioInputDevice::SetVolumeOnIOThread, this, volume));
143 } 143 }
144 144
145 void AudioInputDevice::SetAutomaticGainControl(bool enabled) { 145 void AudioInputDevice::SetAutomaticGainControl(bool enabled) {
146 DVLOG(1) << "SetAutomaticGainControl(enabled=" << enabled << ")"; 146 DVLOG(1) << "SetAutomaticGainControl(enabled=" << enabled << ")";
147 task_runner()->PostTask(FROM_HERE, 147 task_runner()->PostTask(FROM_HERE,
148 base::Bind(&AudioInputDevice::SetAutomaticGainControlOnIOThread, 148 base::Bind(&AudioInputDevice::SetAutomaticGainControlOnIOThread,
149 this, enabled)); 149 this, enabled));
150 } 150 }
151 151
152 void AudioInputDevice::OnStreamCreated( 152 void AudioInputDevice::OnStreamCreated(base::SharedMemoryHandle handle,
153 base::SharedMemoryHandle handle, 153 base::SyncSocket::Handle socket_handle,
154 base::SyncSocket::Handle socket_handle, 154 int length,
155 int length, 155 int total_segments,
156 int total_segments) { 156 bool initially_muted) {
157 DCHECK(task_runner()->BelongsToCurrentThread()); 157 DCHECK(task_runner()->BelongsToCurrentThread());
158 DCHECK(base::SharedMemory::IsHandleValid(handle)); 158 DCHECK(base::SharedMemory::IsHandleValid(handle));
159 #if defined(OS_WIN) 159 #if defined(OS_WIN)
160 DCHECK(socket_handle); 160 DCHECK(socket_handle);
161 #else 161 #else
162 DCHECK_GE(socket_handle, 0); 162 DCHECK_GE(socket_handle, 0);
163 #endif 163 #endif
164 DCHECK_GT(length, 0); 164 DCHECK_GT(length, 0);
165 165
166 if (state_ != CREATING_STREAM) 166 if (state_ != CREATING_STREAM)
167 return; 167 return;
168 168
169 base::AutoLock auto_lock(audio_thread_lock_); 169 base::AutoLock auto_lock(audio_thread_lock_);
170 // TODO(miu): See TODO in OnStreamCreated method for AudioOutputDevice. 170 // TODO(miu): See TODO in OnStreamCreated method for AudioOutputDevice.
171 // Interface changes need to be made; likely, after AudioInputDevice is merged 171 // Interface changes need to be made; likely, after AudioInputDevice is merged
172 // into AudioOutputDevice (http://crbug.com/179597). 172 // into AudioOutputDevice (http://crbug.com/179597).
173 if (stopping_hack_) 173 if (stopping_hack_)
174 return; 174 return;
175 175
176 DCHECK(!audio_callback_); 176 DCHECK(!audio_callback_);
177 DCHECK(!audio_thread_); 177 DCHECK(!audio_thread_);
178
179 if (initially_muted)
180 callback_->OnCaptureMuted(true);
181
178 audio_callback_.reset(new AudioInputDevice::AudioThreadCallback( 182 audio_callback_.reset(new AudioInputDevice::AudioThreadCallback(
179 audio_parameters_, handle, length, total_segments, callback_, 183 audio_parameters_, handle, length, total_segments, callback_,
180 base::BindRepeating(&AudioInputDevice::SetLastCallbackTimeToNow, this))); 184 base::BindRepeating(&AudioInputDevice::SetLastCallbackTimeToNow, this)));
181 audio_thread_.reset(new AudioDeviceThread(audio_callback_.get(), 185 audio_thread_.reset(new AudioDeviceThread(audio_callback_.get(),
182 socket_handle, "AudioInputDevice")); 186 socket_handle, "AudioInputDevice"));
183 187
184 state_ = RECORDING; 188 state_ = RECORDING;
185 ipc_->RecordStream(); 189 ipc_->RecordStream();
186 190
187 // Start detecting missing callbacks. 191 // Start detecting missing callbacks.
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 capture_callback_->Capture( 440 capture_callback_->Capture(
437 audio_bus, 441 audio_bus,
438 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms 442 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms
439 buffer->params.volume, buffer->params.key_pressed); 443 buffer->params.volume, buffer->params.key_pressed);
440 444
441 if (++current_segment_id_ >= total_segments_) 445 if (++current_segment_id_ >= total_segments_)
442 current_segment_id_ = 0; 446 current_segment_id_ = 0;
443 } 447 }
444 448
445 } // namespace media 449 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_input_device.h ('k') | media/audio/audio_input_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698