Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1172)

Side by Side Diff: media/audio/audio_manager_base.cc

Issue 61203008: Attempt to fix audio wedges by restarting all streams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix mock. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/audio/audio_manager_base.h ('k') | media/audio/audio_output_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 411 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
412 int buffer_size = 0; 412 int buffer_size = 0;
413 std::string buffer_size_str(cmd_line->GetSwitchValueASCII( 413 std::string buffer_size_str(cmd_line->GetSwitchValueASCII(
414 switches::kAudioBufferSize)); 414 switches::kAudioBufferSize));
415 if (base::StringToInt(buffer_size_str, &buffer_size) && buffer_size > 0) 415 if (base::StringToInt(buffer_size_str, &buffer_size) && buffer_size > 0)
416 return buffer_size; 416 return buffer_size;
417 417
418 return 0; 418 return 0;
419 } 419 }
420 420
421 void AudioManagerBase::FixWedgedAudio() {
422 DCHECK(message_loop_->BelongsToCurrentThread());
423 #if defined(OS_MACOSX)
424 // Through trial and error, we've found that one way to restore audio after a
425 // hang is to close all outstanding audio streams. Once all streams have been
426 // closed, new streams appear to work correctly.
427 //
428 // In Chrome terms, this means we need to ask all AudioOutputDispatchers to
429 // close all Open()'d streams. Once all streams across all dispatchers have
430 // been closed, we ask for all previously Start()'d streams to be recreated
431 // using the same AudioSourceCallback they had before.
432 //
433 // Since this operation takes place on the audio thread we can be sure that no
434 // other state-changing stream operations will take place while the fix is in
435 // progress.
436 //
437 // See http://crbug.com/160920 for additional details.
438 for (AudioOutputDispatchers::iterator it = output_dispatchers_.begin();
439 it != output_dispatchers_.end(); ++it) {
440 (*it)->dispatcher->CloseStreamsForWedgeFix();
441 }
442 for (AudioOutputDispatchers::iterator it = output_dispatchers_.begin();
443 it != output_dispatchers_.end(); ++it) {
444 (*it)->dispatcher->RestartStreamsForWedgeFix();
445 }
446 #endif
447 }
448
421 } // namespace media 449 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_manager_base.h ('k') | media/audio/audio_output_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698