From 1ce61c57c06d34bee3a25cb14143ae76e108e06d Mon Sep 17 00:00:00 2001 From: jpark37 Date: Thu, 10 Oct 2019 19:03:18 -0700 Subject: [PATCH 1/2] win-capture: Fix extra duplicator refs Make duplicator_capture_tick the sole creater, and reference adder of IDXGIOutputDuplication objects. This prevents a situation where duplicator_capture::showing cause be false while duplicator_capture::duplicator was not null at startup on background scenes, preventing IDXGIOutputDuplication from being recreated when DXGI_ERROR_ACCESS_LOST. --- plugins/win-capture/duplicator-monitor-capture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/win-capture/duplicator-monitor-capture.c b/plugins/win-capture/duplicator-monitor-capture.c index 2b4e2ce84..0efd48a99 100644 --- a/plugins/win-capture/duplicator-monitor-capture.c +++ b/plugins/win-capture/duplicator-monitor-capture.c @@ -52,7 +52,7 @@ static inline void update_settings(struct duplicator_capture *capture, obs_enter_graphics(); gs_duplicator_destroy(capture->duplicator); - capture->duplicator = gs_duplicator_create(capture->monitor); + capture->duplicator = NULL; capture->width = 0; capture->height = 0; capture->x = 0; From 471d752d7567111a9975d2e96f32ed5ea3559b90 Mon Sep 17 00:00:00 2001 From: jpark37 Date: Thu, 10 Oct 2019 19:13:10 -0700 Subject: [PATCH 2/2] libobs-d3d11: Use unordered_map for duplicator collection Not in love with STL, but lets at least use the semantically-correct collection. It's also a shame this is a global variable with gross pre-main allocations, but attaching it to the device instance would break the interface. --- libobs-d3d11/d3d11-duplicator.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libobs-d3d11/d3d11-duplicator.cpp b/libobs-d3d11/d3d11-duplicator.cpp index 231662619..844a86c9a 100644 --- a/libobs-d3d11/d3d11-duplicator.cpp +++ b/libobs-d3d11/d3d11-duplicator.cpp @@ -16,7 +16,7 @@ ******************************************************************************/ #include "d3d11-subsystem.hpp" -#include +#include static inline bool get_monitor(gs_device_t *device, int monitor_idx, IDXGIOutput **dxgiOutput) @@ -122,11 +122,11 @@ EXPORT bool device_get_duplicator_monitor_info(gs_device_t *device, return true; } -static std::map instances; +static std::unordered_map instances; void reset_duplicators(void) { - for (auto &pair : instances) { + for (std::pair &pair : instances) { pair.second->updated = false; } } @@ -136,7 +136,7 @@ EXPORT gs_duplicator_t *device_duplicator_create(gs_device_t *device, { gs_duplicator *duplicator = nullptr; - auto it = instances.find(monitor_idx); + const auto it = instances.find(monitor_idx); if (it != instances.end()) { duplicator = it->second; duplicator->refs++;