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

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

Issue 1908423006: Allow content embedders to create AudioManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ScopedAudioManagerPtr instead of raw pointer Created 4 years, 8 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 | « chromecast/media/audio/cast_audio_manager_factory.cc ('k') | content/public/browser/DEPS » ('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 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 is_tracing_startup_for_duration_ = false; 1480 is_tracing_startup_for_duration_ = false;
1481 TracingController::GetInstance()->StopTracing( 1481 TracingController::GetInstance()->StopTracing(
1482 TracingController::CreateFileSink( 1482 TracingController::CreateFileSink(
1483 startup_trace_file_, 1483 startup_trace_file_,
1484 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); 1484 base::Bind(OnStoppedStartupTracing, startup_trace_file_)));
1485 } 1485 }
1486 1486
1487 void BrowserMainLoop::CreateAudioManager() { 1487 void BrowserMainLoop::CreateAudioManager() {
1488 DCHECK(!audio_thread_); 1488 DCHECK(!audio_thread_);
1489 DCHECK(!audio_manager_); 1489 DCHECK(!audio_manager_);
1490 // TODO(alokp): Allow content embedders to override the default 1490
1491 // task runners by defining ContentBrowserClient::GetAudioTaskRunner. 1491 bool use_hang_monitor = true;
1492 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner; 1492 audio_manager_ = GetContentClient()->browser()->CreateAudioManager(
1493 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner; 1493 MediaInternals::GetInstance());
1494 scoped_refptr<base::SingleThreadTaskRunner> monitor_task_runner; 1494 if (!audio_manager_) {
1495 audio_thread_.reset(new base::Thread("AudioThread")); 1495 audio_thread_.reset(new base::Thread("AudioThread"));
1496 #if defined(OS_WIN) 1496 #if defined(OS_WIN)
1497 audio_thread_->init_com_with_mta(true); 1497 audio_thread_->init_com_with_mta(true);
1498 #endif // defined(OS_WIN) 1498 #endif // defined(OS_WIN)
1499 CHECK(audio_thread_->Start()); 1499 CHECK(audio_thread_->Start());
1500 #if defined(OS_MACOSX) 1500 #if defined(OS_MACOSX)
1501 // On Mac audio task runner must belong to the main thread. 1501 // On Mac audio task runner must belong to the main thread.
1502 // See http://crbug.com/158170. 1502 // See http://crbug.com/158170.
1503 // Since the audio thread is the UI thread, a hang monitor is not 1503 // Since the audio thread is the UI thread, a hang monitor is not
1504 // necessary or recommended. 1504 // necessary or recommended.
1505 audio_task_runner = base::ThreadTaskRunnerHandle::Get(); 1505 use_hang_monitor = false;
1506 worker_task_runner = audio_thread_->task_runner(); 1506 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner =
1507 base::ThreadTaskRunnerHandle::Get();
1507 #else 1508 #else
1508 audio_task_runner = audio_thread_->task_runner(); 1509 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner =
1509 worker_task_runner = audio_thread_->task_runner(); 1510 audio_thread_->task_runner();
1510 monitor_task_runner = io_thread_->task_runner();
1511 #endif // defined(OS_MACOSX) 1511 #endif // defined(OS_MACOSX)
1512 audio_manager_ = media::AudioManager::Create( 1512 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner =
1513 std::move(audio_task_runner), std::move(worker_task_runner), 1513 audio_thread_->task_runner();
1514 std::move(monitor_task_runner), MediaInternals::GetInstance()); 1514 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner),
1515 std::move(worker_task_runner),
1516 MediaInternals::GetInstance());
1517 }
1518 CHECK(audio_manager_);
1519
1520 if (use_hang_monitor)
1521 media::AudioManager::StartHangMonitor(io_thread_->task_runner());
1515 } 1522 }
1516 1523
1517 } // namespace content 1524 } // namespace content
OLDNEW
« no previous file with comments | « chromecast/media/audio/cast_audio_manager_factory.cc ('k') | content/public/browser/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698