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

Side by Side Diff: webrtc/modules/audio_device/win/audio_device_wave_win.cc

Issue 2685783014: Replace NULL with nullptr in all C++ files. (Closed)
Patch Set: Fixing android. Created 3 years, 10 months 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 27 matching lines...) Expand all
38 namespace webrtc { 38 namespace webrtc {
39 39
40 // ============================================================================ 40 // ============================================================================
41 // Construction & Destruction 41 // Construction & Destruction
42 // ============================================================================ 42 // ============================================================================
43 43
44 // ---------------------------------------------------------------------------- 44 // ----------------------------------------------------------------------------
45 // AudioDeviceWindowsWave - ctor 45 // AudioDeviceWindowsWave - ctor
46 // ---------------------------------------------------------------------------- 46 // ----------------------------------------------------------------------------
47 47
48 AudioDeviceWindowsWave::AudioDeviceWindowsWave(const int32_t id) : 48 AudioDeviceWindowsWave::AudioDeviceWindowsWave(const int32_t id)
49 _ptrAudioBuffer(NULL), 49 : _ptrAudioBuffer(nullptr),
50 _critSect(*CriticalSectionWrapper::CreateCriticalSection()), 50 _critSect(*CriticalSectionWrapper::CreateCriticalSection()),
51 _timeEvent(*EventTimerWrapper::Create()), 51 _timeEvent(*EventTimerWrapper::Create()),
52 _recStartEvent(*EventWrapper::Create()), 52 _recStartEvent(*EventWrapper::Create()),
53 _playStartEvent(*EventWrapper::Create()), 53 _playStartEvent(*EventWrapper::Create()),
54 _hGetCaptureVolumeThread(NULL), 54 _hGetCaptureVolumeThread(nullptr),
55 _hShutdownGetVolumeEvent(NULL), 55 _hShutdownGetVolumeEvent(nullptr),
56 _hSetCaptureVolumeThread(NULL), 56 _hSetCaptureVolumeThread(nullptr),
57 _hShutdownSetVolumeEvent(NULL), 57 _hShutdownSetVolumeEvent(nullptr),
58 _hSetCaptureVolumeEvent(NULL), 58 _hSetCaptureVolumeEvent(nullptr),
59 _critSectCb(*CriticalSectionWrapper::CreateCriticalSection()), 59 _critSectCb(*CriticalSectionWrapper::CreateCriticalSection()),
60 _id(id), 60 _id(id),
61 _mixerManager(id), 61 _mixerManager(id),
62 _usingInputDeviceIndex(false), 62 _usingInputDeviceIndex(false),
63 _usingOutputDeviceIndex(false), 63 _usingOutputDeviceIndex(false),
64 _inputDevice(AudioDeviceModule::kDefaultDevice), 64 _inputDevice(AudioDeviceModule::kDefaultDevice),
65 _outputDevice(AudioDeviceModule::kDefaultDevice), 65 _outputDevice(AudioDeviceModule::kDefaultDevice),
66 _inputDeviceIndex(0), 66 _inputDeviceIndex(0),
67 _outputDeviceIndex(0), 67 _outputDeviceIndex(0),
68 _inputDeviceIsSpecified(false), 68 _inputDeviceIsSpecified(false),
69 _outputDeviceIsSpecified(false), 69 _outputDeviceIsSpecified(false),
70 _initialized(false), 70 _initialized(false),
71 _recIsInitialized(false), 71 _recIsInitialized(false),
72 _playIsInitialized(false), 72 _playIsInitialized(false),
73 _recording(false), 73 _recording(false),
74 _playing(false), 74 _playing(false),
75 _startRec(false), 75 _startRec(false),
76 _stopRec(false), 76 _stopRec(false),
77 _startPlay(false), 77 _startPlay(false),
78 _stopPlay(false), 78 _stopPlay(false),
79 _AGC(false), 79 _AGC(false),
80 _hWaveIn(NULL), 80 _hWaveIn(nullptr),
81 _hWaveOut(NULL), 81 _hWaveOut(nullptr),
82 _recChannels(N_REC_CHANNELS), 82 _recChannels(N_REC_CHANNELS),
83 _playChannels(N_PLAY_CHANNELS), 83 _playChannels(N_PLAY_CHANNELS),
84 _recBufCount(0), 84 _recBufCount(0),
85 _recPutBackDelay(0), 85 _recPutBackDelay(0),
86 _recDelayCount(0), 86 _recDelayCount(0),
87 _playBufCount(0), 87 _playBufCount(0),
88 _prevPlayTime(0), 88 _prevPlayTime(0),
89 _prevRecTime(0), 89 _prevRecTime(0),
90 _prevTimerCheckTime(0), 90 _prevTimerCheckTime(0),
91 _timesdwBytes(0), 91 _timesdwBytes(0),
92 _timerFaults(0), 92 _timerFaults(0),
93 _timerRestartAttempts(0), 93 _timerRestartAttempts(0),
94 _no_of_msecleft_warnings(0), 94 _no_of_msecleft_warnings(0),
95 _MAX_minBuffer(65), 95 _MAX_minBuffer(65),
96 _useHeader(0), 96 _useHeader(0),
97 _dTcheckPlayBufDelay(10), 97 _dTcheckPlayBufDelay(10),
98 _playBufDelay(80), 98 _playBufDelay(80),
99 _playBufDelayFixed(80), 99 _playBufDelayFixed(80),
100 _minPlayBufDelay(20), 100 _minPlayBufDelay(20),
101 _avgCPULoad(0), 101 _avgCPULoad(0),
102 _sndCardPlayDelay(0), 102 _sndCardPlayDelay(0),
103 _sndCardRecDelay(0), 103 _sndCardRecDelay(0),
104 _plSampOld(0), 104 _plSampOld(0),
105 _rcSampOld(0), 105 _rcSampOld(0),
106 _playBufType(AudioDeviceModule::kAdaptiveBufferSize), 106 _playBufType(AudioDeviceModule::kAdaptiveBufferSize),
107 _recordedBytes(0), 107 _recordedBytes(0),
108 _playWarning(0), 108 _playWarning(0),
109 _playError(0), 109 _playError(0),
110 _recWarning(0), 110 _recWarning(0),
111 _recError(0), 111 _recError(0),
112 _newMicLevel(0), 112 _newMicLevel(0),
113 _minMicVolume(0), 113 _minMicVolume(0),
114 _maxMicVolume(0) 114 _maxMicVolume(0) {
115 { 115 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, "%s created", __FUNCTION__);
116 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, "%s created", __FUNCTION__ );
117 116
118 // Initialize value, set to 0 if it fails 117 // Initialize value, set to 0 if it fails
119 if (!QueryPerformanceFrequency(&_perfFreq)) 118 if (!QueryPerformanceFrequency(&_perfFreq)) {
120 { 119 _perfFreq.QuadPart = 0;
121 _perfFreq.QuadPart = 0; 120 }
122 }
123 121
124 _hShutdownGetVolumeEvent = CreateEvent(NULL, FALSE, FALSE, NULL); 122 _hShutdownGetVolumeEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
125 _hShutdownSetVolumeEvent = CreateEvent(NULL, FALSE, FALSE, NULL); 123 _hShutdownSetVolumeEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
126 _hSetCaptureVolumeEvent = CreateEvent(NULL, FALSE, FALSE, NULL); 124 _hSetCaptureVolumeEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
127 } 125 }
128 126
129 // ---------------------------------------------------------------------------- 127 // ----------------------------------------------------------------------------
130 // AudioDeviceWindowsWave - dtor 128 // AudioDeviceWindowsWave - dtor
131 // ---------------------------------------------------------------------------- 129 // ----------------------------------------------------------------------------
132 130
133 AudioDeviceWindowsWave::~AudioDeviceWindowsWave() 131 AudioDeviceWindowsWave::~AudioDeviceWindowsWave()
134 { 132 {
135 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s destroyed", __FUNCTIO N__); 133 WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, _id, "%s destroyed", __FUNCTIO N__);
136 134
137 Terminate(); 135 Terminate();
138 136
139 delete &_recStartEvent; 137 delete &_recStartEvent;
140 delete &_playStartEvent; 138 delete &_playStartEvent;
141 delete &_timeEvent; 139 delete &_timeEvent;
142 delete &_critSect; 140 delete &_critSect;
143 delete &_critSectCb; 141 delete &_critSectCb;
144 142
145 if (NULL != _hShutdownGetVolumeEvent) 143 if (nullptr != _hShutdownGetVolumeEvent) {
146 { 144 CloseHandle(_hShutdownGetVolumeEvent);
147 CloseHandle(_hShutdownGetVolumeEvent); 145 _hShutdownGetVolumeEvent = nullptr;
148 _hShutdownGetVolumeEvent = NULL;
149 } 146 }
150 147
151 if (NULL != _hShutdownSetVolumeEvent) 148 if (nullptr != _hShutdownSetVolumeEvent) {
152 { 149 CloseHandle(_hShutdownSetVolumeEvent);
153 CloseHandle(_hShutdownSetVolumeEvent); 150 _hShutdownSetVolumeEvent = nullptr;
154 _hShutdownSetVolumeEvent = NULL;
155 } 151 }
156 152
157 if (NULL != _hSetCaptureVolumeEvent) 153 if (nullptr != _hSetCaptureVolumeEvent) {
158 { 154 CloseHandle(_hSetCaptureVolumeEvent);
159 CloseHandle(_hSetCaptureVolumeEvent); 155 _hSetCaptureVolumeEvent = nullptr;
160 _hSetCaptureVolumeEvent = NULL;
161 } 156 }
162 } 157 }
163 158
164 // ============================================================================ 159 // ============================================================================
165 // API 160 // API
166 // ============================================================================ 161 // ============================================================================
167 162
168 // ---------------------------------------------------------------------------- 163 // ----------------------------------------------------------------------------
169 // AttachAudioBuffer 164 // AttachAudioBuffer
170 // ---------------------------------------------------------------------------- 165 // ----------------------------------------------------------------------------
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 if (!_timeEvent.StartTimer(periodic, TIMER_PERIOD_MS)) { 228 if (!_timeEvent.StartTimer(periodic, TIMER_PERIOD_MS)) {
234 LOG(LS_ERROR) << "failed to start the timer event"; 229 LOG(LS_ERROR) << "failed to start the timer event";
235 _ptrThread->Stop(); 230 _ptrThread->Stop();
236 _ptrThread.reset(); 231 _ptrThread.reset();
237 return InitStatus::OTHER_ERROR; 232 return InitStatus::OTHER_ERROR;
238 } 233 }
239 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, 234 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
240 "periodic timer (dT=%d) is now active", TIMER_PERIOD_MS); 235 "periodic timer (dT=%d) is now active", TIMER_PERIOD_MS);
241 236
242 _hGetCaptureVolumeThread = 237 _hGetCaptureVolumeThread =
243 CreateThread(NULL, 0, GetCaptureVolumeThread, this, 0, NULL); 238 CreateThread(nullptr, 0, GetCaptureVolumeThread, this, 0, nullptr);
244 if (_hGetCaptureVolumeThread == NULL) { 239 if (_hGetCaptureVolumeThread == nullptr) {
245 LOG(LS_ERROR) << " failed to create the volume getter thread"; 240 LOG(LS_ERROR) << " failed to create the volume getter thread";
246 return InitStatus::OTHER_ERROR; 241 return InitStatus::OTHER_ERROR;
247 } 242 }
248 243
249 SetThreadPriority(_hGetCaptureVolumeThread, THREAD_PRIORITY_NORMAL); 244 SetThreadPriority(_hGetCaptureVolumeThread, THREAD_PRIORITY_NORMAL);
250 245
251 _hSetCaptureVolumeThread = 246 _hSetCaptureVolumeThread =
252 CreateThread(NULL, 0, SetCaptureVolumeThread, this, 0, NULL); 247 CreateThread(nullptr, 0, SetCaptureVolumeThread, this, 0, nullptr);
253 if (_hSetCaptureVolumeThread == NULL) { 248 if (_hSetCaptureVolumeThread == nullptr) {
254 LOG(LS_ERROR) << " failed to create the volume setter thread"; 249 LOG(LS_ERROR) << " failed to create the volume setter thread";
255 return InitStatus::OTHER_ERROR; 250 return InitStatus::OTHER_ERROR;
256 } 251 }
257 252
258 SetThreadPriority(_hSetCaptureVolumeThread, THREAD_PRIORITY_NORMAL); 253 SetThreadPriority(_hSetCaptureVolumeThread, THREAD_PRIORITY_NORMAL);
259 254
260 _initialized = true; 255 _initialized = true;
261 256
262 return InitStatus::OK; 257 return InitStatus::OK;
263 } 258 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 _critSect.Enter(); 291 _critSect.Enter();
297 SetEvent(_hShutdownGetVolumeEvent); 292 SetEvent(_hShutdownGetVolumeEvent);
298 _critSect.Leave(); 293 _critSect.Leave();
299 int32_t ret = WaitForSingleObject(_hGetCaptureVolumeThread, 2000); 294 int32_t ret = WaitForSingleObject(_hGetCaptureVolumeThread, 2000);
300 if (ret != WAIT_OBJECT_0) 295 if (ret != WAIT_OBJECT_0)
301 { 296 {
302 // the thread did not stop as it should 297 // the thread did not stop as it should
303 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, 298 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
304 " failed to close down volume getter thread"); 299 " failed to close down volume getter thread");
305 CloseHandle(_hGetCaptureVolumeThread); 300 CloseHandle(_hGetCaptureVolumeThread);
306 _hGetCaptureVolumeThread = NULL; 301 _hGetCaptureVolumeThread = nullptr;
307 return -1; 302 return -1;
308 } 303 }
309 _critSect.Enter(); 304 _critSect.Enter();
310 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, 305 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
311 " volume getter thread is now closed"); 306 " volume getter thread is now closed");
312 307
313 SetEvent(_hShutdownSetVolumeEvent); 308 SetEvent(_hShutdownSetVolumeEvent);
314 _critSect.Leave(); 309 _critSect.Leave();
315 ret = WaitForSingleObject(_hSetCaptureVolumeThread, 2000); 310 ret = WaitForSingleObject(_hSetCaptureVolumeThread, 2000);
316 if (ret != WAIT_OBJECT_0) 311 if (ret != WAIT_OBJECT_0)
317 { 312 {
318 // the thread did not stop as it should 313 // the thread did not stop as it should
319 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, 314 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
320 " failed to close down volume setter thread"); 315 " failed to close down volume setter thread");
321 CloseHandle(_hSetCaptureVolumeThread); 316 CloseHandle(_hSetCaptureVolumeThread);
322 _hSetCaptureVolumeThread = NULL; 317 _hSetCaptureVolumeThread = nullptr;
323 return -1; 318 return -1;
324 } 319 }
325 _critSect.Enter(); 320 _critSect.Enter();
326 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, 321 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
327 " volume setter thread is now closed"); 322 " volume setter thread is now closed");
328 323
329 CloseHandle(_hGetCaptureVolumeThread); 324 CloseHandle(_hGetCaptureVolumeThread);
330 _hGetCaptureVolumeThread = NULL; 325 _hGetCaptureVolumeThread = nullptr;
331 326
332 CloseHandle(_hSetCaptureVolumeThread); 327 CloseHandle(_hSetCaptureVolumeThread);
333 _hSetCaptureVolumeThread = NULL; 328 _hSetCaptureVolumeThread = nullptr;
334 329
335 _critSect.Leave(); 330 _critSect.Leave();
336 331
337 _timeEvent.StopTimer(); 332 _timeEvent.StopTimer();
338 333
339 _initialized = false; 334 _initialized = false;
340 _outputDeviceIsSpecified = false; 335 _outputDeviceIsSpecified = false;
341 _inputDeviceIsSpecified = false; 336 _inputDeviceIsSpecified = false;
342 337
343 return 0; 338 return 0;
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 // ---------------------------------------------------------------------------- 614 // ----------------------------------------------------------------------------
620 615
621 int32_t AudioDeviceWindowsWave::SetWaveOutVolume(uint16_t volumeLeft, uint16_t v olumeRight) 616 int32_t AudioDeviceWindowsWave::SetWaveOutVolume(uint16_t volumeLeft, uint16_t v olumeRight)
622 { 617 {
623 618
624 MMRESULT res(0); 619 MMRESULT res(0);
625 WAVEOUTCAPS caps; 620 WAVEOUTCAPS caps;
626 621
627 CriticalSectionScoped lock(&_critSect); 622 CriticalSectionScoped lock(&_critSect);
628 623
629 if (_hWaveOut == NULL) 624 if (_hWaveOut == nullptr) {
630 { 625 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
631 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no open playout dev ice exists => using default"); 626 "no open playout device exists => using default");
632 } 627 }
633 628
634 // To determine whether the device supports volume control on both 629 // To determine whether the device supports volume control on both
635 // the left and right channels, use the WAVECAPS_LRVOLUME flag. 630 // the left and right channels, use the WAVECAPS_LRVOLUME flag.
636 // 631 //
637 res = waveOutGetDevCaps((UINT_PTR)_hWaveOut, &caps, sizeof(WAVEOUTCAPS)); 632 res = waveOutGetDevCaps((UINT_PTR)_hWaveOut, &caps, sizeof(WAVEOUTCAPS));
638 if (MMSYSERR_NOERROR != res) 633 if (MMSYSERR_NOERROR != res)
639 { 634 {
640 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveOutGetDevCaps() failed (err=%d)", res); 635 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveOutGetDevCaps() failed (err=%d)", res);
641 TraceWaveOutError(res); 636 TraceWaveOutError(res);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 // ---------------------------------------------------------------------------- 678 // ----------------------------------------------------------------------------
684 679
685 int32_t AudioDeviceWindowsWave::WaveOutVolume(uint16_t& volumeLeft, uint16_t& vo lumeRight) const 680 int32_t AudioDeviceWindowsWave::WaveOutVolume(uint16_t& volumeLeft, uint16_t& vo lumeRight) const
686 { 681 {
687 682
688 MMRESULT res(0); 683 MMRESULT res(0);
689 WAVEOUTCAPS caps; 684 WAVEOUTCAPS caps;
690 685
691 CriticalSectionScoped lock(&_critSect); 686 CriticalSectionScoped lock(&_critSect);
692 687
693 if (_hWaveOut == NULL) 688 if (_hWaveOut == nullptr) {
694 { 689 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
695 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no open playout dev ice exists => using default"); 690 "no open playout device exists => using default");
696 } 691 }
697 692
698 // To determine whether the device supports volume control on both 693 // To determine whether the device supports volume control on both
699 // the left and right channels, use the WAVECAPS_LRVOLUME flag. 694 // the left and right channels, use the WAVECAPS_LRVOLUME flag.
700 // 695 //
701 res = waveOutGetDevCaps((UINT_PTR)_hWaveOut, &caps, sizeof(WAVEOUTCAPS)); 696 res = waveOutGetDevCaps((UINT_PTR)_hWaveOut, &caps, sizeof(WAVEOUTCAPS));
702 if (MMSYSERR_NOERROR != res) 697 if (MMSYSERR_NOERROR != res)
703 { 698 {
704 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveOutGetDevCaps() failed (err=%d)", res); 699 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveOutGetDevCaps() failed (err=%d)", res);
705 TraceWaveOutError(res); 700 TraceWaveOutError(res);
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 1266
1272 uint16_t nDevices(PlayoutDevices()); 1267 uint16_t nDevices(PlayoutDevices());
1273 1268
1274 // Special fix for the case when the user asks for the name of the default d evice. 1269 // Special fix for the case when the user asks for the name of the default d evice.
1275 // 1270 //
1276 if (index == (uint16_t)(-1)) 1271 if (index == (uint16_t)(-1))
1277 { 1272 {
1278 index = 0; 1273 index = 0;
1279 } 1274 }
1280 1275
1281 if ((index > (nDevices-1)) || (name == NULL)) 1276 if ((index > (nDevices - 1)) || (name == nullptr)) {
1282 { 1277 return -1;
1283 return -1;
1284 } 1278 }
1285 1279
1286 memset(name, 0, kAdmMaxDeviceNameSize); 1280 memset(name, 0, kAdmMaxDeviceNameSize);
1287 1281
1288 if (guid != NULL) 1282 if (guid != nullptr) {
1289 { 1283 memset(guid, 0, kAdmMaxGuidSize);
1290 memset(guid, 0, kAdmMaxGuidSize);
1291 } 1284 }
1292 1285
1293 WAVEOUTCAPSW caps; // szPname member (product name (NULL terminated) is a WCHAR 1286 WAVEOUTCAPSW
1287 caps; // szPname member (product name (nullptr terminated) is a WCHAR
1294 MMRESULT res; 1288 MMRESULT res;
1295 1289
1296 res = waveOutGetDevCapsW(index, &caps, sizeof(WAVEOUTCAPSW)); 1290 res = waveOutGetDevCapsW(index, &caps, sizeof(WAVEOUTCAPSW));
1297 if (res != MMSYSERR_NOERROR) 1291 if (res != MMSYSERR_NOERROR)
1298 { 1292 {
1299 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveOutGetDevCapsW( ) failed (err=%d)", res); 1293 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveOutGetDevCapsW( ) failed (err=%d)", res);
1300 return -1; 1294 return -1;
1301 } 1295 }
1302 if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, name, kAdmMaxDeviceNam eSize, NULL, NULL) == 0) 1296 if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, name,
1303 { 1297 kAdmMaxDeviceNameSize, nullptr, nullptr) == 0) {
1304 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiByte(C P_UTF8) failed with error code %d - 1", GetLastError()); 1298 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
1299 "WideCharToMultiByte(CP_UTF8) failed with error code %d - 1",
1300 GetLastError());
1305 } 1301 }
1306 1302
1307 if (guid == NULL) 1303 if (guid == nullptr) {
1308 { 1304 return 0;
1309 return 0;
1310 } 1305 }
1311 1306
1312 // It is possible to get the unique endpoint ID string using the Wave API. 1307 // It is possible to get the unique endpoint ID string using the Wave API.
1313 // However, it is only supported on Windows Vista and Windows 7. 1308 // However, it is only supported on Windows Vista and Windows 7.
1314 1309
1315 size_t cbEndpointId(0); 1310 size_t cbEndpointId(0);
1316 1311
1317 // Get the size (including the terminating null) of the endpoint ID string o f the waveOut device. 1312 // Get the size (including the terminating null) of the endpoint ID string o f the waveOut device.
1318 // Windows Vista supports the DRV_QUERYFUNCTIONINSTANCEIDSIZE and DRV_QUERYF UNCTIONINSTANCEID messages. 1313 // Windows Vista supports the DRV_QUERYFUNCTIONINSTANCEIDSIZE and DRV_QUERYF UNCTIONINSTANCEID messages.
1319 res = waveOutMessage((HWAVEOUT)IntToPtr(index), 1314 res = waveOutMessage((HWAVEOUT)IntToPtr(index),
1320 DRV_QUERYFUNCTIONINSTANCEIDSIZE, 1315 DRV_QUERYFUNCTIONINSTANCEIDSIZE,
1321 (DWORD_PTR)&cbEndpointId, NULL); 1316 (DWORD_PTR)&cbEndpointId, NULL);
1322 if (res != MMSYSERR_NOERROR) 1317 if (res != MMSYSERR_NOERROR)
1323 { 1318 {
1324 // DRV_QUERYFUNCTIONINSTANCEIDSIZE is not supported <=> earlier version of Windows than Vista 1319 // DRV_QUERYFUNCTIONINSTANCEIDSIZE is not supported <=> earlier version of Windows than Vista
1325 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "waveOutMessage(DRV_QUE RYFUNCTIONINSTANCEIDSIZE) failed (err=%d)", res); 1320 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "waveOutMessage(DRV_QUE RYFUNCTIONINSTANCEIDSIZE) failed (err=%d)", res);
1326 TraceWaveOutError(res); 1321 TraceWaveOutError(res);
1327 // Best we can do is to copy the friendly name and use it as guid 1322 // Best we can do is to copy the friendly name and use it as guid
1328 if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, guid, kAdmMaxGuidS ize, NULL, NULL) == 0) 1323 if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, guid,
1329 { 1324 kAdmMaxGuidSize, nullptr, nullptr) == 0) {
1330 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiBy te(CP_UTF8) failed with error code %d - 2", GetLastError()); 1325 WEBRTC_TRACE(
1326 kTraceError, kTraceAudioDevice, _id,
1327 "WideCharToMultiByte(CP_UTF8) failed with error code %d - 2",
1328 GetLastError());
1331 } 1329 }
1332 return 0; 1330 return 0;
1333 } 1331 }
1334 1332
1335 // waveOutMessage(DRV_QUERYFUNCTIONINSTANCEIDSIZE) worked => we are on a Vis ta or Windows 7 device 1333 // waveOutMessage(DRV_QUERYFUNCTIONINSTANCEIDSIZE) worked => we are on a Vis ta or Windows 7 device
1336 1334
1337 WCHAR *pstrEndpointId = NULL; 1335 WCHAR* pstrEndpointId = nullptr;
1338 pstrEndpointId = (WCHAR*)CoTaskMemAlloc(cbEndpointId); 1336 pstrEndpointId = (WCHAR*)CoTaskMemAlloc(cbEndpointId);
1339 1337
1340 // Get the endpoint ID string for this waveOut device. 1338 // Get the endpoint ID string for this waveOut device.
1341 res = waveOutMessage((HWAVEOUT)IntToPtr(index), 1339 res = waveOutMessage((HWAVEOUT)IntToPtr(index),
1342 DRV_QUERYFUNCTIONINSTANCEID, 1340 DRV_QUERYFUNCTIONINSTANCEID,
1343 (DWORD_PTR)pstrEndpointId, 1341 (DWORD_PTR)pstrEndpointId,
1344 cbEndpointId); 1342 cbEndpointId);
1345 if (res != MMSYSERR_NOERROR) 1343 if (res != MMSYSERR_NOERROR)
1346 { 1344 {
1347 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "waveOutMessage(DRV_QUE RYFUNCTIONINSTANCEID) failed (err=%d)", res); 1345 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "waveOutMessage(DRV_QUE RYFUNCTIONINSTANCEID) failed (err=%d)", res);
1348 TraceWaveOutError(res); 1346 TraceWaveOutError(res);
1349 // Best we can do is to copy the friendly name and use it as guid 1347 // Best we can do is to copy the friendly name and use it as guid
1350 if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, guid, kAdmMaxGuidS ize, NULL, NULL) == 0) 1348 if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, guid,
1351 { 1349 kAdmMaxGuidSize, nullptr, nullptr) == 0) {
1352 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiBy te(CP_UTF8) failed with error code %d - 3", GetLastError()); 1350 WEBRTC_TRACE(
1351 kTraceError, kTraceAudioDevice, _id,
1352 "WideCharToMultiByte(CP_UTF8) failed with error code %d - 3",
1353 GetLastError());
1353 } 1354 }
1354 CoTaskMemFree(pstrEndpointId); 1355 CoTaskMemFree(pstrEndpointId);
1355 return 0; 1356 return 0;
1356 } 1357 }
1357 1358
1358 if (WideCharToMultiByte(CP_UTF8, 0, pstrEndpointId, -1, guid, kAdmMaxGuidSiz e, NULL, NULL) == 0) 1359 if (WideCharToMultiByte(CP_UTF8, 0, pstrEndpointId, -1, guid,
1359 { 1360 kAdmMaxGuidSize, nullptr, nullptr) == 0) {
1360 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiByte(C P_UTF8) failed with error code %d - 4", GetLastError()); 1361 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
1362 "WideCharToMultiByte(CP_UTF8) failed with error code %d - 4",
1363 GetLastError());
1361 } 1364 }
1362 CoTaskMemFree(pstrEndpointId); 1365 CoTaskMemFree(pstrEndpointId);
1363 1366
1364 return 0; 1367 return 0;
1365 } 1368 }
1366 1369
1367 // ---------------------------------------------------------------------------- 1370 // ----------------------------------------------------------------------------
1368 // RecordingDeviceName 1371 // RecordingDeviceName
1369 // ---------------------------------------------------------------------------- 1372 // ----------------------------------------------------------------------------
1370 1373
1371 int32_t AudioDeviceWindowsWave::RecordingDeviceName( 1374 int32_t AudioDeviceWindowsWave::RecordingDeviceName(
1372 uint16_t index, 1375 uint16_t index,
1373 char name[kAdmMaxDeviceNameSize], 1376 char name[kAdmMaxDeviceNameSize],
1374 char guid[kAdmMaxGuidSize]) 1377 char guid[kAdmMaxGuidSize])
1375 { 1378 {
1376 1379
1377 uint16_t nDevices(RecordingDevices()); 1380 uint16_t nDevices(RecordingDevices());
1378 1381
1379 // Special fix for the case when the user asks for the name of the default d evice. 1382 // Special fix for the case when the user asks for the name of the default d evice.
1380 // 1383 //
1381 if (index == (uint16_t)(-1)) 1384 if (index == (uint16_t)(-1))
1382 { 1385 {
1383 index = 0; 1386 index = 0;
1384 } 1387 }
1385 1388
1386 if ((index > (nDevices-1)) || (name == NULL)) 1389 if ((index > (nDevices - 1)) || (name == nullptr)) {
1387 { 1390 return -1;
1388 return -1;
1389 } 1391 }
1390 1392
1391 memset(name, 0, kAdmMaxDeviceNameSize); 1393 memset(name, 0, kAdmMaxDeviceNameSize);
1392 1394
1393 if (guid != NULL) 1395 if (guid != nullptr) {
1394 { 1396 memset(guid, 0, kAdmMaxGuidSize);
1395 memset(guid, 0, kAdmMaxGuidSize);
1396 } 1397 }
1397 1398
1398 WAVEINCAPSW caps; // szPname member (product name (NULL terminated) is a WCHAR 1399 WAVEINCAPSW
1400 caps; // szPname member (product name (nullptr terminated) is a WCHAR
1399 MMRESULT res; 1401 MMRESULT res;
1400 1402
1401 res = waveInGetDevCapsW(index, &caps, sizeof(WAVEINCAPSW)); 1403 res = waveInGetDevCapsW(index, &caps, sizeof(WAVEINCAPSW));
1402 if (res != MMSYSERR_NOERROR) 1404 if (res != MMSYSERR_NOERROR)
1403 { 1405 {
1404 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveInGetDevCapsW() failed (err=%d)", res); 1406 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveInGetDevCapsW() failed (err=%d)", res);
1405 return -1; 1407 return -1;
1406 } 1408 }
1407 if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, name, kAdmMaxDeviceNam eSize, NULL, NULL) == 0) 1409 if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, name,
1408 { 1410 kAdmMaxDeviceNameSize, nullptr, nullptr) == 0) {
1409 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiByte(C P_UTF8) failed with error code %d - 1", GetLastError()); 1411 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
1412 "WideCharToMultiByte(CP_UTF8) failed with error code %d - 1",
1413 GetLastError());
1410 } 1414 }
1411 1415
1412 if (guid == NULL) 1416 if (guid == nullptr) {
1413 { 1417 return 0;
1414 return 0;
1415 } 1418 }
1416 1419
1417 // It is possible to get the unique endpoint ID string using the Wave API. 1420 // It is possible to get the unique endpoint ID string using the Wave API.
1418 // However, it is only supported on Windows Vista and Windows 7. 1421 // However, it is only supported on Windows Vista and Windows 7.
1419 1422
1420 size_t cbEndpointId(0); 1423 size_t cbEndpointId(0);
1421 1424
1422 // Get the size (including the terminating null) of the endpoint ID string o f the waveOut device. 1425 // Get the size (including the terminating null) of the endpoint ID string o f the waveOut device.
1423 // Windows Vista supports the DRV_QUERYFUNCTIONINSTANCEIDSIZE and DRV_QUERYF UNCTIONINSTANCEID messages. 1426 // Windows Vista supports the DRV_QUERYFUNCTIONINSTANCEIDSIZE and DRV_QUERYF UNCTIONINSTANCEID messages.
1424 res = waveInMessage((HWAVEIN)IntToPtr(index), 1427 res =
1425 DRV_QUERYFUNCTIONINSTANCEIDSIZE, 1428 waveInMessage((HWAVEIN)IntToPtr(index), DRV_QUERYFUNCTIONINSTANCEIDSIZE,
1426 (DWORD_PTR)&cbEndpointId, NULL); 1429 (DWORD_PTR)&cbEndpointId, NULL);
1427 if (res != MMSYSERR_NOERROR) 1430 if (res != MMSYSERR_NOERROR)
1428 { 1431 {
1429 // DRV_QUERYFUNCTIONINSTANCEIDSIZE is not supported <=> earlier version of Windows than Vista 1432 // DRV_QUERYFUNCTIONINSTANCEIDSIZE is not supported <=> earlier version of Windows than Vista
1430 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "waveInMessage(DRV_QUER YFUNCTIONINSTANCEIDSIZE) failed (err=%d)", res); 1433 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "waveInMessage(DRV_QUER YFUNCTIONINSTANCEIDSIZE) failed (err=%d)", res);
1431 TraceWaveInError(res); 1434 TraceWaveInError(res);
1432 // Best we can do is to copy the friendly name and use it as guid 1435 // Best we can do is to copy the friendly name and use it as guid
1433 if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, guid, kAdmMaxGuidS ize, NULL, NULL) == 0) 1436 if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, guid,
1434 { 1437 kAdmMaxGuidSize, nullptr, nullptr) == 0) {
1435 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiBy te(CP_UTF8) failed with error code %d - 2", GetLastError()); 1438 WEBRTC_TRACE(
1439 kTraceError, kTraceAudioDevice, _id,
1440 "WideCharToMultiByte(CP_UTF8) failed with error code %d - 2",
1441 GetLastError());
1436 } 1442 }
1437 return 0; 1443 return 0;
1438 } 1444 }
1439 1445
1440 // waveOutMessage(DRV_QUERYFUNCTIONINSTANCEIDSIZE) worked => we are on a Vis ta or Windows 7 device 1446 // waveOutMessage(DRV_QUERYFUNCTIONINSTANCEIDSIZE) worked => we are on a Vis ta or Windows 7 device
1441 1447
1442 WCHAR *pstrEndpointId = NULL; 1448 WCHAR* pstrEndpointId = nullptr;
1443 pstrEndpointId = (WCHAR*)CoTaskMemAlloc(cbEndpointId); 1449 pstrEndpointId = (WCHAR*)CoTaskMemAlloc(cbEndpointId);
1444 1450
1445 // Get the endpoint ID string for this waveOut device. 1451 // Get the endpoint ID string for this waveOut device.
1446 res = waveInMessage((HWAVEIN)IntToPtr(index), 1452 res = waveInMessage((HWAVEIN)IntToPtr(index),
1447 DRV_QUERYFUNCTIONINSTANCEID, 1453 DRV_QUERYFUNCTIONINSTANCEID,
1448 (DWORD_PTR)pstrEndpointId, 1454 (DWORD_PTR)pstrEndpointId,
1449 cbEndpointId); 1455 cbEndpointId);
1450 if (res != MMSYSERR_NOERROR) 1456 if (res != MMSYSERR_NOERROR)
1451 { 1457 {
1452 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "waveInMessage(DRV_QUER YFUNCTIONINSTANCEID) failed (err=%d)", res); 1458 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "waveInMessage(DRV_QUER YFUNCTIONINSTANCEID) failed (err=%d)", res);
1453 TraceWaveInError(res); 1459 TraceWaveInError(res);
1454 // Best we can do is to copy the friendly name and use it as guid 1460 // Best we can do is to copy the friendly name and use it as guid
1455 if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, guid, kAdmMaxGuidS ize, NULL, NULL) == 0) 1461 if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, guid,
1456 { 1462 kAdmMaxGuidSize, nullptr, nullptr) == 0) {
1457 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiBy te(CP_UTF8) failed with error code %d - 3", GetLastError()); 1463 WEBRTC_TRACE(
1464 kTraceError, kTraceAudioDevice, _id,
1465 "WideCharToMultiByte(CP_UTF8) failed with error code %d - 3",
1466 GetLastError());
1458 } 1467 }
1459 CoTaskMemFree(pstrEndpointId); 1468 CoTaskMemFree(pstrEndpointId);
1460 return 0; 1469 return 0;
1461 } 1470 }
1462 1471
1463 if (WideCharToMultiByte(CP_UTF8, 0, pstrEndpointId, -1, guid, kAdmMaxGuidSiz e, NULL, NULL) == 0) 1472 if (WideCharToMultiByte(CP_UTF8, 0, pstrEndpointId, -1, guid,
1464 { 1473 kAdmMaxGuidSize, nullptr, nullptr) == 0) {
1465 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiByte(C P_UTF8) failed with error code %d - 4", GetLastError()); 1474 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
1475 "WideCharToMultiByte(CP_UTF8) failed with error code %d - 4",
1476 GetLastError());
1466 } 1477 }
1467 CoTaskMemFree(pstrEndpointId); 1478 CoTaskMemFree(pstrEndpointId);
1468 1479
1469 return 0; 1480 return 0;
1470 } 1481 }
1471 1482
1472 // ---------------------------------------------------------------------------- 1483 // ----------------------------------------------------------------------------
1473 // RecordingDevices 1484 // RecordingDevices
1474 // ---------------------------------------------------------------------------- 1485 // ----------------------------------------------------------------------------
1475 1486
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1608 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "InitSpeaker() faile d"); 1619 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "InitSpeaker() faile d");
1609 } 1620 }
1610 1621
1611 // Enumerate all availiable output devices 1622 // Enumerate all availiable output devices
1612 EnumeratePlayoutDevices(); 1623 EnumeratePlayoutDevices();
1613 1624
1614 // Start by closing any existing wave-output devices 1625 // Start by closing any existing wave-output devices
1615 // 1626 //
1616 MMRESULT res(MMSYSERR_ERROR); 1627 MMRESULT res(MMSYSERR_ERROR);
1617 1628
1618 if (_hWaveOut != NULL) 1629 if (_hWaveOut != nullptr) {
1619 { 1630 res = waveOutClose(_hWaveOut);
1620 res = waveOutClose(_hWaveOut); 1631 if (MMSYSERR_NOERROR != res) {
1621 if (MMSYSERR_NOERROR != res) 1632 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
1622 { 1633 "waveOutClose() failed (err=%d)", res);
1623 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveOutClose() failed (err=%d)", res); 1634 TraceWaveOutError(res);
1624 TraceWaveOutError(res); 1635 }
1625 }
1626 } 1636 }
1627 1637
1628 // Set the output wave format 1638 // Set the output wave format
1629 // 1639 //
1630 WAVEFORMATEX waveFormat; 1640 WAVEFORMATEX waveFormat;
1631 1641
1632 waveFormat.wFormatTag = WAVE_FORMAT_PCM; 1642 waveFormat.wFormatTag = WAVE_FORMAT_PCM;
1633 waveFormat.nChannels = _playChannels; // mono <=> 1, stereo <=> 2 1643 waveFormat.nChannels = _playChannels; // mono <=> 1, stereo <=> 2
1634 waveFormat.nSamplesPerSec = N_PLAY_SAMPLES_PER_SEC; 1644 waveFormat.nSamplesPerSec = N_PLAY_SAMPLES_PER_SEC;
1635 waveFormat.wBitsPerSample = 16; 1645 waveFormat.wBitsPerSample = 16;
1636 waveFormat.nBlockAlign = waveFormat.nChannels * (waveFormat.wBitsPerSamp le/8); 1646 waveFormat.nBlockAlign = waveFormat.nChannels * (waveFormat.wBitsPerSamp le/8);
1637 waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAl ign; 1647 waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAl ign;
1638 waveFormat.cbSize = 0; 1648 waveFormat.cbSize = 0;
1639 1649
1640 // Open the given waveform-audio output device for playout 1650 // Open the given waveform-audio output device for playout
1641 // 1651 //
1642 HWAVEOUT hWaveOut(NULL); 1652 HWAVEOUT hWaveOut(nullptr);
1643 1653
1644 if (IsUsingOutputDeviceIndex()) 1654 if (IsUsingOutputDeviceIndex())
1645 { 1655 {
1646 // verify settings first 1656 // verify settings first
1647 res = waveOutOpen(NULL, _outputDeviceIndex, &waveFormat, 0, 0, CALLBACK_ NULL | WAVE_FORMAT_QUERY); 1657 res = waveOutOpen(nullptr, _outputDeviceIndex, &waveFormat, 0, 0,
1658 CALLBACK_NULL | WAVE_FORMAT_QUERY);
1648 if (MMSYSERR_NOERROR == res) 1659 if (MMSYSERR_NOERROR == res)
1649 { 1660 {
1650 // open the given waveform-audio output device for recording 1661 // open the given waveform-audio output device for recording
1651 res = waveOutOpen(&hWaveOut, _outputDeviceIndex, &waveFormat, 0, 0, CALLBACK_NULL); 1662 res = waveOutOpen(&hWaveOut, _outputDeviceIndex, &waveFormat, 0, 0,
1663 CALLBACK_NULL);
1652 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening output dev ice corresponding to device ID %u", _outputDeviceIndex); 1664 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening output dev ice corresponding to device ID %u", _outputDeviceIndex);
1653 } 1665 }
1654 } 1666 }
1655 else 1667 else
1656 { 1668 {
1657 if (_outputDevice == AudioDeviceModule::kDefaultCommunicationDevice) 1669 if (_outputDevice == AudioDeviceModule::kDefaultCommunicationDevice)
1658 { 1670 {
1659 // check if it is possible to open the default communication device (supported on Windows 7) 1671 // check if it is possible to open the default communication device (supported on Windows 7)
1660 res = waveOutOpen(NULL, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NUL L | WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE | WAVE_FORMAT_QUERY); 1672 res = waveOutOpen(nullptr, WAVE_MAPPER, &waveFormat, 0, 0,
1673 CALLBACK_NULL |
1674 WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE |
1675 WAVE_FORMAT_QUERY);
1661 if (MMSYSERR_NOERROR == res) 1676 if (MMSYSERR_NOERROR == res)
1662 { 1677 {
1663 // if so, open the default communication device for real 1678 // if so, open the default communication device for real
1664 res = waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0, CAL LBACK_NULL | WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE); 1679 res = waveOutOpen(
1680 &hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0,
1681 CALLBACK_NULL | WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE);
1665 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening defaul t communication device"); 1682 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening defaul t communication device");
1666 } 1683 }
1667 else 1684 else
1668 { 1685 {
1669 // use default device since default communication device was not avaliable 1686 // use default device since default communication device was not avaliable
1670 res = waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0, CAL LBACK_NULL); 1687 res = waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0,
1688 CALLBACK_NULL);
1671 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "unable to open default communication device => using default instead"); 1689 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "unable to open default communication device => using default instead");
1672 } 1690 }
1673 } 1691 }
1674 else if (_outputDevice == AudioDeviceModule::kDefaultDevice) 1692 else if (_outputDevice == AudioDeviceModule::kDefaultDevice)
1675 { 1693 {
1676 // open default device since it has been requested 1694 // open default device since it has been requested
1677 res = waveOutOpen(NULL, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NUL L | WAVE_FORMAT_QUERY); 1695 res = waveOutOpen(nullptr, WAVE_MAPPER, &waveFormat, 0, 0,
1696 CALLBACK_NULL | WAVE_FORMAT_QUERY);
1678 if (MMSYSERR_NOERROR == res) 1697 if (MMSYSERR_NOERROR == res)
1679 { 1698 {
1680 res = waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0, CAL LBACK_NULL); 1699 res = waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0,
1681 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening defaul t output device"); 1700 CALLBACK_NULL);
1701 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
1702 "opening default output device");
1682 } 1703 }
1683 } 1704 }
1684 } 1705 }
1685 1706
1686 if (MMSYSERR_NOERROR != res) 1707 if (MMSYSERR_NOERROR != res)
1687 { 1708 {
1688 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "waveOutOpen() failed (err=%d)", res); 1709 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "waveOutOpen() failed (err=%d)", res);
1689 TraceWaveOutError(res); 1710 TraceWaveOutError(res);
1690 return -1; 1711 return -1;
1691 } 1712 }
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "InitMicrophone() fa iled"); 1828 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "InitMicrophone() fa iled");
1808 } 1829 }
1809 1830
1810 // Enumerate all availiable input devices 1831 // Enumerate all availiable input devices
1811 EnumerateRecordingDevices(); 1832 EnumerateRecordingDevices();
1812 1833
1813 // Start by closing any existing wave-input devices 1834 // Start by closing any existing wave-input devices
1814 // 1835 //
1815 MMRESULT res(MMSYSERR_ERROR); 1836 MMRESULT res(MMSYSERR_ERROR);
1816 1837
1817 if (_hWaveIn != NULL) 1838 if (_hWaveIn != nullptr) {
1818 { 1839 res = waveInClose(_hWaveIn);
1819 res = waveInClose(_hWaveIn); 1840 if (MMSYSERR_NOERROR != res) {
1820 if (MMSYSERR_NOERROR != res) 1841 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
1821 { 1842 "waveInClose() failed (err=%d)", res);
1822 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveInClose() f ailed (err=%d)", res); 1843 TraceWaveInError(res);
1823 TraceWaveInError(res); 1844 }
1824 }
1825 } 1845 }
1826 1846
1827 // Set the input wave format 1847 // Set the input wave format
1828 // 1848 //
1829 WAVEFORMATEX waveFormat; 1849 WAVEFORMATEX waveFormat;
1830 1850
1831 waveFormat.wFormatTag = WAVE_FORMAT_PCM; 1851 waveFormat.wFormatTag = WAVE_FORMAT_PCM;
1832 waveFormat.nChannels = _recChannels; // mono <=> 1, stereo <=> 2 1852 waveFormat.nChannels = _recChannels; // mono <=> 1, stereo <=> 2
1833 waveFormat.nSamplesPerSec = N_REC_SAMPLES_PER_SEC; 1853 waveFormat.nSamplesPerSec = N_REC_SAMPLES_PER_SEC;
1834 waveFormat.wBitsPerSample = 16; 1854 waveFormat.wBitsPerSample = 16;
1835 waveFormat.nBlockAlign = waveFormat.nChannels * (waveFormat.wBitsPerSamp le/8); 1855 waveFormat.nBlockAlign = waveFormat.nChannels * (waveFormat.wBitsPerSamp le/8);
1836 waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAl ign; 1856 waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAl ign;
1837 waveFormat.cbSize = 0; 1857 waveFormat.cbSize = 0;
1838 1858
1839 // Open the given waveform-audio input device for recording 1859 // Open the given waveform-audio input device for recording
1840 // 1860 //
1841 HWAVEIN hWaveIn(NULL); 1861 HWAVEIN hWaveIn(nullptr);
1842 1862
1843 if (IsUsingInputDeviceIndex()) 1863 if (IsUsingInputDeviceIndex())
1844 { 1864 {
1845 // verify settings first 1865 // verify settings first
1846 res = waveInOpen(NULL, _inputDeviceIndex, &waveFormat, 0, 0, CALLBACK_NU LL | WAVE_FORMAT_QUERY); 1866 res = waveInOpen(nullptr, _inputDeviceIndex, &waveFormat, 0, 0,
1867 CALLBACK_NULL | WAVE_FORMAT_QUERY);
1847 if (MMSYSERR_NOERROR == res) 1868 if (MMSYSERR_NOERROR == res)
1848 { 1869 {
1849 // open the given waveform-audio input device for recording 1870 // open the given waveform-audio input device for recording
1850 res = waveInOpen(&hWaveIn, _inputDeviceIndex, &waveFormat, 0, 0, CAL LBACK_NULL); 1871 res = waveInOpen(&hWaveIn, _inputDeviceIndex, &waveFormat, 0, 0,
1872 CALLBACK_NULL);
1851 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening input devi ce corresponding to device ID %u", _inputDeviceIndex); 1873 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening input devi ce corresponding to device ID %u", _inputDeviceIndex);
1852 } 1874 }
1853 } 1875 }
1854 else 1876 else
1855 { 1877 {
1856 if (_inputDevice == AudioDeviceModule::kDefaultCommunicationDevice) 1878 if (_inputDevice == AudioDeviceModule::kDefaultCommunicationDevice)
1857 { 1879 {
1858 // check if it is possible to open the default communication device (supported on Windows 7) 1880 // check if it is possible to open the default communication device (supported on Windows 7)
1859 res = waveInOpen(NULL, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NULL | WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE | WAVE_FORMAT_QUERY); 1881 res = waveInOpen(nullptr, WAVE_MAPPER, &waveFormat, 0, 0,
1882 CALLBACK_NULL |
1883 WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE |
1884 WAVE_FORMAT_QUERY);
1860 if (MMSYSERR_NOERROR == res) 1885 if (MMSYSERR_NOERROR == res)
1861 { 1886 {
1862 // if so, open the default communication device for real 1887 // if so, open the default communication device for real
1863 res = waveInOpen(&hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0, CALLB ACK_NULL | WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE); 1888 res = waveInOpen(
1889 &hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0,
1890 CALLBACK_NULL | WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE);
1864 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening defaul t communication device"); 1891 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening defaul t communication device");
1865 } 1892 }
1866 else 1893 else
1867 { 1894 {
1868 // use default device since default communication device was not avaliable 1895 // use default device since default communication device was not avaliable
1869 res = waveInOpen(&hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0, CALLB ACK_NULL); 1896 res = waveInOpen(&hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0,
1897 CALLBACK_NULL);
1870 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "unable to open default communication device => using default instead"); 1898 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "unable to open default communication device => using default instead");
1871 } 1899 }
1872 } 1900 }
1873 else if (_inputDevice == AudioDeviceModule::kDefaultDevice) 1901 else if (_inputDevice == AudioDeviceModule::kDefaultDevice)
1874 { 1902 {
1875 // open default device since it has been requested 1903 // open default device since it has been requested
1876 res = waveInOpen(NULL, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NULL | WAVE_FORMAT_QUERY); 1904 res = waveInOpen(nullptr, WAVE_MAPPER, &waveFormat, 0, 0,
1905 CALLBACK_NULL | WAVE_FORMAT_QUERY);
1877 if (MMSYSERR_NOERROR == res) 1906 if (MMSYSERR_NOERROR == res)
1878 { 1907 {
1879 res = waveInOpen(&hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0, CALLB ACK_NULL); 1908 res = waveInOpen(&hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0,
1880 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening defaul t input device"); 1909 CALLBACK_NULL);
1910 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
1911 "opening default input device");
1881 } 1912 }
1882 } 1913 }
1883 } 1914 }
1884 1915
1885 if (MMSYSERR_NOERROR != res) 1916 if (MMSYSERR_NOERROR != res)
1886 { 1917 {
1887 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "waveInOpen() failed ( err=%d)", res); 1918 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "waveInOpen() failed ( err=%d)", res);
1888 TraceWaveInError(res); 1919 TraceWaveInError(res);
1889 return -1; 1920 return -1;
1890 } 1921 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1974 int32_t AudioDeviceWindowsWave::StopRecording() 2005 int32_t AudioDeviceWindowsWave::StopRecording()
1975 { 2006 {
1976 2007
1977 CriticalSectionScoped lock(&_critSect); 2008 CriticalSectionScoped lock(&_critSect);
1978 2009
1979 if (!_recIsInitialized) 2010 if (!_recIsInitialized)
1980 { 2011 {
1981 return 0; 2012 return 0;
1982 } 2013 }
1983 2014
1984 if (_hWaveIn == NULL) 2015 if (_hWaveIn == nullptr) {
1985 { 2016 return -1;
1986 return -1;
1987 } 2017 }
1988 2018
1989 bool wasRecording = _recording; 2019 bool wasRecording = _recording;
1990 _recIsInitialized = false; 2020 _recIsInitialized = false;
1991 _recording = false; 2021 _recording = false;
1992 2022
1993 MMRESULT res; 2023 MMRESULT res;
1994 2024
1995 // Stop waveform-adio input. If there are any buffers in the queue, the 2025 // Stop waveform-adio input. If there are any buffers in the queue, the
1996 // current buffer will be marked as done (the dwBytesRecorded member in 2026 // current buffer will be marked as done (the dwBytesRecorded member in
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 2064
2035 // Close the given waveform-audio input device. 2065 // Close the given waveform-audio input device.
2036 // 2066 //
2037 res = waveInClose(_hWaveIn); 2067 res = waveInClose(_hWaveIn);
2038 if (MMSYSERR_NOERROR != res) 2068 if (MMSYSERR_NOERROR != res)
2039 { 2069 {
2040 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveInClose() faile d (err=%d)", res); 2070 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveInClose() faile d (err=%d)", res);
2041 TraceWaveInError(res); 2071 TraceWaveInError(res);
2042 } 2072 }
2043 2073
2044 // Set the wave input handle to NULL 2074 // Set the wave input handle to null
2045 // 2075 //
2046 _hWaveIn = NULL; 2076 _hWaveIn = nullptr;
2047 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "_hWaveIn is now set to NUL L"); 2077 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
2078 "_hWaveIn is now set to null");
2048 2079
2049 return 0; 2080 return 0;
2050 } 2081 }
2051 2082
2052 // ---------------------------------------------------------------------------- 2083 // ----------------------------------------------------------------------------
2053 // RecordingIsInitialized 2084 // RecordingIsInitialized
2054 // ---------------------------------------------------------------------------- 2085 // ----------------------------------------------------------------------------
2055 2086
2056 bool AudioDeviceWindowsWave::RecordingIsInitialized() const 2087 bool AudioDeviceWindowsWave::RecordingIsInitialized() const
2057 { 2088 {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 int32_t AudioDeviceWindowsWave::StopPlayout() 2156 int32_t AudioDeviceWindowsWave::StopPlayout()
2126 { 2157 {
2127 2158
2128 CriticalSectionScoped lock(&_critSect); 2159 CriticalSectionScoped lock(&_critSect);
2129 2160
2130 if (!_playIsInitialized) 2161 if (!_playIsInitialized)
2131 { 2162 {
2132 return 0; 2163 return 0;
2133 } 2164 }
2134 2165
2135 if (_hWaveOut == NULL) 2166 if (_hWaveOut == nullptr) {
2136 { 2167 return -1;
2137 return -1;
2138 } 2168 }
2139 2169
2140 _playIsInitialized = false; 2170 _playIsInitialized = false;
2141 _playing = false; 2171 _playing = false;
2142 _sndCardPlayDelay = 0; 2172 _sndCardPlayDelay = 0;
2143 _sndCardRecDelay = 0; 2173 _sndCardRecDelay = 0;
2144 2174
2145 MMRESULT res; 2175 MMRESULT res;
2146 2176
2147 // The waveOutReset function stops playback on the given waveform-audio 2177 // The waveOutReset function stops playback on the given waveform-audio
(...skipping 30 matching lines...) Expand all
2178 // waveOutClose, the application must wait for all buffers to finish playing 2208 // waveOutClose, the application must wait for all buffers to finish playing
2179 // or call the waveOutReset function to terminate playback. 2209 // or call the waveOutReset function to terminate playback.
2180 // 2210 //
2181 res = waveOutClose(_hWaveOut); 2211 res = waveOutClose(_hWaveOut);
2182 if (MMSYSERR_NOERROR != res) 2212 if (MMSYSERR_NOERROR != res)
2183 { 2213 {
2184 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveOutClose() fail ed (err=%d)", res); 2214 WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveOutClose() fail ed (err=%d)", res);
2185 TraceWaveOutError(res); 2215 TraceWaveOutError(res);
2186 } 2216 }
2187 2217
2188 _hWaveOut = NULL; 2218 _hWaveOut = nullptr;
2189 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "_hWaveOut is now set to NU LL"); 2219 WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
2220 "_hWaveOut is now set to null");
2190 2221
2191 return 0; 2222 return 0;
2192 } 2223 }
2193 2224
2194 // ---------------------------------------------------------------------------- 2225 // ----------------------------------------------------------------------------
2195 // PlayoutDelay 2226 // PlayoutDelay
2196 // ---------------------------------------------------------------------------- 2227 // ----------------------------------------------------------------------------
2197 2228
2198 int32_t AudioDeviceWindowsWave::PlayoutDelay(uint16_t& delayMS) const 2229 int32_t AudioDeviceWindowsWave::PlayoutDelay(uint16_t& delayMS) const
2199 { 2230 {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2343 // ============================================================================ 2374 // ============================================================================
2344 // Private Methods 2375 // Private Methods
2345 // ============================================================================ 2376 // ============================================================================
2346 2377
2347 // ---------------------------------------------------------------------------- 2378 // ----------------------------------------------------------------------------
2348 // InputSanityCheckAfterUnlockedPeriod 2379 // InputSanityCheckAfterUnlockedPeriod
2349 // ---------------------------------------------------------------------------- 2380 // ----------------------------------------------------------------------------
2350 2381
2351 int32_t AudioDeviceWindowsWave::InputSanityCheckAfterUnlockedPeriod() const 2382 int32_t AudioDeviceWindowsWave::InputSanityCheckAfterUnlockedPeriod() const
2352 { 2383 {
2353 if (_hWaveIn == NULL) 2384 if (_hWaveIn == nullptr) {
2354 { 2385 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
2355 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "input state has been modified during unlocked period"); 2386 "input state has been modified during unlocked period");
2356 return -1; 2387 return -1;
2357 } 2388 }
2358 return 0; 2389 return 0;
2359 } 2390 }
2360 2391
2361 // ---------------------------------------------------------------------------- 2392 // ----------------------------------------------------------------------------
2362 // OutputSanityCheckAfterUnlockedPeriod 2393 // OutputSanityCheckAfterUnlockedPeriod
2363 // ---------------------------------------------------------------------------- 2394 // ----------------------------------------------------------------------------
2364 2395
2365 int32_t AudioDeviceWindowsWave::OutputSanityCheckAfterUnlockedPeriod() const 2396 int32_t AudioDeviceWindowsWave::OutputSanityCheckAfterUnlockedPeriod() const
2366 { 2397 {
2367 if (_hWaveOut == NULL) 2398 if (_hWaveOut == nullptr) {
2368 { 2399 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
2369 WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "output state has been modified during unlocked period"); 2400 "output state has been modified during unlocked period");
2370 return -1; 2401 return -1;
2371 } 2402 }
2372 return 0; 2403 return 0;
2373 } 2404 }
2374 2405
2375 // ---------------------------------------------------------------------------- 2406 // ----------------------------------------------------------------------------
2376 // EnumeratePlayoutDevices 2407 // EnumeratePlayoutDevices
2377 // ---------------------------------------------------------------------------- 2408 // ----------------------------------------------------------------------------
2378 2409
2379 int32_t AudioDeviceWindowsWave::EnumeratePlayoutDevices() 2410 int32_t AudioDeviceWindowsWave::EnumeratePlayoutDevices()
2380 { 2411 {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2551 2582
2552 // ---------------------------------------------------------------------------- 2583 // ----------------------------------------------------------------------------
2553 // PrepareStartPlayout 2584 // PrepareStartPlayout
2554 // ---------------------------------------------------------------------------- 2585 // ----------------------------------------------------------------------------
2555 2586
2556 int32_t AudioDeviceWindowsWave::PrepareStartPlayout() 2587 int32_t AudioDeviceWindowsWave::PrepareStartPlayout()
2557 { 2588 {
2558 2589
2559 CriticalSectionScoped lock(&_critSect); 2590 CriticalSectionScoped lock(&_critSect);
2560 2591
2561 if (_hWaveOut == NULL) 2592 if (_hWaveOut == nullptr) {
2562 { 2593 return -1;
2563 return -1;
2564 } 2594 }
2565 2595
2566 // A total of 30ms of data is immediately placed in the SC buffer 2596 // A total of 30ms of data is immediately placed in the SC buffer
2567 // 2597 //
2568 int8_t zeroVec[4*PLAY_BUF_SIZE_IN_SAMPLES]; // max allocation 2598 int8_t zeroVec[4*PLAY_BUF_SIZE_IN_SAMPLES]; // max allocation
2569 memset(zeroVec, 0, 4*PLAY_BUF_SIZE_IN_SAMPLES); 2599 memset(zeroVec, 0, 4*PLAY_BUF_SIZE_IN_SAMPLES);
2570 2600
2571 { 2601 {
2572 Write(zeroVec, PLAY_BUF_SIZE_IN_SAMPLES); 2602 Write(zeroVec, PLAY_BUF_SIZE_IN_SAMPLES);
2573 Write(zeroVec, PLAY_BUF_SIZE_IN_SAMPLES); 2603 Write(zeroVec, PLAY_BUF_SIZE_IN_SAMPLES);
(...skipping 14 matching lines...) Expand all
2588 2618
2589 // ---------------------------------------------------------------------------- 2619 // ----------------------------------------------------------------------------
2590 // PrepareStartRecording 2620 // PrepareStartRecording
2591 // ---------------------------------------------------------------------------- 2621 // ----------------------------------------------------------------------------
2592 2622
2593 int32_t AudioDeviceWindowsWave::PrepareStartRecording() 2623 int32_t AudioDeviceWindowsWave::PrepareStartRecording()
2594 { 2624 {
2595 2625
2596 CriticalSectionScoped lock(&_critSect); 2626 CriticalSectionScoped lock(&_critSect);
2597 2627
2598 if (_hWaveIn == NULL) 2628 if (_hWaveIn == nullptr) {
2599 { 2629 return -1;
2600 return -1;
2601 } 2630 }
2602 2631
2603 _playAcc = 0; 2632 _playAcc = 0;
2604 _recordedBytes = 0; 2633 _recordedBytes = 0;
2605 _recPutBackDelay = REC_PUT_BACK_DELAY; 2634 _recPutBackDelay = REC_PUT_BACK_DELAY;
2606 2635
2607 MMRESULT res; 2636 MMRESULT res;
2608 MMTIME mmtime; 2637 MMTIME mmtime;
2609 mmtime.wType = TIME_SAMPLES; 2638 mmtime.wType = TIME_SAMPLES;
2610 2639
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after
3511 3540
3512 return (0); 3541 return (0);
3513 } 3542 }
3514 3543
3515 // ---------------------------------------------------------------------------- 3544 // ----------------------------------------------------------------------------
3516 // Write 3545 // Write
3517 // ---------------------------------------------------------------------------- 3546 // ----------------------------------------------------------------------------
3518 3547
3519 int32_t AudioDeviceWindowsWave::Write(int8_t* data, uint16_t nSamples) 3548 int32_t AudioDeviceWindowsWave::Write(int8_t* data, uint16_t nSamples)
3520 { 3549 {
3521 if (_hWaveOut == NULL) 3550 if (_hWaveOut == nullptr) {
3522 { 3551 return -1;
3523 return -1;
3524 } 3552 }
3525 3553
3526 if (_playIsInitialized) 3554 if (_playIsInitialized)
3527 { 3555 {
3528 MMRESULT res; 3556 MMRESULT res;
3529 3557
3530 const uint16_t bufCount(_playBufCount); 3558 const uint16_t bufCount(_playBufCount);
3531 3559
3532 // Place data in the memory associated with _waveHeaderOut[bufCount] 3560 // Place data in the memory associated with _waveHeaderOut[bufCount]
3533 // 3561 //
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
3714 bool AudioDeviceWindowsWave::KeyPressed() const{ 3742 bool AudioDeviceWindowsWave::KeyPressed() const{
3715 3743
3716 int key_down = 0; 3744 int key_down = 0;
3717 for (int key = VK_SPACE; key < VK_NUMLOCK; key++) { 3745 for (int key = VK_SPACE; key < VK_NUMLOCK; key++) {
3718 short res = GetAsyncKeyState(key); 3746 short res = GetAsyncKeyState(key);
3719 key_down |= res & 0x1; // Get the LSB 3747 key_down |= res & 0x1; // Get the LSB
3720 } 3748 }
3721 return (key_down > 0); 3749 return (key_down > 0);
3722 } 3750 }
3723 } // namespace webrtc 3751 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698