0

AudioManager Init: Fix AudioService init bug at --single-process mode

Updated part of the running logic.
If it is judged that it was started in single-process mode,
it calls the CreateEmbeddedService service.

BUG=1060099

Update: Fix IsAudioServiceOutOfProcess bug. remove Illegal inclusion.
change coding style.

R=lli.kernel.kvm@gmail.com

Change-Id: I4698be5075fe0dca6630ef1263da9520f20c8fc5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2121864
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753913}
This commit is contained in:
Lei Li
2020-03-27 04:33:23 +00:00
committed by Commit Bot
parent 0650ec2415
commit d9d7df43f1
3 changed files with 23 additions and 18 deletions

@ -573,6 +573,7 @@ Lauri Oherd <lauri.oherd@gmail.com>
Lavar Askew <open.hyperion@gmail.com> Lavar Askew <open.hyperion@gmail.com>
Legend Lee <guanxian.li@intel.com> Legend Lee <guanxian.li@intel.com>
Leith Bade <leith@leithalweapon.geek.nz> Leith Bade <leith@leithalweapon.geek.nz>
Lei Li <lli.kernel.kvm@gmail.com>
Lenny Khazan <lenny.khazan@gmail.com> Lenny Khazan <lenny.khazan@gmail.com>
Leo Wolf <jclw@ymail.com> Leo Wolf <jclw@ymail.com>
Leon Han <leon.han@intel.com> Leon Han <leon.han@intel.com>

@ -63,7 +63,9 @@ base::Optional<base::TimeDelta> GetAudioServiceProcessIdleTimeout() {
} }
bool IsAudioServiceOutOfProcess() { bool IsAudioServiceOutOfProcess() {
return base::FeatureList::IsEnabled(features::kAudioServiceOutOfProcess) && return !base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSingleProcess) &&
base::FeatureList::IsEnabled(features::kAudioServiceOutOfProcess) &&
!GetContentClient()->browser()->OverridesAudioManager(); !GetContentClient()->browser()->OverridesAudioManager();
} }

@ -175,9 +175,9 @@
#endif #endif
#if defined(OS_WIN) #if defined(OS_WIN)
#include <windows.h>
#include <commctrl.h> #include <commctrl.h>
#include <shellapi.h> #include <shellapi.h>
#include <windows.h>
#include "content/browser/renderer_host/dwrite_font_lookup_table_builder_win.h" #include "content/browser/renderer_host/dwrite_font_lookup_table_builder_win.h"
#include "net/base/winsock_init.h" #include "net/base/winsock_init.h"
@ -226,8 +226,8 @@
#if defined(USE_X11) #if defined(USE_X11)
#include "gpu/config/gpu_driver_bug_workaround_type.h" #include "gpu/config/gpu_driver_bug_workaround_type.h"
#include "ui/base/x/x11_util_internal.h" // nogncheck #include "ui/base/x/x11_util_internal.h" // nogncheck
#include "ui/gfx/x/x11_connection.h" // nogncheck #include "ui/gfx/x/x11_connection.h" // nogncheck
#include "ui/gfx/x/x11_types.h" // nogncheck #include "ui/gfx/x/x11_types.h" // nogncheck
#endif #endif
#if defined(USE_NSS_CERTS) #if defined(USE_NSS_CERTS)
@ -282,8 +282,8 @@ static void GLibLogHandler(const gchar* log_domain,
static void SetUpGLibLogHandler() { static void SetUpGLibLogHandler() {
// Register GLib-handled assertions to go through our logging system. // Register GLib-handled assertions to go through our logging system.
const char* const kLogDomains[] = const char* const kLogDomains[] = {nullptr, "Gtk", "Gdk", "GLib",
{ nullptr, "Gtk", "Gdk", "GLib", "GLib-GObject" }; "GLib-GObject"};
for (size_t i = 0; i < base::size(kLogDomains); i++) { for (size_t i = 0; i < base::size(kLogDomains); i++) {
g_log_set_handler( g_log_set_handler(
kLogDomains[i], kLogDomains[i],
@ -796,11 +796,10 @@ void BrowserMainLoop::PostMainMessageLoopStart() {
} }
if (!parsed_command_line_.HasSwitch( if (!parsed_command_line_.HasSwitch(
switches::kDisableScreenOrientationLock)) { switches::kDisableScreenOrientationLock)) {
TRACE_EVENT0("startup", TRACE_EVENT0("startup",
"BrowserMainLoop::Subsystem:ScreenOrientationProvider"); "BrowserMainLoop::Subsystem:ScreenOrientationProvider");
screen_orientation_delegate_.reset( screen_orientation_delegate_.reset(new ScreenOrientationDelegateAndroid());
new ScreenOrientationDelegateAndroid());
} }
base::trace_event::TraceLog::GetInstance()->AddEnabledStateObserver( base::trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(
@ -824,8 +823,7 @@ void BrowserMainLoop::PostMainMessageLoopStart() {
int BrowserMainLoop::PreCreateThreads() { int BrowserMainLoop::PreCreateThreads() {
if (parts_) { if (parts_) {
TRACE_EVENT0("startup", TRACE_EVENT0("startup", "BrowserMainLoop::CreateThreads:PreCreateThreads");
"BrowserMainLoop::CreateThreads:PreCreateThreads");
result_code_ = parts_->PreCreateThreads(); result_code_ = parts_->PreCreateThreads();
} }
@ -1017,7 +1015,7 @@ int BrowserMainLoop::PreMainMessageLoopRun() {
if (parts_) { if (parts_) {
TRACE_EVENT0("startup", TRACE_EVENT0("startup",
"BrowserMainLoop::CreateThreads:PreMainMessageLoopRun"); "BrowserMainLoop::CreateThreads:PreMainMessageLoopRun");
parts_->PreMainMessageLoopRun(); parts_->PreMainMessageLoopRun();
} }
@ -1345,8 +1343,9 @@ int BrowserMainLoop::BrowserThreadsStarted() {
// MediaStreamManager needs the IO thread to be created. // MediaStreamManager needs the IO thread to be created.
{ {
TRACE_EVENT0("startup", TRACE_EVENT0(
"BrowserMainLoop::BrowserThreadsStarted:InitMediaStreamManager"); "startup",
"BrowserMainLoop::BrowserThreadsStarted:InitMediaStreamManager");
scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner = scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner =
audio_manager_ ? audio_manager_->GetTaskRunner() : nullptr; audio_manager_ ? audio_manager_->GetTaskRunner() : nullptr;
@ -1366,8 +1365,9 @@ int BrowserMainLoop::BrowserThreadsStarted() {
} }
{ {
TRACE_EVENT0("startup", TRACE_EVENT0(
"BrowserMainLoop::BrowserThreadsStarted:InitSpeechRecognition"); "startup",
"BrowserMainLoop::BrowserThreadsStarted:InitSpeechRecognition");
speech_recognition_manager_.reset(new SpeechRecognitionManagerImpl( speech_recognition_manager_.reset(new SpeechRecognitionManagerImpl(
audio_system_.get(), media_stream_manager_.get())); audio_system_.get(), media_stream_manager_.get()));
} }
@ -1382,7 +1382,7 @@ int BrowserMainLoop::BrowserThreadsStarted() {
{ {
TRACE_EVENT0("startup", TRACE_EVENT0("startup",
"BrowserMainLoop::BrowserThreadsStarted::SaveFileManager"); "BrowserMainLoop::BrowserThreadsStarted::SaveFileManager");
save_file_manager_ = new SaveFileManager(); save_file_manager_ = new SaveFileManager();
} }
@ -1526,7 +1526,9 @@ void BrowserMainLoop::InitializeAudio() {
// Do not initialize |audio_manager_| if running out of process. // Do not initialize |audio_manager_| if running out of process.
if (!audio_manager_ && if (!audio_manager_ &&
!base::FeatureList::IsEnabled(features::kAudioServiceOutOfProcess)) { (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kSingleProcess) ||
!base::FeatureList::IsEnabled(features::kAudioServiceOutOfProcess))) {
audio_manager_ = audio_manager_ =
media::AudioManager::Create(std::make_unique<media::AudioThreadImpl>(), media::AudioManager::Create(std::make_unique<media::AudioThreadImpl>(),
MediaInternals::GetInstance()); MediaInternals::GetInstance());