UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
windows.c File Reference
#include "debug.h"
#include "utils/windows.h"
Include dependency graph for windows.c:

Go to the source code of this file.

Macros

#define MOD_NAME   "[utils/win] "
 

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.c.

Macro Definition Documentation

◆ MOD_NAME

#define MOD_NAME   "[utils/win] "

Definition at line 53 of file windows.c.

Function Documentation

◆ com_initialize()

bool com_initialize ( bool * com_initialized,
const char * err_prefix )
Parameters
[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().