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

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

Issue 2582533002: Simplify AudioInputRendererHost IPC interface. (Closed)
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « media/audio/audio_input_device.h ('k') | media/audio/audio_input_ipc.h » ('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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 DCHECK(!audio_thread_); 148 DCHECK(!audio_thread_);
149 audio_callback_.reset(new AudioInputDevice::AudioThreadCallback( 149 audio_callback_.reset(new AudioInputDevice::AudioThreadCallback(
150 audio_parameters_, handle, length, total_segments, callback_)); 150 audio_parameters_, handle, length, total_segments, callback_));
151 audio_thread_.reset(new AudioDeviceThread(audio_callback_.get(), 151 audio_thread_.reset(new AudioDeviceThread(audio_callback_.get(),
152 socket_handle, "AudioInputDevice")); 152 socket_handle, "AudioInputDevice"));
153 153
154 state_ = RECORDING; 154 state_ = RECORDING;
155 ipc_->RecordStream(); 155 ipc_->RecordStream();
156 } 156 }
157 157
158 void AudioInputDevice::OnVolume(double volume) { 158 void AudioInputDevice::OnError() {
159 NOTIMPLEMENTED();
160 }
161
162 void AudioInputDevice::OnStateChanged(
163 AudioInputIPCDelegateState state) {
164 DCHECK(task_runner()->BelongsToCurrentThread()); 159 DCHECK(task_runner()->BelongsToCurrentThread());
165 160
166 // Do nothing if the stream has been closed. 161 // Do nothing if the stream has been closed.
167 if (state_ < CREATING_STREAM) 162 if (state_ < CREATING_STREAM)
168 return; 163 return;
169 164
170 // TODO(miu): Clean-up inconsistent and incomplete handling here. 165 DLOG(WARNING) << "AudioInputDevice::OnError()";
171 // http://crbug.com/180640 166 // Don't dereference the callback object if the audio thread
172 switch (state) { 167 // is stopped or stopping. That could mean that the callback
173 case AUDIO_INPUT_IPC_DELEGATE_STATE_STOPPED: 168 // object has been deleted.
Max Morin 2016/12/15 15:12:40 This message is handled here, but is never actuall
174 ShutDownOnIOThread(); 169 // TODO(tommi): Add an explicit contract for clearing the callback
175 break; 170 // object. Possibly require calling Initialize again or provide
176 case AUDIO_INPUT_IPC_DELEGATE_STATE_RECORDING: 171 // a callback object via Start() and clear it in Stop().
177 NOTIMPLEMENTED(); 172 {
178 break; 173 base::AutoLock auto_lock_(audio_thread_lock_);
179 case AUDIO_INPUT_IPC_DELEGATE_STATE_ERROR: 174 if (audio_thread_) {
180 DLOG(WARNING) << "AudioInputDevice::OnStateChanged(ERROR)"; 175 callback_->OnCaptureError(
181 // Don't dereference the callback object if the audio thread 176 "AudioInputDevice::OnError - audio thread still running");
182 // is stopped or stopping. That could mean that the callback 177 }
183 // object has been deleted.
184 // TODO(tommi): Add an explicit contract for clearing the callback
185 // object. Possibly require calling Initialize again or provide
186 // a callback object via Start() and clear it in Stop().
187 {
188 base::AutoLock auto_lock_(audio_thread_lock_);
189 if (audio_thread_) {
190 callback_->OnCaptureError(
191 "AudioInputDevice::OnStateChanged - audio thread still running");
192 }
193 } 178 }
194 break;
195 default:
196 NOTREACHED();
197 break;
198 }
199 } 179 }
200 180
201 void AudioInputDevice::OnIPCClosed() { 181 void AudioInputDevice::OnIPCClosed() {
202 DCHECK(task_runner()->BelongsToCurrentThread()); 182 DCHECK(task_runner()->BelongsToCurrentThread());
203 state_ = IPC_CLOSED; 183 state_ = IPC_CLOSED;
204 ipc_.reset(); 184 ipc_.reset();
205 } 185 }
206 186
207 AudioInputDevice::~AudioInputDevice() {} 187 AudioInputDevice::~AudioInputDevice() {}
208 188
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 capture_callback_->Capture( 325 capture_callback_->Capture(
346 audio_bus, 326 audio_bus,
347 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms 327 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms
348 buffer->params.volume, buffer->params.key_pressed); 328 buffer->params.volume, buffer->params.key_pressed);
349 329
350 if (++current_segment_id_ >= total_segments_) 330 if (++current_segment_id_ >= total_segments_)
351 current_segment_id_ = 0; 331 current_segment_id_ = 0;
352 } 332 }
353 333
354 } // namespace media 334 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_input_device.h ('k') | media/audio/audio_input_ipc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698