mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
osd/windows: Create single-threaded COM apartment on main thread.
This commit is contained in:
parent
8994dbb3f6
commit
4a18756e4f
@ -126,7 +126,7 @@ void choose_image(device_image_interface &device, HWND owner, REFCLSID class_id,
|
||||
|
||||
// create file dialog
|
||||
Microsoft::WRL::ComPtr<IFileDialog> dialog;
|
||||
hr = CoCreateInstance(class_id, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(dialog.GetAddressOf()));
|
||||
hr = CoCreateInstance(class_id, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&dialog));
|
||||
|
||||
// set file types
|
||||
if (SUCCEEDED(hr))
|
||||
@ -159,7 +159,7 @@ void choose_image(device_image_interface &device, HWND owner, REFCLSID class_id,
|
||||
// FIXME: strip off archive names - opening a file inside an archive decompresses it to a temporary location
|
||||
std::wstring wfull = osd::text::to_wstring(full);
|
||||
Microsoft::WRL::ComPtr<IShellItem> item;
|
||||
if (SUCCEEDED(SHCreateItemFromParsingName(wfull.c_str(), nullptr, IID_PPV_ARGS(item.GetAddressOf()))))
|
||||
if (SUCCEEDED(SHCreateItemFromParsingName(wfull.c_str(), nullptr, IID_PPV_ARGS(&item))))
|
||||
{
|
||||
//dialog->SetFolder(item); disabled until
|
||||
}
|
||||
@ -176,7 +176,7 @@ void choose_image(device_image_interface &device, HWND owner, REFCLSID class_id,
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
Microsoft::WRL::ComPtr<IShellItem> result;
|
||||
hr = dialog->GetResult(result.GetAddressOf());
|
||||
hr = dialog->GetResult(&result);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
PWSTR selection = nullptr;
|
||||
|
@ -288,29 +288,6 @@ private:
|
||||
{
|
||||
xinput_deviceids.clear();
|
||||
|
||||
// CoInit if needed
|
||||
class com_helper
|
||||
{
|
||||
public:
|
||||
com_helper()
|
||||
{
|
||||
switch (CoInitialize(nullptr))
|
||||
{
|
||||
case S_OK:
|
||||
case S_FALSE:
|
||||
m_succeeded = true;
|
||||
}
|
||||
}
|
||||
~com_helper()
|
||||
{
|
||||
if (m_succeeded)
|
||||
CoUninitialize();
|
||||
}
|
||||
private:
|
||||
bool m_succeeded = false;
|
||||
};
|
||||
com_helper cominit;
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
// Create WMI
|
||||
|
@ -292,8 +292,6 @@ int sound_xaudio2::init(osd_interface &osd, osd_options const &options)
|
||||
m_sample_rate = options.sample_rate();
|
||||
m_audio_latency = options.audio_latency();
|
||||
|
||||
CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
||||
|
||||
// Create the IXAudio2 object
|
||||
HR_GOERR(OSD_DYNAMIC_CALL(XAudio2Create, m_xAudio2.GetAddressOf(), 0, XAUDIO2_DEFAULT_PROCESSOR));
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <mmsystem.h>
|
||||
#include <objbase.h>
|
||||
#include <tchar.h>
|
||||
#include <io.h>
|
||||
|
||||
@ -269,6 +270,7 @@ void windows_osd_interface::output_oslog(const char *buffer)
|
||||
windows_osd_interface::windows_osd_interface(windows_options &options)
|
||||
: osd_common_t(options)
|
||||
, m_options(options)
|
||||
, m_com_status(SUCCEEDED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED)))
|
||||
, m_last_event_check(std::chrono::steady_clock::time_point::min())
|
||||
{
|
||||
}
|
||||
@ -280,6 +282,8 @@ windows_osd_interface::windows_osd_interface(windows_options &options)
|
||||
|
||||
windows_osd_interface::~windows_osd_interface()
|
||||
{
|
||||
if (m_com_status)
|
||||
CoUninitialize();
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,7 +98,8 @@ private:
|
||||
virtual void osd_exit() override;
|
||||
static void output_oslog(const char *buffer);
|
||||
|
||||
windows_options & m_options;
|
||||
windows_options &m_options;
|
||||
bool const m_com_status;
|
||||
|
||||
std::chrono::steady_clock::time_point m_last_event_check;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user