提交 2707f05c 编写于 作者: J jp9000

Revert "win-capture: Allow window capturing of current process"

This reverts commit 8d520b97.

This can actually cause a hard lock due to the windows API when
destroying window capture.  When the graphics thread locks the source
list for doing tick or render, and then the UI thread tries to destroy a
source, the UI thread will wait for the graphics thread to complete
rendering/ticking of sources.  The video_tick of window capture would
then check windows in the same process and try to query the window's
name via GetWindowText.  However, GetWindowText is synchronous, and will
not return until the window event has been processed by the UI thread,
so it will perpetually lock because the two threads are waiting for each
other to finish.
上级 8d520b97
......@@ -1579,7 +1579,7 @@ static obs_properties_t *game_capture_properties(void *data)
p = obs_properties_add_list(ppts, SETTING_CAPTURE_WINDOW, TEXT_WINDOW,
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
obs_property_list_add_string(p, "", "");
fill_window_list(p, INCLUDE_MINIMIZED, false);
fill_window_list(p, INCLUDE_MINIMIZED);
obs_property_set_modified_callback(p, window_changed_callback);
......
......@@ -118,7 +118,7 @@ static obs_properties_t *wc_properties(void *unused)
p = obs_properties_add_list(ppts, "window", TEXT_WINDOW,
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
fill_window_list(p, EXCLUDE_MINIMIZED, true);
fill_window_list(p, EXCLUDE_MINIMIZED);
p = obs_properties_add_list(ppts, "priority", TEXT_MATCH_PRIORITY,
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
......
#define PSAPI_VERSION 1
#include <obs.h>
#include <util/dstr.h>
#include <util/darray.h>
#include <windows.h>
#include <psapi.h>
......@@ -68,13 +67,6 @@ static inline HANDLE open_process(DWORD desired_access, bool inherit_handle,
return open_process_proc(desired_access, inherit_handle, process_id);
}
static inline bool is_self(HWND window)
{
DWORD id;
GetWindowThreadProcessId(window, &id);
return id == GetCurrentProcessId();
}
bool get_window_exe(struct dstr *name, HWND window)
{
wchar_t wname[MAX_PATH];
......@@ -85,6 +77,8 @@ bool get_window_exe(struct dstr *name, HWND window)
DWORD id;
GetWindowThreadProcessId(window, &id);
if (id == GetCurrentProcessId())
return false;
process = open_process(PROCESS_QUERY_LIMITED_INFORMATION, false, id);
if (!process)
......@@ -210,29 +204,14 @@ static inline HWND first_window(enum window_search_mode mode)
return window;
}
void fill_window_list(obs_property_t *p, enum window_search_mode mode,
bool allow_self)
void fill_window_list(obs_property_t *p, enum window_search_mode mode)
{
HWND window = first_window(mode);
DARRAY(HWND) process_windows;
da_init(process_windows);
while (window) {
if (is_self(window))
da_push_back(process_windows, &window);
else
add_window(p, window);
add_window(p, window);
window = next_window(window, mode);
}
if (allow_self) {
for (size_t i = 0; i < process_windows.num; i++)
add_window(p, process_windows.array[i]);
}
da_free(process_windows);
}
static int window_rating(HWND window,
......
......@@ -15,8 +15,7 @@ enum window_search_mode {
extern bool get_window_exe(struct dstr *name, HWND window);
extern void fill_window_list(obs_property_t *p, enum window_search_mode mode,
bool allow_self);
extern void fill_window_list(obs_property_t *p, enum window_search_mode mode);
extern void build_window_strings(const char *str,
char **class,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册