Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: media/audio/win/audio_manager_win.cc

Issue 8418034: Make string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 string16 AudioManagerWin::GetAudioInputDeviceModel() { 183 string16 AudioManagerWin::GetAudioInputDeviceModel() {
184 // Get the default audio capture device and its device interface name. 184 // Get the default audio capture device and its device interface name.
185 DWORD device_id = 0; 185 DWORD device_id = 0;
186 waveInMessage(reinterpret_cast<HWAVEIN>(WAVE_MAPPER), 186 waveInMessage(reinterpret_cast<HWAVEIN>(WAVE_MAPPER),
187 DRVM_MAPPER_PREFERRED_GET, 187 DRVM_MAPPER_PREFERRED_GET,
188 reinterpret_cast<DWORD_PTR>(&device_id), NULL); 188 reinterpret_cast<DWORD_PTR>(&device_id), NULL);
189 ULONG device_interface_name_size = 0; 189 ULONG device_interface_name_size = 0;
190 waveInMessage(reinterpret_cast<HWAVEIN>(device_id), 190 waveInMessage(reinterpret_cast<HWAVEIN>(device_id),
191 DRV_QUERYDEVICEINTERFACESIZE, 191 DRV_QUERYDEVICEINTERFACESIZE,
192 reinterpret_cast<DWORD_PTR>(&device_interface_name_size), 0); 192 reinterpret_cast<DWORD_PTR>(&device_interface_name_size), 0);
193 if (device_interface_name_size == 0) // No audio capture device? 193 size_t bytes_in_char16 = sizeof(string16::value_type);
194 return string16(); 194 DCHECK_EQ(0u, device_interface_name_size % bytes_in_char16);
195 if (device_interface_name_size <= bytes_in_char16)
196 return string16(); // No audio capture device.
195 197
196 string16 device_interface_name; 198 string16 device_interface_name;
197 string16::value_type* name_ptr = WriteInto(&device_interface_name, 199 string16::value_type* name_ptr = WriteInto(&device_interface_name,
198 device_interface_name_size / sizeof(string16::value_type)); 200 device_interface_name_size / bytes_in_char16);
199 waveInMessage(reinterpret_cast<HWAVEIN>(device_id), 201 waveInMessage(reinterpret_cast<HWAVEIN>(device_id),
200 DRV_QUERYDEVICEINTERFACE, 202 DRV_QUERYDEVICEINTERFACE,
201 reinterpret_cast<DWORD_PTR>(name_ptr), 203 reinterpret_cast<DWORD_PTR>(name_ptr),
202 static_cast<DWORD_PTR>(device_interface_name_size)); 204 static_cast<DWORD_PTR>(device_interface_name_size));
203 205
204 // Enumerate all audio devices and find the one matching the above device 206 // Enumerate all audio devices and find the one matching the above device
205 // interface name. 207 // interface name.
206 HDEVINFO device_info = SetupDiGetClassDevs( 208 HDEVINFO device_info = SetupDiGetClassDevs(
207 &AM_KSCATEGORY_AUDIO, 0, 0, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT); 209 &AM_KSCATEGORY_AUDIO, 0, 0, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
208 if (device_info == INVALID_HANDLE_VALUE) 210 if (device_info == INVALID_HANDLE_VALUE)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 name.device_name = AudioManagerBase::kDefaultDeviceName; 278 name.device_name = AudioManagerBase::kDefaultDeviceName;
277 name.unique_id = "0"; 279 name.unique_id = "0";
278 device_names->push_back(name); 280 device_names->push_back(name);
279 } 281 }
280 } 282 }
281 283
282 // static 284 // static
283 AudioManager* AudioManager::CreateAudioManager() { 285 AudioManager* AudioManager::CreateAudioManager() {
284 return new AudioManagerWin(); 286 return new AudioManagerWin();
285 } 287 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698