| 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_manager_base.h" | 5 #include "media/audio/audio_manager_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 return buffer_size; | 405 return buffer_size; |
| 406 | 406 |
| 407 return 0; | 407 return 0; |
| 408 } | 408 } |
| 409 | 409 |
| 410 scoped_ptr<AudioLog> AudioManagerBase::CreateAudioLog( | 410 scoped_ptr<AudioLog> AudioManagerBase::CreateAudioLog( |
| 411 AudioLogFactory::AudioComponent component) { | 411 AudioLogFactory::AudioComponent component) { |
| 412 return audio_log_factory_->CreateAudioLog(component); | 412 return audio_log_factory_->CreateAudioLog(component); |
| 413 } | 413 } |
| 414 | 414 |
| 415 void AudioManagerBase::FixWedgedAudio() { | |
| 416 DCHECK(task_runner_->BelongsToCurrentThread()); | |
| 417 #if defined(OS_MACOSX) | |
| 418 // Through trial and error, we've found that one way to restore audio after a | |
| 419 // hang is to close all outstanding audio streams. Once all streams have been | |
| 420 // closed, new streams appear to work correctly. | |
| 421 // | |
| 422 // In Chrome terms, this means we need to ask all AudioOutputDispatchers to | |
| 423 // close all Open()'d streams. Once all streams across all dispatchers have | |
| 424 // been closed, we ask for all previously Start()'d streams to be recreated | |
| 425 // using the same AudioSourceCallback they had before. | |
| 426 // | |
| 427 // Since this operation takes place on the audio thread we can be sure that no | |
| 428 // other state-changing stream operations will take place while the fix is in | |
| 429 // progress. | |
| 430 // | |
| 431 // See http://crbug.com/160920 for additional details. | |
| 432 for (AudioOutputDispatchers::iterator it = output_dispatchers_.begin(); | |
| 433 it != output_dispatchers_.end(); ++it) { | |
| 434 (*it)->dispatcher->CloseStreamsForWedgeFix(); | |
| 435 } | |
| 436 for (AudioOutputDispatchers::iterator it = output_dispatchers_.begin(); | |
| 437 it != output_dispatchers_.end(); ++it) { | |
| 438 (*it)->dispatcher->RestartStreamsForWedgeFix(); | |
| 439 } | |
| 440 #endif | |
| 441 } | |
| 442 | |
| 443 } // namespace media | 415 } // namespace media |
| OLD | NEW |