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

Unified Diff: media/audio/win/audio_manager_win.cc

Issue 144613003: Remove use of CoreAudioUtil::IsSupported() from AudioManager startup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests. Created 6 years, 11 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/win/audio_manager_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/audio/win/audio_manager_win.cc
diff --git a/media/audio/win/audio_manager_win.cc b/media/audio/win/audio_manager_win.cc
index fb689c4e66fcb4a730cf2c446effd9f06ff26f2f..ec963a702a843a420cca6d4160e60c6b5e666806 100644
--- a/media/audio/win/audio_manager_win.cc
+++ b/media/audio/win/audio_manager_win.cc
@@ -128,28 +128,25 @@ static int NumberOfWaveOutBuffers() {
}
AudioManagerWin::AudioManagerWin(AudioLogFactory* audio_log_factory)
- : AudioManagerBase(audio_log_factory) {
- if (!CoreAudioUtil::IsSupported()) {
- // Use the Wave API for device enumeration if XP or lower.
- enumeration_type_ = kWaveEnumeration;
- } else {
- // Use the MMDevice API for device enumeration if Vista or higher.
- enumeration_type_ = kMMDeviceEnumeration;
- }
-
+ : AudioManagerBase(audio_log_factory),
+ enumeration_type_(kUninitializedEnumeration) {
SetMaxOutputStreamsAllowed(kMaxOutputStreams);
+ // WARNING: This is executed on the UI loop, do not add any code here which
+ // loads libraries or attempts to call out into the OS. Instead add such code
+ // to the InitializeOnAudioThread() method below.
+
// Task must be posted last to avoid races from handing out "this" to the
// audio thread.
GetTaskRunner()->PostTask(FROM_HERE, base::Bind(
- &AudioManagerWin::CreateDeviceListener, base::Unretained(this)));
+ &AudioManagerWin::InitializeOnAudioThread, base::Unretained(this)));
}
AudioManagerWin::~AudioManagerWin() {
// It's safe to post a task here since Shutdown() will wait for all tasks to
// complete before returning.
GetTaskRunner()->PostTask(FROM_HERE, base::Bind(
- &AudioManagerWin::DestroyDeviceListener, base::Unretained(this)));
+ &AudioManagerWin::ShutdownOnAudioThread, base::Unretained(this)));
Shutdown();
}
@@ -161,19 +158,25 @@ bool AudioManagerWin::HasAudioInputDevices() {
return (::waveInGetNumDevs() != 0);
}
-void AudioManagerWin::CreateDeviceListener() {
+void AudioManagerWin::InitializeOnAudioThread() {
DCHECK(GetTaskRunner()->BelongsToCurrentThread());
- // AudioDeviceListenerWin must be initialized on a COM thread and should only
- // be used if WASAPI / Core Audio is supported.
if (CoreAudioUtil::IsSupported()) {
+ // Use the MMDevice API for device enumeration if Vista or higher.
+ enumeration_type_ = kMMDeviceEnumeration;
+
+ // AudioDeviceListenerWin must be initialized on a COM thread and should
+ // only be used if WASAPI / Core Audio is supported.
output_device_listener_.reset(new AudioDeviceListenerWin(BindToCurrentLoop(
base::Bind(&AudioManagerWin::NotifyAllOutputDeviceChangeListeners,
base::Unretained(this)))));
+ } else {
+ // Use the Wave API for device enumeration if XP or lower.
+ enumeration_type_ = kWaveEnumeration;
}
}
-void AudioManagerWin::DestroyDeviceListener() {
+void AudioManagerWin::ShutdownOnAudioThread() {
DCHECK(GetTaskRunner()->BelongsToCurrentThread());
output_device_listener_.reset();
}
« no previous file with comments | « media/audio/win/audio_manager_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698