Always reset the thread desktop before calling DuplicateOutput()
Otherwise capture will fail if the thread desktop is different than the current input desktop (ex: UAC secure desktop is active)
This commit is contained in:
parent
8a86678d62
commit
f64712f277
2 changed files with 31 additions and 4 deletions
|
|
@ -52,6 +52,23 @@ set_gpu_preference(int preference) {
|
|||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
syncThreadDesktop() {
|
||||
auto hDesk = OpenInputDesktop(DF_ALLOWOTHERACCOUNTHOOK, FALSE, GENERIC_ALL);
|
||||
if (!hDesk) {
|
||||
auto err = GetLastError();
|
||||
std::cout << "Failed to Open Input Desktop [0x"sv << util::hex(err).to_string_view() << ']' << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SetThreadDesktop(hDesk)) {
|
||||
auto err = GetLastError();
|
||||
std::cout << "Failed to sync desktop to thread [0x"sv << util::hex(err).to_string_view() << ']' << std::endl;
|
||||
}
|
||||
|
||||
CloseDesktop(hDesk);
|
||||
}
|
||||
|
||||
HRESULT
|
||||
test_dxgi_duplication(dxgi::adapter_t &adapter, dxgi::output_t &output) {
|
||||
D3D_FEATURE_LEVEL featureLevels[] {
|
||||
|
|
@ -87,6 +104,9 @@ test_dxgi_duplication(dxgi::adapter_t &adapter, dxgi::output_t &output) {
|
|||
return status;
|
||||
}
|
||||
|
||||
// Ensure we can duplicate the current display
|
||||
syncThreadDesktop();
|
||||
|
||||
// Return the result of DuplicateOutput() to Sunshine
|
||||
dxgi::dup_t dup;
|
||||
return output1->DuplicateOutput((IUnknown *) device.get(), &dup);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue