mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-07-06 18:40:23 +00:00
Fix compilation errors with the C++ build
This commit is contained in:
parent
99be0acc1e
commit
5dc77acec9
|
@ -3799,7 +3799,7 @@ typedef double ma_double;
|
|||
|
||||
typedef void* ma_handle;
|
||||
typedef void* ma_ptr;
|
||||
typedef void (* ma_proc)(void);
|
||||
typedef void* ma_proc;
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_WCHAR_T_DEFINED)
|
||||
typedef ma_uint16 wchar_t;
|
||||
|
@ -11340,6 +11340,21 @@ IMPLEMENTATION
|
|||
|
||||
#if defined(MA_WIN32)
|
||||
#include <windows.h>
|
||||
|
||||
/*
|
||||
There's a possibility that WIN32_LEAN_AND_MEAN has been defined which will exclude some symbols
|
||||
such as STGM_READ and CLSCTL_ALL. We need to check these and define them ourselves if they're
|
||||
unavailable.
|
||||
*/
|
||||
#ifndef STGM_READ
|
||||
#define STGM_READ 0x00000000L
|
||||
#endif
|
||||
#ifndef CLSCTX_ALL
|
||||
#define CLSCTX_ALL 23
|
||||
#endif
|
||||
|
||||
/* IUnknown is used by both the WASAPI and DirectSound backends. It easier to just declare our version here. */
|
||||
typedef struct ma_IUnknown ma_IUnknown;
|
||||
#endif
|
||||
|
||||
#if !defined(MA_WIN32)
|
||||
|
@ -11773,7 +11788,7 @@ static MA_INLINE void ma_sleep(ma_uint32 milliseconds)
|
|||
}
|
||||
#endif
|
||||
|
||||
static MA_INLINE void ma_yield()
|
||||
static MA_INLINE void ma_yield(void)
|
||||
{
|
||||
#if defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64)
|
||||
/* x86/x64 */
|
||||
|
@ -11808,7 +11823,7 @@ static MA_INLINE void ma_yield()
|
|||
#define MA_MM_DENORMALS_ZERO_MASK 0x0040
|
||||
#define MA_MM_FLUSH_ZERO_MASK 0x8000
|
||||
|
||||
static MA_INLINE unsigned int ma_disable_denormals()
|
||||
static MA_INLINE unsigned int ma_disable_denormals(void)
|
||||
{
|
||||
unsigned int prevState;
|
||||
|
||||
|
@ -20105,17 +20120,9 @@ static const IID MA_IID_DEVINTERFACE_AUDIO_CAPTURE = {0x2EEF81BE,
|
|||
static const IID MA_IID_IActivateAudioInterfaceCompletionHandler = {0x41D949AB, 0x9862, 0x444A, {0x80, 0xF6, 0xC2, 0x61, 0x33, 0x4D, 0xA5, 0xEB}}; /* 41D949AB-9862-444A-80F6-C261334DA5EB */
|
||||
#endif
|
||||
|
||||
static const IID MA_CLSID_MMDeviceEnumerator_Instance = {0xBCDE0395, 0xE52F, 0x467C, {0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E}}; /* BCDE0395-E52F-467C-8E3D-C4579291692E = __uuidof(MMDeviceEnumerator) */
|
||||
static const IID MA_IID_IMMDeviceEnumerator_Instance = {0xA95664D2, 0x9614, 0x4F35, {0xA7, 0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6}}; /* A95664D2-9614-4F35-A746-DE8DB63617E6 = __uuidof(IMMDeviceEnumerator) */
|
||||
#ifdef __cplusplus
|
||||
#define MA_CLSID_MMDeviceEnumerator MA_CLSID_MMDeviceEnumerator_Instance
|
||||
#define MA_IID_IMMDeviceEnumerator MA_IID_IMMDeviceEnumerator_Instance
|
||||
#else
|
||||
#define MA_CLSID_MMDeviceEnumerator &MA_CLSID_MMDeviceEnumerator_Instance
|
||||
#define MA_IID_IMMDeviceEnumerator &MA_IID_IMMDeviceEnumerator_Instance
|
||||
#endif
|
||||
static const IID MA_CLSID_MMDeviceEnumerator = {0xBCDE0395, 0xE52F, 0x467C, {0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E}}; /* BCDE0395-E52F-467C-8E3D-C4579291692E = __uuidof(MMDeviceEnumerator) */
|
||||
static const IID MA_IID_IMMDeviceEnumerator = {0xA95664D2, 0x9614, 0x4F35, {0xA7, 0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6}}; /* A95664D2-9614-4F35-A746-DE8DB63617E6 = __uuidof(IMMDeviceEnumerator) */
|
||||
|
||||
typedef struct ma_IUnknown ma_IUnknown;
|
||||
#if defined(MA_WIN32_DESKTOP) || defined(MA_WIN32_GDK)
|
||||
#define MA_MM_DEVICE_STATE_ACTIVE 1
|
||||
#define MA_MM_DEVICE_STATE_DISABLED 2
|
||||
|
@ -21292,7 +21299,7 @@ static ma_result ma_context_create_IMMDeviceEnumerator__wasapi(ma_context* pCont
|
|||
|
||||
*ppDeviceEnumerator = NULL; /* Safety. */
|
||||
|
||||
hr = ma_CoCreateInstance(pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
|
||||
hr = ma_CoCreateInstance(pContext, &MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
|
||||
if (FAILED(hr)) {
|
||||
ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator.");
|
||||
return ma_result_from_HRESULT(hr);
|
||||
|
@ -21366,7 +21373,7 @@ static ma_result ma_context_get_MMDevice__wasapi(ma_context* pContext, ma_device
|
|||
MA_ASSERT(pContext != NULL);
|
||||
MA_ASSERT(ppMMDevice != NULL);
|
||||
|
||||
hr = ma_CoCreateInstance(pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
|
||||
hr = ma_CoCreateInstance(pContext, &MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
|
||||
if (FAILED(hr)) {
|
||||
ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create IMMDeviceEnumerator.\n");
|
||||
return ma_result_from_HRESULT(hr);
|
||||
|
@ -21744,7 +21751,7 @@ static ma_result ma_context_enumerate_devices__wasapi(ma_context* pContext, ma_e
|
|||
HRESULT hr;
|
||||
ma_IMMDeviceEnumerator* pDeviceEnumerator;
|
||||
|
||||
hr = ma_CoCreateInstance(pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
|
||||
hr = ma_CoCreateInstance(pContext, &MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
|
||||
if (FAILED(hr)) {
|
||||
ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator.");
|
||||
return ma_result_from_HRESULT(hr);
|
||||
|
@ -22673,7 +22680,7 @@ static ma_result ma_device_init__wasapi(ma_device* pDevice, const ma_device_conf
|
|||
|
||||
ma_mutex_init(&pDevice->wasapi.rerouteLock);
|
||||
|
||||
hr = ma_CoCreateInstance(pDevice->pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
|
||||
hr = ma_CoCreateInstance(pDevice->pContext, &MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator);
|
||||
if (FAILED(hr)) {
|
||||
ma_device_uninit__wasapi(pDevice);
|
||||
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator.");
|
||||
|
@ -25209,16 +25216,75 @@ WinMM Backend
|
|||
#ifdef MA_HAS_WINMM
|
||||
|
||||
/*
|
||||
Some older compilers don't have WAVEOUTCAPS2A and WAVEINCAPS2A, so we'll need to write this ourselves. These structures
|
||||
are exactly the same as the older ones but they have a few GUIDs for manufacturer/product/name identification. I'm keeping
|
||||
the names the same as the Win32 library for consistency, but namespaced to avoid naming conflicts with the Win32 version.
|
||||
Some build configurations will exclude the WinMM API. An example is when WIN32_LEAN_AND_MEAN
|
||||
is defined. We need to define the types and functions we need manually.
|
||||
*/
|
||||
#define MA_MMSYSERR_NOERROR 0
|
||||
#define MA_MMSYSERR_ERROR 1
|
||||
#define MA_MMSYSERR_BADDEVICEID 2
|
||||
#define MA_MMSYSERR_INVALHANDLE 5
|
||||
#define MA_MMSYSERR_NOMEM 7
|
||||
#define MA_MMSYSERR_INVALFLAG 10
|
||||
#define MA_MMSYSERR_INVALPARAM 11
|
||||
#define MA_MMSYSERR_HANDLEBUSY 12
|
||||
|
||||
#define MA_CALLBACK_EVENT 0x00050000
|
||||
#define MA_WAVE_ALLOWSYNC 0x0002
|
||||
|
||||
#define MA_WHDR_DONE 0x00000001
|
||||
#define MA_WHDR_PREPARED 0x00000002
|
||||
#define MA_WHDR_BEGINLOOP 0x00000004
|
||||
#define MA_WHDR_ENDLOOP 0x00000008
|
||||
#define MA_WHDR_INQUEUE 0x00000010
|
||||
|
||||
#define MA_MAXPNAMELEN 32
|
||||
|
||||
typedef void* MA_HWAVEIN;
|
||||
typedef void* MA_HWAVEOUT;
|
||||
typedef UINT MA_MMRESULT;
|
||||
typedef UINT MA_MMVERSION;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD wMid;
|
||||
WORD wPid;
|
||||
MMVERSION vDriverVersion;
|
||||
CHAR szPname[MAXPNAMELEN];
|
||||
MA_MMVERSION vDriverVersion;
|
||||
CHAR szPname[MA_MAXPNAMELEN];
|
||||
DWORD dwFormats;
|
||||
WORD wChannels;
|
||||
WORD wReserved1;
|
||||
} MA_WAVEINCAPSA;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD wMid;
|
||||
WORD wPid;
|
||||
MA_MMVERSION vDriverVersion;
|
||||
CHAR szPname[MA_MAXPNAMELEN];
|
||||
DWORD dwFormats;
|
||||
WORD wChannels;
|
||||
WORD wReserved1;
|
||||
DWORD dwSupport;
|
||||
} MA_WAVEOUTCAPSA;
|
||||
|
||||
typedef struct tagWAVEHDR
|
||||
{
|
||||
char* lpData;
|
||||
DWORD dwBufferLength;
|
||||
DWORD dwBytesRecorded;
|
||||
DWORD_PTR dwUser;
|
||||
DWORD dwFlags;
|
||||
DWORD dwLoops;
|
||||
struct tagWAVEHDR* lpNext;
|
||||
DWORD_PTR reserved;
|
||||
} MA_WAVEHDR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD wMid;
|
||||
WORD wPid;
|
||||
MA_MMVERSION vDriverVersion;
|
||||
CHAR szPname[MA_MAXPNAMELEN];
|
||||
DWORD dwFormats;
|
||||
WORD wChannels;
|
||||
WORD wReserved1;
|
||||
|
@ -25227,12 +25293,13 @@ typedef struct
|
|||
GUID ProductGuid;
|
||||
GUID NameGuid;
|
||||
} MA_WAVEOUTCAPS2A;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WORD wMid;
|
||||
WORD wPid;
|
||||
MMVERSION vDriverVersion;
|
||||
CHAR szPname[MAXPNAMELEN];
|
||||
MA_MMVERSION vDriverVersion;
|
||||
CHAR szPname[MA_MAXPNAMELEN];
|
||||
DWORD dwFormats;
|
||||
WORD wChannels;
|
||||
WORD wReserved1;
|
||||
|
@ -25241,37 +25308,37 @@ typedef struct
|
|||
GUID NameGuid;
|
||||
} MA_WAVEINCAPS2A;
|
||||
|
||||
typedef UINT (WINAPI * MA_PFN_waveOutGetNumDevs)(void);
|
||||
typedef MMRESULT (WINAPI * MA_PFN_waveOutGetDevCapsA)(ma_uintptr uDeviceID, WAVEOUTCAPSA* pwoc, UINT cbwoc);
|
||||
typedef MMRESULT (WINAPI * MA_PFN_waveOutOpen)(HWAVEOUT* phwo, UINT uDeviceID, const MA_WAVEFORMATEX* pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen);
|
||||
typedef MMRESULT (WINAPI * MA_PFN_waveOutClose)(HWAVEOUT hwo);
|
||||
typedef MMRESULT (WINAPI * MA_PFN_waveOutPrepareHeader)(HWAVEOUT hwo, WAVEHDR* pwh, UINT cbwh);
|
||||
typedef MMRESULT (WINAPI * MA_PFN_waveOutUnprepareHeader)(HWAVEOUT hwo, WAVEHDR* pwh, UINT cbwh);
|
||||
typedef MMRESULT (WINAPI * MA_PFN_waveOutWrite)(HWAVEOUT hwo, WAVEHDR* pwh, UINT cbwh);
|
||||
typedef MMRESULT (WINAPI * MA_PFN_waveOutReset)(HWAVEOUT hwo);
|
||||
typedef UINT (WINAPI * MA_PFN_waveInGetNumDevs)(void);
|
||||
typedef MMRESULT (WINAPI * MA_PFN_waveInGetDevCapsA)(ma_uintptr uDeviceID, WAVEINCAPSA* pwic, UINT cbwic);
|
||||
typedef MMRESULT (WINAPI * MA_PFN_waveInOpen)(HWAVEIN* phwi, UINT uDeviceID, const MA_WAVEFORMATEX* pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen);
|
||||
typedef MMRESULT (WINAPI * MA_PFN_waveInClose)(HWAVEIN hwi);
|
||||
typedef MMRESULT (WINAPI * MA_PFN_waveInPrepareHeader)(HWAVEIN hwi, WAVEHDR* pwh, UINT cbwh);
|
||||
typedef MMRESULT (WINAPI * MA_PFN_waveInUnprepareHeader)(HWAVEIN hwi, WAVEHDR* pwh, UINT cbwh);
|
||||
typedef MMRESULT (WINAPI * MA_PFN_waveInAddBuffer)(HWAVEIN hwi, WAVEHDR* pwh, UINT cbwh);
|
||||
typedef MMRESULT (WINAPI * MA_PFN_waveInStart)(HWAVEIN hwi);
|
||||
typedef MMRESULT (WINAPI * MA_PFN_waveInReset)(HWAVEIN hwi);
|
||||
typedef UINT (WINAPI * MA_PFN_waveOutGetNumDevs)(void);
|
||||
typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutGetDevCapsA)(ma_uintptr uDeviceID, MA_WAVEOUTCAPSA* pwoc, UINT cbwoc);
|
||||
typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutOpen)(MA_HWAVEOUT* phwo, UINT uDeviceID, const MA_WAVEFORMATEX* pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen);
|
||||
typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutClose)(MA_HWAVEOUT hwo);
|
||||
typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutPrepareHeader)(MA_HWAVEOUT hwo, MA_WAVEHDR* pwh, UINT cbwh);
|
||||
typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutUnprepareHeader)(MA_HWAVEOUT hwo, MA_WAVEHDR* pwh, UINT cbwh);
|
||||
typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutWrite)(MA_HWAVEOUT hwo, MA_WAVEHDR* pwh, UINT cbwh);
|
||||
typedef MA_MMRESULT (WINAPI * MA_PFN_waveOutReset)(MA_HWAVEOUT hwo);
|
||||
typedef UINT (WINAPI * MA_PFN_waveInGetNumDevs)(void);
|
||||
typedef MA_MMRESULT (WINAPI * MA_PFN_waveInGetDevCapsA)(ma_uintptr uDeviceID, MA_WAVEINCAPSA* pwic, UINT cbwic);
|
||||
typedef MA_MMRESULT (WINAPI * MA_PFN_waveInOpen)(MA_HWAVEIN* phwi, UINT uDeviceID, const MA_WAVEFORMATEX* pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen);
|
||||
typedef MA_MMRESULT (WINAPI * MA_PFN_waveInClose)(MA_HWAVEIN hwi);
|
||||
typedef MA_MMRESULT (WINAPI * MA_PFN_waveInPrepareHeader)(MA_HWAVEIN hwi, MA_WAVEHDR* pwh, UINT cbwh);
|
||||
typedef MA_MMRESULT (WINAPI * MA_PFN_waveInUnprepareHeader)(MA_HWAVEIN hwi, MA_WAVEHDR* pwh, UINT cbwh);
|
||||
typedef MA_MMRESULT (WINAPI * MA_PFN_waveInAddBuffer)(MA_HWAVEIN hwi, MA_WAVEHDR* pwh, UINT cbwh);
|
||||
typedef MA_MMRESULT (WINAPI * MA_PFN_waveInStart)(MA_HWAVEIN hwi);
|
||||
typedef MA_MMRESULT (WINAPI * MA_PFN_waveInReset)(MA_HWAVEIN hwi);
|
||||
|
||||
static ma_result ma_result_from_MMRESULT(MMRESULT resultMM)
|
||||
static ma_result ma_result_from_MMRESULT(MA_MMRESULT resultMM)
|
||||
{
|
||||
switch (resultMM)
|
||||
{
|
||||
case MMSYSERR_NOERROR: return MA_SUCCESS;
|
||||
case MMSYSERR_BADDEVICEID: return MA_INVALID_ARGS;
|
||||
case MMSYSERR_INVALHANDLE: return MA_INVALID_ARGS;
|
||||
case MMSYSERR_NOMEM: return MA_OUT_OF_MEMORY;
|
||||
case MMSYSERR_INVALFLAG: return MA_INVALID_ARGS;
|
||||
case MMSYSERR_INVALPARAM: return MA_INVALID_ARGS;
|
||||
case MMSYSERR_HANDLEBUSY: return MA_BUSY;
|
||||
case MMSYSERR_ERROR: return MA_ERROR;
|
||||
default: return MA_ERROR;
|
||||
case MA_MMSYSERR_NOERROR: return MA_SUCCESS;
|
||||
case MA_MMSYSERR_BADDEVICEID: return MA_INVALID_ARGS;
|
||||
case MA_MMSYSERR_INVALHANDLE: return MA_INVALID_ARGS;
|
||||
case MA_MMSYSERR_NOMEM: return MA_OUT_OF_MEMORY;
|
||||
case MA_MMSYSERR_INVALFLAG: return MA_INVALID_ARGS;
|
||||
case MA_MMSYSERR_INVALPARAM: return MA_INVALID_ARGS;
|
||||
case MA_MMSYSERR_HANDLEBUSY: return MA_BUSY;
|
||||
case MA_MMSYSERR_ERROR: return MA_ERROR;
|
||||
default: return MA_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25307,7 +25374,7 @@ we can do things generically and typesafely. Names are being kept the same for c
|
|||
*/
|
||||
typedef struct
|
||||
{
|
||||
CHAR szPname[MAXPNAMELEN];
|
||||
CHAR szPname[MA_MAXPNAMELEN];
|
||||
DWORD dwFormats;
|
||||
WORD wChannels;
|
||||
GUID NameGuid;
|
||||
|
@ -25558,13 +25625,13 @@ static ma_result ma_context_enumerate_devices__winmm(ma_context* pContext, ma_en
|
|||
/* Playback. */
|
||||
playbackDeviceCount = ((MA_PFN_waveOutGetNumDevs)pContext->winmm.waveOutGetNumDevs)();
|
||||
for (iPlaybackDevice = 0; iPlaybackDevice < playbackDeviceCount; ++iPlaybackDevice) {
|
||||
MMRESULT result;
|
||||
MA_MMRESULT result;
|
||||
MA_WAVEOUTCAPS2A caps;
|
||||
|
||||
MA_ZERO_OBJECT(&caps);
|
||||
|
||||
result = ((MA_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(iPlaybackDevice, (WAVEOUTCAPSA*)&caps, sizeof(caps));
|
||||
if (result == MMSYSERR_NOERROR) {
|
||||
result = ((MA_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(iPlaybackDevice, (MA_WAVEOUTCAPSA*)&caps, sizeof(caps));
|
||||
if (result == MA_MMSYSERR_NOERROR) {
|
||||
ma_device_info deviceInfo;
|
||||
|
||||
MA_ZERO_OBJECT(&deviceInfo);
|
||||
|
@ -25587,13 +25654,13 @@ static ma_result ma_context_enumerate_devices__winmm(ma_context* pContext, ma_en
|
|||
/* Capture. */
|
||||
captureDeviceCount = ((MA_PFN_waveInGetNumDevs)pContext->winmm.waveInGetNumDevs)();
|
||||
for (iCaptureDevice = 0; iCaptureDevice < captureDeviceCount; ++iCaptureDevice) {
|
||||
MMRESULT result;
|
||||
MA_MMRESULT result;
|
||||
MA_WAVEINCAPS2A caps;
|
||||
|
||||
MA_ZERO_OBJECT(&caps);
|
||||
|
||||
result = ((MA_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(iCaptureDevice, (WAVEINCAPSA*)&caps, sizeof(caps));
|
||||
if (result == MMSYSERR_NOERROR) {
|
||||
result = ((MA_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(iCaptureDevice, (MA_WAVEINCAPSA*)&caps, sizeof(caps));
|
||||
if (result == MA_MMSYSERR_NOERROR) {
|
||||
ma_device_info deviceInfo;
|
||||
|
||||
MA_ZERO_OBJECT(&deviceInfo);
|
||||
|
@ -25635,23 +25702,23 @@ static ma_result ma_context_get_device_info__winmm(ma_context* pContext, ma_devi
|
|||
}
|
||||
|
||||
if (deviceType == ma_device_type_playback) {
|
||||
MMRESULT result;
|
||||
MA_MMRESULT result;
|
||||
MA_WAVEOUTCAPS2A caps;
|
||||
|
||||
MA_ZERO_OBJECT(&caps);
|
||||
|
||||
result = ((MA_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(winMMDeviceID, (WAVEOUTCAPSA*)&caps, sizeof(caps));
|
||||
if (result == MMSYSERR_NOERROR) {
|
||||
result = ((MA_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(winMMDeviceID, (MA_WAVEOUTCAPSA*)&caps, sizeof(caps));
|
||||
if (result == MA_MMSYSERR_NOERROR) {
|
||||
return ma_context_get_device_info_from_WAVEOUTCAPS2(pContext, &caps, pDeviceInfo);
|
||||
}
|
||||
} else {
|
||||
MMRESULT result;
|
||||
MA_MMRESULT result;
|
||||
MA_WAVEINCAPS2A caps;
|
||||
|
||||
MA_ZERO_OBJECT(&caps);
|
||||
|
||||
result = ((MA_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(winMMDeviceID, (WAVEINCAPSA*)&caps, sizeof(caps));
|
||||
if (result == MMSYSERR_NOERROR) {
|
||||
result = ((MA_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(winMMDeviceID, (MA_WAVEINCAPSA*)&caps, sizeof(caps));
|
||||
if (result == MA_MMSYSERR_NOERROR) {
|
||||
return ma_context_get_device_info_from_WAVEINCAPS2(pContext, &caps, pDeviceInfo);
|
||||
}
|
||||
}
|
||||
|
@ -25665,13 +25732,13 @@ static ma_result ma_device_uninit__winmm(ma_device* pDevice)
|
|||
MA_ASSERT(pDevice != NULL);
|
||||
|
||||
if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
|
||||
((MA_PFN_waveInClose)pDevice->pContext->winmm.waveInClose)((HWAVEIN)pDevice->winmm.hDeviceCapture);
|
||||
((MA_PFN_waveInClose)pDevice->pContext->winmm.waveInClose)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture);
|
||||
CloseHandle((HANDLE)pDevice->winmm.hEventCapture);
|
||||
}
|
||||
|
||||
if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
|
||||
((MA_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset)((HWAVEOUT)pDevice->winmm.hDevicePlayback);
|
||||
((MA_PFN_waveOutClose)pDevice->pContext->winmm.waveOutClose)((HWAVEOUT)pDevice->winmm.hDevicePlayback);
|
||||
((MA_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback);
|
||||
((MA_PFN_waveOutClose)pDevice->pContext->winmm.waveOutClose)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback);
|
||||
CloseHandle((HANDLE)pDevice->winmm.hEventPlayback);
|
||||
}
|
||||
|
||||
|
@ -25728,9 +25795,9 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi
|
|||
|
||||
/* The capture device needs to be initialized first. */
|
||||
if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
|
||||
WAVEINCAPSA caps;
|
||||
MA_WAVEINCAPSA caps;
|
||||
MA_WAVEFORMATEX wf;
|
||||
MMRESULT resultMM;
|
||||
MA_MMRESULT resultMM;
|
||||
|
||||
/* We use an event to know when a new fragment needs to be enqueued. */
|
||||
pDevice->winmm.hEventCapture = (ma_handle)CreateEventA(NULL, TRUE, TRUE, NULL);
|
||||
|
@ -25740,7 +25807,7 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi
|
|||
}
|
||||
|
||||
/* The format should be based on the device's actual format. */
|
||||
if (((MA_PFN_waveInGetDevCapsA)pDevice->pContext->winmm.waveInGetDevCapsA)(winMMDeviceIDCapture, &caps, sizeof(caps)) != MMSYSERR_NOERROR) {
|
||||
if (((MA_PFN_waveInGetDevCapsA)pDevice->pContext->winmm.waveInGetDevCapsA)(winMMDeviceIDCapture, &caps, sizeof(caps)) != MA_MMSYSERR_NOERROR) {
|
||||
errorMsg = "[WinMM] Failed to retrieve internal device caps.", errorCode = MA_FORMAT_NOT_SUPPORTED;
|
||||
goto on_error;
|
||||
}
|
||||
|
@ -25751,8 +25818,8 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi
|
|||
goto on_error;
|
||||
}
|
||||
|
||||
resultMM = ((MA_PFN_waveInOpen)pDevice->pContext->winmm.waveInOpen)((HWAVEIN*)&pDevice->winmm.hDeviceCapture, winMMDeviceIDCapture, &wf, (DWORD_PTR)pDevice->winmm.hEventCapture, (DWORD_PTR)pDevice, CALLBACK_EVENT | WAVE_ALLOWSYNC);
|
||||
if (resultMM != MMSYSERR_NOERROR) {
|
||||
resultMM = ((MA_PFN_waveInOpen)pDevice->pContext->winmm.waveInOpen)((MA_HWAVEIN*)&pDevice->winmm.hDeviceCapture, winMMDeviceIDCapture, &wf, (DWORD_PTR)pDevice->winmm.hEventCapture, (DWORD_PTR)pDevice, MA_CALLBACK_EVENT | MA_WAVE_ALLOWSYNC);
|
||||
if (resultMM != MA_MMSYSERR_NOERROR) {
|
||||
errorMsg = "[WinMM] Failed to open capture device.", errorCode = MA_FAILED_TO_OPEN_BACKEND_DEVICE;
|
||||
goto on_error;
|
||||
}
|
||||
|
@ -25766,9 +25833,9 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi
|
|||
}
|
||||
|
||||
if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
|
||||
WAVEOUTCAPSA caps;
|
||||
MA_WAVEOUTCAPSA caps;
|
||||
MA_WAVEFORMATEX wf;
|
||||
MMRESULT resultMM;
|
||||
MA_MMRESULT resultMM;
|
||||
|
||||
/* We use an event to know when a new fragment needs to be enqueued. */
|
||||
pDevice->winmm.hEventPlayback = (ma_handle)CreateEventA(NULL, TRUE, TRUE, NULL);
|
||||
|
@ -25778,7 +25845,7 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi
|
|||
}
|
||||
|
||||
/* The format should be based on the device's actual format. */
|
||||
if (((MA_PFN_waveOutGetDevCapsA)pDevice->pContext->winmm.waveOutGetDevCapsA)(winMMDeviceIDPlayback, &caps, sizeof(caps)) != MMSYSERR_NOERROR) {
|
||||
if (((MA_PFN_waveOutGetDevCapsA)pDevice->pContext->winmm.waveOutGetDevCapsA)(winMMDeviceIDPlayback, &caps, sizeof(caps)) != MA_MMSYSERR_NOERROR) {
|
||||
errorMsg = "[WinMM] Failed to retrieve internal device caps.", errorCode = MA_FORMAT_NOT_SUPPORTED;
|
||||
goto on_error;
|
||||
}
|
||||
|
@ -25789,8 +25856,8 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi
|
|||
goto on_error;
|
||||
}
|
||||
|
||||
resultMM = ((MA_PFN_waveOutOpen)pDevice->pContext->winmm.waveOutOpen)((HWAVEOUT*)&pDevice->winmm.hDevicePlayback, winMMDeviceIDPlayback, &wf, (DWORD_PTR)pDevice->winmm.hEventPlayback, (DWORD_PTR)pDevice, CALLBACK_EVENT | WAVE_ALLOWSYNC);
|
||||
if (resultMM != MMSYSERR_NOERROR) {
|
||||
resultMM = ((MA_PFN_waveOutOpen)pDevice->pContext->winmm.waveOutOpen)((MA_HWAVEOUT*)&pDevice->winmm.hDevicePlayback, winMMDeviceIDPlayback, &wf, (DWORD_PTR)pDevice->winmm.hEventPlayback, (DWORD_PTR)pDevice, MA_CALLBACK_EVENT | MA_WAVE_ALLOWSYNC);
|
||||
if (resultMM != MA_MMSYSERR_NOERROR) {
|
||||
errorMsg = "[WinMM] Failed to open playback device.", errorCode = MA_FAILED_TO_OPEN_BACKEND_DEVICE;
|
||||
goto on_error;
|
||||
}
|
||||
|
@ -25810,10 +25877,10 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi
|
|||
*/
|
||||
heapSize = 0;
|
||||
if (pConfig->deviceType == ma_device_type_capture || pConfig->deviceType == ma_device_type_duplex) {
|
||||
heapSize += sizeof(WAVEHDR)*pDescriptorCapture->periodCount + (pDescriptorCapture->periodSizeInFrames * pDescriptorCapture->periodCount * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels));
|
||||
heapSize += sizeof(MA_WAVEHDR)*pDescriptorCapture->periodCount + (pDescriptorCapture->periodSizeInFrames * pDescriptorCapture->periodCount * ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels));
|
||||
}
|
||||
if (pConfig->deviceType == ma_device_type_playback || pConfig->deviceType == ma_device_type_duplex) {
|
||||
heapSize += sizeof(WAVEHDR)*pDescriptorPlayback->periodCount + (pDescriptorPlayback->periodSizeInFrames * pDescriptorPlayback->periodCount * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels));
|
||||
heapSize += sizeof(MA_WAVEHDR)*pDescriptorPlayback->periodCount + (pDescriptorPlayback->periodSizeInFrames * pDescriptorPlayback->periodCount * ma_get_bytes_per_frame(pDescriptorPlayback->format, pDescriptorPlayback->channels));
|
||||
}
|
||||
|
||||
pDevice->winmm._pHeapData = (ma_uint8*)ma_calloc(heapSize, &pDevice->pContext->allocationCallbacks);
|
||||
|
@ -25829,27 +25896,27 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi
|
|||
|
||||
if (pConfig->deviceType == ma_device_type_capture) {
|
||||
pDevice->winmm.pWAVEHDRCapture = pDevice->winmm._pHeapData;
|
||||
pDevice->winmm.pIntermediaryBufferCapture = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*(pDescriptorCapture->periodCount));
|
||||
pDevice->winmm.pIntermediaryBufferCapture = pDevice->winmm._pHeapData + (sizeof(MA_WAVEHDR)*(pDescriptorCapture->periodCount));
|
||||
} else {
|
||||
pDevice->winmm.pWAVEHDRCapture = pDevice->winmm._pHeapData;
|
||||
pDevice->winmm.pIntermediaryBufferCapture = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*(pDescriptorCapture->periodCount + pDescriptorPlayback->periodCount));
|
||||
pDevice->winmm.pIntermediaryBufferCapture = pDevice->winmm._pHeapData + (sizeof(MA_WAVEHDR)*(pDescriptorCapture->periodCount + pDescriptorPlayback->periodCount));
|
||||
}
|
||||
|
||||
/* Prepare headers. */
|
||||
for (iPeriod = 0; iPeriod < pDescriptorCapture->periodCount; ++iPeriod) {
|
||||
ma_uint32 periodSizeInBytes = ma_get_period_size_in_bytes(pDescriptorCapture->periodSizeInFrames, pDescriptorCapture->format, pDescriptorCapture->channels);
|
||||
|
||||
((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].lpData = (char*)(pDevice->winmm.pIntermediaryBufferCapture + (periodSizeInBytes*iPeriod));
|
||||
((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwBufferLength = periodSizeInBytes;
|
||||
((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwFlags = 0L;
|
||||
((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwLoops = 0L;
|
||||
((MA_PFN_waveInPrepareHeader)pDevice->pContext->winmm.waveInPrepareHeader)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(WAVEHDR));
|
||||
((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].lpData = (char*)(pDevice->winmm.pIntermediaryBufferCapture + (periodSizeInBytes*iPeriod));
|
||||
((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwBufferLength = periodSizeInBytes;
|
||||
((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwFlags = 0L;
|
||||
((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwLoops = 0L;
|
||||
((MA_PFN_waveInPrepareHeader)pDevice->pContext->winmm.waveInPrepareHeader)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(MA_WAVEHDR));
|
||||
|
||||
/*
|
||||
The user data of the WAVEHDR structure is a single flag the controls whether or not it is ready for writing. Consider it to be named "isLocked". A value of 0 means
|
||||
The user data of the MA_WAVEHDR structure is a single flag the controls whether or not it is ready for writing. Consider it to be named "isLocked". A value of 0 means
|
||||
it's unlocked and available for writing. A value of 1 means it's locked.
|
||||
*/
|
||||
((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwUser = 0;
|
||||
((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwUser = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25858,27 +25925,27 @@ static ma_result ma_device_init__winmm(ma_device* pDevice, const ma_device_confi
|
|||
|
||||
if (pConfig->deviceType == ma_device_type_playback) {
|
||||
pDevice->winmm.pWAVEHDRPlayback = pDevice->winmm._pHeapData;
|
||||
pDevice->winmm.pIntermediaryBufferPlayback = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*pDescriptorPlayback->periodCount);
|
||||
pDevice->winmm.pIntermediaryBufferPlayback = pDevice->winmm._pHeapData + (sizeof(MA_WAVEHDR)*pDescriptorPlayback->periodCount);
|
||||
} else {
|
||||
pDevice->winmm.pWAVEHDRPlayback = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*(pDescriptorCapture->periodCount));
|
||||
pDevice->winmm.pIntermediaryBufferPlayback = pDevice->winmm._pHeapData + (sizeof(WAVEHDR)*(pDescriptorCapture->periodCount + pDescriptorPlayback->periodCount)) + (pDescriptorCapture->periodSizeInFrames*pDescriptorCapture->periodCount*ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels));
|
||||
pDevice->winmm.pWAVEHDRPlayback = pDevice->winmm._pHeapData + (sizeof(MA_WAVEHDR)*(pDescriptorCapture->periodCount));
|
||||
pDevice->winmm.pIntermediaryBufferPlayback = pDevice->winmm._pHeapData + (sizeof(MA_WAVEHDR)*(pDescriptorCapture->periodCount + pDescriptorPlayback->periodCount)) + (pDescriptorCapture->periodSizeInFrames*pDescriptorCapture->periodCount*ma_get_bytes_per_frame(pDescriptorCapture->format, pDescriptorCapture->channels));
|
||||
}
|
||||
|
||||
/* Prepare headers. */
|
||||
for (iPeriod = 0; iPeriod < pDescriptorPlayback->periodCount; ++iPeriod) {
|
||||
ma_uint32 periodSizeInBytes = ma_get_period_size_in_bytes(pDescriptorPlayback->periodSizeInFrames, pDescriptorPlayback->format, pDescriptorPlayback->channels);
|
||||
|
||||
((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].lpData = (char*)(pDevice->winmm.pIntermediaryBufferPlayback + (periodSizeInBytes*iPeriod));
|
||||
((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwBufferLength = periodSizeInBytes;
|
||||
((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwFlags = 0L;
|
||||
((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwLoops = 0L;
|
||||
((MA_PFN_waveOutPrepareHeader)pDevice->pContext->winmm.waveOutPrepareHeader)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(WAVEHDR));
|
||||
((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].lpData = (char*)(pDevice->winmm.pIntermediaryBufferPlayback + (periodSizeInBytes*iPeriod));
|
||||
((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwBufferLength = periodSizeInBytes;
|
||||
((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwFlags = 0L;
|
||||
((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwLoops = 0L;
|
||||
((MA_PFN_waveOutPrepareHeader)pDevice->pContext->winmm.waveOutPrepareHeader)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(MA_WAVEHDR));
|
||||
|
||||
/*
|
||||
The user data of the WAVEHDR structure is a single flag the controls whether or not it is ready for writing. Consider it to be named "isLocked". A value of 0 means
|
||||
The user data of the MA_WAVEHDR structure is a single flag the controls whether or not it is ready for writing. Consider it to be named "isLocked". A value of 0 means
|
||||
it's unlocked and available for writing. A value of 1 means it's locked.
|
||||
*/
|
||||
((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwUser = 0;
|
||||
((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwUser = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25889,22 +25956,22 @@ on_error:
|
|||
if (pDevice->winmm.pWAVEHDRCapture != NULL) {
|
||||
ma_uint32 iPeriod;
|
||||
for (iPeriod = 0; iPeriod < pDescriptorCapture->periodCount; ++iPeriod) {
|
||||
((MA_PFN_waveInUnprepareHeader)pDevice->pContext->winmm.waveInUnprepareHeader)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(WAVEHDR));
|
||||
((MA_PFN_waveInUnprepareHeader)pDevice->pContext->winmm.waveInUnprepareHeader)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(MA_WAVEHDR));
|
||||
}
|
||||
}
|
||||
|
||||
((MA_PFN_waveInClose)pDevice->pContext->winmm.waveInClose)((HWAVEIN)pDevice->winmm.hDeviceCapture);
|
||||
((MA_PFN_waveInClose)pDevice->pContext->winmm.waveInClose)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture);
|
||||
}
|
||||
|
||||
if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
|
||||
if (pDevice->winmm.pWAVEHDRCapture != NULL) {
|
||||
ma_uint32 iPeriod;
|
||||
for (iPeriod = 0; iPeriod < pDescriptorPlayback->periodCount; ++iPeriod) {
|
||||
((MA_PFN_waveOutUnprepareHeader)pDevice->pContext->winmm.waveOutUnprepareHeader)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(WAVEHDR));
|
||||
((MA_PFN_waveOutUnprepareHeader)pDevice->pContext->winmm.waveOutUnprepareHeader)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(MA_WAVEHDR));
|
||||
}
|
||||
}
|
||||
|
||||
((MA_PFN_waveOutClose)pDevice->pContext->winmm.waveOutClose)((HWAVEOUT)pDevice->winmm.hDevicePlayback);
|
||||
((MA_PFN_waveOutClose)pDevice->pContext->winmm.waveOutClose)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback);
|
||||
}
|
||||
|
||||
ma_free(pDevice->winmm._pHeapData, &pDevice->pContext->allocationCallbacks);
|
||||
|
@ -25921,19 +25988,19 @@ static ma_result ma_device_start__winmm(ma_device* pDevice)
|
|||
MA_ASSERT(pDevice != NULL);
|
||||
|
||||
if (pDevice->type == ma_device_type_capture || pDevice->type == ma_device_type_duplex) {
|
||||
MMRESULT resultMM;
|
||||
WAVEHDR* pWAVEHDR;
|
||||
MA_MMRESULT resultMM;
|
||||
MA_WAVEHDR* pWAVEHDR;
|
||||
ma_uint32 iPeriod;
|
||||
|
||||
pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRCapture;
|
||||
pWAVEHDR = (MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture;
|
||||
|
||||
/* Make sure the event is reset to a non-signaled state to ensure we don't prematurely return from WaitForSingleObject(). */
|
||||
ResetEvent((HANDLE)pDevice->winmm.hEventCapture);
|
||||
|
||||
/* To start the device we attach all of the buffers and then start it. As the buffers are filled with data we will get notifications. */
|
||||
for (iPeriod = 0; iPeriod < pDevice->capture.internalPeriods; ++iPeriod) {
|
||||
resultMM = ((MA_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(WAVEHDR));
|
||||
if (resultMM != MMSYSERR_NOERROR) {
|
||||
resultMM = ((MA_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(MA_WAVEHDR));
|
||||
if (resultMM != MA_MMSYSERR_NOERROR) {
|
||||
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WinMM] Failed to attach input buffers to capture device in preparation for capture.");
|
||||
return ma_result_from_MMRESULT(resultMM);
|
||||
}
|
||||
|
@ -25943,8 +26010,8 @@ static ma_result ma_device_start__winmm(ma_device* pDevice)
|
|||
}
|
||||
|
||||
/* Capture devices need to be explicitly started, unlike playback devices. */
|
||||
resultMM = ((MA_PFN_waveInStart)pDevice->pContext->winmm.waveInStart)((HWAVEIN)pDevice->winmm.hDeviceCapture);
|
||||
if (resultMM != MMSYSERR_NOERROR) {
|
||||
resultMM = ((MA_PFN_waveInStart)pDevice->pContext->winmm.waveInStart)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture);
|
||||
if (resultMM != MA_MMSYSERR_NOERROR) {
|
||||
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WinMM] Failed to start backend device.");
|
||||
return ma_result_from_MMRESULT(resultMM);
|
||||
}
|
||||
|
@ -25959,7 +26026,7 @@ static ma_result ma_device_start__winmm(ma_device* pDevice)
|
|||
|
||||
static ma_result ma_device_stop__winmm(ma_device* pDevice)
|
||||
{
|
||||
MMRESULT resultMM;
|
||||
MA_MMRESULT resultMM;
|
||||
|
||||
MA_ASSERT(pDevice != NULL);
|
||||
|
||||
|
@ -25968,22 +26035,22 @@ static ma_result ma_device_stop__winmm(ma_device* pDevice)
|
|||
return MA_INVALID_ARGS;
|
||||
}
|
||||
|
||||
resultMM = ((MA_PFN_waveInReset)pDevice->pContext->winmm.waveInReset)((HWAVEIN)pDevice->winmm.hDeviceCapture);
|
||||
if (resultMM != MMSYSERR_NOERROR) {
|
||||
resultMM = ((MA_PFN_waveInReset)pDevice->pContext->winmm.waveInReset)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture);
|
||||
if (resultMM != MA_MMSYSERR_NOERROR) {
|
||||
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_WARNING, "[WinMM] WARNING: Failed to reset capture device.");
|
||||
}
|
||||
}
|
||||
|
||||
if (pDevice->type == ma_device_type_playback || pDevice->type == ma_device_type_duplex) {
|
||||
ma_uint32 iPeriod;
|
||||
WAVEHDR* pWAVEHDR;
|
||||
MA_WAVEHDR* pWAVEHDR;
|
||||
|
||||
if (pDevice->winmm.hDevicePlayback == NULL) {
|
||||
return MA_INVALID_ARGS;
|
||||
}
|
||||
|
||||
/* We need to drain the device. To do this we just loop over each header and if it's locked just wait for the event. */
|
||||
pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback;
|
||||
pWAVEHDR = (MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback;
|
||||
for (iPeriod = 0; iPeriod < pDevice->playback.internalPeriods; iPeriod += 1) {
|
||||
if (pWAVEHDR[iPeriod].dwUser == 1) { /* 1 = locked. */
|
||||
if (WaitForSingleObject((HANDLE)pDevice->winmm.hEventPlayback, INFINITE) != WAIT_OBJECT_0) {
|
||||
|
@ -25994,8 +26061,8 @@ static ma_result ma_device_stop__winmm(ma_device* pDevice)
|
|||
}
|
||||
}
|
||||
|
||||
resultMM = ((MA_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset)((HWAVEOUT)pDevice->winmm.hDevicePlayback);
|
||||
if (resultMM != MMSYSERR_NOERROR) {
|
||||
resultMM = ((MA_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback);
|
||||
if (resultMM != MA_MMSYSERR_NOERROR) {
|
||||
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_WARNING, "[WinMM] WARNING: Failed to reset playback device.");
|
||||
}
|
||||
}
|
||||
|
@ -26006,9 +26073,9 @@ static ma_result ma_device_stop__winmm(ma_device* pDevice)
|
|||
static ma_result ma_device_write__winmm(ma_device* pDevice, const void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesWritten)
|
||||
{
|
||||
ma_result result = MA_SUCCESS;
|
||||
MMRESULT resultMM;
|
||||
MA_MMRESULT resultMM;
|
||||
ma_uint32 totalFramesWritten;
|
||||
WAVEHDR* pWAVEHDR;
|
||||
MA_WAVEHDR* pWAVEHDR;
|
||||
|
||||
MA_ASSERT(pDevice != NULL);
|
||||
MA_ASSERT(pPCMFrames != NULL);
|
||||
|
@ -26017,7 +26084,7 @@ static ma_result ma_device_write__winmm(ma_device* pDevice, const void* pPCMFram
|
|||
*pFramesWritten = 0;
|
||||
}
|
||||
|
||||
pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback;
|
||||
pWAVEHDR = (MA_WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback;
|
||||
|
||||
/* Keep processing as much data as possible. */
|
||||
totalFramesWritten = 0;
|
||||
|
@ -26042,14 +26109,14 @@ static ma_result ma_device_write__winmm(ma_device* pDevice, const void* pPCMFram
|
|||
/* If we've consumed the buffer entirely we need to write it out to the device. */
|
||||
if (pDevice->winmm.headerFramesConsumedPlayback == (pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwBufferLength/bpf)) {
|
||||
pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwUser = 1; /* 1 = locked. */
|
||||
pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwFlags &= ~WHDR_DONE; /* <-- Need to make sure the WHDR_DONE flag is unset. */
|
||||
pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwFlags &= ~MA_WHDR_DONE; /* <-- Need to make sure the WHDR_DONE flag is unset. */
|
||||
|
||||
/* Make sure the event is reset to a non-signaled state to ensure we don't prematurely return from WaitForSingleObject(). */
|
||||
ResetEvent((HANDLE)pDevice->winmm.hEventPlayback);
|
||||
|
||||
/* The device will be started here. */
|
||||
resultMM = ((MA_PFN_waveOutWrite)pDevice->pContext->winmm.waveOutWrite)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &pWAVEHDR[pDevice->winmm.iNextHeaderPlayback], sizeof(WAVEHDR));
|
||||
if (resultMM != MMSYSERR_NOERROR) {
|
||||
resultMM = ((MA_PFN_waveOutWrite)pDevice->pContext->winmm.waveOutWrite)((MA_HWAVEOUT)pDevice->winmm.hDevicePlayback, &pWAVEHDR[pDevice->winmm.iNextHeaderPlayback], sizeof(MA_WAVEHDR));
|
||||
if (resultMM != MA_MMSYSERR_NOERROR) {
|
||||
result = ma_result_from_MMRESULT(resultMM);
|
||||
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WinMM] waveOutWrite() failed.");
|
||||
break;
|
||||
|
@ -26077,7 +26144,7 @@ static ma_result ma_device_write__winmm(ma_device* pDevice, const void* pPCMFram
|
|||
}
|
||||
|
||||
/* Something happened. If the next buffer has been marked as done we need to reset a bit of state. */
|
||||
if ((pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwFlags & WHDR_DONE) != 0) {
|
||||
if ((pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwFlags & MA_WHDR_DONE) != 0) {
|
||||
pWAVEHDR[pDevice->winmm.iNextHeaderPlayback].dwUser = 0; /* 0 = unlocked (make it available for writing). */
|
||||
pDevice->winmm.headerFramesConsumedPlayback = 0;
|
||||
}
|
||||
|
@ -26098,9 +26165,9 @@ static ma_result ma_device_write__winmm(ma_device* pDevice, const void* pPCMFram
|
|||
static ma_result ma_device_read__winmm(ma_device* pDevice, void* pPCMFrames, ma_uint32 frameCount, ma_uint32* pFramesRead)
|
||||
{
|
||||
ma_result result = MA_SUCCESS;
|
||||
MMRESULT resultMM;
|
||||
MA_MMRESULT resultMM;
|
||||
ma_uint32 totalFramesRead;
|
||||
WAVEHDR* pWAVEHDR;
|
||||
MA_WAVEHDR* pWAVEHDR;
|
||||
|
||||
MA_ASSERT(pDevice != NULL);
|
||||
MA_ASSERT(pPCMFrames != NULL);
|
||||
|
@ -26109,7 +26176,7 @@ static ma_result ma_device_read__winmm(ma_device* pDevice, void* pPCMFrames, ma_
|
|||
*pFramesRead = 0;
|
||||
}
|
||||
|
||||
pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRCapture;
|
||||
pWAVEHDR = (MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture;
|
||||
|
||||
/* Keep processing as much data as possible. */
|
||||
totalFramesRead = 0;
|
||||
|
@ -26131,14 +26198,14 @@ static ma_result ma_device_read__winmm(ma_device* pDevice, void* pPCMFrames, ma_
|
|||
/* If we've consumed the buffer entirely we need to add it back to the device. */
|
||||
if (pDevice->winmm.headerFramesConsumedCapture == (pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwBufferLength/bpf)) {
|
||||
pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwUser = 1; /* 1 = locked. */
|
||||
pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwFlags &= ~WHDR_DONE; /* <-- Need to make sure the WHDR_DONE flag is unset. */
|
||||
pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwFlags &= ~MA_WHDR_DONE; /* <-- Need to make sure the WHDR_DONE flag is unset. */
|
||||
|
||||
/* Make sure the event is reset to a non-signaled state to ensure we don't prematurely return from WaitForSingleObject(). */
|
||||
ResetEvent((HANDLE)pDevice->winmm.hEventCapture);
|
||||
|
||||
/* The device will be started here. */
|
||||
resultMM = ((MA_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[pDevice->winmm.iNextHeaderCapture], sizeof(WAVEHDR));
|
||||
if (resultMM != MMSYSERR_NOERROR) {
|
||||
resultMM = ((MA_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((MA_HWAVEIN)pDevice->winmm.hDeviceCapture, &((MA_WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[pDevice->winmm.iNextHeaderCapture], sizeof(MA_WAVEHDR));
|
||||
if (resultMM != MA_MMSYSERR_NOERROR) {
|
||||
result = ma_result_from_MMRESULT(resultMM);
|
||||
ma_log_post(ma_device_get_log(pDevice), MA_LOG_LEVEL_ERROR, "[WinMM] waveInAddBuffer() failed.");
|
||||
break;
|
||||
|
@ -26166,7 +26233,7 @@ static ma_result ma_device_read__winmm(ma_device* pDevice, void* pPCMFrames, ma_
|
|||
}
|
||||
|
||||
/* Something happened. If the next buffer has been marked as done we need to reset a bit of state. */
|
||||
if ((pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwFlags & WHDR_DONE) != 0) {
|
||||
if ((pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwFlags & MA_WHDR_DONE) != 0) {
|
||||
pWAVEHDR[pDevice->winmm.iNextHeaderCapture].dwUser = 0; /* 0 = unlocked (make it available for reading). */
|
||||
pDevice->winmm.headerFramesConsumedCapture = 0;
|
||||
}
|
||||
|
@ -41246,7 +41313,7 @@ MA_API ma_result ma_context_uninit(ma_context* pContext)
|
|||
return MA_SUCCESS;
|
||||
}
|
||||
|
||||
MA_API size_t ma_context_sizeof()
|
||||
MA_API size_t ma_context_sizeof(void)
|
||||
{
|
||||
return sizeof(ma_context);
|
||||
}
|
||||
|
@ -53646,7 +53713,7 @@ MA_API ma_result ma_channel_converter_get_output_channel_map(const ma_channel_co
|
|||
Data Conversion
|
||||
|
||||
**************************************************************************************************************************************************************/
|
||||
MA_API ma_data_converter_config ma_data_converter_config_init_default()
|
||||
MA_API ma_data_converter_config ma_data_converter_config_init_default(void)
|
||||
{
|
||||
ma_data_converter_config config;
|
||||
MA_ZERO_OBJECT(&config);
|
||||
|
|
Loading…
Reference in a new issue