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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 DCHECK(message_loop()->BelongsToCurrentThread()); | 246 DCHECK(message_loop()->BelongsToCurrentThread()); |
247 if (stream_id_) | 247 if (stream_id_) |
248 ipc_->RecordStream(stream_id_); | 248 ipc_->RecordStream(stream_id_); |
249 } | 249 } |
250 | 250 |
251 void AudioInputDevice::ShutDownOnIOThread() { | 251 void AudioInputDevice::ShutDownOnIOThread() { |
252 DCHECK(message_loop()->BelongsToCurrentThread()); | 252 DCHECK(message_loop()->BelongsToCurrentThread()); |
253 // NOTE: |completion| may be NULL. | 253 // NOTE: |completion| may be NULL. |
254 // Make sure we don't call shutdown more than once. | 254 // Make sure we don't call shutdown more than once. |
255 if (stream_id_) { | 255 if (stream_id_) { |
256 ipc_->CloseStream(stream_id_); | 256 if (ipc_) { |
257 ipc_->RemoveDelegate(stream_id_); | 257 ipc_->CloseStream(stream_id_); |
| 258 ipc_->RemoveDelegate(stream_id_); |
| 259 } |
258 | 260 |
259 stream_id_ = 0; | 261 stream_id_ = 0; |
260 session_id_ = 0; | 262 session_id_ = 0; |
261 pending_device_ready_ = false; | 263 pending_device_ready_ = false; |
262 agc_is_enabled_ = false; | 264 agc_is_enabled_ = false; |
263 } | 265 } |
264 | 266 |
265 // We can run into an issue where ShutDownOnIOThread is called right after | 267 // We can run into an issue where ShutDownOnIOThread is called right after |
266 // OnStreamCreated is called in cases where Start/Stop are called before we | 268 // OnStreamCreated is called in cases where Start/Stop are called before we |
267 // get the OnStreamCreated callback. To handle that corner case, we call | 269 // get the OnStreamCreated callback. To handle that corner case, we call |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 number_of_frames); | 343 number_of_frames); |
342 } | 344 } |
343 | 345 |
344 // Deliver captured data to the client in floating point format | 346 // Deliver captured data to the client in floating point format |
345 // and update the audio-delay measurement. | 347 // and update the audio-delay measurement. |
346 capture_callback_->Capture(audio_data_, number_of_frames, | 348 capture_callback_->Capture(audio_data_, number_of_frames, |
347 audio_delay_milliseconds, volume); | 349 audio_delay_milliseconds, volume); |
348 } | 350 } |
349 | 351 |
350 } // namespace media | 352 } // namespace media |
OLD | NEW |