obs-studio/plugins/win-capture/hook-helpers.h
jp9000 f53df7da64 clang-format: Apply formatting
Code submissions have continually suffered from formatting
inconsistencies that constantly have to be addressed.  Using
clang-format simplifies this by making code formatting more consistent,
and allows automation of the code formatting so that maintainers can
focus more on the code itself instead of code formatting.
2019-06-23 23:49:10 -07:00

51 lines
1.1 KiB
C

#pragma once
#if !defined(__cplusplus) && !defined(inline)
#define inline __inline
#endif
#define GC_EVENT_FLAGS (EVENT_MODIFY_STATE | SYNCHRONIZE)
#define GC_MUTEX_FLAGS (SYNCHRONIZE)
static inline HANDLE create_event(const wchar_t *name)
{
return CreateEventW(NULL, false, false, name);
}
static inline HANDLE open_event(const wchar_t *name)
{
return OpenEventW(GC_EVENT_FLAGS, false, name);
}
static inline HANDLE create_mutex(const wchar_t *name)
{
return CreateMutexW(NULL, false, name);
}
static inline HANDLE open_mutex(const wchar_t *name)
{
return OpenMutexW(GC_MUTEX_FLAGS, false, name);
}
static inline HANDLE create_event_plus_id(const wchar_t *name, DWORD id)
{
wchar_t new_name[64];
_snwprintf(new_name, 64, L"%s%lu", name, id);
return create_event(new_name);
}
static inline HANDLE create_mutex_plus_id(const wchar_t *name, DWORD id)
{
wchar_t new_name[64];
_snwprintf(new_name, 64, L"%s%lu", name, id);
return create_mutex(new_name);
}
static inline bool object_signalled(HANDLE event)
{
if (!event)
return false;
return WaitForSingleObject(event, 0) == WAIT_OBJECT_0;
}