mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-22 00:06:59 +02:00
More Windows/Cosmopolitan work.
This commit is contained in:
+64
-40
@@ -7419,7 +7419,7 @@ struct ma_context
|
|||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
#ifdef MA_WIN32
|
#if defined(MA_WIN32) || defined(__COSMOPOLITAN__)
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
/*HMODULE*/ ma_handle hOle32DLL;
|
/*HMODULE*/ ma_handle hOle32DLL;
|
||||||
@@ -11336,35 +11336,56 @@ IMPLEMENTATION
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__COSMOPOLITAN__)
|
#if defined(__COSMOPOLITAN__)
|
||||||
typedef uint64_t HWND;
|
|
||||||
typedef uint64_t HANDLE;
|
|
||||||
typedef uint32_t HRESULT;
|
|
||||||
typedef uint8_t BYTE;
|
|
||||||
typedef uint16_t WORD;
|
|
||||||
typedef uint32_t DWORD;
|
|
||||||
typedef int32_t BOOL;
|
|
||||||
typedef int32_t LONG; /* `long` is always 32-bit on Windows. */
|
|
||||||
typedef uint32_t ULONG;
|
|
||||||
|
|
||||||
#define TRUE 1
|
|
||||||
#define FALSE 0
|
|
||||||
|
|
||||||
#define WINAPI
|
#define WINAPI
|
||||||
#define S_OK 0
|
#define STDMETHODCALLTYPE
|
||||||
#define WAIT_OBJECT_0 0
|
|
||||||
|
|
||||||
#define FAILED(hr) ((hr) < 0)
|
typedef uint64_t HWND;
|
||||||
#define NOERROR 0
|
typedef uint64_t HANDLE;
|
||||||
#define E_POINTER ((HRESULT)0x80004003)
|
typedef uint32_t HRESULT;
|
||||||
#define E_UNEXPECTED ((HRESULT)0x8000FFFF)
|
typedef uint8_t BYTE;
|
||||||
#define E_NOTIMPL ((HRESULT)0x80004001)
|
typedef uint16_t WORD;
|
||||||
#define E_OUTOFMEMORY ((HRESULT)0x8007000E)
|
typedef uint32_t DWORD;
|
||||||
#define E_INVALIDARG ((HRESULT)0x80070057)
|
typedef uint64_t DWORDLONG;
|
||||||
#define E_NOINTERFACE ((HRESULT)0x80004002)
|
typedef int32_t BOOL;
|
||||||
#define E_HANDLE ((HRESULT)0x80070006)
|
typedef int32_t LONG; /* `long` is always 32-bit on Windows. */
|
||||||
#define E_ABORT ((HRESULT)0x80004004)
|
typedef uint32_t ULONG;
|
||||||
#define E_FAIL ((HRESULT)0x80004005)
|
typedef uint64_t ULONGLONG;
|
||||||
#define E_ACCESSDENIED ((HRESULT)0x80070005)
|
typedef char16_t WCHAR;
|
||||||
|
|
||||||
|
#define TRUE 1
|
||||||
|
#define FALSE 0
|
||||||
|
|
||||||
|
#define WAIT_OBJECT_0 0
|
||||||
|
#define INFINITE 0xFFFFFFFF
|
||||||
|
|
||||||
|
#define FAILED(hr) ((hr) < 0)
|
||||||
|
#define SUCCEEDED(hr) ((hr) >= 0)
|
||||||
|
|
||||||
|
#define NOERROR 0
|
||||||
|
#define S_OK 0
|
||||||
|
#define S_FALSE 1
|
||||||
|
#define E_POINTER ((HRESULT)0x80004003)
|
||||||
|
#define E_UNEXPECTED ((HRESULT)0x8000FFFF)
|
||||||
|
#define E_NOTIMPL ((HRESULT)0x80004001)
|
||||||
|
#define E_OUTOFMEMORY ((HRESULT)0x8007000E)
|
||||||
|
#define E_INVALIDARG ((HRESULT)0x80070057)
|
||||||
|
#define E_NOINTERFACE ((HRESULT)0x80004002)
|
||||||
|
#define E_HANDLE ((HRESULT)0x80070006)
|
||||||
|
#define E_ABORT ((HRESULT)0x80004004)
|
||||||
|
#define E_FAIL ((HRESULT)0x80004005)
|
||||||
|
#define E_ACCESSDENIED ((HRESULT)0x80070005)
|
||||||
|
|
||||||
|
#define ERROR_SUCCESS 0
|
||||||
|
#define ERROR_FILE_NOT_FOUND 2
|
||||||
|
#define ERROR_PATH_NOT_FOUND 3
|
||||||
|
#define ERROR_TOO_MANY_OPEN_FILES 4
|
||||||
|
#define ERROR_ACCESS_DENIED 5
|
||||||
|
#define ERROR_NOT_ENOUGH_MEMORY 8
|
||||||
|
#define ERROR_HANDLE_EOF 38
|
||||||
|
#define ERROR_INVALID_PARAMETER 87
|
||||||
|
#define ERROR_DISK_FULL 112
|
||||||
|
#define ERROR_SEM_TIMEOUT 121
|
||||||
|
#define ERROR_NEGATIVE_SEEK 131
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@@ -11374,7 +11395,7 @@ IMPLEMENTATION
|
|||||||
unsigned char Data4[8];
|
unsigned char Data4[8];
|
||||||
} GUID, IID;
|
} GUID, IID;
|
||||||
|
|
||||||
static HANDLE CreateEventA(struct NtSecurityAttributes *lpEventAttributes, bool32 bManualReset, bool32 bInitialState, const char* lpName)
|
static HANDLE CreateEventA(struct NtSecurityAttributes* lpEventAttributes, bool32 bManualReset, bool32 bInitialState, const char* lpName)
|
||||||
{
|
{
|
||||||
assert(lpName == NULL); /* If this is ever triggered we'll need to do a ANSI-to-Unicode conversion. */
|
assert(lpName == NULL); /* If this is ever triggered we'll need to do a ANSI-to-Unicode conversion. */
|
||||||
return (HANDLE)CreateEvent(lpEventAttributes, bManualReset, bInitialState, (const char16_t*)lpName);
|
return (HANDLE)CreateEvent(lpEventAttributes, bManualReset, bInitialState, (const char16_t*)lpName);
|
||||||
@@ -11386,6 +11407,9 @@ IMPLEMENTATION
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define MA_VT_LPWSTR 31
|
||||||
|
#define MA_VT_BLOB 65
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
WORD vt;
|
WORD vt;
|
||||||
@@ -11399,13 +11423,13 @@ IMPLEMENTATION
|
|||||||
ULONG cbSize;
|
ULONG cbSize;
|
||||||
BYTE* pBlobData;
|
BYTE* pBlobData;
|
||||||
} blob;
|
} blob;
|
||||||
wchar_t* pwszVal;
|
WCHAR* pwszVal;
|
||||||
char pad[16]; /* Just to ensure the size of the struct matches the official version. */
|
char pad[16]; /* Just to ensure the size of the struct matches the official version. */
|
||||||
};
|
};
|
||||||
} MA_PROPVARIANT;
|
} MA_PROPVARIANT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MA_POSIX
|
#if !defined(MA_WIN32)
|
||||||
#include <stdlib.h> /* For malloc(), free(), wcstombs(). */
|
#include <stdlib.h> /* For malloc(), free(), wcstombs(). */
|
||||||
#include <string.h> /* For memset() */
|
#include <string.h> /* For memset() */
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
@@ -11414,7 +11438,7 @@ IMPLEMENTATION
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MA_NX
|
#ifdef MA_NX
|
||||||
#include <time.h> /* For nanosleep() */
|
#include <time.h> /* For nanosleep() */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/stat.h> /* For fstat(), etc. */
|
#include <sys/stat.h> /* For fstat(), etc. */
|
||||||
@@ -16011,7 +16035,7 @@ MA_API ma_uint64 ma_calculate_frame_count_after_resampling(ma_uint32 sampleRateO
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(MA_WIN32)
|
#if defined(MA_WIN32) || defined(__COSMOPOLITAN__)
|
||||||
static ma_result ma_result_from_GetLastError(DWORD error)
|
static ma_result ma_result_from_GetLastError(DWORD error)
|
||||||
{
|
{
|
||||||
switch (error)
|
switch (error)
|
||||||
@@ -21316,7 +21340,7 @@ static LPWSTR ma_context_get_default_device_id_from_IMMDeviceEnumerator__wasapi(
|
|||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
ma_IMMDevice* pMMDefaultDevice = NULL;
|
ma_IMMDevice* pMMDefaultDevice = NULL;
|
||||||
LPWSTR pDefaultDeviceID = NULL;
|
WCHAR* pDefaultDeviceID = NULL;
|
||||||
ma_EDataFlow dataFlow;
|
ma_EDataFlow dataFlow;
|
||||||
ma_ERole role;
|
ma_ERole role;
|
||||||
|
|
||||||
@@ -21352,7 +21376,7 @@ static LPWSTR ma_context_get_default_device_id__wasapi(ma_context* pContext, ma_
|
|||||||
{
|
{
|
||||||
ma_result result;
|
ma_result result;
|
||||||
ma_IMMDeviceEnumerator* pDeviceEnumerator;
|
ma_IMMDeviceEnumerator* pDeviceEnumerator;
|
||||||
LPWSTR pDefaultDeviceID = NULL;
|
WCHAR* pDefaultDeviceID = NULL;
|
||||||
|
|
||||||
MA_ASSERT(pContext != NULL);
|
MA_ASSERT(pContext != NULL);
|
||||||
|
|
||||||
@@ -21398,7 +21422,7 @@ static ma_result ma_context_get_MMDevice__wasapi(ma_context* pContext, ma_device
|
|||||||
|
|
||||||
static ma_result ma_context_get_device_id_from_MMDevice__wasapi(ma_context* pContext, ma_IMMDevice* pMMDevice, ma_device_id* pDeviceID)
|
static ma_result ma_context_get_device_id_from_MMDevice__wasapi(ma_context* pContext, ma_IMMDevice* pMMDevice, ma_device_id* pDeviceID)
|
||||||
{
|
{
|
||||||
LPWSTR pDeviceIDString;
|
WCHAR* pDeviceIDString;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
MA_ASSERT(pDeviceID != NULL);
|
MA_ASSERT(pDeviceID != NULL);
|
||||||
@@ -21484,7 +21508,7 @@ static ma_result ma_context_enumerate_devices_by_type__wasapi(ma_context* pConte
|
|||||||
UINT deviceCount;
|
UINT deviceCount;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
ma_uint32 iDevice;
|
ma_uint32 iDevice;
|
||||||
LPWSTR pDefaultDeviceID = NULL;
|
WCHAR* pDefaultDeviceID = NULL;
|
||||||
ma_IMMDeviceCollection* pDeviceCollection = NULL;
|
ma_IMMDeviceCollection* pDeviceCollection = NULL;
|
||||||
|
|
||||||
MA_ASSERT(pContext != NULL);
|
MA_ASSERT(pContext != NULL);
|
||||||
@@ -21565,7 +21589,7 @@ static ma_result ma_context_get_IAudioClient_UWP__wasapi(ma_context* pContext, m
|
|||||||
ma_IActivateAudioInterfaceAsyncOperation *pAsyncOp = NULL;
|
ma_IActivateAudioInterfaceAsyncOperation *pAsyncOp = NULL;
|
||||||
ma_completion_handler_uwp completionHandler;
|
ma_completion_handler_uwp completionHandler;
|
||||||
IID iid;
|
IID iid;
|
||||||
LPOLESTR iidStr;
|
WCHAR* iidStr;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
ma_result result;
|
ma_result result;
|
||||||
HRESULT activateResult;
|
HRESULT activateResult;
|
||||||
@@ -21575,7 +21599,7 @@ static ma_result ma_context_get_IAudioClient_UWP__wasapi(ma_context* pContext, m
|
|||||||
MA_ASSERT(ppAudioClient != NULL);
|
MA_ASSERT(ppAudioClient != NULL);
|
||||||
|
|
||||||
if (pDeviceID != NULL) {
|
if (pDeviceID != NULL) {
|
||||||
iidStr = (LPOLESTR)pDeviceID->wasapi;
|
iidStr = (WCHAR*)pDeviceID->wasapi;
|
||||||
} else {
|
} else {
|
||||||
if (deviceType == ma_device_type_capture) {
|
if (deviceType == ma_device_type_capture) {
|
||||||
iid = MA_IID_DEVINTERFACE_AUDIO_CAPTURE;
|
iid = MA_IID_DEVINTERFACE_AUDIO_CAPTURE;
|
||||||
@@ -21712,7 +21736,7 @@ static ma_result ma_context_get_IAudioClient__wasapi(ma_context* pContext, ma_de
|
|||||||
audioclientActivationParams.ProcessLoopbackParams.TargetProcessId = (DWORD)loopbackProcessID;
|
audioclientActivationParams.ProcessLoopbackParams.TargetProcessId = (DWORD)loopbackProcessID;
|
||||||
|
|
||||||
ma_PropVariantInit(&activationParams);
|
ma_PropVariantInit(&activationParams);
|
||||||
activationParams.vt = VT_BLOB;
|
activationParams.vt = MA_VT_BLOB;
|
||||||
activationParams.blob.cbSize = sizeof(audioclientActivationParams);
|
activationParams.blob.cbSize = sizeof(audioclientActivationParams);
|
||||||
activationParams.blob.pBlobData = (BYTE*)&audioclientActivationParams;
|
activationParams.blob.pBlobData = (BYTE*)&audioclientActivationParams;
|
||||||
pActivationParams = &activationParams;
|
pActivationParams = &activationParams;
|
||||||
|
|||||||
Reference in New Issue
Block a user