mirror of
https://github.com/mpv-player/mpv
synced 2025-01-01 12:22:22 +00:00
win32: more wchar_t -> WCHAR replacements
This was essentially missing from commit 0b52ac8a
.
Since L"..." string literals have the type wchar_t[], we can't use them
for UTF-16 strings. Use C11 u"..." string literals instead. These have
the type char16_t[], but we simply assume char16_t is the same
underlying type as WCHAR. In practice, they're both unsigned short.
For this reason use -std=c11 on Windows. Since Windows is a "special"
environment (we require either MinGW or Cygwin), we don't need to worry
too much about compiler compatibility.
This commit is contained in:
parent
c8fab7cc7b
commit
fefac2c941
@ -227,7 +227,7 @@ static int LoadDirectSound(struct ao *ao)
|
||||
struct priv *p = ao->priv;
|
||||
|
||||
// initialize directsound
|
||||
p->hdsound_dll = LoadLibrary(L"DSOUND.DLL");
|
||||
p->hdsound_dll = LoadLibraryW(u"DSOUND.DLL");
|
||||
if (p->hdsound_dll == NULL) {
|
||||
MP_ERR(ao, "cannot load DSOUND.DLL\n");
|
||||
return 0;
|
||||
|
@ -67,7 +67,7 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDeviceStateChanged(
|
||||
if (change->is_hotplug) {
|
||||
MP_VERBOSE(ao, "OnDeviceStateChanged triggered: sending hotplug event\n");
|
||||
ao_hotplug_event(ao);
|
||||
} else if (pwstrDeviceId && !wcscmp(pwstrDeviceId, change->monitored)) {
|
||||
} else if (pwstrDeviceId && !lstrcmpW(pwstrDeviceId, change->monitored)) {
|
||||
switch (dwNewState) {
|
||||
case DEVICE_STATE_DISABLED:
|
||||
case DEVICE_STATE_NOTPRESENT:
|
||||
@ -110,7 +110,7 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDeviceRemoved(
|
||||
if (change->is_hotplug) {
|
||||
MP_VERBOSE(ao, "OnDeviceRemoved triggered: sending hotplug event\n");
|
||||
ao_hotplug_event(ao);
|
||||
} else if (pwstrDeviceId && !wcscmp(pwstrDeviceId, change->monitored)) {
|
||||
} else if (pwstrDeviceId && !lstrcmpW(pwstrDeviceId, change->monitored)) {
|
||||
MP_VERBOSE(ao, "OnDeviceRemoved triggered for device %S: "
|
||||
"requesting ao reload\n", pwstrDeviceId);
|
||||
ao_request_reload(ao);
|
||||
@ -144,7 +144,7 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnDefaultDeviceChanged(
|
||||
}
|
||||
|
||||
/* don't reload if already on the new default */
|
||||
if (pwstrDeviceId && !wcscmp(pwstrDeviceId, change->monitored)) {
|
||||
if (pwstrDeviceId && !lstrcmpW(pwstrDeviceId, change->monitored)) {
|
||||
MP_VERBOSE(ao, "OnDefaultDeviceChanged triggered: "
|
||||
"already using default device, no reload required\n");
|
||||
return S_OK;
|
||||
@ -167,7 +167,7 @@ static HRESULT STDMETHODCALLTYPE sIMMNotificationClient_OnPropertyValueChanged(
|
||||
struct ao *ao = change->ao;
|
||||
|
||||
if (!change->is_hotplug && pwstrDeviceId &&
|
||||
!wcscmp(pwstrDeviceId, change->monitored))
|
||||
!lstrcmpW(pwstrDeviceId, change->monitored))
|
||||
{
|
||||
MP_VERBOSE(ao, "OnPropertyValueChanged triggered on device %S\n",
|
||||
pwstrDeviceId);
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "osdep/io.h"
|
||||
#include "osdep/timer.h"
|
||||
|
||||
#define MIXER_DEFAULT_LABEL L"mpv - video player"
|
||||
#define MIXER_DEFAULT_LABEL u"mpv - video player"
|
||||
|
||||
DEFINE_PROPERTYKEY(mp_PKEY_Device_FriendlyName,
|
||||
0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20,
|
||||
@ -190,7 +190,7 @@ bool wasapi_fill_VistaBlob(wasapi_state *state)
|
||||
{
|
||||
if (!state)
|
||||
goto exit_label;
|
||||
state->VistaBlob.hAvrt = LoadLibraryW(L"avrt.dll");
|
||||
state->VistaBlob.hAvrt = LoadLibraryW(u"avrt.dll");
|
||||
if (!state->VistaBlob.hAvrt)
|
||||
goto exit_label;
|
||||
|
||||
@ -620,7 +620,7 @@ static HRESULT init_session_display(struct wasapi_state *state) {
|
||||
EXIT_ON_ERROR(hr);
|
||||
|
||||
GetModuleFileNameW(NULL, path, MAX_PATH);
|
||||
lstrcatW(path, L",-IDI_ICON1");
|
||||
lstrcatW(path, u",-IDI_ICON1");
|
||||
|
||||
hr = IAudioSessionControl_SetDisplayName(state->pSessionControl, MIXER_DEFAULT_LABEL, NULL);
|
||||
EXIT_ON_ERROR(hr);
|
||||
@ -725,7 +725,7 @@ reinit:
|
||||
|
||||
if (state->VistaBlob.hAvrt) {
|
||||
state->hTask =
|
||||
state->VistaBlob.pAvSetMmThreadCharacteristicsW(L"Pro Audio", &state->taskIndex);
|
||||
state->VistaBlob.pAvSetMmThreadCharacteristicsW(u"Pro Audio", &state->taskIndex);
|
||||
}
|
||||
|
||||
MP_VERBOSE(state, "Format fixed. Using %lld byte buffer block size\n",
|
||||
|
@ -112,7 +112,7 @@ static int create_overlapped_pipe(HANDLE *read, HANDLE *write)
|
||||
unsigned long id = atomic_fetch_add(&counter, 1);
|
||||
unsigned pid = GetCurrentProcessId();
|
||||
wchar_t buf[36];
|
||||
swprintf(buf, sizeof(buf), L"\\\\.\\pipe\\mpv-anon-%08x-%08lx", pid, id);
|
||||
swprintf(buf, sizeof(buf), u"\\\\.\\pipe\\mpv-anon-%08x-%08lx", pid, id);
|
||||
|
||||
// The function for creating anonymous pipes (CreatePipe) can't create
|
||||
// overlapped pipes, so instead, use a named pipe with a unique name
|
||||
|
@ -198,7 +198,7 @@ static bool check_stream_network(int fd)
|
||||
// NtQueryVolumeInformationFile is an internal Windows function. It has
|
||||
// been present since Windows XP, however this code should fail gracefully
|
||||
// if it's removed from a future version of Windows.
|
||||
HMODULE ntdll = GetModuleHandleW(L"ntdll.dll");
|
||||
HMODULE ntdll = GetModuleHandleW(u"ntdll.dll");
|
||||
pNtQueryVolumeInformationFile = (NTSTATUS (NTAPI*)(HANDLE,
|
||||
PIO_STATUS_BLOCK, PVOID, ULONG, FS_INFORMATION_CLASS))
|
||||
GetProcAddress(ntdll, "NtQueryVolumeInformationFile");
|
||||
|
@ -355,7 +355,7 @@ static int create_device(struct lavc_ctx *s)
|
||||
}
|
||||
}
|
||||
|
||||
ctx->d3dlib = LoadLibrary(L"d3d9.dll");
|
||||
ctx->d3dlib = LoadLibraryW(u"d3d9.dll");
|
||||
if (!ctx->d3dlib) {
|
||||
MP_ERR(ctx, "Failed to load D3D9 library\n");
|
||||
goto fail;
|
||||
@ -423,7 +423,7 @@ static int dxva2_init(struct lavc_ctx *s)
|
||||
|
||||
ctx->deviceHandle = INVALID_HANDLE_VALUE;
|
||||
|
||||
ctx->dxva2lib = LoadLibrary(L"dxva2.dll");
|
||||
ctx->dxva2lib = LoadLibraryW(u"dxva2.dll");
|
||||
if (!ctx->dxva2lib) {
|
||||
MP_ERR(ctx, "Failed to load DXVA2 library\n");
|
||||
goto fail;
|
||||
|
@ -84,7 +84,7 @@ static void *w32gpa(const GLubyte *procName)
|
||||
void *res = wglGetProcAddress(procName);
|
||||
if (res)
|
||||
return res;
|
||||
oglmod = GetModuleHandle(L"opengl32.dll");
|
||||
oglmod = GetModuleHandleW(u"opengl32.dll");
|
||||
return GetProcAddress(oglmod, procName);
|
||||
}
|
||||
|
||||
@ -208,7 +208,7 @@ static void create_ctx(void *ptr)
|
||||
if (!w32_ctx->context)
|
||||
create_context_w32_old(ctx);
|
||||
|
||||
w32_ctx->dwmapi_dll = LoadLibrary(L"Dwmapi.dll");
|
||||
w32_ctx->dwmapi_dll = LoadLibraryW(u"Dwmapi.dll");
|
||||
if (w32_ctx->dwmapi_dll)
|
||||
w32_ctx->dwmflush = (DwmFlush_t)GetProcAddress(w32_ctx->dwmapi_dll, "DwmFlush");
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include "misc/rendezvous.h"
|
||||
#include "talloc.h"
|
||||
|
||||
static const WCHAR classname[] = L"mpv";
|
||||
static const WCHAR classname[] = u"mpv";
|
||||
|
||||
static __thread struct vo_w32_state *w32_thread_context;
|
||||
|
||||
@ -1129,7 +1129,7 @@ static void *gui_thread(void *ptr)
|
||||
.style = CS_HREDRAW | CS_VREDRAW,
|
||||
.lpfnWndProc = WndProc,
|
||||
.hInstance = hInstance,
|
||||
.hIcon = LoadIconW(hInstance, L"IDI_ICON1"),
|
||||
.hIcon = LoadIconW(hInstance, u"IDI_ICON1"),
|
||||
.hCursor = LoadCursor(NULL, IDC_ARROW),
|
||||
.lpszClassName = classname,
|
||||
};
|
||||
|
@ -51,6 +51,7 @@ def __add_clang_flags__(ctx):
|
||||
def __add_mswin_flags__(ctx):
|
||||
ctx.env.CFLAGS += ['-D_WIN32_WINNT=0x600', '-DUNICODE', '-DCOBJMACROS',
|
||||
'-U__STRICT_ANSI__']
|
||||
ctx.env.CFLAGS += ['-std=c11']
|
||||
|
||||
def __add_mingw_flags__(ctx):
|
||||
__add_mswin_flags__(ctx)
|
||||
|
Loading…
Reference in New Issue
Block a user