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 <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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 callback_->OnCaptureError("IPC delegate state error."); | 184 callback_->OnCaptureError("IPC delegate state error."); |
185 } | 185 } |
186 } | 186 } |
187 | 187 |
188 void AudioInputDevice::OnIPCClosed() { | 188 void AudioInputDevice::OnIPCClosed() { |
189 DCHECK(task_runner()->BelongsToCurrentThread()); | 189 DCHECK(task_runner()->BelongsToCurrentThread()); |
190 state_ = IPC_CLOSED; | 190 state_ = IPC_CLOSED; |
191 ipc_.reset(); | 191 ipc_.reset(); |
192 } | 192 } |
193 | 193 |
194 AudioInputDevice::~AudioInputDevice() {} | 194 AudioInputDevice::~AudioInputDevice() { |
| 195 #if DCHECK_IS_ON() |
| 196 // Make sure we've stopped the stream properly before destructing |this|. |
| 197 DCHECK(audio_thread_lock_.Try()); |
| 198 DCHECK_LE(state_, IDLE); |
| 199 DCHECK(!audio_thread_); |
| 200 DCHECK(!audio_callback_); |
| 201 DCHECK(!stopping_hack_); |
| 202 audio_thread_lock_.Release(); |
| 203 #endif // DCHECK_IS_ON() |
| 204 } |
195 | 205 |
196 void AudioInputDevice::StartUpOnIOThread() { | 206 void AudioInputDevice::StartUpOnIOThread() { |
197 DCHECK(task_runner()->BelongsToCurrentThread()); | 207 DCHECK(task_runner()->BelongsToCurrentThread()); |
198 | 208 |
199 // Make sure we don't call Start() more than once. | 209 // Make sure we don't call Start() more than once. |
200 if (state_ != IDLE) | 210 if (state_ != IDLE) |
201 return; | 211 return; |
202 | 212 |
203 if (session_id_ <= 0) { | 213 if (session_id_ <= 0) { |
204 DLOG(WARNING) << "Invalid session id for the input stream " << session_id_; | 214 DLOG(WARNING) << "Invalid session id for the input stream " << session_id_; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 capture_callback_->Capture( | 348 capture_callback_->Capture( |
339 audio_bus, | 349 audio_bus, |
340 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms | 350 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms |
341 buffer->params.volume, buffer->params.key_pressed); | 351 buffer->params.volume, buffer->params.key_pressed); |
342 | 352 |
343 if (++current_segment_id_ >= total_segments_) | 353 if (++current_segment_id_ >= total_segments_) |
344 current_segment_id_ = 0; | 354 current_segment_id_ = 0; |
345 } | 355 } |
346 | 356 |
347 } // namespace media | 357 } // namespace media |
OLD | NEW |