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

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

Issue 1011683002: Lazily initialize MessageLoop for faster thread startup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months 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
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/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // CoreAudio calls must occur on the main thread of the process, which in our 88 // CoreAudio calls must occur on the main thread of the process, which in our
89 // case is sadly the browser UI thread. Failure to execute calls on the right 89 // case is sadly the browser UI thread. Failure to execute calls on the right
90 // thread leads to crashes and odd behavior. See http://crbug.com/158170. 90 // thread leads to crashes and odd behavior. See http://crbug.com/158170.
91 // TODO(dalecurtis): We should require the message loop to be passed in. 91 // TODO(dalecurtis): We should require the message loop to be passed in.
92 if (base::MessageLoopForUI::IsCurrent()) { 92 if (base::MessageLoopForUI::IsCurrent()) {
93 task_runner_ = base::MessageLoopProxy::current(); 93 task_runner_ = base::MessageLoopProxy::current();
94 return; 94 return;
95 } 95 }
96 #endif 96 #endif
97 97
98 #if defined(OS_WIN)
99 // We check COM initializer status right after calling this, so wait here
DaleCurtis 2015/03/18 22:04:28 Ah dang, I was hoping this one would be one we cou
kinuko 2015/03/19 03:08:16 I haven't taken a deeper look but I guess we can p
kinuko 2015/03/19 03:08:16 I guess we can probably fix this but with some ref
100 // until we finish audio thread initialization (where we also run COM
101 // initializer).
102 CHECK(audio_thread_.StartAndWait());
103 #else
98 CHECK(audio_thread_.Start()); 104 CHECK(audio_thread_.Start());
105 #endif
99 task_runner_ = audio_thread_.message_loop_proxy(); 106 task_runner_ = audio_thread_.message_loop_proxy();
100 } 107 }
101 108
102 AudioManagerBase::~AudioManagerBase() { 109 AudioManagerBase::~AudioManagerBase() {
103 // The platform specific AudioManager implementation must have already 110 // The platform specific AudioManager implementation must have already
104 // stopped the audio thread. Otherwise, we may destroy audio streams before 111 // stopped the audio thread. Otherwise, we may destroy audio streams before
105 // stopping the thread, resulting an unexpected behavior. 112 // stopping the thread, resulting an unexpected behavior.
106 // This way we make sure activities of the audio streams are all stopped 113 // This way we make sure activities of the audio streams are all stopped
107 // before we destroy them. 114 // before we destroy them.
108 CHECK(!audio_thread_.IsRunning()); 115 CHECK(!audio_thread_.IsRunning());
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 scoped_ptr<AudioLog> AudioManagerBase::CreateAudioLog( 405 scoped_ptr<AudioLog> AudioManagerBase::CreateAudioLog(
399 AudioLogFactory::AudioComponent component) { 406 AudioLogFactory::AudioComponent component) {
400 return audio_log_factory_->CreateAudioLog(component); 407 return audio_log_factory_->CreateAudioLog(component);
401 } 408 }
402 409
403 void AudioManagerBase::SetHasKeyboardMic() { 410 void AudioManagerBase::SetHasKeyboardMic() {
404 NOTREACHED(); 411 NOTREACHED();
405 } 412 }
406 413
407 } // namespace media 414 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698