| Index: webrtc/modules/audio_device/win/audio_device_wave_win.cc
|
| diff --git a/webrtc/modules/audio_device/win/audio_device_wave_win.cc b/webrtc/modules/audio_device/win/audio_device_wave_win.cc
|
| index 7874575e7ce166259801f1aa34bfe8f603d9ff9d..f26c1b2a0d5c0601e37e122889fda5cebd81e367 100644
|
| --- a/webrtc/modules/audio_device/win/audio_device_wave_win.cc
|
| +++ b/webrtc/modules/audio_device/win/audio_device_wave_win.cc
|
| @@ -45,85 +45,83 @@ namespace webrtc {
|
| // AudioDeviceWindowsWave - ctor
|
| // ----------------------------------------------------------------------------
|
|
|
| -AudioDeviceWindowsWave::AudioDeviceWindowsWave(const int32_t id) :
|
| - _ptrAudioBuffer(NULL),
|
| - _critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
| - _timeEvent(*EventTimerWrapper::Create()),
|
| - _recStartEvent(*EventWrapper::Create()),
|
| - _playStartEvent(*EventWrapper::Create()),
|
| - _hGetCaptureVolumeThread(NULL),
|
| - _hShutdownGetVolumeEvent(NULL),
|
| - _hSetCaptureVolumeThread(NULL),
|
| - _hShutdownSetVolumeEvent(NULL),
|
| - _hSetCaptureVolumeEvent(NULL),
|
| - _critSectCb(*CriticalSectionWrapper::CreateCriticalSection()),
|
| - _id(id),
|
| - _mixerManager(id),
|
| - _usingInputDeviceIndex(false),
|
| - _usingOutputDeviceIndex(false),
|
| - _inputDevice(AudioDeviceModule::kDefaultDevice),
|
| - _outputDevice(AudioDeviceModule::kDefaultDevice),
|
| - _inputDeviceIndex(0),
|
| - _outputDeviceIndex(0),
|
| - _inputDeviceIsSpecified(false),
|
| - _outputDeviceIsSpecified(false),
|
| - _initialized(false),
|
| - _recIsInitialized(false),
|
| - _playIsInitialized(false),
|
| - _recording(false),
|
| - _playing(false),
|
| - _startRec(false),
|
| - _stopRec(false),
|
| - _startPlay(false),
|
| - _stopPlay(false),
|
| - _AGC(false),
|
| - _hWaveIn(NULL),
|
| - _hWaveOut(NULL),
|
| - _recChannels(N_REC_CHANNELS),
|
| - _playChannels(N_PLAY_CHANNELS),
|
| - _recBufCount(0),
|
| - _recPutBackDelay(0),
|
| - _recDelayCount(0),
|
| - _playBufCount(0),
|
| - _prevPlayTime(0),
|
| - _prevRecTime(0),
|
| - _prevTimerCheckTime(0),
|
| - _timesdwBytes(0),
|
| - _timerFaults(0),
|
| - _timerRestartAttempts(0),
|
| - _no_of_msecleft_warnings(0),
|
| - _MAX_minBuffer(65),
|
| - _useHeader(0),
|
| - _dTcheckPlayBufDelay(10),
|
| - _playBufDelay(80),
|
| - _playBufDelayFixed(80),
|
| - _minPlayBufDelay(20),
|
| - _avgCPULoad(0),
|
| - _sndCardPlayDelay(0),
|
| - _sndCardRecDelay(0),
|
| - _plSampOld(0),
|
| - _rcSampOld(0),
|
| - _playBufType(AudioDeviceModule::kAdaptiveBufferSize),
|
| - _recordedBytes(0),
|
| - _playWarning(0),
|
| - _playError(0),
|
| - _recWarning(0),
|
| - _recError(0),
|
| - _newMicLevel(0),
|
| - _minMicVolume(0),
|
| - _maxMicVolume(0)
|
| -{
|
| - WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, "%s created", __FUNCTION__);
|
| -
|
| - // Initialize value, set to 0 if it fails
|
| - if (!QueryPerformanceFrequency(&_perfFreq))
|
| - {
|
| - _perfFreq.QuadPart = 0;
|
| - }
|
| -
|
| - _hShutdownGetVolumeEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
| - _hShutdownSetVolumeEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
| - _hSetCaptureVolumeEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
| +AudioDeviceWindowsWave::AudioDeviceWindowsWave(const int32_t id)
|
| + : _ptrAudioBuffer(nullptr),
|
| + _critSect(*CriticalSectionWrapper::CreateCriticalSection()),
|
| + _timeEvent(*EventTimerWrapper::Create()),
|
| + _recStartEvent(*EventWrapper::Create()),
|
| + _playStartEvent(*EventWrapper::Create()),
|
| + _hGetCaptureVolumeThread(nullptr),
|
| + _hShutdownGetVolumeEvent(nullptr),
|
| + _hSetCaptureVolumeThread(nullptr),
|
| + _hShutdownSetVolumeEvent(nullptr),
|
| + _hSetCaptureVolumeEvent(nullptr),
|
| + _critSectCb(*CriticalSectionWrapper::CreateCriticalSection()),
|
| + _id(id),
|
| + _mixerManager(id),
|
| + _usingInputDeviceIndex(false),
|
| + _usingOutputDeviceIndex(false),
|
| + _inputDevice(AudioDeviceModule::kDefaultDevice),
|
| + _outputDevice(AudioDeviceModule::kDefaultDevice),
|
| + _inputDeviceIndex(0),
|
| + _outputDeviceIndex(0),
|
| + _inputDeviceIsSpecified(false),
|
| + _outputDeviceIsSpecified(false),
|
| + _initialized(false),
|
| + _recIsInitialized(false),
|
| + _playIsInitialized(false),
|
| + _recording(false),
|
| + _playing(false),
|
| + _startRec(false),
|
| + _stopRec(false),
|
| + _startPlay(false),
|
| + _stopPlay(false),
|
| + _AGC(false),
|
| + _hWaveIn(nullptr),
|
| + _hWaveOut(nullptr),
|
| + _recChannels(N_REC_CHANNELS),
|
| + _playChannels(N_PLAY_CHANNELS),
|
| + _recBufCount(0),
|
| + _recPutBackDelay(0),
|
| + _recDelayCount(0),
|
| + _playBufCount(0),
|
| + _prevPlayTime(0),
|
| + _prevRecTime(0),
|
| + _prevTimerCheckTime(0),
|
| + _timesdwBytes(0),
|
| + _timerFaults(0),
|
| + _timerRestartAttempts(0),
|
| + _no_of_msecleft_warnings(0),
|
| + _MAX_minBuffer(65),
|
| + _useHeader(0),
|
| + _dTcheckPlayBufDelay(10),
|
| + _playBufDelay(80),
|
| + _playBufDelayFixed(80),
|
| + _minPlayBufDelay(20),
|
| + _avgCPULoad(0),
|
| + _sndCardPlayDelay(0),
|
| + _sndCardRecDelay(0),
|
| + _plSampOld(0),
|
| + _rcSampOld(0),
|
| + _playBufType(AudioDeviceModule::kAdaptiveBufferSize),
|
| + _recordedBytes(0),
|
| + _playWarning(0),
|
| + _playError(0),
|
| + _recWarning(0),
|
| + _recError(0),
|
| + _newMicLevel(0),
|
| + _minMicVolume(0),
|
| + _maxMicVolume(0) {
|
| + WEBRTC_TRACE(kTraceMemory, kTraceAudioDevice, id, "%s created", __FUNCTION__);
|
| +
|
| + // Initialize value, set to 0 if it fails
|
| + if (!QueryPerformanceFrequency(&_perfFreq)) {
|
| + _perfFreq.QuadPart = 0;
|
| + }
|
| +
|
| + _hShutdownGetVolumeEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
|
| + _hShutdownSetVolumeEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
|
| + _hSetCaptureVolumeEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
|
| }
|
|
|
| // ----------------------------------------------------------------------------
|
| @@ -142,22 +140,19 @@ AudioDeviceWindowsWave::~AudioDeviceWindowsWave()
|
| delete &_critSect;
|
| delete &_critSectCb;
|
|
|
| - if (NULL != _hShutdownGetVolumeEvent)
|
| - {
|
| - CloseHandle(_hShutdownGetVolumeEvent);
|
| - _hShutdownGetVolumeEvent = NULL;
|
| + if (nullptr != _hShutdownGetVolumeEvent) {
|
| + CloseHandle(_hShutdownGetVolumeEvent);
|
| + _hShutdownGetVolumeEvent = nullptr;
|
| }
|
|
|
| - if (NULL != _hShutdownSetVolumeEvent)
|
| - {
|
| - CloseHandle(_hShutdownSetVolumeEvent);
|
| - _hShutdownSetVolumeEvent = NULL;
|
| + if (nullptr != _hShutdownSetVolumeEvent) {
|
| + CloseHandle(_hShutdownSetVolumeEvent);
|
| + _hShutdownSetVolumeEvent = nullptr;
|
| }
|
|
|
| - if (NULL != _hSetCaptureVolumeEvent)
|
| - {
|
| - CloseHandle(_hSetCaptureVolumeEvent);
|
| - _hSetCaptureVolumeEvent = NULL;
|
| + if (nullptr != _hSetCaptureVolumeEvent) {
|
| + CloseHandle(_hSetCaptureVolumeEvent);
|
| + _hSetCaptureVolumeEvent = nullptr;
|
| }
|
| }
|
|
|
| @@ -240,8 +235,8 @@ AudioDeviceGeneric::InitStatus AudioDeviceWindowsWave::Init() {
|
| "periodic timer (dT=%d) is now active", TIMER_PERIOD_MS);
|
|
|
| _hGetCaptureVolumeThread =
|
| - CreateThread(NULL, 0, GetCaptureVolumeThread, this, 0, NULL);
|
| - if (_hGetCaptureVolumeThread == NULL) {
|
| + CreateThread(nullptr, 0, GetCaptureVolumeThread, this, 0, nullptr);
|
| + if (_hGetCaptureVolumeThread == nullptr) {
|
| LOG(LS_ERROR) << " failed to create the volume getter thread";
|
| return InitStatus::OTHER_ERROR;
|
| }
|
| @@ -249,8 +244,8 @@ AudioDeviceGeneric::InitStatus AudioDeviceWindowsWave::Init() {
|
| SetThreadPriority(_hGetCaptureVolumeThread, THREAD_PRIORITY_NORMAL);
|
|
|
| _hSetCaptureVolumeThread =
|
| - CreateThread(NULL, 0, SetCaptureVolumeThread, this, 0, NULL);
|
| - if (_hSetCaptureVolumeThread == NULL) {
|
| + CreateThread(nullptr, 0, SetCaptureVolumeThread, this, 0, nullptr);
|
| + if (_hSetCaptureVolumeThread == nullptr) {
|
| LOG(LS_ERROR) << " failed to create the volume setter thread";
|
| return InitStatus::OTHER_ERROR;
|
| }
|
| @@ -303,7 +298,7 @@ int32_t AudioDeviceWindowsWave::Terminate()
|
| WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| " failed to close down volume getter thread");
|
| CloseHandle(_hGetCaptureVolumeThread);
|
| - _hGetCaptureVolumeThread = NULL;
|
| + _hGetCaptureVolumeThread = nullptr;
|
| return -1;
|
| }
|
| _critSect.Enter();
|
| @@ -319,7 +314,7 @@ int32_t AudioDeviceWindowsWave::Terminate()
|
| WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| " failed to close down volume setter thread");
|
| CloseHandle(_hSetCaptureVolumeThread);
|
| - _hSetCaptureVolumeThread = NULL;
|
| + _hSetCaptureVolumeThread = nullptr;
|
| return -1;
|
| }
|
| _critSect.Enter();
|
| @@ -327,10 +322,10 @@ int32_t AudioDeviceWindowsWave::Terminate()
|
| " volume setter thread is now closed");
|
|
|
| CloseHandle(_hGetCaptureVolumeThread);
|
| - _hGetCaptureVolumeThread = NULL;
|
| + _hGetCaptureVolumeThread = nullptr;
|
|
|
| CloseHandle(_hSetCaptureVolumeThread);
|
| - _hSetCaptureVolumeThread = NULL;
|
| + _hSetCaptureVolumeThread = nullptr;
|
|
|
| _critSect.Leave();
|
|
|
| @@ -626,9 +621,9 @@ int32_t AudioDeviceWindowsWave::SetWaveOutVolume(uint16_t volumeLeft, uint16_t v
|
|
|
| CriticalSectionScoped lock(&_critSect);
|
|
|
| - if (_hWaveOut == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no open playout device exists => using default");
|
| + if (_hWaveOut == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + "no open playout device exists => using default");
|
| }
|
|
|
| // To determine whether the device supports volume control on both
|
| @@ -690,9 +685,9 @@ int32_t AudioDeviceWindowsWave::WaveOutVolume(uint16_t& volumeLeft, uint16_t& vo
|
|
|
| CriticalSectionScoped lock(&_critSect);
|
|
|
| - if (_hWaveOut == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "no open playout device exists => using default");
|
| + if (_hWaveOut == nullptr) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + "no open playout device exists => using default");
|
| }
|
|
|
| // To determine whether the device supports volume control on both
|
| @@ -1278,19 +1273,18 @@ int32_t AudioDeviceWindowsWave::PlayoutDeviceName(
|
| index = 0;
|
| }
|
|
|
| - if ((index > (nDevices-1)) || (name == NULL))
|
| - {
|
| - return -1;
|
| + if ((index > (nDevices - 1)) || (name == nullptr)) {
|
| + return -1;
|
| }
|
|
|
| memset(name, 0, kAdmMaxDeviceNameSize);
|
|
|
| - if (guid != NULL)
|
| - {
|
| - memset(guid, 0, kAdmMaxGuidSize);
|
| + if (guid != nullptr) {
|
| + memset(guid, 0, kAdmMaxGuidSize);
|
| }
|
|
|
| - WAVEOUTCAPSW caps; // szPname member (product name (NULL terminated) is a WCHAR
|
| + WAVEOUTCAPSW
|
| + caps; // szPname member (product name (nullptr terminated) is a WCHAR
|
| MMRESULT res;
|
|
|
| res = waveOutGetDevCapsW(index, &caps, sizeof(WAVEOUTCAPSW));
|
| @@ -1299,14 +1293,15 @@ int32_t AudioDeviceWindowsWave::PlayoutDeviceName(
|
| WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveOutGetDevCapsW() failed (err=%d)", res);
|
| return -1;
|
| }
|
| - if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, name, kAdmMaxDeviceNameSize, NULL, NULL) == 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiByte(CP_UTF8) failed with error code %d - 1", GetLastError());
|
| + if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, name,
|
| + kAdmMaxDeviceNameSize, nullptr, nullptr) == 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + "WideCharToMultiByte(CP_UTF8) failed with error code %d - 1",
|
| + GetLastError());
|
| }
|
|
|
| - if (guid == NULL)
|
| - {
|
| - return 0;
|
| + if (guid == nullptr) {
|
| + return 0;
|
| }
|
|
|
| // It is possible to get the unique endpoint ID string using the Wave API.
|
| @@ -1317,7 +1312,7 @@ int32_t AudioDeviceWindowsWave::PlayoutDeviceName(
|
| // Get the size (including the terminating null) of the endpoint ID string of the waveOut device.
|
| // Windows Vista supports the DRV_QUERYFUNCTIONINSTANCEIDSIZE and DRV_QUERYFUNCTIONINSTANCEID messages.
|
| res = waveOutMessage((HWAVEOUT)IntToPtr(index),
|
| - DRV_QUERYFUNCTIONINSTANCEIDSIZE,
|
| + DRV_QUERYFUNCTIONINSTANCEIDSIZE,
|
| (DWORD_PTR)&cbEndpointId, NULL);
|
| if (res != MMSYSERR_NOERROR)
|
| {
|
| @@ -1325,16 +1320,19 @@ int32_t AudioDeviceWindowsWave::PlayoutDeviceName(
|
| WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "waveOutMessage(DRV_QUERYFUNCTIONINSTANCEIDSIZE) failed (err=%d)", res);
|
| TraceWaveOutError(res);
|
| // Best we can do is to copy the friendly name and use it as guid
|
| - if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, guid, kAdmMaxGuidSize, NULL, NULL) == 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiByte(CP_UTF8) failed with error code %d - 2", GetLastError());
|
| + if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, guid,
|
| + kAdmMaxGuidSize, nullptr, nullptr) == 0) {
|
| + WEBRTC_TRACE(
|
| + kTraceError, kTraceAudioDevice, _id,
|
| + "WideCharToMultiByte(CP_UTF8) failed with error code %d - 2",
|
| + GetLastError());
|
| }
|
| return 0;
|
| }
|
|
|
| // waveOutMessage(DRV_QUERYFUNCTIONINSTANCEIDSIZE) worked => we are on a Vista or Windows 7 device
|
|
|
| - WCHAR *pstrEndpointId = NULL;
|
| + WCHAR* pstrEndpointId = nullptr;
|
| pstrEndpointId = (WCHAR*)CoTaskMemAlloc(cbEndpointId);
|
|
|
| // Get the endpoint ID string for this waveOut device.
|
| @@ -1347,17 +1345,22 @@ int32_t AudioDeviceWindowsWave::PlayoutDeviceName(
|
| WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "waveOutMessage(DRV_QUERYFUNCTIONINSTANCEID) failed (err=%d)", res);
|
| TraceWaveOutError(res);
|
| // Best we can do is to copy the friendly name and use it as guid
|
| - if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, guid, kAdmMaxGuidSize, NULL, NULL) == 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiByte(CP_UTF8) failed with error code %d - 3", GetLastError());
|
| + if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, guid,
|
| + kAdmMaxGuidSize, nullptr, nullptr) == 0) {
|
| + WEBRTC_TRACE(
|
| + kTraceError, kTraceAudioDevice, _id,
|
| + "WideCharToMultiByte(CP_UTF8) failed with error code %d - 3",
|
| + GetLastError());
|
| }
|
| CoTaskMemFree(pstrEndpointId);
|
| return 0;
|
| }
|
|
|
| - if (WideCharToMultiByte(CP_UTF8, 0, pstrEndpointId, -1, guid, kAdmMaxGuidSize, NULL, NULL) == 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiByte(CP_UTF8) failed with error code %d - 4", GetLastError());
|
| + if (WideCharToMultiByte(CP_UTF8, 0, pstrEndpointId, -1, guid,
|
| + kAdmMaxGuidSize, nullptr, nullptr) == 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + "WideCharToMultiByte(CP_UTF8) failed with error code %d - 4",
|
| + GetLastError());
|
| }
|
| CoTaskMemFree(pstrEndpointId);
|
|
|
| @@ -1383,19 +1386,18 @@ int32_t AudioDeviceWindowsWave::RecordingDeviceName(
|
| index = 0;
|
| }
|
|
|
| - if ((index > (nDevices-1)) || (name == NULL))
|
| - {
|
| - return -1;
|
| + if ((index > (nDevices - 1)) || (name == nullptr)) {
|
| + return -1;
|
| }
|
|
|
| memset(name, 0, kAdmMaxDeviceNameSize);
|
|
|
| - if (guid != NULL)
|
| - {
|
| - memset(guid, 0, kAdmMaxGuidSize);
|
| + if (guid != nullptr) {
|
| + memset(guid, 0, kAdmMaxGuidSize);
|
| }
|
|
|
| - WAVEINCAPSW caps; // szPname member (product name (NULL terminated) is a WCHAR
|
| + WAVEINCAPSW
|
| + caps; // szPname member (product name (nullptr terminated) is a WCHAR
|
| MMRESULT res;
|
|
|
| res = waveInGetDevCapsW(index, &caps, sizeof(WAVEINCAPSW));
|
| @@ -1404,14 +1406,15 @@ int32_t AudioDeviceWindowsWave::RecordingDeviceName(
|
| WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveInGetDevCapsW() failed (err=%d)", res);
|
| return -1;
|
| }
|
| - if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, name, kAdmMaxDeviceNameSize, NULL, NULL) == 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiByte(CP_UTF8) failed with error code %d - 1", GetLastError());
|
| + if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, name,
|
| + kAdmMaxDeviceNameSize, nullptr, nullptr) == 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + "WideCharToMultiByte(CP_UTF8) failed with error code %d - 1",
|
| + GetLastError());
|
| }
|
|
|
| - if (guid == NULL)
|
| - {
|
| - return 0;
|
| + if (guid == nullptr) {
|
| + return 0;
|
| }
|
|
|
| // It is possible to get the unique endpoint ID string using the Wave API.
|
| @@ -1421,25 +1424,28 @@ int32_t AudioDeviceWindowsWave::RecordingDeviceName(
|
|
|
| // Get the size (including the terminating null) of the endpoint ID string of the waveOut device.
|
| // Windows Vista supports the DRV_QUERYFUNCTIONINSTANCEIDSIZE and DRV_QUERYFUNCTIONINSTANCEID messages.
|
| - res = waveInMessage((HWAVEIN)IntToPtr(index),
|
| - DRV_QUERYFUNCTIONINSTANCEIDSIZE,
|
| - (DWORD_PTR)&cbEndpointId, NULL);
|
| + res =
|
| + waveInMessage((HWAVEIN)IntToPtr(index), DRV_QUERYFUNCTIONINSTANCEIDSIZE,
|
| + (DWORD_PTR)&cbEndpointId, NULL);
|
| if (res != MMSYSERR_NOERROR)
|
| {
|
| // DRV_QUERYFUNCTIONINSTANCEIDSIZE is not supported <=> earlier version of Windows than Vista
|
| WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "waveInMessage(DRV_QUERYFUNCTIONINSTANCEIDSIZE) failed (err=%d)", res);
|
| TraceWaveInError(res);
|
| // Best we can do is to copy the friendly name and use it as guid
|
| - if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, guid, kAdmMaxGuidSize, NULL, NULL) == 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiByte(CP_UTF8) failed with error code %d - 2", GetLastError());
|
| + if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, guid,
|
| + kAdmMaxGuidSize, nullptr, nullptr) == 0) {
|
| + WEBRTC_TRACE(
|
| + kTraceError, kTraceAudioDevice, _id,
|
| + "WideCharToMultiByte(CP_UTF8) failed with error code %d - 2",
|
| + GetLastError());
|
| }
|
| return 0;
|
| }
|
|
|
| // waveOutMessage(DRV_QUERYFUNCTIONINSTANCEIDSIZE) worked => we are on a Vista or Windows 7 device
|
|
|
| - WCHAR *pstrEndpointId = NULL;
|
| + WCHAR* pstrEndpointId = nullptr;
|
| pstrEndpointId = (WCHAR*)CoTaskMemAlloc(cbEndpointId);
|
|
|
| // Get the endpoint ID string for this waveOut device.
|
| @@ -1452,17 +1458,22 @@ int32_t AudioDeviceWindowsWave::RecordingDeviceName(
|
| WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "waveInMessage(DRV_QUERYFUNCTIONINSTANCEID) failed (err=%d)", res);
|
| TraceWaveInError(res);
|
| // Best we can do is to copy the friendly name and use it as guid
|
| - if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, guid, kAdmMaxGuidSize, NULL, NULL) == 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiByte(CP_UTF8) failed with error code %d - 3", GetLastError());
|
| + if (WideCharToMultiByte(CP_UTF8, 0, caps.szPname, -1, guid,
|
| + kAdmMaxGuidSize, nullptr, nullptr) == 0) {
|
| + WEBRTC_TRACE(
|
| + kTraceError, kTraceAudioDevice, _id,
|
| + "WideCharToMultiByte(CP_UTF8) failed with error code %d - 3",
|
| + GetLastError());
|
| }
|
| CoTaskMemFree(pstrEndpointId);
|
| return 0;
|
| }
|
|
|
| - if (WideCharToMultiByte(CP_UTF8, 0, pstrEndpointId, -1, guid, kAdmMaxGuidSize, NULL, NULL) == 0)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "WideCharToMultiByte(CP_UTF8) failed with error code %d - 4", GetLastError());
|
| + if (WideCharToMultiByte(CP_UTF8, 0, pstrEndpointId, -1, guid,
|
| + kAdmMaxGuidSize, nullptr, nullptr) == 0) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + "WideCharToMultiByte(CP_UTF8) failed with error code %d - 4",
|
| + GetLastError());
|
| }
|
| CoTaskMemFree(pstrEndpointId);
|
|
|
| @@ -1615,14 +1626,13 @@ int32_t AudioDeviceWindowsWave::InitPlayout()
|
| //
|
| MMRESULT res(MMSYSERR_ERROR);
|
|
|
| - if (_hWaveOut != NULL)
|
| - {
|
| - res = waveOutClose(_hWaveOut);
|
| - if (MMSYSERR_NOERROR != res)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveOutClose() failed (err=%d)", res);
|
| - TraceWaveOutError(res);
|
| - }
|
| + if (_hWaveOut != nullptr) {
|
| + res = waveOutClose(_hWaveOut);
|
| + if (MMSYSERR_NOERROR != res) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + "waveOutClose() failed (err=%d)", res);
|
| + TraceWaveOutError(res);
|
| + }
|
| }
|
|
|
| // Set the output wave format
|
| @@ -1639,16 +1649,18 @@ int32_t AudioDeviceWindowsWave::InitPlayout()
|
|
|
| // Open the given waveform-audio output device for playout
|
| //
|
| - HWAVEOUT hWaveOut(NULL);
|
| + HWAVEOUT hWaveOut(nullptr);
|
|
|
| if (IsUsingOutputDeviceIndex())
|
| {
|
| // verify settings first
|
| - res = waveOutOpen(NULL, _outputDeviceIndex, &waveFormat, 0, 0, CALLBACK_NULL | WAVE_FORMAT_QUERY);
|
| + res = waveOutOpen(nullptr, _outputDeviceIndex, &waveFormat, 0, 0,
|
| + CALLBACK_NULL | WAVE_FORMAT_QUERY);
|
| if (MMSYSERR_NOERROR == res)
|
| {
|
| // open the given waveform-audio output device for recording
|
| - res = waveOutOpen(&hWaveOut, _outputDeviceIndex, &waveFormat, 0, 0, CALLBACK_NULL);
|
| + res = waveOutOpen(&hWaveOut, _outputDeviceIndex, &waveFormat, 0, 0,
|
| + CALLBACK_NULL);
|
| WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening output device corresponding to device ID %u", _outputDeviceIndex);
|
| }
|
| }
|
| @@ -1657,28 +1669,37 @@ int32_t AudioDeviceWindowsWave::InitPlayout()
|
| if (_outputDevice == AudioDeviceModule::kDefaultCommunicationDevice)
|
| {
|
| // check if it is possible to open the default communication device (supported on Windows 7)
|
| - res = waveOutOpen(NULL, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NULL | WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE | WAVE_FORMAT_QUERY);
|
| + res = waveOutOpen(nullptr, WAVE_MAPPER, &waveFormat, 0, 0,
|
| + CALLBACK_NULL |
|
| + WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE |
|
| + WAVE_FORMAT_QUERY);
|
| if (MMSYSERR_NOERROR == res)
|
| {
|
| // if so, open the default communication device for real
|
| - res = waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NULL | WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE);
|
| + res = waveOutOpen(
|
| + &hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0,
|
| + CALLBACK_NULL | WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE);
|
| WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening default communication device");
|
| }
|
| else
|
| {
|
| // use default device since default communication device was not avaliable
|
| - res = waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NULL);
|
| + res = waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0,
|
| + CALLBACK_NULL);
|
| WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "unable to open default communication device => using default instead");
|
| }
|
| }
|
| else if (_outputDevice == AudioDeviceModule::kDefaultDevice)
|
| {
|
| // open default device since it has been requested
|
| - res = waveOutOpen(NULL, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NULL | WAVE_FORMAT_QUERY);
|
| + res = waveOutOpen(nullptr, WAVE_MAPPER, &waveFormat, 0, 0,
|
| + CALLBACK_NULL | WAVE_FORMAT_QUERY);
|
| if (MMSYSERR_NOERROR == res)
|
| {
|
| - res = waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NULL);
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening default output device");
|
| + res = waveOutOpen(&hWaveOut, WAVE_MAPPER, &waveFormat, 0, 0,
|
| + CALLBACK_NULL);
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| + "opening default output device");
|
| }
|
| }
|
| }
|
| @@ -1814,14 +1835,13 @@ int32_t AudioDeviceWindowsWave::InitRecording()
|
| //
|
| MMRESULT res(MMSYSERR_ERROR);
|
|
|
| - if (_hWaveIn != NULL)
|
| - {
|
| - res = waveInClose(_hWaveIn);
|
| - if (MMSYSERR_NOERROR != res)
|
| - {
|
| - WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "waveInClose() failed (err=%d)", res);
|
| - TraceWaveInError(res);
|
| - }
|
| + if (_hWaveIn != nullptr) {
|
| + res = waveInClose(_hWaveIn);
|
| + if (MMSYSERR_NOERROR != res) {
|
| + WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id,
|
| + "waveInClose() failed (err=%d)", res);
|
| + TraceWaveInError(res);
|
| + }
|
| }
|
|
|
| // Set the input wave format
|
| @@ -1838,16 +1858,18 @@ int32_t AudioDeviceWindowsWave::InitRecording()
|
|
|
| // Open the given waveform-audio input device for recording
|
| //
|
| - HWAVEIN hWaveIn(NULL);
|
| + HWAVEIN hWaveIn(nullptr);
|
|
|
| if (IsUsingInputDeviceIndex())
|
| {
|
| // verify settings first
|
| - res = waveInOpen(NULL, _inputDeviceIndex, &waveFormat, 0, 0, CALLBACK_NULL | WAVE_FORMAT_QUERY);
|
| + res = waveInOpen(nullptr, _inputDeviceIndex, &waveFormat, 0, 0,
|
| + CALLBACK_NULL | WAVE_FORMAT_QUERY);
|
| if (MMSYSERR_NOERROR == res)
|
| {
|
| // open the given waveform-audio input device for recording
|
| - res = waveInOpen(&hWaveIn, _inputDeviceIndex, &waveFormat, 0, 0, CALLBACK_NULL);
|
| + res = waveInOpen(&hWaveIn, _inputDeviceIndex, &waveFormat, 0, 0,
|
| + CALLBACK_NULL);
|
| WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening input device corresponding to device ID %u", _inputDeviceIndex);
|
| }
|
| }
|
| @@ -1856,28 +1878,37 @@ int32_t AudioDeviceWindowsWave::InitRecording()
|
| if (_inputDevice == AudioDeviceModule::kDefaultCommunicationDevice)
|
| {
|
| // check if it is possible to open the default communication device (supported on Windows 7)
|
| - res = waveInOpen(NULL, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NULL | WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE | WAVE_FORMAT_QUERY);
|
| + res = waveInOpen(nullptr, WAVE_MAPPER, &waveFormat, 0, 0,
|
| + CALLBACK_NULL |
|
| + WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE |
|
| + WAVE_FORMAT_QUERY);
|
| if (MMSYSERR_NOERROR == res)
|
| {
|
| // if so, open the default communication device for real
|
| - res = waveInOpen(&hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NULL | WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE);
|
| + res = waveInOpen(
|
| + &hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0,
|
| + CALLBACK_NULL | WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE);
|
| WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening default communication device");
|
| }
|
| else
|
| {
|
| // use default device since default communication device was not avaliable
|
| - res = waveInOpen(&hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NULL);
|
| + res = waveInOpen(&hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0,
|
| + CALLBACK_NULL);
|
| WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "unable to open default communication device => using default instead");
|
| }
|
| }
|
| else if (_inputDevice == AudioDeviceModule::kDefaultDevice)
|
| {
|
| // open default device since it has been requested
|
| - res = waveInOpen(NULL, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NULL | WAVE_FORMAT_QUERY);
|
| + res = waveInOpen(nullptr, WAVE_MAPPER, &waveFormat, 0, 0,
|
| + CALLBACK_NULL | WAVE_FORMAT_QUERY);
|
| if (MMSYSERR_NOERROR == res)
|
| {
|
| - res = waveInOpen(&hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0, CALLBACK_NULL);
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "opening default input device");
|
| + res = waveInOpen(&hWaveIn, WAVE_MAPPER, &waveFormat, 0, 0,
|
| + CALLBACK_NULL);
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| + "opening default input device");
|
| }
|
| }
|
| }
|
| @@ -1981,9 +2012,8 @@ int32_t AudioDeviceWindowsWave::StopRecording()
|
| return 0;
|
| }
|
|
|
| - if (_hWaveIn == NULL)
|
| - {
|
| - return -1;
|
| + if (_hWaveIn == nullptr) {
|
| + return -1;
|
| }
|
|
|
| bool wasRecording = _recording;
|
| @@ -2041,10 +2071,11 @@ int32_t AudioDeviceWindowsWave::StopRecording()
|
| TraceWaveInError(res);
|
| }
|
|
|
| - // Set the wave input handle to NULL
|
| + // Set the wave input handle to null
|
| //
|
| - _hWaveIn = NULL;
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "_hWaveIn is now set to NULL");
|
| + _hWaveIn = nullptr;
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| + "_hWaveIn is now set to null");
|
|
|
| return 0;
|
| }
|
| @@ -2132,9 +2163,8 @@ int32_t AudioDeviceWindowsWave::StopPlayout()
|
| return 0;
|
| }
|
|
|
| - if (_hWaveOut == NULL)
|
| - {
|
| - return -1;
|
| + if (_hWaveOut == nullptr) {
|
| + return -1;
|
| }
|
|
|
| _playIsInitialized = false;
|
| @@ -2185,8 +2215,9 @@ int32_t AudioDeviceWindowsWave::StopPlayout()
|
| TraceWaveOutError(res);
|
| }
|
|
|
| - _hWaveOut = NULL;
|
| - WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "_hWaveOut is now set to NULL");
|
| + _hWaveOut = nullptr;
|
| + WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id,
|
| + "_hWaveOut is now set to null");
|
|
|
| return 0;
|
| }
|
| @@ -2350,10 +2381,10 @@ void AudioDeviceWindowsWave::ClearRecordingError()
|
|
|
| int32_t AudioDeviceWindowsWave::InputSanityCheckAfterUnlockedPeriod() const
|
| {
|
| - if (_hWaveIn == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "input state has been modified during unlocked period");
|
| - return -1;
|
| + if (_hWaveIn == nullptr) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + "input state has been modified during unlocked period");
|
| + return -1;
|
| }
|
| return 0;
|
| }
|
| @@ -2364,10 +2395,10 @@ int32_t AudioDeviceWindowsWave::InputSanityCheckAfterUnlockedPeriod() const
|
|
|
| int32_t AudioDeviceWindowsWave::OutputSanityCheckAfterUnlockedPeriod() const
|
| {
|
| - if (_hWaveOut == NULL)
|
| - {
|
| - WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id, "output state has been modified during unlocked period");
|
| - return -1;
|
| + if (_hWaveOut == nullptr) {
|
| + WEBRTC_TRACE(kTraceError, kTraceAudioDevice, _id,
|
| + "output state has been modified during unlocked period");
|
| + return -1;
|
| }
|
| return 0;
|
| }
|
| @@ -2558,9 +2589,8 @@ int32_t AudioDeviceWindowsWave::PrepareStartPlayout()
|
|
|
| CriticalSectionScoped lock(&_critSect);
|
|
|
| - if (_hWaveOut == NULL)
|
| - {
|
| - return -1;
|
| + if (_hWaveOut == nullptr) {
|
| + return -1;
|
| }
|
|
|
| // A total of 30ms of data is immediately placed in the SC buffer
|
| @@ -2595,9 +2625,8 @@ int32_t AudioDeviceWindowsWave::PrepareStartRecording()
|
|
|
| CriticalSectionScoped lock(&_critSect);
|
|
|
| - if (_hWaveIn == NULL)
|
| - {
|
| - return -1;
|
| + if (_hWaveIn == nullptr) {
|
| + return -1;
|
| }
|
|
|
| _playAcc = 0;
|
| @@ -3518,9 +3547,8 @@ int AudioDeviceWindowsWave::PlayProc(LONGLONG& consumedTime)
|
|
|
| int32_t AudioDeviceWindowsWave::Write(int8_t* data, uint16_t nSamples)
|
| {
|
| - if (_hWaveOut == NULL)
|
| - {
|
| - return -1;
|
| + if (_hWaveOut == nullptr) {
|
| + return -1;
|
| }
|
|
|
| if (_playIsInitialized)
|
|
|