OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 29 matching lines...) Expand all Loading... |
40 const int kWinMaxChannels = 8; | 40 const int kWinMaxChannels = 8; |
41 | 41 |
42 const int kWinMaxInputChannels = 2; | 42 const int kWinMaxInputChannels = 2; |
43 // We use 3 buffers for recording audio so that if a recording callback takes | 43 // We use 3 buffers for recording audio so that if a recording callback takes |
44 // some time to return we won't lose audio. More buffers while recording are | 44 // some time to return we won't lose audio. More buffers while recording are |
45 // ok because they don't introduce any delay in recording, unlike in playback | 45 // ok because they don't introduce any delay in recording, unlike in playback |
46 // where you first need to fill in that number of buffers before starting to | 46 // where you first need to fill in that number of buffers before starting to |
47 // play. | 47 // play. |
48 const int kNumInputBuffers = 3; | 48 const int kNumInputBuffers = 3; |
49 | 49 |
| 50 int GetVersionPartAsInt(DWORDLONG num) { |
| 51 return static_cast<int>(num & 0xffff); |
| 52 } |
| 53 |
50 // Returns a string containing the given device's description and installed | 54 // Returns a string containing the given device's description and installed |
51 // driver version. | 55 // driver version. |
52 string16 GetDeviceAndDriverInfo(HDEVINFO device_info, | 56 string16 GetDeviceAndDriverInfo(HDEVINFO device_info, |
53 SP_DEVINFO_DATA* device_data) { | 57 SP_DEVINFO_DATA* device_data) { |
54 // Save the old install params setting and set a flag for the | 58 // Save the old install params setting and set a flag for the |
55 // SetupDiBuildDriverInfoList below to return only the installed drivers. | 59 // SetupDiBuildDriverInfoList below to return only the installed drivers. |
56 SP_DEVINSTALL_PARAMS old_device_install_params; | 60 SP_DEVINSTALL_PARAMS old_device_install_params; |
57 old_device_install_params.cbSize = sizeof(old_device_install_params); | 61 old_device_install_params.cbSize = sizeof(old_device_install_params); |
58 SetupDiGetDeviceInstallParams(device_info, device_data, | 62 SetupDiGetDeviceInstallParams(device_info, device_data, |
59 &old_device_install_params); | 63 &old_device_install_params); |
60 SP_DEVINSTALL_PARAMS device_install_params = old_device_install_params; | 64 SP_DEVINSTALL_PARAMS device_install_params = old_device_install_params; |
61 device_install_params.FlagsEx |= DI_FLAGSEX_INSTALLEDDRIVER; | 65 device_install_params.FlagsEx |= DI_FLAGSEX_INSTALLEDDRIVER; |
62 SetupDiSetDeviceInstallParams(device_info, device_data, | 66 SetupDiSetDeviceInstallParams(device_info, device_data, |
63 &device_install_params); | 67 &device_install_params); |
64 | 68 |
65 SP_DRVINFO_DATA driver_data; | 69 SP_DRVINFO_DATA driver_data; |
66 driver_data.cbSize = sizeof(driver_data); | 70 driver_data.cbSize = sizeof(driver_data); |
67 string16 device_and_driver_info; | 71 string16 device_and_driver_info; |
68 if (SetupDiBuildDriverInfoList(device_info, device_data, | 72 if (SetupDiBuildDriverInfoList(device_info, device_data, |
69 SPDIT_COMPATDRIVER)) { | 73 SPDIT_COMPATDRIVER)) { |
70 if (SetupDiEnumDriverInfo(device_info, device_data, SPDIT_COMPATDRIVER, 0, | 74 if (SetupDiEnumDriverInfo(device_info, device_data, SPDIT_COMPATDRIVER, 0, |
71 &driver_data)) { | 75 &driver_data)) { |
72 DWORDLONG version = driver_data.DriverVersion; | 76 DWORDLONG version = driver_data.DriverVersion; |
73 device_and_driver_info = string16(driver_data.Description) + L" v" + | 77 device_and_driver_info = string16(driver_data.Description) + L" v" + |
74 base::IntToString16((version >> 48) & 0xffff) + L"." + | 78 base::IntToString16(GetVersionPartAsInt((version >> 48))) + L"." + |
75 base::IntToString16((version >> 32) & 0xffff) + L"." + | 79 base::IntToString16(GetVersionPartAsInt((version >> 32))) + L"." + |
76 base::IntToString16((version >> 16) & 0xffff) + L"." + | 80 base::IntToString16(GetVersionPartAsInt((version >> 16))) + L"." + |
77 base::IntToString16(version & 0xffff); | 81 base::IntToString16(GetVersionPartAsInt(version)); |
78 } | 82 } |
79 SetupDiDestroyDriverInfoList(device_info, device_data, SPDIT_COMPATDRIVER); | 83 SetupDiDestroyDriverInfoList(device_info, device_data, SPDIT_COMPATDRIVER); |
80 } | 84 } |
81 | 85 |
82 SetupDiSetDeviceInstallParams(device_info, device_data, | 86 SetupDiSetDeviceInstallParams(device_info, device_data, |
83 &old_device_install_params); | 87 &old_device_install_params); |
84 | 88 |
85 return device_and_driver_info; | 89 return device_and_driver_info; |
86 } | 90 } |
87 | 91 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 return GetDeviceAndDriverInfo(device_info, &device_data); | 209 return GetDeviceAndDriverInfo(device_info, &device_data); |
206 } | 210 } |
207 | 211 |
208 return string16(); | 212 return string16(); |
209 } | 213 } |
210 | 214 |
211 // static | 215 // static |
212 AudioManager* AudioManager::CreateAudioManager() { | 216 AudioManager* AudioManager::CreateAudioManager() { |
213 return new AudioManagerWin(); | 217 return new AudioManagerWin(); |
214 } | 218 } |
OLD | NEW |