Commit 216f044e authored by Nirbheek Chauhan's avatar Nirbheek Chauhan 🐜 Committed by Sebastian Dröge
Browse files

decklink: Fix linking on MinGW

MinGW does not provide comsupp.lib, so there's no implementation of
_com_util::ConvertBSTRToString. Use a fallback implementation that
uses wcstombs() instead.

On MinGW we also truncate the name to 100 chars which should be fine.
parent 62a727d3
......@@ -967,7 +967,7 @@ init_devices (gpointer data)
GST_DEBUG ("Input %d supports:", i);
while ((ret = mode_iter->Next (&mode)) == S_OK) {
const char *name;
char *name;
mode->GetName ((COMSTR_T *) & name);
CONVERT_COM_STRING (name);
......@@ -1005,7 +1005,7 @@ init_devices (gpointer data)
GST_DEBUG ("Output %d supports:", i);
while ((ret = mode_iter->Next (&mode)) == S_OK) {
const char *name;
char *name;
mode->GetName ((COMSTR_T *) & name);
CONVERT_COM_STRING (name);
......
......@@ -39,13 +39,19 @@
#define bool BOOL
#define COMSTR_T BSTR
#define FREE_COM_STRING(s) delete[] s;
#define CONVERT_COM_STRING(s) BSTR _s = (BSTR)s; s = _com_util::ConvertBSTRToString(_s); ::SysFreeString(_s);
/* MinGW does not have comsuppw.lib, so no _com_util::ConvertBSTRToString */
# ifdef __MINGW32__
# define CONVERT_COM_STRING(s) BSTR _s = (BSTR)s; s = (char*) malloc(100); wcstombs(s, _s, 100); ::SysFreeString(_s);
# define FREE_COM_STRING(s) free(s);
# else
# define CONVERT_COM_STRING(s) BSTR _s = (BSTR)s; s = _com_util::ConvertBSTRToString(_s); ::SysFreeString(_s);
# define FREE_COM_STRING(s) delete[] s;
# endif
#else
#define COMSTR_T const char*
#define FREE_COM_STRING(s)
#define CONVERT_COM_STRING(s)
#endif /* _MSC_VER */
#define FREE_COM_STRING(s)
#endif /* G_OS_WIN32 */
typedef enum {
GST_DECKLINK_MODE_AUTO,
......
......@@ -12,12 +12,15 @@ decklink_libs = []
if host_machine.system() == 'windows'
decklink_sources += ['win/DeckLinkAPIDispatch.cpp', 'win/DeckLinkAPI_i.c']
# Only used by MSVC. On MinGW, this is all inlined.
# FIXME: Use commsuppwd.lib for debug builds?
comutil_dep = cxx.find_library('comsuppw', required : false)
if comutil_dep.found()
if cxx.get_id() == 'msvc'
# FIXME: Use commsuppwd.lib for debug builds?
comutil_dep = cxx.find_library('comsuppw')
if comutil_dep.found()
build_decklink = true
decklink_libs = [comutil_dep]
endif
else
build_decklink = true
decklink_libs = [comutil_dep]
endif
else
libdl = cc.find_library('dl', required: false)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment