summaryrefslogtreecommitdiffstats
path: root/media/audio
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-19 19:18:00 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-19 19:18:00 +0000
commit1d8f73edc86d9f21ffd3c7d6793aa895f27640b7 (patch)
tree17dc414617756a5b4a5c76be85349664890b67d0 /media/audio
parentee432ee0a565736be395b8729bc811212fd88bf3 (diff)
downloadchromium_src-1d8f73edc86d9f21ffd3c7d6793aa895f27640b7.zip
chromium_src-1d8f73edc86d9f21ffd3c7d6793aa895f27640b7.tar.gz
chromium_src-1d8f73edc86d9f21ffd3c7d6793aa895f27640b7.tar.bz2
Fix compilation of audio_manager_win.cc in Win Release.
Also fix line endings. TBR=satish@chromium.org Review URL: http://codereview.chromium.org/5099004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66792 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio')
-rw-r--r--media/audio/win/audio_manager_win.cc178
1 files changed, 91 insertions, 87 deletions
diff --git a/media/audio/win/audio_manager_win.cc b/media/audio/win/audio_manager_win.cc
index 84dba63..4a36172 100644
--- a/media/audio/win/audio_manager_win.cc
+++ b/media/audio/win/audio_manager_win.cc
@@ -47,42 +47,46 @@ const int kWinMaxInputChannels = 2;
// play.
const int kNumInputBuffers = 3;
+int GetVersionPartAsInt(DWORDLONG num) {
+ return static_cast<int>(num & 0xffff);
+}
+
// Returns a string containing the given device's description and installed
// driver version.
string16 GetDeviceAndDriverInfo(HDEVINFO device_info,
SP_DEVINFO_DATA* device_data) {
- // Save the old install params setting and set a flag for the
- // SetupDiBuildDriverInfoList below to return only the installed drivers.
- SP_DEVINSTALL_PARAMS old_device_install_params;
- old_device_install_params.cbSize = sizeof(old_device_install_params);
- SetupDiGetDeviceInstallParams(device_info, device_data,
- &old_device_install_params);
- SP_DEVINSTALL_PARAMS device_install_params = old_device_install_params;
- device_install_params.FlagsEx |= DI_FLAGSEX_INSTALLEDDRIVER;
- SetupDiSetDeviceInstallParams(device_info, device_data,
- &device_install_params);
-
- SP_DRVINFO_DATA driver_data;
- driver_data.cbSize = sizeof(driver_data);
- string16 device_and_driver_info;
- if (SetupDiBuildDriverInfoList(device_info, device_data,
- SPDIT_COMPATDRIVER)) {
- if (SetupDiEnumDriverInfo(device_info, device_data, SPDIT_COMPATDRIVER, 0,
- &driver_data)) {
- DWORDLONG version = driver_data.DriverVersion;
- device_and_driver_info = string16(driver_data.Description) + L" v" +
- base::IntToString16((version >> 48) & 0xffff) + L"." +
- base::IntToString16((version >> 32) & 0xffff) + L"." +
- base::IntToString16((version >> 16) & 0xffff) + L"." +
- base::IntToString16(version & 0xffff);
- }
- SetupDiDestroyDriverInfoList(device_info, device_data, SPDIT_COMPATDRIVER);
- }
-
- SetupDiSetDeviceInstallParams(device_info, device_data,
- &old_device_install_params);
-
- return device_and_driver_info;
+ // Save the old install params setting and set a flag for the
+ // SetupDiBuildDriverInfoList below to return only the installed drivers.
+ SP_DEVINSTALL_PARAMS old_device_install_params;
+ old_device_install_params.cbSize = sizeof(old_device_install_params);
+ SetupDiGetDeviceInstallParams(device_info, device_data,
+ &old_device_install_params);
+ SP_DEVINSTALL_PARAMS device_install_params = old_device_install_params;
+ device_install_params.FlagsEx |= DI_FLAGSEX_INSTALLEDDRIVER;
+ SetupDiSetDeviceInstallParams(device_info, device_data,
+ &device_install_params);
+
+ SP_DRVINFO_DATA driver_data;
+ driver_data.cbSize = sizeof(driver_data);
+ string16 device_and_driver_info;
+ if (SetupDiBuildDriverInfoList(device_info, device_data,
+ SPDIT_COMPATDRIVER)) {
+ if (SetupDiEnumDriverInfo(device_info, device_data, SPDIT_COMPATDRIVER, 0,
+ &driver_data)) {
+ DWORDLONG version = driver_data.DriverVersion;
+ device_and_driver_info = string16(driver_data.Description) + L" v" +
+ base::IntToString16(GetVersionPartAsInt((version >> 48))) + L"." +
+ base::IntToString16(GetVersionPartAsInt((version >> 32))) + L"." +
+ base::IntToString16(GetVersionPartAsInt((version >> 16))) + L"." +
+ base::IntToString16(GetVersionPartAsInt(version));
+ }
+ SetupDiDestroyDriverInfoList(device_info, device_data, SPDIT_COMPATDRIVER);
+ }
+
+ SetupDiSetDeviceInstallParams(device_info, device_data,
+ &old_device_install_params);
+
+ return device_and_driver_info;
}
} // namespace
@@ -151,61 +155,61 @@ AudioManagerWin::~AudioManagerWin() {
string16 AudioManagerWin::GetAudioInputDeviceModel() {
// Get the default audio capture device and its device interface name.
- DWORD device_id = 0;
- waveInMessage(reinterpret_cast<HWAVEIN>(WAVE_MAPPER),
- DRVM_MAPPER_PREFERRED_GET,
- reinterpret_cast<DWORD_PTR>(&device_id), NULL);
- ULONG device_interface_name_size = 0;
- waveInMessage(reinterpret_cast<HWAVEIN>(device_id),
- DRV_QUERYDEVICEINTERFACESIZE,
- reinterpret_cast<DWORD_PTR>(&device_interface_name_size), 0);
- string16 device_interface_name;
- string16::value_type* name_ptr = WriteInto(&device_interface_name,
- device_interface_name_size / sizeof(string16::value_type));
- waveInMessage(reinterpret_cast<HWAVEIN>(device_id),
- DRV_QUERYDEVICEINTERFACE,
- reinterpret_cast<DWORD_PTR>(name_ptr),
- static_cast<DWORD_PTR>(device_interface_name_size));
-
- // Enumerate all audio devices and find the one matching the above device
- // interface name.
- HDEVINFO device_info = SetupDiGetClassDevs(
- &AM_KSCATEGORY_AUDIO, 0, 0, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
- if (device_info == INVALID_HANDLE_VALUE)
- return string16();
-
- DWORD interface_index = 0;
- SP_DEVICE_INTERFACE_DATA interface_data;
- interface_data.cbSize = sizeof(interface_data);
- while (SetupDiEnumDeviceInterfaces(device_info, 0, &AM_KSCATEGORY_AUDIO,
- interface_index++, &interface_data)) {
- // Query the size of the struct, allocate it and then query the data.
- SP_DEVINFO_DATA device_data;
- device_data.cbSize = sizeof(device_data);
- DWORD interface_detail_size = 0;
- SetupDiGetDeviceInterfaceDetail(device_info, &interface_data, 0, 0,
- &interface_detail_size, &device_data);
- if (!interface_detail_size)
- continue;
-
- scoped_array<char> interface_detail_buffer(new char[interface_detail_size]);
- SP_DEVICE_INTERFACE_DETAIL_DATA* interface_detail =
- reinterpret_cast<SP_DEVICE_INTERFACE_DETAIL_DATA*>(
- interface_detail_buffer.get());
- interface_detail->cbSize = interface_detail_size;
- if (!SetupDiGetDeviceInterfaceDetail(device_info, &interface_data,
- interface_detail,
- interface_detail_size, NULL,
- &device_data))
- return string16();
-
- bool device_found = (device_interface_name == interface_detail->DevicePath);
-
- if (device_found)
- return GetDeviceAndDriverInfo(device_info, &device_data);
- }
-
- return string16();
+ DWORD device_id = 0;
+ waveInMessage(reinterpret_cast<HWAVEIN>(WAVE_MAPPER),
+ DRVM_MAPPER_PREFERRED_GET,
+ reinterpret_cast<DWORD_PTR>(&device_id), NULL);
+ ULONG device_interface_name_size = 0;
+ waveInMessage(reinterpret_cast<HWAVEIN>(device_id),
+ DRV_QUERYDEVICEINTERFACESIZE,
+ reinterpret_cast<DWORD_PTR>(&device_interface_name_size), 0);
+ string16 device_interface_name;
+ string16::value_type* name_ptr = WriteInto(&device_interface_name,
+ device_interface_name_size / sizeof(string16::value_type));
+ waveInMessage(reinterpret_cast<HWAVEIN>(device_id),
+ DRV_QUERYDEVICEINTERFACE,
+ reinterpret_cast<DWORD_PTR>(name_ptr),
+ static_cast<DWORD_PTR>(device_interface_name_size));
+
+ // Enumerate all audio devices and find the one matching the above device
+ // interface name.
+ HDEVINFO device_info = SetupDiGetClassDevs(
+ &AM_KSCATEGORY_AUDIO, 0, 0, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
+ if (device_info == INVALID_HANDLE_VALUE)
+ return string16();
+
+ DWORD interface_index = 0;
+ SP_DEVICE_INTERFACE_DATA interface_data;
+ interface_data.cbSize = sizeof(interface_data);
+ while (SetupDiEnumDeviceInterfaces(device_info, 0, &AM_KSCATEGORY_AUDIO,
+ interface_index++, &interface_data)) {
+ // Query the size of the struct, allocate it and then query the data.
+ SP_DEVINFO_DATA device_data;
+ device_data.cbSize = sizeof(device_data);
+ DWORD interface_detail_size = 0;
+ SetupDiGetDeviceInterfaceDetail(device_info, &interface_data, 0, 0,
+ &interface_detail_size, &device_data);
+ if (!interface_detail_size)
+ continue;
+
+ scoped_array<char> interface_detail_buffer(new char[interface_detail_size]);
+ SP_DEVICE_INTERFACE_DETAIL_DATA* interface_detail =
+ reinterpret_cast<SP_DEVICE_INTERFACE_DETAIL_DATA*>(
+ interface_detail_buffer.get());
+ interface_detail->cbSize = interface_detail_size;
+ if (!SetupDiGetDeviceInterfaceDetail(device_info, &interface_data,
+ interface_detail,
+ interface_detail_size, NULL,
+ &device_data))
+ return string16();
+
+ bool device_found = (device_interface_name == interface_detail->DevicePath);
+
+ if (device_found)
+ return GetDeviceAndDriverInfo(device_info, &device_data);
+ }
+
+ return string16();
}
// static