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

Unified Diff: media/audio/pulse/audio_manager_pulse.cc

Issue 1806313003: Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments from patch 48 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/pulse/audio_manager_pulse.h ('k') | media/audio/sounds/audio_stream_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/pulse/audio_manager_pulse.cc
diff --git a/media/audio/pulse/audio_manager_pulse.cc b/media/audio/pulse/audio_manager_pulse.cc
index d6e9543183a0f86c8130b1459f8cd6a65e54ef2d..b96728c73c4cbb41f6dbf6ef1052d57405e5a75e 100644
--- a/media/audio/pulse/audio_manager_pulse.cc
+++ b/media/audio/pulse/audio_manager_pulse.cc
@@ -47,18 +47,13 @@ static const base::FilePath::CharType kPulseLib[] =
FILE_PATH_LITERAL("libpulse.so.0");
#endif
-// static
-AudioManager* AudioManagerPulse::Create(AudioLogFactory* audio_log_factory) {
- scoped_ptr<AudioManagerPulse> ret(new AudioManagerPulse(audio_log_factory));
- if (ret->Init())
- return ret.release();
-
- DVLOG(1) << "PulseAudio is not available on the OS";
- return NULL;
-}
-
-AudioManagerPulse::AudioManagerPulse(AudioLogFactory* audio_log_factory)
- : AudioManagerBase(audio_log_factory),
+AudioManagerPulse::AudioManagerPulse(
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner,
+ AudioLogFactory* audio_log_factory)
+ : AudioManagerBase(std::move(task_runner),
+ std::move(worker_task_runner),
+ audio_log_factory),
input_mainloop_(NULL),
input_context_(NULL),
devices_(NULL),
@@ -68,12 +63,20 @@ AudioManagerPulse::AudioManagerPulse(AudioLogFactory* audio_log_factory)
AudioManagerPulse::~AudioManagerPulse() {
Shutdown();
-
// The Pulse objects are the last things to be destroyed since Shutdown()
// needs them.
DestroyPulse();
}
+bool AudioManagerPulse::Init() {
+ // TODO(alokp): Investigate if InitPulse can happen on the audio thread.
+ // It currently needs to happen on the main thread so that is InitPulse fails,
+ // we can fallback to ALSA implementation. Initializing it on audio thread
+ // would unblock the main thread and make InitPulse consistent with
+ // DestroyPulse which happens on the audio thread.
+ return InitPulse();
+}
+
// Implementation of AudioManager.
bool AudioManagerPulse::HasAudioOutputDevices() {
AudioDeviceNames devices;
@@ -217,7 +220,7 @@ int AudioManagerPulse::GetNativeSampleRate() {
return native_input_sample_rate_;
}
-bool AudioManagerPulse::Init() {
+bool AudioManagerPulse::InitPulse() {
DCHECK(!input_mainloop_);
#if defined(DLOPEN_PULSEAUDIO)
« no previous file with comments | « media/audio/pulse/audio_manager_pulse.h ('k') | media/audio/sounds/audio_stream_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698