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

Side by Side Diff: content/browser/browser_main_loop.cc

Issue 2077983003: Intiialize AudioManager and related class lazily (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix MediaSessionTest Created 4 years, 5 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
« no previous file with comments | « no previous file | content/browser/renderer_host/render_process_host_impl.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 "content/browser/browser_main_loop.h" 5 #include "content/browser/browser_main_loop.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 TracingController::GetInstance()->StopTracing( 1470 TracingController::GetInstance()->StopTracing(
1471 TracingController::CreateFileSink( 1471 TracingController::CreateFileSink(
1472 startup_trace_file_, 1472 startup_trace_file_,
1473 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); 1473 base::Bind(OnStoppedStartupTracing, startup_trace_file_)));
1474 } 1474 }
1475 1475
1476 void BrowserMainLoop::CreateAudioManager() { 1476 void BrowserMainLoop::CreateAudioManager() {
1477 DCHECK(!audio_thread_); 1477 DCHECK(!audio_thread_);
1478 DCHECK(!audio_manager_); 1478 DCHECK(!audio_manager_);
1479 1479
1480 bool use_hang_monitor = true;
1481 audio_manager_ = GetContentClient()->browser()->CreateAudioManager( 1480 audio_manager_ = GetContentClient()->browser()->CreateAudioManager(
1482 MediaInternals::GetInstance()); 1481 MediaInternals::GetInstance());
1483 if (!audio_manager_) { 1482 if (!audio_manager_) {
1484 audio_thread_.reset(new base::Thread("AudioThread")); 1483 audio_thread_.reset(new base::Thread("AudioThread"));
1485 #if defined(OS_WIN) 1484 #if defined(OS_WIN)
1486 audio_thread_->init_com_with_mta(true); 1485 audio_thread_->init_com_with_mta(true);
1487 #endif // defined(OS_WIN) 1486 #endif // defined(OS_WIN)
1488 CHECK(audio_thread_->Start()); 1487 CHECK(audio_thread_->Start());
1489 #if defined(OS_MACOSX) 1488 #if defined(OS_MACOSX)
1490 // On Mac audio task runner must belong to the main thread. 1489 // On Mac audio task runner must belong to the main thread.
1491 // See http://crbug.com/158170. 1490 // See http://crbug.com/158170.
1492 // Since the audio thread is the UI thread, a hang monitor is not
1493 // necessary or recommended.
1494 use_hang_monitor = false;
1495 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner = 1491 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner =
1496 base::ThreadTaskRunnerHandle::Get(); 1492 base::ThreadTaskRunnerHandle::Get();
1497 #else 1493 #else
1498 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner = 1494 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner =
1499 audio_thread_->task_runner(); 1495 audio_thread_->task_runner();
1500 #endif // defined(OS_MACOSX) 1496 #endif // defined(OS_MACOSX)
1501 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner = 1497 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner =
1502 audio_thread_->task_runner(); 1498 audio_thread_->task_runner();
1503 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner), 1499 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner),
1504 std::move(worker_task_runner), 1500 std::move(worker_task_runner),
1505 MediaInternals::GetInstance()); 1501 MediaInternals::GetInstance());
1506 } 1502 }
1507 CHECK(audio_manager_); 1503 CHECK(audio_manager_);
1508
1509 if (use_hang_monitor)
1510 media::AudioManager::StartHangMonitor(io_thread_->task_runner());
1511 } 1504 }
1512 1505
1513 } // namespace content 1506 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/render_process_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698