Commit 61a85dca authored by David Reid's avatar David Reid

Fix NXDK build for Xbox.

This disables the WASAPI, DirectSound and WinMM backends which means
you will not get any actual audio output working. An Xbox backend will
need to come later. The main purpose of this commit is to get the main
library compiling.

The main complication arises from the fact that both _WIN32 and
_MSC_VER are defined which makes miniaudio think it's using a normal
desktop Windows build. In practice it mostly works, but there's a few
things needing to be changed specifically for NXDK:

  - `fopen_s()` is not a thing with NXDK. It always uses `fopen()`.
  - There is no `_wfopen()`, nor `wcsrtombs()`, so attempting to open
    a file from a wide character string will fail.
  - There is also no `CreateFileW()`, so this code path will also
    result in an error if you attempt to open a file from a wide
    character path.
  - `CoInitialize()` is not a thing with NXDK and has therefore been
    excluded from the build.
  - `GetFileInformationByHandle()` does not exist, and neither does
    `struct stat` or `stat()`. Since the only file information miniaudio
    attempts to retrieve is the file size, I've implemented a fall back
    which uses the seek/tell/seek pattern when info retrieval is
    unavailable.
  - A fall back has been implemented for comparing wide character path
    extensions which performs a case-sensitive compare instead. This
    means that if you are using wide character paths, miniaudio will not
    detect an extension like "wav" and "WAV" as the same thing. This
    might be made more robust later if there is enough demand.

Public issue https://github.com/mackron/miniaudio/issues/1023
parent c87f207f
...@@ -3864,9 +3864,20 @@ typedef ma_uint16 wchar_t; ...@@ -3864,9 +3864,20 @@ typedef ma_uint16 wchar_t;
#define MA_WIN32_UWP #define MA_WIN32_UWP
#elif defined(WINAPI_FAMILY) && (defined(WINAPI_FAMILY_GAMES) && WINAPI_FAMILY == WINAPI_FAMILY_GAMES) #elif defined(WINAPI_FAMILY) && (defined(WINAPI_FAMILY_GAMES) && WINAPI_FAMILY == WINAPI_FAMILY_GAMES)
#define MA_WIN32_GDK #define MA_WIN32_GDK
#elif defined(NXDK)
#define MA_WIN32_NXDK
#else #else
#define MA_WIN32_DESKTOP #define MA_WIN32_DESKTOP
#endif #endif
/* The original Xbox. */
#if defined(NXDK) /* <-- Add other Xbox compiler toolchains here, and then add a toolchain-specific define in case we need to discriminate between them later. */
#define MA_XBOX
#if defined(NXDK)
#define MA_XBOX_NXDK
#endif
#endif
#endif #endif
#if !defined(_WIN32) /* If it's not Win32, assume POSIX. */ #if !defined(_WIN32) /* If it's not Win32, assume POSIX. */
#define MA_POSIX #define MA_POSIX
...@@ -6576,7 +6587,7 @@ This section contains the APIs for device playback and capture. Here is where yo ...@@ -6576,7 +6587,7 @@ This section contains the APIs for device playback and capture. Here is where yo
************************************************************************************************************************************************************/ ************************************************************************************************************************************************************/
#ifndef MA_NO_DEVICE_IO #ifndef MA_NO_DEVICE_IO
/* Some backends are only supported on certain platforms. */ /* Some backends are only supported on certain platforms. */
#if defined(MA_WIN32) #if defined(MA_WIN32) && !defined(MA_XBOX)
#define MA_SUPPORT_WASAPI #define MA_SUPPORT_WASAPI
#if defined(MA_WIN32_DESKTOP) /* DirectSound and WinMM backends are only supported on desktops. */ #if defined(MA_WIN32_DESKTOP) /* DirectSound and WinMM backends are only supported on desktops. */
...@@ -11563,7 +11574,12 @@ IMPLEMENTATION ...@@ -11563,7 +11574,12 @@ IMPLEMENTATION
#include <unistd.h> #include <unistd.h>
#endif #endif
#include <sys/stat.h> /* For fstat(), etc. */ /* For fstat(), etc. */
#if defined(MA_XBOX_NXDK)
#include <stat.h> /* Suggestion for NXDK: Add a sys/stat.h wrapper for compatibility. */
#else
#include <sys/stat.h>
#endif
#ifdef MA_EMSCRIPTEN #ifdef MA_EMSCRIPTEN
#include <emscripten/emscripten.h> #include <emscripten/emscripten.h>
...@@ -12030,7 +12046,7 @@ static MA_INLINE unsigned int ma_disable_denormals(void) ...@@ -12030,7 +12046,7 @@ static MA_INLINE unsigned int ma_disable_denormals(void)
{ {
unsigned int prevState; unsigned int prevState;
#if defined(_MSC_VER) #if defined(_MSC_VER) && !defined(MA_XBOX_NXDK)
{ {
/* /*
Older versions of Visual Studio don't support the "safe" versions of _controlfp_s(). I don't Older versions of Visual Studio don't support the "safe" versions of _controlfp_s(). I don't
...@@ -12077,7 +12093,7 @@ static MA_INLINE unsigned int ma_disable_denormals(void) ...@@ -12077,7 +12093,7 @@ static MA_INLINE unsigned int ma_disable_denormals(void)
static MA_INLINE void ma_restore_denormals(unsigned int prevState) static MA_INLINE void ma_restore_denormals(unsigned int prevState)
{ {
#if defined(_MSC_VER) #if defined(_MSC_VER) && !defined(MA_XBOX_NXDK)
{ {
/* Older versions of Visual Studio do not support _controlfp_s(). See ma_disable_denormals(). */ /* Older versions of Visual Studio do not support _controlfp_s(). See ma_disable_denormals(). */
#if _MSC_VER <= 1200 #if _MSC_VER <= 1200
...@@ -13199,7 +13215,7 @@ MA_API ma_result ma_fopen(FILE** ppFile, const char* pFilePath, const char* pOpe ...@@ -13199,7 +13215,7 @@ MA_API ma_result ma_fopen(FILE** ppFile, const char* pFilePath, const char* pOpe
return MA_INVALID_ARGS; return MA_INVALID_ARGS;
} }
#if defined(_MSC_VER) && _MSC_VER >= 1400 #if (defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(MA_XBOX_NXDK)
err = fopen_s(ppFile, pFilePath, pOpenMode); err = fopen_s(ppFile, pFilePath, pOpenMode);
if (err != 0) { if (err != 0) {
return ma_result_from_errno(err); return ma_result_from_errno(err);
...@@ -13241,7 +13257,7 @@ _wfopen() isn't always available in all compilation environments. ...@@ -13241,7 +13257,7 @@ _wfopen() isn't always available in all compilation environments.
This can be reviewed as compatibility issues arise. The preference is to use _wfopen_s() and _wfopen() as opposed to the wcsrtombs() This can be reviewed as compatibility issues arise. The preference is to use _wfopen_s() and _wfopen() as opposed to the wcsrtombs()
fallback, so if you notice your compiler not detecting this properly I'm happy to look at adding support. fallback, so if you notice your compiler not detecting this properly I'm happy to look at adding support.
*/ */
#if defined(_WIN32) #if defined(_WIN32) && !defined(MA_XBOX_NXDK)
#if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS)) #if defined(_MSC_VER) || defined(__MINGW64__) || (!defined(__STRICT_ANSI__) && !defined(_NO_EXT_KEYS))
#define MA_HAS_WFOPEN #define MA_HAS_WFOPEN
#endif #endif
...@@ -13257,29 +13273,34 @@ MA_API ma_result ma_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_ ...@@ -13257,29 +13273,34 @@ MA_API ma_result ma_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_
return MA_INVALID_ARGS; return MA_INVALID_ARGS;
} }
#if defined(MA_HAS_WFOPEN) #if defined(MA_HAS_WFOPEN)
{ {
/* Use _wfopen() on Windows. */ /* Use _wfopen() on Windows. */
#if defined(_MSC_VER) && _MSC_VER >= 1400 #if defined(_MSC_VER) && _MSC_VER >= 1400
{
errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode); errno_t err = _wfopen_s(ppFile, pFilePath, pOpenMode);
if (err != 0) { if (err != 0) {
return ma_result_from_errno(err); return ma_result_from_errno(err);
} }
}
#else #else
{
*ppFile = _wfopen(pFilePath, pOpenMode); *ppFile = _wfopen(pFilePath, pOpenMode);
if (*ppFile == NULL) { if (*ppFile == NULL) {
return ma_result_from_errno(errno); return ma_result_from_errno(errno);
} }
}
#endif #endif
(void)pAllocationCallbacks; (void)pAllocationCallbacks;
} }
#else #elif !defined(MA_XBOX_NXDK) /* If your compiler does not support wcsrtombs(), add it here. */
{
/* /*
Use fopen() on anything other than Windows. Requires a conversion. This is annoying because fopen() is locale specific. The only real way I can Use fopen() on anything other than Windows. Requires a conversion. This is annoying because fopen() is locale specific. The only real way I can
think of to do this is with wcsrtombs(). Note that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for think of to do this is with wcsrtombs(). Note that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for
maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler error I'll look into improving compatibility. maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler error I'll look into improving compatibility.
*/ */
{
mbstate_t mbs; mbstate_t mbs;
size_t lenMB; size_t lenMB;
const wchar_t* pFilePathTemp = pFilePath; const wchar_t* pFilePathTemp = pFilePath;
...@@ -13320,11 +13341,16 @@ MA_API ma_result ma_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_ ...@@ -13320,11 +13341,16 @@ MA_API ma_result ma_wfopen(FILE** ppFile, const wchar_t* pFilePath, const wchar_
ma_free(pFilePathMB, pAllocationCallbacks); ma_free(pFilePathMB, pAllocationCallbacks);
} }
#else
{
/* Getting here means there is no way to open the file with a wide character string. */
*ppFile = NULL;
}
#endif
if (*ppFile == NULL) { if (*ppFile == NULL) {
return MA_ERROR; return MA_ERROR;
} }
#endif
return MA_SUCCESS; return MA_SUCCESS;
} }
...@@ -19609,7 +19635,7 @@ MA_API ma_bool32 ma_is_loopback_supported(ma_backend backend) ...@@ -19609,7 +19635,7 @@ MA_API ma_bool32 ma_is_loopback_supported(ma_backend backend)
#if defined(MA_WIN32) #if defined(MA_WIN32) && !defined(MA_XBOX)
/* WASAPI error codes. */ /* WASAPI error codes. */
#define MA_AUDCLNT_E_NOT_INITIALIZED ((HRESULT)0x88890001) #define MA_AUDCLNT_E_NOT_INITIALIZED ((HRESULT)0x88890001)
#define MA_AUDCLNT_E_ALREADY_INITIALIZED ((HRESULT)0x88890002) #define MA_AUDCLNT_E_ALREADY_INITIALIZED ((HRESULT)0x88890002)
...@@ -19824,6 +19850,11 @@ typedef LONG (WINAPI * MA_PFN_RegCloseKey)(HKEY hKey); ...@@ -19824,6 +19850,11 @@ typedef LONG (WINAPI * MA_PFN_RegCloseKey)(HKEY hKey);
typedef LONG (WINAPI * MA_PFN_RegQueryValueExA)(HKEY hKey, const char* lpValueName, DWORD* lpReserved, DWORD* lpType, BYTE* lpData, DWORD* lpcbData); typedef LONG (WINAPI * MA_PFN_RegQueryValueExA)(HKEY hKey, const char* lpValueName, DWORD* lpReserved, DWORD* lpType, BYTE* lpData, DWORD* lpcbData);
#endif /* MA_WIN32_DESKTOP */ #endif /* MA_WIN32_DESKTOP */
static GUID MA_GUID_KSDATAFORMAT_SUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
static GUID MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
/*static GUID MA_GUID_KSDATAFORMAT_SUBTYPE_ALAW = {0x00000006, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};*/
/*static GUID MA_GUID_KSDATAFORMAT_SUBTYPE_MULAW = {0x00000007, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};*/
MA_API size_t ma_strlen_WCHAR(const WCHAR* str) MA_API size_t ma_strlen_WCHAR(const WCHAR* str)
{ {
size_t len = 0; size_t len = 0;
...@@ -20558,14 +20589,6 @@ static MA_INLINE void ma_device__set_state(ma_device* pDevice, ma_device_state n ...@@ -20558,14 +20589,6 @@ static MA_INLINE void ma_device__set_state(ma_device* pDevice, ma_device_state n
} }
#if defined(MA_WIN32)
static GUID MA_GUID_KSDATAFORMAT_SUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
static GUID MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
/*static GUID MA_GUID_KSDATAFORMAT_SUBTYPE_ALAW = {0x00000006, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};*/
/*static GUID MA_GUID_KSDATAFORMAT_SUBTYPE_MULAW = {0x00000007, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};*/
#endif
MA_API ma_uint32 ma_get_format_priority_index(ma_format format) /* Lower = better. */ MA_API ma_uint32 ma_get_format_priority_index(ma_format format) /* Lower = better. */
{ {
...@@ -21277,7 +21300,7 @@ static ma_result ma_context_init__null(ma_context* pContext, const ma_context_co ...@@ -21277,7 +21300,7 @@ static ma_result ma_context_init__null(ma_context* pContext, const ma_context_co
WIN32 COMMON WIN32 COMMON
*******************************************************************************/ *******************************************************************************/
#if defined(MA_WIN32) #if defined(MA_WIN32) && !defined(MA_XBOX)
#if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK)
#define ma_CoInitializeEx(pContext, pvReserved, dwCoInit) ((pContext->win32.CoInitializeEx) ? ((MA_PFN_CoInitializeEx)pContext->win32.CoInitializeEx)(pvReserved, dwCoInit) : ((MA_PFN_CoInitialize)pContext->win32.CoInitialize)(pvReserved)) #define ma_CoInitializeEx(pContext, pvReserved, dwCoInit) ((pContext->win32.CoInitializeEx) ? ((MA_PFN_CoInitializeEx)pContext->win32.CoInitializeEx)(pvReserved, dwCoInit) : ((MA_PFN_CoInitialize)pContext->win32.CoInitialize)(pvReserved))
#define ma_CoUninitialize(pContext) ((MA_PFN_CoUninitialize)pContext->win32.CoUninitialize)() #define ma_CoUninitialize(pContext) ((MA_PFN_CoUninitialize)pContext->win32.CoUninitialize)()
...@@ -21292,7 +21315,7 @@ WIN32 COMMON ...@@ -21292,7 +21315,7 @@ WIN32 COMMON
#define ma_PropVariantClear(pContext, pvar) PropVariantClear(pvar) #define ma_PropVariantClear(pContext, pvar) PropVariantClear(pvar)
#endif #endif
#if !defined(MAXULONG_PTR) && !defined(__WATCOMC__) #if !defined(MAXULONG_PTR) && !defined(__WATCOMC__) && !defined(MA_XBOX_NXDK)
typedef size_t DWORD_PTR; typedef size_t DWORD_PTR;
#endif #endif
...@@ -42588,13 +42611,13 @@ MA_API ma_result ma_device_post_init(ma_device* pDevice, ma_device_type deviceTy ...@@ -42588,13 +42611,13 @@ MA_API ma_result ma_device_post_init(ma_device* pDevice, ma_device_type deviceTy
static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData) static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData)
{ {
ma_device* pDevice = (ma_device*)pData; ma_device* pDevice = (ma_device*)pData;
#ifdef MA_WIN32 #if defined(MA_WIN32) && !defined(MA_XBOX)
HRESULT CoInitializeResult; HRESULT CoInitializeResult;
#endif #endif
MA_ASSERT(pDevice != NULL); MA_ASSERT(pDevice != NULL);
#ifdef MA_WIN32 #if defined(MA_WIN32) && !defined(MA_XBOX)
CoInitializeResult = ma_CoInitializeEx(pDevice->pContext, NULL, MA_COINIT_VALUE); CoInitializeResult = ma_CoInitializeEx(pDevice->pContext, NULL, MA_COINIT_VALUE);
#endif #endif
...@@ -42685,7 +42708,7 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData) ...@@ -42685,7 +42708,7 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData)
ma_event_signal(&pDevice->stopEvent); ma_event_signal(&pDevice->stopEvent);
} }
#ifdef MA_WIN32 #if defined(MA_WIN32) && !defined(MA_XBOX)
if (CoInitializeResult == S_OK || CoInitializeResult == S_FALSE) { if (CoInitializeResult == S_OK || CoInitializeResult == S_FALSE) {
ma_CoUninitialize(pDevice->pContext); ma_CoUninitialize(pDevice->pContext);
} }
...@@ -42710,10 +42733,16 @@ static ma_bool32 ma_device__is_initialized(ma_device* pDevice) ...@@ -42710,10 +42733,16 @@ static ma_bool32 ma_device__is_initialized(ma_device* pDevice)
static ma_result ma_context_uninit_backend_apis__win32(ma_context* pContext) static ma_result ma_context_uninit_backend_apis__win32(ma_context* pContext)
{ {
/* For some reason UWP complains when CoUninitialize() is called. I'm just not going to call it on UWP. */ /* For some reason UWP complains when CoUninitialize() is called. I'm just not going to call it on UWP. */
#if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) #if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK)
{
/* TODO: Remove this once the new single threaded backend system is in place in 0.12. */
#if !defined(MA_XBOX)
{
if (pContext->win32.CoInitializeResult == S_OK || pContext->win32.CoInitializeResult == S_FALSE) { if (pContext->win32.CoInitializeResult == S_OK || pContext->win32.CoInitializeResult == S_FALSE) {
ma_CoUninitialize(pContext); ma_CoUninitialize(pContext); /* TODO: Remove this once the new single threaded backend system is in place in 0.12. */
} }
}
#endif
#if defined(MA_WIN32_DESKTOP) #if defined(MA_WIN32_DESKTOP)
ma_dlclose(ma_context_get_log(pContext), pContext->win32.hUser32DLL); ma_dlclose(ma_context_get_log(pContext), pContext->win32.hUser32DLL);
...@@ -42721,17 +42750,26 @@ static ma_result ma_context_uninit_backend_apis__win32(ma_context* pContext) ...@@ -42721,17 +42750,26 @@ static ma_result ma_context_uninit_backend_apis__win32(ma_context* pContext)
#endif #endif
ma_dlclose(ma_context_get_log(pContext), pContext->win32.hOle32DLL); ma_dlclose(ma_context_get_log(pContext), pContext->win32.hOle32DLL);
#else }
#else
{
(void)pContext; (void)pContext;
#endif }
#endif
return MA_SUCCESS; return MA_SUCCESS;
} }
static ma_result ma_context_init_backend_apis__win32(ma_context* pContext) static ma_result ma_context_init_backend_apis__win32(ma_context* pContext)
{ {
#if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK) /*
TODO: Reassess all of this stuff and move everything to the relevant backends. For example, I think
GetForegroundWindow() and GetDesktopWindow() are only used by the DirectSound backend.
*/
#if (defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK)) && !defined(MA_XBOX)
{
#if defined(MA_WIN32_DESKTOP) #if defined(MA_WIN32_DESKTOP)
{
/* User32.dll */ /* User32.dll */
pContext->win32.hUser32DLL = ma_dlopen(ma_context_get_log(pContext), "user32.dll"); pContext->win32.hUser32DLL = ma_dlopen(ma_context_get_log(pContext), "user32.dll");
if (pContext->win32.hUser32DLL == NULL) { if (pContext->win32.hUser32DLL == NULL) {
...@@ -42751,6 +42789,7 @@ static ma_result ma_context_init_backend_apis__win32(ma_context* pContext) ...@@ -42751,6 +42789,7 @@ static ma_result ma_context_init_backend_apis__win32(ma_context* pContext)
pContext->win32.RegOpenKeyExA = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hAdvapi32DLL, "RegOpenKeyExA"); pContext->win32.RegOpenKeyExA = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hAdvapi32DLL, "RegOpenKeyExA");
pContext->win32.RegCloseKey = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hAdvapi32DLL, "RegCloseKey"); pContext->win32.RegCloseKey = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hAdvapi32DLL, "RegCloseKey");
pContext->win32.RegQueryValueExA = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hAdvapi32DLL, "RegQueryValueExA"); pContext->win32.RegQueryValueExA = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hAdvapi32DLL, "RegQueryValueExA");
}
#endif #endif
/* Ole32.dll */ /* Ole32.dll */
...@@ -42766,11 +42805,20 @@ static ma_result ma_context_init_backend_apis__win32(ma_context* pContext) ...@@ -42766,11 +42805,20 @@ static ma_result ma_context_init_backend_apis__win32(ma_context* pContext)
pContext->win32.CoTaskMemFree = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hOle32DLL, "CoTaskMemFree"); pContext->win32.CoTaskMemFree = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hOle32DLL, "CoTaskMemFree");
pContext->win32.PropVariantClear = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hOle32DLL, "PropVariantClear"); pContext->win32.PropVariantClear = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hOle32DLL, "PropVariantClear");
pContext->win32.StringFromGUID2 = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hOle32DLL, "StringFromGUID2"); pContext->win32.StringFromGUID2 = (ma_proc)ma_dlsym(ma_context_get_log(pContext), pContext->win32.hOle32DLL, "StringFromGUID2");
#else }
#else
{
(void)pContext; /* Unused. */ (void)pContext; /* Unused. */
#endif }
#endif
/* TODO: Remove this once the new single threaded backend system is in place in 0.12. */
#if !defined(MA_XBOX)
{
pContext->win32.CoInitializeResult = ma_CoInitializeEx(pContext, NULL, MA_COINIT_VALUE); pContext->win32.CoInitializeResult = ma_CoInitializeEx(pContext, NULL, MA_COINIT_VALUE);
}
#endif
return MA_SUCCESS; return MA_SUCCESS;
} }
#else #else
...@@ -60871,7 +60919,7 @@ MA_API ma_result ma_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo ...@@ -60871,7 +60919,7 @@ MA_API ma_result ma_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo
} }
#if !defined(MA_USE_WIN32_FILEIO) && (defined(MA_WIN32) && defined(MA_WIN32_DESKTOP) && !defined(MA_NO_WIN32_FILEIO) && !defined(MA_POSIX)) #if !defined(MA_USE_WIN32_FILEIO) && (defined(MA_WIN32) && (defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_NXDK)) && !defined(MA_NO_WIN32_FILEIO) && !defined(MA_POSIX))
#define MA_USE_WIN32_FILEIO #define MA_USE_WIN32_FILEIO
#endif #endif
...@@ -60948,6 +60996,8 @@ static ma_result ma_default_vfs_open__win32(ma_vfs* pVFS, const char* pFilePath, ...@@ -60948,6 +60996,8 @@ static ma_result ma_default_vfs_open__win32(ma_vfs* pVFS, const char* pFilePath,
static ma_result ma_default_vfs_open_w__win32(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile) static ma_result ma_default_vfs_open_w__win32(ma_vfs* pVFS, const wchar_t* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
{ {
#if !defined(MA_XBOX_NXDK)
{
HANDLE hFile; HANDLE hFile;
DWORD dwDesiredAccess; DWORD dwDesiredAccess;
DWORD dwShareMode; DWORD dwShareMode;
...@@ -60967,6 +61017,13 @@ static ma_result ma_default_vfs_open_w__win32(ma_vfs* pVFS, const wchar_t* pFile ...@@ -60967,6 +61017,13 @@ static ma_result ma_default_vfs_open_w__win32(ma_vfs* pVFS, const wchar_t* pFile
*pFile = hFile; *pFile = hFile;
return MA_SUCCESS; return MA_SUCCESS;
}
#else
{
/* No CreateFileW() available. */
return MA_NOT_IMPLEMENTED;
}
#endif
} }
static ma_result ma_default_vfs_close__win32(ma_vfs* pVFS, ma_vfs_file file) static ma_result ma_default_vfs_close__win32(ma_vfs* pVFS, ma_vfs_file file)
...@@ -61137,11 +61194,13 @@ static ma_result ma_default_vfs_tell__win32(ma_vfs* pVFS, ma_vfs_file file, ma_i ...@@ -61137,11 +61194,13 @@ static ma_result ma_default_vfs_tell__win32(ma_vfs* pVFS, ma_vfs_file file, ma_i
static ma_result ma_default_vfs_info__win32(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo) static ma_result ma_default_vfs_info__win32(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo)
{ {
(void)pVFS;
#if !defined(MA_XBOX_NXDK)
{
BY_HANDLE_FILE_INFORMATION fi; BY_HANDLE_FILE_INFORMATION fi;
BOOL result; BOOL result;
(void)pVFS;
result = GetFileInformationByHandle((HANDLE)file, &fi); result = GetFileInformationByHandle((HANDLE)file, &fi);
if (result == 0) { if (result == 0) {
return ma_result_from_GetLastError(GetLastError()); return ma_result_from_GetLastError(GetLastError());
...@@ -61150,6 +61209,13 @@ static ma_result ma_default_vfs_info__win32(ma_vfs* pVFS, ma_vfs_file file, ma_f ...@@ -61150,6 +61209,13 @@ static ma_result ma_default_vfs_info__win32(ma_vfs* pVFS, ma_vfs_file file, ma_f
pInfo->sizeInBytes = ((ma_uint64)fi.nFileSizeHigh << 32) | ((ma_uint64)fi.nFileSizeLow); pInfo->sizeInBytes = ((ma_uint64)fi.nFileSizeHigh << 32) | ((ma_uint64)fi.nFileSizeLow);
return MA_SUCCESS; return MA_SUCCESS;
}
#else
{
/* GetFileInformationByHandle() is unavailable. */
return MA_NOT_IMPLEMENTED;
}
#endif
} }
#else #else
static ma_result ma_default_vfs_open__stdio(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile) static ma_result ma_default_vfs_open__stdio(ma_vfs* pVFS, const char* pFilePath, ma_uint32 openMode, ma_vfs_file* pFile)
...@@ -61487,6 +61553,8 @@ static ma_result ma_default_vfs_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* p ...@@ -61487,6 +61553,8 @@ static ma_result ma_default_vfs_tell(ma_vfs* pVFS, ma_vfs_file file, ma_int64* p
static ma_result ma_default_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo) static ma_result ma_default_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_info* pInfo)
{ {
ma_result result;
if (pInfo == NULL) { if (pInfo == NULL) {
return MA_INVALID_ARGS; return MA_INVALID_ARGS;
} }
...@@ -61498,10 +61566,43 @@ static ma_result ma_default_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_inf ...@@ -61498,10 +61566,43 @@ static ma_result ma_default_vfs_info(ma_vfs* pVFS, ma_vfs_file file, ma_file_inf
} }
#if defined(MA_USE_WIN32_FILEIO) #if defined(MA_USE_WIN32_FILEIO)
return ma_default_vfs_info__win32(pVFS, file, pInfo); result = ma_default_vfs_info__win32(pVFS, file, pInfo);
#else #else
return ma_default_vfs_info__stdio(pVFS, file, pInfo); result = ma_default_vfs_info__stdio(pVFS, file, pInfo);
#endif #endif
if (result == MA_NOT_IMPLEMENTED) {
/* Not implemented. Fall back to seek/tell/seek. */
ma_result result;
ma_int64 cursor;
ma_int64 sizeInBytes;
result = ma_default_vfs_tell(pVFS, file, &cursor);
if (result != MA_SUCCESS) {
return result;
}
result = ma_default_vfs_seek(pVFS, file, 0, ma_seek_origin_end);
if (result != MA_SUCCESS) {
return result;
}
result = ma_default_vfs_tell(pVFS, file, &sizeInBytes);
if (result != MA_SUCCESS) {
return result;
}
pInfo->sizeInBytes = sizeInBytes;
result = ma_default_vfs_seek(pVFS, file, cursor, ma_seek_origin_start);
if (result != MA_SUCCESS) {
return result;
}
MA_ASSERT(result == MA_SUCCESS);
}
return result;
} }
...@@ -62419,7 +62520,7 @@ extern "C" { ...@@ -62419,7 +62520,7 @@ extern "C" {
#define MA_DR_MP3_XSTRINGIFY(x) MA_DR_MP3_STRINGIFY(x) #define MA_DR_MP3_XSTRINGIFY(x) MA_DR_MP3_STRINGIFY(x)
#define MA_DR_MP3_VERSION_MAJOR 0 #define MA_DR_MP3_VERSION_MAJOR 0
#define MA_DR_MP3_VERSION_MINOR 7 #define MA_DR_MP3_VERSION_MINOR 7
#define MA_DR_MP3_VERSION_REVISION 0 #define MA_DR_MP3_VERSION_REVISION 1
#define MA_DR_MP3_VERSION_STRING MA_DR_MP3_XSTRINGIFY(MA_DR_MP3_VERSION_MAJOR) "." MA_DR_MP3_XSTRINGIFY(MA_DR_MP3_VERSION_MINOR) "." MA_DR_MP3_XSTRINGIFY(MA_DR_MP3_VERSION_REVISION) #define MA_DR_MP3_VERSION_STRING MA_DR_MP3_XSTRINGIFY(MA_DR_MP3_VERSION_MAJOR) "." MA_DR_MP3_XSTRINGIFY(MA_DR_MP3_VERSION_MINOR) "." MA_DR_MP3_XSTRINGIFY(MA_DR_MP3_VERSION_REVISION)
#include <stddef.h> #include <stddef.h>
#define MA_DR_MP3_MAX_PCM_FRAMES_PER_MP3_FRAME 1152 #define MA_DR_MP3_MAX_PCM_FRAMES_PER_MP3_FRAME 1152
...@@ -66466,14 +66567,16 @@ static ma_bool32 ma_path_extension_equal_w(const wchar_t* path, const wchar_t* e ...@@ -66466,14 +66567,16 @@ static ma_bool32 ma_path_extension_equal_w(const wchar_t* path, const wchar_t* e
ext1 = extension; ext1 = extension;
ext2 = ma_path_extension_w(path); ext2 = ma_path_extension_w(path);
#if defined(_MSC_VER) || defined(__WATCOMC__) || defined(__DMC__) #if (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__DMC__)) && !defined(MA_XBOX_NXDK)
{
return _wcsicmp(ext1, ext2) == 0; return _wcsicmp(ext1, ext2) == 0;
#else }
#elif !defined(MA_XBOX_NXDK)
{
/* /*
I'm not aware of a wide character version of strcasecmp(). I'm therefore converting the extensions to multibyte strings and comparing those. This I'm not aware of a wide character version of strcasecmp(). I'm therefore converting the extensions to multibyte strings and comparing those. This
isn't the most efficient way to do it, but it should work OK. isn't the most efficient way to do it, but it should work OK.
*/ */
{
char ext1MB[4096]; char ext1MB[4096];
char ext2MB[4096]; char ext2MB[4096];
const wchar_t* pext1 = ext1; const wchar_t* pext1 = ext1;
...@@ -66493,7 +66596,13 @@ static ma_bool32 ma_path_extension_equal_w(const wchar_t* path, const wchar_t* e ...@@ -66493,7 +66596,13 @@ static ma_bool32 ma_path_extension_equal_w(const wchar_t* path, const wchar_t* e
return strcasecmp(ext1MB, ext2MB) == 0; return strcasecmp(ext1MB, ext2MB) == 0;
} }
#endif #else
{
/* Getting here means we don't have a way to do a case-sensitive comparison for wide strings. Fall back to a simple case-sensitive comparison. */
/* TODO: Implement our own wchar_t-to-char conversion routine and then use the char* version for comparing. */
return wcscmp(ext1, ext2) == 0;
}
#endif
} }
#endif /* MA_HAS_PATH_API */ #endif /* MA_HAS_PATH_API */
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