Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 AudioInputIPC* ipc, | 43 AudioInputIPC* ipc, |
| 44 const scoped_refptr<base::MessageLoopProxy>& io_loop) | 44 const scoped_refptr<base::MessageLoopProxy>& io_loop) |
| 45 : ScopedLoopObserver(io_loop), | 45 : ScopedLoopObserver(io_loop), |
| 46 callback_(NULL), | 46 callback_(NULL), |
| 47 event_handler_(NULL), | 47 event_handler_(NULL), |
| 48 ipc_(ipc), | 48 ipc_(ipc), |
| 49 stream_id_(0), | 49 stream_id_(0), |
| 50 session_id_(0), | 50 session_id_(0), |
| 51 pending_device_ready_(false), | 51 pending_device_ready_(false), |
| 52 agc_is_enabled_(false) { | 52 agc_is_enabled_(false) { |
| 53 CHECK(ipc_); | 53 CHECK(ipc_.get()); |
|
tommi (sloooow) - chröme
2012/10/17 18:40:06
.get() isn't necessary
miu
2012/10/17 20:10:44
Done.
| |
| 54 } | 54 } |
| 55 | 55 |
| 56 void AudioInputDevice::Initialize(const AudioParameters& params, | 56 void AudioInputDevice::Initialize(const AudioParameters& params, |
| 57 CaptureCallback* callback, | 57 CaptureCallback* callback, |
| 58 CaptureEventHandler* event_handler) { | 58 CaptureEventHandler* event_handler) { |
| 59 DCHECK(!callback_); | 59 DCHECK(!callback_); |
| 60 DCHECK(!event_handler_); | 60 DCHECK(!event_handler_); |
| 61 audio_parameters_ = params; | 61 audio_parameters_ = params; |
| 62 callback_ = callback; | 62 callback_ = callback; |
| 63 event_handler_ = event_handler; | 63 event_handler_ = event_handler; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 agc_is_enabled_); | 202 agc_is_enabled_); |
| 203 } | 203 } |
| 204 | 204 |
| 205 pending_device_ready_ = false; | 205 pending_device_ready_ = false; |
| 206 // Notify the client that the device has been started. | 206 // Notify the client that the device has been started. |
| 207 if (event_handler_) | 207 if (event_handler_) |
| 208 event_handler_->OnDeviceStarted(device_id); | 208 event_handler_->OnDeviceStarted(device_id); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void AudioInputDevice::OnIPCClosed() { | 211 void AudioInputDevice::OnIPCClosed() { |
| 212 ipc_ = NULL; | 212 ipc_.reset(); |
| 213 } | 213 } |
| 214 | 214 |
| 215 AudioInputDevice::~AudioInputDevice() { | 215 AudioInputDevice::~AudioInputDevice() { |
| 216 // TODO(henrika): The current design requires that the user calls | 216 // TODO(henrika): The current design requires that the user calls |
| 217 // Stop before deleting this class. | 217 // Stop before deleting this class. |
| 218 CHECK_EQ(0, stream_id_); | 218 CHECK_EQ(0, stream_id_); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void AudioInputDevice::InitializeOnIOThread() { | 221 void AudioInputDevice::InitializeOnIOThread() { |
| 222 DCHECK(message_loop()->BelongsToCurrentThread()); | 222 DCHECK(message_loop()->BelongsToCurrentThread()); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 247 DCHECK(message_loop()->BelongsToCurrentThread()); | 247 DCHECK(message_loop()->BelongsToCurrentThread()); |
| 248 if (stream_id_) | 248 if (stream_id_) |
| 249 ipc_->RecordStream(stream_id_); | 249 ipc_->RecordStream(stream_id_); |
| 250 } | 250 } |
| 251 | 251 |
| 252 void AudioInputDevice::ShutDownOnIOThread() { | 252 void AudioInputDevice::ShutDownOnIOThread() { |
| 253 DCHECK(message_loop()->BelongsToCurrentThread()); | 253 DCHECK(message_loop()->BelongsToCurrentThread()); |
| 254 // NOTE: |completion| may be NULL. | 254 // NOTE: |completion| may be NULL. |
| 255 // Make sure we don't call shutdown more than once. | 255 // Make sure we don't call shutdown more than once. |
| 256 if (stream_id_) { | 256 if (stream_id_) { |
| 257 if (ipc_) { | 257 if (ipc_.get()) { |
|
tommi (sloooow) - chröme
2012/10/17 18:40:06
ditto
miu
2012/10/17 20:10:44
Done.
| |
| 258 ipc_->CloseStream(stream_id_); | 258 ipc_->CloseStream(stream_id_); |
| 259 ipc_->RemoveDelegate(stream_id_); | 259 ipc_->RemoveDelegate(stream_id_); |
| 260 } | 260 } |
| 261 | 261 |
| 262 stream_id_ = 0; | 262 stream_id_ = 0; |
| 263 session_id_ = 0; | 263 session_id_ = 0; |
| 264 pending_device_ready_ = false; | 264 pending_device_ready_ = false; |
| 265 agc_is_enabled_ = false; | 265 agc_is_enabled_ = false; |
| 266 } | 266 } |
| 267 | 267 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 // with nominal range -1.0 -> +1.0. | 336 // with nominal range -1.0 -> +1.0. |
| 337 audio_bus_->FromInterleaved(memory, audio_bus_->frames(), bytes_per_sample); | 337 audio_bus_->FromInterleaved(memory, audio_bus_->frames(), bytes_per_sample); |
| 338 | 338 |
| 339 // Deliver captured data to the client in floating point format | 339 // Deliver captured data to the client in floating point format |
| 340 // and update the audio-delay measurement. | 340 // and update the audio-delay measurement. |
| 341 capture_callback_->Capture(audio_bus_.get(), | 341 capture_callback_->Capture(audio_bus_.get(), |
| 342 audio_delay_milliseconds, volume); | 342 audio_delay_milliseconds, volume); |
| 343 } | 343 } |
| 344 | 344 |
| 345 } // namespace media | 345 } // namespace media |
| OLD | NEW |