Chromium Code Reviews| 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> |
| 11 #include <setupapi.h> | 11 #include <setupapi.h> |
| 12 | 12 |
| 13 #include "base/bind.h" | |
| 14 #include "base/bind_helpers.h" | |
| 13 #include "base/basictypes.h" | 15 #include "base/basictypes.h" |
| 14 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 15 #include "base/file_path.h" | 17 #include "base/file_path.h" |
| 16 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/message_loop.h" | |
| 17 #include "base/path_service.h" | 20 #include "base/path_service.h" |
| 18 #include "base/process_util.h" | 21 #include "base/process_util.h" |
| 19 #include "base/string_number_conversions.h" | 22 #include "base/string_number_conversions.h" |
| 20 #include "base/string_util.h" | 23 #include "base/string_util.h" |
| 21 #include "media/audio/audio_util.h" | 24 #include "media/audio/audio_util.h" |
| 22 #include "media/audio/win/audio_low_latency_input_win.h" | 25 #include "media/audio/win/audio_low_latency_input_win.h" |
| 23 #include "media/audio/win/audio_low_latency_output_win.h" | 26 #include "media/audio/win/audio_low_latency_output_win.h" |
| 24 #include "media/audio/win/audio_manager_win.h" | 27 #include "media/audio/win/audio_manager_win.h" |
| 25 #include "media/audio/win/audio_unified_win.h" | 28 #include "media/audio/win/audio_unified_win.h" |
| 26 #include "media/audio/win/device_enumeration_win.h" | 29 #include "media/audio/win/device_enumeration_win.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 } | 119 } |
| 117 | 120 |
| 118 bool AudioManagerWin::HasAudioOutputDevices() { | 121 bool AudioManagerWin::HasAudioOutputDevices() { |
| 119 return (::waveOutGetNumDevs() != 0); | 122 return (::waveOutGetNumDevs() != 0); |
| 120 } | 123 } |
| 121 | 124 |
| 122 bool AudioManagerWin::HasAudioInputDevices() { | 125 bool AudioManagerWin::HasAudioInputDevices() { |
| 123 return (::waveInGetNumDevs() != 0); | 126 return (::waveInGetNumDevs() != 0); |
| 124 } | 127 } |
| 125 | 128 |
| 129 void AudioManagerWin::InitializeOnAudioThread() { | |
| 130 // AudioDeviceListenerWin must be initialized on a COM thread. | |
| 131 output_device_listener_.reset(new AudioDeviceListenerWin(this)); | |
| 132 } | |
| 133 | |
| 126 string16 AudioManagerWin::GetAudioInputDeviceModel() { | 134 string16 AudioManagerWin::GetAudioInputDeviceModel() { |
| 127 // Get the default audio capture device and its device interface name. | 135 // Get the default audio capture device and its device interface name. |
| 128 DWORD device_id = 0; | 136 DWORD device_id = 0; |
| 129 waveInMessage(reinterpret_cast<HWAVEIN>(WAVE_MAPPER), | 137 waveInMessage(reinterpret_cast<HWAVEIN>(WAVE_MAPPER), |
| 130 DRVM_MAPPER_PREFERRED_GET, | 138 DRVM_MAPPER_PREFERRED_GET, |
| 131 reinterpret_cast<DWORD_PTR>(&device_id), NULL); | 139 reinterpret_cast<DWORD_PTR>(&device_id), NULL); |
| 132 ULONG device_interface_name_size = 0; | 140 ULONG device_interface_name_size = 0; |
| 133 waveInMessage(reinterpret_cast<HWAVEIN>(device_id), | 141 waveInMessage(reinterpret_cast<HWAVEIN>(device_id), |
| 134 DRV_QUERYDEVICEINTERFACESIZE, | 142 DRV_QUERYDEVICEINTERFACESIZE, |
| 135 reinterpret_cast<DWORD_PTR>(&device_interface_name_size), 0); | 143 reinterpret_cast<DWORD_PTR>(&device_interface_name_size), 0); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 bits_per_sample = 16; | 346 bits_per_sample = 16; |
| 339 channel_layout = WASAPIAudioOutputStream::HardwareChannelLayout(); | 347 channel_layout = WASAPIAudioOutputStream::HardwareChannelLayout(); |
| 340 } | 348 } |
| 341 | 349 |
| 342 // TODO(dalecurtis): This should include hardware bits per channel eventually. | 350 // TODO(dalecurtis): This should include hardware bits per channel eventually. |
| 343 return AudioParameters( | 351 return AudioParameters( |
| 344 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, | 352 AudioParameters::AUDIO_PCM_LOW_LATENCY, channel_layout, |
| 345 sample_rate, bits_per_sample, GetAudioHardwareBufferSize()); | 353 sample_rate, bits_per_sample, GetAudioHardwareBufferSize()); |
| 346 } | 354 } |
| 347 | 355 |
| 356 void AudioManagerWin::OnDeviceChange() { | |
| 357 // Only fire device changes if low latency output is supported. | |
| 358 if (!media::IsWASAPISupported()) | |
|
scherkus (not reviewing)
2012/10/24 04:27:09
This is impossible because your check for the equi
DaleCurtis
2012/10/24 19:27:29
Done.
| |
| 359 return; | |
| 360 | |
| 361 GetMessageLoop()->PostTask(FROM_HERE, base::Bind( | |
| 362 &AudioManagerWin::NotifyAllOutputDeviceChangeListeners, | |
| 363 base::Unretained(this))); | |
| 364 } | |
| 365 | |
| 348 } // namespace media | 366 } // namespace media |
| OLD | NEW |