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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| 166 |
165 // AudioDeviceListenerWin must be initialized on a COM thread and should only | 167 // AudioDeviceListenerWin must be initialized on a COM thread and should only |
166 // be used if WASAPI / Core Audio is supported. | 168 // be used if WASAPI / Core Audio is supported. |
167 if (CoreAudioUtil::IsSupported()) { | 169 if (CoreAudioUtil::IsSupported()) { |
168 output_device_listener_.reset(new AudioDeviceListenerWin(BindToLoop( | 170 output_device_listener_.reset(new AudioDeviceListenerWin(BindToCurrentLoop( |
169 GetTaskRunner(), base::Bind( | 171 base::Bind(&AudioManagerWin::NotifyAllOutputDeviceChangeListeners, |
170 &AudioManagerWin::NotifyAllOutputDeviceChangeListeners, | 172 base::Unretained(this))))); |
171 base::Unretained(this))))); | |
172 } | 173 } |
173 } | 174 } |
174 | 175 |
175 void AudioManagerWin::DestroyDeviceListener() { | 176 void AudioManagerWin::DestroyDeviceListener() { |
| 177 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
176 output_device_listener_.reset(); | 178 output_device_listener_.reset(); |
177 } | 179 } |
178 | 180 |
179 base::string16 AudioManagerWin::GetAudioInputDeviceModel() { | 181 base::string16 AudioManagerWin::GetAudioInputDeviceModel() { |
180 // Get the default audio capture device and its device interface name. | 182 // Get the default audio capture device and its device interface name. |
181 DWORD device_id = 0; | 183 DWORD device_id = 0; |
182 waveInMessage(reinterpret_cast<HWAVEIN>(WAVE_MAPPER), | 184 waveInMessage(reinterpret_cast<HWAVEIN>(WAVE_MAPPER), |
183 DRVM_MAPPER_PREFERRED_GET, | 185 DRVM_MAPPER_PREFERRED_GET, |
184 reinterpret_cast<DWORD_PTR>(&device_id), NULL); | 186 reinterpret_cast<DWORD_PTR>(&device_id), NULL); |
185 ULONG device_interface_name_size = 0; | 187 ULONG device_interface_name_size = 0; |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, | 525 return new PCMWaveInAudioInputStream(this, params, kNumInputBuffers, |
524 xp_device_id); | 526 xp_device_id); |
525 } | 527 } |
526 | 528 |
527 /// static | 529 /// static |
528 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { | 530 AudioManager* CreateAudioManager(AudioLogFactory* audio_log_factory) { |
529 return new AudioManagerWin(audio_log_factory); | 531 return new AudioManagerWin(audio_log_factory); |
530 } | 532 } |
531 | 533 |
532 } // namespace media | 534 } // namespace media |
OLD | NEW |