USB: dshow: Initialize multi-threaded COM libs

This commit is contained in:
jackun 2021-09-29 19:15:12 +03:00 committed by lightningterror
parent c3c15a95c4
commit 42d730c80f
2 changed files with 6 additions and 1 deletions

View File

@ -467,7 +467,6 @@ namespace usb_eyetoy
pSourceConfig = nullptr;
samplegrabber = nullptr;
callbackhandler = new CallbackHandler();
CoInitialize(NULL);
mpeg_buffer.start = calloc(1, 640 * 480 * 2);
}
@ -479,6 +478,8 @@ namespace usb_eyetoy
int DirectShow::Open(int width, int height, FrameFormat format, int mirror)
{
dshowCoInitialize = wil::CoInitializeEx_failfast(COINIT_MULTITHREADED);
frame_width = width;
frame_height = height;
frame_format = format;
@ -520,6 +521,7 @@ namespace usb_eyetoy
safe_release(pGraphBuilder);
safe_release(pGraph);
safe_release(pControl);
dshowCoInitialize.reset();
return 0;
};

View File

@ -21,6 +21,8 @@
#include <windows.h>
#include <dshow.h>
#include <wil/com.h>
extern "C" {
extern GUID IID_ISampleGrabberCB;
extern GUID CLSID_SampleGrabber;
@ -109,6 +111,7 @@ namespace usb_eyetoy
private:
int mPort;
wil::unique_couninitialize_call dshowCoInitialize;
ICaptureGraphBuilder2* pGraphBuilder;
IFilterGraph2* pGraph;
IMediaControl* pControl;