OLD | NEW |
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 "media/audio/audio_io.h" | 5 #include "media/audio/audio_io.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <objbase.h> // This has to be before initguid.h | 8 #include <objbase.h> // This has to be before initguid.h |
9 #include <initguid.h> | 9 #include <initguid.h> |
10 #include <mmsystem.h> | 10 #include <mmsystem.h> |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 enumeration_type_ = kWaveEnumeration; | 134 enumeration_type_ = kWaveEnumeration; |
135 } else { | 135 } else { |
136 // Use the MMDevice API for device enumeration if Vista or higher. | 136 // Use the MMDevice API for device enumeration if Vista or higher. |
137 enumeration_type_ = kMMDeviceEnumeration; | 137 enumeration_type_ = kMMDeviceEnumeration; |
138 } | 138 } |
139 | 139 |
140 SetMaxOutputStreamsAllowed(kMaxOutputStreams); | 140 SetMaxOutputStreamsAllowed(kMaxOutputStreams); |
141 | 141 |
142 // Task must be posted last to avoid races from handing out "this" to the | 142 // Task must be posted last to avoid races from handing out "this" to the |
143 // audio thread. | 143 // audio thread. |
144 GetMessageLoop()->PostTask(FROM_HERE, base::Bind( | 144 GetTaskRunner()->PostTask(FROM_HERE, base::Bind( |
145 &AudioManagerWin::CreateDeviceListener, base::Unretained(this))); | 145 &AudioManagerWin::CreateDeviceListener, base::Unretained(this))); |
146 } | 146 } |
147 | 147 |
148 AudioManagerWin::~AudioManagerWin() { | 148 AudioManagerWin::~AudioManagerWin() { |
149 // It's safe to post a task here since Shutdown() will wait for all tasks to | 149 // It's safe to post a task here since Shutdown() will wait for all tasks to |
150 // complete before returning. | 150 // complete before returning. |
151 GetMessageLoop()->PostTask(FROM_HERE, base::Bind( | 151 GetTaskRunner()->PostTask(FROM_HERE, base::Bind( |
152 &AudioManagerWin::DestroyDeviceListener, base::Unretained(this))); | 152 &AudioManagerWin::DestroyDeviceListener, base::Unretained(this))); |
153 Shutdown(); | 153 Shutdown(); |
154 } | 154 } |
155 | 155 |
156 bool AudioManagerWin::HasAudioOutputDevices() { | 156 bool AudioManagerWin::HasAudioOutputDevices() { |
157 return (::waveOutGetNumDevs() != 0); | 157 return (::waveOutGetNumDevs() != 0); |
158 } | 158 } |
159 | 159 |
160 bool AudioManagerWin::HasAudioInputDevices() { | 160 bool AudioManagerWin::HasAudioInputDevices() { |
161 return (::waveInGetNumDevs() != 0); | 161 return (::waveInGetNumDevs() != 0); |
162 } | 162 } |
163 | 163 |
164 void AudioManagerWin::CreateDeviceListener() { | 164 void AudioManagerWin::CreateDeviceListener() { |
165 // AudioDeviceListenerWin must be initialized on a COM thread and should only | 165 // AudioDeviceListenerWin must be initialized on a COM thread and should only |
166 // be used if WASAPI / Core Audio is supported. | 166 // be used if WASAPI / Core Audio is supported. |
167 if (CoreAudioUtil::IsSupported()) { | 167 if (CoreAudioUtil::IsSupported()) { |
168 output_device_listener_.reset(new AudioDeviceListenerWin(BindToLoop( | 168 output_device_listener_.reset(new AudioDeviceListenerWin(BindToLoop( |
169 GetMessageLoop(), base::Bind( | 169 GetTaskRunner(), base::Bind( |
170 &AudioManagerWin::NotifyAllOutputDeviceChangeListeners, | 170 &AudioManagerWin::NotifyAllOutputDeviceChangeListeners, |
171 base::Unretained(this))))); | 171 base::Unretained(this))))); |
172 } | 172 } |
173 } | 173 } |
174 | 174 |
175 void AudioManagerWin::DestroyDeviceListener() { | 175 void AudioManagerWin::DestroyDeviceListener() { |
176 output_device_listener_.reset(); | 176 output_device_listener_.reset(); |
177 } | 177 } |
178 | 178 |
179 base::string16 AudioManagerWin::GetAudioInputDeviceModel() { | 179 base::string16 AudioManagerWin::GetAudioInputDeviceModel() { |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | 523 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
524 xp_device_id); | 524 xp_device_id); |
525 } | 525 } |
526 | 526 |
527 /// static | 527 /// static |
528 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { | 528 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { |
529 return new AudioManagerWin(audio_log_factory); | 529 return new AudioManagerWin(audio_log_factory); |
530 } | 530 } |
531 | 531 |
532 } // namespace media | 532 } // namespace media |
OLD | NEW |