mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-15 03:20:00 +01:00
avfilter/vsrc_gfxcapture: keep cbdata object alive
Depending on the threading backend the stdlib uses, creating a mutex/condvar can be quite expensive. So keep this object alive in the ctx, on which we synchronize via the uninit mutex anyway.
This commit is contained in:
@@ -149,6 +149,7 @@ struct GfxCaptureContextCpp {
|
|||||||
volatile int wgc_thread_init_res { INT_MAX };
|
volatile int wgc_thread_init_res { INT_MAX };
|
||||||
std::recursive_mutex wgc_thread_uninit_mutex;
|
std::recursive_mutex wgc_thread_uninit_mutex;
|
||||||
volatile int wgc_thread_res { 0 };
|
volatile int wgc_thread_res { 0 };
|
||||||
|
std::shared_ptr<void> wgc_thread_cb_data;
|
||||||
|
|
||||||
HWND capture_hwnd { nullptr };
|
HWND capture_hwnd { nullptr };
|
||||||
HMONITOR capture_hmonitor { nullptr };
|
HMONITOR capture_hmonitor { nullptr };
|
||||||
@@ -716,11 +717,17 @@ static int run_on_wgc_thread(AVFilterContext *avctx, F &&cb)
|
|||||||
struct CBData {
|
struct CBData {
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
std::condition_variable cond;
|
std::condition_variable cond;
|
||||||
bool done { false };
|
bool done;
|
||||||
bool cancel { false };
|
bool cancel;
|
||||||
int ret { AVERROR_BUG };
|
int ret;
|
||||||
};
|
};
|
||||||
auto cbdata = std::make_shared<CBData>();
|
auto cbdata = ctx->wgc_thread_cb_data ?
|
||||||
|
std::static_pointer_cast<CBData>(ctx->wgc_thread_cb_data) :
|
||||||
|
std::make_shared<CBData>();
|
||||||
|
ctx->wgc_thread_cb_data = cbdata;
|
||||||
|
|
||||||
|
cbdata->done = cbdata->cancel = false;
|
||||||
|
cbdata->ret = AVERROR_BUG;
|
||||||
|
|
||||||
boolean res = 0;
|
boolean res = 0;
|
||||||
CHECK_HR_RET(wgctx->dispatcher_queue->TryEnqueue(
|
CHECK_HR_RET(wgctx->dispatcher_queue->TryEnqueue(
|
||||||
|
|||||||
Reference in New Issue
Block a user