d3d12screencapturesrc: Fix desktop handle leak
Calling CloseDesktop() on a handle that is currently in use will fail. Close the handle after current desktop handle change Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9136>
This commit is contained in:
parent
e2f54cc405
commit
d5dfa3ef5e
@ -429,13 +429,13 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HDESK hdesk = OpenInputDesktop (0, FALSE, GENERIC_ALL);
|
auto prev_hdesk = GetThreadDesktop (GetCurrentThreadId ());
|
||||||
|
auto hdesk = OpenInputDesktop (0, FALSE, GENERIC_ALL);
|
||||||
if (hdesk) {
|
if (hdesk) {
|
||||||
if (!SetThreadDesktop (hdesk)) {
|
if (!SetThreadDesktop (hdesk)) {
|
||||||
GST_WARNING ("SetThreadDesktop() failed, error %lu", GetLastError());
|
GST_WARNING ("SetThreadDesktop() failed, error %lu", GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseDesktop (hdesk);
|
|
||||||
} else {
|
} else {
|
||||||
GST_WARNING ("OpenInputDesktop() failed, error %lu", GetLastError());
|
GST_WARNING ("OpenInputDesktop() failed, error %lu", GetLastError());
|
||||||
}
|
}
|
||||||
@ -469,6 +469,12 @@ public:
|
|||||||
if (FAILED (hr))
|
if (FAILED (hr))
|
||||||
hr = output1->DuplicateOutput(device, &dupl_);
|
hr = output1->DuplicateOutput(device, &dupl_);
|
||||||
|
|
||||||
|
if (prev_hdesk)
|
||||||
|
SetThreadDesktop (prev_hdesk);
|
||||||
|
|
||||||
|
if (hdesk)
|
||||||
|
CloseDesktop (hdesk);
|
||||||
|
|
||||||
if (FAILED (hr)) {
|
if (FAILED (hr)) {
|
||||||
if (hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE) {
|
if (hr == DXGI_ERROR_NOT_CURRENTLY_AVAILABLE) {
|
||||||
GST_ERROR ("Hit the max allowed number of Desktop Duplication session");
|
GST_ERROR ("Hit the max allowed number of Desktop Duplication session");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user