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_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/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 done->Signal(); | 359 done->Signal(); |
| 360 } | 360 } |
| 361 | 361 |
| 362 void AudioOutputController::OnDeviceChange() { | 362 void AudioOutputController::OnDeviceChange() { |
| 363 DCHECK(message_loop_->BelongsToCurrentThread()); | 363 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 364 DVLOG(1) << "Received OnDeviceChange() notification."; | 364 DVLOG(1) << "Received OnDeviceChange() notification."; |
| 365 | 365 |
| 366 // We should always have a stream by this point. | 366 // We should always have a stream by this point. |
| 367 CHECK(stream_); | 367 CHECK(stream_); |
| 368 | 368 |
| 369 // We only need to reconnect low latency streams. | |
| 370 // TODO(dalecurtis): Ideally AudioOutputController shouldn't have to make this | |
| 371 // decision, but for now it's the only object which holds the necessary pieces | |
| 372 // of information. Eventually we'll get rid of the non-low latency audio | |
| 373 // implementations and this can be dropped at that time. | |
|
scherkus (not reviewing)
2012/10/23 02:23:11
...not as long as we're shipping on XP
perhaps a
DaleCurtis
2012/10/23 03:28:20
I was considering WaveOut on XP ~= low latency. T
henrika (OOO until Aug 14)
2012/10/23 07:38:06
Can you make a few tests on a Win7 machine where y
DaleCurtis
2012/10/23 20:09:08
What are you looking to test? I was planning to ha
DaleCurtis
2012/10/24 00:09:27
I decided to do this check in the platform specifi
| |
| 374 if (params_.format() != AudioParameters::AUDIO_PCM_LOW_LATENCY) | |
| 375 return; | |
| 376 | |
| 369 // Preserve the original state and shutdown the stream. | 377 // Preserve the original state and shutdown the stream. |
| 370 State original_state = state_; | 378 State original_state = state_; |
| 371 stream_->Stop(); | 379 stream_->Stop(); |
| 372 stream_->Close(); | 380 stream_->Close(); |
| 373 stream_ = NULL; | 381 stream_ = NULL; |
| 374 | 382 |
| 375 // Recreate the stream, exit if we ran into an error. | 383 // Recreate the stream, exit if we ran into an error. |
| 376 state_ = kRecreating; | 384 state_ = kRecreating; |
| 377 DoCreate(); | 385 DoCreate(); |
| 378 if (!stream_ || state_ == kError) | 386 if (!stream_ || state_ == kError) |
| 379 return; | 387 return; |
| 380 | 388 |
| 381 // Get us back to the original state or an equivalent state. | 389 // Get us back to the original state or an equivalent state. |
| 382 switch (original_state) { | 390 switch (original_state) { |
| 383 case kStarting: | 391 case kStarting: |
| 384 case kPlaying: | 392 case kPlaying: |
| 385 DoPlay(); | 393 DoPlay(); |
| 386 return; | 394 return; |
| 387 case kCreated: | 395 case kCreated: |
| 388 case kPausedWhenStarting: | 396 case kPausedWhenStarting: |
| 389 case kPaused: | 397 case kPaused: |
| 390 // From the outside these three states are equivalent. | 398 // From the outside these three states are equivalent. |
| 391 return; | 399 return; |
| 392 default: | 400 default: |
| 393 NOTREACHED() << "Invalid original state."; | 401 NOTREACHED() << "Invalid original state."; |
| 394 } | 402 } |
| 395 } | 403 } |
| 396 | 404 |
| 397 } // namespace media | 405 } // namespace media |
| OLD | NEW |