From f69bd5f184ccb7169be5237ec956887ca48af6a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Tue, 20 Aug 2019 16:58:49 +0200 Subject: [PATCH] Delete AudioDeviceWindowsCore::WideToUTF8, replaced with rtc::ToUtf8 Bug: None Change-Id: I4152693622cc27a73ccd8526216d78532e110698 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/149837 Reviewed-by: Henrik Andreassson Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/master@{#28927} --- .../audio_device/win/audio_device_core_win.cc | 20 +------------------ .../audio_device/win/audio_device_core_win.h | 6 ------ 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/modules/audio_device/win/audio_device_core_win.cc b/modules/audio_device/win/audio_device_core_win.cc index 0d5ceff000..f95e1f08d2 100644 --- a/modules/audio_device/win/audio_device_core_win.cc +++ b/modules/audio_device/win/audio_device_core_win.cc @@ -4177,25 +4177,7 @@ void AudioDeviceWindowsCore::_TraceCOMError(HRESULT hr) const { RTC_LOG(LS_ERROR) << "Core Audio method failed (hr=" << hr << ")"; StringCchPrintfW(buf, MAXERRORLENGTH, L"Error details: "); StringCchCatW(buf, MAXERRORLENGTH, errorText); - RTC_LOG(LS_ERROR) << WideToUTF8(buf); -} - -// ---------------------------------------------------------------------------- -// WideToUTF8 -// ---------------------------------------------------------------------------- - -char* AudioDeviceWindowsCore::WideToUTF8(const wchar_t* src) const { - const size_t kStrLen = sizeof(_str); - memset(_str, 0, kStrLen); - // Get required size (in bytes) to be able to complete the conversion. - unsigned int required_size = - (unsigned int)WideCharToMultiByte(CP_UTF8, 0, src, -1, _str, 0, 0, 0); - if (required_size <= kStrLen) { - // Process the entire input string, including the terminating null char. - if (WideCharToMultiByte(CP_UTF8, 0, src, -1, _str, kStrLen, 0, 0) == 0) - memset(_str, 0, kStrLen); - } - return _str; + RTC_LOG(LS_ERROR) << rtc::ToUtf8(buf); } bool AudioDeviceWindowsCore::KeyPressed() const { diff --git a/modules/audio_device/win/audio_device_core_win.h b/modules/audio_device/win/audio_device_core_win.h index 6ae5988db4..81db3d8bc4 100644 --- a/modules/audio_device/win/audio_device_core_win.h +++ b/modules/audio_device/win/audio_device_core_win.h @@ -233,10 +233,6 @@ class AudioDeviceWindowsCore : public AudioDeviceGeneric { int32_t _GetDefaultDevice(EDataFlow dir, ERole role, IMMDevice** ppDevice); int32_t _GetListDevice(EDataFlow dir, int index, IMMDevice** ppDevice); - // Converts from wide-char to UTF-8 if UNICODE is defined. - // Does nothing if UNICODE is undefined. - char* WideToUTF8(const wchar_t* src) const; - int32_t InitRecordingDMO(); ScopedCOMInitializer _comInit; @@ -310,8 +306,6 @@ class AudioDeviceWindowsCore : public AudioDeviceGeneric { AudioDeviceModule::WindowsDeviceType _outputDevice; uint16_t _inputDeviceIndex; uint16_t _outputDeviceIndex; - - mutable char _str[512]; }; #endif // #if (_MSC_VER >= 1400)