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_output_controller.h" | 5 #include "media/audio/audio_output_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "media/audio/audio_util.h" |
13 #include "media/audio/shared_memory_util.h" | 14 #include "media/audio/shared_memory_util.h" |
14 | 15 |
15 using base::Time; | 16 using base::Time; |
16 using base::TimeDelta; | 17 using base::TimeDelta; |
17 | 18 |
18 namespace media { | 19 namespace media { |
19 | 20 |
20 // Polling-related constants. | 21 // Polling-related constants. |
21 const int AudioOutputController::kPollNumAttempts = 3; | 22 const int AudioOutputController::kPollNumAttempts = 3; |
22 const int AudioOutputController::kPollPauseInMilliseconds = 3; | 23 const int AudioOutputController::kPollPauseInMilliseconds = 3; |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 diverting_to_stream_ = NULL; | 322 diverting_to_stream_ = NULL; |
322 stream_ = NULL; | 323 stream_ = NULL; |
323 } | 324 } |
324 | 325 |
325 state_ = kEmpty; | 326 state_ = kEmpty; |
326 } | 327 } |
327 | 328 |
328 void AudioOutputController::OnDeviceChange() { | 329 void AudioOutputController::OnDeviceChange() { |
329 DCHECK(message_loop_->BelongsToCurrentThread()); | 330 DCHECK(message_loop_->BelongsToCurrentThread()); |
330 | 331 |
| 332 // TODO(dalecurtis): Notify the renderer side that a device change has |
| 333 // occurred. Currently querying the hardware information here will lead to |
| 334 // crashes on OSX. See http://crbug.com/158170. |
| 335 |
331 // Recreate the stream (DoCreate() will first shut down an existing stream). | 336 // Recreate the stream (DoCreate() will first shut down an existing stream). |
332 // Exit if we ran into an error. | 337 // Exit if we ran into an error. |
333 const State original_state = state_; | 338 const State original_state = state_; |
334 DoCreate(true); | 339 DoCreate(true); |
335 if (!stream_ || state_ == kError) | 340 if (!stream_ || state_ == kError) |
336 return; | 341 return; |
337 | 342 |
338 // Get us back to the original state or an equivalent state. | 343 // Get us back to the original state or an equivalent state. |
339 switch (original_state) { | 344 switch (original_state) { |
340 case kStarting: | 345 case kStarting: |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 DCHECK(base::AtomicRefCountIsZero(&num_allowed_io_)); | 401 DCHECK(base::AtomicRefCountIsZero(&num_allowed_io_)); |
397 base::AtomicRefCountInc(&num_allowed_io_); | 402 base::AtomicRefCountInc(&num_allowed_io_); |
398 } | 403 } |
399 | 404 |
400 void AudioOutputController::DisallowEntryToOnMoreIOData() { | 405 void AudioOutputController::DisallowEntryToOnMoreIOData() { |
401 const bool is_zero = !base::AtomicRefCountDec(&num_allowed_io_); | 406 const bool is_zero = !base::AtomicRefCountDec(&num_allowed_io_); |
402 DCHECK(is_zero); | 407 DCHECK(is_zero); |
403 } | 408 } |
404 | 409 |
405 } // namespace media | 410 } // namespace media |
OLD | NEW |