| 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 "media/audio/audio_util.h" |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.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; |
| (...skipping 299 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 // Notify the renderer side that a device change has occurred. |
| 333 // TODO(dalecurtis): The new hardware information should be passed in instead |
| 334 // of being retrieved by every single AudioOutputController. |
| 335 handler_->OnDeviceChange( |
| 336 this, GetAudioHardwareSampleRate(), GetAudioHardwareBufferSize()); |
| 337 |
| 331 // Recreate the stream (DoCreate() will first shut down an existing stream). | 338 // Recreate the stream (DoCreate() will first shut down an existing stream). |
| 332 // Exit if we ran into an error. | 339 // Exit if we ran into an error. |
| 333 const State original_state = state_; | 340 const State original_state = state_; |
| 334 DoCreate(true); | 341 DoCreate(true); |
| 335 if (!stream_ || state_ == kError) | 342 if (!stream_ || state_ == kError) |
| 336 return; | 343 return; |
| 337 | 344 |
| 338 // Get us back to the original state or an equivalent state. | 345 // Get us back to the original state or an equivalent state. |
| 339 switch (original_state) { | 346 switch (original_state) { |
| 340 case kStarting: | 347 case kStarting: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 DCHECK(base::AtomicRefCountIsZero(&num_allowed_io_)); | 403 DCHECK(base::AtomicRefCountIsZero(&num_allowed_io_)); |
| 397 base::AtomicRefCountInc(&num_allowed_io_); | 404 base::AtomicRefCountInc(&num_allowed_io_); |
| 398 } | 405 } |
| 399 | 406 |
| 400 void AudioOutputController::DisallowEntryToOnMoreIOData() { | 407 void AudioOutputController::DisallowEntryToOnMoreIOData() { |
| 401 const bool is_zero = !base::AtomicRefCountDec(&num_allowed_io_); | 408 const bool is_zero = !base::AtomicRefCountDec(&num_allowed_io_); |
| 402 DCHECK(is_zero); | 409 DCHECK(is_zero); |
| 403 } | 410 } |
| 404 | 411 |
| 405 } // namespace media | 412 } // namespace media |
| OLD | NEW |