mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 13:08:50 +02:00
Revert "win-capture: Allow window capturing of current process"
This reverts commit 8d520b970d
.
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.
This commit is contained in:
parent
8d520b970d
commit
2707f05c46
@ -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);
|
||||
|
@ -1,7 +1,6 @@
|
||||
#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,
|
||||
|
Loading…
Reference in New Issue
Block a user