Skip to content
Snippets Groups Projects
Verified Commit cd6bbf55 authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame :jack_o_lantern:
Browse files

fixup! Bug 41459: WebRTC fails to build under mingw (Part 2)

Reworked the _com_error conversion to string, to use functions that are
available also to mingw.
parent e3e4be18
No related branches found
No related tags found
1 merge request!694Bug 41796: Rebased on top of FIREFOX_ESR_115_BASE
......@@ -10,7 +10,9 @@
#include "modules/desktop_capture/win/desktop_capture_utils.h"
#include "rtc_base/strings/string_builder.h"
#include <cstdio>
#include <cstdlib>
#include "stringapiset.h"
namespace webrtc {
namespace desktop_capture {
......@@ -20,11 +22,16 @@ namespace utils {
std::string ComErrorToString(const _com_error& error) {
char buffer[1024];
rtc::SimpleStringBuilder string_builder(buffer);
// Use _bstr_t to simplify the wchar to char conversion for ErrorMessage().
_bstr_t error_message(error.ErrorMessage());
string_builder.AppendFormat("HRESULT: 0x%08X, Message: %s", error.Error(),
static_cast<const char*>(error_message));
return string_builder.str();
string_builder.AppendFormat("HRESULT: 0x%08X, Message: ", error.Error());
#ifdef _UNICODE
WideCharToMultiByte(CP_UTF8, 0, error.ErrorMessage(), -1,
buffer + string_builder.size(),
sizeof(buffer) - string_builder.size(), nullptr, nullptr);
buffer[sizeof(buffer) - 1] = 0;
#else
string_builder << error.ErrorMessage();
#endif
return buffer;
}
} // namespace utils
......
......@@ -11,8 +11,18 @@
#ifndef RTC_BASE_WIN_CREATE_DIRECT3D_DEVICE_H_
#define RTC_BASE_WIN_CREATE_DIRECT3D_DEVICE_H_
#include <windows.graphics.directX.direct3d11.h>
#include <windows.graphics.directx.direct3d11.h>
#ifndef __MINGW32__
# include <windows.graphics.directX.direct3d11.interop.h>
#else
# include <dxgi.h>
# include <inspectable.h>
extern "C" {
// This function is only used in decltype(..)
HRESULT __stdcall CreateDirect3D11DeviceFromDXGIDevice(
::IDXGIDevice* dxgiDevice, ::IInspectable** graphicsDevice);
}
#endif
#include <winerror.h>
#include <wrl/client.h>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment