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/message_loop/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 427 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
428 int buffer_size = 0; | 428 int buffer_size = 0; |
429 std::string buffer_size_str(cmd_line->GetSwitchValueASCII( | 429 std::string buffer_size_str(cmd_line->GetSwitchValueASCII( |
430 switches::kAudioBufferSize)); | 430 switches::kAudioBufferSize)); |
431 if (base::StringToInt(buffer_size_str, &buffer_size) && buffer_size > 0) | 431 if (base::StringToInt(buffer_size_str, &buffer_size) && buffer_size > 0) |
432 return buffer_size; | 432 return buffer_size; |
433 | 433 |
434 return 0; | 434 return 0; |
435 } | 435 } |
436 | 436 |
| 437 void AudioManagerBase::FixWedgedAudio() { |
| 438 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 439 #if defined(OS_MACOSX) |
| 440 // Through trial and error, we've found that one way to restore audio after a |
| 441 // hang is to close all outstanding audio streams. Once all streams have been |
| 442 // closed, new streams appear to work correctly. |
| 443 // |
| 444 // In Chrome terms, this means we need to ask all AudioOutputDispatchers to |
| 445 // close all Open()'d streams. Once all streams across all dispatchers have |
| 446 // been closed, we ask for all previously Start()'d streams to be recreated |
| 447 // using the same AudioSourceCallback they had before. |
| 448 // |
| 449 // Since this operation takes place on the audio thread we can be sure that no |
| 450 // other state-changing stream operations will take place while the fix is in |
| 451 // progress. |
| 452 // |
| 453 // See http://crbug.com/160920 for additional details. |
| 454 for (AudioOutputDispatchers::iterator it = output_dispatchers_.begin(); |
| 455 it != output_dispatchers_.end(); ++it) { |
| 456 (*it)->dispatcher->CloseStreamsForWedgeFix(); |
| 457 } |
| 458 for (AudioOutputDispatchers::iterator it = output_dispatchers_.begin(); |
| 459 it != output_dispatchers_.end(); ++it) { |
| 460 (*it)->dispatcher->RestartStreamsForWedgeFix(); |
| 461 } |
| 462 #endif |
| 463 } |
| 464 |
437 } // namespace media | 465 } // namespace media |
OLD | NEW |