mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
mfvideosrc: Only device activation needs to be running on UI thread
... and the other operations does not have the thread constraint. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1466>
This commit is contained in:
parent
502aea3969
commit
6d960781fc
2 changed files with 4 additions and 85 deletions
|
@ -424,19 +424,7 @@ HRESULT
|
|||
MediaCaptureWrapper::EnumrateFrameSourceGroup
|
||||
(std::vector<GstWinRTMediaFrameSourceGroup> &group_list)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if (dispatcher_) {
|
||||
hr = runOnUIThread (INFINITE,
|
||||
[this, &group_list] {
|
||||
return enumrateFrameSourceGroup(group_list);
|
||||
});
|
||||
|
||||
} else {
|
||||
hr = enumrateFrameSourceGroup(group_list);
|
||||
}
|
||||
|
||||
return hr;
|
||||
return enumrateFrameSourceGroup (group_list);
|
||||
}
|
||||
|
||||
HRESULT
|
||||
|
@ -490,39 +478,17 @@ MediaCaptureWrapper::StartCapture()
|
|||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
hr = openMediaCapture();
|
||||
hr = openMediaCapture ();
|
||||
if (!gst_mf_result (hr))
|
||||
return hr;
|
||||
|
||||
if (dispatcher_) {
|
||||
hr = runOnUIThread (INFINITE,
|
||||
[this] {
|
||||
return startCapture();
|
||||
});
|
||||
|
||||
} else {
|
||||
hr = startCapture();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
return startCapture ();
|
||||
}
|
||||
|
||||
HRESULT
|
||||
MediaCaptureWrapper::StopCapture()
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if (dispatcher_) {
|
||||
hr = runOnUIThread (INFINITE,
|
||||
[this] {
|
||||
return stopCapture();
|
||||
});
|
||||
|
||||
} else {
|
||||
hr = stopCapture();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
return stopCapture ();
|
||||
}
|
||||
|
||||
HRESULT
|
||||
|
|
|
@ -164,53 +164,6 @@ private:
|
|||
HRESULT onCaptureFailed(IMediaCapture *capture,
|
||||
IMediaCaptureFailedEventArgs *args);
|
||||
static HRESULT enumrateFrameSourceGroup(std::vector<GstWinRTMediaFrameSourceGroup> &list);
|
||||
|
||||
template <typename CB>
|
||||
HRESULT runOnUIThread(DWORD timeout, CB && cb)
|
||||
{
|
||||
ComPtr<IAsyncAction> asyncAction;
|
||||
HRESULT hr;
|
||||
HRESULT hr_callback;
|
||||
boolean can_now;
|
||||
DWORD wait_ret;
|
||||
|
||||
if (!dispatcher_)
|
||||
return cb();
|
||||
|
||||
hr = dispatcher_->get_HasThreadAccess (&can_now);
|
||||
|
||||
if (FAILED (hr))
|
||||
return hr;
|
||||
|
||||
if (can_now)
|
||||
return cb ();
|
||||
|
||||
Event event (CreateEventEx (NULL, NULL, CREATE_EVENT_MANUAL_RESET,
|
||||
EVENT_ALL_ACCESS));
|
||||
|
||||
if (!event.IsValid())
|
||||
return E_FAIL;
|
||||
|
||||
auto handler =
|
||||
Callback<Implements<RuntimeClassFlags<ClassicCom>,
|
||||
IDispatchedHandler, FtmBase>>([&hr_callback, &cb, &event] {
|
||||
hr_callback = cb ();
|
||||
SetEvent (event.Get());
|
||||
return S_OK;
|
||||
});
|
||||
|
||||
hr = dispatcher_->RunAsync(CoreDispatcherPriority_Normal,
|
||||
handler.Get(), &asyncAction);
|
||||
|
||||
if (FAILED (hr))
|
||||
return hr;
|
||||
|
||||
wait_ret = WaitForSingleObject(event.Get(), timeout);
|
||||
if (wait_ret != WAIT_OBJECT_0)
|
||||
return E_FAIL;
|
||||
|
||||
return hr_callback;
|
||||
}
|
||||
};
|
||||
|
||||
HRESULT
|
||||
|
|
Loading…
Reference in a new issue