UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
windows.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define HRESULT_GET_ERROR_COMMON(res, errptr)
 

Enumerations

enum  { BUILD_WINDOWS_11_OR_LATER = 22000 }
 

Functions

bool com_initialize (bool *com_initialized, const char *err_prefix)
 
void com_uninitialize (bool *com_initialized)
 

Detailed Description

Author
Martin Pulec pulec.nosp@m.@ces.nosp@m.net.c.nosp@m.z

Definition in file windows.h.

Macro Definition Documentation

◆ HRESULT_GET_ERROR_COMMON

#define HRESULT_GET_ERROR_COMMON ( res,
errptr )
Value:
switch (res) { \
case S_OK: errptr = "Operation successful"; break; \
case S_FALSE: errptr = "Operation completed"; break; \
case E_NOTIMPL: errptr = "Not implemented"; break; \
case E_NOINTERFACE: errptr = "No such interface supported"; break; \
case E_POINTER: errptr = "Pointer that is not valid"; break; \
case E_ABORT: errptr = "Operation aborted"; break; \
case E_FAIL: errptr = "Unspecified failure"; break; \
case E_UNEXPECTED: errptr = "Unexpected failure"; break; \
case E_ACCESSDENIED: errptr = "General access denied error"; break; \
case E_HANDLE: errptr = "Handle that is not valid"; break; \
case E_OUTOFMEMORY: errptr = "Failed to allocate necessary memory"; break; \
case E_INVALIDARG: errptr = "One or more arguments are not valid"; break; \
}

this macro is shared between both utils/windows.cpp, where the error codes defines system and bmd_hresult_to_string where only the subset below is defined by LinuxCOM.h compat, so use only values defined in that header.

Definition at line 60 of file windows.h.

60#define HRESULT_GET_ERROR_COMMON(res, errptr) \
61 switch (res) { \
62 case S_OK: errptr = "Operation successful"; break; \
63 case S_FALSE: errptr = "Operation completed"; break; \
64 case E_NOTIMPL: errptr = "Not implemented"; break; \
65 case E_NOINTERFACE: errptr = "No such interface supported"; break; \
66 case E_POINTER: errptr = "Pointer that is not valid"; break; \
67 case E_ABORT: errptr = "Operation aborted"; break; \
68 case E_FAIL: errptr = "Unspecified failure"; break; \
69 case E_UNEXPECTED: errptr = "Unexpected failure"; break; \
70 case E_ACCESSDENIED: errptr = "General access denied error"; break; \
71 case E_HANDLE: errptr = "Handle that is not valid"; break; \
72 case E_OUTOFMEMORY: errptr = "Failed to allocate necessary memory"; break; \
73 case E_INVALIDARG: errptr = "One or more arguments are not valid"; break; \
74 }

Referenced by bmd_hresult_to_string().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
BUILD_WINDOWS_11_OR_LATER 

Definition at line 45 of file windows.h.

45 {
47};
@ BUILD_WINDOWS_11_OR_LATER
Definition windows.h:46

Function Documentation

◆ com_initialize()

bool com_initialize ( bool * com_initialized,
const char * err_prefix )
Parameters
com_initialized- pointer passed to com_initialize (or create_com_iterator)
[out]com_initializea pointer to a bool that will be passed to com_uninintialize(). The value should be initialized to false - the current logic can guard only one init/uninit so true is assumed bo be a repeated call.
[in]err_prefixoptional error prefix to be used for eventual error messges (may be NULL)
Return values
trueif either COM already initalized for this thread or this call initializes COM succesfully
falseCOM could not have been initialized

Definition at line 65 of file windows.c.

66{
67 if (*com_initialized) {
68 MSG(WARNING, "com_initialized should be initalized to false "
69 "upon the call!\n");
70 }
71#ifdef _WIN32
72 if (err_prefix == NULL) {
73 err_prefix = "";
74 }
75 *com_initialized = false;
76 // Initialize COM on this thread
77 HRESULT result = CoInitializeEx(NULL, COINIT_MULTITHREADED);
78 if (SUCCEEDED(result)) {
79 *com_initialized = true;
80 return true;
81 }
82 if (result == RPC_E_CHANGED_MODE) {
83 log_msg(LOG_LEVEL_WARNING, "%sCOM already intiialized with a different mode!\n", err_prefix);
84 return true;
85 }
86 log_msg(LOG_LEVEL_ERROR, "%sInitialize of COM failed - %s\n", err_prefix, hresult_to_str(result));
87 return false;
88#else
89 (void) com_initialized, (void) err_prefix;
90 return true;
91#endif
92}
void log_msg(int level, const char *format,...)
Definition debug.cpp:130
#define LOG_LEVEL_ERROR
general errors
Definition debug.h:59
#define MSG(l, fmt,...)
Definition debug.h:96
#define LOG_LEVEL_WARNING
less severe errors
Definition debug.h:60

References LOG_LEVEL_ERROR, LOG_LEVEL_WARNING, log_msg(), and MSG.

Referenced by vidcap_decklink_state::vidcap_decklink_state(), audio_cap_wasapi_init(), audio_cap_wasapi_probe(), audio_play_wasapi_help(), audio_play_wasapi_init(), audio_play_wasapi_probe(), blackmagic_api_version_check(), common_init(), common_preinit(), create_decklink_iterator(), print_decklink_version(), and show_help().

Here is the call graph for this function:

◆ com_uninitialize()

void com_uninitialize ( bool * com_initialized)

Definition at line 94 of file windows.c.

95{
96#ifdef _WIN32
97 if (!*com_initialized) {
98 return;
99 }
100 *com_initialized = false;
101 CoUninitialize();
102#else
103 (void) com_initialized;
104#endif
105}

Referenced by vidcap_decklink_state::~vidcap_decklink_state(), audio_cap_wasapi_probe(), audio_play_wasapi_help(), audio_play_wasapi_init(), audio_play_wasapi_probe(), cleanup(), common_cleanup(), decklink_uninitialize(), print_decklink_version(), and show_help().