mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 14:08:56 +00:00
decklink: Implement Windows string conversion with common API between MinGW and MSVC
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4738>
This commit is contained in:
parent
ab582a3b7d
commit
f1e7ac13cd
1 changed files with 17 additions and 11 deletions
|
@ -32,20 +32,26 @@
|
||||||
#include "win/DeckLinkAPI.h"
|
#include "win/DeckLinkAPI.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <comutil.h>
|
|
||||||
|
|
||||||
#define bool BOOL
|
#define bool BOOL
|
||||||
#define COMSTR_T BSTR
|
#define COMSTR_T BSTR
|
||||||
/* MinGW does not have comsuppw.lib, so no _com_util::ConvertBSTRToString */
|
#define CONVERT_COM_STRING(s) G_STMT_START { \
|
||||||
# ifdef __MINGW32__
|
BSTR _s = (BSTR)s; \
|
||||||
# define CONVERT_COM_STRING(s) G_STMT_START { BSTR _s = (BSTR)s; s = (char*) malloc(100); wcstombs(s, _s, 100); ::SysFreeString(_s); } G_STMT_END
|
int _s_length = ::SysStringLen(_s); \
|
||||||
# define FREE_COM_STRING(s) free(s);
|
int _length = ::WideCharToMultiByte(CP_ACP, 0, (wchar_t*)_s, _s_length, NULL, 0, NULL, NULL); \
|
||||||
# define CONVERT_TO_COM_STRING(s) G_STMT_START { char * _s = (char *)s; s = (BSTR) malloc(100); mbstowcs(s, _s, 100); g_free(_s); } G_STMT_END
|
s = (char *) malloc(_length); \
|
||||||
# else
|
::WideCharToMultiByte(CP_ACP, 0, (wchar_t*)_s, _s_length, s, _length, NULL, NULL); \
|
||||||
# define CONVERT_COM_STRING(s) G_STMT_START { BSTR _s = (BSTR)s; s = _com_util::ConvertBSTRToString(_s); ::SysFreeString(_s); } G_STMT_END
|
::SysFreeString(_s); \
|
||||||
# define FREE_COM_STRING(s) G_STMT_START { delete[] s; } G_STMT_END
|
} G_STMT_END
|
||||||
# define CONVERT_TO_COM_STRING(s) G_STMT_START { char * _s = (char *)s; s = _com_util::ConvertStringToBSTR(_s); g_free(_s); } G_STMT_END
|
#define FREE_COM_STRING(s) free(s);
|
||||||
# endif /* __MINGW32__ */
|
#define CONVERT_TO_COM_STRING(s) G_STMT_START { \
|
||||||
|
char * _s = (char *)s; \
|
||||||
|
int _s_length = strlen((char*)_s); \
|
||||||
|
int _length = ::MultiByteToWideChar(CP_ACP, 0, (char*)_s, _s_length, NULL, 0); \
|
||||||
|
s = ::SysAllocStringLen(NULL, _length); \
|
||||||
|
::MultiByteToWideChar(CP_ACP, 0, (char*)_s, _s_length, s, _length); \
|
||||||
|
g_free(_s); \
|
||||||
|
} G_STMT_END
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
#include "osx/DeckLinkAPI.h"
|
#include "osx/DeckLinkAPI.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue