From f1bf58d0f8b154f5dd40d7a11b8191234eafef5b Mon Sep 17 00:00:00 2001 From: David Reid Date: Wed, 6 Mar 2019 20:51:38 +1000 Subject: [PATCH] "MAL_" to "MA_". --- README.md | 10 +- examples/advanced_config.c | 22 +- examples/simple_capture.c | 4 +- examples/simple_enumeration.c | 4 +- examples/simple_playback.c | 6 +- examples/simple_playback_emscripten.c | 4 +- miniaudio.h | 8242 ++++++++++++------------- research/mal_resampler.h | 136 +- research/mal_ring_buffer.h | 100 +- research/tests/mal_resampler_test_0.c | 4 +- tests/mal_debug_playback.c | 22 +- tests/mal_dithering.c | 16 +- tests/mal_duplex.c | 6 +- tests/mal_no_device_io.c | 6 +- tests/mal_profiling.c | 104 +- tests/mal_resampling.c | 18 +- tests/mal_stop.c | 10 +- tests/mal_test_0.c | 438 +- tools/mini_sigvis/mini_sigvis.h | 48 +- 19 files changed, 4600 insertions(+), 4600 deletions(-) diff --git a/README.md b/README.md index 1a88500d..21657bd3 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ int main(int argc, char** argv) mal_decoder decoder; mal_result result = mal_decoder_init_file(argv[1], NULL, &decoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return -2; } @@ -107,13 +107,13 @@ int main(int argc, char** argv) config.pUserData = &decoder; mal_device device; - if (mal_device_init(NULL, &config, &device) != MAL_SUCCESS) { + if (mal_device_init(NULL, &config, &device) != MA_SUCCESS) { printf("Failed to open playback device.\n"); mal_decoder_uninit(&decoder); return -3; } - if (mal_device_start(&device) != MAL_SUCCESS) { + if (mal_device_start(&device) != MA_SUCCESS) { printf("Failed to start playback device.\n"); mal_device_uninit(&device); mal_decoder_uninit(&decoder); @@ -165,7 +165,7 @@ is an example for loading a decoder from a file: ``` mal_decoder decoder; mal_result result = mal_decoder_init_file("MySong.mp3", NULL, &decoder); -if (result != MAL_SUCCESS) { +if (result != MA_SUCCESS) { return false; // An error occurred. } @@ -195,7 +195,7 @@ You can also seek to a specific frame like so: ``` mal_result result = mal_decoder_seek_to_pcm_frame(pDecoder, targetFrame); -if (result != MAL_SUCCESS) { +if (result != MA_SUCCESS) { return false; // An error occurred. } ``` diff --git a/examples/advanced_config.c b/examples/advanced_config.c index 545aba74..1d8ad577 100644 --- a/examples/advanced_config.c +++ b/examples/advanced_config.c @@ -55,7 +55,7 @@ int main(int argc, char** argv) // During initialization, PulseAudio can try to automatically start the PulseAudio daemon. This does not // suit miniaudio's trial and error backend initialization architecture so it's disabled by default, but you // can enable it like so: - contextConfig.pulse.tryAutoSpawn = MAL_TRUE; + contextConfig.pulse.tryAutoSpawn = MA_TRUE; // ALSA @@ -65,7 +65,7 @@ int main(int argc, char** argv) // combat this, miniaudio will include only unique card/device pairs by default. The problem with this is that // you lose a bit of flexibility and control. Setting alsa.useVerboseDeviceEnumeration makes it so the ALSA // backend includes all devices (and there's a lot of them!). - contextConfig.alsa.useVerboseDeviceEnumeration = MAL_TRUE; + contextConfig.alsa.useVerboseDeviceEnumeration = MA_TRUE; // JACK @@ -75,7 +75,7 @@ int main(int argc, char** argv) contextConfig.jack.pClientName = "My Application"; // Also like PulseAudio, you can have JACK try to automatically start using the following: - contextConfig.jack.tryStartServer = MAL_TRUE; + contextConfig.jack.tryStartServer = MA_TRUE; @@ -100,7 +100,7 @@ int main(int argc, char** argv) }; mal_context context; - if (mal_context_init(backends, sizeof(backends)/sizeof(backends[0]), &contextConfig, &context) != MAL_SUCCESS) { + if (mal_context_init(backends, sizeof(backends)/sizeof(backends[0]), &contextConfig, &context) != MA_SUCCESS) { printf("Failed to initialize context."); return -2; } @@ -112,7 +112,7 @@ int main(int argc, char** argv) mal_device_info* pCaptureDeviceInfos; mal_uint32 captureDeviceCount; mal_result result = mal_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, &pCaptureDeviceInfos, &captureDeviceCount); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to retrieve device information.\n"); return -3; } @@ -154,21 +154,21 @@ int main(int argc, char** argv) // miniaudio allows applications to control the mapping of channels. The config below swaps the left and right // channels. Normally in an interleaved audio stream, the left channel comes first, but we can change that // like the following: - deviceConfig.playback.channelMap[0] = MAL_CHANNEL_FRONT_RIGHT; - deviceConfig.playback.channelMap[1] = MAL_CHANNEL_FRONT_LEFT; + deviceConfig.playback.channelMap[0] = MA_CHANNEL_FRONT_RIGHT; + deviceConfig.playback.channelMap[1] = MA_CHANNEL_FRONT_LEFT; // The ALSA backend has two ways of delivering data to and from a device: memory mapping and read/write. By // default memory mapping will be used over read/write because it avoids a single point of data movement // internally and is thus, theoretically, more efficient. In testing, however, this has been less stable than // read/write mode so an option exists to disable it if need be. This is mainly for debugging, but is left // here in case it might be useful for others. If you find a bug specific to mmap mode, please report it! - deviceConfig.alsa.noMMap = MAL_TRUE; + deviceConfig.alsa.noMMap = MA_TRUE; // This is not used in this example, but miniaudio allows you to directly control the device ID that's used // for device selection by mal_device_init(). Below is an example for ALSA. In this example it forces // mal_device_init() to try opening the "hw:0,0" device. This is useful for debugging in case you have // audio glitches or whatnot with specific devices. -#ifdef MAL_SUPPORT_ALSA +#ifdef MA_SUPPORT_ALSA mal_device_id customDeviceID; if (context.backend == mal_backend_alsa) { strcpy(customDeviceID.alsa, "hw:0,0"); @@ -182,13 +182,13 @@ int main(int argc, char** argv) #endif mal_device playbackDevice; - if (mal_device_init(&context, &deviceConfig, &playbackDevice) != MAL_SUCCESS) { + if (mal_device_init(&context, &deviceConfig, &playbackDevice) != MA_SUCCESS) { printf("Failed to initialize playback device.\n"); mal_context_uninit(&context); return -7; } - if (mal_device_start(&playbackDevice) != MAL_SUCCESS) { + if (mal_device_start(&playbackDevice) != MA_SUCCESS) { printf("Failed to start playback device.\n"); mal_device_uninit(&playbackDevice); mal_context_uninit(&context); diff --git a/examples/simple_capture.c b/examples/simple_capture.c index 63e1fad2..631c546c 100644 --- a/examples/simple_capture.c +++ b/examples/simple_capture.c @@ -50,13 +50,13 @@ int main(int argc, char** argv) mal_device device; result = mal_device_init(NULL, &config, &device); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize capture device.\n"); return -2; } result = mal_device_start(&device); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { mal_device_uninit(&device); printf("Failed to start device.\n"); return -3; diff --git a/examples/simple_enumeration.c b/examples/simple_enumeration.c index c208693e..3d35df1f 100644 --- a/examples/simple_enumeration.c +++ b/examples/simple_enumeration.c @@ -9,7 +9,7 @@ int main(int argc, char** argv) (void)argv; mal_context context; - if (mal_context_init(NULL, 0, NULL, &context) != MAL_SUCCESS) { + if (mal_context_init(NULL, 0, NULL, &context) != MA_SUCCESS) { printf("Failed to initialize context.\n"); return -2; } @@ -19,7 +19,7 @@ int main(int argc, char** argv) mal_device_info* pCaptureDeviceInfos; mal_uint32 captureDeviceCount; mal_result result = mal_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, &pCaptureDeviceInfos, &captureDeviceCount); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to retrieve device information.\n"); return -3; } diff --git a/examples/simple_playback.c b/examples/simple_playback.c index 7a79f546..dd1c668d 100644 --- a/examples/simple_playback.c +++ b/examples/simple_playback.c @@ -31,7 +31,7 @@ int main(int argc, char** argv) mal_decoder decoder; mal_result result = mal_decoder_init_file(argv[1], NULL, &decoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return -2; } @@ -43,13 +43,13 @@ int main(int argc, char** argv) config.pUserData = &decoder; mal_device device; - if (mal_device_init(NULL, &config, &device) != MAL_SUCCESS) { + if (mal_device_init(NULL, &config, &device) != MA_SUCCESS) { printf("Failed to open playback device.\n"); mal_decoder_uninit(&decoder); return -3; } - if (mal_device_start(&device) != MAL_SUCCESS) { + if (mal_device_start(&device) != MA_SUCCESS) { printf("Failed to start playback device.\n"); mal_device_uninit(&device); mal_decoder_uninit(&decoder); diff --git a/examples/simple_playback_emscripten.c b/examples/simple_playback_emscripten.c index b3f68700..a8b41003 100644 --- a/examples/simple_playback_emscripten.c +++ b/examples/simple_playback_emscripten.c @@ -42,14 +42,14 @@ int main(int argc, char** argv) config.pUserData = &sineWave; mal_device device; - if (mal_device_init(NULL, &config, &device) != MAL_SUCCESS) { + if (mal_device_init(NULL, &config, &device) != MA_SUCCESS) { printf("Failed to open playback device.\n"); return -4; } printf("Device Name: %s\n", device.playback.name); - if (mal_device_start(&device) != MAL_SUCCESS) { + if (mal_device_start(&device) != MA_SUCCESS) { printf("Failed to start playback device.\n"); mal_device_uninit(&device); return -5; diff --git a/miniaudio.h b/miniaudio.h index 97a20eec..b84e51a7 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -55,7 +55,7 @@ The major feature added to version 0.9 is full-duplex. This has necessitated a f config.pUserData = &myUserData; result = mal_device_init(&myContext, &config, &device); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { ... handle error ... } @@ -186,7 +186,7 @@ Playback Example config.pUserData = &decoder; mal_device device; - if (mal_device_init(NULL, &config, &device) != MAL_SUCCESS) { + if (mal_device_init(NULL, &config, &device) != MA_SUCCESS) { ... An error occurred ... } @@ -202,7 +202,7 @@ BUILDING miniaudio should Just Work by adding it to your project's source tree. You do not need to download or install any dependencies. See below for platform-specific details. -If you want to disable a specific backend, #define the appropriate MAL_NO_* option before the implementation. +If you want to disable a specific backend, #define the appropriate MA_NO_* option before the implementation. Note that GCC and Clang requires "-msse2", "-mavx2", etc. for SIMD optimizations. @@ -299,89 +299,89 @@ OPTIONS ======= #define these options before including this file. -#define MAL_NO_WASAPI +#define MA_NO_WASAPI Disables the WASAPI backend. -#define MAL_NO_DSOUND +#define MA_NO_DSOUND Disables the DirectSound backend. -#define MAL_NO_WINMM +#define MA_NO_WINMM Disables the WinMM backend. -#define MAL_NO_ALSA +#define MA_NO_ALSA Disables the ALSA backend. -#define MAL_NO_PULSEAUDIO +#define MA_NO_PULSEAUDIO Disables the PulseAudio backend. -#define MAL_NO_JACK +#define MA_NO_JACK Disables the JACK backend. -#define MAL_NO_COREAUDIO +#define MA_NO_COREAUDIO Disables the Core Audio backend. -#define MAL_NO_SNDIO +#define MA_NO_SNDIO Disables the sndio backend. -#define MAL_NO_AUDIO4 +#define MA_NO_AUDIO4 Disables the audio(4) backend. -#define MAL_NO_OSS +#define MA_NO_OSS Disables the OSS backend. -#define MAL_NO_AAUDIO +#define MA_NO_AAUDIO Disables the AAudio backend. -#define MAL_NO_OPENSL +#define MA_NO_OPENSL Disables the OpenSL|ES backend. -#define MAL_NO_WEBAUDIO +#define MA_NO_WEBAUDIO Disables the Web Audio backend. -#define MAL_NO_NULL +#define MA_NO_NULL Disables the null backend. -#define MAL_DEFAULT_PERIODS +#define MA_DEFAULT_PERIODS When a period count of 0 is specified when a device is initialized, it will default to this. -#define MAL_BASE_BUFFER_SIZE_IN_MILLISECONDS_LOW_LATENCY -#define MAL_BASE_BUFFER_SIZE_IN_MILLISECONDS_CONSERVATIVE +#define MA_BASE_BUFFER_SIZE_IN_MILLISECONDS_LOW_LATENCY +#define MA_BASE_BUFFER_SIZE_IN_MILLISECONDS_CONSERVATIVE When a buffer size of 0 is specified when a device is initialized it will default to a buffer of this size, depending on the chosen performance profile. These can be increased or decreased depending on your specific requirements. -#define MAL_NO_DECODING +#define MA_NO_DECODING Disables the decoding APIs. -#define MAL_NO_DEVICE_IO +#define MA_NO_DEVICE_IO Disables playback and recording. This will disable mal_context and mal_device APIs. This is useful if you only want to use miniaudio's data conversion and/or decoding APIs. -#define MAL_NO_STDIO +#define MA_NO_STDIO Disables file IO APIs. -#define MAL_NO_SSE2 +#define MA_NO_SSE2 Disables SSE2 optimizations. -#define MAL_NO_AVX2 +#define MA_NO_AVX2 Disables AVX2 optimizations. -#define MAL_NO_AVX512 +#define MA_NO_AVX512 Disables AVX-512 optimizations. -#define MAL_NO_NEON +#define MA_NO_NEON Disables NEON optimizations. -#define MAL_LOG_LEVEL +#define MA_LOG_LEVEL Sets the logging level. Set level to one of the following: - MAL_LOG_LEVEL_VERBOSE - MAL_LOG_LEVEL_INFO - MAL_LOG_LEVEL_WARNING - MAL_LOG_LEVEL_ERROR + MA_LOG_LEVEL_VERBOSE + MA_LOG_LEVEL_INFO + MA_LOG_LEVEL_WARNING + MA_LOG_LEVEL_ERROR -#define MAL_DEBUT_OUTPUT +#define MA_DEBUT_OUTPUT Enable printf() debug output. -#define MAL_COINIT_VALUE +#define MA_COINIT_VALUE Windows only. The value to pass to internal calls to CoInitializeEx(). Defaults to COINIT_MULTITHREADED. @@ -439,33 +439,33 @@ extern "C" { // Platform/backend detection. #ifdef _WIN32 - #define MAL_WIN32 + #define MA_WIN32 #if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PC_APP || WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) - #define MAL_WIN32_UWP + #define MA_WIN32_UWP #else - #define MAL_WIN32_DESKTOP + #define MA_WIN32_DESKTOP #endif #else - #define MAL_POSIX + #define MA_POSIX #include // Unfortunate #include, but needed for pthread_t, pthread_mutex_t and pthread_cond_t types. #ifdef __unix__ - #define MAL_UNIX + #define MA_UNIX #if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) - #define MAL_BSD + #define MA_BSD #endif #endif #ifdef __linux__ - #define MAL_LINUX + #define MA_LINUX #endif #ifdef __APPLE__ - #define MAL_APPLE + #define MA_APPLE #endif #ifdef __ANDROID__ - #define MAL_ANDROID + #define MA_ANDROID #endif #ifdef __EMSCRIPTEN__ - #define MAL_EMSCRIPTEN + #define MA_EMSCRIPTEN #endif #endif @@ -490,7 +490,7 @@ extern "C" { #pragma GCC diagnostic pop #endif #else - #define MAL_HAS_STDINT + #define MA_HAS_STDINT #include typedef int8_t mal_int8; typedef uint8_t mal_uint8; @@ -502,7 +502,7 @@ extern "C" { typedef uint64_t mal_uint64; #endif -#ifdef MAL_HAS_STDINT +#ifdef MA_HAS_STDINT typedef uintptr_t mal_uintptr; #else #if defined(_WIN32) @@ -524,8 +524,8 @@ extern "C" { typedef mal_uint8 mal_bool8; typedef mal_uint32 mal_bool32; -#define MAL_TRUE 1 -#define MAL_FALSE 0 +#define MA_TRUE 1 +#define MA_FALSE 0 typedef void* mal_handle; typedef void* mal_ptr; @@ -541,182 +541,182 @@ typedef mal_uint16 wchar_t; #endif #if defined(SIZE_MAX) - #define MAL_SIZE_MAX SIZE_MAX + #define MA_SIZE_MAX SIZE_MAX #else - #define MAL_SIZE_MAX 0xFFFFFFFF /* When SIZE_MAX is not defined by the standard library just default to the maximum 32-bit unsigned integer. */ + #define MA_SIZE_MAX 0xFFFFFFFF /* When SIZE_MAX is not defined by the standard library just default to the maximum 32-bit unsigned integer. */ #endif #ifdef _MSC_VER -#define MAL_INLINE __forceinline +#define MA_INLINE __forceinline #else #ifdef __GNUC__ -#define MAL_INLINE inline __attribute__((always_inline)) +#define MA_INLINE inline __attribute__((always_inline)) #else -#define MAL_INLINE inline +#define MA_INLINE inline #endif #endif #ifdef _MSC_VER -#define MAL_ALIGN(alignment) __declspec(align(alignment)) +#define MA_ALIGN(alignment) __declspec(align(alignment)) #elif !defined(__DMC__) -#define MAL_ALIGN(alignment) __attribute__((aligned(alignment))) +#define MA_ALIGN(alignment) __attribute__((aligned(alignment))) #else -#define MAL_ALIGN(alignment) +#define MA_ALIGN(alignment) #endif #ifdef _MSC_VER -#define MAL_ALIGNED_STRUCT(alignment) MAL_ALIGN(alignment) struct +#define MA_ALIGNED_STRUCT(alignment) MA_ALIGN(alignment) struct #else -#define MAL_ALIGNED_STRUCT(alignment) struct MAL_ALIGN(alignment) +#define MA_ALIGNED_STRUCT(alignment) struct MA_ALIGN(alignment) #endif // SIMD alignment in bytes. Currently set to 64 bytes in preparation for future AVX-512 optimizations. -#define MAL_SIMD_ALIGNMENT 64 +#define MA_SIMD_ALIGNMENT 64 // Logging levels -#define MAL_LOG_LEVEL_VERBOSE 4 -#define MAL_LOG_LEVEL_INFO 3 -#define MAL_LOG_LEVEL_WARNING 2 -#define MAL_LOG_LEVEL_ERROR 1 +#define MA_LOG_LEVEL_VERBOSE 4 +#define MA_LOG_LEVEL_INFO 3 +#define MA_LOG_LEVEL_WARNING 2 +#define MA_LOG_LEVEL_ERROR 1 -#ifndef MAL_LOG_LEVEL -#define MAL_LOG_LEVEL MAL_LOG_LEVEL_ERROR +#ifndef MA_LOG_LEVEL +#define MA_LOG_LEVEL MA_LOG_LEVEL_ERROR #endif typedef struct mal_context mal_context; typedef struct mal_device mal_device; typedef mal_uint8 mal_channel; -#define MAL_CHANNEL_NONE 0 -#define MAL_CHANNEL_MONO 1 -#define MAL_CHANNEL_FRONT_LEFT 2 -#define MAL_CHANNEL_FRONT_RIGHT 3 -#define MAL_CHANNEL_FRONT_CENTER 4 -#define MAL_CHANNEL_LFE 5 -#define MAL_CHANNEL_BACK_LEFT 6 -#define MAL_CHANNEL_BACK_RIGHT 7 -#define MAL_CHANNEL_FRONT_LEFT_CENTER 8 -#define MAL_CHANNEL_FRONT_RIGHT_CENTER 9 -#define MAL_CHANNEL_BACK_CENTER 10 -#define MAL_CHANNEL_SIDE_LEFT 11 -#define MAL_CHANNEL_SIDE_RIGHT 12 -#define MAL_CHANNEL_TOP_CENTER 13 -#define MAL_CHANNEL_TOP_FRONT_LEFT 14 -#define MAL_CHANNEL_TOP_FRONT_CENTER 15 -#define MAL_CHANNEL_TOP_FRONT_RIGHT 16 -#define MAL_CHANNEL_TOP_BACK_LEFT 17 -#define MAL_CHANNEL_TOP_BACK_CENTER 18 -#define MAL_CHANNEL_TOP_BACK_RIGHT 19 -#define MAL_CHANNEL_AUX_0 20 -#define MAL_CHANNEL_AUX_1 21 -#define MAL_CHANNEL_AUX_2 22 -#define MAL_CHANNEL_AUX_3 23 -#define MAL_CHANNEL_AUX_4 24 -#define MAL_CHANNEL_AUX_5 25 -#define MAL_CHANNEL_AUX_6 26 -#define MAL_CHANNEL_AUX_7 27 -#define MAL_CHANNEL_AUX_8 28 -#define MAL_CHANNEL_AUX_9 29 -#define MAL_CHANNEL_AUX_10 30 -#define MAL_CHANNEL_AUX_11 31 -#define MAL_CHANNEL_AUX_12 32 -#define MAL_CHANNEL_AUX_13 33 -#define MAL_CHANNEL_AUX_14 34 -#define MAL_CHANNEL_AUX_15 35 -#define MAL_CHANNEL_AUX_16 36 -#define MAL_CHANNEL_AUX_17 37 -#define MAL_CHANNEL_AUX_18 38 -#define MAL_CHANNEL_AUX_19 39 -#define MAL_CHANNEL_AUX_20 40 -#define MAL_CHANNEL_AUX_21 41 -#define MAL_CHANNEL_AUX_22 42 -#define MAL_CHANNEL_AUX_23 43 -#define MAL_CHANNEL_AUX_24 44 -#define MAL_CHANNEL_AUX_25 45 -#define MAL_CHANNEL_AUX_26 46 -#define MAL_CHANNEL_AUX_27 47 -#define MAL_CHANNEL_AUX_28 48 -#define MAL_CHANNEL_AUX_29 49 -#define MAL_CHANNEL_AUX_30 50 -#define MAL_CHANNEL_AUX_31 51 -#define MAL_CHANNEL_LEFT MAL_CHANNEL_FRONT_LEFT -#define MAL_CHANNEL_RIGHT MAL_CHANNEL_FRONT_RIGHT -#define MAL_CHANNEL_POSITION_COUNT MAL_CHANNEL_AUX_31 + 1 +#define MA_CHANNEL_NONE 0 +#define MA_CHANNEL_MONO 1 +#define MA_CHANNEL_FRONT_LEFT 2 +#define MA_CHANNEL_FRONT_RIGHT 3 +#define MA_CHANNEL_FRONT_CENTER 4 +#define MA_CHANNEL_LFE 5 +#define MA_CHANNEL_BACK_LEFT 6 +#define MA_CHANNEL_BACK_RIGHT 7 +#define MA_CHANNEL_FRONT_LEFT_CENTER 8 +#define MA_CHANNEL_FRONT_RIGHT_CENTER 9 +#define MA_CHANNEL_BACK_CENTER 10 +#define MA_CHANNEL_SIDE_LEFT 11 +#define MA_CHANNEL_SIDE_RIGHT 12 +#define MA_CHANNEL_TOP_CENTER 13 +#define MA_CHANNEL_TOP_FRONT_LEFT 14 +#define MA_CHANNEL_TOP_FRONT_CENTER 15 +#define MA_CHANNEL_TOP_FRONT_RIGHT 16 +#define MA_CHANNEL_TOP_BACK_LEFT 17 +#define MA_CHANNEL_TOP_BACK_CENTER 18 +#define MA_CHANNEL_TOP_BACK_RIGHT 19 +#define MA_CHANNEL_AUX_0 20 +#define MA_CHANNEL_AUX_1 21 +#define MA_CHANNEL_AUX_2 22 +#define MA_CHANNEL_AUX_3 23 +#define MA_CHANNEL_AUX_4 24 +#define MA_CHANNEL_AUX_5 25 +#define MA_CHANNEL_AUX_6 26 +#define MA_CHANNEL_AUX_7 27 +#define MA_CHANNEL_AUX_8 28 +#define MA_CHANNEL_AUX_9 29 +#define MA_CHANNEL_AUX_10 30 +#define MA_CHANNEL_AUX_11 31 +#define MA_CHANNEL_AUX_12 32 +#define MA_CHANNEL_AUX_13 33 +#define MA_CHANNEL_AUX_14 34 +#define MA_CHANNEL_AUX_15 35 +#define MA_CHANNEL_AUX_16 36 +#define MA_CHANNEL_AUX_17 37 +#define MA_CHANNEL_AUX_18 38 +#define MA_CHANNEL_AUX_19 39 +#define MA_CHANNEL_AUX_20 40 +#define MA_CHANNEL_AUX_21 41 +#define MA_CHANNEL_AUX_22 42 +#define MA_CHANNEL_AUX_23 43 +#define MA_CHANNEL_AUX_24 44 +#define MA_CHANNEL_AUX_25 45 +#define MA_CHANNEL_AUX_26 46 +#define MA_CHANNEL_AUX_27 47 +#define MA_CHANNEL_AUX_28 48 +#define MA_CHANNEL_AUX_29 49 +#define MA_CHANNEL_AUX_30 50 +#define MA_CHANNEL_AUX_31 51 +#define MA_CHANNEL_LEFT MA_CHANNEL_FRONT_LEFT +#define MA_CHANNEL_RIGHT MA_CHANNEL_FRONT_RIGHT +#define MA_CHANNEL_POSITION_COUNT MA_CHANNEL_AUX_31 + 1 typedef int mal_result; -#define MAL_SUCCESS 0 +#define MA_SUCCESS 0 /* General errors. */ -#define MAL_ERROR -1 /* A generic error. */ -#define MAL_INVALID_ARGS -2 -#define MAL_INVALID_OPERATION -3 -#define MAL_OUT_OF_MEMORY -4 -#define MAL_ACCESS_DENIED -5 -#define MAL_TOO_LARGE -6 -#define MAL_TIMEOUT -7 +#define MA_ERROR -1 /* A generic error. */ +#define MA_INVALID_ARGS -2 +#define MA_INVALID_OPERATION -3 +#define MA_OUT_OF_MEMORY -4 +#define MA_ACCESS_DENIED -5 +#define MA_TOO_LARGE -6 +#define MA_TIMEOUT -7 /* General miniaudio-specific errors. */ -#define MAL_FORMAT_NOT_SUPPORTED -100 -#define MAL_DEVICE_TYPE_NOT_SUPPORTED -101 -#define MAL_SHARE_MODE_NOT_SUPPORTED -102 -#define MAL_NO_BACKEND -103 -#define MAL_NO_DEVICE -104 -#define MAL_API_NOT_FOUND -105 -#define MAL_INVALID_DEVICE_CONFIG -106 +#define MA_FORMAT_NOT_SUPPORTED -100 +#define MA_DEVICE_TYPE_NOT_SUPPORTED -101 +#define MA_SHARE_MODE_NOT_SUPPORTED -102 +#define MA_NO_BACKEND -103 +#define MA_NO_DEVICE -104 +#define MA_API_NOT_FOUND -105 +#define MA_INVALID_DEVICE_CONFIG -106 /* State errors. */ -#define MAL_DEVICE_BUSY -200 -#define MAL_DEVICE_NOT_INITIALIZED -201 -#define MAL_DEVICE_NOT_STARTED -202 -#define MAL_DEVICE_UNAVAILABLE -203 +#define MA_DEVICE_BUSY -200 +#define MA_DEVICE_NOT_INITIALIZED -201 +#define MA_DEVICE_NOT_STARTED -202 +#define MA_DEVICE_UNAVAILABLE -203 /* Operation errors. */ -#define MAL_FAILED_TO_MAP_DEVICE_BUFFER -300 -#define MAL_FAILED_TO_UNMAP_DEVICE_BUFFER -301 -#define MAL_FAILED_TO_INIT_BACKEND -302 -#define MAL_FAILED_TO_READ_DATA_FROM_CLIENT -303 -#define MAL_FAILED_TO_READ_DATA_FROM_DEVICE -304 -#define MAL_FAILED_TO_SEND_DATA_TO_CLIENT -305 -#define MAL_FAILED_TO_SEND_DATA_TO_DEVICE -306 -#define MAL_FAILED_TO_OPEN_BACKEND_DEVICE -307 -#define MAL_FAILED_TO_START_BACKEND_DEVICE -308 -#define MAL_FAILED_TO_STOP_BACKEND_DEVICE -309 -#define MAL_FAILED_TO_CONFIGURE_BACKEND_DEVICE -310 -#define MAL_FAILED_TO_CREATE_MUTEX -311 -#define MAL_FAILED_TO_CREATE_EVENT -312 -#define MAL_FAILED_TO_CREATE_THREAD -313 +#define MA_FAILED_TO_MAP_DEVICE_BUFFER -300 +#define MA_FAILED_TO_UNMAP_DEVICE_BUFFER -301 +#define MA_FAILED_TO_INIT_BACKEND -302 +#define MA_FAILED_TO_READ_DATA_FROM_CLIENT -303 +#define MA_FAILED_TO_READ_DATA_FROM_DEVICE -304 +#define MA_FAILED_TO_SEND_DATA_TO_CLIENT -305 +#define MA_FAILED_TO_SEND_DATA_TO_DEVICE -306 +#define MA_FAILED_TO_OPEN_BACKEND_DEVICE -307 +#define MA_FAILED_TO_START_BACKEND_DEVICE -308 +#define MA_FAILED_TO_STOP_BACKEND_DEVICE -309 +#define MA_FAILED_TO_CONFIGURE_BACKEND_DEVICE -310 +#define MA_FAILED_TO_CREATE_MUTEX -311 +#define MA_FAILED_TO_CREATE_EVENT -312 +#define MA_FAILED_TO_CREATE_THREAD -313 // Standard sample rates. -#define MAL_SAMPLE_RATE_8000 8000 -#define MAL_SAMPLE_RATE_11025 11025 -#define MAL_SAMPLE_RATE_16000 16000 -#define MAL_SAMPLE_RATE_22050 22050 -#define MAL_SAMPLE_RATE_24000 24000 -#define MAL_SAMPLE_RATE_32000 32000 -#define MAL_SAMPLE_RATE_44100 44100 -#define MAL_SAMPLE_RATE_48000 48000 -#define MAL_SAMPLE_RATE_88200 88200 -#define MAL_SAMPLE_RATE_96000 96000 -#define MAL_SAMPLE_RATE_176400 176400 -#define MAL_SAMPLE_RATE_192000 192000 -#define MAL_SAMPLE_RATE_352800 352800 -#define MAL_SAMPLE_RATE_384000 384000 +#define MA_SAMPLE_RATE_8000 8000 +#define MA_SAMPLE_RATE_11025 11025 +#define MA_SAMPLE_RATE_16000 16000 +#define MA_SAMPLE_RATE_22050 22050 +#define MA_SAMPLE_RATE_24000 24000 +#define MA_SAMPLE_RATE_32000 32000 +#define MA_SAMPLE_RATE_44100 44100 +#define MA_SAMPLE_RATE_48000 48000 +#define MA_SAMPLE_RATE_88200 88200 +#define MA_SAMPLE_RATE_96000 96000 +#define MA_SAMPLE_RATE_176400 176400 +#define MA_SAMPLE_RATE_192000 192000 +#define MA_SAMPLE_RATE_352800 352800 +#define MA_SAMPLE_RATE_384000 384000 -#define MAL_MIN_PCM_SAMPLE_SIZE_IN_BYTES 1 // For simplicity, miniaudio does not support PCM samples that are not byte aligned. -#define MAL_MAX_PCM_SAMPLE_SIZE_IN_BYTES 8 -#define MAL_MIN_CHANNELS 1 -#define MAL_MAX_CHANNELS 32 -#define MAL_MIN_SAMPLE_RATE MAL_SAMPLE_RATE_8000 -#define MAL_MAX_SAMPLE_RATE MAL_SAMPLE_RATE_384000 -#define MAL_SRC_SINC_MIN_WINDOW_WIDTH 2 -#define MAL_SRC_SINC_MAX_WINDOW_WIDTH 32 -#define MAL_SRC_SINC_DEFAULT_WINDOW_WIDTH 32 -#define MAL_SRC_SINC_LOOKUP_TABLE_RESOLUTION 8 -#define MAL_SRC_INPUT_BUFFER_SIZE_IN_SAMPLES 256 +#define MA_MIN_PCM_SAMPLE_SIZE_IN_BYTES 1 // For simplicity, miniaudio does not support PCM samples that are not byte aligned. +#define MA_MAX_PCM_SAMPLE_SIZE_IN_BYTES 8 +#define MA_MIN_CHANNELS 1 +#define MA_MAX_CHANNELS 32 +#define MA_MIN_SAMPLE_RATE MA_SAMPLE_RATE_8000 +#define MA_MAX_SAMPLE_RATE MA_SAMPLE_RATE_384000 +#define MA_SRC_SINC_MIN_WINDOW_WIDTH 2 +#define MA_SRC_SINC_MAX_WINDOW_WIDTH 32 +#define MA_SRC_SINC_DEFAULT_WINDOW_WIDTH 32 +#define MA_SRC_SINC_LOOKUP_TABLE_RESOLUTION 8 +#define MA_SRC_INPUT_BUFFER_SIZE_IN_SAMPLES 256 typedef enum { @@ -820,10 +820,10 @@ typedef struct { mal_uint32 channelsIn; mal_uint32 channelsOut; - mal_channel channelMapIn[MAL_MAX_CHANNELS]; - mal_channel channelMapOut[MAL_MAX_CHANNELS]; + mal_channel channelMapIn[MA_MAX_CHANNELS]; + mal_channel channelMapOut[MA_MAX_CHANNELS]; mal_channel_mix_mode mixingMode; - float weights[MAL_MAX_CHANNELS][MAL_MAX_CHANNELS]; // [in][out]. Only used when mixingMode is set to mal_channel_mix_mode_custom_weights. + float weights[MA_MAX_CHANNELS][MA_MAX_CHANNELS]; // [in][out]. Only used when mixingMode is set to mal_channel_mix_mode_custom_weights. mal_bool32 noSSE2 : 1; mal_bool32 noAVX2 : 1; mal_bool32 noAVX512 : 1; @@ -841,7 +841,7 @@ struct mal_channel_router mal_bool32 useAVX2 : 1; mal_bool32 useAVX512 : 1; mal_bool32 useNEON : 1; - mal_uint8 shuffleTable[MAL_MAX_CHANNELS]; + mal_uint8 shuffleTable[MA_MAX_CHANNELS]; }; @@ -889,24 +889,24 @@ typedef struct }; } mal_src_config; -MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_src +MA_ALIGNED_STRUCT(MA_SIMD_ALIGNMENT) mal_src { union { struct { - MAL_ALIGN(MAL_SIMD_ALIGNMENT) float input[MAL_MAX_CHANNELS][MAL_SRC_INPUT_BUFFER_SIZE_IN_SAMPLES]; + MA_ALIGN(MA_SIMD_ALIGNMENT) float input[MA_MAX_CHANNELS][MA_SRC_INPUT_BUFFER_SIZE_IN_SAMPLES]; float timeIn; mal_uint32 leftoverFrames; } linear; struct { - MAL_ALIGN(MAL_SIMD_ALIGNMENT) float input[MAL_MAX_CHANNELS][MAL_SRC_SINC_MAX_WINDOW_WIDTH*2 + MAL_SRC_INPUT_BUFFER_SIZE_IN_SAMPLES]; + MA_ALIGN(MA_SIMD_ALIGNMENT) float input[MA_MAX_CHANNELS][MA_SRC_SINC_MAX_WINDOW_WIDTH*2 + MA_SRC_INPUT_BUFFER_SIZE_IN_SAMPLES]; float timeIn; mal_uint32 inputFrameCount; // The number of frames sitting in the input buffer, not including the first half of the window. mal_uint32 windowPosInSamples; // An offset of . - float table[MAL_SRC_SINC_MAX_WINDOW_WIDTH*1 * MAL_SRC_SINC_LOOKUP_TABLE_RESOLUTION]; // Precomputed lookup table. The +1 is used to avoid the need for an overflow check. + float table[MA_SRC_SINC_MAX_WINDOW_WIDTH*1 * MA_SRC_SINC_LOOKUP_TABLE_RESOLUTION]; // Precomputed lookup table. The +1 is used to avoid the need for an overflow check. } sinc; }; @@ -926,11 +926,11 @@ typedef struct mal_format formatIn; mal_uint32 channelsIn; mal_uint32 sampleRateIn; - mal_channel channelMapIn[MAL_MAX_CHANNELS]; + mal_channel channelMapIn[MA_MAX_CHANNELS]; mal_format formatOut; mal_uint32 channelsOut; mal_uint32 sampleRateOut; - mal_channel channelMapOut[MAL_MAX_CHANNELS]; + mal_channel channelMapOut[MA_MAX_CHANNELS]; mal_channel_mix_mode channelMixMode; mal_dither_mode ditherMode; mal_src_algorithm srcAlgorithm; @@ -948,7 +948,7 @@ typedef struct }; } mal_pcm_converter_config; -MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_pcm_converter +MA_ALIGNED_STRUCT(MA_SIMD_ALIGNMENT) mal_pcm_converter { mal_pcm_converter_read_proc onRead; void* pUserData; @@ -987,49 +987,49 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_pcm_converter // |---------------|------------------------------| // | Channel Count | Mapping | // |---------------|------------------------------| -// | 1 (Mono) | 0: MAL_CHANNEL_MONO | +// | 1 (Mono) | 0: MA_CHANNEL_MONO | // |---------------|------------------------------| -// | 2 (Stereo) | 0: MAL_CHANNEL_FRONT_LEFT | -// | | 1: MAL_CHANNEL_FRONT_RIGHT | +// | 2 (Stereo) | 0: MA_CHANNEL_FRONT_LEFT | +// | | 1: MA_CHANNEL_FRONT_RIGHT | // |---------------|------------------------------| -// | 3 | 0: MAL_CHANNEL_FRONT_LEFT | -// | | 1: MAL_CHANNEL_FRONT_RIGHT | -// | | 2: MAL_CHANNEL_FRONT_CENTER | +// | 3 | 0: MA_CHANNEL_FRONT_LEFT | +// | | 1: MA_CHANNEL_FRONT_RIGHT | +// | | 2: MA_CHANNEL_FRONT_CENTER | // |---------------|------------------------------| -// | 4 (Surround) | 0: MAL_CHANNEL_FRONT_LEFT | -// | | 1: MAL_CHANNEL_FRONT_RIGHT | -// | | 2: MAL_CHANNEL_FRONT_CENTER | -// | | 3: MAL_CHANNEL_BACK_CENTER | +// | 4 (Surround) | 0: MA_CHANNEL_FRONT_LEFT | +// | | 1: MA_CHANNEL_FRONT_RIGHT | +// | | 2: MA_CHANNEL_FRONT_CENTER | +// | | 3: MA_CHANNEL_BACK_CENTER | // |---------------|------------------------------| -// | 5 | 0: MAL_CHANNEL_FRONT_LEFT | -// | | 1: MAL_CHANNEL_FRONT_RIGHT | -// | | 2: MAL_CHANNEL_FRONT_CENTER | -// | | 3: MAL_CHANNEL_BACK_LEFT | -// | | 4: MAL_CHANNEL_BACK_RIGHT | +// | 5 | 0: MA_CHANNEL_FRONT_LEFT | +// | | 1: MA_CHANNEL_FRONT_RIGHT | +// | | 2: MA_CHANNEL_FRONT_CENTER | +// | | 3: MA_CHANNEL_BACK_LEFT | +// | | 4: MA_CHANNEL_BACK_RIGHT | // |---------------|------------------------------| -// | 6 (5.1) | 0: MAL_CHANNEL_FRONT_LEFT | -// | | 1: MAL_CHANNEL_FRONT_RIGHT | -// | | 2: MAL_CHANNEL_FRONT_CENTER | -// | | 3: MAL_CHANNEL_LFE | -// | | 4: MAL_CHANNEL_SIDE_LEFT | -// | | 5: MAL_CHANNEL_SIDE_RIGHT | +// | 6 (5.1) | 0: MA_CHANNEL_FRONT_LEFT | +// | | 1: MA_CHANNEL_FRONT_RIGHT | +// | | 2: MA_CHANNEL_FRONT_CENTER | +// | | 3: MA_CHANNEL_LFE | +// | | 4: MA_CHANNEL_SIDE_LEFT | +// | | 5: MA_CHANNEL_SIDE_RIGHT | // |---------------|------------------------------| -// | 7 | 0: MAL_CHANNEL_FRONT_LEFT | -// | | 1: MAL_CHANNEL_FRONT_RIGHT | -// | | 2: MAL_CHANNEL_FRONT_CENTER | -// | | 3: MAL_CHANNEL_LFE | -// | | 4: MAL_CHANNEL_BACK_CENTER | -// | | 4: MAL_CHANNEL_SIDE_LEFT | -// | | 5: MAL_CHANNEL_SIDE_RIGHT | +// | 7 | 0: MA_CHANNEL_FRONT_LEFT | +// | | 1: MA_CHANNEL_FRONT_RIGHT | +// | | 2: MA_CHANNEL_FRONT_CENTER | +// | | 3: MA_CHANNEL_LFE | +// | | 4: MA_CHANNEL_BACK_CENTER | +// | | 4: MA_CHANNEL_SIDE_LEFT | +// | | 5: MA_CHANNEL_SIDE_RIGHT | // |---------------|------------------------------| -// | 8 (7.1) | 0: MAL_CHANNEL_FRONT_LEFT | -// | | 1: MAL_CHANNEL_FRONT_RIGHT | -// | | 2: MAL_CHANNEL_FRONT_CENTER | -// | | 3: MAL_CHANNEL_LFE | -// | | 4: MAL_CHANNEL_BACK_LEFT | -// | | 5: MAL_CHANNEL_BACK_RIGHT | -// | | 6: MAL_CHANNEL_SIDE_LEFT | -// | | 7: MAL_CHANNEL_SIDE_RIGHT | +// | 8 (7.1) | 0: MA_CHANNEL_FRONT_LEFT | +// | | 1: MA_CHANNEL_FRONT_RIGHT | +// | | 2: MA_CHANNEL_FRONT_CENTER | +// | | 3: MA_CHANNEL_LFE | +// | | 4: MA_CHANNEL_BACK_LEFT | +// | | 5: MA_CHANNEL_BACK_RIGHT | +// | | 6: MA_CHANNEL_SIDE_LEFT | +// | | 7: MA_CHANNEL_SIDE_RIGHT | // |---------------|------------------------------| // | Other | All channels set to 0. This | // | | is equivalent to the same | @@ -1039,7 +1039,7 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_pcm_converter ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Helper for retrieving a standard channel map. -void mal_get_standard_channel_map(mal_standard_channel_map standardChannelMap, mal_uint32 channels, mal_channel channelMap[MAL_MAX_CHANNELS]); +void mal_get_standard_channel_map(mal_standard_channel_map standardChannelMap, mal_uint32 channels, mal_channel channelMap[MA_MAX_CHANNELS]); // Copies a channel map. void mal_channel_map_copy(mal_channel* pOut, const mal_channel* pIn, mal_uint32 channels); @@ -1047,24 +1047,24 @@ void mal_channel_map_copy(mal_channel* pOut, const mal_channel* pIn, mal_uint32 // Determines whether or not a channel map is valid. // -// A blank channel map is valid (all channels set to MAL_CHANNEL_NONE). The way a blank channel map is handled is context specific, but +// A blank channel map is valid (all channels set to MA_CHANNEL_NONE). The way a blank channel map is handled is context specific, but // is usually treated as a passthrough. // // Invalid channel maps: // - A channel map with no channels // - A channel map with more than one channel and a mono channel -mal_bool32 mal_channel_map_valid(mal_uint32 channels, const mal_channel channelMap[MAL_MAX_CHANNELS]); +mal_bool32 mal_channel_map_valid(mal_uint32 channels, const mal_channel channelMap[MA_MAX_CHANNELS]); // Helper for comparing two channel maps for equality. // // This assumes the channel count is the same between the two. -mal_bool32 mal_channel_map_equal(mal_uint32 channels, const mal_channel channelMapA[MAL_MAX_CHANNELS], const mal_channel channelMapB[MAL_MAX_CHANNELS]); +mal_bool32 mal_channel_map_equal(mal_uint32 channels, const mal_channel channelMapA[MA_MAX_CHANNELS], const mal_channel channelMapB[MA_MAX_CHANNELS]); -// Helper for determining if a channel map is blank (all channels set to MAL_CHANNEL_NONE). -mal_bool32 mal_channel_map_blank(mal_uint32 channels, const mal_channel channelMap[MAL_MAX_CHANNELS]); +// Helper for determining if a channel map is blank (all channels set to MA_CHANNEL_NONE). +mal_bool32 mal_channel_map_blank(mal_uint32 channels, const mal_channel channelMap[MA_MAX_CHANNELS]); // Helper for determining whether or not a channel is present in the given channel map. -mal_bool32 mal_channel_map_contains_channel_position(mal_uint32 channels, const mal_channel channelMap[MAL_MAX_CHANNELS], mal_channel channelPosition); +mal_bool32 mal_channel_map_contains_channel_position(mal_uint32 channels, const mal_channel channelMap[MA_MAX_CHANNELS], mal_channel channelPosition); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1195,7 +1195,7 @@ mal_result mal_channel_router_init(const mal_channel_router_config* pConfig, mal mal_uint64 mal_channel_router_read_deinterleaved(mal_channel_router* pRouter, mal_uint64 frameCount, void** ppSamplesOut, void* pUserData); // Helper for initializing a channel router config. -mal_channel_router_config mal_channel_router_config_init(mal_uint32 channelsIn, const mal_channel channelMapIn[MAL_MAX_CHANNELS], mal_uint32 channelsOut, const mal_channel channelMapOut[MAL_MAX_CHANNELS], mal_channel_mix_mode mixingMode, mal_channel_router_read_deinterleaved_proc onRead, void* pUserData); +mal_channel_router_config mal_channel_router_config_init(mal_uint32 channelsIn, const mal_channel channelMapIn[MA_MAX_CHANNELS], mal_uint32 channelsOut, const mal_channel channelMapOut[MA_MAX_CHANNELS], mal_channel_mix_mode mixingMode, mal_channel_router_read_deinterleaved_proc onRead, void* pUserData); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1266,7 +1266,7 @@ mal_uint64 mal_pcm_converter_read(mal_pcm_converter* pDSP, void* pFramesOut, mal // Helper for initializing a mal_pcm_converter_config object. mal_pcm_converter_config mal_pcm_converter_config_init_new(void); mal_pcm_converter_config mal_pcm_converter_config_init(mal_format formatIn, mal_uint32 channelsIn, mal_uint32 sampleRateIn, mal_format formatOut, mal_uint32 channelsOut, mal_uint32 sampleRateOut, mal_pcm_converter_read_proc onRead, void* pUserData); -mal_pcm_converter_config mal_pcm_converter_config_init_ex(mal_format formatIn, mal_uint32 channelsIn, mal_uint32 sampleRateIn, mal_channel channelMapIn[MAL_MAX_CHANNELS], mal_format formatOut, mal_uint32 channelsOut, mal_uint32 sampleRateOut, mal_channel channelMapOut[MAL_MAX_CHANNELS], mal_pcm_converter_read_proc onRead, void* pUserData); +mal_pcm_converter_config mal_pcm_converter_config_init_ex(mal_format formatIn, mal_uint32 channelsIn, mal_uint32 sampleRateIn, mal_channel channelMapIn[MA_MAX_CHANNELS], mal_format formatOut, mal_uint32 channelsOut, mal_uint32 sampleRateOut, mal_channel channelMapOut[MA_MAX_CHANNELS], mal_pcm_converter_read_proc onRead, void* pUserData); // High-level helper for doing a full format conversion in one go. Returns the number of output frames. Call this with pOut set to NULL to @@ -1276,7 +1276,7 @@ mal_pcm_converter_config mal_pcm_converter_config_init_ex(mal_format formatIn, m // // This function is useful for one-off bulk conversions, but if you're streaming data you should use the DSP APIs instead. mal_uint64 mal_convert_frames(void* pOut, mal_format formatOut, mal_uint32 channelsOut, mal_uint32 sampleRateOut, const void* pIn, mal_format formatIn, mal_uint32 channelsIn, mal_uint32 sampleRateIn, mal_uint64 frameCount); -mal_uint64 mal_convert_frames_ex(void* pOut, mal_format formatOut, mal_uint32 channelsOut, mal_uint32 sampleRateOut, mal_channel channelMapOut[MAL_MAX_CHANNELS], const void* pIn, mal_format formatIn, mal_uint32 channelsIn, mal_uint32 sampleRateIn, mal_channel channelMapIn[MAL_MAX_CHANNELS], mal_uint64 frameCount); +mal_uint64 mal_convert_frames_ex(void* pOut, mal_format formatOut, mal_uint32 channelsOut, mal_uint32 sampleRateOut, mal_channel channelMapOut[MA_MAX_CHANNELS], const void* pIn, mal_format formatIn, mal_uint32 channelsIn, mal_uint32 sampleRateIn, mal_channel channelMapIn[MA_MAX_CHANNELS], mal_uint64 frameCount); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1325,7 +1325,7 @@ mal_uint64 mal_convert_frames_ex(void* pOut, mal_format formatOut, mal_uint32 ch // only one thread is allowed to read. The producer is the only one allowed to move the write pointer, and the // consumer is the only one allowed to move the read pointer. // - Operates on bytes. Use mal_pcm_rb to operate in terms of PCM frames. -// - Maximum buffer size in bytes is 0x7FFFFFFF-(MAL_SIMD_ALIGNMENT-1) because of reasons. +// - Maximum buffer size in bytes is 0x7FFFFFFF-(MA_SIMD_ALIGNMENT-1) because of reasons. // // // PCM Ring Buffer @@ -1390,13 +1390,13 @@ void* mal_pcm_rb_get_subbuffer_ptr(mal_pcm_rb* pRB, mal_uint32 subbufferIndex, v // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// malloc(). Calls MAL_MALLOC(). +// malloc(). Calls MA_MALLOC(). void* mal_malloc(size_t sz); -// realloc(). Calls MAL_REALLOC(). +// realloc(). Calls MA_REALLOC(). void* mal_realloc(void* p, size_t sz); -// free(). Calls MAL_FREE(). +// free(). Calls MA_FREE(). void mal_free(void* p); // Performs an aligned malloc, with the assumption that the alignment is a power of 2. @@ -1418,7 +1418,7 @@ void mal_blend_f32(float* pOut, float* pInA, float* pInB, float factor, mal_uint // Thread Safety: SAFE // This is API is pure. mal_uint32 mal_get_bytes_per_sample(mal_format format); -static MAL_INLINE mal_uint32 mal_get_bytes_per_frame(mal_format format, mal_uint32 channels) { return mal_get_bytes_per_sample(format) * channels; } +static MA_INLINE mal_uint32 mal_get_bytes_per_frame(mal_format format, mal_uint32 channels) { return mal_get_bytes_per_sample(format) * channels; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1465,97 +1465,97 @@ void mal_interleave_pcm_frames(mal_format format, mal_uint32 channels, mal_uint6 // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef MAL_NO_DEVICE_IO +#ifndef MA_NO_DEVICE_IO // Some backends are only supported on certain platforms. -#if defined(MAL_WIN32) - #define MAL_SUPPORT_WASAPI - #if defined(MAL_WIN32_DESKTOP) // DirectSound and WinMM backends are only supported on desktop's. - #define MAL_SUPPORT_DSOUND - #define MAL_SUPPORT_WINMM - #define MAL_SUPPORT_JACK // JACK is technically supported on Windows, but I don't know how many people use it in practice... +#if defined(MA_WIN32) + #define MA_SUPPORT_WASAPI + #if defined(MA_WIN32_DESKTOP) // DirectSound and WinMM backends are only supported on desktop's. + #define MA_SUPPORT_DSOUND + #define MA_SUPPORT_WINMM + #define MA_SUPPORT_JACK // JACK is technically supported on Windows, but I don't know how many people use it in practice... #endif #endif -#if defined(MAL_UNIX) - #if defined(MAL_LINUX) - #if !defined(MAL_ANDROID) // ALSA is not supported on Android. - #define MAL_SUPPORT_ALSA +#if defined(MA_UNIX) + #if defined(MA_LINUX) + #if !defined(MA_ANDROID) // ALSA is not supported on Android. + #define MA_SUPPORT_ALSA #endif #endif - #if !defined(MAL_BSD) && !defined(MAL_ANDROID) && !defined(MAL_EMSCRIPTEN) - #define MAL_SUPPORT_PULSEAUDIO - #define MAL_SUPPORT_JACK + #if !defined(MA_BSD) && !defined(MA_ANDROID) && !defined(MA_EMSCRIPTEN) + #define MA_SUPPORT_PULSEAUDIO + #define MA_SUPPORT_JACK #endif - #if defined(MAL_ANDROID) - #define MAL_SUPPORT_AAUDIO - #define MAL_SUPPORT_OPENSL + #if defined(MA_ANDROID) + #define MA_SUPPORT_AAUDIO + #define MA_SUPPORT_OPENSL #endif - #if defined(__OpenBSD__) // <-- Change this to "#if defined(MAL_BSD)" to enable sndio on all BSD flavors. - #define MAL_SUPPORT_SNDIO // sndio is only supported on OpenBSD for now. May be expanded later if there's demand. + #if defined(__OpenBSD__) // <-- Change this to "#if defined(MA_BSD)" to enable sndio on all BSD flavors. + #define MA_SUPPORT_SNDIO // sndio is only supported on OpenBSD for now. May be expanded later if there's demand. #endif #if defined(__NetBSD__) || defined(__OpenBSD__) - #define MAL_SUPPORT_AUDIO4 // Only support audio(4) on platforms with known support. + #define MA_SUPPORT_AUDIO4 // Only support audio(4) on platforms with known support. #endif #if defined(__FreeBSD__) || defined(__DragonFly__) - #define MAL_SUPPORT_OSS // Only support OSS on specific platforms with known support. + #define MA_SUPPORT_OSS // Only support OSS on specific platforms with known support. #endif #endif -#if defined(MAL_APPLE) - #define MAL_SUPPORT_COREAUDIO +#if defined(MA_APPLE) + #define MA_SUPPORT_COREAUDIO #endif -#if defined(MAL_EMSCRIPTEN) - #define MAL_SUPPORT_WEBAUDIO +#if defined(MA_EMSCRIPTEN) + #define MA_SUPPORT_WEBAUDIO #endif // Explicitly disable the Null backend for Emscripten because it uses a background thread which is not properly supported right now. -#if !defined(MAL_EMSCRIPTEN) -#define MAL_SUPPORT_NULL +#if !defined(MA_EMSCRIPTEN) +#define MA_SUPPORT_NULL #endif -#if !defined(MAL_NO_WASAPI) && defined(MAL_SUPPORT_WASAPI) - #define MAL_ENABLE_WASAPI +#if !defined(MA_NO_WASAPI) && defined(MA_SUPPORT_WASAPI) + #define MA_ENABLE_WASAPI #endif -#if !defined(MAL_NO_DSOUND) && defined(MAL_SUPPORT_DSOUND) - #define MAL_ENABLE_DSOUND +#if !defined(MA_NO_DSOUND) && defined(MA_SUPPORT_DSOUND) + #define MA_ENABLE_DSOUND #endif -#if !defined(MAL_NO_WINMM) && defined(MAL_SUPPORT_WINMM) - #define MAL_ENABLE_WINMM +#if !defined(MA_NO_WINMM) && defined(MA_SUPPORT_WINMM) + #define MA_ENABLE_WINMM #endif -#if !defined(MAL_NO_ALSA) && defined(MAL_SUPPORT_ALSA) - #define MAL_ENABLE_ALSA +#if !defined(MA_NO_ALSA) && defined(MA_SUPPORT_ALSA) + #define MA_ENABLE_ALSA #endif -#if !defined(MAL_NO_PULSEAUDIO) && defined(MAL_SUPPORT_PULSEAUDIO) - #define MAL_ENABLE_PULSEAUDIO +#if !defined(MA_NO_PULSEAUDIO) && defined(MA_SUPPORT_PULSEAUDIO) + #define MA_ENABLE_PULSEAUDIO #endif -#if !defined(MAL_NO_JACK) && defined(MAL_SUPPORT_JACK) - #define MAL_ENABLE_JACK +#if !defined(MA_NO_JACK) && defined(MA_SUPPORT_JACK) + #define MA_ENABLE_JACK #endif -#if !defined(MAL_NO_COREAUDIO) && defined(MAL_SUPPORT_COREAUDIO) - #define MAL_ENABLE_COREAUDIO +#if !defined(MA_NO_COREAUDIO) && defined(MA_SUPPORT_COREAUDIO) + #define MA_ENABLE_COREAUDIO #endif -#if !defined(MAL_NO_SNDIO) && defined(MAL_SUPPORT_SNDIO) - #define MAL_ENABLE_SNDIO +#if !defined(MA_NO_SNDIO) && defined(MA_SUPPORT_SNDIO) + #define MA_ENABLE_SNDIO #endif -#if !defined(MAL_NO_AUDIO4) && defined(MAL_SUPPORT_AUDIO4) - #define MAL_ENABLE_AUDIO4 +#if !defined(MA_NO_AUDIO4) && defined(MA_SUPPORT_AUDIO4) + #define MA_ENABLE_AUDIO4 #endif -#if !defined(MAL_NO_OSS) && defined(MAL_SUPPORT_OSS) - #define MAL_ENABLE_OSS +#if !defined(MA_NO_OSS) && defined(MA_SUPPORT_OSS) + #define MA_ENABLE_OSS #endif -#if !defined(MAL_NO_AAUDIO) && defined(MAL_SUPPORT_AAUDIO) - #define MAL_ENABLE_AAUDIO +#if !defined(MA_NO_AAUDIO) && defined(MA_SUPPORT_AAUDIO) + #define MA_ENABLE_AAUDIO #endif -#if !defined(MAL_NO_OPENSL) && defined(MAL_SUPPORT_OPENSL) - #define MAL_ENABLE_OPENSL +#if !defined(MA_NO_OPENSL) && defined(MA_SUPPORT_OPENSL) + #define MA_ENABLE_OPENSL #endif -#if !defined(MAL_NO_WEBAUDIO) && defined(MAL_SUPPORT_WEBAUDIO) - #define MAL_ENABLE_WEBAUDIO +#if !defined(MA_NO_WEBAUDIO) && defined(MA_SUPPORT_WEBAUDIO) + #define MA_ENABLE_WEBAUDIO #endif -#if !defined(MAL_NO_NULL) && defined(MAL_SUPPORT_NULL) - #define MAL_ENABLE_NULL +#if !defined(MA_NO_NULL) && defined(MA_SUPPORT_NULL) + #define MA_ENABLE_NULL #endif -#ifdef MAL_SUPPORT_WASAPI +#ifdef MA_SUPPORT_WASAPI // We need a IMMNotificationClient object for WASAPI. typedef struct { @@ -1603,13 +1603,13 @@ typedef struct union { -#ifdef MAL_WIN32 +#ifdef MA_WIN32 struct { /*HANDLE*/ mal_handle hThread; } win32; #endif -#ifdef MAL_POSIX +#ifdef MA_POSIX struct { pthread_t thread; @@ -1625,13 +1625,13 @@ typedef struct union { -#ifdef MAL_WIN32 +#ifdef MA_WIN32 struct { /*HANDLE*/ mal_handle hMutex; } win32; #endif -#ifdef MAL_POSIX +#ifdef MA_POSIX struct { pthread_mutex_t mutex; @@ -1647,13 +1647,13 @@ typedef struct union { -#ifdef MAL_WIN32 +#ifdef MA_WIN32 struct { /*HANDLE*/ mal_handle hEvent; } win32; #endif -#ifdef MAL_POSIX +#ifdef MA_POSIX struct { pthread_mutex_t mutex; @@ -1700,10 +1700,10 @@ It is possible for pDevice to be null in which case the log originated from the came from the device. logLevel is one of the following: - MAL_LOG_LEVEL_VERBOSE - MAL_LOG_LEVEL_INFO - MAL_LOG_LEVEL_WARNING - MAL_LOG_LEVEL_ERROR + MA_LOG_LEVEL_VERBOSE + MA_LOG_LEVEL_INFO + MA_LOG_LEVEL_WARNING + MA_LOG_LEVEL_ERROR */ typedef void (* mal_log_proc)(mal_context* pContext, mal_device* pDevice, mal_uint32 logLevel, const char* message); @@ -1722,46 +1722,46 @@ typedef enum typedef union { -#ifdef MAL_SUPPORT_WASAPI +#ifdef MA_SUPPORT_WASAPI wchar_t wasapi[64]; // WASAPI uses a wchar_t string for identification. #endif -#ifdef MAL_SUPPORT_DSOUND +#ifdef MA_SUPPORT_DSOUND mal_uint8 dsound[16]; // DirectSound uses a GUID for identification. #endif -#ifdef MAL_SUPPORT_WINMM +#ifdef MA_SUPPORT_WINMM /*UINT_PTR*/ mal_uint32 winmm; // When creating a device, WinMM expects a Win32 UINT_PTR for device identification. In practice it's actually just a UINT. #endif -#ifdef MAL_SUPPORT_ALSA +#ifdef MA_SUPPORT_ALSA char alsa[256]; // ALSA uses a name string for identification. #endif -#ifdef MAL_SUPPORT_PULSEAUDIO +#ifdef MA_SUPPORT_PULSEAUDIO char pulse[256]; // PulseAudio uses a name string for identification. #endif -#ifdef MAL_SUPPORT_JACK +#ifdef MA_SUPPORT_JACK int jack; // JACK always uses default devices. #endif -#ifdef MAL_SUPPORT_COREAUDIO +#ifdef MA_SUPPORT_COREAUDIO char coreaudio[256]; // Core Audio uses a string for identification. #endif -#ifdef MAL_SUPPORT_SNDIO +#ifdef MA_SUPPORT_SNDIO char sndio[256]; // "snd/0", etc. #endif -#ifdef MAL_SUPPORT_AUDIO4 +#ifdef MA_SUPPORT_AUDIO4 char audio4[256]; // "/dev/audio", etc. #endif -#ifdef MAL_SUPPORT_OSS +#ifdef MA_SUPPORT_OSS char oss[64]; // "dev/dsp0", etc. "dev/dsp" for the default device. #endif -#ifdef MAL_SUPPORT_AAUDIO +#ifdef MA_SUPPORT_AAUDIO mal_int32 aaudio; // AAudio uses a 32-bit integer for identification. #endif -#ifdef MAL_SUPPORT_OPENSL +#ifdef MA_SUPPORT_OPENSL mal_uint32 opensl; // OpenSL|ES uses a 32-bit unsigned integer for identification. #endif -#ifdef MAL_SUPPORT_WEBAUDIO +#ifdef MA_SUPPORT_WEBAUDIO char webaudio[32]; // Web Audio always uses default devices for now, but if this changes it'll be a GUID. #endif -#ifdef MAL_SUPPORT_NULL +#ifdef MA_SUPPORT_NULL int nullbackend; // The null backend uses an integer for device IDs. #endif } mal_device_id; @@ -1811,7 +1811,7 @@ typedef struct mal_device_id* pDeviceID; mal_format format; mal_uint32 channels; - mal_channel channelMap[MAL_MAX_CHANNELS]; + mal_channel channelMap[MA_MAX_CHANNELS]; mal_share_mode shareMode; } playback; struct @@ -1819,7 +1819,7 @@ typedef struct mal_device_id* pDeviceID; mal_format format; mal_uint32 channels; - mal_channel channelMap[MAL_MAX_CHANNELS]; + mal_channel channelMap[MA_MAX_CHANNELS]; mal_share_mode shareMode; } capture; @@ -1886,13 +1886,13 @@ struct mal_context union { -#ifdef MAL_SUPPORT_WASAPI +#ifdef MA_SUPPORT_WASAPI struct { int _unused; } wasapi; #endif -#ifdef MAL_SUPPORT_DSOUND +#ifdef MA_SUPPORT_DSOUND struct { mal_handle hDSoundDLL; @@ -1902,7 +1902,7 @@ struct mal_context mal_proc DirectSoundCaptureEnumerateA; } dsound; #endif -#ifdef MAL_SUPPORT_WINMM +#ifdef MA_SUPPORT_WINMM struct { mal_handle hWinMM; @@ -1925,7 +1925,7 @@ struct mal_context mal_proc waveInReset; } winmm; #endif -#ifdef MAL_SUPPORT_ALSA +#ifdef MA_SUPPORT_ALSA struct { mal_handle asoundSO; @@ -1988,7 +1988,7 @@ struct mal_context mal_mutex internalDeviceEnumLock; } alsa; #endif -#ifdef MAL_SUPPORT_PULSEAUDIO +#ifdef MA_SUPPORT_PULSEAUDIO struct { mal_handle pulseSO; @@ -2038,7 +2038,7 @@ struct mal_context mal_proc pa_stream_readable_size; } pulse; #endif -#ifdef MAL_SUPPORT_JACK +#ifdef MA_SUPPORT_JACK struct { mal_handle jackSO; @@ -2060,7 +2060,7 @@ struct mal_context mal_proc jack_free; } jack; #endif -#ifdef MAL_SUPPORT_COREAUDIO +#ifdef MA_SUPPORT_COREAUDIO struct { mal_handle hCoreFoundation; @@ -2088,7 +2088,7 @@ struct mal_context /*AudioComponent*/ mal_ptr component; } coreaudio; #endif -#ifdef MAL_SUPPORT_SNDIO +#ifdef MA_SUPPORT_SNDIO struct { mal_handle sndioSO; @@ -2111,20 +2111,20 @@ struct mal_context mal_proc sio_initpar; } sndio; #endif -#ifdef MAL_SUPPORT_AUDIO4 +#ifdef MA_SUPPORT_AUDIO4 struct { int _unused; } audio4; #endif -#ifdef MAL_SUPPORT_OSS +#ifdef MA_SUPPORT_OSS struct { int versionMajor; int versionMinor; } oss; #endif -#ifdef MAL_SUPPORT_AAUDIO +#ifdef MA_SUPPORT_AAUDIO struct { mal_handle hAAudio; /* libaaudio.so */ @@ -2154,19 +2154,19 @@ struct mal_context mal_proc AAudioStream_requestStop; } aaudio; #endif -#ifdef MAL_SUPPORT_OPENSL +#ifdef MA_SUPPORT_OPENSL struct { int _unused; } opensl; #endif -#ifdef MAL_SUPPORT_WEBAUDIO +#ifdef MA_SUPPORT_WEBAUDIO struct { int _unused; } webaudio; #endif -#ifdef MAL_SUPPORT_NULL +#ifdef MA_SUPPORT_NULL struct { int _unused; @@ -2176,7 +2176,7 @@ struct mal_context union { -#ifdef MAL_WIN32 +#ifdef MA_WIN32 struct { /*HMODULE*/ mal_handle hOle32DLL; @@ -2197,7 +2197,7 @@ struct mal_context mal_proc RegQueryValueExA; } win32; #endif -#ifdef MAL_POSIX +#ifdef MA_POSIX struct { mal_handle pthreadSO; @@ -2222,7 +2222,7 @@ struct mal_context }; }; -MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_device +MA_ALIGNED_STRUCT(MA_SIMD_ALIGNMENT) mal_device { mal_context* pContext; mal_device_type type; @@ -2250,11 +2250,11 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_device mal_bool32 usingDefaultChannelMap : 1; mal_format format; mal_uint32 channels; - mal_channel channelMap[MAL_MAX_CHANNELS]; + mal_channel channelMap[MA_MAX_CHANNELS]; mal_format internalFormat; mal_uint32 internalChannels; mal_uint32 internalSampleRate; - mal_channel internalChannelMap[MAL_MAX_CHANNELS]; + mal_channel internalChannelMap[MA_MAX_CHANNELS]; mal_uint32 internalBufferSizeInFrames; mal_uint32 internalPeriods; mal_pcm_converter converter; @@ -2270,11 +2270,11 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_device mal_bool32 usingDefaultChannelMap : 1; mal_format format; mal_uint32 channels; - mal_channel channelMap[MAL_MAX_CHANNELS]; + mal_channel channelMap[MA_MAX_CHANNELS]; mal_format internalFormat; mal_uint32 internalChannels; mal_uint32 internalSampleRate; - mal_channel internalChannelMap[MAL_MAX_CHANNELS]; + mal_channel internalChannelMap[MA_MAX_CHANNELS]; mal_uint32 internalBufferSizeInFrames; mal_uint32 internalPeriods; mal_pcm_converter converter; @@ -2284,7 +2284,7 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_device union { -#ifdef MAL_SUPPORT_WASAPI +#ifdef MA_SUPPORT_WASAPI struct { /*IAudioClient**/ mal_ptr pAudioClientPlayback; @@ -2308,7 +2308,7 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_device mal_bool32 isStartedPlayback; } wasapi; #endif -#ifdef MAL_SUPPORT_DSOUND +#ifdef MA_SUPPORT_DSOUND struct { /*LPDIRECTSOUND*/ mal_ptr pPlayback; @@ -2318,7 +2318,7 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_device /*LPDIRECTSOUNDCAPTUREBUFFER*/ mal_ptr pCaptureBuffer; } dsound; #endif -#ifdef MAL_SUPPORT_WINMM +#ifdef MA_SUPPORT_WINMM struct { /*HWAVEOUT*/ mal_handle hDevicePlayback; @@ -2339,7 +2339,7 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_device mal_bool32 isStarted; } winmm; #endif -#ifdef MAL_SUPPORT_ALSA +#ifdef MA_SUPPORT_ALSA struct { /*snd_pcm_t**/ mal_ptr pPCMPlayback; @@ -2348,7 +2348,7 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_device mal_bool32 isUsingMMapCapture : 1; } alsa; #endif -#ifdef MAL_SUPPORT_PULSEAUDIO +#ifdef MA_SUPPORT_PULSEAUDIO struct { /*pa_mainloop**/ mal_ptr pMainLoop; @@ -2366,18 +2366,18 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_device mal_bool32 breakFromMainLoop : 1; } pulse; #endif -#ifdef MAL_SUPPORT_JACK +#ifdef MA_SUPPORT_JACK struct { /*jack_client_t**/ mal_ptr pClient; - /*jack_port_t**/ mal_ptr pPortsPlayback[MAL_MAX_CHANNELS]; - /*jack_port_t**/ mal_ptr pPortsCapture[MAL_MAX_CHANNELS]; + /*jack_port_t**/ mal_ptr pPortsPlayback[MA_MAX_CHANNELS]; + /*jack_port_t**/ mal_ptr pPortsCapture[MA_MAX_CHANNELS]; float* pIntermediaryBufferPlayback; // Typed as a float because JACK is always floating point. float* pIntermediaryBufferCapture; mal_pcm_rb duplexRB; } jack; #endif -#ifdef MAL_SUPPORT_COREAUDIO +#ifdef MA_SUPPORT_COREAUDIO struct { mal_uint32 deviceObjectIDPlayback; @@ -2396,7 +2396,7 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_device mal_pcm_rb duplexRB; } coreaudio; #endif -#ifdef MAL_SUPPORT_SNDIO +#ifdef MA_SUPPORT_SNDIO struct { mal_ptr handlePlayback; @@ -2405,21 +2405,21 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_device mal_bool32 isStartedCapture; } sndio; #endif -#ifdef MAL_SUPPORT_AUDIO4 +#ifdef MA_SUPPORT_AUDIO4 struct { int fdPlayback; int fdCapture; } audio4; #endif -#ifdef MAL_SUPPORT_OSS +#ifdef MA_SUPPORT_OSS struct { int fdPlayback; int fdCapture; } oss; #endif -#ifdef MAL_SUPPORT_AAUDIO +#ifdef MA_SUPPORT_AAUDIO struct { /*AAudioStream**/ mal_ptr pStreamPlayback; @@ -2427,7 +2427,7 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_device mal_pcm_rb duplexRB; } aaudio; #endif -#ifdef MAL_SUPPORT_OPENSL +#ifdef MA_SUPPORT_OPENSL struct { /*SLObjectItf*/ mal_ptr pOutputMixObj; @@ -2445,7 +2445,7 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_device mal_pcm_rb duplexRB; } opensl; #endif -#ifdef MAL_SUPPORT_WEBAUDIO +#ifdef MA_SUPPORT_WEBAUDIO struct { int indexPlayback; /* We use a factory on the JavaScript side to manage devices and use an index for JS/C interop. */ @@ -2453,7 +2453,7 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_device mal_pcm_rb duplexRB; /* In external capture format. */ } webaudio; #endif -#ifdef MAL_SUPPORT_NULL +#ifdef MA_SUPPORT_NULL struct { mal_thread deviceThread; @@ -2508,7 +2508,7 @@ MAL_ALIGNED_STRUCT(MAL_SIMD_ALIGNMENT) mal_device // structure which performs run-time linking for the relevant backends every time it's initialized. // // Return Value: -// MAL_SUCCESS if successful; any other error code otherwise. +// MA_SUCCESS if successful; any other error code otherwise. // // Thread Safety: UNSAFE mal_result mal_context_init(const mal_backend backends[], mal_uint32 backendCount, const mal_context_config* pConfig, mal_context* pContext); @@ -2518,7 +2518,7 @@ mal_result mal_context_init(const mal_backend backends[], mal_uint32 backendCoun // Results are undefined if you call this while any device created by this context is still active. // // Return Value: -// MAL_SUCCESS if successful; any other error code otherwise. +// MA_SUCCESS if successful; any other error code otherwise. // // Thread Safety: UNSAFE mal_result mal_context_uninit(mal_context* pContext); @@ -2547,7 +2547,7 @@ mal_result mal_context_uninit(mal_context* pContext); // Returning false from the callback will stop enumeration. Returning true will continue enumeration. // // Return Value: -// MAL_SUCCESS if successful; any other error code otherwise. +// MA_SUCCESS if successful; any other error code otherwise. // // Thread Safety: SAFE // This is guarded using a simple mutex lock. @@ -2566,7 +2566,7 @@ mal_result mal_context_enumerate_devices(mal_context* pContext, mal_enum_devices // documentation for mal_context_enumerate_devices() for more information. // // Return Value: -// MAL_SUCCESS if successful; any other error code otherwise. +// MA_SUCCESS if successful; any other error code otherwise. // // Thread Safety: SAFE // Since each call to this function invalidates the pointers from the previous call, you @@ -2588,7 +2588,7 @@ mal_result mal_context_get_devices(mal_context* pContext, mal_device_info** ppPl // This leaves pDeviceInfo unmodified in the result of an error. // // Return Value: -// MAL_SUCCESS if successful; any other error code otherwise. +// MA_SUCCESS if successful; any other error code otherwise. // // Thread Safety: SAFE // This is guarded using a simple mutex lock. @@ -2614,8 +2614,8 @@ mal_result mal_context_get_device_info(mal_context* pContext, mal_device_type de // sample format, channel count, sample rate and channel map it will default to the values used by // the backend's internal device. For the size of the buffer you can set bufferSizeInFrames or // bufferSizeInMilliseconds (if both are set it will prioritize bufferSizeInFrames). If both are -// set to zero, it will default to MAL_BASE_BUFFER_SIZE_IN_MILLISECONDS_LOW_LATENCY or -// MAL_BASE_BUFFER_SIZE_IN_MILLISECONDS_CONSERVATIVE, depending on whether or not performanceProfile +// set to zero, it will default to MA_BASE_BUFFER_SIZE_IN_MILLISECONDS_LOW_LATENCY or +// MA_BASE_BUFFER_SIZE_IN_MILLISECONDS_CONSERVATIVE, depending on whether or not performanceProfile // is set to mal_performance_profile_low_latency or mal_performance_profile_conservative. // // If you request exclusive mode and the backend does not support it an error will be returned. For @@ -2649,7 +2649,7 @@ mal_result mal_context_get_device_info(mal_context* pContext, mal_device_type de // back to the "hw" device. // // Return Value: -// MAL_SUCCESS if successful; any other error code otherwise. +// MA_SUCCESS if successful; any other error code otherwise. // // Thread Safety: UNSAFE // It is not safe to call this function simultaneously for different devices because some backends @@ -2669,7 +2669,7 @@ mal_result mal_device_init_ex(const mal_backend backends[], mal_uint32 backendCo // harmless if you do. // // Return Value: -// MAL_SUCCESS if successful; any other error code otherwise. +// MA_SUCCESS if successful; any other error code otherwise. // // Thread Safety: UNSAFE // As soon as this API is called the device should be considered undefined. All bets are off if you @@ -2693,7 +2693,7 @@ void mal_device_set_stop_callback(mal_device* pDevice, mal_stop_proc proc); // waits on a mutex for thread-safety. // // Return Value: -// MAL_SUCCESS if successful; any other error code otherwise. +// MA_SUCCESS if successful; any other error code otherwise. // // Thread Safety: SAFE mal_result mal_device_start(mal_device* pDevice); @@ -2712,7 +2712,7 @@ mal_result mal_device_start(mal_device* pDevice); // which can in turn result in de-syncs. // // Return Value: -// MAL_SUCCESS if successful; any other error code otherwise. +// MA_SUCCESS if successful; any other error code otherwise. // // Thread Safety: SAFE mal_result mal_device_stop(mal_device* pDevice); @@ -2817,7 +2817,7 @@ mal_uint32 mal_get_default_buffer_size_in_frames(mal_performance_profile perform // Copies silent frames into the given buffer. void mal_zero_pcm_frames(void* p, mal_uint32 frameCount, mal_format format, mal_uint32 channels); -#endif // MAL_NO_DEVICE_IO +#endif // MA_NO_DEVICE_IO @@ -2827,7 +2827,7 @@ void mal_zero_pcm_frames(void* p, mal_uint32 frameCount, mal_format format, mal_ // Decoding // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef MAL_NO_DECODING +#ifndef MA_NO_DECODING typedef struct mal_decoder mal_decoder; @@ -2847,7 +2847,7 @@ typedef struct mal_format format; // Set to 0 or mal_format_unknown to use the stream's internal format. mal_uint32 channels; // Set to 0 to use the stream's internal channels. mal_uint32 sampleRate; // Set to 0 to use the stream's internal sample rate. - mal_channel channelMap[MAL_MAX_CHANNELS]; + mal_channel channelMap[MA_MAX_CHANNELS]; mal_channel_mix_mode channelMixMode; mal_dither_mode ditherMode; mal_src_algorithm srcAlgorithm; @@ -2865,11 +2865,11 @@ struct mal_decoder mal_format internalFormat; mal_uint32 internalChannels; mal_uint32 internalSampleRate; - mal_channel internalChannelMap[MAL_MAX_CHANNELS]; + mal_channel internalChannelMap[MA_MAX_CHANNELS]; mal_format outputFormat; mal_uint32 outputChannels; mal_uint32 outputSampleRate; - mal_channel outputChannelMap[MAL_MAX_CHANNELS]; + mal_channel outputChannelMap[MA_MAX_CHANNELS]; mal_pcm_converter dsp; // <-- Format conversion is achieved by running frames through this. mal_decoder_seek_to_pcm_frame_proc onSeekToPCMFrame; mal_decoder_uninit_proc onUninit; @@ -2898,7 +2898,7 @@ mal_result mal_decoder_init_memory_vorbis(const void* pData, size_t dataSize, co mal_result mal_decoder_init_memory_mp3(const void* pData, size_t dataSize, const mal_decoder_config* pConfig, mal_decoder* pDecoder); mal_result mal_decoder_init_memory_raw(const void* pData, size_t dataSize, const mal_decoder_config* pConfigIn, const mal_decoder_config* pConfigOut, mal_decoder* pDecoder); -#ifndef MAL_NO_STDIO +#ifndef MA_NO_STDIO mal_result mal_decoder_init_file(const char* pFilePath, const mal_decoder_config* pConfig, mal_decoder* pDecoder); mal_result mal_decoder_init_file_wav(const char* pFilePath, const mal_decoder_config* pConfig, mal_decoder* pDecoder); #endif @@ -2911,12 +2911,12 @@ mal_result mal_decoder_seek_to_pcm_frame(mal_decoder* pDecoder, mal_uint64 frame // Helper for opening and decoding a file into a heap allocated block of memory. Free the returned pointer with mal_free(). On input, // pConfig should be set to what you want. On output it will be set to what you got. -#ifndef MAL_NO_STDIO +#ifndef MA_NO_STDIO mal_result mal_decode_file(const char* pFilePath, mal_decoder_config* pConfig, mal_uint64* pFrameCountOut, void** ppDataOut); #endif mal_result mal_decode_memory(const void* pData, size_t dataSize, mal_decoder_config* pConfig, mal_uint64* pFrameCountOut, void** ppDataOut); -#endif // MAL_NO_DECODING +#endif // MA_NO_DECODING ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -2956,11 +2956,11 @@ mal_uint64 mal_sine_wave_read_f32_ex(mal_sine_wave* pSineWave, mal_uint64 frameC #include // For INT_MAX #include // sin(), etc. -#if defined(MAL_DEBUG_OUTPUT) +#if defined(MA_DEBUG_OUTPUT) #include // for printf() for debug output #endif -#ifdef MAL_WIN32 +#ifdef MA_WIN32 #include #include #include @@ -2970,132 +2970,132 @@ mal_uint64 mal_sine_wave_read_f32_ex(mal_sine_wave* pSineWave, mal_uint64 frameC #include // For memset() #endif -#if defined(MAL_APPLE) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101200) +#if defined(MA_APPLE) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101200) #include // For mach_absolute_time() #endif -#ifdef MAL_POSIX +#ifdef MA_POSIX #include #include #endif -#ifdef MAL_EMSCRIPTEN +#ifdef MA_EMSCRIPTEN #include #endif -#if !defined(MAL_64BIT) && !defined(MAL_32BIT) +#if !defined(MA_64BIT) && !defined(MA_32BIT) #ifdef _WIN32 #ifdef _WIN64 -#define MAL_64BIT +#define MA_64BIT #else -#define MAL_32BIT +#define MA_32BIT #endif #endif #endif -#if !defined(MAL_64BIT) && !defined(MAL_32BIT) +#if !defined(MA_64BIT) && !defined(MA_32BIT) #ifdef __GNUC__ #ifdef __LP64__ -#define MAL_64BIT +#define MA_64BIT #else -#define MAL_32BIT +#define MA_32BIT #endif #endif #endif -#if !defined(MAL_64BIT) && !defined(MAL_32BIT) +#if !defined(MA_64BIT) && !defined(MA_32BIT) #include #if INTPTR_MAX == INT64_MAX -#define MAL_64BIT +#define MA_64BIT #else -#define MAL_32BIT +#define MA_32BIT #endif #endif // Architecture Detection #if defined(__x86_64__) || defined(_M_X64) -#define MAL_X64 +#define MA_X64 #elif defined(__i386) || defined(_M_IX86) -#define MAL_X86 +#define MA_X86 #elif defined(__arm__) || defined(_M_ARM) -#define MAL_ARM +#define MA_ARM #endif // Cannot currently support AVX-512 if AVX is disabled. -#if !defined(MAL_NO_AVX512) && defined(MAL_NO_AVX2) -#define MAL_NO_AVX512 +#if !defined(MA_NO_AVX512) && defined(MA_NO_AVX2) +#define MA_NO_AVX512 #endif // Intrinsics Support -#if defined(MAL_X64) || defined(MAL_X86) +#if defined(MA_X64) || defined(MA_X86) #if defined(_MSC_VER) && !defined(__clang__) // MSVC. - #if !defined(MAL_NO_SSE2) // Assume all MSVC compilers support SSE2 intrinsics. - #define MAL_SUPPORT_SSE2 + #if !defined(MA_NO_SSE2) // Assume all MSVC compilers support SSE2 intrinsics. + #define MA_SUPPORT_SSE2 #endif - //#if _MSC_VER >= 1600 && !defined(MAL_NO_AVX) // 2010 - // #define MAL_SUPPORT_AVX + //#if _MSC_VER >= 1600 && !defined(MA_NO_AVX) // 2010 + // #define MA_SUPPORT_AVX //#endif - #if _MSC_VER >= 1700 && !defined(MAL_NO_AVX2) // 2012 - #define MAL_SUPPORT_AVX2 + #if _MSC_VER >= 1700 && !defined(MA_NO_AVX2) // 2012 + #define MA_SUPPORT_AVX2 #endif - #if _MSC_VER >= 1910 && !defined(MAL_NO_AVX512) // 2017 - #define MAL_SUPPORT_AVX512 + #if _MSC_VER >= 1910 && !defined(MA_NO_AVX512) // 2017 + #define MA_SUPPORT_AVX512 #endif #else // Assume GNUC-style. - #if defined(__SSE2__) && !defined(MAL_NO_SSE2) - #define MAL_SUPPORT_SSE2 + #if defined(__SSE2__) && !defined(MA_NO_SSE2) + #define MA_SUPPORT_SSE2 #endif - //#if defined(__AVX__) && !defined(MAL_NO_AVX) - // #define MAL_SUPPORT_AVX + //#if defined(__AVX__) && !defined(MA_NO_AVX) + // #define MA_SUPPORT_AVX //#endif - #if defined(__AVX2__) && !defined(MAL_NO_AVX2) - #define MAL_SUPPORT_AVX2 + #if defined(__AVX2__) && !defined(MA_NO_AVX2) + #define MA_SUPPORT_AVX2 #endif - #if defined(__AVX512F__) && !defined(MAL_NO_AVX512) - #define MAL_SUPPORT_AVX512 + #if defined(__AVX512F__) && !defined(MA_NO_AVX512) + #define MA_SUPPORT_AVX512 #endif #endif // If at this point we still haven't determined compiler support for the intrinsics just fall back to __has_include. #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include) - #if !defined(MAL_SUPPORT_SSE2) && !defined(MAL_NO_SSE2) && __has_include() - #define MAL_SUPPORT_SSE2 + #if !defined(MA_SUPPORT_SSE2) && !defined(MA_NO_SSE2) && __has_include() + #define MA_SUPPORT_SSE2 #endif - //#if !defined(MAL_SUPPORT_AVX) && !defined(MAL_NO_AVX) && __has_include() - // #define MAL_SUPPORT_AVX + //#if !defined(MA_SUPPORT_AVX) && !defined(MA_NO_AVX) && __has_include() + // #define MA_SUPPORT_AVX //#endif - #if !defined(MAL_SUPPORT_AVX2) && !defined(MAL_NO_AVX2) && __has_include() - #define MAL_SUPPORT_AVX2 + #if !defined(MA_SUPPORT_AVX2) && !defined(MA_NO_AVX2) && __has_include() + #define MA_SUPPORT_AVX2 #endif - #if !defined(MAL_SUPPORT_AVX512) && !defined(MAL_NO_AVX512) && __has_include() - #define MAL_SUPPORT_AVX512 + #if !defined(MA_SUPPORT_AVX512) && !defined(MA_NO_AVX512) && __has_include() + #define MA_SUPPORT_AVX512 #endif #endif - #if defined(MAL_SUPPORT_AVX512) + #if defined(MA_SUPPORT_AVX512) #include // Not a mistake. Intentionally including instead of because otherwise the compiler will complain. - #elif defined(MAL_SUPPORT_AVX2) || defined(MAL_SUPPORT_AVX) + #elif defined(MA_SUPPORT_AVX2) || defined(MA_SUPPORT_AVX) #include - #elif defined(MAL_SUPPORT_SSE2) + #elif defined(MA_SUPPORT_SSE2) #include #endif #endif -#if defined(MAL_ARM) - #if !defined(MAL_NO_NEON) && (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64)) - #define MAL_SUPPORT_NEON +#if defined(MA_ARM) + #if !defined(MA_NO_NEON) && (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64)) + #define MA_SUPPORT_NEON #endif // Fall back to looking for the #include file. #if !defined(__GNUC__) && !defined(__clang__) && defined(__has_include) - #if !defined(MAL_SUPPORT_NEON) && !defined(MAL_NO_NEON) && __has_include() - #define MAL_SUPPORT_NEON + #if !defined(MA_SUPPORT_NEON) && !defined(MA_NO_NEON) && __has_include() + #define MA_SUPPORT_NEON #endif #endif - #if defined(MAL_SUPPORT_NEON) + #if defined(MA_SUPPORT_NEON) #include #endif #endif @@ -3105,28 +3105,28 @@ mal_uint64 mal_sine_wave_read_f32_ex(mal_sine_wave* pSineWave, mal_uint64 frameC #pragma warning(disable:4752) // found Intel(R) Advanced Vector Extensions; consider using /arch:AVX #endif -#if defined(MAL_X64) || defined(MAL_X86) +#if defined(MA_X64) || defined(MA_X86) #if defined(_MSC_VER) && !defined(__clang__) #if _MSC_VER >= 1400 #include - static MAL_INLINE void mal_cpuid(int info[4], int fid) + static MA_INLINE void mal_cpuid(int info[4], int fid) { __cpuid(info, fid); } #else - #define MAL_NO_CPUID + #define MA_NO_CPUID #endif #if _MSC_VER >= 1600 - static MAL_INLINE unsigned __int64 mal_xgetbv(int reg) + static MA_INLINE unsigned __int64 mal_xgetbv(int reg) { return _xgetbv(reg); } #else - #define MAL_NO_XGETBV + #define MA_NO_XGETBV #endif - #elif (defined(__GNUC__) || defined(__clang__)) && !defined(MAL_ANDROID) - static MAL_INLINE void mal_cpuid(int info[4], int fid) + #elif (defined(__GNUC__) || defined(__clang__)) && !defined(MA_ANDROID) + static MA_INLINE void mal_cpuid(int info[4], int fid) { // It looks like the -fPIC option uses the ebx register which GCC complains about. We can work around this by just using a different register, the // specific register of which I'm letting the compiler decide on. The "k" prefix is used to specify a 32-bit register. The {...} syntax is for @@ -3147,7 +3147,7 @@ mal_uint64 mal_sine_wave_read_f32_ex(mal_sine_wave* pSineWave, mal_uint64 frameC #endif } - static MAL_INLINE unsigned long long mal_xgetbv(int reg) + static MA_INLINE unsigned long long mal_xgetbv(int reg) { unsigned int hi; unsigned int lo; @@ -3159,25 +3159,25 @@ mal_uint64 mal_sine_wave_read_f32_ex(mal_sine_wave* pSineWave, mal_uint64 frameC return ((unsigned long long)hi << 32ULL) | (unsigned long long)lo; } #else - #define MAL_NO_CPUID - #define MAL_NO_XGETBV + #define MA_NO_CPUID + #define MA_NO_XGETBV #endif #else - #define MAL_NO_CPUID - #define MAL_NO_XGETBV + #define MA_NO_CPUID + #define MA_NO_XGETBV #endif -static MAL_INLINE mal_bool32 mal_has_sse2() +static MA_INLINE mal_bool32 mal_has_sse2() { -#if defined(MAL_SUPPORT_SSE2) - #if (defined(MAL_X64) || defined(MAL_X86)) && !defined(MAL_NO_SSE2) - #if defined(MAL_X64) - return MAL_TRUE; // 64-bit targets always support SSE2. +#if defined(MA_SUPPORT_SSE2) + #if (defined(MA_X64) || defined(MA_X86)) && !defined(MA_NO_SSE2) + #if defined(MA_X64) + return MA_TRUE; // 64-bit targets always support SSE2. #elif (defined(_M_IX86_FP) && _M_IX86_FP == 2) || defined(__SSE2__) - return MAL_TRUE; // If the compiler is allowed to freely generate SSE2 code we can assume support. + return MA_TRUE; // If the compiler is allowed to freely generate SSE2 code we can assume support. #else - #if defined(MAL_NO_CPUID) - return MAL_FALSE; + #if defined(MA_NO_CPUID) + return MA_FALSE; #else int info[4]; mal_cpuid(info, 1); @@ -3185,58 +3185,58 @@ static MAL_INLINE mal_bool32 mal_has_sse2() #endif #endif #else - return MAL_FALSE; // SSE2 is only supported on x86 and x64 architectures. + return MA_FALSE; // SSE2 is only supported on x86 and x64 architectures. #endif #else - return MAL_FALSE; // No compiler support. + return MA_FALSE; // No compiler support. #endif } #if 0 -static MAL_INLINE mal_bool32 mal_has_avx() +static MA_INLINE mal_bool32 mal_has_avx() { -#if defined(MAL_SUPPORT_AVX) - #if (defined(MAL_X64) || defined(MAL_X86)) && !defined(MAL_NO_AVX) +#if defined(MA_SUPPORT_AVX) + #if (defined(MA_X64) || defined(MA_X86)) && !defined(MA_NO_AVX) #if defined(_AVX_) || defined(__AVX__) - return MAL_TRUE; // If the compiler is allowed to freely generate AVX code we can assume support. + return MA_TRUE; // If the compiler is allowed to freely generate AVX code we can assume support. #else // AVX requires both CPU and OS support. - #if defined(MAL_NO_CPUID) || defined(MAL_NO_XGETBV) - return MAL_FALSE; + #if defined(MA_NO_CPUID) || defined(MA_NO_XGETBV) + return MA_FALSE; #else int info[4]; mal_cpuid(info, 1); if (((info[2] & (1 << 27)) != 0) && ((info[2] & (1 << 28)) != 0)) { mal_uint64 xrc = mal_xgetbv(0); if ((xrc & 0x06) == 0x06) { - return MAL_TRUE; + return MA_TRUE; } else { - return MAL_FALSE; + return MA_FALSE; } } else { - return MAL_FALSE; + return MA_FALSE; } #endif #endif #else - return MAL_FALSE; // AVX is only supported on x86 and x64 architectures. + return MA_FALSE; // AVX is only supported on x86 and x64 architectures. #endif #else - return MAL_FALSE; // No compiler support. + return MA_FALSE; // No compiler support. #endif } #endif -static MAL_INLINE mal_bool32 mal_has_avx2() +static MA_INLINE mal_bool32 mal_has_avx2() { -#if defined(MAL_SUPPORT_AVX2) - #if (defined(MAL_X64) || defined(MAL_X86)) && !defined(MAL_NO_AVX2) +#if defined(MA_SUPPORT_AVX2) + #if (defined(MA_X64) || defined(MA_X86)) && !defined(MA_NO_AVX2) #if defined(_AVX2_) || defined(__AVX2__) - return MAL_TRUE; // If the compiler is allowed to freely generate AVX2 code we can assume support. + return MA_TRUE; // If the compiler is allowed to freely generate AVX2 code we can assume support. #else // AVX2 requires both CPU and OS support. - #if defined(MAL_NO_CPUID) || defined(MAL_NO_XGETBV) - return MAL_FALSE; + #if defined(MA_NO_CPUID) || defined(MA_NO_XGETBV) + return MA_FALSE; #else int info1[4]; int info7[4]; @@ -3245,33 +3245,33 @@ static MAL_INLINE mal_bool32 mal_has_avx2() if (((info1[2] & (1 << 27)) != 0) && ((info7[1] & (1 << 5)) != 0)) { mal_uint64 xrc = mal_xgetbv(0); if ((xrc & 0x06) == 0x06) { - return MAL_TRUE; + return MA_TRUE; } else { - return MAL_FALSE; + return MA_FALSE; } } else { - return MAL_FALSE; + return MA_FALSE; } #endif #endif #else - return MAL_FALSE; // AVX2 is only supported on x86 and x64 architectures. + return MA_FALSE; // AVX2 is only supported on x86 and x64 architectures. #endif #else - return MAL_FALSE; // No compiler support. + return MA_FALSE; // No compiler support. #endif } -static MAL_INLINE mal_bool32 mal_has_avx512f() +static MA_INLINE mal_bool32 mal_has_avx512f() { -#if defined(MAL_SUPPORT_AVX512) - #if (defined(MAL_X64) || defined(MAL_X86)) && !defined(MAL_NO_AVX512) +#if defined(MA_SUPPORT_AVX512) + #if (defined(MA_X64) || defined(MA_X86)) && !defined(MA_NO_AVX512) #if defined(__AVX512F__) - return MAL_TRUE; // If the compiler is allowed to freely generate AVX-512F code we can assume support. + return MA_TRUE; // If the compiler is allowed to freely generate AVX-512F code we can assume support. #else // AVX-512 requires both CPU and OS support. - #if defined(MAL_NO_CPUID) || defined(MAL_NO_XGETBV) - return MAL_FALSE; + #if defined(MA_NO_CPUID) || defined(MA_NO_XGETBV) + return MA_FALSE; #else int info1[4]; int info7[4]; @@ -3280,129 +3280,129 @@ static MAL_INLINE mal_bool32 mal_has_avx512f() if (((info1[2] & (1 << 27)) != 0) && ((info7[1] & (1 << 16)) != 0)) { mal_uint64 xrc = mal_xgetbv(0); if ((xrc & 0xE6) == 0xE6) { - return MAL_TRUE; + return MA_TRUE; } else { - return MAL_FALSE; + return MA_FALSE; } } else { - return MAL_FALSE; + return MA_FALSE; } #endif #endif #else - return MAL_FALSE; // AVX-512F is only supported on x86 and x64 architectures. + return MA_FALSE; // AVX-512F is only supported on x86 and x64 architectures. #endif #else - return MAL_FALSE; // No compiler support. + return MA_FALSE; // No compiler support. #endif } -static MAL_INLINE mal_bool32 mal_has_neon() +static MA_INLINE mal_bool32 mal_has_neon() { -#if defined(MAL_SUPPORT_NEON) - #if defined(MAL_ARM) && !defined(MAL_NO_NEON) +#if defined(MA_SUPPORT_NEON) + #if defined(MA_ARM) && !defined(MA_NO_NEON) #if (defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64)) - return MAL_TRUE; // If the compiler is allowed to freely generate NEON code we can assume support. + return MA_TRUE; // If the compiler is allowed to freely generate NEON code we can assume support. #else // TODO: Runtime check. - return MAL_FALSE; + return MA_FALSE; #endif #else - return MAL_FALSE; // NEON is only supported on ARM architectures. + return MA_FALSE; // NEON is only supported on ARM architectures. #endif #else - return MAL_FALSE; // No compiler support. + return MA_FALSE; // No compiler support. #endif } -static MAL_INLINE mal_bool32 mal_is_little_endian() +static MA_INLINE mal_bool32 mal_is_little_endian() { -#if defined(MAL_X86) || defined(MAL_X64) - return MAL_TRUE; +#if defined(MA_X86) || defined(MA_X64) + return MA_TRUE; #else int n = 1; return (*(char*)&n) == 1; #endif } -static MAL_INLINE mal_bool32 mal_is_big_endian() +static MA_INLINE mal_bool32 mal_is_big_endian() { return !mal_is_little_endian(); } -#ifndef MAL_COINIT_VALUE -#define MAL_COINIT_VALUE 0 /* 0 = COINIT_MULTITHREADED*/ +#ifndef MA_COINIT_VALUE +#define MA_COINIT_VALUE 0 /* 0 = COINIT_MULTITHREADED*/ #endif -#ifndef MAL_PI -#define MAL_PI 3.14159265358979323846264f +#ifndef MA_PI +#define MA_PI 3.14159265358979323846264f #endif -#ifndef MAL_PI_D -#define MAL_PI_D 3.14159265358979323846264 +#ifndef MA_PI_D +#define MA_PI_D 3.14159265358979323846264 #endif -#ifndef MAL_TAU -#define MAL_TAU 6.28318530717958647693f +#ifndef MA_TAU +#define MA_TAU 6.28318530717958647693f #endif -#ifndef MAL_TAU_D -#define MAL_TAU_D 6.28318530717958647693 +#ifndef MA_TAU_D +#define MA_TAU_D 6.28318530717958647693 #endif // The default format when mal_format_unknown (0) is requested when initializing a device. -#ifndef MAL_DEFAULT_FORMAT -#define MAL_DEFAULT_FORMAT mal_format_f32 +#ifndef MA_DEFAULT_FORMAT +#define MA_DEFAULT_FORMAT mal_format_f32 #endif // The default channel count to use when 0 is used when initializing a device. -#ifndef MAL_DEFAULT_CHANNELS -#define MAL_DEFAULT_CHANNELS 2 +#ifndef MA_DEFAULT_CHANNELS +#define MA_DEFAULT_CHANNELS 2 #endif // The default sample rate to use when 0 is used when initializing a device. -#ifndef MAL_DEFAULT_SAMPLE_RATE -#define MAL_DEFAULT_SAMPLE_RATE 48000 +#ifndef MA_DEFAULT_SAMPLE_RATE +#define MA_DEFAULT_SAMPLE_RATE 48000 #endif // Default periods when none is specified in mal_device_init(). More periods means more work on the CPU. -#ifndef MAL_DEFAULT_PERIODS -#define MAL_DEFAULT_PERIODS 3 +#ifndef MA_DEFAULT_PERIODS +#define MA_DEFAULT_PERIODS 3 #endif // The base buffer size in milliseconds for low latency mode. -#ifndef MAL_BASE_BUFFER_SIZE_IN_MILLISECONDS_LOW_LATENCY -#define MAL_BASE_BUFFER_SIZE_IN_MILLISECONDS_LOW_LATENCY (10*MAL_DEFAULT_PERIODS) +#ifndef MA_BASE_BUFFER_SIZE_IN_MILLISECONDS_LOW_LATENCY +#define MA_BASE_BUFFER_SIZE_IN_MILLISECONDS_LOW_LATENCY (10*MA_DEFAULT_PERIODS) #endif // The base buffer size in milliseconds for conservative mode. -#ifndef MAL_BASE_BUFFER_SIZE_IN_MILLISECONDS_CONSERVATIVE -#define MAL_BASE_BUFFER_SIZE_IN_MILLISECONDS_CONSERVATIVE (100*MAL_DEFAULT_PERIODS) +#ifndef MA_BASE_BUFFER_SIZE_IN_MILLISECONDS_CONSERVATIVE +#define MA_BASE_BUFFER_SIZE_IN_MILLISECONDS_CONSERVATIVE (100*MA_DEFAULT_PERIODS) #endif // Standard sample rates, in order of priority. mal_uint32 g_malStandardSampleRatePriorities[] = { - MAL_SAMPLE_RATE_48000, // Most common - MAL_SAMPLE_RATE_44100, + MA_SAMPLE_RATE_48000, // Most common + MA_SAMPLE_RATE_44100, - MAL_SAMPLE_RATE_32000, // Lows - MAL_SAMPLE_RATE_24000, - MAL_SAMPLE_RATE_22050, + MA_SAMPLE_RATE_32000, // Lows + MA_SAMPLE_RATE_24000, + MA_SAMPLE_RATE_22050, - MAL_SAMPLE_RATE_88200, // Highs - MAL_SAMPLE_RATE_96000, - MAL_SAMPLE_RATE_176400, - MAL_SAMPLE_RATE_192000, + MA_SAMPLE_RATE_88200, // Highs + MA_SAMPLE_RATE_96000, + MA_SAMPLE_RATE_176400, + MA_SAMPLE_RATE_192000, - MAL_SAMPLE_RATE_16000, // Extreme lows - MAL_SAMPLE_RATE_11025, - MAL_SAMPLE_RATE_8000, + MA_SAMPLE_RATE_16000, // Extreme lows + MA_SAMPLE_RATE_11025, + MA_SAMPLE_RATE_8000, - MAL_SAMPLE_RATE_352800, // Extreme highs - MAL_SAMPLE_RATE_384000 + MA_SAMPLE_RATE_352800, // Extreme highs + MA_SAMPLE_RATE_384000 }; mal_format g_malFormatPriorities[] = { @@ -3424,57 +3424,57 @@ mal_format g_malFormatPriorities[] = { // Standard Library Stuff // /////////////////////////////////////////////////////////////////////////////// -#ifndef MAL_MALLOC -#ifdef MAL_WIN32 -#define MAL_MALLOC(sz) HeapAlloc(GetProcessHeap(), 0, (sz)) +#ifndef MA_MALLOC +#ifdef MA_WIN32 +#define MA_MALLOC(sz) HeapAlloc(GetProcessHeap(), 0, (sz)) #else -#define MAL_MALLOC(sz) malloc((sz)) +#define MA_MALLOC(sz) malloc((sz)) #endif #endif -#ifndef MAL_REALLOC -#ifdef MAL_WIN32 -#define MAL_REALLOC(p, sz) (((sz) > 0) ? ((p) ? HeapReAlloc(GetProcessHeap(), 0, (p), (sz)) : HeapAlloc(GetProcessHeap(), 0, (sz))) : ((VOID*)(size_t)(HeapFree(GetProcessHeap(), 0, (p)) & 0))) +#ifndef MA_REALLOC +#ifdef MA_WIN32 +#define MA_REALLOC(p, sz) (((sz) > 0) ? ((p) ? HeapReAlloc(GetProcessHeap(), 0, (p), (sz)) : HeapAlloc(GetProcessHeap(), 0, (sz))) : ((VOID*)(size_t)(HeapFree(GetProcessHeap(), 0, (p)) & 0))) #else -#define MAL_REALLOC(p, sz) realloc((p), (sz)) +#define MA_REALLOC(p, sz) realloc((p), (sz)) #endif #endif -#ifndef MAL_FREE -#ifdef MAL_WIN32 -#define MAL_FREE(p) HeapFree(GetProcessHeap(), 0, (p)) +#ifndef MA_FREE +#ifdef MA_WIN32 +#define MA_FREE(p) HeapFree(GetProcessHeap(), 0, (p)) #else -#define MAL_FREE(p) free((p)) +#define MA_FREE(p) free((p)) #endif #endif -#ifndef MAL_ZERO_MEMORY -#ifdef MAL_WIN32 -#define MAL_ZERO_MEMORY(p, sz) ZeroMemory((p), (sz)) +#ifndef MA_ZERO_MEMORY +#ifdef MA_WIN32 +#define MA_ZERO_MEMORY(p, sz) ZeroMemory((p), (sz)) #else -#define MAL_ZERO_MEMORY(p, sz) memset((p), 0, (sz)) +#define MA_ZERO_MEMORY(p, sz) memset((p), 0, (sz)) #endif #endif -#ifndef MAL_COPY_MEMORY -#ifdef MAL_WIN32 -#define MAL_COPY_MEMORY(dst, src, sz) CopyMemory((dst), (src), (sz)) +#ifndef MA_COPY_MEMORY +#ifdef MA_WIN32 +#define MA_COPY_MEMORY(dst, src, sz) CopyMemory((dst), (src), (sz)) #else -#define MAL_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz)) +#define MA_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz)) #endif #endif -#ifndef MAL_ASSERT -#ifdef MAL_WIN32 -#define MAL_ASSERT(condition) assert(condition) +#ifndef MA_ASSERT +#ifdef MA_WIN32 +#define MA_ASSERT(condition) assert(condition) #else -#define MAL_ASSERT(condition) assert(condition) +#define MA_ASSERT(condition) assert(condition) #endif #endif -#define mal_zero_memory MAL_ZERO_MEMORY -#define mal_copy_memory MAL_COPY_MEMORY -#define mal_assert MAL_ASSERT +#define mal_zero_memory MA_ZERO_MEMORY +#define mal_copy_memory MA_COPY_MEMORY +#define mal_assert MA_ASSERT #define mal_zero_object(p) mal_zero_memory((p), sizeof(*(p))) #define mal_countof(x) (sizeof(x) / sizeof(x[0])) @@ -3683,7 +3683,7 @@ int mal_strcmp(const char* str1, const char* str2) // Thanks to good old Bit Twiddling Hacks for this one: http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 -static MAL_INLINE unsigned int mal_next_power_of_2(unsigned int x) +static MA_INLINE unsigned int mal_next_power_of_2(unsigned int x) { x--; x |= x >> 1; @@ -3696,12 +3696,12 @@ static MAL_INLINE unsigned int mal_next_power_of_2(unsigned int x) return x; } -static MAL_INLINE unsigned int mal_prev_power_of_2(unsigned int x) +static MA_INLINE unsigned int mal_prev_power_of_2(unsigned int x) { return mal_next_power_of_2(x) >> 1; } -static MAL_INLINE unsigned int mal_round_to_power_of_2(unsigned int x) +static MA_INLINE unsigned int mal_round_to_power_of_2(unsigned int x) { unsigned int prev = mal_prev_power_of_2(x); unsigned int next = mal_next_power_of_2(x); @@ -3712,7 +3712,7 @@ static MAL_INLINE unsigned int mal_round_to_power_of_2(unsigned int x) } } -static MAL_INLINE unsigned int mal_count_set_bits(unsigned int x) +static MA_INLINE unsigned int mal_count_set_bits(unsigned int x) { unsigned int count = 0; while (x != 0) { @@ -3729,18 +3729,18 @@ static MAL_INLINE unsigned int mal_count_set_bits(unsigned int x) // Clamps an f32 sample to -1..1 -static MAL_INLINE float mal_clip_f32(float x) +static MA_INLINE float mal_clip_f32(float x) { if (x < -1) return -1; if (x > +1) return +1; return x; } -static MAL_INLINE float mal_mix_f32(float x, float y, float a) +static MA_INLINE float mal_mix_f32(float x, float y, float a) { return x*(1-a) + y*a; } -static MAL_INLINE float mal_mix_f32_fast(float x, float y, float a) +static MA_INLINE float mal_mix_f32_fast(float x, float y, float a) { float r0 = (y - x); float r1 = r0*a; @@ -3748,42 +3748,42 @@ static MAL_INLINE float mal_mix_f32_fast(float x, float y, float a) //return x + (y - x)*a; } -#if defined(MAL_SUPPORT_SSE2) -static MAL_INLINE __m128 mal_mix_f32_fast__sse2(__m128 x, __m128 y, __m128 a) +#if defined(MA_SUPPORT_SSE2) +static MA_INLINE __m128 mal_mix_f32_fast__sse2(__m128 x, __m128 y, __m128 a) { return _mm_add_ps(x, _mm_mul_ps(_mm_sub_ps(y, x), a)); } #endif -#if defined(MAL_SUPPORT_AVX2) -static MAL_INLINE __m256 mal_mix_f32_fast__avx2(__m256 x, __m256 y, __m256 a) +#if defined(MA_SUPPORT_AVX2) +static MA_INLINE __m256 mal_mix_f32_fast__avx2(__m256 x, __m256 y, __m256 a) { return _mm256_add_ps(x, _mm256_mul_ps(_mm256_sub_ps(y, x), a)); } #endif -#if defined(MAL_SUPPORT_AVX512) -static MAL_INLINE __m512 mal_mix_f32_fast__avx512(__m512 x, __m512 y, __m512 a) +#if defined(MA_SUPPORT_AVX512) +static MA_INLINE __m512 mal_mix_f32_fast__avx512(__m512 x, __m512 y, __m512 a) { return _mm512_add_ps(x, _mm512_mul_ps(_mm512_sub_ps(y, x), a)); } #endif -#if defined(MAL_SUPPORT_NEON) -static MAL_INLINE float32x4_t mal_mix_f32_fast__neon(float32x4_t x, float32x4_t y, float32x4_t a) +#if defined(MA_SUPPORT_NEON) +static MA_INLINE float32x4_t mal_mix_f32_fast__neon(float32x4_t x, float32x4_t y, float32x4_t a) { return vaddq_f32(x, vmulq_f32(vsubq_f32(y, x), a)); } #endif -static MAL_INLINE double mal_mix_f64(double x, double y, double a) +static MA_INLINE double mal_mix_f64(double x, double y, double a) { return x*(1-a) + y*a; } -static MAL_INLINE double mal_mix_f64_fast(double x, double y, double a) +static MA_INLINE double mal_mix_f64_fast(double x, double y, double a) { return x + (y - x)*a; } -static MAL_INLINE float mal_scale_to_range_f32(float x, float lo, float hi) +static MA_INLINE float mal_scale_to_range_f32(float x, float lo, float hi) { return lo + x*(hi-lo); } @@ -3797,9 +3797,9 @@ static MAL_INLINE float mal_scale_to_range_f32(float x, float lo, float hi) // Note that miniaudio's LCG implementation uses global state which is _not_ thread-local. When this is called across // multiple threads, results will be unpredictable. However, it won't crash and results will still be random enough // for miniaudio's purposes. -#define MAL_LCG_M 4294967296 -#define MAL_LCG_A 1103515245 -#define MAL_LCG_C 12345 +#define MA_LCG_M 4294967296 +#define MA_LCG_A 1103515245 +#define MA_LCG_C 12345 static mal_int32 g_malLCG; void mal_seed(mal_int32 seed) @@ -3810,7 +3810,7 @@ void mal_seed(mal_int32 seed) mal_int32 mal_rand_s32() { mal_int32 lcg = g_malLCG; - mal_int32 r = (MAL_LCG_A * lcg + MAL_LCG_C) % MAL_LCG_M; + mal_int32 r = (MA_LCG_A * lcg + MA_LCG_C) % MA_LCG_M; g_malLCG = r; return r; } @@ -3825,31 +3825,31 @@ float mal_rand_f32() return (float)mal_rand_f64(); } -static MAL_INLINE float mal_rand_range_f32(float lo, float hi) +static MA_INLINE float mal_rand_range_f32(float lo, float hi) { return mal_scale_to_range_f32(mal_rand_f32(), lo, hi); } -static MAL_INLINE mal_int32 mal_rand_range_s32(mal_int32 lo, mal_int32 hi) +static MA_INLINE mal_int32 mal_rand_range_s32(mal_int32 lo, mal_int32 hi) { double x = mal_rand_f64(); return lo + (mal_int32)(x*(hi-lo)); } -static MAL_INLINE float mal_dither_f32_rectangle(float ditherMin, float ditherMax) +static MA_INLINE float mal_dither_f32_rectangle(float ditherMin, float ditherMax) { return mal_rand_range_f32(ditherMin, ditherMax); } -static MAL_INLINE float mal_dither_f32_triangle(float ditherMin, float ditherMax) +static MA_INLINE float mal_dither_f32_triangle(float ditherMin, float ditherMax) { float a = mal_rand_range_f32(ditherMin, 0); float b = mal_rand_range_f32(0, ditherMax); return a + b; } -static MAL_INLINE float mal_dither_f32(mal_dither_mode ditherMode, float ditherMin, float ditherMax) +static MA_INLINE float mal_dither_f32(mal_dither_mode ditherMode, float ditherMin, float ditherMax) { if (ditherMode == mal_dither_mode_rectangle) { return mal_dither_f32_rectangle(ditherMin, ditherMax); @@ -3861,7 +3861,7 @@ static MAL_INLINE float mal_dither_f32(mal_dither_mode ditherMode, float ditherM return 0; } -static MAL_INLINE mal_int32 mal_dither_s32(mal_dither_mode ditherMode, mal_int32 ditherMin, mal_int32 ditherMax) +static MA_INLINE mal_int32 mal_dither_s32(mal_dither_mode ditherMode, mal_int32 ditherMin, mal_int32 ditherMax) { if (ditherMode == mal_dither_mode_rectangle) { mal_int32 a = mal_rand_range_s32(ditherMin, ditherMax); @@ -3934,10 +3934,10 @@ void mal_split_buffer(void* pBuffer, size_t bufferSize, size_t splitCount, size_ #define mal_atomic_decrement_32(a) __sync_sub_and_fetch(a, 1) #endif -#ifdef MAL_64BIT +#ifdef MA_64BIT #define mal_atomic_exchange_ptr mal_atomic_exchange_64 #endif -#ifdef MAL_32BIT +#ifdef MA_32BIT #define mal_atomic_exchange_ptr mal_atomic_exchange_32 #endif @@ -3977,85 +3977,85 @@ mal_uint64 mal_calculate_frame_count_after_src(mal_uint32 sampleRateOut, mal_uin // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef MAL_NO_DEVICE_IO +#ifndef MA_NO_DEVICE_IO // Unfortunately using runtime linking for pthreads causes problems. This has occurred for me when testing on FreeBSD. When // using runtime linking, deadlocks can occur (for me it happens when loading data from fread()). It turns out that doing // compile-time linking fixes this. I'm not sure why this happens, but the safest way I can think of to fix this is to simply // disable runtime linking by default. To enable runtime linking, #define this before the implementation of this file. I am // not officially supporting this, but I'm leaving it here in case it's useful for somebody, somewhere. -//#define MAL_USE_RUNTIME_LINKING_FOR_PTHREAD +//#define MA_USE_RUNTIME_LINKING_FOR_PTHREAD // Disable run-time linking on certain backends. -#ifndef MAL_NO_RUNTIME_LINKING - #if defined(MAL_ANDROID) || defined(MAL_EMSCRIPTEN) - #define MAL_NO_RUNTIME_LINKING +#ifndef MA_NO_RUNTIME_LINKING + #if defined(MA_ANDROID) || defined(MA_EMSCRIPTEN) + #define MA_NO_RUNTIME_LINKING #endif #endif // Check if we have the necessary development packages for each backend at the top so we can use this to determine whether or not // certain unused functions and variables can be excluded from the build to avoid warnings. -#ifdef MAL_ENABLE_WASAPI - #define MAL_HAS_WASAPI // Every compiler should support WASAPI +#ifdef MA_ENABLE_WASAPI + #define MA_HAS_WASAPI // Every compiler should support WASAPI #endif -#ifdef MAL_ENABLE_DSOUND - #define MAL_HAS_DSOUND // Every compiler should support DirectSound. +#ifdef MA_ENABLE_DSOUND + #define MA_HAS_DSOUND // Every compiler should support DirectSound. #endif -#ifdef MAL_ENABLE_WINMM - #define MAL_HAS_WINMM // Every compiler I'm aware of supports WinMM. +#ifdef MA_ENABLE_WINMM + #define MA_HAS_WINMM // Every compiler I'm aware of supports WinMM. #endif -#ifdef MAL_ENABLE_ALSA - #define MAL_HAS_ALSA - #ifdef MAL_NO_RUNTIME_LINKING +#ifdef MA_ENABLE_ALSA + #define MA_HAS_ALSA + #ifdef MA_NO_RUNTIME_LINKING #ifdef __has_include #if !__has_include() - #undef MAL_HAS_ALSA + #undef MA_HAS_ALSA #endif #endif #endif #endif -#ifdef MAL_ENABLE_PULSEAUDIO - #define MAL_HAS_PULSEAUDIO - #ifdef MAL_NO_RUNTIME_LINKING +#ifdef MA_ENABLE_PULSEAUDIO + #define MA_HAS_PULSEAUDIO + #ifdef MA_NO_RUNTIME_LINKING #ifdef __has_include #if !__has_include() - #undef MAL_HAS_PULSEAUDIO + #undef MA_HAS_PULSEAUDIO #endif #endif #endif #endif -#ifdef MAL_ENABLE_JACK - #define MAL_HAS_JACK - #ifdef MAL_NO_RUNTIME_LINKING +#ifdef MA_ENABLE_JACK + #define MA_HAS_JACK + #ifdef MA_NO_RUNTIME_LINKING #ifdef __has_include #if !__has_include() - #undef MAL_HAS_JACK + #undef MA_HAS_JACK #endif #endif #endif #endif -#ifdef MAL_ENABLE_COREAUDIO - #define MAL_HAS_COREAUDIO +#ifdef MA_ENABLE_COREAUDIO + #define MA_HAS_COREAUDIO #endif -#ifdef MAL_ENABLE_SNDIO - #define MAL_HAS_SNDIO +#ifdef MA_ENABLE_SNDIO + #define MA_HAS_SNDIO #endif -#ifdef MAL_ENABLE_AUDIO4 - #define MAL_HAS_AUDIO4 +#ifdef MA_ENABLE_AUDIO4 + #define MA_HAS_AUDIO4 #endif -#ifdef MAL_ENABLE_OSS - #define MAL_HAS_OSS +#ifdef MA_ENABLE_OSS + #define MA_HAS_OSS #endif -#ifdef MAL_ENABLE_AAUDIO - #define MAL_HAS_AAUDIO +#ifdef MA_ENABLE_AAUDIO + #define MA_HAS_AAUDIO #endif -#ifdef MAL_ENABLE_OPENSL - #define MAL_HAS_OPENSL +#ifdef MA_ENABLE_OPENSL + #define MA_HAS_OPENSL #endif -#ifdef MAL_ENABLE_WEBAUDIO - #define MAL_HAS_WEBAUDIO +#ifdef MA_ENABLE_WEBAUDIO + #define MA_HAS_WEBAUDIO #endif -#ifdef MAL_ENABLE_NULL - #define MAL_HAS_NULL // Everything supports the null backend. +#ifdef MA_ENABLE_NULL + #define MA_HAS_NULL // Everything supports the null backend. #endif const char* mal_get_backend_name(mal_backend backend) @@ -4082,41 +4082,41 @@ const char* mal_get_backend_name(mal_backend backend) -#ifdef MAL_WIN32 - #define MAL_THREADCALL WINAPI +#ifdef MA_WIN32 + #define MA_THREADCALL WINAPI typedef unsigned long mal_thread_result; #else - #define MAL_THREADCALL + #define MA_THREADCALL typedef void* mal_thread_result; #endif -typedef mal_thread_result (MAL_THREADCALL * mal_thread_entry_proc)(void* pData); +typedef mal_thread_result (MA_THREADCALL * mal_thread_entry_proc)(void* pData); -#ifdef MAL_WIN32 -typedef HRESULT (WINAPI * MAL_PFN_CoInitializeEx)(LPVOID pvReserved, DWORD dwCoInit); -typedef void (WINAPI * MAL_PFN_CoUninitialize)(); -typedef HRESULT (WINAPI * MAL_PFN_CoCreateInstance)(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID *ppv); -typedef void (WINAPI * MAL_PFN_CoTaskMemFree)(LPVOID pv); -typedef HRESULT (WINAPI * MAL_PFN_PropVariantClear)(PROPVARIANT *pvar); -typedef int (WINAPI * MAL_PFN_StringFromGUID2)(const GUID* const rguid, LPOLESTR lpsz, int cchMax); +#ifdef MA_WIN32 +typedef HRESULT (WINAPI * MA_PFN_CoInitializeEx)(LPVOID pvReserved, DWORD dwCoInit); +typedef void (WINAPI * MA_PFN_CoUninitialize)(); +typedef HRESULT (WINAPI * MA_PFN_CoCreateInstance)(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID riid, LPVOID *ppv); +typedef void (WINAPI * MA_PFN_CoTaskMemFree)(LPVOID pv); +typedef HRESULT (WINAPI * MA_PFN_PropVariantClear)(PROPVARIANT *pvar); +typedef int (WINAPI * MA_PFN_StringFromGUID2)(const GUID* const rguid, LPOLESTR lpsz, int cchMax); -typedef HWND (WINAPI * MAL_PFN_GetForegroundWindow)(); -typedef HWND (WINAPI * MAL_PFN_GetDesktopWindow)(); +typedef HWND (WINAPI * MA_PFN_GetForegroundWindow)(); +typedef HWND (WINAPI * MA_PFN_GetDesktopWindow)(); // Microsoft documents these APIs as returning LSTATUS, but the Win32 API shipping with some compilers do not define it. It's just a LONG. -typedef LONG (WINAPI * MAL_PFN_RegOpenKeyExA)(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult); -typedef LONG (WINAPI * MAL_PFN_RegCloseKey)(HKEY hKey); -typedef LONG (WINAPI * MAL_PFN_RegQueryValueExA)(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData); +typedef LONG (WINAPI * MA_PFN_RegOpenKeyExA)(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult); +typedef LONG (WINAPI * MA_PFN_RegCloseKey)(HKEY hKey); +typedef LONG (WINAPI * MA_PFN_RegQueryValueExA)(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData); #endif -#define MAL_STATE_UNINITIALIZED 0 -#define MAL_STATE_STOPPED 1 // The device's default state after initialization. -#define MAL_STATE_STARTED 2 // The worker thread is in it's main loop waiting for the driver to request or deliver audio data. -#define MAL_STATE_STARTING 3 // Transitioning from a stopped state to started. -#define MAL_STATE_STOPPING 4 // Transitioning from a started state to stopped. +#define MA_STATE_UNINITIALIZED 0 +#define MA_STATE_STOPPED 1 // The device's default state after initialization. +#define MA_STATE_STARTED 2 // The worker thread is in it's main loop waiting for the driver to request or deliver audio data. +#define MA_STATE_STARTING 3 // Transitioning from a stopped state to started. +#define MA_STATE_STOPPING 4 // Transitioning from a started state to stopped. -#define MAL_DEFAULT_PLAYBACK_DEVICE_NAME "Default Playback Device" -#define MAL_DEFAULT_CAPTURE_DEVICE_NAME "Default Capture Device" +#define MA_DEFAULT_PLAYBACK_DEVICE_NAME "Default Playback Device" +#define MA_DEFAULT_CAPTURE_DEVICE_NAME "Default Capture Device" /////////////////////////////////////////////////////////////////////////////// @@ -4124,7 +4124,7 @@ typedef LONG (WINAPI * MAL_PFN_RegQueryValueExA)(HKEY hKey, LPCSTR lpValueName, // Timing // /////////////////////////////////////////////////////////////////////////////// -#ifdef MAL_WIN32 +#ifdef MA_WIN32 LARGE_INTEGER g_mal_TimerFrequency = {{0}}; void mal_timer_init(mal_timer* pTimer) { @@ -4146,7 +4146,7 @@ double mal_timer_get_time_in_seconds(mal_timer* pTimer) return (double)(counter.QuadPart - pTimer->counter) / g_mal_TimerFrequency.QuadPart; } -#elif defined(MAL_APPLE) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101200) +#elif defined(MA_APPLE) && (__MAC_OS_X_VERSION_MIN_REQUIRED < 101200) mal_uint64 g_mal_TimerFrequency = 0; void mal_timer_init(mal_timer* pTimer) { @@ -4164,7 +4164,7 @@ double mal_timer_get_time_in_seconds(mal_timer* pTimer) return (newTimeCounter - oldTimeCounter) / g_mal_TimerFrequency; } -#elif defined(MAL_EMSCRIPTEN) +#elif defined(MA_EMSCRIPTEN) void mal_timer_init(mal_timer* pTimer) { pTimer->counterD = emscripten_get_now(); @@ -4176,15 +4176,15 @@ double mal_timer_get_time_in_seconds(mal_timer* pTimer) } #else #if defined(CLOCK_MONOTONIC) - #define MAL_CLOCK_ID CLOCK_MONOTONIC + #define MA_CLOCK_ID CLOCK_MONOTONIC #else - #define MAL_CLOCK_ID CLOCK_REALTIME + #define MA_CLOCK_ID CLOCK_REALTIME #endif void mal_timer_init(mal_timer* pTimer) { struct timespec newTime; - clock_gettime(MAL_CLOCK_ID, &newTime); + clock_gettime(MA_CLOCK_ID, &newTime); pTimer->counter = (newTime.tv_sec * 1000000000) + newTime.tv_nsec; } @@ -4192,7 +4192,7 @@ void mal_timer_init(mal_timer* pTimer) double mal_timer_get_time_in_seconds(mal_timer* pTimer) { struct timespec newTime; - clock_gettime(MAL_CLOCK_ID, &newTime); + clock_gettime(MA_CLOCK_ID, &newTime); mal_uint64 newTimeCounter = (newTime.tv_sec * 1000000000) + newTime.tv_nsec; mal_uint64 oldTimeCounter = pTimer->counter; @@ -4210,7 +4210,7 @@ double mal_timer_get_time_in_seconds(mal_timer* pTimer) mal_handle mal_dlopen(const char* filename) { #ifdef _WIN32 -#ifdef MAL_WIN32_DESKTOP +#ifdef MA_WIN32_DESKTOP return (mal_handle)LoadLibraryA(filename); #else // *sigh* It appears there is no ANSI version of LoadPackagedLibrary()... @@ -4250,7 +4250,7 @@ mal_proc mal_dlsym(mal_handle handle, const char* symbol) // Threading // /////////////////////////////////////////////////////////////////////////////// -#ifdef MAL_WIN32 +#ifdef MA_WIN32 int mal_thread_priority_to_win32(mal_thread_priority priority) { switch (priority) { @@ -4269,12 +4269,12 @@ mal_result mal_thread_create__win32(mal_context* pContext, mal_thread* pThread, { pThread->win32.hThread = CreateThread(NULL, 0, entryProc, pData, 0, NULL); if (pThread->win32.hThread == NULL) { - return MAL_FAILED_TO_CREATE_THREAD; + return MA_FAILED_TO_CREATE_THREAD; } SetThreadPriority((HANDLE)pThread->win32.hThread, mal_thread_priority_to_win32(pContext->config.threadPriority)); - return MAL_SUCCESS; + return MA_SUCCESS; } void mal_thread_wait__win32(mal_thread* pThread) @@ -4294,10 +4294,10 @@ mal_result mal_mutex_init__win32(mal_context* pContext, mal_mutex* pMutex) pMutex->win32.hMutex = CreateEventA(NULL, FALSE, TRUE, NULL); if (pMutex->win32.hMutex == NULL) { - return MAL_FAILED_TO_CREATE_MUTEX; + return MA_FAILED_TO_CREATE_MUTEX; } - return MAL_SUCCESS; + return MA_SUCCESS; } void mal_mutex_uninit__win32(mal_mutex* pMutex) @@ -4322,10 +4322,10 @@ mal_result mal_event_init__win32(mal_context* pContext, mal_event* pEvent) pEvent->win32.hEvent = CreateEventW(NULL, FALSE, FALSE, NULL); if (pEvent->win32.hEvent == NULL) { - return MAL_FAILED_TO_CREATE_EVENT; + return MA_FAILED_TO_CREATE_EVENT; } - return MAL_SUCCESS; + return MA_SUCCESS; } void mal_event_uninit__win32(mal_event* pEvent) @@ -4345,7 +4345,7 @@ mal_bool32 mal_event_signal__win32(mal_event* pEvent) #endif -#ifdef MAL_POSIX +#ifdef MA_POSIX #include typedef int (* mal_pthread_create_proc)(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg); @@ -4385,7 +4385,7 @@ mal_bool32 mal_thread_create__posix(mal_context* pContext, mal_thread* pThread, scheduler = SCHED_FIFO; } #endif -#ifdef MAL_LINUX +#ifdef MA_LINUX } else { scheduler = sched_getscheduler(0); #endif @@ -4424,10 +4424,10 @@ mal_bool32 mal_thread_create__posix(mal_context* pContext, mal_thread* pThread, int result = ((mal_pthread_create_proc)pContext->posix.pthread_create)(&pThread->posix.thread, pAttr, entryProc, pData); if (result != 0) { - return MAL_FAILED_TO_CREATE_THREAD; + return MA_FAILED_TO_CREATE_THREAD; } - return MAL_SUCCESS; + return MA_SUCCESS; } void mal_thread_wait__posix(mal_thread* pThread) @@ -4437,9 +4437,9 @@ void mal_thread_wait__posix(mal_thread* pThread) void mal_sleep__posix(mal_uint32 milliseconds) { -#ifdef MAL_EMSCRIPTEN +#ifdef MA_EMSCRIPTEN (void)milliseconds; - mal_assert(MAL_FALSE); /* The Emscripten build should never sleep. */ + mal_assert(MA_FALSE); /* The Emscripten build should never sleep. */ #else usleep(milliseconds * 1000); /* <-- usleep is in microseconds. */ #endif @@ -4450,10 +4450,10 @@ mal_result mal_mutex_init__posix(mal_context* pContext, mal_mutex* pMutex) { int result = ((mal_pthread_mutex_init_proc)pContext->posix.pthread_mutex_init)(&pMutex->posix.mutex, NULL); if (result != 0) { - return MAL_FAILED_TO_CREATE_MUTEX; + return MA_FAILED_TO_CREATE_MUTEX; } - return MAL_SUCCESS; + return MA_SUCCESS; } void mal_mutex_uninit__posix(mal_mutex* pMutex) @@ -4475,15 +4475,15 @@ void mal_mutex_unlock__posix(mal_mutex* pMutex) mal_result mal_event_init__posix(mal_context* pContext, mal_event* pEvent) { if (((mal_pthread_mutex_init_proc)pContext->posix.pthread_mutex_init)(&pEvent->posix.mutex, NULL) != 0) { - return MAL_FAILED_TO_CREATE_MUTEX; + return MA_FAILED_TO_CREATE_MUTEX; } if (((mal_pthread_cond_init_proc)pContext->posix.pthread_cond_init)(&pEvent->posix.condition, NULL) != 0) { - return MAL_FAILED_TO_CREATE_EVENT; + return MA_FAILED_TO_CREATE_EVENT; } pEvent->posix.value = 0; - return MAL_SUCCESS; + return MA_SUCCESS; } void mal_event_uninit__posix(mal_event* pEvent) @@ -4503,7 +4503,7 @@ mal_bool32 mal_event_wait__posix(mal_event* pEvent) } ((mal_pthread_mutex_unlock_proc)pEvent->pContext->posix.pthread_mutex_unlock)(&pEvent->posix.mutex); - return MAL_TRUE; + return MA_TRUE; } mal_bool32 mal_event_signal__posix(mal_event* pEvent) @@ -4515,20 +4515,20 @@ mal_bool32 mal_event_signal__posix(mal_event* pEvent) } ((mal_pthread_mutex_unlock_proc)pEvent->pContext->posix.pthread_mutex_unlock)(&pEvent->posix.mutex); - return MAL_TRUE; + return MA_TRUE; } #endif mal_result mal_thread_create(mal_context* pContext, mal_thread* pThread, mal_thread_entry_proc entryProc, void* pData) { - if (pContext == NULL || pThread == NULL || entryProc == NULL) return MAL_FALSE; + if (pContext == NULL || pThread == NULL || entryProc == NULL) return MA_FALSE; pThread->pContext = pContext; -#ifdef MAL_WIN32 +#ifdef MA_WIN32 return mal_thread_create__win32(pContext, pThread, entryProc, pData); #endif -#ifdef MAL_POSIX +#ifdef MA_POSIX return mal_thread_create__posix(pContext, pThread, entryProc, pData); #endif } @@ -4537,20 +4537,20 @@ void mal_thread_wait(mal_thread* pThread) { if (pThread == NULL) return; -#ifdef MAL_WIN32 +#ifdef MA_WIN32 mal_thread_wait__win32(pThread); #endif -#ifdef MAL_POSIX +#ifdef MA_POSIX mal_thread_wait__posix(pThread); #endif } void mal_sleep(mal_uint32 milliseconds) { -#ifdef MAL_WIN32 +#ifdef MA_WIN32 mal_sleep__win32(milliseconds); #endif -#ifdef MAL_POSIX +#ifdef MA_POSIX mal_sleep__posix(milliseconds); #endif } @@ -4559,15 +4559,15 @@ void mal_sleep(mal_uint32 milliseconds) mal_result mal_mutex_init(mal_context* pContext, mal_mutex* pMutex) { if (pContext == NULL || pMutex == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } pMutex->pContext = pContext; -#ifdef MAL_WIN32 +#ifdef MA_WIN32 return mal_mutex_init__win32(pContext, pMutex); #endif -#ifdef MAL_POSIX +#ifdef MA_POSIX return mal_mutex_init__posix(pContext, pMutex); #endif } @@ -4576,10 +4576,10 @@ void mal_mutex_uninit(mal_mutex* pMutex) { if (pMutex == NULL || pMutex->pContext == NULL) return; -#ifdef MAL_WIN32 +#ifdef MA_WIN32 mal_mutex_uninit__win32(pMutex); #endif -#ifdef MAL_POSIX +#ifdef MA_POSIX mal_mutex_uninit__posix(pMutex); #endif } @@ -4588,10 +4588,10 @@ void mal_mutex_lock(mal_mutex* pMutex) { if (pMutex == NULL || pMutex->pContext == NULL) return; -#ifdef MAL_WIN32 +#ifdef MA_WIN32 mal_mutex_lock__win32(pMutex); #endif -#ifdef MAL_POSIX +#ifdef MA_POSIX mal_mutex_lock__posix(pMutex); #endif } @@ -4600,10 +4600,10 @@ void mal_mutex_unlock(mal_mutex* pMutex) { if (pMutex == NULL || pMutex->pContext == NULL) return; -#ifdef MAL_WIN32 +#ifdef MA_WIN32 mal_mutex_unlock__win32(pMutex); #endif -#ifdef MAL_POSIX +#ifdef MA_POSIX mal_mutex_unlock__posix(pMutex); #endif } @@ -4611,14 +4611,14 @@ void mal_mutex_unlock(mal_mutex* pMutex) mal_result mal_event_init(mal_context* pContext, mal_event* pEvent) { - if (pContext == NULL || pEvent == NULL) return MAL_FALSE; + if (pContext == NULL || pEvent == NULL) return MA_FALSE; pEvent->pContext = pContext; -#ifdef MAL_WIN32 +#ifdef MA_WIN32 return mal_event_init__win32(pContext, pEvent); #endif -#ifdef MAL_POSIX +#ifdef MA_POSIX return mal_event_init__posix(pContext, pEvent); #endif } @@ -4627,34 +4627,34 @@ void mal_event_uninit(mal_event* pEvent) { if (pEvent == NULL || pEvent->pContext == NULL) return; -#ifdef MAL_WIN32 +#ifdef MA_WIN32 mal_event_uninit__win32(pEvent); #endif -#ifdef MAL_POSIX +#ifdef MA_POSIX mal_event_uninit__posix(pEvent); #endif } mal_bool32 mal_event_wait(mal_event* pEvent) { - if (pEvent == NULL || pEvent->pContext == NULL) return MAL_FALSE; + if (pEvent == NULL || pEvent->pContext == NULL) return MA_FALSE; -#ifdef MAL_WIN32 +#ifdef MA_WIN32 return mal_event_wait__win32(pEvent); #endif -#ifdef MAL_POSIX +#ifdef MA_POSIX return mal_event_wait__posix(pEvent); #endif } mal_bool32 mal_event_signal(mal_event* pEvent) { - if (pEvent == NULL || pEvent->pContext == NULL) return MAL_FALSE; + if (pEvent == NULL || pEvent->pContext == NULL) return MA_FALSE; -#ifdef MAL_WIN32 +#ifdef MA_WIN32 return mal_event_signal__win32(pEvent); #endif -#ifdef MAL_POSIX +#ifdef MA_POSIX return mal_event_signal__posix(pEvent); #endif } @@ -4663,11 +4663,11 @@ mal_bool32 mal_event_signal(mal_event* pEvent) mal_uint32 mal_get_best_sample_rate_within_range(mal_uint32 sampleRateMin, mal_uint32 sampleRateMax) { // Normalize the range in case we were given something stupid. - if (sampleRateMin < MAL_MIN_SAMPLE_RATE) { - sampleRateMin = MAL_MIN_SAMPLE_RATE; + if (sampleRateMin < MA_MIN_SAMPLE_RATE) { + sampleRateMin = MA_MIN_SAMPLE_RATE; } - if (sampleRateMax > MAL_MAX_SAMPLE_RATE) { - sampleRateMax = MAL_MAX_SAMPLE_RATE; + if (sampleRateMax > MA_MAX_SAMPLE_RATE) { + sampleRateMax = MA_MAX_SAMPLE_RATE; } if (sampleRateMin > sampleRateMax) { sampleRateMin = sampleRateMax; @@ -4685,7 +4685,7 @@ mal_uint32 mal_get_best_sample_rate_within_range(mal_uint32 sampleRateMin, mal_u } // Should never get here. - mal_assert(MAL_FALSE); + mal_assert(MA_FALSE); return 0; } @@ -4736,9 +4736,9 @@ mal_uint32 mal_calculate_buffer_size_in_frames_from_milliseconds(mal_uint32 buff mal_uint32 mal_get_default_buffer_size_in_milliseconds(mal_performance_profile performanceProfile) { if (performanceProfile == mal_performance_profile_low_latency) { - return MAL_BASE_BUFFER_SIZE_IN_MILLISECONDS_LOW_LATENCY; + return MA_BASE_BUFFER_SIZE_IN_MILLISECONDS_LOW_LATENCY; } else { - return MAL_BASE_BUFFER_SIZE_IN_MILLISECONDS_CONSERVATIVE; + return MA_BASE_BUFFER_SIZE_IN_MILLISECONDS_CONSERVATIVE; } } @@ -4773,10 +4773,10 @@ const char* mal_log_level_to_string(mal_uint32 logLevel) { switch (logLevel) { - case MAL_LOG_LEVEL_VERBOSE: return ""; - case MAL_LOG_LEVEL_INFO: return "INFO"; - case MAL_LOG_LEVEL_WARNING: return "WARNING"; - case MAL_LOG_LEVEL_ERROR: return "ERROR"; + case MA_LOG_LEVEL_VERBOSE: return ""; + case MA_LOG_LEVEL_INFO: return "INFO"; + case MA_LOG_LEVEL_WARNING: return "WARNING"; + case MA_LOG_LEVEL_ERROR: return "ERROR"; default: return "ERROR"; } } @@ -4786,10 +4786,10 @@ void mal_log(mal_context* pContext, mal_device* pDevice, mal_uint32 logLevel, co { if (pContext == NULL) return; -#if defined(MAL_LOG_LEVEL) - if (logLevel <= MAL_LOG_LEVEL) { - #if defined(MAL_DEBUG_OUTPUT) - if (logLevel <= MAL_LOG_LEVEL) { +#if defined(MA_LOG_LEVEL) + if (logLevel <= MA_LOG_LEVEL) { + #if defined(MA_DEBUG_OUTPUT) + if (logLevel <= MA_LOG_LEVEL) { printf("%s: %s\n", mal_log_level_to_string(logLevel), message); } #endif @@ -4890,7 +4890,7 @@ mal_uint32 mal_device__pcm_converter__on_read_from_buffer_playback(mal_pcm_conve // A helper function for reading sample data from the client. -static MAL_INLINE void mal_device__read_frames_from_client(mal_device* pDevice, mal_uint32 frameCount, void* pSamples) +static MA_INLINE void mal_device__read_frames_from_client(mal_device* pDevice, mal_uint32 frameCount, void* pSamples) { mal_assert(pDevice != NULL); mal_assert(frameCount > 0); @@ -4900,7 +4900,7 @@ static MAL_INLINE void mal_device__read_frames_from_client(mal_device* pDevice, } // A helper for sending sample data to the client. -static MAL_INLINE void mal_device__send_frames_to_client(mal_device* pDevice, mal_uint32 frameCount, const void* pSamples) +static MA_INLINE void mal_device__send_frames_to_client(mal_device* pDevice, mal_uint32 frameCount, const void* pSamples) { mal_assert(pDevice != NULL); mal_assert(frameCount > 0); @@ -4929,7 +4929,7 @@ static MAL_INLINE void mal_device__send_frames_to_client(mal_device* pDevice, ma } } -static MAL_INLINE mal_result mal_device__handle_duplex_callback_capture(mal_device* pDevice, mal_uint32 frameCount, const void* pFramesInInternalFormat, mal_pcm_rb* pRB) +static MA_INLINE mal_result mal_device__handle_duplex_callback_capture(mal_device* pDevice, mal_uint32 frameCount, const void* pFramesInInternalFormat, mal_pcm_rb* pRB) { mal_assert(pDevice != NULL); mal_assert(frameCount > 0); @@ -4947,8 +4947,8 @@ static MAL_INLINE mal_result mal_device__handle_duplex_callback_capture(mal_devi mal_uint32 framesToProcess = 256; void* pFramesInExternalFormat; result = mal_pcm_rb_acquire_write(pRB, &framesToProcess, &pFramesInExternalFormat); - if (result != MAL_SUCCESS) { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "Failed to acquire capture PCM frames from ring buffer.", result); + if (result != MA_SUCCESS) { + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "Failed to acquire capture PCM frames from ring buffer.", result); break; } @@ -4962,8 +4962,8 @@ static MAL_INLINE mal_result mal_device__handle_duplex_callback_capture(mal_devi framesProcessed = (mal_uint32)mal_pcm_converter_read(&pDevice->capture.converter, pFramesInExternalFormat, framesToProcess); result = mal_pcm_rb_commit_write(pRB, framesProcessed, pFramesInExternalFormat); - if (result != MAL_SUCCESS) { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "Failed to commit capture PCM frames to ring buffer.", result); + if (result != MA_SUCCESS) { + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "Failed to commit capture PCM frames to ring buffer.", result); break; } @@ -4972,10 +4972,10 @@ static MAL_INLINE mal_result mal_device__handle_duplex_callback_capture(mal_devi } } - return MAL_SUCCESS; + return MA_SUCCESS; } -static MAL_INLINE mal_result mal_device__handle_duplex_callback_playback(mal_device* pDevice, mal_uint32 frameCount, void* pFramesInInternalFormat, mal_pcm_rb* pRB) +static MA_INLINE mal_result mal_device__handle_duplex_callback_playback(mal_device* pDevice, mal_uint32 frameCount, void* pFramesInInternalFormat, mal_pcm_rb* pRB) { mal_assert(pDevice != NULL); mal_assert(frameCount > 0); @@ -5005,7 +5005,7 @@ static MAL_INLINE mal_result mal_device__handle_duplex_callback_playback(mal_dev mal_uint32 inputFrameCount = framesToProcessFromClient; void* pInputFrames; result = mal_pcm_rb_acquire_read(pRB, &inputFrameCount, &pInputFrames); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { if (inputFrameCount > 0) { /* Use actual input frames. */ pDevice->onData(pDevice, playbackFramesInExternalFormat, pInputFrames, inputFrameCount); @@ -5017,7 +5017,7 @@ static MAL_INLINE mal_result mal_device__handle_duplex_callback_playback(mal_dev /* We're done with the captured samples. */ result = mal_pcm_rb_commit_read(pRB, inputFrameCount, pInputFrames); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { break; /* Don't know what to do here... Just abandon ship. */ } } else { @@ -5039,33 +5039,33 @@ static MAL_INLINE mal_result mal_device__handle_duplex_callback_playback(mal_dev pFramesInInternalFormat = mal_offset_ptr(pFramesInInternalFormat, inputFrameCount * mal_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels)); } - return MAL_SUCCESS; + return MA_SUCCESS; } // A helper for changing the state of the device. -static MAL_INLINE void mal_device__set_state(mal_device* pDevice, mal_uint32 newState) +static MA_INLINE void mal_device__set_state(mal_device* pDevice, mal_uint32 newState) { mal_atomic_exchange_32(&pDevice->state, newState); } // A helper for getting the state of the device. -static MAL_INLINE mal_uint32 mal_device__get_state(mal_device* pDevice) +static MA_INLINE mal_uint32 mal_device__get_state(mal_device* pDevice) { return pDevice->state; } /* A helper for determining whether or not the device is running in async mode. */ -static MAL_INLINE mal_bool32 mal_device__is_async(mal_device* pDevice) +static MA_INLINE mal_bool32 mal_device__is_async(mal_device* pDevice) { return pDevice->onData != NULL; } -#ifdef MAL_WIN32 - GUID MAL_GUID_KSDATAFORMAT_SUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; - GUID MAL_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; - //GUID MAL_GUID_KSDATAFORMAT_SUBTYPE_ALAW = {0x00000006, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; - //GUID MAL_GUID_KSDATAFORMAT_SUBTYPE_MULAW = {0x00000007, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; +#ifdef MA_WIN32 + GUID MA_GUID_KSDATAFORMAT_SUBTYPE_PCM = {0x00000001, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; + GUID MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = {0x00000003, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; + //GUID MA_GUID_KSDATAFORMAT_SUBTYPE_ALAW = {0x00000006, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; + //GUID MA_GUID_KSDATAFORMAT_SUBTYPE_MULAW = {0x00000007, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}}; #endif @@ -5073,18 +5073,18 @@ mal_bool32 mal_context__device_id_equal(mal_context* pContext, const mal_device_ { mal_assert(pContext != NULL); - if (pID0 == pID1) return MAL_TRUE; + if (pID0 == pID1) return MA_TRUE; if ((pID0 == NULL && pID1 != NULL) || (pID0 != NULL && pID1 == NULL)) { - return MAL_FALSE; + return MA_FALSE; } if (pContext->onDeviceIDEqual) { return pContext->onDeviceIDEqual(pContext, pID0, pID1); } - return MAL_FALSE; + return MA_FALSE; } @@ -5105,7 +5105,7 @@ mal_bool32 mal_context__try_get_device_name_by_id__enum_callback(mal_context* pC if (pData->deviceType == deviceType) { if (pContext->onDeviceIDEqual(pContext, pData->pDeviceID, &pDeviceInfo->id)) { mal_strncpy_s(pData->pName, pData->nameBufferSize, pDeviceInfo->name, (size_t)-1); - pData->foundDevice = MAL_TRUE; + pData->foundDevice = MA_TRUE; } } @@ -5121,7 +5121,7 @@ mal_result mal_context__try_get_device_name_by_id(mal_context* pContext, mal_dev mal_assert(pName != NULL); if (pDeviceID == NULL) { - return MAL_NO_DEVICE; + return MA_NO_DEVICE; } mal_context__try_get_device_name_by_id__enum_callback_data data; @@ -5129,16 +5129,16 @@ mal_result mal_context__try_get_device_name_by_id(mal_context* pContext, mal_dev data.pDeviceID = pDeviceID; data.pName = pName; data.nameBufferSize = nameBufferSize; - data.foundDevice = MAL_FALSE; + data.foundDevice = MA_FALSE; mal_result result = mal_context_enumerate_devices(pContext, mal_context__try_get_device_name_by_id__enum_callback, &data); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } if (!data.foundDevice) { - return MAL_NO_DEVICE; + return MA_NO_DEVICE; } else { - return MAL_SUCCESS; + return MA_SUCCESS; } } @@ -5162,14 +5162,14 @@ void mal_device__post_init_setup(mal_device* pDevice, mal_device_type deviceType // Null Backend // /////////////////////////////////////////////////////////////////////////////// -#ifdef MAL_HAS_NULL +#ifdef MA_HAS_NULL -#define MAL_DEVICE_OP_NONE__NULL 0 -#define MAL_DEVICE_OP_START__NULL 1 -#define MAL_DEVICE_OP_SUSPEND__NULL 2 -#define MAL_DEVICE_OP_KILL__NULL 3 +#define MA_DEVICE_OP_NONE__NULL 0 +#define MA_DEVICE_OP_START__NULL 1 +#define MA_DEVICE_OP_SUSPEND__NULL 2 +#define MA_DEVICE_OP_KILL__NULL 3 -mal_thread_result MAL_THREADCALL mal_device_thread__null(void* pData) +mal_thread_result MA_THREADCALL mal_device_thread__null(void* pData) { mal_device* pDevice = (mal_device*)pData; mal_assert(pDevice != NULL); @@ -5181,49 +5181,49 @@ mal_thread_result MAL_THREADCALL mal_device_thread__null(void* pData) /* At this point an event should have been triggered. */ /* Starting the device needs to put the thread into a loop. */ - if (pDevice->null_device.operation == MAL_DEVICE_OP_START__NULL) { - mal_atomic_exchange_32(&pDevice->null_device.operation, MAL_DEVICE_OP_NONE__NULL); + if (pDevice->null_device.operation == MA_DEVICE_OP_START__NULL) { + mal_atomic_exchange_32(&pDevice->null_device.operation, MA_DEVICE_OP_NONE__NULL); /* Reset the timer just in case. */ mal_timer_init(&pDevice->null_device.timer); /* Keep looping until an operation has been requested. */ - while (pDevice->null_device.operation != MAL_DEVICE_OP_NONE__NULL && pDevice->null_device.operation != MAL_DEVICE_OP_START__NULL) { + while (pDevice->null_device.operation != MA_DEVICE_OP_NONE__NULL && pDevice->null_device.operation != MA_DEVICE_OP_START__NULL) { mal_sleep(10); /* Don't hog the CPU. */ } /* Getting here means a suspend or kill operation has been requested. */ - mal_atomic_exchange_32(&pDevice->null_device.operationResult, MAL_SUCCESS); + mal_atomic_exchange_32(&pDevice->null_device.operationResult, MA_SUCCESS); mal_event_signal(&pDevice->null_device.operationCompletionEvent); continue; } /* Suspending the device means we need to stop the timer and just continue the loop. */ - if (pDevice->null_device.operation == MAL_DEVICE_OP_SUSPEND__NULL) { - mal_atomic_exchange_32(&pDevice->null_device.operation, MAL_DEVICE_OP_NONE__NULL); + if (pDevice->null_device.operation == MA_DEVICE_OP_SUSPEND__NULL) { + mal_atomic_exchange_32(&pDevice->null_device.operation, MA_DEVICE_OP_NONE__NULL); /* We need to add the current run time to the prior run time, then reset the timer. */ pDevice->null_device.priorRunTime += mal_timer_get_time_in_seconds(&pDevice->null_device.timer); mal_timer_init(&pDevice->null_device.timer); /* We're done. */ - mal_atomic_exchange_32(&pDevice->null_device.operationResult, MAL_SUCCESS); + mal_atomic_exchange_32(&pDevice->null_device.operationResult, MA_SUCCESS); mal_event_signal(&pDevice->null_device.operationCompletionEvent); continue; } /* Killing the device means we need to get out of this loop so that this thread can terminate. */ - if (pDevice->null_device.operation == MAL_DEVICE_OP_KILL__NULL) { - mal_atomic_exchange_32(&pDevice->null_device.operation, MAL_DEVICE_OP_NONE__NULL); - mal_atomic_exchange_32(&pDevice->null_device.operationResult, MAL_SUCCESS); + if (pDevice->null_device.operation == MA_DEVICE_OP_KILL__NULL) { + mal_atomic_exchange_32(&pDevice->null_device.operation, MA_DEVICE_OP_NONE__NULL); + mal_atomic_exchange_32(&pDevice->null_device.operationResult, MA_SUCCESS); mal_event_signal(&pDevice->null_device.operationCompletionEvent); break; } /* Getting a signal on a "none" operation probably means an error. Return invalid operation. */ - if (pDevice->null_device.operation == MAL_DEVICE_OP_NONE__NULL) { - mal_assert(MAL_FALSE); /* <-- Trigger this in debug mode to ensure developers are aware they're doing something wrong (or there's a bug in a miniaudio). */ - mal_atomic_exchange_32(&pDevice->null_device.operationResult, MAL_INVALID_OPERATION); + if (pDevice->null_device.operation == MA_DEVICE_OP_NONE__NULL) { + mal_assert(MA_FALSE); /* <-- Trigger this in debug mode to ensure developers are aware they're doing something wrong (or there's a bug in a miniaudio). */ + mal_atomic_exchange_32(&pDevice->null_device.operationResult, MA_INVALID_OPERATION); mal_event_signal(&pDevice->null_device.operationCompletionEvent); continue; /* Continue the loop. Don't terminate. */ } @@ -5236,11 +5236,11 @@ mal_result mal_device_do_operation__null(mal_device* pDevice, mal_uint32 operati { mal_atomic_exchange_32(&pDevice->null_device.operation, operation); if (!mal_event_signal(&pDevice->null_device.operationEvent)) { - return MAL_ERROR; + return MA_ERROR; } if (!mal_event_wait(&pDevice->null_device.operationCompletionEvent)) { - return MAL_ERROR; + return MA_ERROR; } return pDevice->null_device.operationResult; @@ -5274,7 +5274,7 @@ mal_result mal_context_enumerate_devices__null(mal_context* pContext, mal_enum_d mal_assert(pContext != NULL); mal_assert(callback != NULL); - mal_bool32 cbResult = MAL_TRUE; + mal_bool32 cbResult = MA_TRUE; // Playback. if (cbResult) { @@ -5292,7 +5292,7 @@ mal_result mal_context_enumerate_devices__null(mal_context* pContext, mal_enum_d cbResult = callback(pContext, mal_device_type_capture, &deviceInfo, pUserData); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_get_device_info__null(mal_context* pContext, mal_device_type deviceType, const mal_device_id* pDeviceID, mal_share_mode shareMode, mal_device_info* pDeviceInfo) @@ -5303,7 +5303,7 @@ mal_result mal_context_get_device_info__null(mal_context* pContext, mal_device_t (void)shareMode; if (pDeviceID != NULL && pDeviceID->nullbackend != 0) { - return MAL_NO_DEVICE; // Don't know the device. + return MA_NO_DEVICE; // Don't know the device. } // Name / Description @@ -5320,11 +5320,11 @@ mal_result mal_context_get_device_info__null(mal_context* pContext, mal_device_t } pDeviceInfo->minChannels = 1; - pDeviceInfo->maxChannels = MAL_MAX_CHANNELS; - pDeviceInfo->minSampleRate = MAL_SAMPLE_RATE_8000; - pDeviceInfo->maxSampleRate = MAL_SAMPLE_RATE_384000; + pDeviceInfo->maxChannels = MA_MAX_CHANNELS; + pDeviceInfo->minSampleRate = MA_SAMPLE_RATE_8000; + pDeviceInfo->maxSampleRate = MA_SAMPLE_RATE_384000; - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -5333,7 +5333,7 @@ void mal_device_uninit__null(mal_device* pDevice) mal_assert(pDevice != NULL); /* Keep it clean and wait for the device thread to finish before returning. */ - mal_device_do_operation__null(pDevice, MAL_DEVICE_OP_KILL__NULL); + mal_device_do_operation__null(pDevice, MA_DEVICE_OP_KILL__NULL); /* At this point the loop in the device thread is as good as terminated so we can uninitialize our events. */ mal_event_uninit(&pDevice->null_device.operationCompletionEvent); @@ -5378,46 +5378,46 @@ mal_result mal_device_init__null(mal_context* pContext, const mal_device_config* first period is "written" to it, and then stopped in mal_device_stop__null(). */ result = mal_event_init(pContext, &pDevice->null_device.operationEvent); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } result = mal_event_init(pContext, &pDevice->null_device.operationCompletionEvent); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } result = mal_thread_create(pContext, &pDevice->thread, mal_device_thread__null, pDevice); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_start__null(mal_device* pDevice) { mal_assert(pDevice != NULL); - mal_device_do_operation__null(pDevice, MAL_DEVICE_OP_START__NULL); + mal_device_do_operation__null(pDevice, MA_DEVICE_OP_START__NULL); - mal_atomic_exchange_32(&pDevice->null_device.isStarted, MAL_TRUE); - return MAL_SUCCESS; + mal_atomic_exchange_32(&pDevice->null_device.isStarted, MA_TRUE); + return MA_SUCCESS; } mal_result mal_device_stop__null(mal_device* pDevice) { mal_assert(pDevice != NULL); - mal_device_do_operation__null(pDevice, MAL_DEVICE_OP_SUSPEND__NULL); + mal_device_do_operation__null(pDevice, MA_DEVICE_OP_SUSPEND__NULL); - mal_atomic_exchange_32(&pDevice->null_device.isStarted, MAL_FALSE); - return MAL_SUCCESS; + mal_atomic_exchange_32(&pDevice->null_device.isStarted, MA_FALSE); + return MA_SUCCESS; } mal_result mal_device_write__null(mal_device* pDevice, const void* pPCMFrames, mal_uint32 frameCount) { - mal_result result = MAL_SUCCESS; + mal_result result = MA_SUCCESS; mal_uint32 totalPCMFramesProcessed; mal_bool32 wasStartedOnEntry; @@ -5447,7 +5447,7 @@ mal_result mal_device_write__null(mal_device* pDevice, const void* pPCMFrames, m if (!pDevice->null_device.isStarted && !wasStartedOnEntry) { result = mal_device_start__null(pDevice); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { break; } } @@ -5485,13 +5485,13 @@ mal_result mal_device_write__null(mal_device* pDevice, const void* pPCMFrames, m mal_result mal_device_read__null(mal_device* pDevice, void* pPCMFrames, mal_uint32 frameCount) { - mal_result result = MAL_SUCCESS; + mal_result result = MA_SUCCESS; mal_uint32 totalPCMFramesProcessed; /* The device needs to be started immediately. */ if (!pDevice->null_device.isStarted) { result = mal_device_start__null(pDevice); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } @@ -5556,7 +5556,7 @@ mal_result mal_context_uninit__null(mal_context* pContext) mal_assert(pContext->backend == mal_backend_null); (void)pContext; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_init__null(mal_context* pContext) @@ -5575,7 +5575,7 @@ mal_result mal_context_init__null(mal_context* pContext) pContext->onDeviceRead = mal_device_read__null; /* The null backend always works. */ - return MAL_SUCCESS; + return MA_SUCCESS; } #endif @@ -5585,13 +5585,13 @@ mal_result mal_context_init__null(mal_context* pContext) // WIN32 COMMON // /////////////////////////////////////////////////////////////////////////////// -#if defined(MAL_WIN32) -#if defined(MAL_WIN32_DESKTOP) - #define mal_CoInitializeEx(pContext, pvReserved, dwCoInit) ((MAL_PFN_CoInitializeEx)pContext->win32.CoInitializeEx)(pvReserved, dwCoInit) - #define mal_CoUninitialize(pContext) ((MAL_PFN_CoUninitialize)pContext->win32.CoUninitialize)() - #define mal_CoCreateInstance(pContext, rclsid, pUnkOuter, dwClsContext, riid, ppv) ((MAL_PFN_CoCreateInstance)pContext->win32.CoCreateInstance)(rclsid, pUnkOuter, dwClsContext, riid, ppv) - #define mal_CoTaskMemFree(pContext, pv) ((MAL_PFN_CoTaskMemFree)pContext->win32.CoTaskMemFree)(pv) - #define mal_PropVariantClear(pContext, pvar) ((MAL_PFN_PropVariantClear)pContext->win32.PropVariantClear)(pvar) +#if defined(MA_WIN32) +#if defined(MA_WIN32_DESKTOP) + #define mal_CoInitializeEx(pContext, pvReserved, dwCoInit) ((MA_PFN_CoInitializeEx)pContext->win32.CoInitializeEx)(pvReserved, dwCoInit) + #define mal_CoUninitialize(pContext) ((MA_PFN_CoUninitialize)pContext->win32.CoUninitialize)() + #define mal_CoCreateInstance(pContext, rclsid, pUnkOuter, dwClsContext, riid, ppv) ((MA_PFN_CoCreateInstance)pContext->win32.CoCreateInstance)(rclsid, pUnkOuter, dwClsContext, riid, ppv) + #define mal_CoTaskMemFree(pContext, pv) ((MA_PFN_CoTaskMemFree)pContext->win32.CoTaskMemFree)(pv) + #define mal_PropVariantClear(pContext, pvar) ((MA_PFN_PropVariantClear)pContext->win32.PropVariantClear)(pvar) #else #define mal_CoInitializeEx(pContext, pvReserved, dwCoInit) CoInitializeEx(pvReserved, dwCoInit) #define mal_CoUninitialize(pContext) CoUninitialize() @@ -5665,65 +5665,65 @@ typedef struct #define WAVE_FORMAT_IEEE_FLOAT 0x0003 #endif -GUID MAL_GUID_NULL = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; +GUID MA_GUID_NULL = {0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}}; // Converts an individual Win32-style channel identifier (SPEAKER_FRONT_LEFT, etc.) to miniaudio. mal_uint8 mal_channel_id_to_mal__win32(DWORD id) { switch (id) { - case SPEAKER_FRONT_LEFT: return MAL_CHANNEL_FRONT_LEFT; - case SPEAKER_FRONT_RIGHT: return MAL_CHANNEL_FRONT_RIGHT; - case SPEAKER_FRONT_CENTER: return MAL_CHANNEL_FRONT_CENTER; - case SPEAKER_LOW_FREQUENCY: return MAL_CHANNEL_LFE; - case SPEAKER_BACK_LEFT: return MAL_CHANNEL_BACK_LEFT; - case SPEAKER_BACK_RIGHT: return MAL_CHANNEL_BACK_RIGHT; - case SPEAKER_FRONT_LEFT_OF_CENTER: return MAL_CHANNEL_FRONT_LEFT_CENTER; - case SPEAKER_FRONT_RIGHT_OF_CENTER: return MAL_CHANNEL_FRONT_RIGHT_CENTER; - case SPEAKER_BACK_CENTER: return MAL_CHANNEL_BACK_CENTER; - case SPEAKER_SIDE_LEFT: return MAL_CHANNEL_SIDE_LEFT; - case SPEAKER_SIDE_RIGHT: return MAL_CHANNEL_SIDE_RIGHT; - case SPEAKER_TOP_CENTER: return MAL_CHANNEL_TOP_CENTER; - case SPEAKER_TOP_FRONT_LEFT: return MAL_CHANNEL_TOP_FRONT_LEFT; - case SPEAKER_TOP_FRONT_CENTER: return MAL_CHANNEL_TOP_FRONT_CENTER; - case SPEAKER_TOP_FRONT_RIGHT: return MAL_CHANNEL_TOP_FRONT_RIGHT; - case SPEAKER_TOP_BACK_LEFT: return MAL_CHANNEL_TOP_BACK_LEFT; - case SPEAKER_TOP_BACK_CENTER: return MAL_CHANNEL_TOP_BACK_CENTER; - case SPEAKER_TOP_BACK_RIGHT: return MAL_CHANNEL_TOP_BACK_RIGHT; + case SPEAKER_FRONT_LEFT: return MA_CHANNEL_FRONT_LEFT; + case SPEAKER_FRONT_RIGHT: return MA_CHANNEL_FRONT_RIGHT; + case SPEAKER_FRONT_CENTER: return MA_CHANNEL_FRONT_CENTER; + case SPEAKER_LOW_FREQUENCY: return MA_CHANNEL_LFE; + case SPEAKER_BACK_LEFT: return MA_CHANNEL_BACK_LEFT; + case SPEAKER_BACK_RIGHT: return MA_CHANNEL_BACK_RIGHT; + case SPEAKER_FRONT_LEFT_OF_CENTER: return MA_CHANNEL_FRONT_LEFT_CENTER; + case SPEAKER_FRONT_RIGHT_OF_CENTER: return MA_CHANNEL_FRONT_RIGHT_CENTER; + case SPEAKER_BACK_CENTER: return MA_CHANNEL_BACK_CENTER; + case SPEAKER_SIDE_LEFT: return MA_CHANNEL_SIDE_LEFT; + case SPEAKER_SIDE_RIGHT: return MA_CHANNEL_SIDE_RIGHT; + case SPEAKER_TOP_CENTER: return MA_CHANNEL_TOP_CENTER; + case SPEAKER_TOP_FRONT_LEFT: return MA_CHANNEL_TOP_FRONT_LEFT; + case SPEAKER_TOP_FRONT_CENTER: return MA_CHANNEL_TOP_FRONT_CENTER; + case SPEAKER_TOP_FRONT_RIGHT: return MA_CHANNEL_TOP_FRONT_RIGHT; + case SPEAKER_TOP_BACK_LEFT: return MA_CHANNEL_TOP_BACK_LEFT; + case SPEAKER_TOP_BACK_CENTER: return MA_CHANNEL_TOP_BACK_CENTER; + case SPEAKER_TOP_BACK_RIGHT: return MA_CHANNEL_TOP_BACK_RIGHT; default: return 0; } } -// Converts an individual miniaudio channel identifier (MAL_CHANNEL_FRONT_LEFT, etc.) to Win32-style. +// Converts an individual miniaudio channel identifier (MA_CHANNEL_FRONT_LEFT, etc.) to Win32-style. DWORD mal_channel_id_to_win32(DWORD id) { switch (id) { - case MAL_CHANNEL_MONO: return SPEAKER_FRONT_CENTER; - case MAL_CHANNEL_FRONT_LEFT: return SPEAKER_FRONT_LEFT; - case MAL_CHANNEL_FRONT_RIGHT: return SPEAKER_FRONT_RIGHT; - case MAL_CHANNEL_FRONT_CENTER: return SPEAKER_FRONT_CENTER; - case MAL_CHANNEL_LFE: return SPEAKER_LOW_FREQUENCY; - case MAL_CHANNEL_BACK_LEFT: return SPEAKER_BACK_LEFT; - case MAL_CHANNEL_BACK_RIGHT: return SPEAKER_BACK_RIGHT; - case MAL_CHANNEL_FRONT_LEFT_CENTER: return SPEAKER_FRONT_LEFT_OF_CENTER; - case MAL_CHANNEL_FRONT_RIGHT_CENTER: return SPEAKER_FRONT_RIGHT_OF_CENTER; - case MAL_CHANNEL_BACK_CENTER: return SPEAKER_BACK_CENTER; - case MAL_CHANNEL_SIDE_LEFT: return SPEAKER_SIDE_LEFT; - case MAL_CHANNEL_SIDE_RIGHT: return SPEAKER_SIDE_RIGHT; - case MAL_CHANNEL_TOP_CENTER: return SPEAKER_TOP_CENTER; - case MAL_CHANNEL_TOP_FRONT_LEFT: return SPEAKER_TOP_FRONT_LEFT; - case MAL_CHANNEL_TOP_FRONT_CENTER: return SPEAKER_TOP_FRONT_CENTER; - case MAL_CHANNEL_TOP_FRONT_RIGHT: return SPEAKER_TOP_FRONT_RIGHT; - case MAL_CHANNEL_TOP_BACK_LEFT: return SPEAKER_TOP_BACK_LEFT; - case MAL_CHANNEL_TOP_BACK_CENTER: return SPEAKER_TOP_BACK_CENTER; - case MAL_CHANNEL_TOP_BACK_RIGHT: return SPEAKER_TOP_BACK_RIGHT; + case MA_CHANNEL_MONO: return SPEAKER_FRONT_CENTER; + case MA_CHANNEL_FRONT_LEFT: return SPEAKER_FRONT_LEFT; + case MA_CHANNEL_FRONT_RIGHT: return SPEAKER_FRONT_RIGHT; + case MA_CHANNEL_FRONT_CENTER: return SPEAKER_FRONT_CENTER; + case MA_CHANNEL_LFE: return SPEAKER_LOW_FREQUENCY; + case MA_CHANNEL_BACK_LEFT: return SPEAKER_BACK_LEFT; + case MA_CHANNEL_BACK_RIGHT: return SPEAKER_BACK_RIGHT; + case MA_CHANNEL_FRONT_LEFT_CENTER: return SPEAKER_FRONT_LEFT_OF_CENTER; + case MA_CHANNEL_FRONT_RIGHT_CENTER: return SPEAKER_FRONT_RIGHT_OF_CENTER; + case MA_CHANNEL_BACK_CENTER: return SPEAKER_BACK_CENTER; + case MA_CHANNEL_SIDE_LEFT: return SPEAKER_SIDE_LEFT; + case MA_CHANNEL_SIDE_RIGHT: return SPEAKER_SIDE_RIGHT; + case MA_CHANNEL_TOP_CENTER: return SPEAKER_TOP_CENTER; + case MA_CHANNEL_TOP_FRONT_LEFT: return SPEAKER_TOP_FRONT_LEFT; + case MA_CHANNEL_TOP_FRONT_CENTER: return SPEAKER_TOP_FRONT_CENTER; + case MA_CHANNEL_TOP_FRONT_RIGHT: return SPEAKER_TOP_FRONT_RIGHT; + case MA_CHANNEL_TOP_BACK_LEFT: return SPEAKER_TOP_BACK_LEFT; + case MA_CHANNEL_TOP_BACK_CENTER: return SPEAKER_TOP_BACK_CENTER; + case MA_CHANNEL_TOP_BACK_RIGHT: return SPEAKER_TOP_BACK_RIGHT; default: return 0; } } // Converts a channel mapping to a Win32-style channel mask. -DWORD mal_channel_map_to_channel_mask__win32(const mal_channel channelMap[MAL_MAX_CHANNELS], mal_uint32 channels) +DWORD mal_channel_map_to_channel_mask__win32(const mal_channel channelMap[MA_MAX_CHANNELS], mal_uint32 channels) { DWORD dwChannelMask = 0; for (mal_uint32 iChannel = 0; iChannel < channels; ++iChannel) { @@ -5734,16 +5734,16 @@ DWORD mal_channel_map_to_channel_mask__win32(const mal_channel channelMap[MAL_MA } // Converts a Win32-style channel mask to a miniaudio channel map. -void mal_channel_mask_to_channel_map__win32(DWORD dwChannelMask, mal_uint32 channels, mal_channel channelMap[MAL_MAX_CHANNELS]) +void mal_channel_mask_to_channel_map__win32(DWORD dwChannelMask, mal_uint32 channels, mal_channel channelMap[MA_MAX_CHANNELS]) { if (channels == 1 && dwChannelMask == 0) { - channelMap[0] = MAL_CHANNEL_MONO; + channelMap[0] = MA_CHANNEL_MONO; } else if (channels == 2 && dwChannelMask == 0) { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; } else { if (channels == 1 && (dwChannelMask & SPEAKER_FRONT_CENTER) != 0) { - channelMap[0] = MAL_CHANNEL_MONO; + channelMap[0] = MA_CHANNEL_MONO; } else { // Just iterate over each bit. mal_uint32 iChannel = 0; @@ -5774,7 +5774,7 @@ mal_format mal_format_from_WAVEFORMATEX(const WAVEFORMATEX* pWF) if (pWF->wFormatTag == WAVE_FORMAT_EXTENSIBLE) { const WAVEFORMATEXTENSIBLE* pWFEX = (const WAVEFORMATEXTENSIBLE*)pWF; - if (mal_is_guid_equal(&pWFEX->SubFormat, &MAL_GUID_KSDATAFORMAT_SUBTYPE_PCM)) { + if (mal_is_guid_equal(&pWFEX->SubFormat, &MA_GUID_KSDATAFORMAT_SUBTYPE_PCM)) { if (pWFEX->Samples.wValidBitsPerSample == 32) { return mal_format_s32; } @@ -5793,7 +5793,7 @@ mal_format mal_format_from_WAVEFORMATEX(const WAVEFORMATEX* pWF) return mal_format_u8; } } - if (mal_is_guid_equal(&pWFEX->SubFormat, &MAL_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)) { + if (mal_is_guid_equal(&pWFEX->SubFormat, &MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)) { if (pWFEX->Samples.wValidBitsPerSample == 32) { return mal_format_f32; } @@ -5836,7 +5836,7 @@ mal_format mal_format_from_WAVEFORMATEX(const WAVEFORMATEX* pWF) // WASAPI Backend // /////////////////////////////////////////////////////////////////////////////// -#ifdef MAL_HAS_WASAPI +#ifdef MA_HAS_WASAPI //#if defined(_MSC_VER) // #pragma warning(push) // #pragma warning(disable:4091) // 'typedef ': ignored on left of '' when no variable is declared @@ -5887,46 +5887,46 @@ typedef struct #endif // Some compilers don't define PropVariantInit(). We just do this ourselves since it's just a memset(). -static MAL_INLINE void mal_PropVariantInit(PROPVARIANT* pProp) +static MA_INLINE void mal_PropVariantInit(PROPVARIANT* pProp) { mal_zero_object(pProp); } -const PROPERTYKEY MAL_PKEY_Device_FriendlyName = {{0xA45C254E, 0xDF1C, 0x4EFD, {0x80, 0x20, 0x67, 0xD1, 0x46, 0xA8, 0x50, 0xE0}}, 14}; -const PROPERTYKEY MAL_PKEY_AudioEngine_DeviceFormat = {{0xF19F064D, 0x82C, 0x4E27, {0xBC, 0x73, 0x68, 0x82, 0xA1, 0xBB, 0x8E, 0x4C}}, 0}; +const PROPERTYKEY MA_PKEY_Device_FriendlyName = {{0xA45C254E, 0xDF1C, 0x4EFD, {0x80, 0x20, 0x67, 0xD1, 0x46, 0xA8, 0x50, 0xE0}}, 14}; +const PROPERTYKEY MA_PKEY_AudioEngine_DeviceFormat = {{0xF19F064D, 0x82C, 0x4E27, {0xBC, 0x73, 0x68, 0x82, 0xA1, 0xBB, 0x8E, 0x4C}}, 0}; -const IID MAL_IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; // 00000000-0000-0000-C000-000000000046 -const IID MAL_IID_IAgileObject = {0x94EA2B94, 0xE9CC, 0x49E0, {0xC0, 0xFF, 0xEE, 0x64, 0xCA, 0x8F, 0x5B, 0x90}}; // 94EA2B94-E9CC-49E0-C0FF-EE64CA8F5B90 +const IID MA_IID_IUnknown = {0x00000000, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}; // 00000000-0000-0000-C000-000000000046 +const IID MA_IID_IAgileObject = {0x94EA2B94, 0xE9CC, 0x49E0, {0xC0, 0xFF, 0xEE, 0x64, 0xCA, 0x8F, 0x5B, 0x90}}; // 94EA2B94-E9CC-49E0-C0FF-EE64CA8F5B90 -const IID MAL_IID_IAudioClient = {0x1CB9AD4C, 0xDBFA, 0x4C32, {0xB1, 0x78, 0xC2, 0xF5, 0x68, 0xA7, 0x03, 0xB2}}; // 1CB9AD4C-DBFA-4C32-B178-C2F568A703B2 = __uuidof(IAudioClient) -const IID MAL_IID_IAudioClient2 = {0x726778CD, 0xF60A, 0x4EDA, {0x82, 0xDE, 0xE4, 0x76, 0x10, 0xCD, 0x78, 0xAA}}; // 726778CD-F60A-4EDA-82DE-E47610CD78AA = __uuidof(IAudioClient2) -const IID MAL_IID_IAudioClient3 = {0x7ED4EE07, 0x8E67, 0x4CD4, {0x8C, 0x1A, 0x2B, 0x7A, 0x59, 0x87, 0xAD, 0x42}}; // 7ED4EE07-8E67-4CD4-8C1A-2B7A5987AD42 = __uuidof(IAudioClient3) -const IID MAL_IID_IAudioRenderClient = {0xF294ACFC, 0x3146, 0x4483, {0xA7, 0xBF, 0xAD, 0xDC, 0xA7, 0xC2, 0x60, 0xE2}}; // F294ACFC-3146-4483-A7BF-ADDCA7C260E2 = __uuidof(IAudioRenderClient) -const IID MAL_IID_IAudioCaptureClient = {0xC8ADBD64, 0xE71E, 0x48A0, {0xA4, 0xDE, 0x18, 0x5C, 0x39, 0x5C, 0xD3, 0x17}}; // C8ADBD64-E71E-48A0-A4DE-185C395CD317 = __uuidof(IAudioCaptureClient) -const IID MAL_IID_IMMNotificationClient = {0x7991EEC9, 0x7E89, 0x4D85, {0x83, 0x90, 0x6C, 0x70, 0x3C, 0xEC, 0x60, 0xC0}}; // 7991EEC9-7E89-4D85-8390-6C703CEC60C0 = __uuidof(IMMNotificationClient) -#ifndef MAL_WIN32_DESKTOP -const IID MAL_IID_DEVINTERFACE_AUDIO_RENDER = {0xE6327CAD, 0xDCEC, 0x4949, {0xAE, 0x8A, 0x99, 0x1E, 0x97, 0x6A, 0x79, 0xD2}}; // E6327CAD-DCEC-4949-AE8A-991E976A79D2 -const IID MAL_IID_DEVINTERFACE_AUDIO_CAPTURE = {0x2EEF81BE, 0x33FA, 0x4800, {0x96, 0x70, 0x1C, 0xD4, 0x74, 0x97, 0x2C, 0x3F}}; // 2EEF81BE-33FA-4800-9670-1CD474972C3F -const IID MAL_IID_IActivateAudioInterfaceCompletionHandler = {0x41D949AB, 0x9862, 0x444A, {0x80, 0xF6, 0xC2, 0x61, 0x33, 0x4D, 0xA5, 0xEB}}; // 41D949AB-9862-444A-80F6-C261334DA5EB +const IID MA_IID_IAudioClient = {0x1CB9AD4C, 0xDBFA, 0x4C32, {0xB1, 0x78, 0xC2, 0xF5, 0x68, 0xA7, 0x03, 0xB2}}; // 1CB9AD4C-DBFA-4C32-B178-C2F568A703B2 = __uuidof(IAudioClient) +const IID MA_IID_IAudioClient2 = {0x726778CD, 0xF60A, 0x4EDA, {0x82, 0xDE, 0xE4, 0x76, 0x10, 0xCD, 0x78, 0xAA}}; // 726778CD-F60A-4EDA-82DE-E47610CD78AA = __uuidof(IAudioClient2) +const IID MA_IID_IAudioClient3 = {0x7ED4EE07, 0x8E67, 0x4CD4, {0x8C, 0x1A, 0x2B, 0x7A, 0x59, 0x87, 0xAD, 0x42}}; // 7ED4EE07-8E67-4CD4-8C1A-2B7A5987AD42 = __uuidof(IAudioClient3) +const IID MA_IID_IAudioRenderClient = {0xF294ACFC, 0x3146, 0x4483, {0xA7, 0xBF, 0xAD, 0xDC, 0xA7, 0xC2, 0x60, 0xE2}}; // F294ACFC-3146-4483-A7BF-ADDCA7C260E2 = __uuidof(IAudioRenderClient) +const IID MA_IID_IAudioCaptureClient = {0xC8ADBD64, 0xE71E, 0x48A0, {0xA4, 0xDE, 0x18, 0x5C, 0x39, 0x5C, 0xD3, 0x17}}; // C8ADBD64-E71E-48A0-A4DE-185C395CD317 = __uuidof(IAudioCaptureClient) +const IID MA_IID_IMMNotificationClient = {0x7991EEC9, 0x7E89, 0x4D85, {0x83, 0x90, 0x6C, 0x70, 0x3C, 0xEC, 0x60, 0xC0}}; // 7991EEC9-7E89-4D85-8390-6C703CEC60C0 = __uuidof(IMMNotificationClient) +#ifndef MA_WIN32_DESKTOP +const IID MA_IID_DEVINTERFACE_AUDIO_RENDER = {0xE6327CAD, 0xDCEC, 0x4949, {0xAE, 0x8A, 0x99, 0x1E, 0x97, 0x6A, 0x79, 0xD2}}; // E6327CAD-DCEC-4949-AE8A-991E976A79D2 +const IID MA_IID_DEVINTERFACE_AUDIO_CAPTURE = {0x2EEF81BE, 0x33FA, 0x4800, {0x96, 0x70, 0x1C, 0xD4, 0x74, 0x97, 0x2C, 0x3F}}; // 2EEF81BE-33FA-4800-9670-1CD474972C3F +const IID MA_IID_IActivateAudioInterfaceCompletionHandler = {0x41D949AB, 0x9862, 0x444A, {0x80, 0xF6, 0xC2, 0x61, 0x33, 0x4D, 0xA5, 0xEB}}; // 41D949AB-9862-444A-80F6-C261334DA5EB #endif -const IID MAL_CLSID_MMDeviceEnumerator_Instance = {0xBCDE0395, 0xE52F, 0x467C, {0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E}}; // BCDE0395-E52F-467C-8E3D-C4579291692E = __uuidof(MMDeviceEnumerator) -const IID MAL_IID_IMMDeviceEnumerator_Instance = {0xA95664D2, 0x9614, 0x4F35, {0xA7, 0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6}}; // A95664D2-9614-4F35-A746-DE8DB63617E6 = __uuidof(IMMDeviceEnumerator) +const IID MA_CLSID_MMDeviceEnumerator_Instance = {0xBCDE0395, 0xE52F, 0x467C, {0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E}}; // BCDE0395-E52F-467C-8E3D-C4579291692E = __uuidof(MMDeviceEnumerator) +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 MAL_CLSID_MMDeviceEnumerator MAL_CLSID_MMDeviceEnumerator_Instance -#define MAL_IID_IMMDeviceEnumerator MAL_IID_IMMDeviceEnumerator_Instance +#define MA_CLSID_MMDeviceEnumerator MA_CLSID_MMDeviceEnumerator_Instance +#define MA_IID_IMMDeviceEnumerator MA_IID_IMMDeviceEnumerator_Instance #else -#define MAL_CLSID_MMDeviceEnumerator &MAL_CLSID_MMDeviceEnumerator_Instance -#define MAL_IID_IMMDeviceEnumerator &MAL_IID_IMMDeviceEnumerator_Instance +#define MA_CLSID_MMDeviceEnumerator &MA_CLSID_MMDeviceEnumerator_Instance +#define MA_IID_IMMDeviceEnumerator &MA_IID_IMMDeviceEnumerator_Instance #endif typedef struct mal_IUnknown mal_IUnknown; -#ifdef MAL_WIN32_DESKTOP -#define MAL_MM_DEVICE_STATE_ACTIVE 1 -#define MAL_MM_DEVICE_STATE_DISABLED 2 -#define MAL_MM_DEVICE_STATE_NOTPRESENT 4 -#define MAL_MM_DEVICE_STATE_UNPLUGGED 8 +#ifdef MA_WIN32_DESKTOP +#define MA_MM_DEVICE_STATE_ACTIVE 1 +#define MA_MM_DEVICE_STATE_DISABLED 2 +#define MA_MM_DEVICE_STATE_NOTPRESENT 4 +#define MA_MM_DEVICE_STATE_UNPLUGGED 8 typedef struct mal_IMMDeviceEnumerator mal_IMMDeviceEnumerator; typedef struct mal_IMMDeviceCollection mal_IMMDeviceCollection; @@ -5942,24 +5942,24 @@ typedef struct mal_IAudioClient3 mal_IAudioClient3; typedef struct mal_IAudioRenderClient mal_IAudioRenderClient; typedef struct mal_IAudioCaptureClient mal_IAudioCaptureClient; -typedef mal_int64 MAL_REFERENCE_TIME; +typedef mal_int64 MA_REFERENCE_TIME; -#define MAL_AUDCLNT_STREAMFLAGS_CROSSPROCESS 0x00010000 -#define MAL_AUDCLNT_STREAMFLAGS_LOOPBACK 0x00020000 -#define MAL_AUDCLNT_STREAMFLAGS_EVENTCALLBACK 0x00040000 -#define MAL_AUDCLNT_STREAMFLAGS_NOPERSIST 0x00080000 -#define MAL_AUDCLNT_STREAMFLAGS_RATEADJUST 0x00100000 -#define MAL_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY 0x08000000 -#define MAL_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM 0x80000000 -#define MAL_AUDCLNT_SESSIONFLAGS_EXPIREWHENUNOWNED 0x10000000 -#define MAL_AUDCLNT_SESSIONFLAGS_DISPLAY_HIDE 0x20000000 -#define MAL_AUDCLNT_SESSIONFLAGS_DISPLAY_HIDEWHENEXPIRED 0x40000000 +#define MA_AUDCLNT_STREAMFLAGS_CROSSPROCESS 0x00010000 +#define MA_AUDCLNT_STREAMFLAGS_LOOPBACK 0x00020000 +#define MA_AUDCLNT_STREAMFLAGS_EVENTCALLBACK 0x00040000 +#define MA_AUDCLNT_STREAMFLAGS_NOPERSIST 0x00080000 +#define MA_AUDCLNT_STREAMFLAGS_RATEADJUST 0x00100000 +#define MA_AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY 0x08000000 +#define MA_AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM 0x80000000 +#define MA_AUDCLNT_SESSIONFLAGS_EXPIREWHENUNOWNED 0x10000000 +#define MA_AUDCLNT_SESSIONFLAGS_DISPLAY_HIDE 0x20000000 +#define MA_AUDCLNT_SESSIONFLAGS_DISPLAY_HIDEWHENEXPIRED 0x40000000 // We only care about a few error codes. -#define MAL_AUDCLNT_E_INVALID_DEVICE_PERIOD (-2004287456) -#define MAL_AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED (-2004287463) -#define MAL_AUDCLNT_S_BUFFER_EMPTY (143196161) -#define MAL_AUDCLNT_E_DEVICE_IN_USE (-2004287478) +#define MA_AUDCLNT_E_INVALID_DEVICE_PERIOD (-2004287456) +#define MA_AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED (-2004287463) +#define MA_AUDCLNT_S_BUFFER_EMPTY (143196161) +#define MA_AUDCLNT_E_DEVICE_IN_USE (-2004287478) typedef enum { @@ -5977,20 +5977,20 @@ typedef enum typedef enum { - MAL_AUDCLNT_SHAREMODE_SHARED, - MAL_AUDCLNT_SHAREMODE_EXCLUSIVE -} MAL_AUDCLNT_SHAREMODE; + MA_AUDCLNT_SHAREMODE_SHARED, + MA_AUDCLNT_SHAREMODE_EXCLUSIVE +} MA_AUDCLNT_SHAREMODE; typedef enum { - MAL_AudioCategory_Other = 0, // <-- miniaudio is only caring about Other. -} MAL_AUDIO_STREAM_CATEGORY; + MA_AudioCategory_Other = 0, // <-- miniaudio is only caring about Other. +} MA_AUDIO_STREAM_CATEGORY; typedef struct { UINT32 cbSize; BOOL bIsOffload; - MAL_AUDIO_STREAM_CATEGORY eCategory; + MA_AUDIO_STREAM_CATEGORY eCategory; } mal_AudioClientProperties; // IUnknown @@ -6009,7 +6009,7 @@ HRESULT mal_IUnknown_QueryInterface(mal_IUnknown* pThis, const IID* const riid, ULONG mal_IUnknown_AddRef(mal_IUnknown* pThis) { return pThis->lpVtbl->AddRef(pThis); } ULONG mal_IUnknown_Release(mal_IUnknown* pThis) { return pThis->lpVtbl->Release(pThis); } -#ifdef MAL_WIN32_DESKTOP +#ifdef MA_WIN32_DESKTOP // IMMNotificationClient typedef struct { @@ -6163,13 +6163,13 @@ typedef struct ULONG (STDMETHODCALLTYPE * Release) (mal_IAudioClient* pThis); // IAudioClient - HRESULT (STDMETHODCALLTYPE * Initialize) (mal_IAudioClient* pThis, MAL_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MAL_REFERENCE_TIME bufferDuration, MAL_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid); + HRESULT (STDMETHODCALLTYPE * Initialize) (mal_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid); HRESULT (STDMETHODCALLTYPE * GetBufferSize) (mal_IAudioClient* pThis, mal_uint32* pNumBufferFrames); - HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (mal_IAudioClient* pThis, MAL_REFERENCE_TIME* pLatency); + HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (mal_IAudioClient* pThis, MA_REFERENCE_TIME* pLatency); HRESULT (STDMETHODCALLTYPE * GetCurrentPadding)(mal_IAudioClient* pThis, mal_uint32* pNumPaddingFrames); - HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(mal_IAudioClient* pThis, MAL_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch); + HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(mal_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch); HRESULT (STDMETHODCALLTYPE * GetMixFormat) (mal_IAudioClient* pThis, WAVEFORMATEX** ppDeviceFormat); - HRESULT (STDMETHODCALLTYPE * GetDevicePeriod) (mal_IAudioClient* pThis, MAL_REFERENCE_TIME* pDefaultDevicePeriod, MAL_REFERENCE_TIME* pMinimumDevicePeriod); + HRESULT (STDMETHODCALLTYPE * GetDevicePeriod) (mal_IAudioClient* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod); HRESULT (STDMETHODCALLTYPE * Start) (mal_IAudioClient* pThis); HRESULT (STDMETHODCALLTYPE * Stop) (mal_IAudioClient* pThis); HRESULT (STDMETHODCALLTYPE * Reset) (mal_IAudioClient* pThis); @@ -6183,13 +6183,13 @@ struct mal_IAudioClient HRESULT mal_IAudioClient_QueryInterface(mal_IAudioClient* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } ULONG mal_IAudioClient_AddRef(mal_IAudioClient* pThis) { return pThis->lpVtbl->AddRef(pThis); } ULONG mal_IAudioClient_Release(mal_IAudioClient* pThis) { return pThis->lpVtbl->Release(pThis); } -HRESULT mal_IAudioClient_Initialize(mal_IAudioClient* pThis, MAL_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MAL_REFERENCE_TIME bufferDuration, MAL_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); } +HRESULT mal_IAudioClient_Initialize(mal_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); } HRESULT mal_IAudioClient_GetBufferSize(mal_IAudioClient* pThis, mal_uint32* pNumBufferFrames) { return pThis->lpVtbl->GetBufferSize(pThis, pNumBufferFrames); } -HRESULT mal_IAudioClient_GetStreamLatency(mal_IAudioClient* pThis, MAL_REFERENCE_TIME* pLatency) { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); } +HRESULT mal_IAudioClient_GetStreamLatency(mal_IAudioClient* pThis, MA_REFERENCE_TIME* pLatency) { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); } HRESULT mal_IAudioClient_GetCurrentPadding(mal_IAudioClient* pThis, mal_uint32* pNumPaddingFrames) { return pThis->lpVtbl->GetCurrentPadding(pThis, pNumPaddingFrames); } -HRESULT mal_IAudioClient_IsFormatSupported(mal_IAudioClient* pThis, MAL_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); } +HRESULT mal_IAudioClient_IsFormatSupported(mal_IAudioClient* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); } HRESULT mal_IAudioClient_GetMixFormat(mal_IAudioClient* pThis, WAVEFORMATEX** ppDeviceFormat) { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); } -HRESULT mal_IAudioClient_GetDevicePeriod(mal_IAudioClient* pThis, MAL_REFERENCE_TIME* pDefaultDevicePeriod, MAL_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); } +HRESULT mal_IAudioClient_GetDevicePeriod(mal_IAudioClient* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); } HRESULT mal_IAudioClient_Start(mal_IAudioClient* pThis) { return pThis->lpVtbl->Start(pThis); } HRESULT mal_IAudioClient_Stop(mal_IAudioClient* pThis) { return pThis->lpVtbl->Stop(pThis); } HRESULT mal_IAudioClient_Reset(mal_IAudioClient* pThis) { return pThis->lpVtbl->Reset(pThis); } @@ -6205,13 +6205,13 @@ typedef struct ULONG (STDMETHODCALLTYPE * Release) (mal_IAudioClient2* pThis); // IAudioClient - HRESULT (STDMETHODCALLTYPE * Initialize) (mal_IAudioClient2* pThis, MAL_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MAL_REFERENCE_TIME bufferDuration, MAL_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid); + HRESULT (STDMETHODCALLTYPE * Initialize) (mal_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid); HRESULT (STDMETHODCALLTYPE * GetBufferSize) (mal_IAudioClient2* pThis, mal_uint32* pNumBufferFrames); - HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (mal_IAudioClient2* pThis, MAL_REFERENCE_TIME* pLatency); + HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (mal_IAudioClient2* pThis, MA_REFERENCE_TIME* pLatency); HRESULT (STDMETHODCALLTYPE * GetCurrentPadding)(mal_IAudioClient2* pThis, mal_uint32* pNumPaddingFrames); - HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(mal_IAudioClient2* pThis, MAL_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch); + HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(mal_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch); HRESULT (STDMETHODCALLTYPE * GetMixFormat) (mal_IAudioClient2* pThis, WAVEFORMATEX** ppDeviceFormat); - HRESULT (STDMETHODCALLTYPE * GetDevicePeriod) (mal_IAudioClient2* pThis, MAL_REFERENCE_TIME* pDefaultDevicePeriod, MAL_REFERENCE_TIME* pMinimumDevicePeriod); + HRESULT (STDMETHODCALLTYPE * GetDevicePeriod) (mal_IAudioClient2* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod); HRESULT (STDMETHODCALLTYPE * Start) (mal_IAudioClient2* pThis); HRESULT (STDMETHODCALLTYPE * Stop) (mal_IAudioClient2* pThis); HRESULT (STDMETHODCALLTYPE * Reset) (mal_IAudioClient2* pThis); @@ -6219,9 +6219,9 @@ typedef struct HRESULT (STDMETHODCALLTYPE * GetService) (mal_IAudioClient2* pThis, const IID* const riid, void** pp); // IAudioClient2 - HRESULT (STDMETHODCALLTYPE * IsOffloadCapable) (mal_IAudioClient2* pThis, MAL_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable); + HRESULT (STDMETHODCALLTYPE * IsOffloadCapable) (mal_IAudioClient2* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable); HRESULT (STDMETHODCALLTYPE * SetClientProperties)(mal_IAudioClient2* pThis, const mal_AudioClientProperties* pProperties); - HRESULT (STDMETHODCALLTYPE * GetBufferSizeLimits)(mal_IAudioClient2* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MAL_REFERENCE_TIME* pMinBufferDuration, MAL_REFERENCE_TIME* pMaxBufferDuration); + HRESULT (STDMETHODCALLTYPE * GetBufferSizeLimits)(mal_IAudioClient2* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration); } mal_IAudioClient2Vtbl; struct mal_IAudioClient2 { @@ -6230,21 +6230,21 @@ struct mal_IAudioClient2 HRESULT mal_IAudioClient2_QueryInterface(mal_IAudioClient2* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } ULONG mal_IAudioClient2_AddRef(mal_IAudioClient2* pThis) { return pThis->lpVtbl->AddRef(pThis); } ULONG mal_IAudioClient2_Release(mal_IAudioClient2* pThis) { return pThis->lpVtbl->Release(pThis); } -HRESULT mal_IAudioClient2_Initialize(mal_IAudioClient2* pThis, MAL_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MAL_REFERENCE_TIME bufferDuration, MAL_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); } +HRESULT mal_IAudioClient2_Initialize(mal_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); } HRESULT mal_IAudioClient2_GetBufferSize(mal_IAudioClient2* pThis, mal_uint32* pNumBufferFrames) { return pThis->lpVtbl->GetBufferSize(pThis, pNumBufferFrames); } -HRESULT mal_IAudioClient2_GetStreamLatency(mal_IAudioClient2* pThis, MAL_REFERENCE_TIME* pLatency) { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); } +HRESULT mal_IAudioClient2_GetStreamLatency(mal_IAudioClient2* pThis, MA_REFERENCE_TIME* pLatency) { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); } HRESULT mal_IAudioClient2_GetCurrentPadding(mal_IAudioClient2* pThis, mal_uint32* pNumPaddingFrames) { return pThis->lpVtbl->GetCurrentPadding(pThis, pNumPaddingFrames); } -HRESULT mal_IAudioClient2_IsFormatSupported(mal_IAudioClient2* pThis, MAL_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); } +HRESULT mal_IAudioClient2_IsFormatSupported(mal_IAudioClient2* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); } HRESULT mal_IAudioClient2_GetMixFormat(mal_IAudioClient2* pThis, WAVEFORMATEX** ppDeviceFormat) { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); } -HRESULT mal_IAudioClient2_GetDevicePeriod(mal_IAudioClient2* pThis, MAL_REFERENCE_TIME* pDefaultDevicePeriod, MAL_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); } +HRESULT mal_IAudioClient2_GetDevicePeriod(mal_IAudioClient2* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); } HRESULT mal_IAudioClient2_Start(mal_IAudioClient2* pThis) { return pThis->lpVtbl->Start(pThis); } HRESULT mal_IAudioClient2_Stop(mal_IAudioClient2* pThis) { return pThis->lpVtbl->Stop(pThis); } HRESULT mal_IAudioClient2_Reset(mal_IAudioClient2* pThis) { return pThis->lpVtbl->Reset(pThis); } HRESULT mal_IAudioClient2_SetEventHandle(mal_IAudioClient2* pThis, HANDLE eventHandle) { return pThis->lpVtbl->SetEventHandle(pThis, eventHandle); } HRESULT mal_IAudioClient2_GetService(mal_IAudioClient2* pThis, const IID* const riid, void** pp) { return pThis->lpVtbl->GetService(pThis, riid, pp); } -HRESULT mal_IAudioClient2_IsOffloadCapable(mal_IAudioClient2* pThis, MAL_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable) { return pThis->lpVtbl->IsOffloadCapable(pThis, category, pOffloadCapable); } +HRESULT mal_IAudioClient2_IsOffloadCapable(mal_IAudioClient2* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable) { return pThis->lpVtbl->IsOffloadCapable(pThis, category, pOffloadCapable); } HRESULT mal_IAudioClient2_SetClientProperties(mal_IAudioClient2* pThis, const mal_AudioClientProperties* pProperties) { return pThis->lpVtbl->SetClientProperties(pThis, pProperties); } -HRESULT mal_IAudioClient2_GetBufferSizeLimits(mal_IAudioClient2* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MAL_REFERENCE_TIME* pMinBufferDuration, MAL_REFERENCE_TIME* pMaxBufferDuration) { return pThis->lpVtbl->GetBufferSizeLimits(pThis, pFormat, eventDriven, pMinBufferDuration, pMaxBufferDuration); } +HRESULT mal_IAudioClient2_GetBufferSizeLimits(mal_IAudioClient2* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration) { return pThis->lpVtbl->GetBufferSizeLimits(pThis, pFormat, eventDriven, pMinBufferDuration, pMaxBufferDuration); } // IAudioClient3 @@ -6256,13 +6256,13 @@ typedef struct ULONG (STDMETHODCALLTYPE * Release) (mal_IAudioClient3* pThis); // IAudioClient - HRESULT (STDMETHODCALLTYPE * Initialize) (mal_IAudioClient3* pThis, MAL_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MAL_REFERENCE_TIME bufferDuration, MAL_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid); + HRESULT (STDMETHODCALLTYPE * Initialize) (mal_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid); HRESULT (STDMETHODCALLTYPE * GetBufferSize) (mal_IAudioClient3* pThis, mal_uint32* pNumBufferFrames); - HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (mal_IAudioClient3* pThis, MAL_REFERENCE_TIME* pLatency); + HRESULT (STDMETHODCALLTYPE * GetStreamLatency) (mal_IAudioClient3* pThis, MA_REFERENCE_TIME* pLatency); HRESULT (STDMETHODCALLTYPE * GetCurrentPadding)(mal_IAudioClient3* pThis, mal_uint32* pNumPaddingFrames); - HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(mal_IAudioClient3* pThis, MAL_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch); + HRESULT (STDMETHODCALLTYPE * IsFormatSupported)(mal_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch); HRESULT (STDMETHODCALLTYPE * GetMixFormat) (mal_IAudioClient3* pThis, WAVEFORMATEX** ppDeviceFormat); - HRESULT (STDMETHODCALLTYPE * GetDevicePeriod) (mal_IAudioClient3* pThis, MAL_REFERENCE_TIME* pDefaultDevicePeriod, MAL_REFERENCE_TIME* pMinimumDevicePeriod); + HRESULT (STDMETHODCALLTYPE * GetDevicePeriod) (mal_IAudioClient3* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod); HRESULT (STDMETHODCALLTYPE * Start) (mal_IAudioClient3* pThis); HRESULT (STDMETHODCALLTYPE * Stop) (mal_IAudioClient3* pThis); HRESULT (STDMETHODCALLTYPE * Reset) (mal_IAudioClient3* pThis); @@ -6270,9 +6270,9 @@ typedef struct HRESULT (STDMETHODCALLTYPE * GetService) (mal_IAudioClient3* pThis, const IID* const riid, void** pp); // IAudioClient2 - HRESULT (STDMETHODCALLTYPE * IsOffloadCapable) (mal_IAudioClient3* pThis, MAL_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable); + HRESULT (STDMETHODCALLTYPE * IsOffloadCapable) (mal_IAudioClient3* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable); HRESULT (STDMETHODCALLTYPE * SetClientProperties)(mal_IAudioClient3* pThis, const mal_AudioClientProperties* pProperties); - HRESULT (STDMETHODCALLTYPE * GetBufferSizeLimits)(mal_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MAL_REFERENCE_TIME* pMinBufferDuration, MAL_REFERENCE_TIME* pMaxBufferDuration); + HRESULT (STDMETHODCALLTYPE * GetBufferSizeLimits)(mal_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration); // IAudioClient3 HRESULT (STDMETHODCALLTYPE * GetSharedModeEnginePeriod) (mal_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, UINT32* pDefaultPeriodInFrames, UINT32* pFundamentalPeriodInFrames, UINT32* pMinPeriodInFrames, UINT32* pMaxPeriodInFrames); @@ -6286,21 +6286,21 @@ struct mal_IAudioClient3 HRESULT mal_IAudioClient3_QueryInterface(mal_IAudioClient3* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } ULONG mal_IAudioClient3_AddRef(mal_IAudioClient3* pThis) { return pThis->lpVtbl->AddRef(pThis); } ULONG mal_IAudioClient3_Release(mal_IAudioClient3* pThis) { return pThis->lpVtbl->Release(pThis); } -HRESULT mal_IAudioClient3_Initialize(mal_IAudioClient3* pThis, MAL_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MAL_REFERENCE_TIME bufferDuration, MAL_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); } +HRESULT mal_IAudioClient3_Initialize(mal_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, DWORD streamFlags, MA_REFERENCE_TIME bufferDuration, MA_REFERENCE_TIME periodicity, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGuid) { return pThis->lpVtbl->Initialize(pThis, shareMode, streamFlags, bufferDuration, periodicity, pFormat, pAudioSessionGuid); } HRESULT mal_IAudioClient3_GetBufferSize(mal_IAudioClient3* pThis, mal_uint32* pNumBufferFrames) { return pThis->lpVtbl->GetBufferSize(pThis, pNumBufferFrames); } -HRESULT mal_IAudioClient3_GetStreamLatency(mal_IAudioClient3* pThis, MAL_REFERENCE_TIME* pLatency) { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); } +HRESULT mal_IAudioClient3_GetStreamLatency(mal_IAudioClient3* pThis, MA_REFERENCE_TIME* pLatency) { return pThis->lpVtbl->GetStreamLatency(pThis, pLatency); } HRESULT mal_IAudioClient3_GetCurrentPadding(mal_IAudioClient3* pThis, mal_uint32* pNumPaddingFrames) { return pThis->lpVtbl->GetCurrentPadding(pThis, pNumPaddingFrames); } -HRESULT mal_IAudioClient3_IsFormatSupported(mal_IAudioClient3* pThis, MAL_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); } +HRESULT mal_IAudioClient3_IsFormatSupported(mal_IAudioClient3* pThis, MA_AUDCLNT_SHAREMODE shareMode, const WAVEFORMATEX* pFormat, WAVEFORMATEX** ppClosestMatch) { return pThis->lpVtbl->IsFormatSupported(pThis, shareMode, pFormat, ppClosestMatch); } HRESULT mal_IAudioClient3_GetMixFormat(mal_IAudioClient3* pThis, WAVEFORMATEX** ppDeviceFormat) { return pThis->lpVtbl->GetMixFormat(pThis, ppDeviceFormat); } -HRESULT mal_IAudioClient3_GetDevicePeriod(mal_IAudioClient3* pThis, MAL_REFERENCE_TIME* pDefaultDevicePeriod, MAL_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); } +HRESULT mal_IAudioClient3_GetDevicePeriod(mal_IAudioClient3* pThis, MA_REFERENCE_TIME* pDefaultDevicePeriod, MA_REFERENCE_TIME* pMinimumDevicePeriod) { return pThis->lpVtbl->GetDevicePeriod(pThis, pDefaultDevicePeriod, pMinimumDevicePeriod); } HRESULT mal_IAudioClient3_Start(mal_IAudioClient3* pThis) { return pThis->lpVtbl->Start(pThis); } HRESULT mal_IAudioClient3_Stop(mal_IAudioClient3* pThis) { return pThis->lpVtbl->Stop(pThis); } HRESULT mal_IAudioClient3_Reset(mal_IAudioClient3* pThis) { return pThis->lpVtbl->Reset(pThis); } HRESULT mal_IAudioClient3_SetEventHandle(mal_IAudioClient3* pThis, HANDLE eventHandle) { return pThis->lpVtbl->SetEventHandle(pThis, eventHandle); } HRESULT mal_IAudioClient3_GetService(mal_IAudioClient3* pThis, const IID* const riid, void** pp) { return pThis->lpVtbl->GetService(pThis, riid, pp); } -HRESULT mal_IAudioClient3_IsOffloadCapable(mal_IAudioClient3* pThis, MAL_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable) { return pThis->lpVtbl->IsOffloadCapable(pThis, category, pOffloadCapable); } +HRESULT mal_IAudioClient3_IsOffloadCapable(mal_IAudioClient3* pThis, MA_AUDIO_STREAM_CATEGORY category, BOOL* pOffloadCapable) { return pThis->lpVtbl->IsOffloadCapable(pThis, category, pOffloadCapable); } HRESULT mal_IAudioClient3_SetClientProperties(mal_IAudioClient3* pThis, const mal_AudioClientProperties* pProperties) { return pThis->lpVtbl->SetClientProperties(pThis, pProperties); } -HRESULT mal_IAudioClient3_GetBufferSizeLimits(mal_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MAL_REFERENCE_TIME* pMinBufferDuration, MAL_REFERENCE_TIME* pMaxBufferDuration) { return pThis->lpVtbl->GetBufferSizeLimits(pThis, pFormat, eventDriven, pMinBufferDuration, pMaxBufferDuration); } +HRESULT mal_IAudioClient3_GetBufferSizeLimits(mal_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, BOOL eventDriven, MA_REFERENCE_TIME* pMinBufferDuration, MA_REFERENCE_TIME* pMaxBufferDuration) { return pThis->lpVtbl->GetBufferSizeLimits(pThis, pFormat, eventDriven, pMinBufferDuration, pMaxBufferDuration); } HRESULT mal_IAudioClient3_GetSharedModeEnginePeriod(mal_IAudioClient3* pThis, const WAVEFORMATEX* pFormat, UINT32* pDefaultPeriodInFrames, UINT32* pFundamentalPeriodInFrames, UINT32* pMinPeriodInFrames, UINT32* pMaxPeriodInFrames) { return pThis->lpVtbl->GetSharedModeEnginePeriod(pThis, pFormat, pDefaultPeriodInFrames, pFundamentalPeriodInFrames, pMinPeriodInFrames, pMaxPeriodInFrames); } HRESULT mal_IAudioClient3_GetCurrentSharedModeEnginePeriod(mal_IAudioClient3* pThis, WAVEFORMATEX** ppFormat, UINT32* pCurrentPeriodInFrames) { return pThis->lpVtbl->GetCurrentSharedModeEnginePeriod(pThis, ppFormat, pCurrentPeriodInFrames); } HRESULT mal_IAudioClient3_InitializeSharedAudioStream(mal_IAudioClient3* pThis, DWORD streamFlags, UINT32 periodInFrames, const WAVEFORMATEX* pFormat, const GUID* pAudioSessionGUID) { return pThis->lpVtbl->InitializeSharedAudioStream(pThis, streamFlags, periodInFrames, pFormat, pAudioSessionGUID); } @@ -6353,7 +6353,7 @@ HRESULT mal_IAudioCaptureClient_GetBuffer(mal_IAudioCaptureClient* pThis, BYTE** HRESULT mal_IAudioCaptureClient_ReleaseBuffer(mal_IAudioCaptureClient* pThis, mal_uint32 numFramesRead) { return pThis->lpVtbl->ReleaseBuffer(pThis, numFramesRead); } HRESULT mal_IAudioCaptureClient_GetNextPacketSize(mal_IAudioCaptureClient* pThis, mal_uint32* pNumFramesInNextPacket) { return pThis->lpVtbl->GetNextPacketSize(pThis, pNumFramesInNextPacket); } -#ifndef MAL_WIN32_DESKTOP +#ifndef MA_WIN32_DESKTOP #include typedef struct mal_completion_handler_uwp mal_completion_handler_uwp; @@ -6378,7 +6378,7 @@ HRESULT STDMETHODCALLTYPE mal_completion_handler_uwp_QueryInterface(mal_completi { // We need to "implement" IAgileObject which is just an indicator that's used internally by WASAPI for some multithreading management. To // "implement" this, we just make sure we return pThis when the IAgileObject is requested. - if (!mal_is_guid_equal(riid, &MAL_IID_IUnknown) && !mal_is_guid_equal(riid, &MAL_IID_IActivateAudioInterfaceCompletionHandler) && !mal_is_guid_equal(riid, &MAL_IID_IAgileObject)) { + if (!mal_is_guid_equal(riid, &MA_IID_IUnknown) && !mal_is_guid_equal(riid, &MA_IID_IActivateAudioInterfaceCompletionHandler) && !mal_is_guid_equal(riid, &MA_IID_IAgileObject)) { *ppObject = NULL; return E_NOINTERFACE; } @@ -6428,10 +6428,10 @@ mal_result mal_completion_handler_uwp_init(mal_completion_handler_uwp* pHandler) pHandler->counter = 1; pHandler->hEvent = CreateEventA(NULL, FALSE, FALSE, NULL); if (pHandler->hEvent == NULL) { - return MAL_ERROR; + return MA_ERROR; } - return MAL_SUCCESS; + return MA_SUCCESS; } void mal_completion_handler_uwp_uninit(mal_completion_handler_uwp* pHandler) @@ -6445,15 +6445,15 @@ void mal_completion_handler_uwp_wait(mal_completion_handler_uwp* pHandler) { WaitForSingleObject(pHandler->hEvent, INFINITE); } -#endif // !MAL_WIN32_DESKTOP +#endif // !MA_WIN32_DESKTOP // We need a virtual table for our notification client object that's used for detecting changes to the default device. -#ifdef MAL_WIN32_DESKTOP +#ifdef MA_WIN32_DESKTOP HRESULT STDMETHODCALLTYPE mal_IMMNotificationClient_QueryInterface(mal_IMMNotificationClient* pThis, const IID* const riid, void** ppObject) { // We care about two interfaces - IUnknown and IMMNotificationClient. If the requested IID is something else // we just return E_NOINTERFACE. Otherwise we need to increment the reference counter and return S_OK. - if (!mal_is_guid_equal(riid, &MAL_IID_IUnknown) && !mal_is_guid_equal(riid, &MAL_IID_IMMNotificationClient)) { + if (!mal_is_guid_equal(riid, &MA_IID_IUnknown) && !mal_is_guid_equal(riid, &MA_IID_IMMNotificationClient)) { *ppObject = NULL; return E_NOINTERFACE; } @@ -6482,7 +6482,7 @@ ULONG STDMETHODCALLTYPE mal_IMMNotificationClient_Release(mal_IMMNotificationCli HRESULT STDMETHODCALLTYPE mal_IMMNotificationClient_OnDeviceStateChanged(mal_IMMNotificationClient* pThis, LPCWSTR pDeviceID, DWORD dwNewState) { -#ifdef MAL_DEBUG_OUTPUT +#ifdef MA_DEBUG_OUTPUT printf("IMMNotificationClient_OnDeviceStateChanged(pDeviceID=%S, dwNewState=%u)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)", (unsigned int)dwNewState); #endif @@ -6494,7 +6494,7 @@ HRESULT STDMETHODCALLTYPE mal_IMMNotificationClient_OnDeviceStateChanged(mal_IMM HRESULT STDMETHODCALLTYPE mal_IMMNotificationClient_OnDeviceAdded(mal_IMMNotificationClient* pThis, LPCWSTR pDeviceID) { -#ifdef MAL_DEBUG_OUTPUT +#ifdef MA_DEBUG_OUTPUT printf("IMMNotificationClient_OnDeviceAdded(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)"); #endif @@ -6506,7 +6506,7 @@ HRESULT STDMETHODCALLTYPE mal_IMMNotificationClient_OnDeviceAdded(mal_IMMNotific HRESULT STDMETHODCALLTYPE mal_IMMNotificationClient_OnDeviceRemoved(mal_IMMNotificationClient* pThis, LPCWSTR pDeviceID) { -#ifdef MAL_DEBUG_OUTPUT +#ifdef MA_DEBUG_OUTPUT printf("IMMNotificationClient_OnDeviceRemoved(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)"); #endif @@ -6518,7 +6518,7 @@ HRESULT STDMETHODCALLTYPE mal_IMMNotificationClient_OnDeviceRemoved(mal_IMMNotif HRESULT STDMETHODCALLTYPE mal_IMMNotificationClient_OnDefaultDeviceChanged(mal_IMMNotificationClient* pThis, mal_EDataFlow dataFlow, mal_ERole role, LPCWSTR pDefaultDeviceID) { -#ifdef MAL_DEBUG_OUTPUT +#ifdef MA_DEBUG_OUTPUT printf("IMMNotificationClient_OnDefaultDeviceChanged(dataFlow=%d, role=%d, pDefaultDeviceID=%S)\n", dataFlow, role, (pDefaultDeviceID != NULL) ? pDefaultDeviceID : L"(NULL)"); #endif @@ -6544,10 +6544,10 @@ HRESULT STDMETHODCALLTYPE mal_IMMNotificationClient_OnDefaultDeviceChanged(mal_I // We don't change the device here - we change it in the worker thread to keep synchronization simple. To do this I'm just setting a flag to // indicate that the default device has changed. if (dataFlow == mal_eRender) { - mal_atomic_exchange_32(&pThis->pDevice->wasapi.hasDefaultPlaybackDeviceChanged, MAL_TRUE); + mal_atomic_exchange_32(&pThis->pDevice->wasapi.hasDefaultPlaybackDeviceChanged, MA_TRUE); } if (dataFlow == mal_eCapture) { - mal_atomic_exchange_32(&pThis->pDevice->wasapi.hasDefaultCaptureDeviceChanged, MAL_TRUE); + mal_atomic_exchange_32(&pThis->pDevice->wasapi.hasDefaultCaptureDeviceChanged, MA_TRUE); } (void)pDefaultDeviceID; @@ -6556,7 +6556,7 @@ HRESULT STDMETHODCALLTYPE mal_IMMNotificationClient_OnDefaultDeviceChanged(mal_I HRESULT STDMETHODCALLTYPE mal_IMMNotificationClient_OnPropertyValueChanged(mal_IMMNotificationClient* pThis, LPCWSTR pDeviceID, const PROPERTYKEY key) { -#ifdef MAL_DEBUG_OUTPUT +#ifdef MA_DEBUG_OUTPUT printf("IMMNotificationClient_OnPropertyValueChanged(pDeviceID=%S)\n", (pDeviceID != NULL) ? pDeviceID : L"(NULL)"); #endif @@ -6576,9 +6576,9 @@ static mal_IMMNotificationClientVtbl g_malNotificationCientVtbl = { mal_IMMNotificationClient_OnDefaultDeviceChanged, mal_IMMNotificationClient_OnPropertyValueChanged }; -#endif // MAL_WIN32_DESKTOP +#endif // MA_WIN32_DESKTOP -#ifdef MAL_WIN32_DESKTOP +#ifdef MA_WIN32_DESKTOP typedef mal_IMMDevice mal_WASAPIDeviceInterface; #else typedef mal_IUnknown mal_WASAPIDeviceInterface; @@ -6621,13 +6621,13 @@ mal_result mal_context_get_device_info_from_IAudioClient__wasapi(mal_context* pC HRESULT hr = mal_IAudioClient_GetMixFormat((mal_IAudioClient*)pAudioClient, (WAVEFORMATEX**)&pWF); if (SUCCEEDED(hr)) { mal_set_device_info_from_WAVEFORMATEX(pWF, pInfo); - return MAL_SUCCESS; + return MA_SUCCESS; } else { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve mix format for device info retrieval.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve mix format for device info retrieval.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } } else { // Exlcusive Mode. We repeatedly call IsFormatSupported() here. This is not currently support on UWP. -#ifdef MAL_WIN32_DESKTOP +#ifdef MA_WIN32_DESKTOP // The first thing to do is get the format from PKEY_AudioEngine_DeviceFormat. This should give us a channel count we assume is // correct which will simplify our searching. mal_IPropertyStore *pProperties; @@ -6636,19 +6636,19 @@ mal_result mal_context_get_device_info_from_IAudioClient__wasapi(mal_context* pC PROPVARIANT var; mal_PropVariantInit(&var); - hr = mal_IPropertyStore_GetValue(pProperties, &MAL_PKEY_AudioEngine_DeviceFormat, &var); + hr = mal_IPropertyStore_GetValue(pProperties, &MA_PKEY_AudioEngine_DeviceFormat, &var); if (SUCCEEDED(hr)) { WAVEFORMATEX* pWF = (WAVEFORMATEX*)var.blob.pBlobData; mal_set_device_info_from_WAVEFORMATEX(pWF, pInfo); // In my testing, the format returned by PKEY_AudioEngine_DeviceFormat is suitable for exclusive mode so we check this format // first. If this fails, fall back to a search. - hr = mal_IAudioClient_IsFormatSupported((mal_IAudioClient*)pAudioClient, MAL_AUDCLNT_SHAREMODE_EXCLUSIVE, pWF, NULL); + hr = mal_IAudioClient_IsFormatSupported((mal_IAudioClient*)pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, pWF, NULL); mal_PropVariantClear(pContext, &var); if (FAILED(hr)) { // The format returned by PKEY_AudioEngine_DeviceFormat is not supported, so fall back to a search. We assume the channel - // count returned by MAL_PKEY_AudioEngine_DeviceFormat is valid and correct. For simplicity we're only returning one format. + // count returned by MA_PKEY_AudioEngine_DeviceFormat is valid and correct. For simplicity we're only returning one format. mal_uint32 channels = pInfo->minChannels; mal_format formatsToSearch[] = { @@ -6660,7 +6660,7 @@ mal_result mal_context_get_device_info_from_IAudioClient__wasapi(mal_context* pC mal_format_u8 }; - mal_channel defaultChannelMap[MAL_MAX_CHANNELS]; + mal_channel defaultChannelMap[MA_MAX_CHANNELS]; mal_get_standard_channel_map(mal_standard_channel_map_microsoft, channels, defaultChannelMap); WAVEFORMATEXTENSIBLE wf; @@ -6670,7 +6670,7 @@ mal_result mal_context_get_device_info_from_IAudioClient__wasapi(mal_context* pC wf.Format.nChannels = (WORD)channels; wf.dwChannelMask = mal_channel_map_to_channel_mask__win32(defaultChannelMap, channels); - mal_bool32 found = MAL_FALSE; + mal_bool32 found = MA_FALSE; for (mal_uint32 iFormat = 0; iFormat < mal_countof(formatsToSearch); ++iFormat) { mal_format format = formatsToSearch[iFormat]; @@ -6679,18 +6679,18 @@ mal_result mal_context_get_device_info_from_IAudioClient__wasapi(mal_context* pC wf.Format.nAvgBytesPerSec = wf.Format.nBlockAlign * wf.Format.nSamplesPerSec; wf.Samples.wValidBitsPerSample = /*(format == mal_format_s24_32) ? 24 :*/ wf.Format.wBitsPerSample; if (format == mal_format_f32) { - wf.SubFormat = MAL_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; + wf.SubFormat = MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; } else { - wf.SubFormat = MAL_GUID_KSDATAFORMAT_SUBTYPE_PCM; + wf.SubFormat = MA_GUID_KSDATAFORMAT_SUBTYPE_PCM; } for (mal_uint32 iSampleRate = 0; iSampleRate < mal_countof(g_malStandardSampleRatePriorities); ++iSampleRate) { wf.Format.nSamplesPerSec = g_malStandardSampleRatePriorities[iSampleRate]; - hr = mal_IAudioClient_IsFormatSupported((mal_IAudioClient*)pAudioClient, MAL_AUDCLNT_SHAREMODE_EXCLUSIVE, (WAVEFORMATEX*)&wf, NULL); + hr = mal_IAudioClient_IsFormatSupported((mal_IAudioClient*)pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, (WAVEFORMATEX*)&wf, NULL); if (SUCCEEDED(hr)) { mal_set_device_info_from_WAVEFORMATEX((WAVEFORMATEX*)&wf, pInfo); - found = MAL_TRUE; + found = MA_TRUE; break; } } @@ -6702,35 +6702,35 @@ mal_result mal_context_get_device_info_from_IAudioClient__wasapi(mal_context* pC if (!found) { mal_IPropertyStore_Release(pProperties); - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to find suitable device format for device info retrieval.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to find suitable device format for device info retrieval.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } } } else { mal_IPropertyStore_Release(pProperties); - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve device format for device info retrieval.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve device format for device info retrieval.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } } else { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to open property store for device info retrieval.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to open property store for device info retrieval.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } - return MAL_SUCCESS; + return MA_SUCCESS; #else // Exclusive mode not fully supported in UWP right now. - return MAL_ERROR; + return MA_ERROR; #endif } } -#ifdef MAL_WIN32_DESKTOP +#ifdef MA_WIN32_DESKTOP mal_result mal_context_get_MMDevice__wasapi(mal_context* pContext, mal_device_type deviceType, const mal_device_id* pDeviceID, mal_IMMDevice** ppMMDevice) { mal_assert(pContext != NULL); mal_assert(ppMMDevice != NULL); mal_IMMDeviceEnumerator* pDeviceEnumerator; - HRESULT hr = mal_CoCreateInstance(pContext, MAL_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MAL_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); + HRESULT hr = mal_CoCreateInstance(pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); if (FAILED(hr)) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to create IMMDeviceEnumerator.", MAL_FAILED_TO_INIT_BACKEND); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create IMMDeviceEnumerator.", MA_FAILED_TO_INIT_BACKEND); } if (pDeviceID == NULL) { @@ -6741,10 +6741,10 @@ mal_result mal_context_get_MMDevice__wasapi(mal_context* pContext, mal_device_ty mal_IMMDeviceEnumerator_Release(pDeviceEnumerator); if (FAILED(hr)) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve IMMDevice.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve IMMDevice.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_get_device_info_from_MMDevice__wasapi(mal_context* pContext, mal_IMMDevice* pMMDevice, mal_share_mode shareMode, mal_bool32 onlySimpleInfo, mal_device_info* pInfo) @@ -6760,8 +6760,8 @@ mal_result mal_context_get_device_info_from_MMDevice__wasapi(mal_context* pConte size_t idlen = wcslen(id); if (idlen+1 > mal_countof(pInfo->id.wasapi)) { mal_CoTaskMemFree(pContext, id); - mal_assert(MAL_FALSE); // NOTE: If this is triggered, please report it. It means the format of the ID must haved change and is too long to fit in our fixed sized buffer. - return MAL_ERROR; + mal_assert(MA_FALSE); // NOTE: If this is triggered, please report it. It means the format of the ID must haved change and is too long to fit in our fixed sized buffer. + return MA_ERROR; } mal_copy_memory(pInfo->id.wasapi, id, idlen * sizeof(wchar_t)); @@ -6778,7 +6778,7 @@ mal_result mal_context_get_device_info_from_MMDevice__wasapi(mal_context* pConte // Description / Friendly Name mal_PropVariantInit(&var); - hr = mal_IPropertyStore_GetValue(pProperties, &MAL_PKEY_Device_FriendlyName, &var); + hr = mal_IPropertyStore_GetValue(pProperties, &MA_PKEY_Device_FriendlyName, &var); if (SUCCEEDED(hr)) { WideCharToMultiByte(CP_UTF8, 0, var.pwszVal, -1, pInfo->name, sizeof(pInfo->name), 0, FALSE); mal_PropVariantClear(pContext, &var); @@ -6791,18 +6791,18 @@ mal_result mal_context_get_device_info_from_MMDevice__wasapi(mal_context* pConte // Format if (!onlySimpleInfo) { mal_IAudioClient* pAudioClient; - hr = mal_IMMDevice_Activate(pMMDevice, &MAL_IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&pAudioClient); + hr = mal_IMMDevice_Activate(pMMDevice, &MA_IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&pAudioClient); if (SUCCEEDED(hr)) { mal_result result = mal_context_get_device_info_from_IAudioClient__wasapi(pContext, pMMDevice, pAudioClient, shareMode, pInfo); mal_IAudioClient_Release(pAudioClient); return result; } else { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to activate audio client for device info retrieval.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to activate audio client for device info retrieval.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_enumerate_device_collection__wasapi(mal_context* pContext, mal_IMMDeviceCollection* pDeviceCollection, mal_device_type deviceType, mal_enum_devices_callback_proc callback, void* pUserData) @@ -6813,7 +6813,7 @@ mal_result mal_context_enumerate_device_collection__wasapi(mal_context* pContext UINT deviceCount; HRESULT hr = mal_IMMDeviceCollection_GetCount(pDeviceCollection, &deviceCount); if (FAILED(hr)) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to get playback device count.", MAL_NO_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to get playback device count.", MA_NO_DEVICE); } for (mal_uint32 iDevice = 0; iDevice < deviceCount; ++iDevice) { @@ -6823,23 +6823,23 @@ mal_result mal_context_enumerate_device_collection__wasapi(mal_context* pContext mal_IMMDevice* pMMDevice; hr = mal_IMMDeviceCollection_Item(pDeviceCollection, iDevice, &pMMDevice); if (SUCCEEDED(hr)) { - mal_result result = mal_context_get_device_info_from_MMDevice__wasapi(pContext, pMMDevice, mal_share_mode_shared, MAL_TRUE, &deviceInfo); // MAL_TRUE = onlySimpleInfo. + mal_result result = mal_context_get_device_info_from_MMDevice__wasapi(pContext, pMMDevice, mal_share_mode_shared, MA_TRUE, &deviceInfo); // MA_TRUE = onlySimpleInfo. mal_IMMDevice_Release(pMMDevice); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { mal_bool32 cbResult = callback(pContext, deviceType, &deviceInfo, pUserData); - if (cbResult == MAL_FALSE) { + if (cbResult == MA_FALSE) { break; } } } } - return MAL_SUCCESS; + return MA_SUCCESS; } #endif -#ifdef MAL_WIN32_DESKTOP +#ifdef MA_WIN32_DESKTOP mal_result mal_context_get_IAudioClient_Desktop__wasapi(mal_context* pContext, mal_device_type deviceType, const mal_device_id* pDeviceID, mal_IAudioClient** ppAudioClient, mal_IMMDevice** ppMMDevice) { mal_result result; @@ -6850,16 +6850,16 @@ mal_result mal_context_get_IAudioClient_Desktop__wasapi(mal_context* pContext, m mal_assert(ppMMDevice != NULL); result = mal_context_get_MMDevice__wasapi(pContext, deviceType, pDeviceID, ppMMDevice); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } - hr = mal_IMMDevice_Activate(*ppMMDevice, &MAL_IID_IAudioClient, CLSCTX_ALL, NULL, (void**)ppAudioClient); + hr = mal_IMMDevice_Activate(*ppMMDevice, &MA_IID_IAudioClient, CLSCTX_ALL, NULL, (void**)ppAudioClient); if (FAILED(hr)) { - return MAL_FAILED_TO_OPEN_BACKEND_DEVICE; + return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } - return MAL_SUCCESS; + return MA_SUCCESS; } #else mal_result mal_context_get_IAudioClient_UWP__wasapi(mal_context* pContext, mal_device_type deviceType, const mal_device_id* pDeviceID, mal_IAudioClient** ppAudioClient, mal_IUnknown** ppActivatedInterface) @@ -6875,9 +6875,9 @@ mal_result mal_context_get_IAudioClient_UWP__wasapi(mal_context* pContext, mal_d mal_copy_memory(&iid, pDeviceID->wasapi, sizeof(iid)); } else { if (deviceType == mal_device_type_playback) { - iid = MAL_IID_DEVINTERFACE_AUDIO_RENDER; + iid = MA_IID_DEVINTERFACE_AUDIO_RENDER; } else { - iid = MAL_IID_DEVINTERFACE_AUDIO_CAPTURE; + iid = MA_IID_DEVINTERFACE_AUDIO_CAPTURE; } } @@ -6888,24 +6888,24 @@ mal_result mal_context_get_IAudioClient_UWP__wasapi(mal_context* pContext, mal_d HRESULT hr = StringFromIID(&iid, &iidStr); #endif if (FAILED(hr)) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to convert device IID to string for ActivateAudioInterfaceAsync(). Out of memory.", MAL_OUT_OF_MEMORY); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to convert device IID to string for ActivateAudioInterfaceAsync(). Out of memory.", MA_OUT_OF_MEMORY); } mal_result result = mal_completion_handler_uwp_init(&completionHandler); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { mal_CoTaskMemFree(pContext, iidStr); - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for waiting for ActivateAudioInterfaceAsync().", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for waiting for ActivateAudioInterfaceAsync().", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } #if defined(__cplusplus) - hr = ActivateAudioInterfaceAsync(iidStr, MAL_IID_IAudioClient, NULL, (IActivateAudioInterfaceCompletionHandler*)&completionHandler, (IActivateAudioInterfaceAsyncOperation**)&pAsyncOp); + hr = ActivateAudioInterfaceAsync(iidStr, MA_IID_IAudioClient, NULL, (IActivateAudioInterfaceCompletionHandler*)&completionHandler, (IActivateAudioInterfaceAsyncOperation**)&pAsyncOp); #else - hr = ActivateAudioInterfaceAsync(iidStr, &MAL_IID_IAudioClient, NULL, (IActivateAudioInterfaceCompletionHandler*)&completionHandler, (IActivateAudioInterfaceAsyncOperation**)&pAsyncOp); + hr = ActivateAudioInterfaceAsync(iidStr, &MA_IID_IAudioClient, NULL, (IActivateAudioInterfaceCompletionHandler*)&completionHandler, (IActivateAudioInterfaceAsyncOperation**)&pAsyncOp); #endif if (FAILED(hr)) { mal_completion_handler_uwp_uninit(&completionHandler); mal_CoTaskMemFree(pContext, iidStr); - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[WASAPI] ActivateAudioInterfaceAsync() failed.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] ActivateAudioInterfaceAsync() failed.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } mal_CoTaskMemFree(pContext, iidStr); @@ -6920,13 +6920,13 @@ mal_result mal_context_get_IAudioClient_UWP__wasapi(mal_context* pContext, mal_d mal_IActivateAudioInterfaceAsyncOperation_Release(pAsyncOp); if (FAILED(hr) || FAILED(activateResult)) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to activate device.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to activate device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } // Here is where we grab the IAudioClient interface. - hr = mal_IUnknown_QueryInterface(pActivatedInterface, &MAL_IID_IAudioClient, (void**)ppAudioClient); + hr = mal_IUnknown_QueryInterface(pActivatedInterface, &MA_IID_IAudioClient, (void**)ppAudioClient); if (FAILED(hr)) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to query IAudioClient interface.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to query IAudioClient interface.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } if (ppActivatedInterface) { @@ -6935,13 +6935,13 @@ mal_result mal_context_get_IAudioClient_UWP__wasapi(mal_context* pContext, mal_d mal_IUnknown_Release(pActivatedInterface); } - return MAL_SUCCESS; + return MA_SUCCESS; } #endif mal_result mal_context_get_IAudioClient__wasapi(mal_context* pContext, mal_device_type deviceType, const mal_device_id* pDeviceID, mal_IAudioClient** ppAudioClient, mal_WASAPIDeviceInterface** ppDeviceInterface) { -#ifdef MAL_WIN32_DESKTOP +#ifdef MA_WIN32_DESKTOP return mal_context_get_IAudioClient_Desktop__wasapi(pContext, deviceType, pDeviceID, ppAudioClient, ppDeviceInterface); #else return mal_context_get_IAudioClient_UWP__wasapi(pContext, deviceType, pDeviceID, ppAudioClient, ppDeviceInterface); @@ -6955,25 +6955,25 @@ mal_result mal_context_enumerate_devices__wasapi(mal_context* pContext, mal_enum mal_assert(callback != NULL); // Different enumeration for desktop and UWP. -#ifdef MAL_WIN32_DESKTOP +#ifdef MA_WIN32_DESKTOP // Desktop mal_IMMDeviceEnumerator* pDeviceEnumerator; - HRESULT hr = mal_CoCreateInstance(pContext, MAL_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MAL_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); + HRESULT hr = mal_CoCreateInstance(pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); if (FAILED(hr)) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create device enumerator.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } mal_IMMDeviceCollection* pDeviceCollection; // Playback. - hr = mal_IMMDeviceEnumerator_EnumAudioEndpoints(pDeviceEnumerator, mal_eRender, MAL_MM_DEVICE_STATE_ACTIVE, &pDeviceCollection); + hr = mal_IMMDeviceEnumerator_EnumAudioEndpoints(pDeviceEnumerator, mal_eRender, MA_MM_DEVICE_STATE_ACTIVE, &pDeviceCollection); if (SUCCEEDED(hr)) { mal_context_enumerate_device_collection__wasapi(pContext, pDeviceCollection, mal_device_type_playback, callback, pUserData); mal_IMMDeviceCollection_Release(pDeviceCollection); } // Capture. - hr = mal_IMMDeviceEnumerator_EnumAudioEndpoints(pDeviceEnumerator, mal_eCapture, MAL_MM_DEVICE_STATE_ACTIVE, &pDeviceCollection); + hr = mal_IMMDeviceEnumerator_EnumAudioEndpoints(pDeviceEnumerator, mal_eCapture, MA_MM_DEVICE_STATE_ACTIVE, &pDeviceCollection); if (SUCCEEDED(hr)) { mal_context_enumerate_device_collection__wasapi(pContext, pDeviceCollection, mal_device_type_capture, callback, pUserData); mal_IMMDeviceCollection_Release(pDeviceCollection); @@ -6988,13 +6988,13 @@ mal_result mal_context_enumerate_devices__wasapi(mal_context* pContext, mal_enum // // Hint: DeviceInformation::FindAllAsync() with DeviceClass.AudioCapture/AudioRender. https://blogs.windows.com/buildingapps/2014/05/15/real-time-audio-in-windows-store-and-windows-phone-apps/ if (callback) { - mal_bool32 cbResult = MAL_TRUE; + mal_bool32 cbResult = MA_TRUE; // Playback. if (cbResult) { mal_device_info deviceInfo; mal_zero_object(&deviceInfo); - mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MAL_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); cbResult = callback(pContext, mal_device_type_playback, &deviceInfo, pUserData); } @@ -7002,44 +7002,44 @@ mal_result mal_context_enumerate_devices__wasapi(mal_context* pContext, mal_enum if (cbResult) { mal_device_info deviceInfo; mal_zero_object(&deviceInfo); - mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MAL_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); cbResult = callback(pContext, mal_device_type_capture, &deviceInfo, pUserData); } } #endif - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_get_device_info__wasapi(mal_context* pContext, mal_device_type deviceType, const mal_device_id* pDeviceID, mal_share_mode shareMode, mal_device_info* pDeviceInfo) { -#ifdef MAL_WIN32_DESKTOP +#ifdef MA_WIN32_DESKTOP mal_IMMDevice* pMMDevice = NULL; mal_result result = mal_context_get_MMDevice__wasapi(pContext, deviceType, pDeviceID, &pMMDevice); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } - result = mal_context_get_device_info_from_MMDevice__wasapi(pContext, pMMDevice, shareMode, MAL_FALSE, pDeviceInfo); // MAL_FALSE = !onlySimpleInfo. + result = mal_context_get_device_info_from_MMDevice__wasapi(pContext, pMMDevice, shareMode, MA_FALSE, pDeviceInfo); // MA_FALSE = !onlySimpleInfo. mal_IMMDevice_Release(pMMDevice); return result; #else // UWP currently only uses default devices. if (deviceType == mal_device_type_playback) { - mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MAL_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { - mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MAL_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } // Not currently supporting exclusive mode on UWP. if (shareMode == mal_share_mode_exclusive) { - return MAL_ERROR; + return MA_ERROR; } mal_IAudioClient* pAudioClient; mal_result result = mal_context_get_IAudioClient_UWP__wasapi(pContext, deviceType, pDeviceID, &pAudioClient, NULL); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -7054,7 +7054,7 @@ void mal_device_uninit__wasapi(mal_device* pDevice) { mal_assert(pDevice != NULL); -#ifdef MAL_WIN32_DESKTOP +#ifdef MA_WIN32_DESKTOP if (pDevice->wasapi.pDeviceEnumerator) { ((mal_IMMDeviceEnumerator*)pDevice->wasapi.pDeviceEnumerator)->lpVtbl->UnregisterEndpointNotificationCallback((mal_IMMDeviceEnumerator*)pDevice->wasapi.pDeviceEnumerator, &pDevice->wasapi.notificationClient); mal_IMMDeviceEnumerator_Release((mal_IMMDeviceEnumerator*)pDevice->wasapi.pDeviceEnumerator); @@ -7090,7 +7090,7 @@ typedef struct mal_format formatIn; mal_uint32 channelsIn; mal_uint32 sampleRateIn; - mal_channel channelMapIn[MAL_MAX_CHANNELS]; + mal_channel channelMapIn[MA_MAX_CHANNELS]; mal_uint32 bufferSizeInFramesIn; mal_uint32 bufferSizeInMillisecondsIn; mal_uint32 periodsIn; @@ -7107,7 +7107,7 @@ typedef struct mal_format formatOut; mal_uint32 channelsOut; mal_uint32 sampleRateOut; - mal_channel channelMapOut[MAL_MAX_CHANNELS]; + mal_channel channelMapOut[MA_MAX_CHANNELS]; mal_uint32 bufferSizeInFramesOut; mal_uint32 periodSizeInFramesOut; mal_uint32 periodsOut; @@ -7123,7 +7123,7 @@ mal_result mal_device_init_internal__wasapi(mal_context* pContext, mal_device_ty /* This function is only used to initialize one device type: either playback or capture. Never full-duplex. */ if (deviceType == mal_device_type_duplex) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } pData->pAudioClient = NULL; @@ -7132,51 +7132,51 @@ mal_result mal_device_init_internal__wasapi(mal_context* pContext, mal_device_ty HRESULT hr; - mal_result result = MAL_SUCCESS; + mal_result result = MA_SUCCESS; const char* errorMsg = ""; - MAL_AUDCLNT_SHAREMODE shareMode = MAL_AUDCLNT_SHAREMODE_SHARED; - MAL_REFERENCE_TIME bufferDurationInMicroseconds; - mal_bool32 wasInitializedUsingIAudioClient3 = MAL_FALSE; + MA_AUDCLNT_SHAREMODE shareMode = MA_AUDCLNT_SHAREMODE_SHARED; + MA_REFERENCE_TIME bufferDurationInMicroseconds; + mal_bool32 wasInitializedUsingIAudioClient3 = MA_FALSE; WAVEFORMATEXTENSIBLE wf; mal_WASAPIDeviceInterface* pDeviceInterface = NULL; result = mal_context_get_IAudioClient__wasapi(pContext, deviceType, pDeviceID, &pData->pAudioClient, &pDeviceInterface); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { goto done; } // Try enabling hardware offloading. mal_IAudioClient2* pAudioClient2; - hr = mal_IAudioClient_QueryInterface(pData->pAudioClient, &MAL_IID_IAudioClient2, (void**)&pAudioClient2); + hr = mal_IAudioClient_QueryInterface(pData->pAudioClient, &MA_IID_IAudioClient2, (void**)&pAudioClient2); if (SUCCEEDED(hr)) { BOOL isHardwareOffloadingSupported = 0; - hr = mal_IAudioClient2_IsOffloadCapable(pAudioClient2, MAL_AudioCategory_Other, &isHardwareOffloadingSupported); + hr = mal_IAudioClient2_IsOffloadCapable(pAudioClient2, MA_AudioCategory_Other, &isHardwareOffloadingSupported); if (SUCCEEDED(hr) && isHardwareOffloadingSupported) { mal_AudioClientProperties clientProperties; mal_zero_object(&clientProperties); clientProperties.cbSize = sizeof(clientProperties); clientProperties.bIsOffload = 1; - clientProperties.eCategory = MAL_AudioCategory_Other; + clientProperties.eCategory = MA_AudioCategory_Other; mal_IAudioClient2_SetClientProperties(pAudioClient2, &clientProperties); } } // Here is where we try to determine the best format to use with the device. If the client if wanting exclusive mode, first try finding the best format for that. If this fails, fall back to shared mode. - result = MAL_FORMAT_NOT_SUPPORTED; + result = MA_FORMAT_NOT_SUPPORTED; if (pData->shareMode == mal_share_mode_exclusive) { - #ifdef MAL_WIN32_DESKTOP + #ifdef MA_WIN32_DESKTOP // In exclusive mode on desktop we always use the backend's native format. mal_IPropertyStore* pStore = NULL; hr = mal_IMMDevice_OpenPropertyStore(pDeviceInterface, STGM_READ, &pStore); if (SUCCEEDED(hr)) { PROPVARIANT prop; mal_PropVariantInit(&prop); - hr = mal_IPropertyStore_GetValue(pStore, &MAL_PKEY_AudioEngine_DeviceFormat, &prop); + hr = mal_IPropertyStore_GetValue(pStore, &MA_PKEY_AudioEngine_DeviceFormat, &prop); if (SUCCEEDED(hr)) { WAVEFORMATEX* pActualFormat = (WAVEFORMATEX*)prop.blob.pBlobData; - hr = mal_IAudioClient_IsFormatSupported((mal_IAudioClient*)pData->pAudioClient, MAL_AUDCLNT_SHAREMODE_EXCLUSIVE, pActualFormat, NULL); + hr = mal_IAudioClient_IsFormatSupported((mal_IAudioClient*)pData->pAudioClient, MA_AUDCLNT_SHAREMODE_EXCLUSIVE, pActualFormat, NULL); if (SUCCEEDED(hr)) { mal_copy_memory(&wf, pActualFormat, sizeof(WAVEFORMATEXTENSIBLE)); } @@ -7196,29 +7196,29 @@ mal_result mal_device_init_internal__wasapi(mal_context* pContext, mal_device_ty #endif if (hr == S_OK) { - shareMode = MAL_AUDCLNT_SHAREMODE_EXCLUSIVE; - result = MAL_SUCCESS; + shareMode = MA_AUDCLNT_SHAREMODE_EXCLUSIVE; + result = MA_SUCCESS; } else { - result = MAL_SHARE_MODE_NOT_SUPPORTED; + result = MA_SHARE_MODE_NOT_SUPPORTED; } } else { // In shared mode we are always using the format reported by the operating system. WAVEFORMATEXTENSIBLE* pNativeFormat = NULL; hr = mal_IAudioClient_GetMixFormat((mal_IAudioClient*)pData->pAudioClient, (WAVEFORMATEX**)&pNativeFormat); if (hr != S_OK) { - result = MAL_FORMAT_NOT_SUPPORTED; + result = MA_FORMAT_NOT_SUPPORTED; } else { mal_copy_memory(&wf, pNativeFormat, sizeof(wf)); - result = MAL_SUCCESS; + result = MA_SUCCESS; } mal_CoTaskMemFree(pContext, pNativeFormat); - shareMode = MAL_AUDCLNT_SHAREMODE_SHARED; + shareMode = MA_AUDCLNT_SHAREMODE_SHARED; } // Return an error if we still haven't found a format. - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { errorMsg = "[WASAPI] Failed to find best device mix format."; goto done; } @@ -7241,15 +7241,15 @@ mal_result mal_device_init_internal__wasapi(mal_context* pContext, mal_device_ty // Slightly different initialization for shared and exclusive modes. We try exclusive mode first, and if it fails, fall back to shared mode. - if (shareMode == MAL_AUDCLNT_SHAREMODE_EXCLUSIVE) { - MAL_REFERENCE_TIME bufferDuration = (bufferDurationInMicroseconds / pData->periodsOut) * 10; + if (shareMode == MA_AUDCLNT_SHAREMODE_EXCLUSIVE) { + MA_REFERENCE_TIME bufferDuration = (bufferDurationInMicroseconds / pData->periodsOut) * 10; // If the periodicy is too small, Initialize() will fail with AUDCLNT_E_INVALID_DEVICE_PERIOD. In this case we should just keep increasing // it and trying it again. hr = E_FAIL; for (;;) { - hr = mal_IAudioClient_Initialize((mal_IAudioClient*)pData->pAudioClient, shareMode, MAL_AUDCLNT_STREAMFLAGS_EVENTCALLBACK, bufferDuration, bufferDuration, (WAVEFORMATEX*)&wf, NULL); - if (hr == MAL_AUDCLNT_E_INVALID_DEVICE_PERIOD) { + hr = mal_IAudioClient_Initialize((mal_IAudioClient*)pData->pAudioClient, shareMode, MA_AUDCLNT_STREAMFLAGS_EVENTCALLBACK, bufferDuration, bufferDuration, (WAVEFORMATEX*)&wf, NULL); + if (hr == MA_AUDCLNT_E_INVALID_DEVICE_PERIOD) { if (bufferDuration > 500*10000) { break; } else { @@ -7265,23 +7265,23 @@ mal_result mal_device_init_internal__wasapi(mal_context* pContext, mal_device_ty } } - if (hr == MAL_AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED) { + if (hr == MA_AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED) { UINT bufferSizeInFrames; hr = mal_IAudioClient_GetBufferSize((mal_IAudioClient*)pData->pAudioClient, &bufferSizeInFrames); if (SUCCEEDED(hr)) { - bufferDuration = (MAL_REFERENCE_TIME)((10000.0 * 1000 / wf.Format.nSamplesPerSec * bufferSizeInFrames) + 0.5); + bufferDuration = (MA_REFERENCE_TIME)((10000.0 * 1000 / wf.Format.nSamplesPerSec * bufferSizeInFrames) + 0.5); // Unfortunately we need to release and re-acquire the audio client according to MSDN. Seems silly - why not just call IAudioClient_Initialize() again?! mal_IAudioClient_Release((mal_IAudioClient*)pData->pAudioClient); - #ifdef MAL_WIN32_DESKTOP - hr = mal_IMMDevice_Activate(pDeviceInterface, &MAL_IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&pData->pAudioClient); + #ifdef MA_WIN32_DESKTOP + hr = mal_IMMDevice_Activate(pDeviceInterface, &MA_IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&pData->pAudioClient); #else - hr = mal_IUnknown_QueryInterface(pDeviceInterface, &MAL_IID_IAudioClient, (void**)&pData->pAudioClient); + hr = mal_IUnknown_QueryInterface(pDeviceInterface, &MA_IID_IAudioClient, (void**)&pData->pAudioClient); #endif if (SUCCEEDED(hr)) { - hr = mal_IAudioClient_Initialize((mal_IAudioClient*)pData->pAudioClient, shareMode, MAL_AUDCLNT_STREAMFLAGS_EVENTCALLBACK, bufferDuration, bufferDuration, (WAVEFORMATEX*)&wf, NULL); + hr = mal_IAudioClient_Initialize((mal_IAudioClient*)pData->pAudioClient, shareMode, MA_AUDCLNT_STREAMFLAGS_EVENTCALLBACK, bufferDuration, bufferDuration, (WAVEFORMATEX*)&wf, NULL); } } } @@ -7289,21 +7289,21 @@ mal_result mal_device_init_internal__wasapi(mal_context* pContext, mal_device_ty if (FAILED(hr)) { /* Failed to initialize in exclusive mode. Don't fall back to shared mode - instead tell the client about it. They can reinitialize in shared mode if they want. */ if (hr == E_ACCESSDENIED) { - errorMsg = "[WASAPI] Failed to initialize device in exclusive mode. Access denied.", result = MAL_ACCESS_DENIED; - } else if (hr == MAL_AUDCLNT_E_DEVICE_IN_USE) { - errorMsg = "[WASAPI] Failed to initialize device in exclusive mode. Device in use.", result = MAL_DEVICE_BUSY; + errorMsg = "[WASAPI] Failed to initialize device in exclusive mode. Access denied.", result = MA_ACCESS_DENIED; + } else if (hr == MA_AUDCLNT_E_DEVICE_IN_USE) { + errorMsg = "[WASAPI] Failed to initialize device in exclusive mode. Device in use.", result = MA_DEVICE_BUSY; } else { - errorMsg = "[WASAPI] Failed to initialize device in exclusive mode."; result = MAL_SHARE_MODE_NOT_SUPPORTED; + errorMsg = "[WASAPI] Failed to initialize device in exclusive mode."; result = MA_SHARE_MODE_NOT_SUPPORTED; } goto done; } } - if (shareMode == MAL_AUDCLNT_SHAREMODE_SHARED) { + if (shareMode == MA_AUDCLNT_SHAREMODE_SHARED) { /* Low latency shared mode via IAudioClient3. */ -#ifndef MAL_WASAPI_NO_LOW_LATENCY_SHARED_MODE +#ifndef MA_WASAPI_NO_LOW_LATENCY_SHARED_MODE mal_IAudioClient3* pAudioClient3 = NULL; - hr = mal_IAudioClient_QueryInterface(pData->pAudioClient, &MAL_IID_IAudioClient3, (void**)&pAudioClient3); + hr = mal_IAudioClient_QueryInterface(pData->pAudioClient, &MA_IID_IAudioClient3, (void**)&pAudioClient3); if (SUCCEEDED(hr)) { UINT32 defaultPeriodInFrames; UINT32 fundamentalPeriodInFrames; @@ -7323,9 +7323,9 @@ mal_result mal_device_init_internal__wasapi(mal_context* pContext, mal_device_ty /* If the client requested a largish buffer than we don't actually want to use low latency shared mode because it forces small buffers. */ if (actualPeriodInFrames >= desiredPeriodInFrames) { - hr = mal_IAudioClient3_InitializeSharedAudioStream(pAudioClient3, MAL_AUDCLNT_STREAMFLAGS_EVENTCALLBACK, actualPeriodInFrames, (WAVEFORMATEX*)&wf, NULL); + hr = mal_IAudioClient3_InitializeSharedAudioStream(pAudioClient3, MA_AUDCLNT_STREAMFLAGS_EVENTCALLBACK, actualPeriodInFrames, (WAVEFORMATEX*)&wf, NULL); if (SUCCEEDED(hr)) { - wasInitializedUsingIAudioClient3 = MAL_TRUE; + wasInitializedUsingIAudioClient3 = MA_TRUE; pData->periodSizeInFramesOut = actualPeriodInFrames; pData->bufferSizeInFramesOut = actualPeriodInFrames * pData->periodsOut; } @@ -7339,15 +7339,15 @@ mal_result mal_device_init_internal__wasapi(mal_context* pContext, mal_device_ty // If we don't have an IAudioClient3 then we need to use the normal initialization routine. if (!wasInitializedUsingIAudioClient3) { - MAL_REFERENCE_TIME bufferDuration = bufferDurationInMicroseconds*10; - hr = mal_IAudioClient_Initialize((mal_IAudioClient*)pData->pAudioClient, shareMode, MAL_AUDCLNT_STREAMFLAGS_EVENTCALLBACK, bufferDuration, 0, (WAVEFORMATEX*)&wf, NULL); + MA_REFERENCE_TIME bufferDuration = bufferDurationInMicroseconds*10; + hr = mal_IAudioClient_Initialize((mal_IAudioClient*)pData->pAudioClient, shareMode, MA_AUDCLNT_STREAMFLAGS_EVENTCALLBACK, bufferDuration, 0, (WAVEFORMATEX*)&wf, NULL); if (FAILED(hr)) { if (hr == E_ACCESSDENIED) { - errorMsg = "[WASAPI] Failed to initialize device. Access denied.", result = MAL_ACCESS_DENIED; - } else if (hr == MAL_AUDCLNT_E_DEVICE_IN_USE) { - errorMsg = "[WASAPI] Failed to initialize device. Device in use.", result = MAL_DEVICE_BUSY; + errorMsg = "[WASAPI] Failed to initialize device. Access denied.", result = MA_ACCESS_DENIED; + } else if (hr == MA_AUDCLNT_E_DEVICE_IN_USE) { + errorMsg = "[WASAPI] Failed to initialize device. Device in use.", result = MA_DEVICE_BUSY; } else { - errorMsg = "[WASAPI] Failed to initialize device.", result = MAL_FAILED_TO_OPEN_BACKEND_DEVICE; + errorMsg = "[WASAPI] Failed to initialize device.", result = MA_FAILED_TO_OPEN_BACKEND_DEVICE; } goto done; @@ -7358,7 +7358,7 @@ mal_result mal_device_init_internal__wasapi(mal_context* pContext, mal_device_ty if (!wasInitializedUsingIAudioClient3) { hr = mal_IAudioClient_GetBufferSize((mal_IAudioClient*)pData->pAudioClient, &pData->bufferSizeInFramesOut); if (FAILED(hr)) { - errorMsg = "[WASAPI] Failed to get audio client's actual buffer size.", result = MAL_FAILED_TO_OPEN_BACKEND_DEVICE; + errorMsg = "[WASAPI] Failed to get audio client's actual buffer size.", result = MA_FAILED_TO_OPEN_BACKEND_DEVICE; goto done; } @@ -7366,25 +7366,25 @@ mal_result mal_device_init_internal__wasapi(mal_context* pContext, mal_device_ty } if (deviceType == mal_device_type_playback) { - hr = mal_IAudioClient_GetService((mal_IAudioClient*)pData->pAudioClient, &MAL_IID_IAudioRenderClient, (void**)&pData->pRenderClient); + hr = mal_IAudioClient_GetService((mal_IAudioClient*)pData->pAudioClient, &MA_IID_IAudioRenderClient, (void**)&pData->pRenderClient); } else { - hr = mal_IAudioClient_GetService((mal_IAudioClient*)pData->pAudioClient, &MAL_IID_IAudioCaptureClient, (void**)&pData->pCaptureClient); + hr = mal_IAudioClient_GetService((mal_IAudioClient*)pData->pAudioClient, &MA_IID_IAudioCaptureClient, (void**)&pData->pCaptureClient); } if (FAILED(hr)) { - errorMsg = "[WASAPI] Failed to get audio client service.", result = MAL_API_NOT_FOUND; + errorMsg = "[WASAPI] Failed to get audio client service.", result = MA_API_NOT_FOUND; goto done; } // Grab the name of the device. -#ifdef MAL_WIN32_DESKTOP +#ifdef MA_WIN32_DESKTOP mal_IPropertyStore *pProperties; hr = mal_IMMDevice_OpenPropertyStore(pDeviceInterface, STGM_READ, &pProperties); if (SUCCEEDED(hr)) { PROPVARIANT varName; mal_PropVariantInit(&varName); - hr = mal_IPropertyStore_GetValue(pProperties, &MAL_PKEY_Device_FriendlyName, &varName); + hr = mal_IPropertyStore_GetValue(pProperties, &MA_PKEY_Device_FriendlyName, &varName); if (SUCCEEDED(hr)) { WideCharToMultiByte(CP_UTF8, 0, varName.pwszVal, -1, pData->deviceName, sizeof(pData->deviceName), 0, FALSE); mal_PropVariantClear(pContext, &varName); @@ -7396,7 +7396,7 @@ mal_result mal_device_init_internal__wasapi(mal_context* pContext, mal_device_ty done: // Clean up. -#ifdef MAL_WIN32_DESKTOP +#ifdef MA_WIN32_DESKTOP if (pDeviceInterface != NULL) { mal_IMMDevice_Release(pDeviceInterface); } @@ -7406,7 +7406,7 @@ done: } #endif - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { if (pData->pRenderClient) { mal_IAudioRenderClient_Release((mal_IAudioRenderClient*)pData->pRenderClient); pData->pRenderClient = NULL; @@ -7420,9 +7420,9 @@ done: pData->pAudioClient = NULL; } - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, errorMsg, result); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, errorMsg, result); } else { - return MAL_SUCCESS; + return MA_SUCCESS; } } @@ -7432,7 +7432,7 @@ mal_result mal_device_reinit__wasapi(mal_device* pDevice, mal_device_type device // We only re-initialize the playback or capture device. Never a full-duplex device. if (deviceType == mal_device_type_duplex) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_device_init_internal_data__wasapi data; @@ -7460,7 +7460,7 @@ mal_result mal_device_reinit__wasapi(mal_device* pDevice, mal_device_type device data.bufferSizeInMillisecondsIn = pDevice->wasapi.originalBufferSizeInMilliseconds; data.periodsIn = pDevice->wasapi.originalPeriods; mal_result result = mal_device_init_internal__wasapi(pDevice->pContext, deviceType, NULL, &data); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -7496,7 +7496,7 @@ mal_result mal_device_reinit__wasapi(mal_device* pDevice, mal_device_type device if (pDevice->wasapi.isStartedCapture) { HRESULT hr = mal_IAudioClient_Start((mal_IAudioClient*)pDevice->wasapi.pAudioClientCapture); if (FAILED(hr)) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal capture device after reinitialization.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal capture device after reinitialization.", MA_FAILED_TO_START_BACKEND_DEVICE); } } } @@ -7532,17 +7532,17 @@ mal_result mal_device_reinit__wasapi(mal_device* pDevice, mal_device_type device if (pDevice->wasapi.isStartedPlayback) { HRESULT hr = mal_IAudioClient_Start((mal_IAudioClient*)pDevice->wasapi.pAudioClientPlayback); if (FAILED(hr)) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal playback device after reinitialization.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal playback device after reinitialization.", MA_FAILED_TO_START_BACKEND_DEVICE); } } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_init__wasapi(mal_context* pContext, const mal_device_config* pConfig, mal_device* pDevice) { - mal_result result = MAL_SUCCESS; + mal_result result = MA_SUCCESS; const char* errorMsg = ""; (void)pContext; @@ -7571,7 +7571,7 @@ mal_result mal_device_init__wasapi(mal_context* pContext, const mal_device_confi data.periodsIn = pConfig->periods; result = mal_device_init_internal__wasapi(pDevice->pContext, mal_device_type_capture, pConfig->capture.pDeviceID, &data); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -7601,7 +7601,7 @@ mal_result mal_device_init__wasapi(mal_context* pContext, const mal_device_confi pDevice->wasapi.pAudioClientCapture = NULL; } - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for capture.", MAL_FAILED_TO_CREATE_EVENT); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for capture.", MA_FAILED_TO_CREATE_EVENT); } mal_IAudioClient_SetEventHandle((mal_IAudioClient*)pDevice->wasapi.pAudioClientCapture, pDevice->wasapi.hEventCapture); @@ -7625,7 +7625,7 @@ mal_result mal_device_init__wasapi(mal_context* pContext, const mal_device_confi data.periodsIn = pConfig->periods; result = mal_device_init_internal__wasapi(pDevice->pContext, mal_device_type_playback, pConfig->playback.pDeviceID, &data); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { if (pConfig->deviceType == mal_device_type_duplex) { if (pDevice->wasapi.pCaptureClient != NULL) { mal_IAudioCaptureClient_Release((mal_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient); @@ -7685,7 +7685,7 @@ mal_result mal_device_init__wasapi(mal_context* pContext, const mal_device_confi pDevice->wasapi.pAudioClientPlayback = NULL; } - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for playback.", MAL_FAILED_TO_CREATE_EVENT); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to create event for playback.", MA_FAILED_TO_CREATE_EVENT); } mal_IAudioClient_SetEventHandle((mal_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, pDevice->wasapi.hEventPlayback); @@ -7696,11 +7696,11 @@ mal_result mal_device_init__wasapi(mal_context* pContext, const mal_device_confi // We need to get notifications of when the default device changes. We do this through a device enumerator by // registering a IMMNotificationClient with it. We only care about this if it's the default device. -#ifdef MAL_WIN32_DESKTOP +#ifdef MA_WIN32_DESKTOP mal_IMMDeviceEnumerator* pDeviceEnumerator; - HRESULT hr = mal_CoCreateInstance(pContext, MAL_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MAL_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); + HRESULT hr = mal_CoCreateInstance(pContext, MA_CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, MA_IID_IMMDeviceEnumerator, (void**)&pDeviceEnumerator); if (FAILED(hr)) { - errorMsg = "[WASAPI] Failed to create device enumerator.", result = MAL_FAILED_TO_OPEN_BACKEND_DEVICE; + errorMsg = "[WASAPI] Failed to create device enumerator.", result = MA_FAILED_TO_OPEN_BACKEND_DEVICE; goto done; } @@ -7717,18 +7717,18 @@ mal_result mal_device_init__wasapi(mal_context* pContext, const mal_device_confi } #endif - mal_atomic_exchange_32(&pDevice->wasapi.isStartedCapture, MAL_FALSE); - mal_atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MAL_FALSE); + mal_atomic_exchange_32(&pDevice->wasapi.isStartedCapture, MA_FALSE); + mal_atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MA_FALSE); - result = MAL_SUCCESS; + result = MA_SUCCESS; done: // Clean up. - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { mal_device_uninit__wasapi(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, errorMsg, result); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, errorMsg, result); } else { - return MAL_SUCCESS; + return MA_SUCCESS; } } @@ -7740,13 +7740,13 @@ mal_result mal_device__get_available_frames__wasapi(mal_device* pDevice, mal_IAu *pFrameCount = 0; if ((mal_ptr)pAudioClient != pDevice->wasapi.pAudioClientPlayback && (mal_ptr)pAudioClient != pDevice->wasapi.pAudioClientCapture) { - return MAL_INVALID_OPERATION; + return MA_INVALID_OPERATION; } mal_uint32 paddingFramesCount; HRESULT hr = mal_IAudioClient_GetCurrentPadding(pAudioClient, &paddingFramesCount); if (FAILED(hr)) { - return MAL_DEVICE_UNAVAILABLE; + return MA_DEVICE_UNAVAILABLE; } // Slightly different rules for exclusive and shared modes. @@ -7761,7 +7761,7 @@ mal_result mal_device__get_available_frames__wasapi(mal_device* pDevice, mal_IAu } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_bool32 mal_device_is_reroute_required__wasapi(mal_device* pDevice, mal_device_type deviceType) @@ -7776,35 +7776,35 @@ mal_bool32 mal_device_is_reroute_required__wasapi(mal_device* pDevice, mal_devic return pDevice->wasapi.hasDefaultCaptureDeviceChanged; } - return MAL_FALSE; + return MA_FALSE; } mal_result mal_device_reroute__wasapi(mal_device* pDevice, mal_device_type deviceType) { if (deviceType == mal_device_type_duplex) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } if (deviceType == mal_device_type_playback) { - mal_atomic_exchange_32(&pDevice->wasapi.hasDefaultPlaybackDeviceChanged, MAL_FALSE); + mal_atomic_exchange_32(&pDevice->wasapi.hasDefaultPlaybackDeviceChanged, MA_FALSE); } if (deviceType == mal_device_type_capture) { - mal_atomic_exchange_32(&pDevice->wasapi.hasDefaultCaptureDeviceChanged, MAL_FALSE); + mal_atomic_exchange_32(&pDevice->wasapi.hasDefaultCaptureDeviceChanged, MA_FALSE); } - #ifdef MAL_DEBUG_OUTPUT + #ifdef MA_DEBUG_OUTPUT printf("=== CHANGING DEVICE ===\n"); #endif mal_result result = mal_device_reinit__wasapi(pDevice, deviceType); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } mal_device__post_init_setup(pDevice, deviceType); - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -7812,7 +7812,7 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) { mal_result result; HRESULT hr; - mal_bool32 exitLoop = MAL_FALSE; + mal_bool32 exitLoop = MA_FALSE; mal_uint32 framesWrittenToPlaybackDevice = 0; mal_uint32 mappedBufferSizeInFramesCapture = 0; mal_uint32 mappedBufferSizeInFramesPlayback = 0; @@ -7833,24 +7833,24 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { hr = mal_IAudioClient_Start((mal_IAudioClient*)pDevice->wasapi.pAudioClientCapture); if (FAILED(hr)) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal capture device.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal capture device.", MA_FAILED_TO_START_BACKEND_DEVICE); } - mal_atomic_exchange_32(&pDevice->wasapi.isStartedCapture, MAL_TRUE); + mal_atomic_exchange_32(&pDevice->wasapi.isStartedCapture, MA_TRUE); } - while (mal_device__get_state(pDevice) == MAL_STATE_STARTED && !exitLoop) { + while (mal_device__get_state(pDevice) == MA_STATE_STARTED && !exitLoop) { /* We may need to reroute the device. */ if (mal_device_is_reroute_required__wasapi(pDevice, mal_device_type_playback)) { result = mal_device_reroute__wasapi(pDevice, mal_device_type_playback); - if (result != MAL_SUCCESS) { - exitLoop = MAL_TRUE; + if (result != MA_SUCCESS) { + exitLoop = MA_TRUE; break; } } if (mal_device_is_reroute_required__wasapi(pDevice, mal_device_type_capture)) { result = mal_device_reroute__wasapi(pDevice, mal_device_type_capture); - if (result != MAL_SUCCESS) { - exitLoop = MAL_TRUE; + if (result != MA_SUCCESS) { + exitLoop = MA_TRUE; break; } } @@ -7868,12 +7868,12 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) /* WASAPI is weird with exclusive mode. You need to wait on the event _before_ querying the available frames. */ if (pDevice->playback.shareMode == mal_share_mode_exclusive) { if (WaitForSingleObject(pDevice->wasapi.hEventPlayback, INFINITE) == WAIT_FAILED) { - return MAL_ERROR; /* Wait failed. */ + return MA_ERROR; /* Wait failed. */ } } result = mal_device__get_available_frames__wasapi(pDevice, (mal_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &framesAvailablePlayback); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -7892,7 +7892,7 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) /* In exclusive mode we waited at the top. */ if (pDevice->playback.shareMode != mal_share_mode_exclusive) { if (WaitForSingleObject(pDevice->wasapi.hEventPlayback, INFINITE) == WAIT_FAILED) { - return MAL_ERROR; /* Wait failed. */ + return MA_ERROR; /* Wait failed. */ } } @@ -7902,8 +7902,8 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) /* We're ready to map the playback device's buffer. We don't release this until it's been entirely filled. */ hr = mal_IAudioRenderClient_GetBuffer((mal_IAudioRenderClient*)pDevice->wasapi.pRenderClient, framesAvailablePlayback, &pMappedBufferPlayback); if (FAILED(hr)) { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from playback device in preparation for writing to the device.", MAL_FAILED_TO_MAP_DEVICE_BUFFER); - exitLoop = MAL_TRUE; + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from playback device in preparation for writing to the device.", MA_FAILED_TO_MAP_DEVICE_BUFFER); + exitLoop = MA_TRUE; break; } @@ -7917,13 +7917,13 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) if (pMappedBufferCapture == NULL) { if (pDevice->capture.shareMode == mal_share_mode_shared) { if (WaitForSingleObject(pDevice->wasapi.hEventCapture, INFINITE) == WAIT_FAILED) { - return MAL_ERROR; /* Wait failed. */ + return MA_ERROR; /* Wait failed. */ } } result = mal_device__get_available_frames__wasapi(pDevice, (mal_IAudioClient*)pDevice->wasapi.pAudioClientCapture, &framesAvailableCapture); - if (result != MAL_SUCCESS) { - exitLoop = MAL_TRUE; + if (result != MA_SUCCESS) { + exitLoop = MA_TRUE; break; } @@ -7934,7 +7934,7 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) /* In exclusive mode we waited at the top. */ if (pDevice->capture.shareMode != mal_share_mode_shared) { if (WaitForSingleObject(pDevice->wasapi.hEventCapture, INFINITE) == WAIT_FAILED) { - return MAL_ERROR; /* Wait failed. */ + return MA_ERROR; /* Wait failed. */ } } @@ -7945,13 +7945,13 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) mappedBufferSizeInFramesCapture = framesAvailableCapture; hr = mal_IAudioCaptureClient_GetBuffer((mal_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pMappedBufferCapture, &mappedBufferSizeInFramesCapture, &flagsCapture, NULL, NULL); if (FAILED(hr)) { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from capture device in preparation for writing to the device.", MAL_FAILED_TO_MAP_DEVICE_BUFFER); - exitLoop = MAL_TRUE; + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from capture device in preparation for writing to the device.", MA_FAILED_TO_MAP_DEVICE_BUFFER); + exitLoop = MA_TRUE; break; } /* TODO: How do we handle the capture flags returned by GetBuffer()? In particular, AUDCLNT_BUFFERFLAGS_SILENT (1). */ - #ifdef MAL_DEBUG_OUTPUT + #ifdef MA_DEBUG_OUTPUT if (flagsCapture != 0) { printf("[WASAPI] Capture Flags: %d\n", flagsCapture); } @@ -8067,8 +8067,8 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) if (mappedBufferFramesRemainingCapture == 0 && pMappedBufferCapture != NULL) { hr = mal_IAudioCaptureClient_ReleaseBuffer((mal_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, mappedBufferSizeInFramesCapture); if (FAILED(hr)) { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to release internal buffer from capture device after reading from the device.", MAL_FAILED_TO_UNMAP_DEVICE_BUFFER); - exitLoop = MAL_TRUE; + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to release internal buffer from capture device after reading from the device.", MA_FAILED_TO_UNMAP_DEVICE_BUFFER); + exitLoop = MA_TRUE; break; } @@ -8090,8 +8090,8 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) if (mappedBufferFramesRemainingPlayback == 0 && pMappedBufferPlayback != NULL) { hr = mal_IAudioRenderClient_ReleaseBuffer((mal_IAudioRenderClient*)pDevice->wasapi.pRenderClient, mappedBufferSizeInFramesPlayback, 0); if (FAILED(hr)) { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to release internal buffer from playback device after writing to the device.", MAL_FAILED_TO_UNMAP_DEVICE_BUFFER); - exitLoop = MAL_TRUE; + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to release internal buffer from playback device after writing to the device.", MA_FAILED_TO_UNMAP_DEVICE_BUFFER); + exitLoop = MA_TRUE; break; } @@ -8109,9 +8109,9 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) if (FAILED(hr)) { mal_IAudioClient_Stop((mal_IAudioClient*)pDevice->wasapi.pAudioClientCapture); mal_IAudioClient_Reset((mal_IAudioClient*)pDevice->wasapi.pAudioClientCapture); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal playback device.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal playback device.", MA_FAILED_TO_START_BACKEND_DEVICE); } - mal_atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MAL_TRUE); + mal_atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MA_TRUE); } } } break; @@ -8125,14 +8125,14 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) /* Wait for data to become available first. */ if (WaitForSingleObject(pDevice->wasapi.hEventCapture, INFINITE) == WAIT_FAILED) { - exitLoop = MAL_TRUE; + exitLoop = MA_TRUE; break; /* Wait failed. */ } /* See how many frames are available. Since we waited at the top, I don't think this should ever return 0. I'm checking for this anyway. */ result = mal_device__get_available_frames__wasapi(pDevice, (mal_IAudioClient*)pDevice->wasapi.pAudioClientCapture, &framesAvailableCapture); - if (result != MAL_SUCCESS) { - exitLoop = MAL_TRUE; + if (result != MA_SUCCESS) { + exitLoop = MA_TRUE; break; } @@ -8144,8 +8144,8 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) mappedBufferSizeInFramesCapture = framesAvailableCapture; hr = mal_IAudioCaptureClient_GetBuffer((mal_IAudioCaptureClient*)pDevice->wasapi.pCaptureClient, (BYTE**)&pMappedBufferCapture, &mappedBufferSizeInFramesCapture, &flagsCapture, NULL, NULL); if (FAILED(hr)) { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from capture device in preparation for writing to the device.", MAL_FAILED_TO_MAP_DEVICE_BUFFER); - exitLoop = MAL_TRUE; + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from capture device in preparation for writing to the device.", MA_FAILED_TO_MAP_DEVICE_BUFFER); + exitLoop = MA_TRUE; break; } @@ -8161,8 +8161,8 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) pMappedBufferCapture = NULL; /* <-- Important. Not doing this can result in an error once we leave this loop because it will use this to know whether or not a final ReleaseBuffer() needs to be called. */ mappedBufferSizeInFramesCapture = 0; if (FAILED(hr)) { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to release internal buffer from capture device after reading from the device.", MAL_FAILED_TO_UNMAP_DEVICE_BUFFER); - exitLoop = MAL_TRUE; + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to release internal buffer from capture device after reading from the device.", MA_FAILED_TO_UNMAP_DEVICE_BUFFER); + exitLoop = MA_TRUE; break; } } break; @@ -8175,14 +8175,14 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) /* Wait for space to become available first. */ if (WaitForSingleObject(pDevice->wasapi.hEventPlayback, INFINITE) == WAIT_FAILED) { - exitLoop = MAL_TRUE; + exitLoop = MA_TRUE; break; /* Wait failed. */ } /* Check how much space is available. If this returns 0 we just keep waiting. */ result = mal_device__get_available_frames__wasapi(pDevice, (mal_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &framesAvailablePlayback); - if (result != MAL_SUCCESS) { - exitLoop = MAL_TRUE; + if (result != MA_SUCCESS) { + exitLoop = MA_TRUE; break; } @@ -8193,8 +8193,8 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) /* Map a the data buffer in preparation for the callback. */ hr = mal_IAudioRenderClient_GetBuffer((mal_IAudioRenderClient*)pDevice->wasapi.pRenderClient, framesAvailablePlayback, &pMappedBufferPlayback); if (FAILED(hr)) { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from playback device in preparation for writing to the device.", MAL_FAILED_TO_MAP_DEVICE_BUFFER); - exitLoop = MAL_TRUE; + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to retrieve internal buffer from playback device in preparation for writing to the device.", MA_FAILED_TO_MAP_DEVICE_BUFFER); + exitLoop = MA_TRUE; break; } @@ -8210,8 +8210,8 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) mappedBufferSizeInFramesPlayback = 0; if (FAILED(hr)) { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to release internal buffer from playback device after writing to the device.", MAL_FAILED_TO_UNMAP_DEVICE_BUFFER); - exitLoop = MAL_TRUE; + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to release internal buffer from playback device after writing to the device.", MA_FAILED_TO_UNMAP_DEVICE_BUFFER); + exitLoop = MA_TRUE; break; } @@ -8220,16 +8220,16 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) if (pDevice->playback.shareMode == mal_share_mode_exclusive || framesWrittenToPlaybackDevice >= (pDevice->playback.internalBufferSizeInFrames/pDevice->playback.internalPeriods)*1) { hr = mal_IAudioClient_Start((mal_IAudioClient*)pDevice->wasapi.pAudioClientPlayback); if (FAILED(hr)) { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal playback device.", MAL_FAILED_TO_START_BACKEND_DEVICE); - exitLoop = MAL_TRUE; + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to start internal playback device.", MA_FAILED_TO_START_BACKEND_DEVICE); + exitLoop = MA_TRUE; break; } - mal_atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MAL_TRUE); + mal_atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MA_TRUE); } } } break; - default: MAL_INVALID_ARGS; + default: MA_INVALID_ARGS; } } @@ -8242,16 +8242,16 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) hr = mal_IAudioClient_Stop((mal_IAudioClient*)pDevice->wasapi.pAudioClientCapture); if (FAILED(hr)) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to stop internal capture device.", MAL_FAILED_TO_STOP_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to stop internal capture device.", MA_FAILED_TO_STOP_BACKEND_DEVICE); } /* The audio client needs to be reset otherwise restarting will fail. */ hr = mal_IAudioClient_Reset((mal_IAudioClient*)pDevice->wasapi.pAudioClientCapture); if (FAILED(hr)) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to reset internal capture device.", MAL_FAILED_TO_STOP_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to reset internal capture device.", MA_FAILED_TO_STOP_BACKEND_DEVICE); } - mal_atomic_exchange_32(&pDevice->wasapi.isStartedCapture, MAL_FALSE); + mal_atomic_exchange_32(&pDevice->wasapi.isStartedCapture, MA_FALSE); } if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) { @@ -8272,7 +8272,7 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) mal_uint32 framesAvailablePlayback; for (;;) { result = mal_device__get_available_frames__wasapi(pDevice, (mal_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &framesAvailablePlayback); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { break; } @@ -8297,19 +8297,19 @@ mal_result mal_device_main_loop__wasapi(mal_device* pDevice) hr = mal_IAudioClient_Stop((mal_IAudioClient*)pDevice->wasapi.pAudioClientPlayback); if (FAILED(hr)) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to stop internal playback device.", MAL_FAILED_TO_STOP_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to stop internal playback device.", MA_FAILED_TO_STOP_BACKEND_DEVICE); } /* The audio client needs to be reset otherwise restarting will fail. */ hr = mal_IAudioClient_Reset((mal_IAudioClient*)pDevice->wasapi.pAudioClientPlayback); if (FAILED(hr)) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WASAPI] Failed to reset internal playback device.", MAL_FAILED_TO_STOP_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WASAPI] Failed to reset internal playback device.", MA_FAILED_TO_STOP_BACKEND_DEVICE); } - mal_atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MAL_FALSE); + mal_atomic_exchange_32(&pDevice->wasapi.isStartedPlayback, MA_FALSE); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_uninit__wasapi(mal_context* pContext) @@ -8318,7 +8318,7 @@ mal_result mal_context_uninit__wasapi(mal_context* pContext) mal_assert(pContext->backend == mal_backend_wasapi); (void)pContext; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_init__wasapi(mal_context* pContext) @@ -8326,9 +8326,9 @@ mal_result mal_context_init__wasapi(mal_context* pContext) mal_assert(pContext != NULL); (void)pContext; - mal_result result = MAL_SUCCESS; + mal_result result = MA_SUCCESS; -#ifdef MAL_WIN32_DESKTOP +#ifdef MA_WIN32_DESKTOP // WASAPI is only supported in Vista SP1 and newer. The reason for SP1 and not the base version of Vista is that event-driven // exclusive mode does not work until SP1. mal_OSVERSIONINFOEXW osvi; @@ -8338,13 +8338,13 @@ mal_result mal_context_init__wasapi(mal_context* pContext) osvi.dwMinorVersion = LOBYTE(_WIN32_WINNT_VISTA); osvi.wServicePackMajor = 1; if (VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, VerSetConditionMask(VerSetConditionMask(VerSetConditionMask(0, VER_MAJORVERSION, VER_GREATER_EQUAL), VER_MINORVERSION, VER_GREATER_EQUAL), VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL))) { - result = MAL_SUCCESS; + result = MA_SUCCESS; } else { - result = MAL_NO_BACKEND; + result = MA_NO_BACKEND; } #endif - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -8369,54 +8369,54 @@ mal_result mal_context_init__wasapi(mal_context* pContext) // DirectSound Backend // /////////////////////////////////////////////////////////////////////////////// -#ifdef MAL_HAS_DSOUND +#ifdef MA_HAS_DSOUND //#include -GUID MAL_GUID_IID_DirectSoundNotify = {0xb0210783, 0x89cd, 0x11d0, {0xaf, 0x08, 0x00, 0xa0, 0xc9, 0x25, 0xcd, 0x16}}; +GUID MA_GUID_IID_DirectSoundNotify = {0xb0210783, 0x89cd, 0x11d0, {0xaf, 0x08, 0x00, 0xa0, 0xc9, 0x25, 0xcd, 0x16}}; // miniaudio only uses priority or exclusive modes. -#define MAL_DSSCL_NORMAL 1 -#define MAL_DSSCL_PRIORITY 2 -#define MAL_DSSCL_EXCLUSIVE 3 -#define MAL_DSSCL_WRITEPRIMARY 4 +#define MA_DSSCL_NORMAL 1 +#define MA_DSSCL_PRIORITY 2 +#define MA_DSSCL_EXCLUSIVE 3 +#define MA_DSSCL_WRITEPRIMARY 4 -#define MAL_DSCAPS_PRIMARYMONO 0x00000001 -#define MAL_DSCAPS_PRIMARYSTEREO 0x00000002 -#define MAL_DSCAPS_PRIMARY8BIT 0x00000004 -#define MAL_DSCAPS_PRIMARY16BIT 0x00000008 -#define MAL_DSCAPS_CONTINUOUSRATE 0x00000010 -#define MAL_DSCAPS_EMULDRIVER 0x00000020 -#define MAL_DSCAPS_CERTIFIED 0x00000040 -#define MAL_DSCAPS_SECONDARYMONO 0x00000100 -#define MAL_DSCAPS_SECONDARYSTEREO 0x00000200 -#define MAL_DSCAPS_SECONDARY8BIT 0x00000400 -#define MAL_DSCAPS_SECONDARY16BIT 0x00000800 +#define MA_DSCAPS_PRIMARYMONO 0x00000001 +#define MA_DSCAPS_PRIMARYSTEREO 0x00000002 +#define MA_DSCAPS_PRIMARY8BIT 0x00000004 +#define MA_DSCAPS_PRIMARY16BIT 0x00000008 +#define MA_DSCAPS_CONTINUOUSRATE 0x00000010 +#define MA_DSCAPS_EMULDRIVER 0x00000020 +#define MA_DSCAPS_CERTIFIED 0x00000040 +#define MA_DSCAPS_SECONDARYMONO 0x00000100 +#define MA_DSCAPS_SECONDARYSTEREO 0x00000200 +#define MA_DSCAPS_SECONDARY8BIT 0x00000400 +#define MA_DSCAPS_SECONDARY16BIT 0x00000800 -#define MAL_DSBCAPS_PRIMARYBUFFER 0x00000001 -#define MAL_DSBCAPS_STATIC 0x00000002 -#define MAL_DSBCAPS_LOCHARDWARE 0x00000004 -#define MAL_DSBCAPS_LOCSOFTWARE 0x00000008 -#define MAL_DSBCAPS_CTRL3D 0x00000010 -#define MAL_DSBCAPS_CTRLFREQUENCY 0x00000020 -#define MAL_DSBCAPS_CTRLPAN 0x00000040 -#define MAL_DSBCAPS_CTRLVOLUME 0x00000080 -#define MAL_DSBCAPS_CTRLPOSITIONNOTIFY 0x00000100 -#define MAL_DSBCAPS_CTRLFX 0x00000200 -#define MAL_DSBCAPS_STICKYFOCUS 0x00004000 -#define MAL_DSBCAPS_GLOBALFOCUS 0x00008000 -#define MAL_DSBCAPS_GETCURRENTPOSITION2 0x00010000 -#define MAL_DSBCAPS_MUTE3DATMAXDISTANCE 0x00020000 -#define MAL_DSBCAPS_LOCDEFER 0x00040000 -#define MAL_DSBCAPS_TRUEPLAYPOSITION 0x00080000 +#define MA_DSBCAPS_PRIMARYBUFFER 0x00000001 +#define MA_DSBCAPS_STATIC 0x00000002 +#define MA_DSBCAPS_LOCHARDWARE 0x00000004 +#define MA_DSBCAPS_LOCSOFTWARE 0x00000008 +#define MA_DSBCAPS_CTRL3D 0x00000010 +#define MA_DSBCAPS_CTRLFREQUENCY 0x00000020 +#define MA_DSBCAPS_CTRLPAN 0x00000040 +#define MA_DSBCAPS_CTRLVOLUME 0x00000080 +#define MA_DSBCAPS_CTRLPOSITIONNOTIFY 0x00000100 +#define MA_DSBCAPS_CTRLFX 0x00000200 +#define MA_DSBCAPS_STICKYFOCUS 0x00004000 +#define MA_DSBCAPS_GLOBALFOCUS 0x00008000 +#define MA_DSBCAPS_GETCURRENTPOSITION2 0x00010000 +#define MA_DSBCAPS_MUTE3DATMAXDISTANCE 0x00020000 +#define MA_DSBCAPS_LOCDEFER 0x00040000 +#define MA_DSBCAPS_TRUEPLAYPOSITION 0x00080000 -#define MAL_DSBPLAY_LOOPING 0x00000001 -#define MAL_DSBPLAY_LOCHARDWARE 0x00000002 -#define MAL_DSBPLAY_LOCSOFTWARE 0x00000004 -#define MAL_DSBPLAY_TERMINATEBY_TIME 0x00000008 -#define MAL_DSBPLAY_TERMINATEBY_DISTANCE 0x00000010 -#define MAL_DSBPLAY_TERMINATEBY_PRIORITY 0x00000020 +#define MA_DSBPLAY_LOOPING 0x00000001 +#define MA_DSBPLAY_LOCHARDWARE 0x00000002 +#define MA_DSBPLAY_LOCSOFTWARE 0x00000004 +#define MA_DSBPLAY_TERMINATEBY_TIME 0x00000008 +#define MA_DSBPLAY_TERMINATEBY_DISTANCE 0x00000010 +#define MA_DSBPLAY_TERMINATEBY_PRIORITY 0x00000020 -#define MAL_DSCBSTART_LOOPING 0x00000001 +#define MA_DSCBSTART_LOOPING 0x00000001 typedef struct { @@ -8426,7 +8426,7 @@ typedef struct DWORD dwReserved; WAVEFORMATEX* lpwfxFormat; GUID guid3DAlgorithm; -} MAL_DSBUFFERDESC; +} MA_DSBUFFERDESC; typedef struct { @@ -8437,7 +8437,7 @@ typedef struct WAVEFORMATEX* lpwfxFormat; DWORD dwFXCount; void* lpDSCFXDesc; // <-- miniaudio doesn't use this, so set to void*. -} MAL_DSCBUFFERDESC; +} MA_DSCBUFFERDESC; typedef struct { @@ -8465,7 +8465,7 @@ typedef struct DWORD dwPlayCpuOverheadSwBuffers; DWORD dwReserved1; DWORD dwReserved2; -} MAL_DSCAPS; +} MA_DSCAPS; typedef struct { @@ -8474,7 +8474,7 @@ typedef struct DWORD dwBufferBytes; DWORD dwUnlockTransferRate; DWORD dwPlayCpuOverhead; -} MAL_DSBCAPS; +} MA_DSBCAPS; typedef struct { @@ -8482,7 +8482,7 @@ typedef struct DWORD dwFlags; DWORD dwFormats; DWORD dwChannels; -} MAL_DSCCAPS; +} MA_DSCCAPS; typedef struct { @@ -8490,13 +8490,13 @@ typedef struct DWORD dwFlags; DWORD dwBufferBytes; DWORD dwReserved; -} MAL_DSCBCAPS; +} MA_DSCBCAPS; typedef struct { DWORD dwOffset; HANDLE hEventNotify; -} MAL_DSBPOSITIONNOTIFY; +} MA_DSBPOSITIONNOTIFY; typedef struct mal_IDirectSound mal_IDirectSound; typedef struct mal_IDirectSoundBuffer mal_IDirectSoundBuffer; @@ -8519,8 +8519,8 @@ typedef struct ULONG (STDMETHODCALLTYPE * Release) (mal_IDirectSound* pThis); // IDirectSound - HRESULT (STDMETHODCALLTYPE * CreateSoundBuffer) (mal_IDirectSound* pThis, const MAL_DSBUFFERDESC* pDSBufferDesc, mal_IDirectSoundBuffer** ppDSBuffer, void* pUnkOuter); - HRESULT (STDMETHODCALLTYPE * GetCaps) (mal_IDirectSound* pThis, MAL_DSCAPS* pDSCaps); + HRESULT (STDMETHODCALLTYPE * CreateSoundBuffer) (mal_IDirectSound* pThis, const MA_DSBUFFERDESC* pDSBufferDesc, mal_IDirectSoundBuffer** ppDSBuffer, void* pUnkOuter); + HRESULT (STDMETHODCALLTYPE * GetCaps) (mal_IDirectSound* pThis, MA_DSCAPS* pDSCaps); HRESULT (STDMETHODCALLTYPE * DuplicateSoundBuffer)(mal_IDirectSound* pThis, mal_IDirectSoundBuffer* pDSBufferOriginal, mal_IDirectSoundBuffer** ppDSBufferDuplicate); HRESULT (STDMETHODCALLTYPE * SetCooperativeLevel) (mal_IDirectSound* pThis, HWND hwnd, DWORD dwLevel); HRESULT (STDMETHODCALLTYPE * Compact) (mal_IDirectSound* pThis); @@ -8535,8 +8535,8 @@ struct mal_IDirectSound HRESULT mal_IDirectSound_QueryInterface(mal_IDirectSound* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } ULONG mal_IDirectSound_AddRef(mal_IDirectSound* pThis) { return pThis->lpVtbl->AddRef(pThis); } ULONG mal_IDirectSound_Release(mal_IDirectSound* pThis) { return pThis->lpVtbl->Release(pThis); } -HRESULT mal_IDirectSound_CreateSoundBuffer(mal_IDirectSound* pThis, const MAL_DSBUFFERDESC* pDSBufferDesc, mal_IDirectSoundBuffer** ppDSBuffer, void* pUnkOuter) { return pThis->lpVtbl->CreateSoundBuffer(pThis, pDSBufferDesc, ppDSBuffer, pUnkOuter); } -HRESULT mal_IDirectSound_GetCaps(mal_IDirectSound* pThis, MAL_DSCAPS* pDSCaps) { return pThis->lpVtbl->GetCaps(pThis, pDSCaps); } +HRESULT mal_IDirectSound_CreateSoundBuffer(mal_IDirectSound* pThis, const MA_DSBUFFERDESC* pDSBufferDesc, mal_IDirectSoundBuffer** ppDSBuffer, void* pUnkOuter) { return pThis->lpVtbl->CreateSoundBuffer(pThis, pDSBufferDesc, ppDSBuffer, pUnkOuter); } +HRESULT mal_IDirectSound_GetCaps(mal_IDirectSound* pThis, MA_DSCAPS* pDSCaps) { return pThis->lpVtbl->GetCaps(pThis, pDSCaps); } HRESULT mal_IDirectSound_DuplicateSoundBuffer(mal_IDirectSound* pThis, mal_IDirectSoundBuffer* pDSBufferOriginal, mal_IDirectSoundBuffer** ppDSBufferDuplicate) { return pThis->lpVtbl->DuplicateSoundBuffer(pThis, pDSBufferOriginal, ppDSBufferDuplicate); } HRESULT mal_IDirectSound_SetCooperativeLevel(mal_IDirectSound* pThis, HWND hwnd, DWORD dwLevel) { return pThis->lpVtbl->SetCooperativeLevel(pThis, hwnd, dwLevel); } HRESULT mal_IDirectSound_Compact(mal_IDirectSound* pThis) { return pThis->lpVtbl->Compact(pThis); } @@ -8554,14 +8554,14 @@ typedef struct ULONG (STDMETHODCALLTYPE * Release) (mal_IDirectSoundBuffer* pThis); // IDirectSoundBuffer - HRESULT (STDMETHODCALLTYPE * GetCaps) (mal_IDirectSoundBuffer* pThis, MAL_DSBCAPS* pDSBufferCaps); + HRESULT (STDMETHODCALLTYPE * GetCaps) (mal_IDirectSoundBuffer* pThis, MA_DSBCAPS* pDSBufferCaps); HRESULT (STDMETHODCALLTYPE * GetCurrentPosition)(mal_IDirectSoundBuffer* pThis, DWORD* pCurrentPlayCursor, DWORD* pCurrentWriteCursor); HRESULT (STDMETHODCALLTYPE * GetFormat) (mal_IDirectSoundBuffer* pThis, WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten); HRESULT (STDMETHODCALLTYPE * GetVolume) (mal_IDirectSoundBuffer* pThis, LONG* pVolume); HRESULT (STDMETHODCALLTYPE * GetPan) (mal_IDirectSoundBuffer* pThis, LONG* pPan); HRESULT (STDMETHODCALLTYPE * GetFrequency) (mal_IDirectSoundBuffer* pThis, DWORD* pFrequency); HRESULT (STDMETHODCALLTYPE * GetStatus) (mal_IDirectSoundBuffer* pThis, DWORD* pStatus); - HRESULT (STDMETHODCALLTYPE * Initialize) (mal_IDirectSoundBuffer* pThis, mal_IDirectSound* pDirectSound, const MAL_DSBUFFERDESC* pDSBufferDesc); + HRESULT (STDMETHODCALLTYPE * Initialize) (mal_IDirectSoundBuffer* pThis, mal_IDirectSound* pDirectSound, const MA_DSBUFFERDESC* pDSBufferDesc); HRESULT (STDMETHODCALLTYPE * Lock) (mal_IDirectSoundBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags); HRESULT (STDMETHODCALLTYPE * Play) (mal_IDirectSoundBuffer* pThis, DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags); HRESULT (STDMETHODCALLTYPE * SetCurrentPosition)(mal_IDirectSoundBuffer* pThis, DWORD dwNewPosition); @@ -8580,14 +8580,14 @@ struct mal_IDirectSoundBuffer HRESULT mal_IDirectSoundBuffer_QueryInterface(mal_IDirectSoundBuffer* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } ULONG mal_IDirectSoundBuffer_AddRef(mal_IDirectSoundBuffer* pThis) { return pThis->lpVtbl->AddRef(pThis); } ULONG mal_IDirectSoundBuffer_Release(mal_IDirectSoundBuffer* pThis) { return pThis->lpVtbl->Release(pThis); } -HRESULT mal_IDirectSoundBuffer_GetCaps(mal_IDirectSoundBuffer* pThis, MAL_DSBCAPS* pDSBufferCaps) { return pThis->lpVtbl->GetCaps(pThis, pDSBufferCaps); } +HRESULT mal_IDirectSoundBuffer_GetCaps(mal_IDirectSoundBuffer* pThis, MA_DSBCAPS* pDSBufferCaps) { return pThis->lpVtbl->GetCaps(pThis, pDSBufferCaps); } HRESULT mal_IDirectSoundBuffer_GetCurrentPosition(mal_IDirectSoundBuffer* pThis, DWORD* pCurrentPlayCursor, DWORD* pCurrentWriteCursor) { return pThis->lpVtbl->GetCurrentPosition(pThis, pCurrentPlayCursor, pCurrentWriteCursor); } HRESULT mal_IDirectSoundBuffer_GetFormat(mal_IDirectSoundBuffer* pThis, WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten) { return pThis->lpVtbl->GetFormat(pThis, pFormat, dwSizeAllocated, pSizeWritten); } HRESULT mal_IDirectSoundBuffer_GetVolume(mal_IDirectSoundBuffer* pThis, LONG* pVolume) { return pThis->lpVtbl->GetVolume(pThis, pVolume); } HRESULT mal_IDirectSoundBuffer_GetPan(mal_IDirectSoundBuffer* pThis, LONG* pPan) { return pThis->lpVtbl->GetPan(pThis, pPan); } HRESULT mal_IDirectSoundBuffer_GetFrequency(mal_IDirectSoundBuffer* pThis, DWORD* pFrequency) { return pThis->lpVtbl->GetFrequency(pThis, pFrequency); } HRESULT mal_IDirectSoundBuffer_GetStatus(mal_IDirectSoundBuffer* pThis, DWORD* pStatus) { return pThis->lpVtbl->GetStatus(pThis, pStatus); } -HRESULT mal_IDirectSoundBuffer_Initialize(mal_IDirectSoundBuffer* pThis, mal_IDirectSound* pDirectSound, const MAL_DSBUFFERDESC* pDSBufferDesc) { return pThis->lpVtbl->Initialize(pThis, pDirectSound, pDSBufferDesc); } +HRESULT mal_IDirectSoundBuffer_Initialize(mal_IDirectSoundBuffer* pThis, mal_IDirectSound* pDirectSound, const MA_DSBUFFERDESC* pDSBufferDesc) { return pThis->lpVtbl->Initialize(pThis, pDirectSound, pDSBufferDesc); } HRESULT mal_IDirectSoundBuffer_Lock(mal_IDirectSoundBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags) { return pThis->lpVtbl->Lock(pThis, dwOffset, dwBytes, ppAudioPtr1, pAudioBytes1, ppAudioPtr2, pAudioBytes2, dwFlags); } HRESULT mal_IDirectSoundBuffer_Play(mal_IDirectSoundBuffer* pThis, DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags) { return pThis->lpVtbl->Play(pThis, dwReserved1, dwPriority, dwFlags); } HRESULT mal_IDirectSoundBuffer_SetCurrentPosition(mal_IDirectSoundBuffer* pThis, DWORD dwNewPosition) { return pThis->lpVtbl->SetCurrentPosition(pThis, dwNewPosition); } @@ -8609,8 +8609,8 @@ typedef struct ULONG (STDMETHODCALLTYPE * Release) (mal_IDirectSoundCapture* pThis); // IDirectSoundCapture - HRESULT (STDMETHODCALLTYPE * CreateCaptureBuffer)(mal_IDirectSoundCapture* pThis, const MAL_DSCBUFFERDESC* pDSCBufferDesc, mal_IDirectSoundCaptureBuffer** ppDSCBuffer, void* pUnkOuter); - HRESULT (STDMETHODCALLTYPE * GetCaps) (mal_IDirectSoundCapture* pThis, MAL_DSCCAPS* pDSCCaps); + HRESULT (STDMETHODCALLTYPE * CreateCaptureBuffer)(mal_IDirectSoundCapture* pThis, const MA_DSCBUFFERDESC* pDSCBufferDesc, mal_IDirectSoundCaptureBuffer** ppDSCBuffer, void* pUnkOuter); + HRESULT (STDMETHODCALLTYPE * GetCaps) (mal_IDirectSoundCapture* pThis, MA_DSCCAPS* pDSCCaps); HRESULT (STDMETHODCALLTYPE * Initialize) (mal_IDirectSoundCapture* pThis, const GUID* pGuidDevice); } mal_IDirectSoundCaptureVtbl; struct mal_IDirectSoundCapture @@ -8620,8 +8620,8 @@ struct mal_IDirectSoundCapture HRESULT mal_IDirectSoundCapture_QueryInterface(mal_IDirectSoundCapture* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } ULONG mal_IDirectSoundCapture_AddRef(mal_IDirectSoundCapture* pThis) { return pThis->lpVtbl->AddRef(pThis); } ULONG mal_IDirectSoundCapture_Release(mal_IDirectSoundCapture* pThis) { return pThis->lpVtbl->Release(pThis); } -HRESULT mal_IDirectSoundCapture_CreateCaptureBuffer(mal_IDirectSoundCapture* pThis, const MAL_DSCBUFFERDESC* pDSCBufferDesc, mal_IDirectSoundCaptureBuffer** ppDSCBuffer, void* pUnkOuter) { return pThis->lpVtbl->CreateCaptureBuffer(pThis, pDSCBufferDesc, ppDSCBuffer, pUnkOuter); } -HRESULT mal_IDirectSoundCapture_GetCaps (mal_IDirectSoundCapture* pThis, MAL_DSCCAPS* pDSCCaps) { return pThis->lpVtbl->GetCaps(pThis, pDSCCaps); } +HRESULT mal_IDirectSoundCapture_CreateCaptureBuffer(mal_IDirectSoundCapture* pThis, const MA_DSCBUFFERDESC* pDSCBufferDesc, mal_IDirectSoundCaptureBuffer** ppDSCBuffer, void* pUnkOuter) { return pThis->lpVtbl->CreateCaptureBuffer(pThis, pDSCBufferDesc, ppDSCBuffer, pUnkOuter); } +HRESULT mal_IDirectSoundCapture_GetCaps (mal_IDirectSoundCapture* pThis, MA_DSCCAPS* pDSCCaps) { return pThis->lpVtbl->GetCaps(pThis, pDSCCaps); } HRESULT mal_IDirectSoundCapture_Initialize (mal_IDirectSoundCapture* pThis, const GUID* pGuidDevice) { return pThis->lpVtbl->Initialize(pThis, pGuidDevice); } @@ -8634,11 +8634,11 @@ typedef struct ULONG (STDMETHODCALLTYPE * Release) (mal_IDirectSoundCaptureBuffer* pThis); // IDirectSoundCaptureBuffer - HRESULT (STDMETHODCALLTYPE * GetCaps) (mal_IDirectSoundCaptureBuffer* pThis, MAL_DSCBCAPS* pDSCBCaps); + HRESULT (STDMETHODCALLTYPE * GetCaps) (mal_IDirectSoundCaptureBuffer* pThis, MA_DSCBCAPS* pDSCBCaps); HRESULT (STDMETHODCALLTYPE * GetCurrentPosition)(mal_IDirectSoundCaptureBuffer* pThis, DWORD* pCapturePosition, DWORD* pReadPosition); HRESULT (STDMETHODCALLTYPE * GetFormat) (mal_IDirectSoundCaptureBuffer* pThis, WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten); HRESULT (STDMETHODCALLTYPE * GetStatus) (mal_IDirectSoundCaptureBuffer* pThis, DWORD* pStatus); - HRESULT (STDMETHODCALLTYPE * Initialize) (mal_IDirectSoundCaptureBuffer* pThis, mal_IDirectSoundCapture* pDirectSoundCapture, const MAL_DSCBUFFERDESC* pDSCBufferDesc); + HRESULT (STDMETHODCALLTYPE * Initialize) (mal_IDirectSoundCaptureBuffer* pThis, mal_IDirectSoundCapture* pDirectSoundCapture, const MA_DSCBUFFERDESC* pDSCBufferDesc); HRESULT (STDMETHODCALLTYPE * Lock) (mal_IDirectSoundCaptureBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags); HRESULT (STDMETHODCALLTYPE * Start) (mal_IDirectSoundCaptureBuffer* pThis, DWORD dwFlags); HRESULT (STDMETHODCALLTYPE * Stop) (mal_IDirectSoundCaptureBuffer* pThis); @@ -8651,11 +8651,11 @@ struct mal_IDirectSoundCaptureBuffer HRESULT mal_IDirectSoundCaptureBuffer_QueryInterface(mal_IDirectSoundCaptureBuffer* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } ULONG mal_IDirectSoundCaptureBuffer_AddRef(mal_IDirectSoundCaptureBuffer* pThis) { return pThis->lpVtbl->AddRef(pThis); } ULONG mal_IDirectSoundCaptureBuffer_Release(mal_IDirectSoundCaptureBuffer* pThis) { return pThis->lpVtbl->Release(pThis); } -HRESULT mal_IDirectSoundCaptureBuffer_GetCaps(mal_IDirectSoundCaptureBuffer* pThis, MAL_DSCBCAPS* pDSCBCaps) { return pThis->lpVtbl->GetCaps(pThis, pDSCBCaps); } +HRESULT mal_IDirectSoundCaptureBuffer_GetCaps(mal_IDirectSoundCaptureBuffer* pThis, MA_DSCBCAPS* pDSCBCaps) { return pThis->lpVtbl->GetCaps(pThis, pDSCBCaps); } HRESULT mal_IDirectSoundCaptureBuffer_GetCurrentPosition(mal_IDirectSoundCaptureBuffer* pThis, DWORD* pCapturePosition, DWORD* pReadPosition) { return pThis->lpVtbl->GetCurrentPosition(pThis, pCapturePosition, pReadPosition); } HRESULT mal_IDirectSoundCaptureBuffer_GetFormat(mal_IDirectSoundCaptureBuffer* pThis, WAVEFORMATEX* pFormat, DWORD dwSizeAllocated, DWORD* pSizeWritten) { return pThis->lpVtbl->GetFormat(pThis, pFormat, dwSizeAllocated, pSizeWritten); } HRESULT mal_IDirectSoundCaptureBuffer_GetStatus(mal_IDirectSoundCaptureBuffer* pThis, DWORD* pStatus) { return pThis->lpVtbl->GetStatus(pThis, pStatus); } -HRESULT mal_IDirectSoundCaptureBuffer_Initialize(mal_IDirectSoundCaptureBuffer* pThis, mal_IDirectSoundCapture* pDirectSoundCapture, const MAL_DSCBUFFERDESC* pDSCBufferDesc) { return pThis->lpVtbl->Initialize(pThis, pDirectSoundCapture, pDSCBufferDesc); } +HRESULT mal_IDirectSoundCaptureBuffer_Initialize(mal_IDirectSoundCaptureBuffer* pThis, mal_IDirectSoundCapture* pDirectSoundCapture, const MA_DSCBUFFERDESC* pDSCBufferDesc) { return pThis->lpVtbl->Initialize(pThis, pDirectSoundCapture, pDSCBufferDesc); } HRESULT mal_IDirectSoundCaptureBuffer_Lock(mal_IDirectSoundCaptureBuffer* pThis, DWORD dwOffset, DWORD dwBytes, void** ppAudioPtr1, DWORD* pAudioBytes1, void** ppAudioPtr2, DWORD* pAudioBytes2, DWORD dwFlags) { return pThis->lpVtbl->Lock(pThis, dwOffset, dwBytes, ppAudioPtr1, pAudioBytes1, ppAudioPtr2, pAudioBytes2, dwFlags); } HRESULT mal_IDirectSoundCaptureBuffer_Start(mal_IDirectSoundCaptureBuffer* pThis, DWORD dwFlags) { return pThis->lpVtbl->Start(pThis, dwFlags); } HRESULT mal_IDirectSoundCaptureBuffer_Stop(mal_IDirectSoundCaptureBuffer* pThis) { return pThis->lpVtbl->Stop(pThis); } @@ -8671,7 +8671,7 @@ typedef struct ULONG (STDMETHODCALLTYPE * Release) (mal_IDirectSoundNotify* pThis); // IDirectSoundNotify - HRESULT (STDMETHODCALLTYPE * SetNotificationPositions)(mal_IDirectSoundNotify* pThis, DWORD dwPositionNotifies, const MAL_DSBPOSITIONNOTIFY* pPositionNotifies); + HRESULT (STDMETHODCALLTYPE * SetNotificationPositions)(mal_IDirectSoundNotify* pThis, DWORD dwPositionNotifies, const MA_DSBPOSITIONNOTIFY* pPositionNotifies); } mal_IDirectSoundNotifyVtbl; struct mal_IDirectSoundNotify { @@ -8680,7 +8680,7 @@ struct mal_IDirectSoundNotify HRESULT mal_IDirectSoundNotify_QueryInterface(mal_IDirectSoundNotify* pThis, const IID* const riid, void** ppObject) { return pThis->lpVtbl->QueryInterface(pThis, riid, ppObject); } ULONG mal_IDirectSoundNotify_AddRef(mal_IDirectSoundNotify* pThis) { return pThis->lpVtbl->AddRef(pThis); } ULONG mal_IDirectSoundNotify_Release(mal_IDirectSoundNotify* pThis) { return pThis->lpVtbl->Release(pThis); } -HRESULT mal_IDirectSoundNotify_SetNotificationPositions(mal_IDirectSoundNotify* pThis, DWORD dwPositionNotifies, const MAL_DSBPOSITIONNOTIFY* pPositionNotifies) { return pThis->lpVtbl->SetNotificationPositions(pThis, dwPositionNotifies, pPositionNotifies); } +HRESULT mal_IDirectSoundNotify_SetNotificationPositions(mal_IDirectSoundNotify* pThis, DWORD dwPositionNotifies, const MA_DSBPOSITIONNOTIFY* pPositionNotifies) { return pThis->lpVtbl->SetNotificationPositions(pThis, dwPositionNotifies, pPositionNotifies); } typedef BOOL (CALLBACK * mal_DSEnumCallbackAProc) (LPGUID pDeviceGUID, LPCSTR pDeviceDescription, LPCSTR pModule, LPVOID pContext); @@ -8738,20 +8738,20 @@ mal_result mal_context_create_IDirectSound__dsound(mal_context* pContext, mal_sh mal_IDirectSound* pDirectSound = NULL; if (FAILED(((mal_DirectSoundCreateProc)pContext->dsound.DirectSoundCreate)((pDeviceID == NULL) ? NULL : (const GUID*)pDeviceID->dsound, &pDirectSound, NULL))) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[DirectSound] DirectSoundCreate() failed for playback device.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[DirectSound] DirectSoundCreate() failed for playback device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } // The cooperative level must be set before doing anything else. - HWND hWnd = ((MAL_PFN_GetForegroundWindow)pContext->win32.GetForegroundWindow)(); + HWND hWnd = ((MA_PFN_GetForegroundWindow)pContext->win32.GetForegroundWindow)(); if (hWnd == NULL) { - hWnd = ((MAL_PFN_GetDesktopWindow)pContext->win32.GetDesktopWindow)(); + hWnd = ((MA_PFN_GetDesktopWindow)pContext->win32.GetDesktopWindow)(); } - if (FAILED(mal_IDirectSound_SetCooperativeLevel(pDirectSound, hWnd, (shareMode == mal_share_mode_exclusive) ? MAL_DSSCL_EXCLUSIVE : MAL_DSSCL_PRIORITY))) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_SetCooperateiveLevel() failed for playback device.", MAL_SHARE_MODE_NOT_SUPPORTED); + if (FAILED(mal_IDirectSound_SetCooperativeLevel(pDirectSound, hWnd, (shareMode == mal_share_mode_exclusive) ? MA_DSSCL_EXCLUSIVE : MA_DSSCL_PRIORITY))) { + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_SetCooperateiveLevel() failed for playback device.", MA_SHARE_MODE_NOT_SUPPORTED); } *ppDirectSound = pDirectSound; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_create_IDirectSoundCapture__dsound(mal_context* pContext, mal_share_mode shareMode, const mal_device_id* pDeviceID, mal_IDirectSoundCapture** ppDirectSoundCapture) @@ -8761,18 +8761,18 @@ mal_result mal_context_create_IDirectSoundCapture__dsound(mal_context* pContext, /* DirectSound does not support exclusive mode for capture. */ if (shareMode == mal_share_mode_exclusive) { - return MAL_SHARE_MODE_NOT_SUPPORTED; + return MA_SHARE_MODE_NOT_SUPPORTED; } *ppDirectSoundCapture = NULL; mal_IDirectSoundCapture* pDirectSoundCapture = NULL; if (FAILED(((mal_DirectSoundCaptureCreateProc)pContext->dsound.DirectSoundCaptureCreate)((pDeviceID == NULL) ? NULL : (const GUID*)pDeviceID->dsound, &pDirectSoundCapture, NULL))) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[DirectSound] DirectSoundCaptureCreate() failed for capture device.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[DirectSound] DirectSoundCaptureCreate() failed for capture device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } *ppDirectSoundCapture = pDirectSoundCapture; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_get_format_info_for_IDirectSoundCapture__dsound(mal_context* pContext, mal_IDirectSoundCapture* pDirectSoundCapture, WORD* pChannels, WORD* pBitsPerSample, DWORD* pSampleRate) @@ -8790,11 +8790,11 @@ mal_result mal_context_get_format_info_for_IDirectSoundCapture__dsound(mal_conte *pSampleRate = 0; } - MAL_DSCCAPS caps; + MA_DSCCAPS caps; mal_zero_object(&caps); caps.dwSize = sizeof(caps); if (FAILED(mal_IDirectSoundCapture_GetCaps(pDirectSoundCapture, &caps))) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCapture_GetCaps() failed for capture device.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCapture_GetCaps() failed for capture device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } if (pChannels) { @@ -8869,7 +8869,7 @@ mal_result mal_context_get_format_info_for_IDirectSoundCapture__dsound(mal_conte *pSampleRate = sampleRate; } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_bool32 mal_context_is_device_id_equal__dsound(mal_context* pContext, const mal_device_id* pID0, const mal_device_id* pID1) @@ -8931,7 +8931,7 @@ mal_result mal_context_enumerate_devices__dsound(mal_context* pContext, mal_enum data.pContext = pContext; data.callback = callback; data.pUserData = pUserData; - data.terminated = MAL_FALSE; + data.terminated = MA_FALSE; // Playback. if (!data.terminated) { @@ -8945,7 +8945,7 @@ mal_result mal_context_enumerate_devices__dsound(mal_context* pContext, mal_enum ((mal_DirectSoundCaptureEnumerateAProc)pContext->dsound.DirectSoundCaptureEnumerateA)(mal_context_enumerate_devices_callback__dsound, &data); } - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -8963,17 +8963,17 @@ BOOL CALLBACK mal_context_get_device_info_callback__dsound(LPGUID lpGuid, LPCSTR mal_context_get_device_info_callback_data__dsound* pData = (mal_context_get_device_info_callback_data__dsound*)lpContext; mal_assert(pData != NULL); - if ((pData->pDeviceID == NULL || mal_is_guid_equal(pData->pDeviceID->dsound, &MAL_GUID_NULL)) && (lpGuid == NULL || mal_is_guid_equal(lpGuid, &MAL_GUID_NULL))) { + if ((pData->pDeviceID == NULL || mal_is_guid_equal(pData->pDeviceID->dsound, &MA_GUID_NULL)) && (lpGuid == NULL || mal_is_guid_equal(lpGuid, &MA_GUID_NULL))) { // Default device. mal_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), lpcstrDescription, (size_t)-1); - pData->found = MAL_TRUE; + pData->found = MA_TRUE; return FALSE; // Stop enumeration. } else { // Not the default device. if (lpGuid != NULL) { if (memcmp(pData->pDeviceID->dsound, lpGuid, sizeof(pData->pDeviceID->dsound)) == 0) { mal_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), lpcstrDescription, (size_t)-1); - pData->found = MAL_TRUE; + pData->found = MA_TRUE; return FALSE; // Stop enumeration. } } @@ -8986,7 +8986,7 @@ mal_result mal_context_get_device_info__dsound(mal_context* pContext, mal_device { /* Exclusive mode and capture not supported with DirectSound. */ if (deviceType == mal_device_type_capture && shareMode == mal_share_mode_exclusive) { - return MAL_SHARE_MODE_NOT_SUPPORTED; + return MA_SHARE_MODE_NOT_SUPPORTED; } if (pDeviceID != NULL) { @@ -8997,7 +8997,7 @@ mal_result mal_context_get_device_info__dsound(mal_context* pContext, mal_device mal_context_get_device_info_callback_data__dsound data; data.pDeviceID = pDeviceID; data.pDeviceInfo = pDeviceInfo; - data.found = MAL_FALSE; + data.found = MA_FALSE; if (deviceType == mal_device_type_playback) { ((mal_DirectSoundEnumerateAProc)pContext->dsound.DirectSoundEnumerateA)(mal_context_get_device_info_callback__dsound, &data); } else { @@ -9005,7 +9005,7 @@ mal_result mal_context_get_device_info__dsound(mal_context* pContext, mal_device } if (!data.found) { - return MAL_NO_DEVICE; + return MA_NO_DEVICE; } } else { // I don't think there's a way to get the name of the default device with DirectSound. In this case we just need to use defaults. @@ -9015,9 +9015,9 @@ mal_result mal_context_get_device_info__dsound(mal_context* pContext, mal_device // Name / Description/ if (deviceType == mal_device_type_playback) { - mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MAL_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { - mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MAL_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } } @@ -9026,18 +9026,18 @@ mal_result mal_context_get_device_info__dsound(mal_context* pContext, mal_device // Playback. mal_IDirectSound* pDirectSound; mal_result result = mal_context_create_IDirectSound__dsound(pContext, shareMode, pDeviceID, &pDirectSound); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } - MAL_DSCAPS caps; + MA_DSCAPS caps; mal_zero_object(&caps); caps.dwSize = sizeof(caps); if (FAILED(mal_IDirectSound_GetCaps(pDirectSound, &caps))) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_GetCaps() failed for playback device.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_GetCaps() failed for playback device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } - if ((caps.dwFlags & MAL_DSCAPS_PRIMARYSTEREO) != 0) { + if ((caps.dwFlags & MA_DSCAPS_PRIMARYSTEREO) != 0) { // It supports at least stereo, but could support more. WORD channels = 2; @@ -9056,17 +9056,17 @@ mal_result mal_context_get_device_info__dsound(mal_context* pContext, mal_device } // Sample rate. - if ((caps.dwFlags & MAL_DSCAPS_CONTINUOUSRATE) != 0) { + if ((caps.dwFlags & MA_DSCAPS_CONTINUOUSRATE) != 0) { pDeviceInfo->minSampleRate = caps.dwMinSecondarySampleRate; pDeviceInfo->maxSampleRate = caps.dwMaxSecondarySampleRate; // On my machine the min and max sample rates can return 100 and 200000 respectively. I'd rather these be within // the range of our standard sample rates so I'm clamping. - if (caps.dwMinSecondarySampleRate < MAL_MIN_SAMPLE_RATE && caps.dwMaxSecondarySampleRate >= MAL_MIN_SAMPLE_RATE) { - pDeviceInfo->minSampleRate = MAL_MIN_SAMPLE_RATE; + if (caps.dwMinSecondarySampleRate < MA_MIN_SAMPLE_RATE && caps.dwMaxSecondarySampleRate >= MA_MIN_SAMPLE_RATE) { + pDeviceInfo->minSampleRate = MA_MIN_SAMPLE_RATE; } - if (caps.dwMaxSecondarySampleRate > MAL_MAX_SAMPLE_RATE && caps.dwMinSecondarySampleRate <= MAL_MAX_SAMPLE_RATE) { - pDeviceInfo->maxSampleRate = MAL_MAX_SAMPLE_RATE; + if (caps.dwMaxSecondarySampleRate > MA_MAX_SAMPLE_RATE && caps.dwMinSecondarySampleRate <= MA_MAX_SAMPLE_RATE) { + pDeviceInfo->maxSampleRate = MA_MAX_SAMPLE_RATE; } } else { // Only supports a single sample rate. Set both min an max to the same thing. Do not clamp within the standard rates. @@ -9087,7 +9087,7 @@ mal_result mal_context_get_device_info__dsound(mal_context* pContext, mal_device // reporting the best format. mal_IDirectSoundCapture* pDirectSoundCapture; mal_result result = mal_context_create_IDirectSoundCapture__dsound(pContext, shareMode, pDeviceID, &pDirectSoundCapture); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -9095,7 +9095,7 @@ mal_result mal_context_get_device_info__dsound(mal_context* pContext, mal_device WORD bitsPerSample; DWORD sampleRate; result = mal_context_get_format_info_for_IDirectSoundCapture__dsound(pContext, pDirectSoundCapture, &channels, &bitsPerSample, &sampleRate); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { mal_IDirectSoundCapture_Release(pDirectSoundCapture); return result; } @@ -9115,13 +9115,13 @@ mal_result mal_context_get_device_info__dsound(mal_context* pContext, mal_device pDeviceInfo->formats[0] = mal_format_s32; } else { mal_IDirectSoundCapture_Release(pDirectSoundCapture); - return MAL_FORMAT_NOT_SUPPORTED; + return MA_FORMAT_NOT_SUPPORTED; } mal_IDirectSoundCapture_Release(pDirectSoundCapture); } - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -9194,16 +9194,16 @@ mal_result mal_config_to_WAVEFORMATEXTENSIBLE(mal_format format, mal_uint32 chan //case mal_format_s24_32: case mal_format_s32: { - subformat = MAL_GUID_KSDATAFORMAT_SUBTYPE_PCM; + subformat = MA_GUID_KSDATAFORMAT_SUBTYPE_PCM; } break; case mal_format_f32: { - subformat = MAL_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; + subformat = MA_GUID_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; } break; default: - return MAL_FORMAT_NOT_SUPPORTED; + return MA_FORMAT_NOT_SUPPORTED; } mal_zero_object(pWF); @@ -9218,7 +9218,7 @@ mal_result mal_config_to_WAVEFORMATEXTENSIBLE(mal_format format, mal_uint32 chan pWF->dwChannelMask = mal_channel_map_to_channel_mask__win32(pChannelMap, channels); pWF->SubFormat = subformat; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_init__dsound(mal_context* pContext, const mal_device_config* pConfig, mal_device* pDevice) @@ -9255,18 +9255,18 @@ mal_result mal_device_init__dsound(mal_context* pContext, const mal_device_confi if (pConfig->deviceType == mal_device_type_capture || pConfig->deviceType == mal_device_type_duplex) { WAVEFORMATEXTENSIBLE wf; result = mal_config_to_WAVEFORMATEXTENSIBLE(pConfig->capture.format, pConfig->capture.channels, pConfig->sampleRate, pConfig->capture.channelMap, &wf); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } result = mal_context_create_IDirectSoundCapture__dsound(pContext, pConfig->capture.shareMode, pConfig->capture.pDeviceID, (mal_IDirectSoundCapture**)&pDevice->dsound.pCapture); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { mal_device_uninit__dsound(pDevice); return result; } result = mal_context_get_format_info_for_IDirectSoundCapture__dsound(pContext, (mal_IDirectSoundCapture*)pDevice->dsound.pCapture, &wf.Format.nChannels, &wf.Format.wBitsPerSample, &wf.Format.nSamplesPerSec); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { mal_device_uninit__dsound(pDevice); return result; } @@ -9274,12 +9274,12 @@ mal_result mal_device_init__dsound(mal_context* pContext, const mal_device_confi wf.Format.nBlockAlign = (wf.Format.nChannels * wf.Format.wBitsPerSample) / 8; wf.Format.nAvgBytesPerSec = wf.Format.nBlockAlign * wf.Format.nSamplesPerSec; wf.Samples.wValidBitsPerSample = wf.Format.wBitsPerSample; - wf.SubFormat = MAL_GUID_KSDATAFORMAT_SUBTYPE_PCM; + wf.SubFormat = MA_GUID_KSDATAFORMAT_SUBTYPE_PCM; /* The size of the buffer must be a clean multiple of the period count. */ mal_uint32 bufferSizeInFrames = (mal_calculate_buffer_size_in_frames_from_milliseconds(bufferSizeInMilliseconds, wf.Format.nSamplesPerSec) / pConfig->periods) * pConfig->periods; - MAL_DSCBUFFERDESC descDS; + MA_DSCBUFFERDESC descDS; mal_zero_object(&descDS); descDS.dwSize = sizeof(descDS); descDS.dwFlags = 0; @@ -9287,7 +9287,7 @@ mal_result mal_device_init__dsound(mal_context* pContext, const mal_device_confi descDS.lpwfxFormat = (WAVEFORMATEX*)&wf; if (FAILED(mal_IDirectSoundCapture_CreateCaptureBuffer((mal_IDirectSoundCapture*)pDevice->dsound.pCapture, &descDS, (mal_IDirectSoundCaptureBuffer**)&pDevice->dsound.pCaptureBuffer, NULL))) { mal_device_uninit__dsound(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCapture_CreateCaptureBuffer() failed for capture device.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCapture_CreateCaptureBuffer() failed for capture device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } // Get the _actual_ properties of the buffer. @@ -9295,7 +9295,7 @@ mal_result mal_device_init__dsound(mal_context* pContext, const mal_device_confi WAVEFORMATEXTENSIBLE* pActualFormat = (WAVEFORMATEXTENSIBLE*)rawdata; if (FAILED(mal_IDirectSoundCaptureBuffer_GetFormat((mal_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, (WAVEFORMATEX*)pActualFormat, sizeof(rawdata), NULL))) { mal_device_uninit__dsound(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] Failed to retrieve the actual format of the capture device's buffer.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to retrieve the actual format of the capture device's buffer.", MA_FORMAT_NOT_SUPPORTED); } pDevice->capture.internalFormat = mal_format_from_WAVEFORMATEX((WAVEFORMATEX*)pActualFormat); @@ -9319,7 +9319,7 @@ mal_result mal_device_init__dsound(mal_context* pContext, const mal_device_confi if (FAILED(mal_IDirectSoundCapture_CreateCaptureBuffer((mal_IDirectSoundCapture*)pDevice->dsound.pCapture, &descDS, (mal_IDirectSoundCaptureBuffer**)&pDevice->dsound.pCaptureBuffer, NULL))) { mal_device_uninit__dsound(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] Second attempt at IDirectSoundCapture_CreateCaptureBuffer() failed for capture device.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Second attempt at IDirectSoundCapture_CreateCaptureBuffer() failed for capture device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } } @@ -9331,37 +9331,37 @@ mal_result mal_device_init__dsound(mal_context* pContext, const mal_device_confi if (pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) { WAVEFORMATEXTENSIBLE wf; result = mal_config_to_WAVEFORMATEXTENSIBLE(pConfig->playback.format, pConfig->playback.channels, pConfig->sampleRate, pConfig->playback.channelMap, &wf); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } result = mal_context_create_IDirectSound__dsound(pContext, pConfig->playback.shareMode, pConfig->playback.pDeviceID, (mal_IDirectSound**)&pDevice->dsound.pPlayback); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { mal_device_uninit__dsound(pDevice); return result; } - MAL_DSBUFFERDESC descDSPrimary; + MA_DSBUFFERDESC descDSPrimary; mal_zero_object(&descDSPrimary); - descDSPrimary.dwSize = sizeof(MAL_DSBUFFERDESC); - descDSPrimary.dwFlags = MAL_DSBCAPS_PRIMARYBUFFER | MAL_DSBCAPS_CTRLVOLUME; + descDSPrimary.dwSize = sizeof(MA_DSBUFFERDESC); + descDSPrimary.dwFlags = MA_DSBCAPS_PRIMARYBUFFER | MA_DSBCAPS_CTRLVOLUME; if (FAILED(mal_IDirectSound_CreateSoundBuffer((mal_IDirectSound*)pDevice->dsound.pPlayback, &descDSPrimary, (mal_IDirectSoundBuffer**)&pDevice->dsound.pPlaybackPrimaryBuffer, NULL))) { mal_device_uninit__dsound(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_CreateSoundBuffer() failed for playback device's primary buffer.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_CreateSoundBuffer() failed for playback device's primary buffer.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } // We may want to make some adjustments to the format if we are using defaults. - MAL_DSCAPS caps; + MA_DSCAPS caps; mal_zero_object(&caps); caps.dwSize = sizeof(caps); if (FAILED(mal_IDirectSound_GetCaps((mal_IDirectSound*)pDevice->dsound.pPlayback, &caps))) { mal_device_uninit__dsound(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_GetCaps() failed for playback device.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_GetCaps() failed for playback device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } if (pDevice->playback.usingDefaultChannels) { - if ((caps.dwFlags & MAL_DSCAPS_PRIMARYSTEREO) != 0) { + if ((caps.dwFlags & MA_DSCAPS_PRIMARYSTEREO) != 0) { // It supports at least stereo, but could support more. wf.Format.nChannels = 2; @@ -9378,7 +9378,7 @@ mal_result mal_device_init__dsound(mal_context* pContext, const mal_device_confi if (pDevice->usingDefaultSampleRate) { // We base the sample rate on the values returned by GetCaps(). - if ((caps.dwFlags & MAL_DSCAPS_CONTINUOUSRATE) != 0) { + if ((caps.dwFlags & MA_DSCAPS_CONTINUOUSRATE) != 0) { wf.Format.nSamplesPerSec = mal_get_best_sample_rate_within_range(caps.dwMinSecondarySampleRate, caps.dwMaxSecondarySampleRate); } else { wf.Format.nSamplesPerSec = caps.dwMaxSecondarySampleRate; @@ -9395,7 +9395,7 @@ mal_result mal_device_init__dsound(mal_context* pContext, const mal_device_confi // and compare the result with the format that was requested with the SetFormat method. if (FAILED(mal_IDirectSoundBuffer_SetFormat((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer, (WAVEFORMATEX*)&wf))) { mal_device_uninit__dsound(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] Failed to set format of playback device's primary buffer.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to set format of playback device's primary buffer.", MA_FORMAT_NOT_SUPPORTED); } // Get the _actual_ properties of the buffer. @@ -9403,7 +9403,7 @@ mal_result mal_device_init__dsound(mal_context* pContext, const mal_device_confi WAVEFORMATEXTENSIBLE* pActualFormat = (WAVEFORMATEXTENSIBLE*)rawdata; if (FAILED(mal_IDirectSoundBuffer_GetFormat((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackPrimaryBuffer, (WAVEFORMATEX*)pActualFormat, sizeof(rawdata), NULL))) { mal_device_uninit__dsound(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] Failed to retrieve the actual format of the playback device's primary buffer.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to retrieve the actual format of the playback device's primary buffer.", MA_FORMAT_NOT_SUPPORTED); } pDevice->playback.internalFormat = mal_format_from_WAVEFORMATEX((WAVEFORMATEX*)pActualFormat); @@ -9433,15 +9433,15 @@ mal_result mal_device_init__dsound(mal_context* pContext, const mal_device_confi // In the first version of DirectSound, the play cursor was significantly ahead of the actual playing sound on emulated // sound cards; it was directly behind the write cursor. Now, if the DSBCAPS_GETCURRENTPOSITION2 flag is specified, the // application can get a more accurate play cursor. - MAL_DSBUFFERDESC descDS; + MA_DSBUFFERDESC descDS; mal_zero_object(&descDS); descDS.dwSize = sizeof(descDS); - descDS.dwFlags = MAL_DSBCAPS_CTRLPOSITIONNOTIFY | MAL_DSBCAPS_GLOBALFOCUS | MAL_DSBCAPS_GETCURRENTPOSITION2; + descDS.dwFlags = MA_DSBCAPS_CTRLPOSITIONNOTIFY | MA_DSBCAPS_GLOBALFOCUS | MA_DSBCAPS_GETCURRENTPOSITION2; descDS.dwBufferBytes = bufferSizeInFrames * mal_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); descDS.lpwfxFormat = (WAVEFORMATEX*)&wf; if (FAILED(mal_IDirectSound_CreateSoundBuffer((mal_IDirectSound*)pDevice->dsound.pPlayback, &descDS, (mal_IDirectSoundBuffer**)&pDevice->dsound.pPlaybackBuffer, NULL))) { mal_device_uninit__dsound(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_CreateSoundBuffer() failed for playback device's secondary buffer.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSound_CreateSoundBuffer() failed for playback device's secondary buffer.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } /* DirectSound should give us a buffer exactly the size we asked for. */ @@ -9449,13 +9449,13 @@ mal_result mal_device_init__dsound(mal_context* pContext, const mal_device_confi pDevice->playback.internalPeriods = pConfig->periods; } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_main_loop__dsound(mal_device* pDevice) { - mal_result result = MAL_SUCCESS; + mal_result result = MA_SUCCESS; mal_uint32 bpfCapture = mal_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); mal_uint32 bpfPlayback = mal_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); HRESULT hr; @@ -9472,7 +9472,7 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) mal_bool32 physicalPlayCursorLoopFlagPlayback = 0; DWORD virtualWriteCursorInBytesPlayback = 0; mal_bool32 virtualWriteCursorLoopFlagPlayback = 0; - mal_bool32 isPlaybackDeviceStarted = MAL_FALSE; + mal_bool32 isPlaybackDeviceStarted = MA_FALSE; mal_uint32 framesWrittenToPlaybackDevice = 0; /* For knowing whether or not the playback device needs to be started. */ mal_uint32 waitTimeInMilliseconds = 1; @@ -9480,12 +9480,12 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) /* The first thing to do is start the capture device. The playback device is only started after the first period is written. */ if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { - if (FAILED(mal_IDirectSoundCaptureBuffer_Start((mal_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, MAL_DSCBSTART_LOOPING))) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCaptureBuffer_Start() failed.", MAL_FAILED_TO_START_BACKEND_DEVICE); + if (FAILED(mal_IDirectSoundCaptureBuffer_Start((mal_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, MA_DSCBSTART_LOOPING))) { + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCaptureBuffer_Start() failed.", MA_FAILED_TO_START_BACKEND_DEVICE); } } - while (mal_device__get_state(pDevice) == MAL_STATE_STARTED) { + while (mal_device__get_state(pDevice) == MA_STATE_STARTED) { switch (pDevice->type) { case mal_device_type_duplex: @@ -9493,7 +9493,7 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) DWORD physicalCaptureCursorInBytes; DWORD physicalReadCursorInBytes; if (FAILED(mal_IDirectSoundCaptureBuffer_GetCurrentPosition((mal_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, &physicalCaptureCursorInBytes, &physicalReadCursorInBytes))) { - return MAL_ERROR; + return MA_ERROR; } /* If nothing is available we just sleep for a bit and return from this iteration. */ @@ -9533,7 +9533,7 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) hr = mal_IDirectSoundCaptureBuffer_Lock((mal_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, lockOffsetInBytesCapture, lockSizeInBytesCapture, &pMappedBufferCapture, &mappedSizeInBytesCapture, NULL, NULL, 0); if (FAILED(hr)) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from capture device in preparation for writing to the device.", MAL_FAILED_TO_MAP_DEVICE_BUFFER); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from capture device in preparation for writing to the device.", MA_FAILED_TO_MAP_DEVICE_BUFFER); } @@ -9582,7 +9582,7 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) availableBytesPlayback += physicalPlayCursorInBytes; /* Wrap around. */ } else { /* This is an error. */ - #ifdef MAL_DEBUG_OUTPUT + #ifdef MA_DEBUG_OUTPUT printf("[DirectSound] (Duplex/Playback) WARNING: Play cursor has moved in front of the write cursor (same loop iterations). physicalPlayCursorInBytes=%d, virtualWriteCursorInBytes=%d.\n", physicalPlayCursorInBytes, virtualWriteCursorInBytesPlayback); #endif availableBytesPlayback = 0; @@ -9593,14 +9593,14 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) availableBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback; } else { /* This is an error. */ - #ifdef MAL_DEBUG_OUTPUT + #ifdef MA_DEBUG_OUTPUT printf("[DirectSound] (Duplex/Playback) WARNING: Write cursor has moved behind the play cursor (different loop iterations). physicalPlayCursorInBytes=%d, virtualWriteCursorInBytes=%d.\n", physicalPlayCursorInBytes, virtualWriteCursorInBytesPlayback); #endif availableBytesPlayback = 0; } } - #ifdef MAL_DEBUG_OUTPUT + #ifdef MA_DEBUG_OUTPUT //printf("[DirectSound] (Duplex/Playback) physicalPlayCursorInBytes=%d, availableBytesPlayback=%d\n", physicalPlayCursorInBytes, availableBytesPlayback); #endif @@ -9608,11 +9608,11 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) if (availableBytesPlayback == 0) { /* If we haven't started the device yet, this will never get beyond 0. In this case we need to get the device started. */ if (!isPlaybackDeviceStarted) { - if (FAILED(mal_IDirectSoundBuffer_Play((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MAL_DSBPLAY_LOOPING))) { + if (FAILED(mal_IDirectSoundBuffer_Play((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MA_DSBPLAY_LOOPING))) { mal_IDirectSoundCaptureBuffer_Stop((mal_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed.", MA_FAILED_TO_START_BACKEND_DEVICE); } - isPlaybackDeviceStarted = MAL_TRUE; + isPlaybackDeviceStarted = MA_TRUE; } else { mal_sleep(waitTimeInMilliseconds); continue; @@ -9632,7 +9632,7 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) hr = mal_IDirectSoundBuffer_Lock((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, lockOffsetInBytesPlayback, lockSizeInBytesPlayback, &pMappedBufferPlayback, &mappedSizeInBytesPlayback, NULL, NULL, 0); if (FAILED(hr)) { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from playback device in preparation for writing to the device.", MAL_FAILED_TO_MAP_DEVICE_BUFFER); + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from playback device in preparation for writing to the device.", MA_FAILED_TO_MAP_DEVICE_BUFFER); break; } @@ -9648,7 +9648,7 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) silentPaddingInBytes = lockSizeInBytesPlayback; } - #ifdef MAL_DEBUG_OUTPUT + #ifdef MA_DEBUG_OUTPUT printf("[DirectSound] (Duplex/Playback) Playback buffer starved. availableBytesPlayback=%d, silentPaddingInBytes=%d\n", availableBytesPlayback, silentPaddingInBytes); #endif } @@ -9665,7 +9665,7 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) hr = mal_IDirectSoundBuffer_Unlock((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, pMappedBufferPlayback, framesWrittenThisIteration*bpfPlayback, NULL, 0); if (FAILED(hr)) { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from playback device after writing to the device.", MAL_FAILED_TO_UNMAP_DEVICE_BUFFER); + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from playback device after writing to the device.", MA_FAILED_TO_UNMAP_DEVICE_BUFFER); break; } @@ -9681,11 +9681,11 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) */ framesWrittenToPlaybackDevice += framesWrittenThisIteration; if (!isPlaybackDeviceStarted && framesWrittenToPlaybackDevice >= ((pDevice->playback.internalBufferSizeInFrames/pDevice->playback.internalPeriods)*2)) { - if (FAILED(mal_IDirectSoundBuffer_Play((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MAL_DSBPLAY_LOOPING))) { + if (FAILED(mal_IDirectSoundBuffer_Play((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MA_DSBPLAY_LOOPING))) { mal_IDirectSoundCaptureBuffer_Stop((mal_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed.", MA_FAILED_TO_START_BACKEND_DEVICE); } - isPlaybackDeviceStarted = MAL_TRUE; + isPlaybackDeviceStarted = MA_TRUE; } if (framesWrittenThisIteration < mappedSizeInBytesPlayback/bpfPlayback) { @@ -9702,7 +9702,7 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) /* At this point we're done with the mapped portion of the capture buffer. */ hr = mal_IDirectSoundCaptureBuffer_Unlock((mal_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, pMappedBufferCapture, mappedSizeInBytesCapture, NULL, 0); if (FAILED(hr)) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from capture device after reading from the device.", MAL_FAILED_TO_UNMAP_DEVICE_BUFFER); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from capture device after reading from the device.", MA_FAILED_TO_UNMAP_DEVICE_BUFFER); } prevReadCursorInBytesCapture = (lockOffsetInBytesCapture + mappedSizeInBytesCapture); } break; @@ -9714,7 +9714,7 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) DWORD physicalCaptureCursorInBytes; DWORD physicalReadCursorInBytes; if (FAILED(mal_IDirectSoundCaptureBuffer_GetCurrentPosition((mal_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, &physicalCaptureCursorInBytes, &physicalReadCursorInBytes))) { - return MAL_ERROR; + return MA_ERROR; } /* If the previous capture position is the same as the current position we need to wait a bit longer. */ @@ -9744,7 +9744,7 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) } } - #ifdef MAL_DEBUG_OUTPUT + #ifdef MA_DEBUG_OUTPUT //printf("[DirectSound] (Capture) physicalCaptureCursorInBytes=%d, physicalReadCursorInBytes=%d\n", physicalCaptureCursorInBytes, physicalReadCursorInBytes); //printf("[DirectSound] (Capture) lockOffsetInBytesCapture=%d, lockSizeInBytesCapture=%d\n", lockOffsetInBytesCapture, lockSizeInBytesCapture); #endif @@ -9756,10 +9756,10 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) hr = mal_IDirectSoundCaptureBuffer_Lock((mal_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, lockOffsetInBytesCapture, lockSizeInBytesCapture, &pMappedBufferCapture, &mappedSizeInBytesCapture, NULL, NULL, 0); if (FAILED(hr)) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from capture device in preparation for writing to the device.", MAL_FAILED_TO_MAP_DEVICE_BUFFER); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from capture device in preparation for writing to the device.", MA_FAILED_TO_MAP_DEVICE_BUFFER); } - #ifdef MAL_DEBUG_OUTPUT + #ifdef MA_DEBUG_OUTPUT if (lockSizeInBytesCapture != mappedSizeInBytesCapture) { printf("[DirectSound] (Capture) lockSizeInBytesCapture=%d != mappedSizeInBytesCapture=%d\n", lockSizeInBytesCapture, mappedSizeInBytesCapture); } @@ -9776,7 +9776,7 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) hr = mal_IDirectSoundCaptureBuffer_Unlock((mal_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer, pMappedBufferCapture, mappedSizeInBytesCapture, NULL, 0); if (FAILED(hr)) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from capture device after reading from the device.", MAL_FAILED_TO_UNMAP_DEVICE_BUFFER); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from capture device after reading from the device.", MA_FAILED_TO_UNMAP_DEVICE_BUFFER); } prevReadCursorInBytesCapture = lockOffsetInBytesCapture + mappedSizeInBytesCapture; @@ -9809,7 +9809,7 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) availableBytesPlayback += physicalPlayCursorInBytes; /* Wrap around. */ } else { /* This is an error. */ - #ifdef MAL_DEBUG_OUTPUT + #ifdef MA_DEBUG_OUTPUT printf("[DirectSound] (Playback) WARNING: Play cursor has moved in front of the write cursor (same loop iterations). physicalPlayCursorInBytes=%d, virtualWriteCursorInBytes=%d.\n", physicalPlayCursorInBytes, virtualWriteCursorInBytesPlayback); #endif availableBytesPlayback = 0; @@ -9820,14 +9820,14 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) availableBytesPlayback = physicalPlayCursorInBytes - virtualWriteCursorInBytesPlayback; } else { /* This is an error. */ - #ifdef MAL_DEBUG_OUTPUT + #ifdef MA_DEBUG_OUTPUT printf("[DirectSound] (Playback) WARNING: Write cursor has moved behind the play cursor (different loop iterations). physicalPlayCursorInBytes=%d, virtualWriteCursorInBytes=%d.\n", physicalPlayCursorInBytes, virtualWriteCursorInBytesPlayback); #endif availableBytesPlayback = 0; } } - #ifdef MAL_DEBUG_OUTPUT + #ifdef MA_DEBUG_OUTPUT //printf("[DirectSound] (Playback) physicalPlayCursorInBytes=%d, availableBytesPlayback=%d\n", physicalPlayCursorInBytes, availableBytesPlayback); #endif @@ -9835,10 +9835,10 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) if (availableBytesPlayback == 0) { /* If we haven't started the device yet, this will never get beyond 0. In this case we need to get the device started. */ if (!isPlaybackDeviceStarted) { - if (FAILED(mal_IDirectSoundBuffer_Play((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MAL_DSBPLAY_LOOPING))) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed.", MAL_FAILED_TO_START_BACKEND_DEVICE); + if (FAILED(mal_IDirectSoundBuffer_Play((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MA_DSBPLAY_LOOPING))) { + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed.", MA_FAILED_TO_START_BACKEND_DEVICE); } - isPlaybackDeviceStarted = MAL_TRUE; + isPlaybackDeviceStarted = MA_TRUE; } else { mal_sleep(waitTimeInMilliseconds); continue; @@ -9857,7 +9857,7 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) hr = mal_IDirectSoundBuffer_Lock((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, lockOffsetInBytesPlayback, lockSizeInBytesPlayback, &pMappedBufferPlayback, &mappedSizeInBytesPlayback, NULL, NULL, 0); if (FAILED(hr)) { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from playback device in preparation for writing to the device.", MAL_FAILED_TO_MAP_DEVICE_BUFFER); + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to map buffer from playback device in preparation for writing to the device.", MA_FAILED_TO_MAP_DEVICE_BUFFER); break; } @@ -9875,7 +9875,7 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) hr = mal_IDirectSoundBuffer_Unlock((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, pMappedBufferPlayback, mappedSizeInBytesPlayback, NULL, 0); if (FAILED(hr)) { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from playback device after writing to the device.", MAL_FAILED_TO_UNMAP_DEVICE_BUFFER); + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] Failed to unlock internal buffer from playback device after writing to the device.", MA_FAILED_TO_UNMAP_DEVICE_BUFFER); break; } @@ -9891,18 +9891,18 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) */ framesWrittenToPlaybackDevice += mappedSizeInBytesPlayback/bpfPlayback; if (!isPlaybackDeviceStarted && framesWrittenToPlaybackDevice >= (pDevice->playback.internalBufferSizeInFrames/pDevice->playback.internalPeriods)) { - if (FAILED(mal_IDirectSoundBuffer_Play((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MAL_DSBPLAY_LOOPING))) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed.", MAL_FAILED_TO_START_BACKEND_DEVICE); + if (FAILED(mal_IDirectSoundBuffer_Play((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0, 0, MA_DSBPLAY_LOOPING))) { + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Play() failed.", MA_FAILED_TO_START_BACKEND_DEVICE); } - isPlaybackDeviceStarted = MAL_TRUE; + isPlaybackDeviceStarted = MA_TRUE; } } break; - default: return MAL_INVALID_ARGS; /* Invalid device type. */ + default: return MA_INVALID_ARGS; /* Invalid device type. */ } - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } @@ -9910,7 +9910,7 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) /* Getting here means the device is being stopped. */ if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { if (FAILED(mal_IDirectSoundCaptureBuffer_Stop((mal_IDirectSoundCaptureBuffer*)pDevice->dsound.pCaptureBuffer))) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCaptureBuffer_Stop() failed.", MAL_FAILED_TO_STOP_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundCaptureBuffer_Stop() failed.", MA_FAILED_TO_STOP_BACKEND_DEVICE); } } @@ -9956,13 +9956,13 @@ mal_result mal_device_main_loop__dsound(mal_device* pDevice) } if (FAILED(mal_IDirectSoundBuffer_Stop((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer))) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Stop() failed.", MAL_FAILED_TO_STOP_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[DirectSound] IDirectSoundBuffer_Stop() failed.", MA_FAILED_TO_STOP_BACKEND_DEVICE); } mal_IDirectSoundBuffer_SetCurrentPosition((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, 0); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_uninit__dsound(mal_context* pContext) @@ -9972,7 +9972,7 @@ mal_result mal_context_uninit__dsound(mal_context* pContext) mal_dlclose(pContext->dsound.hDSoundDLL); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_init__dsound(mal_context* pContext) @@ -9981,7 +9981,7 @@ mal_result mal_context_init__dsound(mal_context* pContext) pContext->dsound.hDSoundDLL = mal_dlopen("dsound.dll"); if (pContext->dsound.hDSoundDLL == NULL) { - return MAL_API_NOT_FOUND; + return MA_API_NOT_FOUND; } pContext->dsound.DirectSoundCreate = mal_dlsym(pContext->dsound.hDSoundDLL, "DirectSoundCreate"); @@ -10001,7 +10001,7 @@ mal_result mal_context_init__dsound(mal_context* pContext) pContext->onDeviceRead = NULL; pContext->onDeviceMainLoop = mal_device_main_loop__dsound; - return MAL_SUCCESS; + return MA_SUCCESS; } #endif @@ -10012,7 +10012,7 @@ mal_result mal_context_init__dsound(mal_context* pContext) // WinMM Backend // /////////////////////////////////////////////////////////////////////////////// -#ifdef MAL_HAS_WINMM +#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 @@ -10030,7 +10030,7 @@ typedef struct GUID ManufacturerGuid; GUID ProductGuid; GUID NameGuid; -} MAL_WAVEOUTCAPS2A; +} MA_WAVEOUTCAPS2A; typedef struct { WORD wMid; @@ -10043,38 +10043,38 @@ typedef struct GUID ManufacturerGuid; GUID ProductGuid; GUID NameGuid; -} MAL_WAVEINCAPS2A; +} MA_WAVEINCAPS2A; -typedef UINT (WINAPI * MAL_PFN_waveOutGetNumDevs)(void); -typedef MMRESULT (WINAPI * MAL_PFN_waveOutGetDevCapsA)(mal_uintptr uDeviceID, LPWAVEOUTCAPSA pwoc, UINT cbwoc); -typedef MMRESULT (WINAPI * MAL_PFN_waveOutOpen)(LPHWAVEOUT phwo, UINT uDeviceID, LPCWAVEFORMATEX pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen); -typedef MMRESULT (WINAPI * MAL_PFN_waveOutClose)(HWAVEOUT hwo); -typedef MMRESULT (WINAPI * MAL_PFN_waveOutPrepareHeader)(HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh); -typedef MMRESULT (WINAPI * MAL_PFN_waveOutUnprepareHeader)(HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh); -typedef MMRESULT (WINAPI * MAL_PFN_waveOutWrite)(HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh); -typedef MMRESULT (WINAPI * MAL_PFN_waveOutReset)(HWAVEOUT hwo); -typedef UINT (WINAPI * MAL_PFN_waveInGetNumDevs)(void); -typedef MMRESULT (WINAPI * MAL_PFN_waveInGetDevCapsA)(mal_uintptr uDeviceID, LPWAVEINCAPSA pwic, UINT cbwic); -typedef MMRESULT (WINAPI * MAL_PFN_waveInOpen)(LPHWAVEIN phwi, UINT uDeviceID, LPCWAVEFORMATEX pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen); -typedef MMRESULT (WINAPI * MAL_PFN_waveInClose)(HWAVEIN hwi); -typedef MMRESULT (WINAPI * MAL_PFN_waveInPrepareHeader)(HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh); -typedef MMRESULT (WINAPI * MAL_PFN_waveInUnprepareHeader)(HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh); -typedef MMRESULT (WINAPI * MAL_PFN_waveInAddBuffer)(HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh); -typedef MMRESULT (WINAPI * MAL_PFN_waveInStart)(HWAVEIN hwi); -typedef MMRESULT (WINAPI * MAL_PFN_waveInReset)(HWAVEIN hwi); +typedef UINT (WINAPI * MA_PFN_waveOutGetNumDevs)(void); +typedef MMRESULT (WINAPI * MA_PFN_waveOutGetDevCapsA)(mal_uintptr uDeviceID, LPWAVEOUTCAPSA pwoc, UINT cbwoc); +typedef MMRESULT (WINAPI * MA_PFN_waveOutOpen)(LPHWAVEOUT phwo, UINT uDeviceID, LPCWAVEFORMATEX 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, LPWAVEHDR pwh, UINT cbwh); +typedef MMRESULT (WINAPI * MA_PFN_waveOutUnprepareHeader)(HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh); +typedef MMRESULT (WINAPI * MA_PFN_waveOutWrite)(HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh); +typedef MMRESULT (WINAPI * MA_PFN_waveOutReset)(HWAVEOUT hwo); +typedef UINT (WINAPI * MA_PFN_waveInGetNumDevs)(void); +typedef MMRESULT (WINAPI * MA_PFN_waveInGetDevCapsA)(mal_uintptr uDeviceID, LPWAVEINCAPSA pwic, UINT cbwic); +typedef MMRESULT (WINAPI * MA_PFN_waveInOpen)(LPHWAVEIN phwi, UINT uDeviceID, LPCWAVEFORMATEX 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, LPWAVEHDR pwh, UINT cbwh); +typedef MMRESULT (WINAPI * MA_PFN_waveInUnprepareHeader)(HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh); +typedef MMRESULT (WINAPI * MA_PFN_waveInAddBuffer)(HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh); +typedef MMRESULT (WINAPI * MA_PFN_waveInStart)(HWAVEIN hwi); +typedef MMRESULT (WINAPI * MA_PFN_waveInReset)(HWAVEIN hwi); mal_result mal_result_from_MMRESULT(MMRESULT resultMM) { switch (resultMM) { - case MMSYSERR_NOERROR: return MAL_SUCCESS; - case MMSYSERR_BADDEVICEID: return MAL_INVALID_ARGS; - case MMSYSERR_INVALHANDLE: return MAL_INVALID_ARGS; - case MMSYSERR_NOMEM: return MAL_OUT_OF_MEMORY; - case MMSYSERR_INVALFLAG: return MAL_INVALID_ARGS; - case MMSYSERR_INVALPARAM: return MAL_INVALID_ARGS; - case MMSYSERR_HANDLEBUSY: return MAL_DEVICE_BUSY; - case MMSYSERR_ERROR: return MAL_ERROR; - default: return MAL_ERROR; + 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_DEVICE_BUSY; + case MMSYSERR_ERROR: return MA_ERROR; + default: return MA_ERROR; } } @@ -10105,7 +10105,7 @@ typedef struct DWORD dwFormats; WORD wChannels; GUID NameGuid; -} MAL_WAVECAPSA; +} MA_WAVECAPSA; mal_result mal_get_best_info_from_formats_flags__winmm(DWORD dwFormats, WORD channels, WORD* pBitsPerSample, DWORD* pSampleRate) { @@ -10144,7 +10144,7 @@ mal_result mal_get_best_info_from_formats_flags__winmm(DWORD dwFormats, WORD cha } else if ((dwFormats & WAVE_FORMAT_96M08) != 0) { sampleRate = 96000; } else { - return MAL_FORMAT_NOT_SUPPORTED; + return MA_FORMAT_NOT_SUPPORTED; } } } else { @@ -10172,7 +10172,7 @@ mal_result mal_get_best_info_from_formats_flags__winmm(DWORD dwFormats, WORD cha } else if ((dwFormats & WAVE_FORMAT_96S08) != 0) { sampleRate = 96000; } else { - return MAL_FORMAT_NOT_SUPPORTED; + return MA_FORMAT_NOT_SUPPORTED; } } } @@ -10184,7 +10184,7 @@ mal_result mal_get_best_info_from_formats_flags__winmm(DWORD dwFormats, WORD cha *pSampleRate = sampleRate; } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_formats_flags_to_WAVEFORMATEX__winmm(DWORD dwFormats, WORD channels, WAVEFORMATEX* pWF) @@ -10224,7 +10224,7 @@ mal_result mal_formats_flags_to_WAVEFORMATEX__winmm(DWORD dwFormats, WORD channe } else if ((dwFormats & WAVE_FORMAT_96M08) != 0) { pWF->nSamplesPerSec = 96000; } else { - return MAL_FORMAT_NOT_SUPPORTED; + return MA_FORMAT_NOT_SUPPORTED; } } } else { @@ -10252,7 +10252,7 @@ mal_result mal_formats_flags_to_WAVEFORMATEX__winmm(DWORD dwFormats, WORD channe } else if ((dwFormats & WAVE_FORMAT_96S08) != 0) { pWF->nSamplesPerSec = 96000; } else { - return MAL_FORMAT_NOT_SUPPORTED; + return MA_FORMAT_NOT_SUPPORTED; } } } @@ -10260,10 +10260,10 @@ mal_result mal_formats_flags_to_WAVEFORMATEX__winmm(DWORD dwFormats, WORD channe pWF->nBlockAlign = (pWF->nChannels * pWF->wBitsPerSample) / 8; pWF->nAvgBytesPerSec = pWF->nBlockAlign * pWF->nSamplesPerSec; - return MAL_SUCCESS; + return MA_SUCCESS; } -mal_result mal_context_get_device_info_from_WAVECAPS(mal_context* pContext, MAL_WAVECAPSA* pCaps, mal_device_info* pDeviceInfo) +mal_result mal_context_get_device_info_from_WAVECAPS(mal_context* pContext, MA_WAVECAPSA* pCaps, mal_device_info* pDeviceInfo) { mal_assert(pContext != NULL); mal_assert(pCaps != NULL); @@ -10286,9 +10286,9 @@ mal_result mal_context_get_device_info_from_WAVECAPS(mal_context* pContext, MAL_ // but WinMM does not specificy the component name. From my admittedly limited testing, I've notice the component name seems to // usually fit within the 31 characters of the fixed sized buffer, so what I'm going to do is parse that string for the component // name, and then concatenate the name from the registry. - if (!mal_is_guid_equal(&pCaps->NameGuid, &MAL_GUID_NULL)) { + if (!mal_is_guid_equal(&pCaps->NameGuid, &MA_GUID_NULL)) { wchar_t guidStrW[256]; - if (((MAL_PFN_StringFromGUID2)pContext->win32.StringFromGUID2)(&pCaps->NameGuid, guidStrW, mal_countof(guidStrW)) > 0) { + if (((MA_PFN_StringFromGUID2)pContext->win32.StringFromGUID2)(&pCaps->NameGuid, guidStrW, mal_countof(guidStrW)) > 0) { char guidStr[256]; WideCharToMultiByte(CP_UTF8, 0, guidStrW, -1, guidStr, sizeof(guidStr), 0, FALSE); @@ -10297,12 +10297,12 @@ mal_result mal_context_get_device_info_from_WAVECAPS(mal_context* pContext, MAL_ mal_strcat_s(keyStr, sizeof(keyStr), guidStr); HKEY hKey; - LONG result = ((MAL_PFN_RegOpenKeyExA)pContext->win32.RegOpenKeyExA)(HKEY_LOCAL_MACHINE, keyStr, 0, KEY_READ, &hKey); + LONG result = ((MA_PFN_RegOpenKeyExA)pContext->win32.RegOpenKeyExA)(HKEY_LOCAL_MACHINE, keyStr, 0, KEY_READ, &hKey); if (result == ERROR_SUCCESS) { BYTE nameFromReg[512]; DWORD nameFromRegSize = sizeof(nameFromReg); - result = ((MAL_PFN_RegQueryValueExA)pContext->win32.RegQueryValueExA)(hKey, "Name", 0, NULL, (LPBYTE)nameFromReg, (LPDWORD)&nameFromRegSize); - ((MAL_PFN_RegCloseKey)pContext->win32.RegCloseKey)(hKey); + result = ((MA_PFN_RegQueryValueExA)pContext->win32.RegQueryValueExA)(hKey, "Name", 0, NULL, (LPBYTE)nameFromReg, (LPDWORD)&nameFromRegSize); + ((MA_PFN_RegCloseKey)pContext->win32.RegCloseKey)(hKey); if (result == ERROR_SUCCESS) { // We have the value from the registry, so now we need to construct the name string. @@ -10330,7 +10330,7 @@ mal_result mal_context_get_device_info_from_WAVECAPS(mal_context* pContext, MAL_ WORD bitsPerSample; DWORD sampleRate; mal_result result = mal_get_best_info_from_formats_flags__winmm(pCaps->dwFormats, pCaps->wChannels, &bitsPerSample, &sampleRate); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -10348,19 +10348,19 @@ mal_result mal_context_get_device_info_from_WAVECAPS(mal_context* pContext, MAL_ } else if (bitsPerSample == 32) { pDeviceInfo->formats[0] = mal_format_s32; } else { - return MAL_FORMAT_NOT_SUPPORTED; + return MA_FORMAT_NOT_SUPPORTED; } - return MAL_SUCCESS; + return MA_SUCCESS; } -mal_result mal_context_get_device_info_from_WAVEOUTCAPS2(mal_context* pContext, MAL_WAVEOUTCAPS2A* pCaps, mal_device_info* pDeviceInfo) +mal_result mal_context_get_device_info_from_WAVEOUTCAPS2(mal_context* pContext, MA_WAVEOUTCAPS2A* pCaps, mal_device_info* pDeviceInfo) { mal_assert(pContext != NULL); mal_assert(pCaps != NULL); mal_assert(pDeviceInfo != NULL); - MAL_WAVECAPSA caps; + MA_WAVECAPSA caps; mal_copy_memory(caps.szPname, pCaps->szPname, sizeof(caps.szPname)); caps.dwFormats = pCaps->dwFormats; caps.wChannels = pCaps->wChannels; @@ -10368,13 +10368,13 @@ mal_result mal_context_get_device_info_from_WAVEOUTCAPS2(mal_context* pContext, return mal_context_get_device_info_from_WAVECAPS(pContext, &caps, pDeviceInfo); } -mal_result mal_context_get_device_info_from_WAVEINCAPS2(mal_context* pContext, MAL_WAVEINCAPS2A* pCaps, mal_device_info* pDeviceInfo) +mal_result mal_context_get_device_info_from_WAVEINCAPS2(mal_context* pContext, MA_WAVEINCAPS2A* pCaps, mal_device_info* pDeviceInfo) { mal_assert(pContext != NULL); mal_assert(pCaps != NULL); mal_assert(pDeviceInfo != NULL); - MAL_WAVECAPSA caps; + MA_WAVECAPSA caps; mal_copy_memory(caps.szPname, pCaps->szPname, sizeof(caps.szPname)); caps.dwFormats = pCaps->dwFormats; caps.wChannels = pCaps->wChannels; @@ -10399,46 +10399,46 @@ mal_result mal_context_enumerate_devices__winmm(mal_context* pContext, mal_enum_ mal_assert(callback != NULL); // Playback. - UINT playbackDeviceCount = ((MAL_PFN_waveOutGetNumDevs)pContext->winmm.waveOutGetNumDevs)(); + UINT playbackDeviceCount = ((MA_PFN_waveOutGetNumDevs)pContext->winmm.waveOutGetNumDevs)(); for (UINT iPlaybackDevice = 0; iPlaybackDevice < playbackDeviceCount; ++iPlaybackDevice) { - MAL_WAVEOUTCAPS2A caps; + MA_WAVEOUTCAPS2A caps; mal_zero_object(&caps); - MMRESULT result = ((MAL_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(iPlaybackDevice, (WAVEOUTCAPSA*)&caps, sizeof(caps)); + MMRESULT result = ((MA_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(iPlaybackDevice, (WAVEOUTCAPSA*)&caps, sizeof(caps)); if (result == MMSYSERR_NOERROR) { mal_device_info deviceInfo; mal_zero_object(&deviceInfo); deviceInfo.id.winmm = iPlaybackDevice; - if (mal_context_get_device_info_from_WAVEOUTCAPS2(pContext, &caps, &deviceInfo) == MAL_SUCCESS) { + if (mal_context_get_device_info_from_WAVEOUTCAPS2(pContext, &caps, &deviceInfo) == MA_SUCCESS) { mal_bool32 cbResult = callback(pContext, mal_device_type_playback, &deviceInfo, pUserData); - if (cbResult == MAL_FALSE) { - return MAL_SUCCESS; // Enumeration was stopped. + if (cbResult == MA_FALSE) { + return MA_SUCCESS; // Enumeration was stopped. } } } } // Capture. - UINT captureDeviceCount = ((MAL_PFN_waveInGetNumDevs)pContext->winmm.waveInGetNumDevs)(); + UINT captureDeviceCount = ((MA_PFN_waveInGetNumDevs)pContext->winmm.waveInGetNumDevs)(); for (UINT iCaptureDevice = 0; iCaptureDevice < captureDeviceCount; ++iCaptureDevice) { - MAL_WAVEINCAPS2A caps; + MA_WAVEINCAPS2A caps; mal_zero_object(&caps); - MMRESULT result = ((MAL_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(iCaptureDevice, (WAVEINCAPSA*)&caps, sizeof(caps)); + MMRESULT result = ((MA_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(iCaptureDevice, (WAVEINCAPSA*)&caps, sizeof(caps)); if (result == MMSYSERR_NOERROR) { mal_device_info deviceInfo; mal_zero_object(&deviceInfo); deviceInfo.id.winmm = iCaptureDevice; - if (mal_context_get_device_info_from_WAVEINCAPS2(pContext, &caps, &deviceInfo) == MAL_SUCCESS) { + if (mal_context_get_device_info_from_WAVEINCAPS2(pContext, &caps, &deviceInfo) == MA_SUCCESS) { mal_bool32 cbResult = callback(pContext, mal_device_type_capture, &deviceInfo, pUserData); - if (cbResult == MAL_FALSE) { - return MAL_SUCCESS; // Enumeration was stopped. + if (cbResult == MA_FALSE) { + return MA_SUCCESS; // Enumeration was stopped. } } } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_get_device_info__winmm(mal_context* pContext, mal_device_type deviceType, const mal_device_id* pDeviceID, mal_share_mode shareMode, mal_device_info* pDeviceInfo) @@ -10446,7 +10446,7 @@ mal_result mal_context_get_device_info__winmm(mal_context* pContext, mal_device_ mal_assert(pContext != NULL); if (shareMode == mal_share_mode_exclusive) { - return MAL_SHARE_MODE_NOT_SUPPORTED; + return MA_SHARE_MODE_NOT_SUPPORTED; } UINT winMMDeviceID = 0; @@ -10457,22 +10457,22 @@ mal_result mal_context_get_device_info__winmm(mal_context* pContext, mal_device_ pDeviceInfo->id.winmm = winMMDeviceID; if (deviceType == mal_device_type_playback) { - MAL_WAVEOUTCAPS2A caps; + MA_WAVEOUTCAPS2A caps; mal_zero_object(&caps); - MMRESULT result = ((MAL_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(winMMDeviceID, (WAVEOUTCAPSA*)&caps, sizeof(caps)); + MMRESULT result = ((MA_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(winMMDeviceID, (WAVEOUTCAPSA*)&caps, sizeof(caps)); if (result == MMSYSERR_NOERROR) { return mal_context_get_device_info_from_WAVEOUTCAPS2(pContext, &caps, pDeviceInfo); } } else { - MAL_WAVEINCAPS2A caps; + MA_WAVEINCAPS2A caps; mal_zero_object(&caps); - MMRESULT result = ((MAL_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(winMMDeviceID, (WAVEINCAPSA*)&caps, sizeof(caps)); + MMRESULT result = ((MA_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(winMMDeviceID, (WAVEINCAPSA*)&caps, sizeof(caps)); if (result == MMSYSERR_NOERROR) { return mal_context_get_device_info_from_WAVEINCAPS2(pContext, &caps, pDeviceInfo); } } - return MAL_NO_DEVICE; + return MA_NO_DEVICE; } @@ -10480,15 +10480,15 @@ void mal_device_uninit__winmm(mal_device* pDevice) { mal_assert(pDevice != NULL); - ((MAL_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset); + ((MA_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset); if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { - ((MAL_PFN_waveInClose)pDevice->pContext->winmm.waveInClose)((HWAVEIN)pDevice->winmm.hDeviceCapture); + ((MA_PFN_waveInClose)pDevice->pContext->winmm.waveInClose)((HWAVEIN)pDevice->winmm.hDeviceCapture); CloseHandle((HANDLE)pDevice->winmm.hEventCapture); } if (pDevice->type == mal_device_type_playback) { - ((MAL_PFN_waveOutClose)pDevice->pContext->winmm.waveOutClose)((HWAVEOUT)pDevice->winmm.hDevicePlayback); + ((MA_PFN_waveOutClose)pDevice->pContext->winmm.waveOutClose)((HWAVEOUT)pDevice->winmm.hDevicePlayback); CloseHandle((HANDLE)pDevice->winmm.hEventPlayback); } @@ -10500,8 +10500,8 @@ void mal_device_uninit__winmm(mal_device* pDevice) mal_result mal_device_init__winmm(mal_context* pContext, const mal_device_config* pConfig, mal_device* pDevice) { const char* errorMsg = ""; - mal_result errorCode = MAL_ERROR; - mal_result result = MAL_SUCCESS; + mal_result errorCode = MA_ERROR; + mal_result result = MA_SUCCESS; mal_uint32 heapSize; UINT winMMDeviceIDPlayback = 0; UINT winMMDeviceIDCapture = 0; @@ -10512,7 +10512,7 @@ mal_result mal_device_init__winmm(mal_context* pContext, const mal_device_config /* No exlusive mode with WinMM. */ if (((pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) && pConfig->playback.shareMode == mal_share_mode_exclusive) || ((pConfig->deviceType == mal_device_type_capture || pConfig->deviceType == mal_device_type_duplex) && pConfig->capture.shareMode == mal_share_mode_exclusive)) { - return MAL_SHARE_MODE_NOT_SUPPORTED; + return MA_SHARE_MODE_NOT_SUPPORTED; } mal_uint32 bufferSizeInMilliseconds = pConfig->bufferSizeInMilliseconds; @@ -10546,25 +10546,25 @@ mal_result mal_device_init__winmm(mal_context* pContext, const mal_device_config // We use an event to know when a new fragment needs to be enqueued. pDevice->winmm.hEventCapture = (mal_handle)CreateEvent(NULL, TRUE, TRUE, NULL); if (pDevice->winmm.hEventCapture == NULL) { - errorMsg = "[WinMM] Failed to create event for fragment enqueing for the capture device.", errorCode = MAL_FAILED_TO_CREATE_EVENT; + errorMsg = "[WinMM] Failed to create event for fragment enqueing for the capture device.", errorCode = MA_FAILED_TO_CREATE_EVENT; goto on_error; } // The format should be based on the device's actual format. - if (((MAL_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(winMMDeviceIDCapture, &caps, sizeof(caps)) != MMSYSERR_NOERROR) { - errorMsg = "[WinMM] Failed to retrieve internal device caps.", errorCode = MAL_FORMAT_NOT_SUPPORTED; + if (((MA_PFN_waveInGetDevCapsA)pContext->winmm.waveInGetDevCapsA)(winMMDeviceIDCapture, &caps, sizeof(caps)) != MMSYSERR_NOERROR) { + errorMsg = "[WinMM] Failed to retrieve internal device caps.", errorCode = MA_FORMAT_NOT_SUPPORTED; goto on_error; } result = mal_formats_flags_to_WAVEFORMATEX__winmm(caps.dwFormats, caps.wChannels, &wf); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { errorMsg = "[WinMM] Could not find appropriate format for internal device.", errorCode = result; goto on_error; } - resultMM = ((MAL_PFN_waveInOpen)pDevice->pContext->winmm.waveInOpen)((LPHWAVEIN)&pDevice->winmm.hDeviceCapture, winMMDeviceIDCapture, &wf, (DWORD_PTR)pDevice->winmm.hEventCapture, (DWORD_PTR)pDevice, CALLBACK_EVENT | WAVE_ALLOWSYNC); + resultMM = ((MA_PFN_waveInOpen)pDevice->pContext->winmm.waveInOpen)((LPHWAVEIN)&pDevice->winmm.hDeviceCapture, winMMDeviceIDCapture, &wf, (DWORD_PTR)pDevice->winmm.hEventCapture, (DWORD_PTR)pDevice, CALLBACK_EVENT | WAVE_ALLOWSYNC); if (resultMM != MMSYSERR_NOERROR) { - errorMsg = "[WinMM] Failed to open capture device.", errorCode = MAL_FAILED_TO_OPEN_BACKEND_DEVICE; + errorMsg = "[WinMM] Failed to open capture device.", errorCode = MA_FAILED_TO_OPEN_BACKEND_DEVICE; goto on_error; } @@ -10584,25 +10584,25 @@ mal_result mal_device_init__winmm(mal_context* pContext, const mal_device_config // We use an event to know when a new fragment needs to be enqueued. pDevice->winmm.hEventPlayback = (mal_handle)CreateEvent(NULL, TRUE, TRUE, NULL); if (pDevice->winmm.hEventPlayback == NULL) { - errorMsg = "[WinMM] Failed to create event for fragment enqueing for the playback device.", errorCode = MAL_FAILED_TO_CREATE_EVENT; + errorMsg = "[WinMM] Failed to create event for fragment enqueing for the playback device.", errorCode = MA_FAILED_TO_CREATE_EVENT; goto on_error; } // The format should be based on the device's actual format. - if (((MAL_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(winMMDeviceIDPlayback, &caps, sizeof(caps)) != MMSYSERR_NOERROR) { - errorMsg = "[WinMM] Failed to retrieve internal device caps.", errorCode = MAL_FORMAT_NOT_SUPPORTED; + if (((MA_PFN_waveOutGetDevCapsA)pContext->winmm.waveOutGetDevCapsA)(winMMDeviceIDPlayback, &caps, sizeof(caps)) != MMSYSERR_NOERROR) { + errorMsg = "[WinMM] Failed to retrieve internal device caps.", errorCode = MA_FORMAT_NOT_SUPPORTED; goto on_error; } result = mal_formats_flags_to_WAVEFORMATEX__winmm(caps.dwFormats, caps.wChannels, &wf); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { errorMsg = "[WinMM] Could not find appropriate format for internal device.", errorCode = result; goto on_error; } - resultMM = ((MAL_PFN_waveOutOpen)pContext->winmm.waveOutOpen)((LPHWAVEOUT)&pDevice->winmm.hDevicePlayback, winMMDeviceIDPlayback, &wf, (DWORD_PTR)pDevice->winmm.hEventPlayback, (DWORD_PTR)pDevice, CALLBACK_EVENT | WAVE_ALLOWSYNC); + resultMM = ((MA_PFN_waveOutOpen)pContext->winmm.waveOutOpen)((LPHWAVEOUT)&pDevice->winmm.hDevicePlayback, winMMDeviceIDPlayback, &wf, (DWORD_PTR)pDevice->winmm.hEventPlayback, (DWORD_PTR)pDevice, CALLBACK_EVENT | WAVE_ALLOWSYNC); if (resultMM != MMSYSERR_NOERROR) { - errorMsg = "[WinMM] Failed to open playback device.", errorCode = MAL_FAILED_TO_OPEN_BACKEND_DEVICE; + errorMsg = "[WinMM] Failed to open playback device.", errorCode = MA_FAILED_TO_OPEN_BACKEND_DEVICE; goto on_error; } @@ -10627,7 +10627,7 @@ mal_result mal_device_init__winmm(mal_context* pContext, const mal_device_config pDevice->winmm._pHeapData = (mal_uint8*)mal_malloc(heapSize); if (pDevice->winmm._pHeapData == NULL) { - errorMsg = "[WinMM] Failed to allocate memory for the intermediary buffer.", errorCode = MAL_OUT_OF_MEMORY; + errorMsg = "[WinMM] Failed to allocate memory for the intermediary buffer.", errorCode = MA_OUT_OF_MEMORY; goto on_error; } @@ -10650,7 +10650,7 @@ mal_result mal_device_init__winmm(mal_context* pContext, const mal_device_config ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwBufferLength = fragmentSizeInBytes; ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwFlags = 0L; ((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod].dwLoops = 0L; - ((MAL_PFN_waveInPrepareHeader)pContext->winmm.waveInPrepareHeader)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(WAVEHDR)); + ((MA_PFN_waveInPrepareHeader)pContext->winmm.waveInPrepareHeader)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(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 @@ -10676,7 +10676,7 @@ mal_result mal_device_init__winmm(mal_context* pContext, const mal_device_config ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwBufferLength = fragmentSizeInBytes; ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwFlags = 0L; ((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod].dwLoops = 0L; - ((MAL_PFN_waveOutPrepareHeader)pContext->winmm.waveOutPrepareHeader)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(WAVEHDR)); + ((MA_PFN_waveOutPrepareHeader)pContext->winmm.waveOutPrepareHeader)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(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 @@ -10686,31 +10686,31 @@ mal_result mal_device_init__winmm(mal_context* pContext, const mal_device_config } } - return MAL_SUCCESS; + return MA_SUCCESS; on_error: if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { if (pDevice->winmm.pWAVEHDRCapture != NULL) { for (mal_uint32 iPeriod = 0; iPeriod < pDevice->capture.internalPeriods; ++iPeriod) { - ((MAL_PFN_waveInUnprepareHeader)pContext->winmm.waveInUnprepareHeader)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(WAVEHDR)); + ((MA_PFN_waveInUnprepareHeader)pContext->winmm.waveInUnprepareHeader)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((WAVEHDR*)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(WAVEHDR)); } } - ((MAL_PFN_waveInClose)pContext->winmm.waveInClose)((HWAVEIN)pDevice->winmm.hDeviceCapture); + ((MA_PFN_waveInClose)pContext->winmm.waveInClose)((HWAVEIN)pDevice->winmm.hDeviceCapture); } if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) { if (pDevice->winmm.pWAVEHDRCapture != NULL) { for (mal_uint32 iPeriod = 0; iPeriod < pDevice->playback.internalPeriods; ++iPeriod) { - ((MAL_PFN_waveOutUnprepareHeader)pContext->winmm.waveOutUnprepareHeader)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(WAVEHDR)); + ((MA_PFN_waveOutUnprepareHeader)pContext->winmm.waveOutUnprepareHeader)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &((WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback)[iPeriod], sizeof(WAVEHDR)); } } - ((MAL_PFN_waveOutClose)pContext->winmm.waveOutClose)((HWAVEOUT)pDevice->winmm.hDevicePlayback); + ((MA_PFN_waveOutClose)pContext->winmm.waveOutClose)((HWAVEOUT)pDevice->winmm.hDevicePlayback); } mal_free(pDevice->winmm._pHeapData); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, errorMsg, errorCode); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, errorMsg, errorCode); } mal_result mal_device_stop__winmm(mal_device* pDevice) @@ -10719,33 +10719,33 @@ mal_result mal_device_stop__winmm(mal_device* pDevice) if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { if (pDevice->winmm.hDeviceCapture == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } - MMRESULT resultMM = ((MAL_PFN_waveInReset)pDevice->pContext->winmm.waveInReset)((HWAVEIN)pDevice->winmm.hDeviceCapture); + MMRESULT resultMM = ((MA_PFN_waveInReset)pDevice->pContext->winmm.waveInReset)((HWAVEIN)pDevice->winmm.hDeviceCapture); if (resultMM != MMSYSERR_NOERROR) { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WinMM] WARNING: Failed to reset capture device.", mal_result_from_MMRESULT(resultMM)); + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] WARNING: Failed to reset capture device.", mal_result_from_MMRESULT(resultMM)); } } if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) { if (pDevice->winmm.hDevicePlayback == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } - MMRESULT resultMM = ((MAL_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset)((HWAVEOUT)pDevice->winmm.hDevicePlayback); + MMRESULT resultMM = ((MA_PFN_waveOutReset)pDevice->pContext->winmm.waveOutReset)((HWAVEOUT)pDevice->winmm.hDevicePlayback); if (resultMM != MMSYSERR_NOERROR) { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WinMM] WARNING: Failed to reset playback device.", mal_result_from_MMRESULT(resultMM)); + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] WARNING: Failed to reset playback device.", mal_result_from_MMRESULT(resultMM)); } } - mal_atomic_exchange_32(&pDevice->winmm.isStarted, MAL_FALSE); - return MAL_SUCCESS; + mal_atomic_exchange_32(&pDevice->winmm.isStarted, MA_FALSE); + return MA_SUCCESS; } mal_result mal_device_write__winmm(mal_device* pDevice, const void* pPCMFrames, mal_uint32 frameCount) { - mal_result result = MAL_SUCCESS; + mal_result result = MA_SUCCESS; MMRESULT resultMM; mal_uint32 totalFramesWritten; WAVEHDR* pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRPlayback; @@ -10782,13 +10782,13 @@ mal_result mal_device_write__winmm(mal_device* pDevice, const void* pPCMFrames, ResetEvent((HANDLE)pDevice->winmm.hEventPlayback); /* The device will be started here. */ - resultMM = ((MAL_PFN_waveOutWrite)pDevice->pContext->winmm.waveOutWrite)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &pWAVEHDR[pDevice->winmm.iNextHeaderPlayback], sizeof(WAVEHDR)); + resultMM = ((MA_PFN_waveOutWrite)pDevice->pContext->winmm.waveOutWrite)((HWAVEOUT)pDevice->winmm.hDevicePlayback, &pWAVEHDR[pDevice->winmm.iNextHeaderPlayback], sizeof(WAVEHDR)); if (resultMM != MMSYSERR_NOERROR) { result = mal_result_from_MMRESULT(resultMM); - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WinMM] waveOutWrite() failed.", result); + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] waveOutWrite() failed.", result); break; } - mal_atomic_exchange_32(&pDevice->winmm.isStarted, MAL_TRUE); + mal_atomic_exchange_32(&pDevice->winmm.isStarted, MA_TRUE); /* Make sure we move to the next header. */ pDevice->winmm.iNextHeaderPlayback = (pDevice->winmm.iNextHeaderPlayback + 1) % pDevice->playback.internalPeriods; @@ -10807,7 +10807,7 @@ mal_result mal_device_write__winmm(mal_device* pDevice, const void* pPCMFrames, /* Getting here means there isn't enough room in the buffer and we need to wait for one to become available. */ if (WaitForSingleObject((HANDLE)pDevice->winmm.hEventPlayback, INFINITE) != WAIT_OBJECT_0) { - result = MAL_ERROR; + result = MA_ERROR; break; } @@ -10831,7 +10831,7 @@ mal_result mal_device_read__winmm(mal_device* pDevice, void* pPCMFrames, mal_uin mal_assert(pDevice != NULL); mal_assert(pPCMFrames != NULL); - mal_result result = MAL_SUCCESS; + mal_result result = MA_SUCCESS; MMRESULT resultMM; mal_uint32 totalFramesRead; WAVEHDR* pWAVEHDR = (WAVEHDR*)pDevice->winmm.pWAVEHDRCapture; @@ -10843,9 +10843,9 @@ mal_result mal_device_read__winmm(mal_device* pDevice, void* pPCMFrames, mal_uin /* 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 (mal_uint32 iPeriod = 0; iPeriod < pDevice->capture.internalPeriods; ++iPeriod) { - resultMM = ((MAL_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((LPWAVEHDR)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(WAVEHDR)); + resultMM = ((MA_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((LPWAVEHDR)pDevice->winmm.pWAVEHDRCapture)[iPeriod], sizeof(WAVEHDR)); if (resultMM != MMSYSERR_NOERROR) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WinMM] Failed to attach input buffers to capture device in preparation for capture.", mal_result_from_MMRESULT(resultMM)); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] Failed to attach input buffers to capture device in preparation for capture.", mal_result_from_MMRESULT(resultMM)); } /* Make sure all of the buffers start out locked. We don't want to access them until the backend tells us we can. */ @@ -10853,12 +10853,12 @@ mal_result mal_device_read__winmm(mal_device* pDevice, void* pPCMFrames, mal_uin } /* Capture devices need to be explicitly started, unlike playback devices. */ - resultMM = ((MAL_PFN_waveInStart)pDevice->pContext->winmm.waveInStart)((HWAVEIN)pDevice->winmm.hDeviceCapture); + resultMM = ((MA_PFN_waveInStart)pDevice->pContext->winmm.waveInStart)((HWAVEIN)pDevice->winmm.hDeviceCapture); if (resultMM != MMSYSERR_NOERROR) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WinMM] Failed to start backend device.", mal_result_from_MMRESULT(resultMM)); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] Failed to start backend device.", mal_result_from_MMRESULT(resultMM)); } - mal_atomic_exchange_32(&pDevice->winmm.isStarted, MAL_TRUE); + mal_atomic_exchange_32(&pDevice->winmm.isStarted, MA_TRUE); } /* Keep processing as much data as possible. */ @@ -10887,10 +10887,10 @@ mal_result mal_device_read__winmm(mal_device* pDevice, void* pPCMFrames, mal_uin ResetEvent((HANDLE)pDevice->winmm.hEventCapture); /* The device will be started here. */ - resultMM = ((MAL_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((LPWAVEHDR)pDevice->winmm.pWAVEHDRCapture)[pDevice->winmm.iNextHeaderCapture], sizeof(WAVEHDR)); + resultMM = ((MA_PFN_waveInAddBuffer)pDevice->pContext->winmm.waveInAddBuffer)((HWAVEIN)pDevice->winmm.hDeviceCapture, &((LPWAVEHDR)pDevice->winmm.pWAVEHDRCapture)[pDevice->winmm.iNextHeaderCapture], sizeof(WAVEHDR)); if (resultMM != MMSYSERR_NOERROR) { result = mal_result_from_MMRESULT(resultMM); - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[WinMM] waveInAddBuffer() failed.", result); + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[WinMM] waveInAddBuffer() failed.", result); break; } @@ -10911,7 +10911,7 @@ mal_result mal_device_read__winmm(mal_device* pDevice, void* pPCMFrames, mal_uin /* Getting here means there isn't enough any data left to send to the client which means we need to wait for more. */ if (WaitForSingleObject((HANDLE)pDevice->winmm.hEventCapture, INFINITE) != WAIT_OBJECT_0) { - result = MAL_ERROR; + result = MA_ERROR; break; } @@ -10936,7 +10936,7 @@ mal_result mal_context_uninit__winmm(mal_context* pContext) mal_assert(pContext->backend == mal_backend_winmm); mal_dlclose(pContext->winmm.hWinMM); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_init__winmm(mal_context* pContext) @@ -10945,7 +10945,7 @@ mal_result mal_context_init__winmm(mal_context* pContext) pContext->winmm.hWinMM = mal_dlopen("winmm.dll"); if (pContext->winmm.hWinMM == NULL) { - return MAL_NO_BACKEND; + return MA_NO_BACKEND; } pContext->winmm.waveOutGetNumDevs = mal_dlsym(pContext->winmm.hWinMM, "waveOutGetNumDevs"); @@ -10977,7 +10977,7 @@ mal_result mal_context_init__winmm(mal_context* pContext) pContext->onDeviceWrite = mal_device_write__winmm; pContext->onDeviceRead = mal_device_read__winmm; - return MAL_SUCCESS; + return MA_SUCCESS; } #endif @@ -10989,9 +10989,9 @@ mal_result mal_context_init__winmm(mal_context* pContext) // ALSA Backend // /////////////////////////////////////////////////////////////////////////////// -#ifdef MAL_HAS_ALSA +#ifdef MA_HAS_ALSA -#ifdef MAL_NO_RUNTIME_LINKING +#ifdef MA_NO_RUNTIME_LINKING #include typedef snd_pcm_uframes_t mal_snd_pcm_uframes_t; typedef snd_pcm_sframes_t mal_snd_pcm_sframes_t; @@ -11007,77 +11007,77 @@ typedef snd_pcm_channel_area_t mal_snd_pcm_channel_area_t; typedef snd_pcm_chmap_t mal_snd_pcm_chmap_t; // snd_pcm_stream_t -#define MAL_SND_PCM_STREAM_PLAYBACK SND_PCM_STREAM_PLAYBACK -#define MAL_SND_PCM_STREAM_CAPTURE SND_PCM_STREAM_CAPTURE +#define MA_SND_PCM_STREAM_PLAYBACK SND_PCM_STREAM_PLAYBACK +#define MA_SND_PCM_STREAM_CAPTURE SND_PCM_STREAM_CAPTURE // snd_pcm_format_t -#define MAL_SND_PCM_FORMAT_UNKNOWN SND_PCM_FORMAT_UNKNOWN -#define MAL_SND_PCM_FORMAT_U8 SND_PCM_FORMAT_U8 -#define MAL_SND_PCM_FORMAT_S16_LE SND_PCM_FORMAT_S16_LE -#define MAL_SND_PCM_FORMAT_S16_BE SND_PCM_FORMAT_S16_BE -#define MAL_SND_PCM_FORMAT_S24_LE SND_PCM_FORMAT_S24_LE -#define MAL_SND_PCM_FORMAT_S24_BE SND_PCM_FORMAT_S24_BE -#define MAL_SND_PCM_FORMAT_S32_LE SND_PCM_FORMAT_S32_LE -#define MAL_SND_PCM_FORMAT_S32_BE SND_PCM_FORMAT_S32_BE -#define MAL_SND_PCM_FORMAT_FLOAT_LE SND_PCM_FORMAT_FLOAT_LE -#define MAL_SND_PCM_FORMAT_FLOAT_BE SND_PCM_FORMAT_FLOAT_BE -#define MAL_SND_PCM_FORMAT_FLOAT64_LE SND_PCM_FORMAT_FLOAT64_LE -#define MAL_SND_PCM_FORMAT_FLOAT64_BE SND_PCM_FORMAT_FLOAT64_BE -#define MAL_SND_PCM_FORMAT_MU_LAW SND_PCM_FORMAT_MU_LAW -#define MAL_SND_PCM_FORMAT_A_LAW SND_PCM_FORMAT_A_LAW -#define MAL_SND_PCM_FORMAT_S24_3LE SND_PCM_FORMAT_S24_3LE -#define MAL_SND_PCM_FORMAT_S24_3BE SND_PCM_FORMAT_S24_3BE +#define MA_SND_PCM_FORMAT_UNKNOWN SND_PCM_FORMAT_UNKNOWN +#define MA_SND_PCM_FORMAT_U8 SND_PCM_FORMAT_U8 +#define MA_SND_PCM_FORMAT_S16_LE SND_PCM_FORMAT_S16_LE +#define MA_SND_PCM_FORMAT_S16_BE SND_PCM_FORMAT_S16_BE +#define MA_SND_PCM_FORMAT_S24_LE SND_PCM_FORMAT_S24_LE +#define MA_SND_PCM_FORMAT_S24_BE SND_PCM_FORMAT_S24_BE +#define MA_SND_PCM_FORMAT_S32_LE SND_PCM_FORMAT_S32_LE +#define MA_SND_PCM_FORMAT_S32_BE SND_PCM_FORMAT_S32_BE +#define MA_SND_PCM_FORMAT_FLOAT_LE SND_PCM_FORMAT_FLOAT_LE +#define MA_SND_PCM_FORMAT_FLOAT_BE SND_PCM_FORMAT_FLOAT_BE +#define MA_SND_PCM_FORMAT_FLOAT64_LE SND_PCM_FORMAT_FLOAT64_LE +#define MA_SND_PCM_FORMAT_FLOAT64_BE SND_PCM_FORMAT_FLOAT64_BE +#define MA_SND_PCM_FORMAT_MU_LAW SND_PCM_FORMAT_MU_LAW +#define MA_SND_PCM_FORMAT_A_LAW SND_PCM_FORMAT_A_LAW +#define MA_SND_PCM_FORMAT_S24_3LE SND_PCM_FORMAT_S24_3LE +#define MA_SND_PCM_FORMAT_S24_3BE SND_PCM_FORMAT_S24_3BE // mal_snd_pcm_access_t -#define MAL_SND_PCM_ACCESS_MMAP_INTERLEAVED SND_PCM_ACCESS_MMAP_INTERLEAVED -#define MAL_SND_PCM_ACCESS_MMAP_NONINTERLEAVED SND_PCM_ACCESS_MMAP_NONINTERLEAVED -#define MAL_SND_PCM_ACCESS_MMAP_COMPLEX SND_PCM_ACCESS_MMAP_COMPLEX -#define MAL_SND_PCM_ACCESS_RW_INTERLEAVED SND_PCM_ACCESS_RW_INTERLEAVED -#define MAL_SND_PCM_ACCESS_RW_NONINTERLEAVED SND_PCM_ACCESS_RW_NONINTERLEAVED +#define MA_SND_PCM_ACCESS_MMAP_INTERLEAVED SND_PCM_ACCESS_MMAP_INTERLEAVED +#define MA_SND_PCM_ACCESS_MMAP_NONINTERLEAVED SND_PCM_ACCESS_MMAP_NONINTERLEAVED +#define MA_SND_PCM_ACCESS_MMAP_COMPLEX SND_PCM_ACCESS_MMAP_COMPLEX +#define MA_SND_PCM_ACCESS_RW_INTERLEAVED SND_PCM_ACCESS_RW_INTERLEAVED +#define MA_SND_PCM_ACCESS_RW_NONINTERLEAVED SND_PCM_ACCESS_RW_NONINTERLEAVED // Channel positions. -#define MAL_SND_CHMAP_UNKNOWN SND_CHMAP_UNKNOWN -#define MAL_SND_CHMAP_NA SND_CHMAP_NA -#define MAL_SND_CHMAP_MONO SND_CHMAP_MONO -#define MAL_SND_CHMAP_FL SND_CHMAP_FL -#define MAL_SND_CHMAP_FR SND_CHMAP_FR -#define MAL_SND_CHMAP_RL SND_CHMAP_RL -#define MAL_SND_CHMAP_RR SND_CHMAP_RR -#define MAL_SND_CHMAP_FC SND_CHMAP_FC -#define MAL_SND_CHMAP_LFE SND_CHMAP_LFE -#define MAL_SND_CHMAP_SL SND_CHMAP_SL -#define MAL_SND_CHMAP_SR SND_CHMAP_SR -#define MAL_SND_CHMAP_RC SND_CHMAP_RC -#define MAL_SND_CHMAP_FLC SND_CHMAP_FLC -#define MAL_SND_CHMAP_FRC SND_CHMAP_FRC -#define MAL_SND_CHMAP_RLC SND_CHMAP_RLC -#define MAL_SND_CHMAP_RRC SND_CHMAP_RRC -#define MAL_SND_CHMAP_FLW SND_CHMAP_FLW -#define MAL_SND_CHMAP_FRW SND_CHMAP_FRW -#define MAL_SND_CHMAP_FLH SND_CHMAP_FLH -#define MAL_SND_CHMAP_FCH SND_CHMAP_FCH -#define MAL_SND_CHMAP_FRH SND_CHMAP_FRH -#define MAL_SND_CHMAP_TC SND_CHMAP_TC -#define MAL_SND_CHMAP_TFL SND_CHMAP_TFL -#define MAL_SND_CHMAP_TFR SND_CHMAP_TFR -#define MAL_SND_CHMAP_TFC SND_CHMAP_TFC -#define MAL_SND_CHMAP_TRL SND_CHMAP_TRL -#define MAL_SND_CHMAP_TRR SND_CHMAP_TRR -#define MAL_SND_CHMAP_TRC SND_CHMAP_TRC -#define MAL_SND_CHMAP_TFLC SND_CHMAP_TFLC -#define MAL_SND_CHMAP_TFRC SND_CHMAP_TFRC -#define MAL_SND_CHMAP_TSL SND_CHMAP_TSL -#define MAL_SND_CHMAP_TSR SND_CHMAP_TSR -#define MAL_SND_CHMAP_LLFE SND_CHMAP_LLFE -#define MAL_SND_CHMAP_RLFE SND_CHMAP_RLFE -#define MAL_SND_CHMAP_BC SND_CHMAP_BC -#define MAL_SND_CHMAP_BLC SND_CHMAP_BLC -#define MAL_SND_CHMAP_BRC SND_CHMAP_BRC +#define MA_SND_CHMAP_UNKNOWN SND_CHMAP_UNKNOWN +#define MA_SND_CHMAP_NA SND_CHMAP_NA +#define MA_SND_CHMAP_MONO SND_CHMAP_MONO +#define MA_SND_CHMAP_FL SND_CHMAP_FL +#define MA_SND_CHMAP_FR SND_CHMAP_FR +#define MA_SND_CHMAP_RL SND_CHMAP_RL +#define MA_SND_CHMAP_RR SND_CHMAP_RR +#define MA_SND_CHMAP_FC SND_CHMAP_FC +#define MA_SND_CHMAP_LFE SND_CHMAP_LFE +#define MA_SND_CHMAP_SL SND_CHMAP_SL +#define MA_SND_CHMAP_SR SND_CHMAP_SR +#define MA_SND_CHMAP_RC SND_CHMAP_RC +#define MA_SND_CHMAP_FLC SND_CHMAP_FLC +#define MA_SND_CHMAP_FRC SND_CHMAP_FRC +#define MA_SND_CHMAP_RLC SND_CHMAP_RLC +#define MA_SND_CHMAP_RRC SND_CHMAP_RRC +#define MA_SND_CHMAP_FLW SND_CHMAP_FLW +#define MA_SND_CHMAP_FRW SND_CHMAP_FRW +#define MA_SND_CHMAP_FLH SND_CHMAP_FLH +#define MA_SND_CHMAP_FCH SND_CHMAP_FCH +#define MA_SND_CHMAP_FRH SND_CHMAP_FRH +#define MA_SND_CHMAP_TC SND_CHMAP_TC +#define MA_SND_CHMAP_TFL SND_CHMAP_TFL +#define MA_SND_CHMAP_TFR SND_CHMAP_TFR +#define MA_SND_CHMAP_TFC SND_CHMAP_TFC +#define MA_SND_CHMAP_TRL SND_CHMAP_TRL +#define MA_SND_CHMAP_TRR SND_CHMAP_TRR +#define MA_SND_CHMAP_TRC SND_CHMAP_TRC +#define MA_SND_CHMAP_TFLC SND_CHMAP_TFLC +#define MA_SND_CHMAP_TFRC SND_CHMAP_TFRC +#define MA_SND_CHMAP_TSL SND_CHMAP_TSL +#define MA_SND_CHMAP_TSR SND_CHMAP_TSR +#define MA_SND_CHMAP_LLFE SND_CHMAP_LLFE +#define MA_SND_CHMAP_RLFE SND_CHMAP_RLFE +#define MA_SND_CHMAP_BC SND_CHMAP_BC +#define MA_SND_CHMAP_BLC SND_CHMAP_BLC +#define MA_SND_CHMAP_BRC SND_CHMAP_BRC // Open mode flags. -#define MAL_SND_PCM_NO_AUTO_RESAMPLE SND_PCM_NO_AUTO_RESAMPLE -#define MAL_SND_PCM_NO_AUTO_CHANNELS SND_PCM_NO_AUTO_CHANNELS -#define MAL_SND_PCM_NO_AUTO_FORMAT SND_PCM_NO_AUTO_FORMAT +#define MA_SND_PCM_NO_AUTO_RESAMPLE SND_PCM_NO_AUTO_RESAMPLE +#define MA_SND_PCM_NO_AUTO_CHANNELS SND_PCM_NO_AUTO_CHANNELS +#define MA_SND_PCM_NO_AUTO_FORMAT SND_PCM_NO_AUTO_FORMAT #else #include // For EPIPE, etc. typedef unsigned long mal_snd_pcm_uframes_t; @@ -11103,88 +11103,88 @@ typedef struct } mal_snd_pcm_chmap_t; // snd_pcm_state_t -#define MAL_SND_PCM_STATE_OPEN 0 -#define MAL_SND_PCM_STATE_SETUP 1 -#define MAL_SND_PCM_STATE_PREPARED 2 -#define MAL_SND_PCM_STATE_RUNNING 3 -#define MAL_SND_PCM_STATE_XRUN 4 -#define MAL_SND_PCM_STATE_DRAINING 5 -#define MAL_SND_PCM_STATE_PAUSED 6 -#define MAL_SND_PCM_STATE_SUSPENDED 7 -#define MAL_SND_PCM_STATE_DISCONNECTED 8 +#define MA_SND_PCM_STATE_OPEN 0 +#define MA_SND_PCM_STATE_SETUP 1 +#define MA_SND_PCM_STATE_PREPARED 2 +#define MA_SND_PCM_STATE_RUNNING 3 +#define MA_SND_PCM_STATE_XRUN 4 +#define MA_SND_PCM_STATE_DRAINING 5 +#define MA_SND_PCM_STATE_PAUSED 6 +#define MA_SND_PCM_STATE_SUSPENDED 7 +#define MA_SND_PCM_STATE_DISCONNECTED 8 // snd_pcm_stream_t -#define MAL_SND_PCM_STREAM_PLAYBACK 0 -#define MAL_SND_PCM_STREAM_CAPTURE 1 +#define MA_SND_PCM_STREAM_PLAYBACK 0 +#define MA_SND_PCM_STREAM_CAPTURE 1 // snd_pcm_format_t -#define MAL_SND_PCM_FORMAT_UNKNOWN -1 -#define MAL_SND_PCM_FORMAT_U8 1 -#define MAL_SND_PCM_FORMAT_S16_LE 2 -#define MAL_SND_PCM_FORMAT_S16_BE 3 -#define MAL_SND_PCM_FORMAT_S24_LE 6 -#define MAL_SND_PCM_FORMAT_S24_BE 7 -#define MAL_SND_PCM_FORMAT_S32_LE 10 -#define MAL_SND_PCM_FORMAT_S32_BE 11 -#define MAL_SND_PCM_FORMAT_FLOAT_LE 14 -#define MAL_SND_PCM_FORMAT_FLOAT_BE 15 -#define MAL_SND_PCM_FORMAT_FLOAT64_LE 16 -#define MAL_SND_PCM_FORMAT_FLOAT64_BE 17 -#define MAL_SND_PCM_FORMAT_MU_LAW 20 -#define MAL_SND_PCM_FORMAT_A_LAW 21 -#define MAL_SND_PCM_FORMAT_S24_3LE 32 -#define MAL_SND_PCM_FORMAT_S24_3BE 33 +#define MA_SND_PCM_FORMAT_UNKNOWN -1 +#define MA_SND_PCM_FORMAT_U8 1 +#define MA_SND_PCM_FORMAT_S16_LE 2 +#define MA_SND_PCM_FORMAT_S16_BE 3 +#define MA_SND_PCM_FORMAT_S24_LE 6 +#define MA_SND_PCM_FORMAT_S24_BE 7 +#define MA_SND_PCM_FORMAT_S32_LE 10 +#define MA_SND_PCM_FORMAT_S32_BE 11 +#define MA_SND_PCM_FORMAT_FLOAT_LE 14 +#define MA_SND_PCM_FORMAT_FLOAT_BE 15 +#define MA_SND_PCM_FORMAT_FLOAT64_LE 16 +#define MA_SND_PCM_FORMAT_FLOAT64_BE 17 +#define MA_SND_PCM_FORMAT_MU_LAW 20 +#define MA_SND_PCM_FORMAT_A_LAW 21 +#define MA_SND_PCM_FORMAT_S24_3LE 32 +#define MA_SND_PCM_FORMAT_S24_3BE 33 // snd_pcm_access_t -#define MAL_SND_PCM_ACCESS_MMAP_INTERLEAVED 0 -#define MAL_SND_PCM_ACCESS_MMAP_NONINTERLEAVED 1 -#define MAL_SND_PCM_ACCESS_MMAP_COMPLEX 2 -#define MAL_SND_PCM_ACCESS_RW_INTERLEAVED 3 -#define MAL_SND_PCM_ACCESS_RW_NONINTERLEAVED 4 +#define MA_SND_PCM_ACCESS_MMAP_INTERLEAVED 0 +#define MA_SND_PCM_ACCESS_MMAP_NONINTERLEAVED 1 +#define MA_SND_PCM_ACCESS_MMAP_COMPLEX 2 +#define MA_SND_PCM_ACCESS_RW_INTERLEAVED 3 +#define MA_SND_PCM_ACCESS_RW_NONINTERLEAVED 4 // Channel positions. -#define MAL_SND_CHMAP_UNKNOWN 0 -#define MAL_SND_CHMAP_NA 1 -#define MAL_SND_CHMAP_MONO 2 -#define MAL_SND_CHMAP_FL 3 -#define MAL_SND_CHMAP_FR 4 -#define MAL_SND_CHMAP_RL 5 -#define MAL_SND_CHMAP_RR 6 -#define MAL_SND_CHMAP_FC 7 -#define MAL_SND_CHMAP_LFE 8 -#define MAL_SND_CHMAP_SL 9 -#define MAL_SND_CHMAP_SR 10 -#define MAL_SND_CHMAP_RC 11 -#define MAL_SND_CHMAP_FLC 12 -#define MAL_SND_CHMAP_FRC 13 -#define MAL_SND_CHMAP_RLC 14 -#define MAL_SND_CHMAP_RRC 15 -#define MAL_SND_CHMAP_FLW 16 -#define MAL_SND_CHMAP_FRW 17 -#define MAL_SND_CHMAP_FLH 18 -#define MAL_SND_CHMAP_FCH 19 -#define MAL_SND_CHMAP_FRH 20 -#define MAL_SND_CHMAP_TC 21 -#define MAL_SND_CHMAP_TFL 22 -#define MAL_SND_CHMAP_TFR 23 -#define MAL_SND_CHMAP_TFC 24 -#define MAL_SND_CHMAP_TRL 25 -#define MAL_SND_CHMAP_TRR 26 -#define MAL_SND_CHMAP_TRC 27 -#define MAL_SND_CHMAP_TFLC 28 -#define MAL_SND_CHMAP_TFRC 29 -#define MAL_SND_CHMAP_TSL 30 -#define MAL_SND_CHMAP_TSR 31 -#define MAL_SND_CHMAP_LLFE 32 -#define MAL_SND_CHMAP_RLFE 33 -#define MAL_SND_CHMAP_BC 34 -#define MAL_SND_CHMAP_BLC 35 -#define MAL_SND_CHMAP_BRC 36 +#define MA_SND_CHMAP_UNKNOWN 0 +#define MA_SND_CHMAP_NA 1 +#define MA_SND_CHMAP_MONO 2 +#define MA_SND_CHMAP_FL 3 +#define MA_SND_CHMAP_FR 4 +#define MA_SND_CHMAP_RL 5 +#define MA_SND_CHMAP_RR 6 +#define MA_SND_CHMAP_FC 7 +#define MA_SND_CHMAP_LFE 8 +#define MA_SND_CHMAP_SL 9 +#define MA_SND_CHMAP_SR 10 +#define MA_SND_CHMAP_RC 11 +#define MA_SND_CHMAP_FLC 12 +#define MA_SND_CHMAP_FRC 13 +#define MA_SND_CHMAP_RLC 14 +#define MA_SND_CHMAP_RRC 15 +#define MA_SND_CHMAP_FLW 16 +#define MA_SND_CHMAP_FRW 17 +#define MA_SND_CHMAP_FLH 18 +#define MA_SND_CHMAP_FCH 19 +#define MA_SND_CHMAP_FRH 20 +#define MA_SND_CHMAP_TC 21 +#define MA_SND_CHMAP_TFL 22 +#define MA_SND_CHMAP_TFR 23 +#define MA_SND_CHMAP_TFC 24 +#define MA_SND_CHMAP_TRL 25 +#define MA_SND_CHMAP_TRR 26 +#define MA_SND_CHMAP_TRC 27 +#define MA_SND_CHMAP_TFLC 28 +#define MA_SND_CHMAP_TFRC 29 +#define MA_SND_CHMAP_TSL 30 +#define MA_SND_CHMAP_TSR 31 +#define MA_SND_CHMAP_LLFE 32 +#define MA_SND_CHMAP_RLFE 33 +#define MA_SND_CHMAP_BC 34 +#define MA_SND_CHMAP_BLC 35 +#define MA_SND_CHMAP_BRC 36 // Open mode flags. -#define MAL_SND_PCM_NO_AUTO_RESAMPLE 0x00010000 -#define MAL_SND_PCM_NO_AUTO_CHANNELS 0x00020000 -#define MAL_SND_PCM_NO_AUTO_FORMAT 0x00040000 +#define MA_SND_PCM_NO_AUTO_RESAMPLE 0x00010000 +#define MA_SND_PCM_NO_AUTO_CHANNELS 0x00020000 +#define MA_SND_PCM_NO_AUTO_FORMAT 0x00040000 #endif typedef int (* mal_snd_pcm_open_proc) (mal_snd_pcm_t **pcm, const char *name, mal_snd_pcm_stream_t stream, int mode); @@ -11291,21 +11291,21 @@ float mal_find_default_buffer_size_scale__alsa(const char* deviceName) mal_snd_pcm_format_t mal_convert_mal_format_to_alsa_format(mal_format format) { mal_snd_pcm_format_t ALSAFormats[] = { - MAL_SND_PCM_FORMAT_UNKNOWN, // mal_format_unknown - MAL_SND_PCM_FORMAT_U8, // mal_format_u8 - MAL_SND_PCM_FORMAT_S16_LE, // mal_format_s16 - MAL_SND_PCM_FORMAT_S24_3LE, // mal_format_s24 - MAL_SND_PCM_FORMAT_S32_LE, // mal_format_s32 - MAL_SND_PCM_FORMAT_FLOAT_LE // mal_format_f32 + MA_SND_PCM_FORMAT_UNKNOWN, // mal_format_unknown + MA_SND_PCM_FORMAT_U8, // mal_format_u8 + MA_SND_PCM_FORMAT_S16_LE, // mal_format_s16 + MA_SND_PCM_FORMAT_S24_3LE, // mal_format_s24 + MA_SND_PCM_FORMAT_S32_LE, // mal_format_s32 + MA_SND_PCM_FORMAT_FLOAT_LE // mal_format_f32 }; if (mal_is_big_endian()) { - ALSAFormats[0] = MAL_SND_PCM_FORMAT_UNKNOWN; - ALSAFormats[1] = MAL_SND_PCM_FORMAT_U8; - ALSAFormats[2] = MAL_SND_PCM_FORMAT_S16_BE; - ALSAFormats[3] = MAL_SND_PCM_FORMAT_S24_3BE; - ALSAFormats[4] = MAL_SND_PCM_FORMAT_S32_BE; - ALSAFormats[5] = MAL_SND_PCM_FORMAT_FLOAT_BE; + ALSAFormats[0] = MA_SND_PCM_FORMAT_UNKNOWN; + ALSAFormats[1] = MA_SND_PCM_FORMAT_U8; + ALSAFormats[2] = MA_SND_PCM_FORMAT_S16_BE; + ALSAFormats[3] = MA_SND_PCM_FORMAT_S24_3BE; + ALSAFormats[4] = MA_SND_PCM_FORMAT_S32_BE; + ALSAFormats[5] = MA_SND_PCM_FORMAT_FLOAT_BE; } @@ -11316,25 +11316,25 @@ mal_format mal_convert_alsa_format_to_mal_format(mal_snd_pcm_format_t formatALSA { if (mal_is_little_endian()) { switch (formatALSA) { - case MAL_SND_PCM_FORMAT_S16_LE: return mal_format_s16; - case MAL_SND_PCM_FORMAT_S24_3LE: return mal_format_s24; - case MAL_SND_PCM_FORMAT_S32_LE: return mal_format_s32; - case MAL_SND_PCM_FORMAT_FLOAT_LE: return mal_format_f32; + case MA_SND_PCM_FORMAT_S16_LE: return mal_format_s16; + case MA_SND_PCM_FORMAT_S24_3LE: return mal_format_s24; + case MA_SND_PCM_FORMAT_S32_LE: return mal_format_s32; + case MA_SND_PCM_FORMAT_FLOAT_LE: return mal_format_f32; default: break; } } else { switch (formatALSA) { - case MAL_SND_PCM_FORMAT_S16_BE: return mal_format_s16; - case MAL_SND_PCM_FORMAT_S24_3BE: return mal_format_s24; - case MAL_SND_PCM_FORMAT_S32_BE: return mal_format_s32; - case MAL_SND_PCM_FORMAT_FLOAT_BE: return mal_format_f32; + case MA_SND_PCM_FORMAT_S16_BE: return mal_format_s16; + case MA_SND_PCM_FORMAT_S24_3BE: return mal_format_s24; + case MA_SND_PCM_FORMAT_S32_BE: return mal_format_s32; + case MA_SND_PCM_FORMAT_FLOAT_BE: return mal_format_f32; default: break; } } // Endian agnostic. switch (formatALSA) { - case MAL_SND_PCM_FORMAT_U8: return mal_format_u8; + case MA_SND_PCM_FORMAT_U8: return mal_format_u8; default: return mal_format_unknown; } } @@ -11343,32 +11343,32 @@ mal_channel mal_convert_alsa_channel_position_to_mal_channel(unsigned int alsaCh { switch (alsaChannelPos) { - case MAL_SND_CHMAP_MONO: return MAL_CHANNEL_MONO; - case MAL_SND_CHMAP_FL: return MAL_CHANNEL_FRONT_LEFT; - case MAL_SND_CHMAP_FR: return MAL_CHANNEL_FRONT_RIGHT; - case MAL_SND_CHMAP_RL: return MAL_CHANNEL_BACK_LEFT; - case MAL_SND_CHMAP_RR: return MAL_CHANNEL_BACK_RIGHT; - case MAL_SND_CHMAP_FC: return MAL_CHANNEL_FRONT_CENTER; - case MAL_SND_CHMAP_LFE: return MAL_CHANNEL_LFE; - case MAL_SND_CHMAP_SL: return MAL_CHANNEL_SIDE_LEFT; - case MAL_SND_CHMAP_SR: return MAL_CHANNEL_SIDE_RIGHT; - case MAL_SND_CHMAP_RC: return MAL_CHANNEL_BACK_CENTER; - case MAL_SND_CHMAP_FLC: return MAL_CHANNEL_FRONT_LEFT_CENTER; - case MAL_SND_CHMAP_FRC: return MAL_CHANNEL_FRONT_RIGHT_CENTER; - case MAL_SND_CHMAP_RLC: return 0; - case MAL_SND_CHMAP_RRC: return 0; - case MAL_SND_CHMAP_FLW: return 0; - case MAL_SND_CHMAP_FRW: return 0; - case MAL_SND_CHMAP_FLH: return 0; - case MAL_SND_CHMAP_FCH: return 0; - case MAL_SND_CHMAP_FRH: return 0; - case MAL_SND_CHMAP_TC: return MAL_CHANNEL_TOP_CENTER; - case MAL_SND_CHMAP_TFL: return MAL_CHANNEL_TOP_FRONT_LEFT; - case MAL_SND_CHMAP_TFR: return MAL_CHANNEL_TOP_FRONT_RIGHT; - case MAL_SND_CHMAP_TFC: return MAL_CHANNEL_TOP_FRONT_CENTER; - case MAL_SND_CHMAP_TRL: return MAL_CHANNEL_TOP_BACK_LEFT; - case MAL_SND_CHMAP_TRR: return MAL_CHANNEL_TOP_BACK_RIGHT; - case MAL_SND_CHMAP_TRC: return MAL_CHANNEL_TOP_BACK_CENTER; + case MA_SND_CHMAP_MONO: return MA_CHANNEL_MONO; + case MA_SND_CHMAP_FL: return MA_CHANNEL_FRONT_LEFT; + case MA_SND_CHMAP_FR: return MA_CHANNEL_FRONT_RIGHT; + case MA_SND_CHMAP_RL: return MA_CHANNEL_BACK_LEFT; + case MA_SND_CHMAP_RR: return MA_CHANNEL_BACK_RIGHT; + case MA_SND_CHMAP_FC: return MA_CHANNEL_FRONT_CENTER; + case MA_SND_CHMAP_LFE: return MA_CHANNEL_LFE; + case MA_SND_CHMAP_SL: return MA_CHANNEL_SIDE_LEFT; + case MA_SND_CHMAP_SR: return MA_CHANNEL_SIDE_RIGHT; + case MA_SND_CHMAP_RC: return MA_CHANNEL_BACK_CENTER; + case MA_SND_CHMAP_FLC: return MA_CHANNEL_FRONT_LEFT_CENTER; + case MA_SND_CHMAP_FRC: return MA_CHANNEL_FRONT_RIGHT_CENTER; + case MA_SND_CHMAP_RLC: return 0; + case MA_SND_CHMAP_RRC: return 0; + case MA_SND_CHMAP_FLW: return 0; + case MA_SND_CHMAP_FRW: return 0; + case MA_SND_CHMAP_FLH: return 0; + case MA_SND_CHMAP_FCH: return 0; + case MA_SND_CHMAP_FRH: return 0; + case MA_SND_CHMAP_TC: return MA_CHANNEL_TOP_CENTER; + case MA_SND_CHMAP_TFL: return MA_CHANNEL_TOP_FRONT_LEFT; + case MA_SND_CHMAP_TFR: return MA_CHANNEL_TOP_FRONT_RIGHT; + case MA_SND_CHMAP_TFC: return MA_CHANNEL_TOP_FRONT_CENTER; + case MA_SND_CHMAP_TRL: return MA_CHANNEL_TOP_BACK_LEFT; + case MA_SND_CHMAP_TRR: return MA_CHANNEL_TOP_BACK_RIGHT; + case MA_SND_CHMAP_TRC: return MA_CHANNEL_TOP_BACK_CENTER; default: break; } @@ -11379,11 +11379,11 @@ mal_bool32 mal_is_common_device_name__alsa(const char* name) { for (size_t iName = 0; iName < mal_countof(g_malCommonDeviceNamesALSA); ++iName) { if (mal_strcmp(name, g_malCommonDeviceNamesALSA[iName]) == 0) { - return MAL_TRUE; + return MA_TRUE; } } - return MAL_FALSE; + return MA_FALSE; } @@ -11391,22 +11391,22 @@ mal_bool32 mal_is_playback_device_blacklisted__alsa(const char* name) { for (size_t iName = 0; iName < mal_countof(g_malBlacklistedPlaybackDeviceNamesALSA); ++iName) { if (mal_strcmp(name, g_malBlacklistedPlaybackDeviceNamesALSA[iName]) == 0) { - return MAL_TRUE; + return MA_TRUE; } } - return MAL_FALSE; + return MA_FALSE; } mal_bool32 mal_is_capture_device_blacklisted__alsa(const char* name) { for (size_t iName = 0; iName < mal_countof(g_malBlacklistedCaptureDeviceNamesALSA); ++iName) { if (mal_strcmp(name, g_malBlacklistedCaptureDeviceNamesALSA[iName]) == 0) { - return MAL_TRUE; + return MA_TRUE; } } - return MAL_FALSE; + return MA_FALSE; } mal_bool32 mal_is_device_blacklisted__alsa(mal_device_type deviceType, const char* name) @@ -11447,11 +11447,11 @@ mal_bool32 mal_is_device_name_in_hw_format__alsa(const char* hwid) // This function is just checking whether or not hwid is in "hw:%d,%d" format. if (hwid == NULL) { - return MAL_FALSE; + return MA_FALSE; } if (hwid[0] != 'h' || hwid[1] != 'w' || hwid[2] != ':') { - return MAL_FALSE; + return MA_FALSE; } hwid += 3; @@ -11459,7 +11459,7 @@ mal_bool32 mal_is_device_name_in_hw_format__alsa(const char* hwid) int commaPos; const char* dev = mal_find_char(hwid, ',', &commaPos); if (dev == NULL) { - return MAL_FALSE; + return MA_FALSE; } else { dev += 1; // Skip past the ",". } @@ -11467,7 +11467,7 @@ mal_bool32 mal_is_device_name_in_hw_format__alsa(const char* hwid) // Check if the part between the ":" and the "," contains only numbers. If not, return false. for (int i = 0; i < commaPos; ++i) { if (hwid[i] < '0' || hwid[i] > '9') { - return MAL_FALSE; + return MA_FALSE; } } @@ -11475,12 +11475,12 @@ mal_bool32 mal_is_device_name_in_hw_format__alsa(const char* hwid) int i = 0; while (dev[i] != '\0') { if (dev[i] < '0' || dev[i] > '9') { - return MAL_FALSE; + return MA_FALSE; } i += 1; } - return MAL_TRUE; + return MA_TRUE; } int mal_convert_device_name_to_hw_format__alsa(mal_context* pContext, char* dst, size_t dstSize, const char* src) // Returns 0 on success, non-0 on error. @@ -11546,11 +11546,11 @@ mal_bool32 mal_does_id_exist_in_list__alsa(mal_device_id* pUniqueIDs, mal_uint32 for (mal_uint32 i = 0; i < count; ++i) { if (mal_strcmp(pUniqueIDs[i].alsa, pHWID) == 0) { - return MAL_TRUE; + return MA_TRUE; } } - return MAL_FALSE; + return MA_FALSE; } @@ -11563,8 +11563,8 @@ mal_result mal_context_open_pcm__alsa(mal_context* pContext, mal_share_mode shar mal_snd_pcm_t* pPCM = NULL; - mal_snd_pcm_stream_t stream = (deviceType == mal_device_type_playback) ? MAL_SND_PCM_STREAM_PLAYBACK : MAL_SND_PCM_STREAM_CAPTURE; - int openMode = MAL_SND_PCM_NO_AUTO_RESAMPLE | MAL_SND_PCM_NO_AUTO_CHANNELS | MAL_SND_PCM_NO_AUTO_FORMAT; + mal_snd_pcm_stream_t stream = (deviceType == mal_device_type_playback) ? MA_SND_PCM_STREAM_PLAYBACK : MA_SND_PCM_STREAM_CAPTURE; + int openMode = MA_SND_PCM_NO_AUTO_RESAMPLE | MA_SND_PCM_NO_AUTO_CHANNELS | MA_SND_PCM_NO_AUTO_FORMAT; if (pDeviceID == NULL) { // We're opening the default device. I don't know if trying anything other than "default" is necessary, but it makes @@ -11598,18 +11598,18 @@ mal_result mal_context_open_pcm__alsa(mal_context* pContext, mal_share_mode shar defaultDeviceNames[6] = "hw:0,0"; } - mal_bool32 isDeviceOpen = MAL_FALSE; + mal_bool32 isDeviceOpen = MA_FALSE; for (size_t i = 0; i < mal_countof(defaultDeviceNames); ++i) { // TODO: i = 1 is temporary for testing purposes. Needs to be i = 0. if (defaultDeviceNames[i] != NULL && defaultDeviceNames[i][0] != '\0') { if (((mal_snd_pcm_open_proc)pContext->alsa.snd_pcm_open)(&pPCM, defaultDeviceNames[i], stream, openMode) == 0) { - isDeviceOpen = MAL_TRUE; + isDeviceOpen = MA_TRUE; break; } } } if (!isDeviceOpen) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_open() failed when trying to open an appropriate default device.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_open() failed when trying to open an appropriate default device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } } else { // We're trying to open a specific device. There's a few things to consider here: @@ -11621,11 +11621,11 @@ mal_result mal_context_open_pcm__alsa(mal_context* pContext, mal_share_mode shar // May end up needing to make small adjustments to the ID, so make a copy. mal_device_id deviceID = *pDeviceID; - mal_bool32 isDeviceOpen = MAL_FALSE; + mal_bool32 isDeviceOpen = MA_FALSE; if (deviceID.alsa[0] != ':') { // The ID is not in ":0,0" format. Use the ID exactly as-is. if (((mal_snd_pcm_open_proc)pContext->alsa.snd_pcm_open)(&pPCM, deviceID.alsa, stream, openMode) == 0) { - isDeviceOpen = MAL_TRUE; + isDeviceOpen = MA_TRUE; } } else { // The ID is in ":0,0" format. Try different plugins depending on the shared mode. @@ -11643,7 +11643,7 @@ mal_result mal_context_open_pcm__alsa(mal_context* pContext, mal_share_mode shar if (mal_strcat_s(hwid, sizeof(hwid), deviceID.alsa) == 0) { if (((mal_snd_pcm_open_proc)pContext->alsa.snd_pcm_open)(&pPCM, hwid, stream, openMode) == 0) { - isDeviceOpen = MAL_TRUE; + isDeviceOpen = MA_TRUE; } } } @@ -11653,19 +11653,19 @@ mal_result mal_context_open_pcm__alsa(mal_context* pContext, mal_share_mode shar mal_strcpy_s(hwid, sizeof(hwid), "hw"); if (mal_strcat_s(hwid, sizeof(hwid), deviceID.alsa) == 0) { if (((mal_snd_pcm_open_proc)pContext->alsa.snd_pcm_open)(&pPCM, hwid, stream, openMode) == 0) { - isDeviceOpen = MAL_TRUE; + isDeviceOpen = MA_TRUE; } } } } if (!isDeviceOpen) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_open() failed.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_open() failed.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } } *ppPCM = pPCM; - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -11684,14 +11684,14 @@ mal_result mal_context_enumerate_devices__alsa(mal_context* pContext, mal_enum_d mal_assert(pContext != NULL); mal_assert(callback != NULL); - mal_bool32 cbResult = MAL_TRUE; + mal_bool32 cbResult = MA_TRUE; mal_mutex_lock(&pContext->alsa.internalDeviceEnumLock); char** ppDeviceHints; if (((mal_snd_device_name_hint_proc)pContext->alsa.snd_device_name_hint)(-1, "pcm", (void***)&ppDeviceHints) < 0) { mal_mutex_unlock(&pContext->alsa.internalDeviceEnumLock); - return MAL_NO_BACKEND; + return MA_NO_BACKEND; } mal_device_id* pUniqueIDs = NULL; @@ -11711,7 +11711,7 @@ mal_result mal_context_enumerate_devices__alsa(mal_context* pContext, mal_enum_d deviceType = mal_device_type_capture; } - mal_bool32 stopEnumeration = MAL_FALSE; + mal_bool32 stopEnumeration = MA_FALSE; #if 0 printf("NAME: %s\n", NAME); printf("DESC: %s\n", DESC); @@ -11815,8 +11815,8 @@ mal_result mal_context_enumerate_devices__alsa(mal_context* pContext, mal_enum_d } } - if (cbResult == MAL_FALSE) { - stopEnumeration = MAL_TRUE; + if (cbResult == MA_FALSE) { + stopEnumeration = MA_TRUE; } next_device: @@ -11836,7 +11836,7 @@ mal_result mal_context_enumerate_devices__alsa(mal_context* pContext, mal_enum_d mal_mutex_unlock(&pContext->alsa.internalDeviceEnumLock); - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -11856,11 +11856,11 @@ mal_bool32 mal_context_get_device_info_enum_callback__alsa(mal_context* pContext if (pData->pDeviceID == NULL && mal_strcmp(pDeviceInfo->id.alsa, "default") == 0) { mal_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pDeviceInfo->name, (size_t)-1); - pData->foundDevice = MAL_TRUE; + pData->foundDevice = MA_TRUE; } else { if (pData->deviceType == deviceType && mal_context_is_device_id_equal__alsa(pContext, pData->pDeviceID, &pDeviceInfo->id)) { mal_strncpy_s(pData->pDeviceInfo->name, sizeof(pData->pDeviceInfo->name), pDeviceInfo->name, (size_t)-1); - pData->foundDevice = MAL_TRUE; + pData->foundDevice = MA_TRUE; } } @@ -11878,21 +11878,21 @@ mal_result mal_context_get_device_info__alsa(mal_context* pContext, mal_device_t data.pDeviceID = pDeviceID; data.shareMode = shareMode; data.pDeviceInfo = pDeviceInfo; - data.foundDevice = MAL_FALSE; + data.foundDevice = MA_FALSE; mal_result result = mal_context_enumerate_devices__alsa(pContext, mal_context_get_device_info_enum_callback__alsa, &data); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } if (!data.foundDevice) { - return MAL_NO_DEVICE; + return MA_NO_DEVICE; } // For detailed info we need to open the device. mal_snd_pcm_t* pPCM; result = mal_context_open_pcm__alsa(pContext, shareMode, deviceType, pDeviceID, &pPCM); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -11901,7 +11901,7 @@ mal_result mal_context_get_device_info__alsa(mal_context* pContext, mal_device_t mal_zero_memory(pHWParams, ((mal_snd_pcm_hw_params_sizeof_proc)pContext->alsa.snd_pcm_hw_params_sizeof)()); if (((mal_snd_pcm_hw_params_any_proc)pContext->alsa.snd_pcm_hw_params_any)(pPCM, pHWParams) < 0) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to initialize hardware parameters. snd_pcm_hw_params_any() failed.", MAL_FAILED_TO_CONFIGURE_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to initialize hardware parameters. snd_pcm_hw_params_any() failed.", MA_FAILED_TO_CONFIGURE_BACKEND_DEVICE); } int sampleRateDir = 0; @@ -11917,24 +11917,24 @@ mal_result mal_context_get_device_info__alsa(mal_context* pContext, mal_device_t ((mal_snd_pcm_hw_params_get_format_mask_proc)pContext->alsa.snd_pcm_hw_params_get_format_mask)(pHWParams, pFormatMask); pDeviceInfo->formatCount = 0; - if (((mal_snd_pcm_format_mask_test_proc)pContext->alsa.snd_pcm_format_mask_test)(pFormatMask, MAL_SND_PCM_FORMAT_U8)) { + if (((mal_snd_pcm_format_mask_test_proc)pContext->alsa.snd_pcm_format_mask_test)(pFormatMask, MA_SND_PCM_FORMAT_U8)) { pDeviceInfo->formats[pDeviceInfo->formatCount++] = mal_format_u8; } - if (((mal_snd_pcm_format_mask_test_proc)pContext->alsa.snd_pcm_format_mask_test)(pFormatMask, MAL_SND_PCM_FORMAT_S16_LE)) { + if (((mal_snd_pcm_format_mask_test_proc)pContext->alsa.snd_pcm_format_mask_test)(pFormatMask, MA_SND_PCM_FORMAT_S16_LE)) { pDeviceInfo->formats[pDeviceInfo->formatCount++] = mal_format_s16; } - if (((mal_snd_pcm_format_mask_test_proc)pContext->alsa.snd_pcm_format_mask_test)(pFormatMask, MAL_SND_PCM_FORMAT_S24_3LE)) { + if (((mal_snd_pcm_format_mask_test_proc)pContext->alsa.snd_pcm_format_mask_test)(pFormatMask, MA_SND_PCM_FORMAT_S24_3LE)) { pDeviceInfo->formats[pDeviceInfo->formatCount++] = mal_format_s24; } - if (((mal_snd_pcm_format_mask_test_proc)pContext->alsa.snd_pcm_format_mask_test)(pFormatMask, MAL_SND_PCM_FORMAT_S32_LE)) { + if (((mal_snd_pcm_format_mask_test_proc)pContext->alsa.snd_pcm_format_mask_test)(pFormatMask, MA_SND_PCM_FORMAT_S32_LE)) { pDeviceInfo->formats[pDeviceInfo->formatCount++] = mal_format_s32; } - if (((mal_snd_pcm_format_mask_test_proc)pContext->alsa.snd_pcm_format_mask_test)(pFormatMask, MAL_SND_PCM_FORMAT_FLOAT_LE)) { + if (((mal_snd_pcm_format_mask_test_proc)pContext->alsa.snd_pcm_format_mask_test)(pFormatMask, MA_SND_PCM_FORMAT_FLOAT_LE)) { pDeviceInfo->formats[pDeviceInfo->formatCount++] = mal_format_f32; } ((mal_snd_pcm_close_proc)pContext->alsa.snd_pcm_close)(pPCM); - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -11947,7 +11947,7 @@ mal_uint32 mal_device__wait_for_frames__alsa(mal_device* pDevice, mal_bool32* pR { mal_assert(pDevice != NULL); - if (pRequiresRestart) *pRequiresRestart = MAL_FALSE; + if (pRequiresRestart) *pRequiresRestart = MA_FALSE; // I want it so that this function returns the period size in frames. We just wait until that number of frames are available and then return. mal_uint32 periodSizeInFrames = pDevice->bufferSizeInFrames / pDevice->periods; @@ -11955,13 +11955,13 @@ mal_uint32 mal_device__wait_for_frames__alsa(mal_device* pDevice, mal_bool32* pR mal_snd_pcm_sframes_t framesAvailable = ((mal_snd_pcm_avail_update_proc)pDevice->pContext->alsa.snd_pcm_avail_update)((mal_snd_pcm_t*)pDevice->alsa.pPCM); if (framesAvailable < 0) { if (framesAvailable == -EPIPE) { - if (((mal_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((mal_snd_pcm_t*)pDevice->alsa.pPCM, framesAvailable, MAL_TRUE) < 0) { + if (((mal_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((mal_snd_pcm_t*)pDevice->alsa.pPCM, framesAvailable, MA_TRUE) < 0) { return 0; } // A device recovery means a restart for mmap mode. if (pRequiresRestart) { - *pRequiresRestart = MAL_TRUE; + *pRequiresRestart = MA_TRUE; } // Try again, but if it fails this time just return an error. @@ -11981,13 +11981,13 @@ mal_uint32 mal_device__wait_for_frames__alsa(mal_device* pDevice, mal_bool32* pR int waitResult = ((mal_snd_pcm_wait_proc)pDevice->pContext->alsa.snd_pcm_wait)((mal_snd_pcm_t*)pDevice->alsa.pPCM, -1); if (waitResult < 0) { if (waitResult == -EPIPE) { - if (((mal_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((mal_snd_pcm_t*)pDevice->alsa.pPCM, waitResult, MAL_TRUE) < 0) { + if (((mal_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((mal_snd_pcm_t*)pDevice->alsa.pPCM, waitResult, MA_TRUE) < 0) { return 0; } // A device recovery means a restart for mmap mode. if (pRequiresRestart) { - *pRequiresRestart = MAL_TRUE; + *pRequiresRestart = MA_TRUE; } } } @@ -12006,11 +12006,11 @@ mal_uint32 mal_device__wait_for_frames__alsa(mal_device* pDevice, mal_bool32* pR mal_bool32 mal_device_read_from_client_and_write__alsa(mal_device* pDevice) { mal_assert(pDevice != NULL); - if (!mal_device_is_started(pDevice) && mal_device__get_state(pDevice) != MAL_STATE_STARTING) { - return MAL_FALSE; + if (!mal_device_is_started(pDevice) && mal_device__get_state(pDevice) != MA_STATE_STARTING) { + return MA_FALSE; } if (pDevice->alsa.breakFromMainLoop) { - return MAL_FALSE; + return MA_FALSE; } if (pDevice->alsa.isUsingMMap) { @@ -12018,12 +12018,12 @@ mal_bool32 mal_device_read_from_client_and_write__alsa(mal_device* pDevice) mal_bool32 requiresRestart; mal_uint32 framesAvailable = mal_device__wait_for_frames__alsa(pDevice, &requiresRestart); if (framesAvailable == 0) { - return MAL_FALSE; + return MA_FALSE; } // Don't bother asking the client for more audio data if we're just stopping the device anyway. if (pDevice->alsa.breakFromMainLoop) { - return MAL_FALSE; + return MA_FALSE; } const mal_snd_pcm_channel_area_t* pAreas; @@ -12032,7 +12032,7 @@ mal_bool32 mal_device_read_from_client_and_write__alsa(mal_device* pDevice) while (framesAvailable > 0) { int result = ((mal_snd_pcm_mmap_begin_proc)pDevice->pContext->alsa.snd_pcm_mmap_begin)((mal_snd_pcm_t*)pDevice->alsa.pPCM, &pAreas, &mappedOffset, &mappedFrames); if (result < 0) { - return MAL_FALSE; + return MA_FALSE; } if (mappedFrames > 0) { @@ -12042,13 +12042,13 @@ mal_bool32 mal_device_read_from_client_and_write__alsa(mal_device* pDevice) result = ((mal_snd_pcm_mmap_commit_proc)pDevice->pContext->alsa.snd_pcm_mmap_commit)((mal_snd_pcm_t*)pDevice->alsa.pPCM, mappedOffset, mappedFrames); if (result < 0 || (mal_snd_pcm_uframes_t)result != mappedFrames) { - ((mal_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((mal_snd_pcm_t*)pDevice->alsa.pPCM, result, MAL_TRUE); - return MAL_FALSE; + ((mal_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((mal_snd_pcm_t*)pDevice->alsa.pPCM, result, MA_TRUE); + return MA_FALSE; } if (requiresRestart) { if (((mal_snd_pcm_start_proc)pDevice->pContext->alsa.snd_pcm_start)((mal_snd_pcm_t*)pDevice->alsa.pPCM) < 0) { - return MAL_FALSE; + return MA_FALSE; } } @@ -12068,7 +12068,7 @@ mal_bool32 mal_device_read_from_client_and_write__alsa(mal_device* pDevice) // Don't bother asking the client for more audio data if we're just stopping the device anyway. if (pDevice->alsa.breakFromMainLoop) { - return MAL_FALSE; + return MA_FALSE; } mal_device__read_frames_from_client(pDevice, framesAvailable, pDevice->alsa.pIntermediaryBuffer); @@ -12079,21 +12079,21 @@ mal_bool32 mal_device_read_from_client_and_write__alsa(mal_device* pDevice) continue; // Just keep trying... } else if (framesWritten == -EPIPE) { // Underrun. Just recover and try writing again. - if (((mal_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((mal_snd_pcm_t*)pDevice->alsa.pPCM, framesWritten, MAL_TRUE) < 0) { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to recover device after underrun.", MAL_FAILED_TO_START_BACKEND_DEVICE); - return MAL_FALSE; + if (((mal_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((mal_snd_pcm_t*)pDevice->alsa.pPCM, framesWritten, MA_TRUE) < 0) { + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to recover device after underrun.", MA_FAILED_TO_START_BACKEND_DEVICE); + return MA_FALSE; } framesWritten = ((mal_snd_pcm_writei_proc)pDevice->pContext->alsa.snd_pcm_writei)((mal_snd_pcm_t*)pDevice->alsa.pPCM, pDevice->alsa.pIntermediaryBuffer, framesAvailable); if (framesWritten < 0) { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to write data to the internal device.", MAL_FAILED_TO_SEND_DATA_TO_DEVICE); - return MAL_FALSE; + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to write data to the internal device.", MA_FAILED_TO_SEND_DATA_TO_DEVICE); + return MA_FALSE; } break; // Success. } else { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_writei() failed when writing initial data.", MAL_FAILED_TO_SEND_DATA_TO_DEVICE); - return MAL_FALSE; + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_writei() failed when writing initial data.", MA_FAILED_TO_SEND_DATA_TO_DEVICE); + return MA_FALSE; } } else { break; // Success. @@ -12101,17 +12101,17 @@ mal_bool32 mal_device_read_from_client_and_write__alsa(mal_device* pDevice) } } - return MAL_TRUE; + return MA_TRUE; } mal_bool32 mal_device_read_and_send_to_client__alsa(mal_device* pDevice) { mal_assert(pDevice != NULL); if (!mal_device_is_started(pDevice)) { - return MAL_FALSE; + return MA_FALSE; } if (pDevice->alsa.breakFromMainLoop) { - return MAL_FALSE; + return MA_FALSE; } mal_uint32 framesToSend = 0; @@ -12121,7 +12121,7 @@ mal_bool32 mal_device_read_and_send_to_client__alsa(mal_device* pDevice) mal_bool32 requiresRestart; mal_uint32 framesAvailable = mal_device__wait_for_frames__alsa(pDevice, &requiresRestart); if (framesAvailable == 0) { - return MAL_FALSE; + return MA_FALSE; } const mal_snd_pcm_channel_area_t* pAreas; @@ -12130,7 +12130,7 @@ mal_bool32 mal_device_read_and_send_to_client__alsa(mal_device* pDevice) while (framesAvailable > 0) { int result = ((mal_snd_pcm_mmap_begin_proc)pDevice->pContext->alsa.snd_pcm_mmap_begin)((mal_snd_pcm_t*)pDevice->alsa.pPCM, &pAreas, &mappedOffset, &mappedFrames); if (result < 0) { - return MAL_FALSE; + return MA_FALSE; } if (mappedFrames > 0) { @@ -12140,13 +12140,13 @@ mal_bool32 mal_device_read_and_send_to_client__alsa(mal_device* pDevice) result = ((mal_snd_pcm_mmap_commit_proc)pDevice->pContext->alsa.snd_pcm_mmap_commit)((mal_snd_pcm_t*)pDevice->alsa.pPCM, mappedOffset, mappedFrames); if (result < 0 || (mal_snd_pcm_uframes_t)result != mappedFrames) { - ((mal_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((mal_snd_pcm_t*)pDevice->alsa.pPCM, result, MAL_TRUE); - return MAL_FALSE; + ((mal_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((mal_snd_pcm_t*)pDevice->alsa.pPCM, result, MA_TRUE); + return MA_FALSE; } if (requiresRestart) { if (((mal_snd_pcm_start_proc)pDevice->pContext->alsa.snd_pcm_start)((mal_snd_pcm_t*)pDevice->alsa.pPCM) < 0) { - return MAL_FALSE; + return MA_FALSE; } } @@ -12171,20 +12171,20 @@ mal_bool32 mal_device_read_and_send_to_client__alsa(mal_device* pDevice) continue; // Just keep trying... } else if (framesRead == -EPIPE) { // Overrun. Just recover and try reading again. - if (((mal_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((mal_snd_pcm_t*)pDevice->alsa.pPCM, framesRead, MAL_TRUE) < 0) { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to recover device after overrun.", MAL_FAILED_TO_START_BACKEND_DEVICE); - return MAL_FALSE; + if (((mal_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((mal_snd_pcm_t*)pDevice->alsa.pPCM, framesRead, MA_TRUE) < 0) { + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to recover device after overrun.", MA_FAILED_TO_START_BACKEND_DEVICE); + return MA_FALSE; } framesRead = ((mal_snd_pcm_readi_proc)pDevice->pContext->alsa.snd_pcm_readi)((mal_snd_pcm_t*)pDevice->alsa.pPCM, pDevice->alsa.pIntermediaryBuffer, framesAvailable); if (framesRead < 0) { - mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to read data from the internal device.", MAL_FAILED_TO_READ_DATA_FROM_DEVICE); - return MAL_FALSE; + mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to read data from the internal device.", MA_FAILED_TO_READ_DATA_FROM_DEVICE); + return MA_FALSE; } break; // Success. } else { - return MAL_FALSE; + return MA_FALSE; } } else { break; // Success. @@ -12199,7 +12199,7 @@ mal_bool32 mal_device_read_and_send_to_client__alsa(mal_device* pDevice) mal_device__send_frames_to_client(pDevice, framesToSend, pBuffer); } - return MAL_TRUE; + return MA_TRUE; } #endif @@ -12227,7 +12227,7 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device mal_format internalFormat; mal_uint32 internalChannels; mal_uint32 internalSampleRate; - mal_channel internalChannelMap[MAL_MAX_CHANNELS]; + mal_channel internalChannelMap[MA_MAX_CHANNELS]; mal_uint32 internalBufferSizeInFrames; mal_uint32 internalPeriods; mal_snd_pcm_hw_params_t* pHWParams; @@ -12244,7 +12244,7 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device pDeviceID = (deviceType == mal_device_type_capture) ? pConfig->capture.pDeviceID : pConfig->playback.pDeviceID; result = mal_context_open_pcm__alsa(pContext, shareMode, deviceType, pDeviceID, &pPCM); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -12264,7 +12264,7 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device /* It's the default device. We need to use DESC from snd_device_name_hint(). */ if (((mal_snd_device_name_hint_proc)pContext->alsa.snd_device_name_hint)(-1, "pcm", (void***)&ppDeviceHints) < 0) { - return MAL_NO_BACKEND; + return MA_NO_BACKEND; } ppNextDeviceHint = ppDeviceHints; @@ -12273,12 +12273,12 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device char* DESC = ((mal_snd_device_name_get_hint_proc)pContext->alsa.snd_device_name_get_hint)(*ppNextDeviceHint, "DESC"); char* IOID = ((mal_snd_device_name_get_hint_proc)pContext->alsa.snd_device_name_get_hint)(*ppNextDeviceHint, "IOID"); - mal_bool32 foundDevice = MAL_FALSE; + mal_bool32 foundDevice = MA_FALSE; if ((deviceType == mal_device_type_playback && (IOID == NULL || mal_strcmp(IOID, "Output") == 0)) || (deviceType == mal_device_type_capture && (IOID != NULL && mal_strcmp(IOID, "Input" ) == 0))) { if (mal_strcmp(NAME, deviceName) == 0) { bufferSizeScaleFactor = mal_find_default_buffer_size_scale__alsa(DESC); - foundDevice = MAL_TRUE; + foundDevice = MA_TRUE; } } @@ -12307,25 +12307,25 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device if (((mal_snd_pcm_hw_params_any_proc)pContext->alsa.snd_pcm_hw_params_any)(pPCM, pHWParams) < 0) { ((mal_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to initialize hardware parameters. snd_pcm_hw_params_any() failed.", MAL_FAILED_TO_CONFIGURE_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to initialize hardware parameters. snd_pcm_hw_params_any() failed.", MA_FAILED_TO_CONFIGURE_BACKEND_DEVICE); } /* MMAP Mode. Try using interleaved MMAP access. If this fails, fall back to standard readi/writei. */ - isUsingMMap = MAL_FALSE; + isUsingMMap = MA_FALSE; #if 0 /* NOTE: MMAP mode temporarily disabled. */ if (deviceType != mal_device_type_capture) { /* <-- Disabling MMAP mode for capture devices because I apparently do not have a device that supports it which means I can't test it... Contributions welcome. */ if (!pConfig->alsa.noMMap && mal_device__is_async(pDevice)) { - if (((mal_snd_pcm_hw_params_set_access_proc)pContext->alsa.snd_pcm_hw_params_set_access)(pPCM, pHWParams, MAL_SND_PCM_ACCESS_MMAP_INTERLEAVED) == 0) { - pDevice->alsa.isUsingMMap = MAL_TRUE; + if (((mal_snd_pcm_hw_params_set_access_proc)pContext->alsa.snd_pcm_hw_params_set_access)(pPCM, pHWParams, MA_SND_PCM_ACCESS_MMAP_INTERLEAVED) == 0) { + pDevice->alsa.isUsingMMap = MA_TRUE; } } } #endif if (!isUsingMMap) { - if (((mal_snd_pcm_hw_params_set_access_proc)pContext->alsa.snd_pcm_hw_params_set_access)(pPCM, pHWParams, MAL_SND_PCM_ACCESS_RW_INTERLEAVED) < 0) {; + if (((mal_snd_pcm_hw_params_set_access_proc)pContext->alsa.snd_pcm_hw_params_set_access)(pPCM, pHWParams, MA_SND_PCM_ACCESS_RW_INTERLEAVED) < 0) {; ((mal_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to set access mode to neither SND_PCM_ACCESS_MMAP_INTERLEAVED nor SND_PCM_ACCESS_RW_INTERLEAVED. snd_pcm_hw_params_set_access() failed.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set access mode to neither SND_PCM_ACCESS_MMAP_INTERLEAVED nor SND_PCM_ACCESS_RW_INTERLEAVED. snd_pcm_hw_params_set_access() failed.", MA_FORMAT_NOT_SUPPORTED); } } @@ -12351,22 +12351,22 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device if (!((mal_snd_pcm_format_mask_test_proc)pContext->alsa.snd_pcm_format_mask_test)(pFormatMask, formatALSA)) { /* The requested format is not supported so now try running through the list of formats and return the best one. */ mal_snd_pcm_format_t preferredFormatsALSA[] = { - MAL_SND_PCM_FORMAT_S16_LE, /* mal_format_s16 */ - MAL_SND_PCM_FORMAT_FLOAT_LE, /* mal_format_f32 */ - MAL_SND_PCM_FORMAT_S32_LE, /* mal_format_s32 */ - MAL_SND_PCM_FORMAT_S24_3LE, /* mal_format_s24 */ - MAL_SND_PCM_FORMAT_U8 /* mal_format_u8 */ + MA_SND_PCM_FORMAT_S16_LE, /* mal_format_s16 */ + MA_SND_PCM_FORMAT_FLOAT_LE, /* mal_format_f32 */ + MA_SND_PCM_FORMAT_S32_LE, /* mal_format_s32 */ + MA_SND_PCM_FORMAT_S24_3LE, /* mal_format_s24 */ + MA_SND_PCM_FORMAT_U8 /* mal_format_u8 */ }; if (mal_is_big_endian()) { - preferredFormatsALSA[0] = MAL_SND_PCM_FORMAT_S16_BE; - preferredFormatsALSA[1] = MAL_SND_PCM_FORMAT_FLOAT_BE; - preferredFormatsALSA[2] = MAL_SND_PCM_FORMAT_S32_BE; - preferredFormatsALSA[3] = MAL_SND_PCM_FORMAT_S24_3BE; - preferredFormatsALSA[4] = MAL_SND_PCM_FORMAT_U8; + preferredFormatsALSA[0] = MA_SND_PCM_FORMAT_S16_BE; + preferredFormatsALSA[1] = MA_SND_PCM_FORMAT_FLOAT_BE; + preferredFormatsALSA[2] = MA_SND_PCM_FORMAT_S32_BE; + preferredFormatsALSA[3] = MA_SND_PCM_FORMAT_S24_3BE; + preferredFormatsALSA[4] = MA_SND_PCM_FORMAT_U8; } - formatALSA = MAL_SND_PCM_FORMAT_UNKNOWN; + formatALSA = MA_SND_PCM_FORMAT_UNKNOWN; for (size_t i = 0; i < (sizeof(preferredFormatsALSA) / sizeof(preferredFormatsALSA[0])); ++i) { if (((mal_snd_pcm_format_mask_test_proc)pContext->alsa.snd_pcm_format_mask_test)(pFormatMask, preferredFormatsALSA[i])) { formatALSA = preferredFormatsALSA[i]; @@ -12374,21 +12374,21 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device } } - if (formatALSA == MAL_SND_PCM_FORMAT_UNKNOWN) { + if (formatALSA == MA_SND_PCM_FORMAT_UNKNOWN) { ((mal_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Format not supported. The device does not support any miniaudio formats.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Format not supported. The device does not support any miniaudio formats.", MA_FORMAT_NOT_SUPPORTED); } } if (((mal_snd_pcm_hw_params_set_format_proc)pContext->alsa.snd_pcm_hw_params_set_format)(pPCM, pHWParams, formatALSA) < 0) { ((mal_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Format not supported. snd_pcm_hw_params_set_format() failed.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Format not supported. snd_pcm_hw_params_set_format() failed.", MA_FORMAT_NOT_SUPPORTED); } internalFormat = mal_convert_alsa_format_to_mal_format(formatALSA); if (internalFormat == mal_format_unknown) { ((mal_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] The chosen format is not supported by miniaudio.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] The chosen format is not supported by miniaudio.", MA_FORMAT_NOT_SUPPORTED); } } @@ -12397,7 +12397,7 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device unsigned int channels = (deviceType == mal_device_type_capture) ? pConfig->capture.channels : pConfig->playback.channels; if (((mal_snd_pcm_hw_params_set_channels_near_proc)pContext->alsa.snd_pcm_hw_params_set_channels_near)(pPCM, pHWParams, &channels) < 0) { ((mal_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to set channel count. snd_pcm_hw_params_set_channels_near() failed.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set channel count. snd_pcm_hw_params_set_channels_near() failed.", MA_FORMAT_NOT_SUPPORTED); } internalChannels = (mal_uint32)channels; } @@ -12428,7 +12428,7 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device sampleRate = pConfig->sampleRate; if (((mal_snd_pcm_hw_params_set_rate_near_proc)pContext->alsa.snd_pcm_hw_params_set_rate_near)(pPCM, pHWParams, &sampleRate, 0) < 0) { ((mal_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Sample rate not supported. snd_pcm_hw_params_set_rate_near() failed.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Sample rate not supported. snd_pcm_hw_params_set_rate_near() failed.", MA_FORMAT_NOT_SUPPORTED); } internalSampleRate = (mal_uint32)sampleRate; } @@ -12442,7 +12442,7 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device if (((mal_snd_pcm_hw_params_set_buffer_size_near_proc)pContext->alsa.snd_pcm_hw_params_set_buffer_size_near)(pPCM, pHWParams, &actualBufferSizeInFrames) < 0) { ((mal_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to set buffer size for device. snd_pcm_hw_params_set_buffer_size() failed.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set buffer size for device. snd_pcm_hw_params_set_buffer_size() failed.", MA_FORMAT_NOT_SUPPORTED); } internalBufferSizeInFrames = actualBufferSizeInFrames; } @@ -12452,7 +12452,7 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device mal_uint32 periods = pConfig->periods; if (((mal_snd_pcm_hw_params_set_periods_near_proc)pContext->alsa.snd_pcm_hw_params_set_periods_near)(pPCM, pHWParams, &periods, NULL) < 0) { ((mal_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to set period count. snd_pcm_hw_params_set_periods_near() failed.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set period count. snd_pcm_hw_params_set_periods_near() failed.", MA_FORMAT_NOT_SUPPORTED); } internalPeriods = periods; } @@ -12460,7 +12460,7 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device /* Apply hardware parameters. */ if (((mal_snd_pcm_hw_params_proc)pContext->alsa.snd_pcm_hw_params)(pPCM, pHWParams) < 0) { ((mal_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to set hardware parameters. snd_pcm_hw_params() failed.", MAL_FAILED_TO_CONFIGURE_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set hardware parameters. snd_pcm_hw_params() failed.", MA_FAILED_TO_CONFIGURE_BACKEND_DEVICE); } @@ -12470,18 +12470,18 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device if (((mal_snd_pcm_sw_params_current_proc)pContext->alsa.snd_pcm_sw_params_current)(pPCM, pSWParams) != 0) { ((mal_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to initialize software parameters. snd_pcm_sw_params_current() failed.", MAL_FAILED_TO_CONFIGURE_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to initialize software parameters. snd_pcm_sw_params_current() failed.", MA_FAILED_TO_CONFIGURE_BACKEND_DEVICE); } if (deviceType == mal_device_type_capture) { if (((mal_snd_pcm_sw_params_set_avail_min_proc)pContext->alsa.snd_pcm_sw_params_set_avail_min)(pPCM, pSWParams, 1) != 0) { ((mal_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_sw_params_set_avail_min() failed.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_sw_params_set_avail_min() failed.", MA_FORMAT_NOT_SUPPORTED); } } else { if (((mal_snd_pcm_sw_params_set_avail_min_proc)pContext->alsa.snd_pcm_sw_params_set_avail_min)(pPCM, pSWParams, 1) != 0) { ((mal_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_sw_params_set_avail_min() failed.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] snd_pcm_sw_params_set_avail_min() failed.", MA_FORMAT_NOT_SUPPORTED); } } @@ -12499,17 +12499,17 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device */ if (((mal_snd_pcm_sw_params_set_start_threshold_proc)pContext->alsa.snd_pcm_sw_params_set_start_threshold)(pPCM, pSWParams, internalBufferSizeInFrames) != 0) { ((mal_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to set start threshold for playback device. snd_pcm_sw_params_set_start_threshold() failed.", MAL_FAILED_TO_CONFIGURE_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set start threshold for playback device. snd_pcm_sw_params_set_start_threshold() failed.", MA_FAILED_TO_CONFIGURE_BACKEND_DEVICE); } if (((mal_snd_pcm_sw_params_set_stop_threshold_proc)pContext->alsa.snd_pcm_sw_params_set_stop_threshold)(pPCM, pSWParams, bufferBoundary) != 0) { /* Set to boundary to loop instead of stop in the event of an xrun. */ ((mal_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to set stop threshold for playback device. snd_pcm_sw_params_set_stop_threshold() failed.", MAL_FAILED_TO_CONFIGURE_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set stop threshold for playback device. snd_pcm_sw_params_set_stop_threshold() failed.", MA_FAILED_TO_CONFIGURE_BACKEND_DEVICE); } } if (((mal_snd_pcm_sw_params_proc)pContext->alsa.snd_pcm_sw_params)(pPCM, pSWParams) != 0) { ((mal_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to set software parameters. snd_pcm_sw_params() failed.", MAL_FAILED_TO_CONFIGURE_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to set software parameters. snd_pcm_sw_params() failed.", MA_FAILED_TO_CONFIGURE_BACKEND_DEVICE); } @@ -12528,7 +12528,7 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device Excess channels use defaults. Do an initial fill with defaults, overwrite the first pChmap->channels, validate to ensure there are no duplicate channels. If validation fails, fall back to defaults. */ - mal_bool32 isValid = MAL_TRUE; + mal_bool32 isValid = MA_TRUE; /* Fill with defaults. */ mal_get_standard_channel_map(mal_standard_channel_map_alsa, internalChannels, internalChannelMap); @@ -12542,7 +12542,7 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device for (mal_uint32 i = 0; i < internalChannels && isValid; ++i) { for (mal_uint32 j = i+1; j < internalChannels; ++j) { if (internalChannelMap[i] == internalChannelMap[j]) { - isValid = MAL_FALSE; + isValid = MA_FALSE; break; } } @@ -12566,7 +12566,7 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device /* We're done. Prepare the device. */ if (((mal_snd_pcm_prepare_proc)pDevice->pContext->alsa.snd_pcm_prepare)(pPCM) < 0) { ((mal_snd_pcm_close_proc)pDevice->pContext->alsa.snd_pcm_close)(pPCM); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to prepare device.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to prepare device.", MA_FAILED_TO_START_BACKEND_DEVICE); } @@ -12590,7 +12590,7 @@ mal_result mal_device_init_by_type__alsa(mal_context* pContext, const mal_device pDevice->playback.internalPeriods = internalPeriods; } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_init__alsa(mal_context* pContext, const mal_device_config* pConfig, mal_device* pDevice) @@ -12601,19 +12601,19 @@ mal_result mal_device_init__alsa(mal_context* pContext, const mal_device_config* if (pConfig->deviceType == mal_device_type_capture || pConfig->deviceType == mal_device_type_duplex) { mal_result result = mal_device_init_by_type__alsa(pContext, pConfig, mal_device_type_capture, pDevice); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } if (pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) { mal_result result = mal_device_init_by_type__alsa(pContext, pConfig, mal_device_type_playback, pDevice); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } - return MAL_SUCCESS; + return MA_SUCCESS; } #if 0 @@ -12623,29 +12623,29 @@ mal_result mal_device_start__alsa(mal_device* pDevice) // Prepare the device first... if (((mal_snd_pcm_prepare_proc)pDevice->pContext->alsa.snd_pcm_prepare)((mal_snd_pcm_t*)pDevice->alsa.pPCM) < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to prepare device.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to prepare device.", MA_FAILED_TO_START_BACKEND_DEVICE); } // ... and then grab an initial chunk from the client. After this is done, the device should // automatically start playing, since that's how we configured the software parameters. if (pDevice->type == mal_device_type_playback) { if (!mal_device_read_from_client_and_write__alsa(pDevice)) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to write initial chunk of data to the playback device.", MAL_FAILED_TO_SEND_DATA_TO_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to write initial chunk of data to the playback device.", MA_FAILED_TO_SEND_DATA_TO_DEVICE); } // mmap mode requires an explicit start. if (pDevice->alsa.isUsingMMap) { if (((mal_snd_pcm_start_proc)pDevice->pContext->alsa.snd_pcm_start)((mal_snd_pcm_t*)pDevice->alsa.pPCM) < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to start capture device.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to start capture device.", MA_FAILED_TO_START_BACKEND_DEVICE); } } } else { if (((mal_snd_pcm_start_proc)pDevice->pContext->alsa.snd_pcm_start)((mal_snd_pcm_t*)pDevice->alsa.pPCM) < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to start capture device.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to start capture device.", MA_FAILED_TO_START_BACKEND_DEVICE); } } - return MAL_SUCCESS; + return MA_SUCCESS; } #endif @@ -12663,7 +12663,7 @@ mal_result mal_device_stop__alsa(mal_device* pDevice) } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_write__alsa(mal_device* pDevice, const void* pPCMFrames, mal_uint32 frameCount) @@ -12692,8 +12692,8 @@ mal_result mal_device_write__alsa(mal_device* pDevice, const void* pPCMFrames, m //printf("TRACE: EPIPE (write)\n"); /* Underrun. Recover and try again. If this fails we need to return an error. */ - if (((mal_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((mal_snd_pcm_t*)pDevice->alsa.pPCMPlayback, resultALSA, MAL_TRUE) < 0) { /* MAL_TRUE=silent (don't print anything on error). */ - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to recover device after underrun.", MAL_FAILED_TO_START_BACKEND_DEVICE); + if (((mal_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((mal_snd_pcm_t*)pDevice->alsa.pPCMPlayback, resultALSA, MA_TRUE) < 0) { /* MA_TRUE=silent (don't print anything on error). */ + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to recover device after underrun.", MA_FAILED_TO_START_BACKEND_DEVICE); } /* @@ -12704,12 +12704,12 @@ mal_result mal_device_write__alsa(mal_device* pDevice, const void* pPCMFrames, m quite right here. */ if (((mal_snd_pcm_start_proc)pDevice->pContext->alsa.snd_pcm_start)((mal_snd_pcm_t*)pDevice->alsa.pPCMPlayback) < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to start device after underrun.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to start device after underrun.", MA_FAILED_TO_START_BACKEND_DEVICE); } resultALSA = ((mal_snd_pcm_writei_proc)pDevice->pContext->alsa.snd_pcm_writei)((mal_snd_pcm_t*)pDevice->alsa.pPCMPlayback, pSrc, framesRemaining); if (resultALSA < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to write data to device after underrun.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to write data to device after underrun.", MA_FAILED_TO_START_BACKEND_DEVICE); } } } @@ -12717,7 +12717,7 @@ mal_result mal_device_write__alsa(mal_device* pDevice, const void* pPCMFrames, m totalPCMFramesProcessed += resultALSA; } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_read__alsa(mal_device* pDevice, void* pPCMFrames, mal_uint32 frameCount) @@ -12729,9 +12729,9 @@ mal_result mal_device_read__alsa(mal_device* pDevice, void* pPCMFrames, mal_uint mal_assert(pPCMFrames != NULL); /* We need to explicitly start the device if it isn't already. */ - if (((mal_snd_pcm_state_proc)pDevice->pContext->alsa.snd_pcm_state)((mal_snd_pcm_t*)pDevice->alsa.pPCMCapture) != MAL_SND_PCM_STATE_RUNNING) { + if (((mal_snd_pcm_state_proc)pDevice->pContext->alsa.snd_pcm_state)((mal_snd_pcm_t*)pDevice->alsa.pPCMCapture) != MA_SND_PCM_STATE_RUNNING) { if (((mal_snd_pcm_start_proc)pDevice->pContext->alsa.snd_pcm_start)((mal_snd_pcm_t*)pDevice->alsa.pPCMCapture) < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to start device in preparation for reading.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to start device in preparation for reading.", MA_FAILED_TO_START_BACKEND_DEVICE); } } @@ -12751,17 +12751,17 @@ mal_result mal_device_read__alsa(mal_device* pDevice, void* pPCMFrames, mal_uint //printf("TRACE: EPIPE (read)\n"); /* Overrun. Recover and try again. If this fails we need to return an error. */ - if (((mal_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((mal_snd_pcm_t*)pDevice->alsa.pPCMCapture, resultALSA, MAL_TRUE) < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to recover device after overrun.", MAL_FAILED_TO_START_BACKEND_DEVICE); + if (((mal_snd_pcm_recover_proc)pDevice->pContext->alsa.snd_pcm_recover)((mal_snd_pcm_t*)pDevice->alsa.pPCMCapture, resultALSA, MA_TRUE) < 0) { + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to recover device after overrun.", MA_FAILED_TO_START_BACKEND_DEVICE); } if (((mal_snd_pcm_start_proc)pDevice->pContext->alsa.snd_pcm_start)((mal_snd_pcm_t*)pDevice->alsa.pPCMCapture) < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to start device after underrun.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to start device after underrun.", MA_FAILED_TO_START_BACKEND_DEVICE); } resultALSA = ((mal_snd_pcm_readi_proc)pDevice->pContext->alsa.snd_pcm_readi)((mal_snd_pcm_t*)pDevice->alsa.pPCMCapture, pDst, framesRemaining); if (resultALSA < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[ALSA] Failed to read data from the internal device.", MAL_FAILED_TO_READ_DATA_FROM_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[ALSA] Failed to read data from the internal device.", MA_FAILED_TO_READ_DATA_FROM_DEVICE); } } } @@ -12769,7 +12769,7 @@ mal_result mal_device_read__alsa(mal_device* pDevice, void* pPCMFrames, mal_uint totalPCMFramesProcessed += resultALSA; } - return MAL_SUCCESS; + return MA_SUCCESS; } #if 0 @@ -12777,15 +12777,15 @@ mal_result mal_device_break_main_loop__alsa(mal_device* pDevice) { mal_assert(pDevice != NULL); - pDevice->alsa.breakFromMainLoop = MAL_TRUE; - return MAL_SUCCESS; + pDevice->alsa.breakFromMainLoop = MA_TRUE; + return MA_SUCCESS; } mal_result mal_device_main_loop__alsa(mal_device* pDevice) { mal_assert(pDevice != NULL); - pDevice->alsa.breakFromMainLoop = MAL_FALSE; + pDevice->alsa.breakFromMainLoop = MA_FALSE; if (pDevice->type == mal_device_type_playback) { // Playback. Read from client, write to device. while (!pDevice->alsa.breakFromMainLoop && mal_device_read_from_client_and_write__alsa(pDevice)) { @@ -12796,7 +12796,7 @@ mal_result mal_device_main_loop__alsa(mal_device* pDevice) } } - return MAL_SUCCESS; + return MA_SUCCESS; } #endif @@ -12808,20 +12808,20 @@ mal_result mal_context_uninit__alsa(mal_context* pContext) // Clean up memory for memory leak checkers. ((mal_snd_config_update_free_global_proc)pContext->alsa.snd_config_update_free_global)(); -#ifndef MAL_NO_RUNTIME_LINKING +#ifndef MA_NO_RUNTIME_LINKING mal_dlclose(pContext->alsa.asoundSO); #endif mal_mutex_uninit(&pContext->alsa.internalDeviceEnumLock); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_init__alsa(mal_context* pContext) { mal_assert(pContext != NULL); -#ifndef MAL_NO_RUNTIME_LINKING +#ifndef MA_NO_RUNTIME_LINKING const char* libasoundNames[] = { "libasound.so.2", "libasound.so" @@ -12835,10 +12835,10 @@ mal_result mal_context_init__alsa(mal_context* pContext) } if (pContext->alsa.asoundSO == NULL) { -#ifdef MAL_DEBUG_OUTPUT +#ifdef MA_DEBUG_OUTPUT printf("[ALSA] Failed to open shared object.\n"); #endif - return MAL_NO_BACKEND; + return MA_NO_BACKEND; } pContext->alsa.snd_pcm_open = (mal_proc)mal_dlsym(pContext->alsa.asoundSO, "snd_pcm_open"); @@ -13009,8 +13009,8 @@ mal_result mal_context_init__alsa(mal_context* pContext) pContext->alsa.snd_config_update_free_global = (mal_proc)_snd_config_update_free_global; #endif - if (mal_mutex_init(pContext, &pContext->alsa.internalDeviceEnumLock) != MAL_SUCCESS) { - mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[ALSA] WARNING: Failed to initialize mutex for internal device enumeration.", MAL_ERROR); + if (mal_mutex_init(pContext, &pContext->alsa.internalDeviceEnumLock) != MA_SUCCESS) { + mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[ALSA] WARNING: Failed to initialize mutex for internal device enumeration.", MA_ERROR); } pContext->onUninit = mal_context_uninit__alsa; @@ -13024,7 +13024,7 @@ mal_result mal_context_init__alsa(mal_context* pContext) pContext->onDeviceWrite = mal_device_write__alsa; pContext->onDeviceRead = mal_device_read__alsa; - return MAL_SUCCESS; + return MA_SUCCESS; } #endif // ALSA @@ -13035,195 +13035,195 @@ mal_result mal_context_init__alsa(mal_context* pContext) // PulseAudio Backend // /////////////////////////////////////////////////////////////////////////////// -#ifdef MAL_HAS_PULSEAUDIO +#ifdef MA_HAS_PULSEAUDIO // It is assumed pulseaudio.h is available when compile-time linking is being used. We use this for type safety when using // compile time linking (we don't have this luxury when using runtime linking without headers). // // When using compile time linking, each of our mal_* equivalents should use the sames types as defined by the header. The // reason for this is that it allow us to take advantage of proper type safety. -#ifdef MAL_NO_RUNTIME_LINKING +#ifdef MA_NO_RUNTIME_LINKING #include -#define MAL_PA_OK PA_OK -#define MAL_PA_ERR_ACCESS PA_ERR_ACCESS -#define MAL_PA_ERR_INVALID PA_ERR_INVALID -#define MAL_PA_ERR_NOENTITY PA_ERR_NOENTITY +#define MA_PA_OK PA_OK +#define MA_PA_ERR_ACCESS PA_ERR_ACCESS +#define MA_PA_ERR_INVALID PA_ERR_INVALID +#define MA_PA_ERR_NOENTITY PA_ERR_NOENTITY -#define MAL_PA_CHANNELS_MAX PA_CHANNELS_MAX -#define MAL_PA_RATE_MAX PA_RATE_MAX +#define MA_PA_CHANNELS_MAX PA_CHANNELS_MAX +#define MA_PA_RATE_MAX PA_RATE_MAX typedef pa_context_flags_t mal_pa_context_flags_t; -#define MAL_PA_CONTEXT_NOFLAGS PA_CONTEXT_NOFLAGS -#define MAL_PA_CONTEXT_NOAUTOSPAWN PA_CONTEXT_NOAUTOSPAWN -#define MAL_PA_CONTEXT_NOFAIL PA_CONTEXT_NOFAIL +#define MA_PA_CONTEXT_NOFLAGS PA_CONTEXT_NOFLAGS +#define MA_PA_CONTEXT_NOAUTOSPAWN PA_CONTEXT_NOAUTOSPAWN +#define MA_PA_CONTEXT_NOFAIL PA_CONTEXT_NOFAIL typedef pa_stream_flags_t mal_pa_stream_flags_t; -#define MAL_PA_STREAM_NOFLAGS PA_STREAM_NOFLAGS -#define MAL_PA_STREAM_START_CORKED PA_STREAM_START_CORKED -#define MAL_PA_STREAM_INTERPOLATE_TIMING PA_STREAM_INTERPOLATE_TIMING -#define MAL_PA_STREAM_NOT_MONOTONIC PA_STREAM_NOT_MONOTONIC -#define MAL_PA_STREAM_AUTO_TIMING_UPDATE PA_STREAM_AUTO_TIMING_UPDATE -#define MAL_PA_STREAM_NO_REMAP_CHANNELS PA_STREAM_NO_REMAP_CHANNELS -#define MAL_PA_STREAM_NO_REMIX_CHANNELS PA_STREAM_NO_REMIX_CHANNELS -#define MAL_PA_STREAM_FIX_FORMAT PA_STREAM_FIX_FORMAT -#define MAL_PA_STREAM_FIX_RATE PA_STREAM_FIX_RATE -#define MAL_PA_STREAM_FIX_CHANNELS PA_STREAM_FIX_CHANNELS -#define MAL_PA_STREAM_DONT_MOVE PA_STREAM_DONT_MOVE -#define MAL_PA_STREAM_VARIABLE_RATE PA_STREAM_VARIABLE_RATE -#define MAL_PA_STREAM_PEAK_DETECT PA_STREAM_PEAK_DETECT -#define MAL_PA_STREAM_START_MUTED PA_STREAM_START_MUTED -#define MAL_PA_STREAM_ADJUST_LATENCY PA_STREAM_ADJUST_LATENCY -#define MAL_PA_STREAM_EARLY_REQUESTS PA_STREAM_EARLY_REQUESTS -#define MAL_PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND -#define MAL_PA_STREAM_START_UNMUTED PA_STREAM_START_UNMUTED -#define MAL_PA_STREAM_FAIL_ON_SUSPEND PA_STREAM_FAIL_ON_SUSPEND -#define MAL_PA_STREAM_RELATIVE_VOLUME PA_STREAM_RELATIVE_VOLUME -#define MAL_PA_STREAM_PASSTHROUGH PA_STREAM_PASSTHROUGH +#define MA_PA_STREAM_NOFLAGS PA_STREAM_NOFLAGS +#define MA_PA_STREAM_START_CORKED PA_STREAM_START_CORKED +#define MA_PA_STREAM_INTERPOLATE_TIMING PA_STREAM_INTERPOLATE_TIMING +#define MA_PA_STREAM_NOT_MONOTONIC PA_STREAM_NOT_MONOTONIC +#define MA_PA_STREAM_AUTO_TIMING_UPDATE PA_STREAM_AUTO_TIMING_UPDATE +#define MA_PA_STREAM_NO_REMAP_CHANNELS PA_STREAM_NO_REMAP_CHANNELS +#define MA_PA_STREAM_NO_REMIX_CHANNELS PA_STREAM_NO_REMIX_CHANNELS +#define MA_PA_STREAM_FIX_FORMAT PA_STREAM_FIX_FORMAT +#define MA_PA_STREAM_FIX_RATE PA_STREAM_FIX_RATE +#define MA_PA_STREAM_FIX_CHANNELS PA_STREAM_FIX_CHANNELS +#define MA_PA_STREAM_DONT_MOVE PA_STREAM_DONT_MOVE +#define MA_PA_STREAM_VARIABLE_RATE PA_STREAM_VARIABLE_RATE +#define MA_PA_STREAM_PEAK_DETECT PA_STREAM_PEAK_DETECT +#define MA_PA_STREAM_START_MUTED PA_STREAM_START_MUTED +#define MA_PA_STREAM_ADJUST_LATENCY PA_STREAM_ADJUST_LATENCY +#define MA_PA_STREAM_EARLY_REQUESTS PA_STREAM_EARLY_REQUESTS +#define MA_PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND +#define MA_PA_STREAM_START_UNMUTED PA_STREAM_START_UNMUTED +#define MA_PA_STREAM_FAIL_ON_SUSPEND PA_STREAM_FAIL_ON_SUSPEND +#define MA_PA_STREAM_RELATIVE_VOLUME PA_STREAM_RELATIVE_VOLUME +#define MA_PA_STREAM_PASSTHROUGH PA_STREAM_PASSTHROUGH typedef pa_sink_flags_t mal_pa_sink_flags_t; -#define MAL_PA_SINK_NOFLAGS PA_SINK_NOFLAGS -#define MAL_PA_SINK_HW_VOLUME_CTRL PA_SINK_HW_VOLUME_CTRL -#define MAL_PA_SINK_LATENCY PA_SINK_LATENCY -#define MAL_PA_SINK_HARDWARE PA_SINK_HARDWARE -#define MAL_PA_SINK_NETWORK PA_SINK_NETWORK -#define MAL_PA_SINK_HW_MUTE_CTRL PA_SINK_HW_MUTE_CTRL -#define MAL_PA_SINK_DECIBEL_VOLUME PA_SINK_DECIBEL_VOLUME -#define MAL_PA_SINK_FLAT_VOLUME PA_SINK_FLAT_VOLUME -#define MAL_PA_SINK_DYNAMIC_LATENCY PA_SINK_DYNAMIC_LATENCY -#define MAL_PA_SINK_SET_FORMATS PA_SINK_SET_FORMATS +#define MA_PA_SINK_NOFLAGS PA_SINK_NOFLAGS +#define MA_PA_SINK_HW_VOLUME_CTRL PA_SINK_HW_VOLUME_CTRL +#define MA_PA_SINK_LATENCY PA_SINK_LATENCY +#define MA_PA_SINK_HARDWARE PA_SINK_HARDWARE +#define MA_PA_SINK_NETWORK PA_SINK_NETWORK +#define MA_PA_SINK_HW_MUTE_CTRL PA_SINK_HW_MUTE_CTRL +#define MA_PA_SINK_DECIBEL_VOLUME PA_SINK_DECIBEL_VOLUME +#define MA_PA_SINK_FLAT_VOLUME PA_SINK_FLAT_VOLUME +#define MA_PA_SINK_DYNAMIC_LATENCY PA_SINK_DYNAMIC_LATENCY +#define MA_PA_SINK_SET_FORMATS PA_SINK_SET_FORMATS typedef pa_source_flags_t mal_pa_source_flags_t; -#define MAL_PA_SOURCE_NOFLAGS PA_SOURCE_NOFLAGS -#define MAL_PA_SOURCE_HW_VOLUME_CTRL PA_SOURCE_HW_VOLUME_CTRL -#define MAL_PA_SOURCE_LATENCY PA_SOURCE_LATENCY -#define MAL_PA_SOURCE_HARDWARE PA_SOURCE_HARDWARE -#define MAL_PA_SOURCE_NETWORK PA_SOURCE_NETWORK -#define MAL_PA_SOURCE_HW_MUTE_CTRL PA_SOURCE_HW_MUTE_CTRL -#define MAL_PA_SOURCE_DECIBEL_VOLUME PA_SOURCE_DECIBEL_VOLUME -#define MAL_PA_SOURCE_DYNAMIC_LATENCY PA_SOURCE_DYNAMIC_LATENCY -#define MAL_PA_SOURCE_FLAT_VOLUME PA_SOURCE_FLAT_VOLUME +#define MA_PA_SOURCE_NOFLAGS PA_SOURCE_NOFLAGS +#define MA_PA_SOURCE_HW_VOLUME_CTRL PA_SOURCE_HW_VOLUME_CTRL +#define MA_PA_SOURCE_LATENCY PA_SOURCE_LATENCY +#define MA_PA_SOURCE_HARDWARE PA_SOURCE_HARDWARE +#define MA_PA_SOURCE_NETWORK PA_SOURCE_NETWORK +#define MA_PA_SOURCE_HW_MUTE_CTRL PA_SOURCE_HW_MUTE_CTRL +#define MA_PA_SOURCE_DECIBEL_VOLUME PA_SOURCE_DECIBEL_VOLUME +#define MA_PA_SOURCE_DYNAMIC_LATENCY PA_SOURCE_DYNAMIC_LATENCY +#define MA_PA_SOURCE_FLAT_VOLUME PA_SOURCE_FLAT_VOLUME typedef pa_context_state_t mal_pa_context_state_t; -#define MAL_PA_CONTEXT_UNCONNECTED PA_CONTEXT_UNCONNECTED -#define MAL_PA_CONTEXT_CONNECTING PA_CONTEXT_CONNECTING -#define MAL_PA_CONTEXT_AUTHORIZING PA_CONTEXT_AUTHORIZING -#define MAL_PA_CONTEXT_SETTING_NAME PA_CONTEXT_SETTING_NAME -#define MAL_PA_CONTEXT_READY PA_CONTEXT_READY -#define MAL_PA_CONTEXT_FAILED PA_CONTEXT_FAILED -#define MAL_PA_CONTEXT_TERMINATED PA_CONTEXT_TERMINATED +#define MA_PA_CONTEXT_UNCONNECTED PA_CONTEXT_UNCONNECTED +#define MA_PA_CONTEXT_CONNECTING PA_CONTEXT_CONNECTING +#define MA_PA_CONTEXT_AUTHORIZING PA_CONTEXT_AUTHORIZING +#define MA_PA_CONTEXT_SETTING_NAME PA_CONTEXT_SETTING_NAME +#define MA_PA_CONTEXT_READY PA_CONTEXT_READY +#define MA_PA_CONTEXT_FAILED PA_CONTEXT_FAILED +#define MA_PA_CONTEXT_TERMINATED PA_CONTEXT_TERMINATED typedef pa_stream_state_t mal_pa_stream_state_t; -#define MAL_PA_STREAM_UNCONNECTED PA_STREAM_UNCONNECTED -#define MAL_PA_STREAM_CREATING PA_STREAM_CREATING -#define MAL_PA_STREAM_READY PA_STREAM_READY -#define MAL_PA_STREAM_FAILED PA_STREAM_FAILED -#define MAL_PA_STREAM_TERMINATED PA_STREAM_TERMINATED +#define MA_PA_STREAM_UNCONNECTED PA_STREAM_UNCONNECTED +#define MA_PA_STREAM_CREATING PA_STREAM_CREATING +#define MA_PA_STREAM_READY PA_STREAM_READY +#define MA_PA_STREAM_FAILED PA_STREAM_FAILED +#define MA_PA_STREAM_TERMINATED PA_STREAM_TERMINATED typedef pa_operation_state_t mal_pa_operation_state_t; -#define MAL_PA_OPERATION_RUNNING PA_OPERATION_RUNNING -#define MAL_PA_OPERATION_DONE PA_OPERATION_DONE -#define MAL_PA_OPERATION_CANCELLED PA_OPERATION_CANCELLED +#define MA_PA_OPERATION_RUNNING PA_OPERATION_RUNNING +#define MA_PA_OPERATION_DONE PA_OPERATION_DONE +#define MA_PA_OPERATION_CANCELLED PA_OPERATION_CANCELLED typedef pa_sink_state_t mal_pa_sink_state_t; -#define MAL_PA_SINK_INVALID_STATE PA_SINK_INVALID_STATE -#define MAL_PA_SINK_RUNNING PA_SINK_RUNNING -#define MAL_PA_SINK_IDLE PA_SINK_IDLE -#define MAL_PA_SINK_SUSPENDED PA_SINK_SUSPENDED +#define MA_PA_SINK_INVALID_STATE PA_SINK_INVALID_STATE +#define MA_PA_SINK_RUNNING PA_SINK_RUNNING +#define MA_PA_SINK_IDLE PA_SINK_IDLE +#define MA_PA_SINK_SUSPENDED PA_SINK_SUSPENDED typedef pa_source_state_t mal_pa_source_state_t; -#define MAL_PA_SOURCE_INVALID_STATE PA_SOURCE_INVALID_STATE -#define MAL_PA_SOURCE_RUNNING PA_SOURCE_RUNNING -#define MAL_PA_SOURCE_IDLE PA_SOURCE_IDLE -#define MAL_PA_SOURCE_SUSPENDED PA_SOURCE_SUSPENDED +#define MA_PA_SOURCE_INVALID_STATE PA_SOURCE_INVALID_STATE +#define MA_PA_SOURCE_RUNNING PA_SOURCE_RUNNING +#define MA_PA_SOURCE_IDLE PA_SOURCE_IDLE +#define MA_PA_SOURCE_SUSPENDED PA_SOURCE_SUSPENDED typedef pa_seek_mode_t mal_pa_seek_mode_t; -#define MAL_PA_SEEK_RELATIVE PA_SEEK_RELATIVE -#define MAL_PA_SEEK_ABSOLUTE PA_SEEK_ABSOLUTE -#define MAL_PA_SEEK_RELATIVE_ON_READ PA_SEEK_RELATIVE_ON_READ -#define MAL_PA_SEEK_RELATIVE_END PA_SEEK_RELATIVE_END +#define MA_PA_SEEK_RELATIVE PA_SEEK_RELATIVE +#define MA_PA_SEEK_ABSOLUTE PA_SEEK_ABSOLUTE +#define MA_PA_SEEK_RELATIVE_ON_READ PA_SEEK_RELATIVE_ON_READ +#define MA_PA_SEEK_RELATIVE_END PA_SEEK_RELATIVE_END typedef pa_channel_position_t mal_pa_channel_position_t; -#define MAL_PA_CHANNEL_POSITION_INVALID PA_CHANNEL_POSITION_INVALID -#define MAL_PA_CHANNEL_POSITION_MONO PA_CHANNEL_POSITION_MONO -#define MAL_PA_CHANNEL_POSITION_FRONT_LEFT PA_CHANNEL_POSITION_FRONT_LEFT -#define MAL_PA_CHANNEL_POSITION_FRONT_RIGHT PA_CHANNEL_POSITION_FRONT_RIGHT -#define MAL_PA_CHANNEL_POSITION_FRONT_CENTER PA_CHANNEL_POSITION_FRONT_CENTER -#define MAL_PA_CHANNEL_POSITION_REAR_CENTER PA_CHANNEL_POSITION_REAR_CENTER -#define MAL_PA_CHANNEL_POSITION_REAR_LEFT PA_CHANNEL_POSITION_REAR_LEFT -#define MAL_PA_CHANNEL_POSITION_REAR_RIGHT PA_CHANNEL_POSITION_REAR_RIGHT -#define MAL_PA_CHANNEL_POSITION_LFE PA_CHANNEL_POSITION_LFE -#define MAL_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER -#define MAL_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER -#define MAL_PA_CHANNEL_POSITION_SIDE_LEFT PA_CHANNEL_POSITION_SIDE_LEFT -#define MAL_PA_CHANNEL_POSITION_SIDE_RIGHT PA_CHANNEL_POSITION_SIDE_RIGHT -#define MAL_PA_CHANNEL_POSITION_AUX0 PA_CHANNEL_POSITION_AUX0 -#define MAL_PA_CHANNEL_POSITION_AUX1 PA_CHANNEL_POSITION_AUX1 -#define MAL_PA_CHANNEL_POSITION_AUX2 PA_CHANNEL_POSITION_AUX2 -#define MAL_PA_CHANNEL_POSITION_AUX3 PA_CHANNEL_POSITION_AUX3 -#define MAL_PA_CHANNEL_POSITION_AUX4 PA_CHANNEL_POSITION_AUX4 -#define MAL_PA_CHANNEL_POSITION_AUX5 PA_CHANNEL_POSITION_AUX5 -#define MAL_PA_CHANNEL_POSITION_AUX6 PA_CHANNEL_POSITION_AUX6 -#define MAL_PA_CHANNEL_POSITION_AUX7 PA_CHANNEL_POSITION_AUX7 -#define MAL_PA_CHANNEL_POSITION_AUX8 PA_CHANNEL_POSITION_AUX8 -#define MAL_PA_CHANNEL_POSITION_AUX9 PA_CHANNEL_POSITION_AUX9 -#define MAL_PA_CHANNEL_POSITION_AUX10 PA_CHANNEL_POSITION_AUX10 -#define MAL_PA_CHANNEL_POSITION_AUX11 PA_CHANNEL_POSITION_AUX11 -#define MAL_PA_CHANNEL_POSITION_AUX12 PA_CHANNEL_POSITION_AUX12 -#define MAL_PA_CHANNEL_POSITION_AUX13 PA_CHANNEL_POSITION_AUX13 -#define MAL_PA_CHANNEL_POSITION_AUX14 PA_CHANNEL_POSITION_AUX14 -#define MAL_PA_CHANNEL_POSITION_AUX15 PA_CHANNEL_POSITION_AUX15 -#define MAL_PA_CHANNEL_POSITION_AUX16 PA_CHANNEL_POSITION_AUX16 -#define MAL_PA_CHANNEL_POSITION_AUX17 PA_CHANNEL_POSITION_AUX17 -#define MAL_PA_CHANNEL_POSITION_AUX18 PA_CHANNEL_POSITION_AUX18 -#define MAL_PA_CHANNEL_POSITION_AUX19 PA_CHANNEL_POSITION_AUX19 -#define MAL_PA_CHANNEL_POSITION_AUX20 PA_CHANNEL_POSITION_AUX20 -#define MAL_PA_CHANNEL_POSITION_AUX21 PA_CHANNEL_POSITION_AUX21 -#define MAL_PA_CHANNEL_POSITION_AUX22 PA_CHANNEL_POSITION_AUX22 -#define MAL_PA_CHANNEL_POSITION_AUX23 PA_CHANNEL_POSITION_AUX23 -#define MAL_PA_CHANNEL_POSITION_AUX24 PA_CHANNEL_POSITION_AUX24 -#define MAL_PA_CHANNEL_POSITION_AUX25 PA_CHANNEL_POSITION_AUX25 -#define MAL_PA_CHANNEL_POSITION_AUX26 PA_CHANNEL_POSITION_AUX26 -#define MAL_PA_CHANNEL_POSITION_AUX27 PA_CHANNEL_POSITION_AUX27 -#define MAL_PA_CHANNEL_POSITION_AUX28 PA_CHANNEL_POSITION_AUX28 -#define MAL_PA_CHANNEL_POSITION_AUX29 PA_CHANNEL_POSITION_AUX29 -#define MAL_PA_CHANNEL_POSITION_AUX30 PA_CHANNEL_POSITION_AUX30 -#define MAL_PA_CHANNEL_POSITION_AUX31 PA_CHANNEL_POSITION_AUX31 -#define MAL_PA_CHANNEL_POSITION_TOP_CENTER PA_CHANNEL_POSITION_TOP_CENTER -#define MAL_PA_CHANNEL_POSITION_TOP_FRONT_LEFT PA_CHANNEL_POSITION_TOP_FRONT_LEFT -#define MAL_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT PA_CHANNEL_POSITION_TOP_FRONT_RIGHT -#define MAL_PA_CHANNEL_POSITION_TOP_FRONT_CENTER PA_CHANNEL_POSITION_TOP_FRONT_CENTER -#define MAL_PA_CHANNEL_POSITION_TOP_REAR_LEFT PA_CHANNEL_POSITION_TOP_REAR_LEFT -#define MAL_PA_CHANNEL_POSITION_TOP_REAR_RIGHT PA_CHANNEL_POSITION_TOP_REAR_RIGHT -#define MAL_PA_CHANNEL_POSITION_TOP_REAR_CENTER PA_CHANNEL_POSITION_TOP_REAR_CENTER -#define MAL_PA_CHANNEL_POSITION_LEFT PA_CHANNEL_POSITION_LEFT -#define MAL_PA_CHANNEL_POSITION_RIGHT PA_CHANNEL_POSITION_RIGHT -#define MAL_PA_CHANNEL_POSITION_CENTER PA_CHANNEL_POSITION_CENTER -#define MAL_PA_CHANNEL_POSITION_SUBWOOFER PA_CHANNEL_POSITION_SUBWOOFER +#define MA_PA_CHANNEL_POSITION_INVALID PA_CHANNEL_POSITION_INVALID +#define MA_PA_CHANNEL_POSITION_MONO PA_CHANNEL_POSITION_MONO +#define MA_PA_CHANNEL_POSITION_FRONT_LEFT PA_CHANNEL_POSITION_FRONT_LEFT +#define MA_PA_CHANNEL_POSITION_FRONT_RIGHT PA_CHANNEL_POSITION_FRONT_RIGHT +#define MA_PA_CHANNEL_POSITION_FRONT_CENTER PA_CHANNEL_POSITION_FRONT_CENTER +#define MA_PA_CHANNEL_POSITION_REAR_CENTER PA_CHANNEL_POSITION_REAR_CENTER +#define MA_PA_CHANNEL_POSITION_REAR_LEFT PA_CHANNEL_POSITION_REAR_LEFT +#define MA_PA_CHANNEL_POSITION_REAR_RIGHT PA_CHANNEL_POSITION_REAR_RIGHT +#define MA_PA_CHANNEL_POSITION_LFE PA_CHANNEL_POSITION_LFE +#define MA_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER +#define MA_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER +#define MA_PA_CHANNEL_POSITION_SIDE_LEFT PA_CHANNEL_POSITION_SIDE_LEFT +#define MA_PA_CHANNEL_POSITION_SIDE_RIGHT PA_CHANNEL_POSITION_SIDE_RIGHT +#define MA_PA_CHANNEL_POSITION_AUX0 PA_CHANNEL_POSITION_AUX0 +#define MA_PA_CHANNEL_POSITION_AUX1 PA_CHANNEL_POSITION_AUX1 +#define MA_PA_CHANNEL_POSITION_AUX2 PA_CHANNEL_POSITION_AUX2 +#define MA_PA_CHANNEL_POSITION_AUX3 PA_CHANNEL_POSITION_AUX3 +#define MA_PA_CHANNEL_POSITION_AUX4 PA_CHANNEL_POSITION_AUX4 +#define MA_PA_CHANNEL_POSITION_AUX5 PA_CHANNEL_POSITION_AUX5 +#define MA_PA_CHANNEL_POSITION_AUX6 PA_CHANNEL_POSITION_AUX6 +#define MA_PA_CHANNEL_POSITION_AUX7 PA_CHANNEL_POSITION_AUX7 +#define MA_PA_CHANNEL_POSITION_AUX8 PA_CHANNEL_POSITION_AUX8 +#define MA_PA_CHANNEL_POSITION_AUX9 PA_CHANNEL_POSITION_AUX9 +#define MA_PA_CHANNEL_POSITION_AUX10 PA_CHANNEL_POSITION_AUX10 +#define MA_PA_CHANNEL_POSITION_AUX11 PA_CHANNEL_POSITION_AUX11 +#define MA_PA_CHANNEL_POSITION_AUX12 PA_CHANNEL_POSITION_AUX12 +#define MA_PA_CHANNEL_POSITION_AUX13 PA_CHANNEL_POSITION_AUX13 +#define MA_PA_CHANNEL_POSITION_AUX14 PA_CHANNEL_POSITION_AUX14 +#define MA_PA_CHANNEL_POSITION_AUX15 PA_CHANNEL_POSITION_AUX15 +#define MA_PA_CHANNEL_POSITION_AUX16 PA_CHANNEL_POSITION_AUX16 +#define MA_PA_CHANNEL_POSITION_AUX17 PA_CHANNEL_POSITION_AUX17 +#define MA_PA_CHANNEL_POSITION_AUX18 PA_CHANNEL_POSITION_AUX18 +#define MA_PA_CHANNEL_POSITION_AUX19 PA_CHANNEL_POSITION_AUX19 +#define MA_PA_CHANNEL_POSITION_AUX20 PA_CHANNEL_POSITION_AUX20 +#define MA_PA_CHANNEL_POSITION_AUX21 PA_CHANNEL_POSITION_AUX21 +#define MA_PA_CHANNEL_POSITION_AUX22 PA_CHANNEL_POSITION_AUX22 +#define MA_PA_CHANNEL_POSITION_AUX23 PA_CHANNEL_POSITION_AUX23 +#define MA_PA_CHANNEL_POSITION_AUX24 PA_CHANNEL_POSITION_AUX24 +#define MA_PA_CHANNEL_POSITION_AUX25 PA_CHANNEL_POSITION_AUX25 +#define MA_PA_CHANNEL_POSITION_AUX26 PA_CHANNEL_POSITION_AUX26 +#define MA_PA_CHANNEL_POSITION_AUX27 PA_CHANNEL_POSITION_AUX27 +#define MA_PA_CHANNEL_POSITION_AUX28 PA_CHANNEL_POSITION_AUX28 +#define MA_PA_CHANNEL_POSITION_AUX29 PA_CHANNEL_POSITION_AUX29 +#define MA_PA_CHANNEL_POSITION_AUX30 PA_CHANNEL_POSITION_AUX30 +#define MA_PA_CHANNEL_POSITION_AUX31 PA_CHANNEL_POSITION_AUX31 +#define MA_PA_CHANNEL_POSITION_TOP_CENTER PA_CHANNEL_POSITION_TOP_CENTER +#define MA_PA_CHANNEL_POSITION_TOP_FRONT_LEFT PA_CHANNEL_POSITION_TOP_FRONT_LEFT +#define MA_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT PA_CHANNEL_POSITION_TOP_FRONT_RIGHT +#define MA_PA_CHANNEL_POSITION_TOP_FRONT_CENTER PA_CHANNEL_POSITION_TOP_FRONT_CENTER +#define MA_PA_CHANNEL_POSITION_TOP_REAR_LEFT PA_CHANNEL_POSITION_TOP_REAR_LEFT +#define MA_PA_CHANNEL_POSITION_TOP_REAR_RIGHT PA_CHANNEL_POSITION_TOP_REAR_RIGHT +#define MA_PA_CHANNEL_POSITION_TOP_REAR_CENTER PA_CHANNEL_POSITION_TOP_REAR_CENTER +#define MA_PA_CHANNEL_POSITION_LEFT PA_CHANNEL_POSITION_LEFT +#define MA_PA_CHANNEL_POSITION_RIGHT PA_CHANNEL_POSITION_RIGHT +#define MA_PA_CHANNEL_POSITION_CENTER PA_CHANNEL_POSITION_CENTER +#define MA_PA_CHANNEL_POSITION_SUBWOOFER PA_CHANNEL_POSITION_SUBWOOFER typedef pa_channel_map_def_t mal_pa_channel_map_def_t; -#define MAL_PA_CHANNEL_MAP_AIFF PA_CHANNEL_MAP_AIFF -#define MAL_PA_CHANNEL_MAP_ALSA PA_CHANNEL_MAP_ALSA -#define MAL_PA_CHANNEL_MAP_AUX PA_CHANNEL_MAP_AUX -#define MAL_PA_CHANNEL_MAP_WAVEEX PA_CHANNEL_MAP_WAVEEX -#define MAL_PA_CHANNEL_MAP_OSS PA_CHANNEL_MAP_OSS -#define MAL_PA_CHANNEL_MAP_DEFAULT PA_CHANNEL_MAP_DEFAULT +#define MA_PA_CHANNEL_MAP_AIFF PA_CHANNEL_MAP_AIFF +#define MA_PA_CHANNEL_MAP_ALSA PA_CHANNEL_MAP_ALSA +#define MA_PA_CHANNEL_MAP_AUX PA_CHANNEL_MAP_AUX +#define MA_PA_CHANNEL_MAP_WAVEEX PA_CHANNEL_MAP_WAVEEX +#define MA_PA_CHANNEL_MAP_OSS PA_CHANNEL_MAP_OSS +#define MA_PA_CHANNEL_MAP_DEFAULT PA_CHANNEL_MAP_DEFAULT typedef pa_sample_format_t mal_pa_sample_format_t; -#define MAL_PA_SAMPLE_INVALID PA_SAMPLE_INVALID -#define MAL_PA_SAMPLE_U8 PA_SAMPLE_U8 -#define MAL_PA_SAMPLE_ALAW PA_SAMPLE_ALAW -#define MAL_PA_SAMPLE_ULAW PA_SAMPLE_ULAW -#define MAL_PA_SAMPLE_S16LE PA_SAMPLE_S16LE -#define MAL_PA_SAMPLE_S16BE PA_SAMPLE_S16BE -#define MAL_PA_SAMPLE_FLOAT32LE PA_SAMPLE_FLOAT32LE -#define MAL_PA_SAMPLE_FLOAT32BE PA_SAMPLE_FLOAT32BE -#define MAL_PA_SAMPLE_S32LE PA_SAMPLE_S32LE -#define MAL_PA_SAMPLE_S32BE PA_SAMPLE_S32BE -#define MAL_PA_SAMPLE_S24LE PA_SAMPLE_S24LE -#define MAL_PA_SAMPLE_S24BE PA_SAMPLE_S24BE -#define MAL_PA_SAMPLE_S24_32LE PA_SAMPLE_S24_32LE -#define MAL_PA_SAMPLE_S24_32BE PA_SAMPLE_S24_32BE +#define MA_PA_SAMPLE_INVALID PA_SAMPLE_INVALID +#define MA_PA_SAMPLE_U8 PA_SAMPLE_U8 +#define MA_PA_SAMPLE_ALAW PA_SAMPLE_ALAW +#define MA_PA_SAMPLE_ULAW PA_SAMPLE_ULAW +#define MA_PA_SAMPLE_S16LE PA_SAMPLE_S16LE +#define MA_PA_SAMPLE_S16BE PA_SAMPLE_S16BE +#define MA_PA_SAMPLE_FLOAT32LE PA_SAMPLE_FLOAT32LE +#define MA_PA_SAMPLE_FLOAT32BE PA_SAMPLE_FLOAT32BE +#define MA_PA_SAMPLE_S32LE PA_SAMPLE_S32LE +#define MA_PA_SAMPLE_S32BE PA_SAMPLE_S32BE +#define MA_PA_SAMPLE_S24LE PA_SAMPLE_S24LE +#define MA_PA_SAMPLE_S24BE PA_SAMPLE_S24BE +#define MA_PA_SAMPLE_S24_32LE PA_SAMPLE_S24_32LE +#define MA_PA_SAMPLE_S24_32BE PA_SAMPLE_S24_32BE typedef pa_mainloop mal_pa_mainloop; typedef pa_mainloop_api mal_pa_mainloop_api; @@ -13245,185 +13245,185 @@ typedef pa_stream_success_cb_t mal_pa_stream_success_cb_t; typedef pa_stream_request_cb_t mal_pa_stream_request_cb_t; typedef pa_free_cb_t mal_pa_free_cb_t; #else -#define MAL_PA_OK 0 -#define MAL_PA_ERR_ACCESS 1 -#define MAL_PA_ERR_INVALID 2 -#define MAL_PA_ERR_NOENTITY 5 +#define MA_PA_OK 0 +#define MA_PA_ERR_ACCESS 1 +#define MA_PA_ERR_INVALID 2 +#define MA_PA_ERR_NOENTITY 5 -#define MAL_PA_CHANNELS_MAX 32 -#define MAL_PA_RATE_MAX 384000 +#define MA_PA_CHANNELS_MAX 32 +#define MA_PA_RATE_MAX 384000 typedef int mal_pa_context_flags_t; -#define MAL_PA_CONTEXT_NOFLAGS 0x00000000 -#define MAL_PA_CONTEXT_NOAUTOSPAWN 0x00000001 -#define MAL_PA_CONTEXT_NOFAIL 0x00000002 +#define MA_PA_CONTEXT_NOFLAGS 0x00000000 +#define MA_PA_CONTEXT_NOAUTOSPAWN 0x00000001 +#define MA_PA_CONTEXT_NOFAIL 0x00000002 typedef int mal_pa_stream_flags_t; -#define MAL_PA_STREAM_NOFLAGS 0x00000000 -#define MAL_PA_STREAM_START_CORKED 0x00000001 -#define MAL_PA_STREAM_INTERPOLATE_TIMING 0x00000002 -#define MAL_PA_STREAM_NOT_MONOTONIC 0x00000004 -#define MAL_PA_STREAM_AUTO_TIMING_UPDATE 0x00000008 -#define MAL_PA_STREAM_NO_REMAP_CHANNELS 0x00000010 -#define MAL_PA_STREAM_NO_REMIX_CHANNELS 0x00000020 -#define MAL_PA_STREAM_FIX_FORMAT 0x00000040 -#define MAL_PA_STREAM_FIX_RATE 0x00000080 -#define MAL_PA_STREAM_FIX_CHANNELS 0x00000100 -#define MAL_PA_STREAM_DONT_MOVE 0x00000200 -#define MAL_PA_STREAM_VARIABLE_RATE 0x00000400 -#define MAL_PA_STREAM_PEAK_DETECT 0x00000800 -#define MAL_PA_STREAM_START_MUTED 0x00001000 -#define MAL_PA_STREAM_ADJUST_LATENCY 0x00002000 -#define MAL_PA_STREAM_EARLY_REQUESTS 0x00004000 -#define MAL_PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND 0x00008000 -#define MAL_PA_STREAM_START_UNMUTED 0x00010000 -#define MAL_PA_STREAM_FAIL_ON_SUSPEND 0x00020000 -#define MAL_PA_STREAM_RELATIVE_VOLUME 0x00040000 -#define MAL_PA_STREAM_PASSTHROUGH 0x00080000 +#define MA_PA_STREAM_NOFLAGS 0x00000000 +#define MA_PA_STREAM_START_CORKED 0x00000001 +#define MA_PA_STREAM_INTERPOLATE_TIMING 0x00000002 +#define MA_PA_STREAM_NOT_MONOTONIC 0x00000004 +#define MA_PA_STREAM_AUTO_TIMING_UPDATE 0x00000008 +#define MA_PA_STREAM_NO_REMAP_CHANNELS 0x00000010 +#define MA_PA_STREAM_NO_REMIX_CHANNELS 0x00000020 +#define MA_PA_STREAM_FIX_FORMAT 0x00000040 +#define MA_PA_STREAM_FIX_RATE 0x00000080 +#define MA_PA_STREAM_FIX_CHANNELS 0x00000100 +#define MA_PA_STREAM_DONT_MOVE 0x00000200 +#define MA_PA_STREAM_VARIABLE_RATE 0x00000400 +#define MA_PA_STREAM_PEAK_DETECT 0x00000800 +#define MA_PA_STREAM_START_MUTED 0x00001000 +#define MA_PA_STREAM_ADJUST_LATENCY 0x00002000 +#define MA_PA_STREAM_EARLY_REQUESTS 0x00004000 +#define MA_PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND 0x00008000 +#define MA_PA_STREAM_START_UNMUTED 0x00010000 +#define MA_PA_STREAM_FAIL_ON_SUSPEND 0x00020000 +#define MA_PA_STREAM_RELATIVE_VOLUME 0x00040000 +#define MA_PA_STREAM_PASSTHROUGH 0x00080000 typedef int mal_pa_sink_flags_t; -#define MAL_PA_SINK_NOFLAGS 0x00000000 -#define MAL_PA_SINK_HW_VOLUME_CTRL 0x00000001 -#define MAL_PA_SINK_LATENCY 0x00000002 -#define MAL_PA_SINK_HARDWARE 0x00000004 -#define MAL_PA_SINK_NETWORK 0x00000008 -#define MAL_PA_SINK_HW_MUTE_CTRL 0x00000010 -#define MAL_PA_SINK_DECIBEL_VOLUME 0x00000020 -#define MAL_PA_SINK_FLAT_VOLUME 0x00000040 -#define MAL_PA_SINK_DYNAMIC_LATENCY 0x00000080 -#define MAL_PA_SINK_SET_FORMATS 0x00000100 +#define MA_PA_SINK_NOFLAGS 0x00000000 +#define MA_PA_SINK_HW_VOLUME_CTRL 0x00000001 +#define MA_PA_SINK_LATENCY 0x00000002 +#define MA_PA_SINK_HARDWARE 0x00000004 +#define MA_PA_SINK_NETWORK 0x00000008 +#define MA_PA_SINK_HW_MUTE_CTRL 0x00000010 +#define MA_PA_SINK_DECIBEL_VOLUME 0x00000020 +#define MA_PA_SINK_FLAT_VOLUME 0x00000040 +#define MA_PA_SINK_DYNAMIC_LATENCY 0x00000080 +#define MA_PA_SINK_SET_FORMATS 0x00000100 typedef int mal_pa_source_flags_t; -#define MAL_PA_SOURCE_NOFLAGS 0x00000000 -#define MAL_PA_SOURCE_HW_VOLUME_CTRL 0x00000001 -#define MAL_PA_SOURCE_LATENCY 0x00000002 -#define MAL_PA_SOURCE_HARDWARE 0x00000004 -#define MAL_PA_SOURCE_NETWORK 0x00000008 -#define MAL_PA_SOURCE_HW_MUTE_CTRL 0x00000010 -#define MAL_PA_SOURCE_DECIBEL_VOLUME 0x00000020 -#define MAL_PA_SOURCE_DYNAMIC_LATENCY 0x00000040 -#define MAL_PA_SOURCE_FLAT_VOLUME 0x00000080 +#define MA_PA_SOURCE_NOFLAGS 0x00000000 +#define MA_PA_SOURCE_HW_VOLUME_CTRL 0x00000001 +#define MA_PA_SOURCE_LATENCY 0x00000002 +#define MA_PA_SOURCE_HARDWARE 0x00000004 +#define MA_PA_SOURCE_NETWORK 0x00000008 +#define MA_PA_SOURCE_HW_MUTE_CTRL 0x00000010 +#define MA_PA_SOURCE_DECIBEL_VOLUME 0x00000020 +#define MA_PA_SOURCE_DYNAMIC_LATENCY 0x00000040 +#define MA_PA_SOURCE_FLAT_VOLUME 0x00000080 typedef int mal_pa_context_state_t; -#define MAL_PA_CONTEXT_UNCONNECTED 0 -#define MAL_PA_CONTEXT_CONNECTING 1 -#define MAL_PA_CONTEXT_AUTHORIZING 2 -#define MAL_PA_CONTEXT_SETTING_NAME 3 -#define MAL_PA_CONTEXT_READY 4 -#define MAL_PA_CONTEXT_FAILED 5 -#define MAL_PA_CONTEXT_TERMINATED 6 +#define MA_PA_CONTEXT_UNCONNECTED 0 +#define MA_PA_CONTEXT_CONNECTING 1 +#define MA_PA_CONTEXT_AUTHORIZING 2 +#define MA_PA_CONTEXT_SETTING_NAME 3 +#define MA_PA_CONTEXT_READY 4 +#define MA_PA_CONTEXT_FAILED 5 +#define MA_PA_CONTEXT_TERMINATED 6 typedef int mal_pa_stream_state_t; -#define MAL_PA_STREAM_UNCONNECTED 0 -#define MAL_PA_STREAM_CREATING 1 -#define MAL_PA_STREAM_READY 2 -#define MAL_PA_STREAM_FAILED 3 -#define MAL_PA_STREAM_TERMINATED 4 +#define MA_PA_STREAM_UNCONNECTED 0 +#define MA_PA_STREAM_CREATING 1 +#define MA_PA_STREAM_READY 2 +#define MA_PA_STREAM_FAILED 3 +#define MA_PA_STREAM_TERMINATED 4 typedef int mal_pa_operation_state_t; -#define MAL_PA_OPERATION_RUNNING 0 -#define MAL_PA_OPERATION_DONE 1 -#define MAL_PA_OPERATION_CANCELLED 2 +#define MA_PA_OPERATION_RUNNING 0 +#define MA_PA_OPERATION_DONE 1 +#define MA_PA_OPERATION_CANCELLED 2 typedef int mal_pa_sink_state_t; -#define MAL_PA_SINK_INVALID_STATE -1 -#define MAL_PA_SINK_RUNNING 0 -#define MAL_PA_SINK_IDLE 1 -#define MAL_PA_SINK_SUSPENDED 2 +#define MA_PA_SINK_INVALID_STATE -1 +#define MA_PA_SINK_RUNNING 0 +#define MA_PA_SINK_IDLE 1 +#define MA_PA_SINK_SUSPENDED 2 typedef int mal_pa_source_state_t; -#define MAL_PA_SOURCE_INVALID_STATE -1 -#define MAL_PA_SOURCE_RUNNING 0 -#define MAL_PA_SOURCE_IDLE 1 -#define MAL_PA_SOURCE_SUSPENDED 2 +#define MA_PA_SOURCE_INVALID_STATE -1 +#define MA_PA_SOURCE_RUNNING 0 +#define MA_PA_SOURCE_IDLE 1 +#define MA_PA_SOURCE_SUSPENDED 2 typedef int mal_pa_seek_mode_t; -#define MAL_PA_SEEK_RELATIVE 0 -#define MAL_PA_SEEK_ABSOLUTE 1 -#define MAL_PA_SEEK_RELATIVE_ON_READ 2 -#define MAL_PA_SEEK_RELATIVE_END 3 +#define MA_PA_SEEK_RELATIVE 0 +#define MA_PA_SEEK_ABSOLUTE 1 +#define MA_PA_SEEK_RELATIVE_ON_READ 2 +#define MA_PA_SEEK_RELATIVE_END 3 typedef int mal_pa_channel_position_t; -#define MAL_PA_CHANNEL_POSITION_INVALID -1 -#define MAL_PA_CHANNEL_POSITION_MONO 0 -#define MAL_PA_CHANNEL_POSITION_FRONT_LEFT 1 -#define MAL_PA_CHANNEL_POSITION_FRONT_RIGHT 2 -#define MAL_PA_CHANNEL_POSITION_FRONT_CENTER 3 -#define MAL_PA_CHANNEL_POSITION_REAR_CENTER 4 -#define MAL_PA_CHANNEL_POSITION_REAR_LEFT 5 -#define MAL_PA_CHANNEL_POSITION_REAR_RIGHT 6 -#define MAL_PA_CHANNEL_POSITION_LFE 7 -#define MAL_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER 8 -#define MAL_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER 9 -#define MAL_PA_CHANNEL_POSITION_SIDE_LEFT 10 -#define MAL_PA_CHANNEL_POSITION_SIDE_RIGHT 11 -#define MAL_PA_CHANNEL_POSITION_AUX0 12 -#define MAL_PA_CHANNEL_POSITION_AUX1 13 -#define MAL_PA_CHANNEL_POSITION_AUX2 14 -#define MAL_PA_CHANNEL_POSITION_AUX3 15 -#define MAL_PA_CHANNEL_POSITION_AUX4 16 -#define MAL_PA_CHANNEL_POSITION_AUX5 17 -#define MAL_PA_CHANNEL_POSITION_AUX6 18 -#define MAL_PA_CHANNEL_POSITION_AUX7 19 -#define MAL_PA_CHANNEL_POSITION_AUX8 20 -#define MAL_PA_CHANNEL_POSITION_AUX9 21 -#define MAL_PA_CHANNEL_POSITION_AUX10 22 -#define MAL_PA_CHANNEL_POSITION_AUX11 23 -#define MAL_PA_CHANNEL_POSITION_AUX12 24 -#define MAL_PA_CHANNEL_POSITION_AUX13 25 -#define MAL_PA_CHANNEL_POSITION_AUX14 26 -#define MAL_PA_CHANNEL_POSITION_AUX15 27 -#define MAL_PA_CHANNEL_POSITION_AUX16 28 -#define MAL_PA_CHANNEL_POSITION_AUX17 29 -#define MAL_PA_CHANNEL_POSITION_AUX18 30 -#define MAL_PA_CHANNEL_POSITION_AUX19 31 -#define MAL_PA_CHANNEL_POSITION_AUX20 32 -#define MAL_PA_CHANNEL_POSITION_AUX21 33 -#define MAL_PA_CHANNEL_POSITION_AUX22 34 -#define MAL_PA_CHANNEL_POSITION_AUX23 35 -#define MAL_PA_CHANNEL_POSITION_AUX24 36 -#define MAL_PA_CHANNEL_POSITION_AUX25 37 -#define MAL_PA_CHANNEL_POSITION_AUX26 38 -#define MAL_PA_CHANNEL_POSITION_AUX27 39 -#define MAL_PA_CHANNEL_POSITION_AUX28 40 -#define MAL_PA_CHANNEL_POSITION_AUX29 41 -#define MAL_PA_CHANNEL_POSITION_AUX30 42 -#define MAL_PA_CHANNEL_POSITION_AUX31 43 -#define MAL_PA_CHANNEL_POSITION_TOP_CENTER 44 -#define MAL_PA_CHANNEL_POSITION_TOP_FRONT_LEFT 45 -#define MAL_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT 46 -#define MAL_PA_CHANNEL_POSITION_TOP_FRONT_CENTER 47 -#define MAL_PA_CHANNEL_POSITION_TOP_REAR_LEFT 48 -#define MAL_PA_CHANNEL_POSITION_TOP_REAR_RIGHT 49 -#define MAL_PA_CHANNEL_POSITION_TOP_REAR_CENTER 50 -#define MAL_PA_CHANNEL_POSITION_LEFT MAL_PA_CHANNEL_POSITION_FRONT_LEFT -#define MAL_PA_CHANNEL_POSITION_RIGHT MAL_PA_CHANNEL_POSITION_FRONT_RIGHT -#define MAL_PA_CHANNEL_POSITION_CENTER MAL_PA_CHANNEL_POSITION_FRONT_CENTER -#define MAL_PA_CHANNEL_POSITION_SUBWOOFER MAL_PA_CHANNEL_POSITION_LFE +#define MA_PA_CHANNEL_POSITION_INVALID -1 +#define MA_PA_CHANNEL_POSITION_MONO 0 +#define MA_PA_CHANNEL_POSITION_FRONT_LEFT 1 +#define MA_PA_CHANNEL_POSITION_FRONT_RIGHT 2 +#define MA_PA_CHANNEL_POSITION_FRONT_CENTER 3 +#define MA_PA_CHANNEL_POSITION_REAR_CENTER 4 +#define MA_PA_CHANNEL_POSITION_REAR_LEFT 5 +#define MA_PA_CHANNEL_POSITION_REAR_RIGHT 6 +#define MA_PA_CHANNEL_POSITION_LFE 7 +#define MA_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER 8 +#define MA_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER 9 +#define MA_PA_CHANNEL_POSITION_SIDE_LEFT 10 +#define MA_PA_CHANNEL_POSITION_SIDE_RIGHT 11 +#define MA_PA_CHANNEL_POSITION_AUX0 12 +#define MA_PA_CHANNEL_POSITION_AUX1 13 +#define MA_PA_CHANNEL_POSITION_AUX2 14 +#define MA_PA_CHANNEL_POSITION_AUX3 15 +#define MA_PA_CHANNEL_POSITION_AUX4 16 +#define MA_PA_CHANNEL_POSITION_AUX5 17 +#define MA_PA_CHANNEL_POSITION_AUX6 18 +#define MA_PA_CHANNEL_POSITION_AUX7 19 +#define MA_PA_CHANNEL_POSITION_AUX8 20 +#define MA_PA_CHANNEL_POSITION_AUX9 21 +#define MA_PA_CHANNEL_POSITION_AUX10 22 +#define MA_PA_CHANNEL_POSITION_AUX11 23 +#define MA_PA_CHANNEL_POSITION_AUX12 24 +#define MA_PA_CHANNEL_POSITION_AUX13 25 +#define MA_PA_CHANNEL_POSITION_AUX14 26 +#define MA_PA_CHANNEL_POSITION_AUX15 27 +#define MA_PA_CHANNEL_POSITION_AUX16 28 +#define MA_PA_CHANNEL_POSITION_AUX17 29 +#define MA_PA_CHANNEL_POSITION_AUX18 30 +#define MA_PA_CHANNEL_POSITION_AUX19 31 +#define MA_PA_CHANNEL_POSITION_AUX20 32 +#define MA_PA_CHANNEL_POSITION_AUX21 33 +#define MA_PA_CHANNEL_POSITION_AUX22 34 +#define MA_PA_CHANNEL_POSITION_AUX23 35 +#define MA_PA_CHANNEL_POSITION_AUX24 36 +#define MA_PA_CHANNEL_POSITION_AUX25 37 +#define MA_PA_CHANNEL_POSITION_AUX26 38 +#define MA_PA_CHANNEL_POSITION_AUX27 39 +#define MA_PA_CHANNEL_POSITION_AUX28 40 +#define MA_PA_CHANNEL_POSITION_AUX29 41 +#define MA_PA_CHANNEL_POSITION_AUX30 42 +#define MA_PA_CHANNEL_POSITION_AUX31 43 +#define MA_PA_CHANNEL_POSITION_TOP_CENTER 44 +#define MA_PA_CHANNEL_POSITION_TOP_FRONT_LEFT 45 +#define MA_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT 46 +#define MA_PA_CHANNEL_POSITION_TOP_FRONT_CENTER 47 +#define MA_PA_CHANNEL_POSITION_TOP_REAR_LEFT 48 +#define MA_PA_CHANNEL_POSITION_TOP_REAR_RIGHT 49 +#define MA_PA_CHANNEL_POSITION_TOP_REAR_CENTER 50 +#define MA_PA_CHANNEL_POSITION_LEFT MA_PA_CHANNEL_POSITION_FRONT_LEFT +#define MA_PA_CHANNEL_POSITION_RIGHT MA_PA_CHANNEL_POSITION_FRONT_RIGHT +#define MA_PA_CHANNEL_POSITION_CENTER MA_PA_CHANNEL_POSITION_FRONT_CENTER +#define MA_PA_CHANNEL_POSITION_SUBWOOFER MA_PA_CHANNEL_POSITION_LFE typedef int mal_pa_channel_map_def_t; -#define MAL_PA_CHANNEL_MAP_AIFF 0 -#define MAL_PA_CHANNEL_MAP_ALSA 1 -#define MAL_PA_CHANNEL_MAP_AUX 2 -#define MAL_PA_CHANNEL_MAP_WAVEEX 3 -#define MAL_PA_CHANNEL_MAP_OSS 4 -#define MAL_PA_CHANNEL_MAP_DEFAULT MAL_PA_CHANNEL_MAP_AIFF +#define MA_PA_CHANNEL_MAP_AIFF 0 +#define MA_PA_CHANNEL_MAP_ALSA 1 +#define MA_PA_CHANNEL_MAP_AUX 2 +#define MA_PA_CHANNEL_MAP_WAVEEX 3 +#define MA_PA_CHANNEL_MAP_OSS 4 +#define MA_PA_CHANNEL_MAP_DEFAULT MA_PA_CHANNEL_MAP_AIFF typedef int mal_pa_sample_format_t; -#define MAL_PA_SAMPLE_INVALID -1 -#define MAL_PA_SAMPLE_U8 0 -#define MAL_PA_SAMPLE_ALAW 1 -#define MAL_PA_SAMPLE_ULAW 2 -#define MAL_PA_SAMPLE_S16LE 3 -#define MAL_PA_SAMPLE_S16BE 4 -#define MAL_PA_SAMPLE_FLOAT32LE 5 -#define MAL_PA_SAMPLE_FLOAT32BE 6 -#define MAL_PA_SAMPLE_S32LE 7 -#define MAL_PA_SAMPLE_S32BE 8 -#define MAL_PA_SAMPLE_S24LE 9 -#define MAL_PA_SAMPLE_S24BE 10 -#define MAL_PA_SAMPLE_S24_32LE 11 -#define MAL_PA_SAMPLE_S24_32BE 12 +#define MA_PA_SAMPLE_INVALID -1 +#define MA_PA_SAMPLE_U8 0 +#define MA_PA_SAMPLE_ALAW 1 +#define MA_PA_SAMPLE_ULAW 2 +#define MA_PA_SAMPLE_S16LE 3 +#define MA_PA_SAMPLE_S16BE 4 +#define MA_PA_SAMPLE_FLOAT32LE 5 +#define MA_PA_SAMPLE_FLOAT32BE 6 +#define MA_PA_SAMPLE_S32LE 7 +#define MA_PA_SAMPLE_S32BE 8 +#define MA_PA_SAMPLE_S24LE 9 +#define MA_PA_SAMPLE_S24BE 10 +#define MA_PA_SAMPLE_S24_32LE 11 +#define MA_PA_SAMPLE_S24_32BE 12 typedef struct mal_pa_mainloop mal_pa_mainloop; typedef struct mal_pa_mainloop_api mal_pa_mainloop_api; @@ -13444,13 +13444,13 @@ typedef struct typedef struct { mal_uint8 channels; - mal_pa_channel_position_t map[MAL_PA_CHANNELS_MAX]; + mal_pa_channel_position_t map[MA_PA_CHANNELS_MAX]; } mal_pa_channel_map; typedef struct { mal_uint8 channels; - mal_uint32 values[MAL_PA_CHANNELS_MAX]; + mal_uint32 values[MA_PA_CHANNELS_MAX]; } mal_pa_cvolume; typedef struct @@ -13580,11 +13580,11 @@ typedef struct mal_result mal_result_from_pulse(int result) { switch (result) { - case MAL_PA_OK: return MAL_SUCCESS; - case MAL_PA_ERR_ACCESS: return MAL_ACCESS_DENIED; - case MAL_PA_ERR_INVALID: return MAL_INVALID_ARGS; - case MAL_PA_ERR_NOENTITY: return MAL_NO_DEVICE; - default: return MAL_ERROR; + case MA_PA_OK: return MA_SUCCESS; + case MA_PA_ERR_ACCESS: return MA_ACCESS_DENIED; + case MA_PA_ERR_INVALID: return MA_INVALID_ARGS; + case MA_PA_ERR_NOENTITY: return MA_NO_DEVICE; + default: return MA_ERROR; } } @@ -13593,26 +13593,26 @@ mal_pa_sample_format_t mal_format_to_pulse(mal_format format) { if (mal_is_little_endian()) { switch (format) { - case mal_format_s16: return MAL_PA_SAMPLE_S16LE; - case mal_format_s24: return MAL_PA_SAMPLE_S24LE; - case mal_format_s32: return MAL_PA_SAMPLE_S32LE; - case mal_format_f32: return MAL_PA_SAMPLE_FLOAT32LE; + case mal_format_s16: return MA_PA_SAMPLE_S16LE; + case mal_format_s24: return MA_PA_SAMPLE_S24LE; + case mal_format_s32: return MA_PA_SAMPLE_S32LE; + case mal_format_f32: return MA_PA_SAMPLE_FLOAT32LE; default: break; } } else { switch (format) { - case mal_format_s16: return MAL_PA_SAMPLE_S16BE; - case mal_format_s24: return MAL_PA_SAMPLE_S24BE; - case mal_format_s32: return MAL_PA_SAMPLE_S32BE; - case mal_format_f32: return MAL_PA_SAMPLE_FLOAT32BE; + case mal_format_s16: return MA_PA_SAMPLE_S16BE; + case mal_format_s24: return MA_PA_SAMPLE_S24BE; + case mal_format_s32: return MA_PA_SAMPLE_S32BE; + case mal_format_f32: return MA_PA_SAMPLE_FLOAT32BE; default: break; } } // Endian agnostic. switch (format) { - case mal_format_u8: return MAL_PA_SAMPLE_U8; - default: return MAL_PA_SAMPLE_INVALID; + case mal_format_u8: return MA_PA_SAMPLE_U8; + default: return MA_PA_SAMPLE_INVALID; } } #endif @@ -13621,25 +13621,25 @@ mal_format mal_format_from_pulse(mal_pa_sample_format_t format) { if (mal_is_little_endian()) { switch (format) { - case MAL_PA_SAMPLE_S16LE: return mal_format_s16; - case MAL_PA_SAMPLE_S24LE: return mal_format_s24; - case MAL_PA_SAMPLE_S32LE: return mal_format_s32; - case MAL_PA_SAMPLE_FLOAT32LE: return mal_format_f32; + case MA_PA_SAMPLE_S16LE: return mal_format_s16; + case MA_PA_SAMPLE_S24LE: return mal_format_s24; + case MA_PA_SAMPLE_S32LE: return mal_format_s32; + case MA_PA_SAMPLE_FLOAT32LE: return mal_format_f32; default: break; } } else { switch (format) { - case MAL_PA_SAMPLE_S16BE: return mal_format_s16; - case MAL_PA_SAMPLE_S24BE: return mal_format_s24; - case MAL_PA_SAMPLE_S32BE: return mal_format_s32; - case MAL_PA_SAMPLE_FLOAT32BE: return mal_format_f32; + case MA_PA_SAMPLE_S16BE: return mal_format_s16; + case MA_PA_SAMPLE_S24BE: return mal_format_s24; + case MA_PA_SAMPLE_S32BE: return mal_format_s32; + case MA_PA_SAMPLE_FLOAT32BE: return mal_format_f32; default: break; } } // Endian agnostic. switch (format) { - case MAL_PA_SAMPLE_U8: return mal_format_u8; + case MA_PA_SAMPLE_U8: return mal_format_u8; default: return mal_format_unknown; } } @@ -13648,59 +13648,59 @@ mal_channel mal_channel_position_from_pulse(mal_pa_channel_position_t position) { switch (position) { - case MAL_PA_CHANNEL_POSITION_INVALID: return MAL_CHANNEL_NONE; - case MAL_PA_CHANNEL_POSITION_MONO: return MAL_CHANNEL_MONO; - case MAL_PA_CHANNEL_POSITION_FRONT_LEFT: return MAL_CHANNEL_FRONT_LEFT; - case MAL_PA_CHANNEL_POSITION_FRONT_RIGHT: return MAL_CHANNEL_FRONT_RIGHT; - case MAL_PA_CHANNEL_POSITION_FRONT_CENTER: return MAL_CHANNEL_FRONT_CENTER; - case MAL_PA_CHANNEL_POSITION_REAR_CENTER: return MAL_CHANNEL_BACK_CENTER; - case MAL_PA_CHANNEL_POSITION_REAR_LEFT: return MAL_CHANNEL_BACK_LEFT; - case MAL_PA_CHANNEL_POSITION_REAR_RIGHT: return MAL_CHANNEL_BACK_RIGHT; - case MAL_PA_CHANNEL_POSITION_LFE: return MAL_CHANNEL_LFE; - case MAL_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER: return MAL_CHANNEL_FRONT_LEFT_CENTER; - case MAL_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER: return MAL_CHANNEL_FRONT_RIGHT_CENTER; - case MAL_PA_CHANNEL_POSITION_SIDE_LEFT: return MAL_CHANNEL_SIDE_LEFT; - case MAL_PA_CHANNEL_POSITION_SIDE_RIGHT: return MAL_CHANNEL_SIDE_RIGHT; - case MAL_PA_CHANNEL_POSITION_AUX0: return MAL_CHANNEL_AUX_0; - case MAL_PA_CHANNEL_POSITION_AUX1: return MAL_CHANNEL_AUX_1; - case MAL_PA_CHANNEL_POSITION_AUX2: return MAL_CHANNEL_AUX_2; - case MAL_PA_CHANNEL_POSITION_AUX3: return MAL_CHANNEL_AUX_3; - case MAL_PA_CHANNEL_POSITION_AUX4: return MAL_CHANNEL_AUX_4; - case MAL_PA_CHANNEL_POSITION_AUX5: return MAL_CHANNEL_AUX_5; - case MAL_PA_CHANNEL_POSITION_AUX6: return MAL_CHANNEL_AUX_6; - case MAL_PA_CHANNEL_POSITION_AUX7: return MAL_CHANNEL_AUX_7; - case MAL_PA_CHANNEL_POSITION_AUX8: return MAL_CHANNEL_AUX_8; - case MAL_PA_CHANNEL_POSITION_AUX9: return MAL_CHANNEL_AUX_9; - case MAL_PA_CHANNEL_POSITION_AUX10: return MAL_CHANNEL_AUX_10; - case MAL_PA_CHANNEL_POSITION_AUX11: return MAL_CHANNEL_AUX_11; - case MAL_PA_CHANNEL_POSITION_AUX12: return MAL_CHANNEL_AUX_12; - case MAL_PA_CHANNEL_POSITION_AUX13: return MAL_CHANNEL_AUX_13; - case MAL_PA_CHANNEL_POSITION_AUX14: return MAL_CHANNEL_AUX_14; - case MAL_PA_CHANNEL_POSITION_AUX15: return MAL_CHANNEL_AUX_15; - case MAL_PA_CHANNEL_POSITION_AUX16: return MAL_CHANNEL_AUX_16; - case MAL_PA_CHANNEL_POSITION_AUX17: return MAL_CHANNEL_AUX_17; - case MAL_PA_CHANNEL_POSITION_AUX18: return MAL_CHANNEL_AUX_18; - case MAL_PA_CHANNEL_POSITION_AUX19: return MAL_CHANNEL_AUX_19; - case MAL_PA_CHANNEL_POSITION_AUX20: return MAL_CHANNEL_AUX_20; - case MAL_PA_CHANNEL_POSITION_AUX21: return MAL_CHANNEL_AUX_21; - case MAL_PA_CHANNEL_POSITION_AUX22: return MAL_CHANNEL_AUX_22; - case MAL_PA_CHANNEL_POSITION_AUX23: return MAL_CHANNEL_AUX_23; - case MAL_PA_CHANNEL_POSITION_AUX24: return MAL_CHANNEL_AUX_24; - case MAL_PA_CHANNEL_POSITION_AUX25: return MAL_CHANNEL_AUX_25; - case MAL_PA_CHANNEL_POSITION_AUX26: return MAL_CHANNEL_AUX_26; - case MAL_PA_CHANNEL_POSITION_AUX27: return MAL_CHANNEL_AUX_27; - case MAL_PA_CHANNEL_POSITION_AUX28: return MAL_CHANNEL_AUX_28; - case MAL_PA_CHANNEL_POSITION_AUX29: return MAL_CHANNEL_AUX_29; - case MAL_PA_CHANNEL_POSITION_AUX30: return MAL_CHANNEL_AUX_30; - case MAL_PA_CHANNEL_POSITION_AUX31: return MAL_CHANNEL_AUX_31; - case MAL_PA_CHANNEL_POSITION_TOP_CENTER: return MAL_CHANNEL_TOP_CENTER; - case MAL_PA_CHANNEL_POSITION_TOP_FRONT_LEFT: return MAL_CHANNEL_TOP_FRONT_LEFT; - case MAL_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT: return MAL_CHANNEL_TOP_FRONT_RIGHT; - case MAL_PA_CHANNEL_POSITION_TOP_FRONT_CENTER: return MAL_CHANNEL_TOP_FRONT_CENTER; - case MAL_PA_CHANNEL_POSITION_TOP_REAR_LEFT: return MAL_CHANNEL_TOP_BACK_LEFT; - case MAL_PA_CHANNEL_POSITION_TOP_REAR_RIGHT: return MAL_CHANNEL_TOP_BACK_RIGHT; - case MAL_PA_CHANNEL_POSITION_TOP_REAR_CENTER: return MAL_CHANNEL_TOP_BACK_CENTER; - default: return MAL_CHANNEL_NONE; + case MA_PA_CHANNEL_POSITION_INVALID: return MA_CHANNEL_NONE; + case MA_PA_CHANNEL_POSITION_MONO: return MA_CHANNEL_MONO; + case MA_PA_CHANNEL_POSITION_FRONT_LEFT: return MA_CHANNEL_FRONT_LEFT; + case MA_PA_CHANNEL_POSITION_FRONT_RIGHT: return MA_CHANNEL_FRONT_RIGHT; + case MA_PA_CHANNEL_POSITION_FRONT_CENTER: return MA_CHANNEL_FRONT_CENTER; + case MA_PA_CHANNEL_POSITION_REAR_CENTER: return MA_CHANNEL_BACK_CENTER; + case MA_PA_CHANNEL_POSITION_REAR_LEFT: return MA_CHANNEL_BACK_LEFT; + case MA_PA_CHANNEL_POSITION_REAR_RIGHT: return MA_CHANNEL_BACK_RIGHT; + case MA_PA_CHANNEL_POSITION_LFE: return MA_CHANNEL_LFE; + case MA_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER: return MA_CHANNEL_FRONT_LEFT_CENTER; + case MA_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER: return MA_CHANNEL_FRONT_RIGHT_CENTER; + case MA_PA_CHANNEL_POSITION_SIDE_LEFT: return MA_CHANNEL_SIDE_LEFT; + case MA_PA_CHANNEL_POSITION_SIDE_RIGHT: return MA_CHANNEL_SIDE_RIGHT; + case MA_PA_CHANNEL_POSITION_AUX0: return MA_CHANNEL_AUX_0; + case MA_PA_CHANNEL_POSITION_AUX1: return MA_CHANNEL_AUX_1; + case MA_PA_CHANNEL_POSITION_AUX2: return MA_CHANNEL_AUX_2; + case MA_PA_CHANNEL_POSITION_AUX3: return MA_CHANNEL_AUX_3; + case MA_PA_CHANNEL_POSITION_AUX4: return MA_CHANNEL_AUX_4; + case MA_PA_CHANNEL_POSITION_AUX5: return MA_CHANNEL_AUX_5; + case MA_PA_CHANNEL_POSITION_AUX6: return MA_CHANNEL_AUX_6; + case MA_PA_CHANNEL_POSITION_AUX7: return MA_CHANNEL_AUX_7; + case MA_PA_CHANNEL_POSITION_AUX8: return MA_CHANNEL_AUX_8; + case MA_PA_CHANNEL_POSITION_AUX9: return MA_CHANNEL_AUX_9; + case MA_PA_CHANNEL_POSITION_AUX10: return MA_CHANNEL_AUX_10; + case MA_PA_CHANNEL_POSITION_AUX11: return MA_CHANNEL_AUX_11; + case MA_PA_CHANNEL_POSITION_AUX12: return MA_CHANNEL_AUX_12; + case MA_PA_CHANNEL_POSITION_AUX13: return MA_CHANNEL_AUX_13; + case MA_PA_CHANNEL_POSITION_AUX14: return MA_CHANNEL_AUX_14; + case MA_PA_CHANNEL_POSITION_AUX15: return MA_CHANNEL_AUX_15; + case MA_PA_CHANNEL_POSITION_AUX16: return MA_CHANNEL_AUX_16; + case MA_PA_CHANNEL_POSITION_AUX17: return MA_CHANNEL_AUX_17; + case MA_PA_CHANNEL_POSITION_AUX18: return MA_CHANNEL_AUX_18; + case MA_PA_CHANNEL_POSITION_AUX19: return MA_CHANNEL_AUX_19; + case MA_PA_CHANNEL_POSITION_AUX20: return MA_CHANNEL_AUX_20; + case MA_PA_CHANNEL_POSITION_AUX21: return MA_CHANNEL_AUX_21; + case MA_PA_CHANNEL_POSITION_AUX22: return MA_CHANNEL_AUX_22; + case MA_PA_CHANNEL_POSITION_AUX23: return MA_CHANNEL_AUX_23; + case MA_PA_CHANNEL_POSITION_AUX24: return MA_CHANNEL_AUX_24; + case MA_PA_CHANNEL_POSITION_AUX25: return MA_CHANNEL_AUX_25; + case MA_PA_CHANNEL_POSITION_AUX26: return MA_CHANNEL_AUX_26; + case MA_PA_CHANNEL_POSITION_AUX27: return MA_CHANNEL_AUX_27; + case MA_PA_CHANNEL_POSITION_AUX28: return MA_CHANNEL_AUX_28; + case MA_PA_CHANNEL_POSITION_AUX29: return MA_CHANNEL_AUX_29; + case MA_PA_CHANNEL_POSITION_AUX30: return MA_CHANNEL_AUX_30; + case MA_PA_CHANNEL_POSITION_AUX31: return MA_CHANNEL_AUX_31; + case MA_PA_CHANNEL_POSITION_TOP_CENTER: return MA_CHANNEL_TOP_CENTER; + case MA_PA_CHANNEL_POSITION_TOP_FRONT_LEFT: return MA_CHANNEL_TOP_FRONT_LEFT; + case MA_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT: return MA_CHANNEL_TOP_FRONT_RIGHT; + case MA_PA_CHANNEL_POSITION_TOP_FRONT_CENTER: return MA_CHANNEL_TOP_FRONT_CENTER; + case MA_PA_CHANNEL_POSITION_TOP_REAR_LEFT: return MA_CHANNEL_TOP_BACK_LEFT; + case MA_PA_CHANNEL_POSITION_TOP_REAR_RIGHT: return MA_CHANNEL_TOP_BACK_RIGHT; + case MA_PA_CHANNEL_POSITION_TOP_REAR_CENTER: return MA_CHANNEL_TOP_BACK_CENTER; + default: return MA_CHANNEL_NONE; } } @@ -13709,39 +13709,39 @@ mal_pa_channel_position_t mal_channel_position_to_pulse(mal_channel position) { switch (position) { - case MAL_CHANNEL_NONE: return MAL_PA_CHANNEL_POSITION_INVALID; - case MAL_CHANNEL_FRONT_LEFT: return MAL_PA_CHANNEL_POSITION_FRONT_LEFT; - case MAL_CHANNEL_FRONT_RIGHT: return MAL_PA_CHANNEL_POSITION_FRONT_RIGHT; - case MAL_CHANNEL_FRONT_CENTER: return MAL_PA_CHANNEL_POSITION_FRONT_CENTER; - case MAL_CHANNEL_LFE: return MAL_PA_CHANNEL_POSITION_LFE; - case MAL_CHANNEL_BACK_LEFT: return MAL_PA_CHANNEL_POSITION_REAR_LEFT; - case MAL_CHANNEL_BACK_RIGHT: return MAL_PA_CHANNEL_POSITION_REAR_RIGHT; - case MAL_CHANNEL_FRONT_LEFT_CENTER: return MAL_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER; - case MAL_CHANNEL_FRONT_RIGHT_CENTER: return MAL_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER; - case MAL_CHANNEL_BACK_CENTER: return MAL_PA_CHANNEL_POSITION_REAR_CENTER; - case MAL_CHANNEL_SIDE_LEFT: return MAL_PA_CHANNEL_POSITION_SIDE_LEFT; - case MAL_CHANNEL_SIDE_RIGHT: return MAL_PA_CHANNEL_POSITION_SIDE_RIGHT; - case MAL_CHANNEL_TOP_CENTER: return MAL_PA_CHANNEL_POSITION_TOP_CENTER; - case MAL_CHANNEL_TOP_FRONT_LEFT: return MAL_PA_CHANNEL_POSITION_TOP_FRONT_LEFT; - case MAL_CHANNEL_TOP_FRONT_CENTER: return MAL_PA_CHANNEL_POSITION_TOP_FRONT_CENTER; - case MAL_CHANNEL_TOP_FRONT_RIGHT: return MAL_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT; - case MAL_CHANNEL_TOP_BACK_LEFT: return MAL_PA_CHANNEL_POSITION_TOP_REAR_LEFT; - case MAL_CHANNEL_TOP_BACK_CENTER: return MAL_PA_CHANNEL_POSITION_TOP_REAR_CENTER; - case MAL_CHANNEL_TOP_BACK_RIGHT: return MAL_PA_CHANNEL_POSITION_TOP_REAR_RIGHT; - case MAL_CHANNEL_19: return MAL_PA_CHANNEL_POSITION_AUX18; - case MAL_CHANNEL_20: return MAL_PA_CHANNEL_POSITION_AUX19; - case MAL_CHANNEL_21: return MAL_PA_CHANNEL_POSITION_AUX20; - case MAL_CHANNEL_22: return MAL_PA_CHANNEL_POSITION_AUX21; - case MAL_CHANNEL_23: return MAL_PA_CHANNEL_POSITION_AUX22; - case MAL_CHANNEL_24: return MAL_PA_CHANNEL_POSITION_AUX23; - case MAL_CHANNEL_25: return MAL_PA_CHANNEL_POSITION_AUX24; - case MAL_CHANNEL_26: return MAL_PA_CHANNEL_POSITION_AUX25; - case MAL_CHANNEL_27: return MAL_PA_CHANNEL_POSITION_AUX26; - case MAL_CHANNEL_28: return MAL_PA_CHANNEL_POSITION_AUX27; - case MAL_CHANNEL_29: return MAL_PA_CHANNEL_POSITION_AUX28; - case MAL_CHANNEL_30: return MAL_PA_CHANNEL_POSITION_AUX29; - case MAL_CHANNEL_31: return MAL_PA_CHANNEL_POSITION_AUX30; - case MAL_CHANNEL_32: return MAL_PA_CHANNEL_POSITION_AUX31; + case MA_CHANNEL_NONE: return MA_PA_CHANNEL_POSITION_INVALID; + case MA_CHANNEL_FRONT_LEFT: return MA_PA_CHANNEL_POSITION_FRONT_LEFT; + case MA_CHANNEL_FRONT_RIGHT: return MA_PA_CHANNEL_POSITION_FRONT_RIGHT; + case MA_CHANNEL_FRONT_CENTER: return MA_PA_CHANNEL_POSITION_FRONT_CENTER; + case MA_CHANNEL_LFE: return MA_PA_CHANNEL_POSITION_LFE; + case MA_CHANNEL_BACK_LEFT: return MA_PA_CHANNEL_POSITION_REAR_LEFT; + case MA_CHANNEL_BACK_RIGHT: return MA_PA_CHANNEL_POSITION_REAR_RIGHT; + case MA_CHANNEL_FRONT_LEFT_CENTER: return MA_PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER; + case MA_CHANNEL_FRONT_RIGHT_CENTER: return MA_PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER; + case MA_CHANNEL_BACK_CENTER: return MA_PA_CHANNEL_POSITION_REAR_CENTER; + case MA_CHANNEL_SIDE_LEFT: return MA_PA_CHANNEL_POSITION_SIDE_LEFT; + case MA_CHANNEL_SIDE_RIGHT: return MA_PA_CHANNEL_POSITION_SIDE_RIGHT; + case MA_CHANNEL_TOP_CENTER: return MA_PA_CHANNEL_POSITION_TOP_CENTER; + case MA_CHANNEL_TOP_FRONT_LEFT: return MA_PA_CHANNEL_POSITION_TOP_FRONT_LEFT; + case MA_CHANNEL_TOP_FRONT_CENTER: return MA_PA_CHANNEL_POSITION_TOP_FRONT_CENTER; + case MA_CHANNEL_TOP_FRONT_RIGHT: return MA_PA_CHANNEL_POSITION_TOP_FRONT_RIGHT; + case MA_CHANNEL_TOP_BACK_LEFT: return MA_PA_CHANNEL_POSITION_TOP_REAR_LEFT; + case MA_CHANNEL_TOP_BACK_CENTER: return MA_PA_CHANNEL_POSITION_TOP_REAR_CENTER; + case MA_CHANNEL_TOP_BACK_RIGHT: return MA_PA_CHANNEL_POSITION_TOP_REAR_RIGHT; + case MA_CHANNEL_19: return MA_PA_CHANNEL_POSITION_AUX18; + case MA_CHANNEL_20: return MA_PA_CHANNEL_POSITION_AUX19; + case MA_CHANNEL_21: return MA_PA_CHANNEL_POSITION_AUX20; + case MA_CHANNEL_22: return MA_PA_CHANNEL_POSITION_AUX21; + case MA_CHANNEL_23: return MA_PA_CHANNEL_POSITION_AUX22; + case MA_CHANNEL_24: return MA_PA_CHANNEL_POSITION_AUX23; + case MA_CHANNEL_25: return MA_PA_CHANNEL_POSITION_AUX24; + case MA_CHANNEL_26: return MA_PA_CHANNEL_POSITION_AUX25; + case MA_CHANNEL_27: return MA_PA_CHANNEL_POSITION_AUX26; + case MA_CHANNEL_28: return MA_PA_CHANNEL_POSITION_AUX27; + case MA_CHANNEL_29: return MA_PA_CHANNEL_POSITION_AUX28; + case MA_CHANNEL_30: return MA_PA_CHANNEL_POSITION_AUX29; + case MA_CHANNEL_31: return MA_PA_CHANNEL_POSITION_AUX30; + case MA_CHANNEL_32: return MA_PA_CHANNEL_POSITION_AUX31; default: return (mal_pa_channel_position_t)position; } } @@ -13753,14 +13753,14 @@ mal_result mal_wait_for_operation__pulse(mal_context* pContext, mal_pa_mainloop* mal_assert(pMainLoop != NULL); mal_assert(pOP != NULL); - while (((mal_pa_operation_get_state_proc)pContext->pulse.pa_operation_get_state)(pOP) == MAL_PA_OPERATION_RUNNING) { + while (((mal_pa_operation_get_state_proc)pContext->pulse.pa_operation_get_state)(pOP) == MA_PA_OPERATION_RUNNING) { int error = ((mal_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)(pMainLoop, 1, NULL); if (error < 0) { return mal_result_from_pulse(error); } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device__wait_for_operation__pulse(mal_device* pDevice, mal_pa_operation* pOP) @@ -13846,41 +13846,41 @@ mal_result mal_context_enumerate_devices__pulse(mal_context* pContext, mal_enum_ mal_assert(pContext != NULL); mal_assert(callback != NULL); - mal_result result = MAL_SUCCESS; + mal_result result = MA_SUCCESS; mal_context_enumerate_devices_callback_data__pulse callbackData; callbackData.pContext = pContext; callbackData.callback = callback; callbackData.pUserData = pUserData; - callbackData.isTerminated = MAL_FALSE; + callbackData.isTerminated = MA_FALSE; mal_pa_operation* pOP = NULL; mal_pa_mainloop* pMainLoop = ((mal_pa_mainloop_new_proc)pContext->pulse.pa_mainloop_new)(); if (pMainLoop == NULL) { - return MAL_FAILED_TO_INIT_BACKEND; + return MA_FAILED_TO_INIT_BACKEND; } mal_pa_mainloop_api* pAPI = ((mal_pa_mainloop_get_api_proc)pContext->pulse.pa_mainloop_get_api)(pMainLoop); if (pAPI == NULL) { ((mal_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)(pMainLoop); - return MAL_FAILED_TO_INIT_BACKEND; + return MA_FAILED_TO_INIT_BACKEND; } mal_pa_context* pPulseContext = ((mal_pa_context_new_proc)pContext->pulse.pa_context_new)(pAPI, pContext->config.pulse.pApplicationName); if (pPulseContext == NULL) { ((mal_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)(pMainLoop); - return MAL_FAILED_TO_INIT_BACKEND; + return MA_FAILED_TO_INIT_BACKEND; } int error = ((mal_pa_context_connect_proc)pContext->pulse.pa_context_connect)(pPulseContext, pContext->config.pulse.pServerName, 0, NULL); - if (error != MAL_PA_OK) { + if (error != MA_PA_OK) { ((mal_pa_context_unref_proc)pContext->pulse.pa_context_unref)(pPulseContext); ((mal_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)(pMainLoop); return mal_result_from_pulse(error); } - while (((mal_pa_context_get_state_proc)pContext->pulse.pa_context_get_state)(pPulseContext) != MAL_PA_CONTEXT_READY) { + while (((mal_pa_context_get_state_proc)pContext->pulse.pa_context_get_state)(pPulseContext) != MA_PA_CONTEXT_READY) { error = ((mal_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)(pMainLoop, 1, NULL); if (error < 0) { result = mal_result_from_pulse(error); @@ -13893,13 +13893,13 @@ mal_result mal_context_enumerate_devices__pulse(mal_context* pContext, mal_enum_ if (!callbackData.isTerminated) { pOP = ((mal_pa_context_get_sink_info_list_proc)pContext->pulse.pa_context_get_sink_info_list)(pPulseContext, mal_context_enumerate_devices_sink_callback__pulse, &callbackData); if (pOP == NULL) { - result = MAL_ERROR; + result = MA_ERROR; goto done; } result = mal_wait_for_operation__pulse(pContext, pMainLoop, pOP); ((mal_pa_operation_unref_proc)pContext->pulse.pa_operation_unref)(pOP); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { goto done; } } @@ -13909,13 +13909,13 @@ mal_result mal_context_enumerate_devices__pulse(mal_context* pContext, mal_enum_ if (!callbackData.isTerminated) { pOP = ((mal_pa_context_get_source_info_list_proc)pContext->pulse.pa_context_get_source_info_list)(pPulseContext, mal_context_enumerate_devices_source_callback__pulse, &callbackData); if (pOP == NULL) { - result = MAL_ERROR; + result = MA_ERROR; goto done; } result = mal_wait_for_operation__pulse(pContext, pMainLoop, pOP); ((mal_pa_operation_unref_proc)pContext->pulse.pa_operation_unref)(pOP); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { goto done; } } @@ -13942,7 +13942,7 @@ void mal_context_get_device_info_sink_callback__pulse(mal_pa_context* pPulseCont mal_context_get_device_info_callback_data__pulse* pData = (mal_context_get_device_info_callback_data__pulse*)pUserData; mal_assert(pData != NULL); - pData->foundDevice = MAL_TRUE; + pData->foundDevice = MA_TRUE; if (pInfo->name != NULL) { mal_strncpy_s(pData->pDeviceInfo->id.pulse, sizeof(pData->pDeviceInfo->id.pulse), pInfo->name, (size_t)-1); @@ -13968,7 +13968,7 @@ void mal_context_get_device_info_source_callback__pulse(mal_pa_context* pPulseCo mal_context_get_device_info_callback_data__pulse* pData = (mal_context_get_device_info_callback_data__pulse*)pUserData; mal_assert(pData != NULL); - pData->foundDevice = MAL_TRUE; + pData->foundDevice = MA_TRUE; if (pInfo->name != NULL) { mal_strncpy_s(pData->pDeviceInfo->id.pulse, sizeof(pData->pDeviceInfo->id.pulse), pInfo->name, (size_t)-1); @@ -13992,42 +13992,42 @@ mal_result mal_context_get_device_info__pulse(mal_context* pContext, mal_device_ /* No exclusive mode with the PulseAudio backend. */ if (shareMode == mal_share_mode_exclusive) { - return MAL_SHARE_MODE_NOT_SUPPORTED; + return MA_SHARE_MODE_NOT_SUPPORTED; } - mal_result result = MAL_SUCCESS; + mal_result result = MA_SUCCESS; mal_context_get_device_info_callback_data__pulse callbackData; callbackData.pDeviceInfo = pDeviceInfo; - callbackData.foundDevice = MAL_FALSE; + callbackData.foundDevice = MA_FALSE; mal_pa_operation* pOP = NULL; mal_pa_mainloop* pMainLoop = ((mal_pa_mainloop_new_proc)pContext->pulse.pa_mainloop_new)(); if (pMainLoop == NULL) { - return MAL_FAILED_TO_INIT_BACKEND; + return MA_FAILED_TO_INIT_BACKEND; } mal_pa_mainloop_api* pAPI = ((mal_pa_mainloop_get_api_proc)pContext->pulse.pa_mainloop_get_api)(pMainLoop); if (pAPI == NULL) { ((mal_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)(pMainLoop); - return MAL_FAILED_TO_INIT_BACKEND; + return MA_FAILED_TO_INIT_BACKEND; } mal_pa_context* pPulseContext = ((mal_pa_context_new_proc)pContext->pulse.pa_context_new)(pAPI, pContext->config.pulse.pApplicationName); if (pPulseContext == NULL) { ((mal_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)(pMainLoop); - return MAL_FAILED_TO_INIT_BACKEND; + return MA_FAILED_TO_INIT_BACKEND; } int error = ((mal_pa_context_connect_proc)pContext->pulse.pa_context_connect)(pPulseContext, pContext->config.pulse.pServerName, 0, NULL); - if (error != MAL_PA_OK) { + if (error != MA_PA_OK) { ((mal_pa_context_unref_proc)pContext->pulse.pa_context_unref)(pPulseContext); ((mal_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)(pMainLoop); return mal_result_from_pulse(error); } - while (((mal_pa_context_get_state_proc)pContext->pulse.pa_context_get_state)(pPulseContext) != MAL_PA_CONTEXT_READY) { + while (((mal_pa_context_get_state_proc)pContext->pulse.pa_context_get_state)(pPulseContext) != MA_PA_CONTEXT_READY) { error = ((mal_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)(pMainLoop, 1, NULL); if (error < 0) { result = mal_result_from_pulse(error); @@ -14045,12 +14045,12 @@ mal_result mal_context_get_device_info__pulse(mal_context* pContext, mal_device_ mal_wait_for_operation__pulse(pContext, pMainLoop, pOP); ((mal_pa_operation_unref_proc)pContext->pulse.pa_operation_unref)(pOP); } else { - result = MAL_ERROR; + result = MA_ERROR; goto done; } if (!callbackData.foundDevice) { - result = MAL_NO_DEVICE; + result = MA_NO_DEVICE; goto done; } @@ -14178,7 +14178,7 @@ mal_result mal_device_init__pulse(mal_context* pContext, const mal_device_config mal_assert(pDevice != NULL); mal_zero_object(&pDevice->pulse); - mal_result result = MAL_SUCCESS; + mal_result result = MA_SUCCESS; int error = 0; const char* devPlayback = NULL; const char* devCapture = NULL; @@ -14186,7 +14186,7 @@ mal_result mal_device_init__pulse(mal_context* pContext, const mal_device_config /* No exclusive mode with the PulseAudio backend. */ if (((pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) && pConfig->playback.shareMode == mal_share_mode_exclusive) || ((pConfig->deviceType == mal_device_type_capture || pConfig->deviceType == mal_device_type_duplex) && pConfig->capture.shareMode == mal_share_mode_exclusive)) { - return MAL_SHARE_MODE_NOT_SUPPORTED; + return MA_SHARE_MODE_NOT_SUPPORTED; } if ((pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) && pConfig->playback.pDeviceID != NULL) { @@ -14217,54 +14217,54 @@ mal_result mal_device_init__pulse(mal_context* pContext, const mal_device_config pDevice->pulse.pMainLoop = ((mal_pa_mainloop_new_proc)pContext->pulse.pa_mainloop_new)(); if (pDevice->pulse.pMainLoop == NULL) { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create main loop for device.", MAL_FAILED_TO_INIT_BACKEND); + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create main loop for device.", MA_FAILED_TO_INIT_BACKEND); goto on_error0; } pDevice->pulse.pAPI = ((mal_pa_mainloop_get_api_proc)pContext->pulse.pa_mainloop_get_api)((mal_pa_mainloop*)pDevice->pulse.pMainLoop); if (pDevice->pulse.pAPI == NULL) { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to retrieve PulseAudio main loop.", MAL_FAILED_TO_INIT_BACKEND); + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to retrieve PulseAudio main loop.", MA_FAILED_TO_INIT_BACKEND); goto on_error1; } pDevice->pulse.pPulseContext = ((mal_pa_context_new_proc)pContext->pulse.pa_context_new)((mal_pa_mainloop_api*)pDevice->pulse.pAPI, pContext->config.pulse.pApplicationName); if (pDevice->pulse.pPulseContext == NULL) { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio context for device.", MAL_FAILED_TO_INIT_BACKEND); + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio context for device.", MA_FAILED_TO_INIT_BACKEND); goto on_error1; } - error = ((mal_pa_context_connect_proc)pContext->pulse.pa_context_connect)((mal_pa_context*)pDevice->pulse.pPulseContext, pContext->config.pulse.pServerName, (pContext->config.pulse.tryAutoSpawn) ? 0 : MAL_PA_CONTEXT_NOAUTOSPAWN, NULL); - if (error != MAL_PA_OK) { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to connect PulseAudio context.", mal_result_from_pulse(error)); + error = ((mal_pa_context_connect_proc)pContext->pulse.pa_context_connect)((mal_pa_context*)pDevice->pulse.pPulseContext, pContext->config.pulse.pServerName, (pContext->config.pulse.tryAutoSpawn) ? 0 : MA_PA_CONTEXT_NOAUTOSPAWN, NULL); + if (error != MA_PA_OK) { + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to connect PulseAudio context.", mal_result_from_pulse(error)); goto on_error2; } - pDevice->pulse.pulseContextState = MAL_PA_CONTEXT_UNCONNECTED; + pDevice->pulse.pulseContextState = MA_PA_CONTEXT_UNCONNECTED; ((mal_pa_context_set_state_callback_proc)pContext->pulse.pa_context_set_state_callback)((mal_pa_context*)pDevice->pulse.pPulseContext, mal_pulse_device_state_callback, pDevice); // Wait for PulseAudio to get itself ready before returning. for (;;) { - if (pDevice->pulse.pulseContextState == MAL_PA_CONTEXT_READY) { + if (pDevice->pulse.pulseContextState == MA_PA_CONTEXT_READY) { break; } else { error = ((mal_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((mal_pa_mainloop*)pDevice->pulse.pMainLoop, 1, NULL); // 1 = block. if (error < 0) { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] The PulseAudio main loop returned an error while connecting the PulseAudio context.", mal_result_from_pulse(error)); + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] The PulseAudio main loop returned an error while connecting the PulseAudio context.", mal_result_from_pulse(error)); goto on_error3; } continue; } // An error may have occurred. - if (pDevice->pulse.pulseContextState == MAL_PA_CONTEXT_FAILED || pDevice->pulse.pulseContextState == MAL_PA_CONTEXT_TERMINATED) { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] An error occurred while connecting the PulseAudio context.", MAL_ERROR); + if (pDevice->pulse.pulseContextState == MA_PA_CONTEXT_FAILED || pDevice->pulse.pulseContextState == MA_PA_CONTEXT_TERMINATED) { + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] An error occurred while connecting the PulseAudio context.", MA_ERROR); goto on_error3; } error = ((mal_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((mal_pa_mainloop*)pDevice->pulse.pMainLoop, 1, NULL); if (error < 0) { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] The PulseAudio main loop returned an error while connecting the PulseAudio context.", mal_result_from_pulse(error)); + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] The PulseAudio main loop returned an error while connecting the PulseAudio context.", mal_result_from_pulse(error)); goto on_error3; } } @@ -14275,7 +14275,7 @@ mal_result mal_device_init__pulse(mal_context* pContext, const mal_device_config mal_device__wait_for_operation__pulse(pDevice, pOP); ((mal_pa_operation_unref_proc)pContext->pulse.pa_operation_unref)(pOP); } else { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to retrieve source info for capture device.", mal_result_from_pulse(error)); + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to retrieve source info for capture device.", mal_result_from_pulse(error)); goto on_error3; } @@ -14286,31 +14286,31 @@ mal_result mal_device_init__pulse(mal_context* pContext, const mal_device_config pDevice->capture.internalPeriods = pConfig->periods; attr = mal_device__pa_buffer_attr_new(pDevice->capture.internalBufferSizeInFrames, pConfig->periods, &ss); - #ifdef MAL_DEBUG_OUTPUT + #ifdef MA_DEBUG_OUTPUT printf("[PulseAudio] Capture attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; internalBufferSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDevice->capture.internalBufferSizeInFrames); #endif pDevice->pulse.pStreamCapture = mal_device__pa_stream_new__pulse(pDevice, pConfig->pulse.pStreamNameCapture, &ss, &cmap); if (pDevice->pulse.pStreamCapture == NULL) { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio capture stream.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio capture stream.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); goto on_error3; } - mal_pa_stream_flags_t streamFlags = MAL_PA_STREAM_START_CORKED | MAL_PA_STREAM_FIX_FORMAT | MAL_PA_STREAM_FIX_RATE | MAL_PA_STREAM_FIX_CHANNELS; + mal_pa_stream_flags_t streamFlags = MA_PA_STREAM_START_CORKED | MA_PA_STREAM_FIX_FORMAT | MA_PA_STREAM_FIX_RATE | MA_PA_STREAM_FIX_CHANNELS; if (devCapture != NULL) { - streamFlags |= MAL_PA_STREAM_DONT_MOVE; + streamFlags |= MA_PA_STREAM_DONT_MOVE; } error = ((mal_pa_stream_connect_record_proc)pContext->pulse.pa_stream_connect_record)((mal_pa_stream*)pDevice->pulse.pStreamCapture, devCapture, &attr, streamFlags); - if (error != MAL_PA_OK) { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to connect PulseAudio capture stream.", mal_result_from_pulse(error)); + if (error != MA_PA_OK) { + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to connect PulseAudio capture stream.", mal_result_from_pulse(error)); goto on_error4; } - while (((mal_pa_stream_get_state_proc)pContext->pulse.pa_stream_get_state)((mal_pa_stream*)pDevice->pulse.pStreamCapture) != MAL_PA_STREAM_READY) { + while (((mal_pa_stream_get_state_proc)pContext->pulse.pa_stream_get_state)((mal_pa_stream*)pDevice->pulse.pStreamCapture) != MA_PA_STREAM_READY) { error = ((mal_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((mal_pa_mainloop*)pDevice->pulse.pMainLoop, 1, NULL); if (error < 0) { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] The PulseAudio main loop returned an error while connecting the PulseAudio capture stream.", mal_result_from_pulse(error)); + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] The PulseAudio main loop returned an error while connecting the PulseAudio capture stream.", mal_result_from_pulse(error)); goto on_error5; } } @@ -14352,7 +14352,7 @@ mal_result mal_device_init__pulse(mal_context* pContext, const mal_device_config } pDevice->capture.internalBufferSizeInFrames = attr.maxlength / (mal_get_bytes_per_sample(pDevice->capture.internalFormat) * pDevice->capture.internalChannels); pDevice->capture.internalPeriods = attr.maxlength / attr.fragsize; - #ifdef MAL_DEBUG_OUTPUT + #ifdef MA_DEBUG_OUTPUT printf("[PulseAudio] Capture actual attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; internalBufferSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDevice->capture.internalBufferSizeInFrames); #endif @@ -14373,7 +14373,7 @@ mal_result mal_device_init__pulse(mal_context* pContext, const mal_device_config mal_device__wait_for_operation__pulse(pDevice, pOP); ((mal_pa_operation_unref_proc)pContext->pulse.pa_operation_unref)(pOP); } else { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to retrieve sink info for playback device.", mal_result_from_pulse(error)); + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to retrieve sink info for playback device.", mal_result_from_pulse(error)); goto on_error3; } @@ -14384,31 +14384,31 @@ mal_result mal_device_init__pulse(mal_context* pContext, const mal_device_config pDevice->playback.internalPeriods = pConfig->periods; attr = mal_device__pa_buffer_attr_new(pDevice->playback.internalBufferSizeInFrames, pConfig->periods, &ss); - #ifdef MAL_DEBUG_OUTPUT + #ifdef MA_DEBUG_OUTPUT printf("[PulseAudio] Playback attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; internalBufferSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDevice->playback.internalBufferSizeInFrames); #endif pDevice->pulse.pStreamPlayback = mal_device__pa_stream_new__pulse(pDevice, pConfig->pulse.pStreamNamePlayback, &ss, &cmap); if (pDevice->pulse.pStreamPlayback == NULL) { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio playback stream.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to create PulseAudio playback stream.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); goto on_error3; } - mal_pa_stream_flags_t streamFlags = MAL_PA_STREAM_START_CORKED | MAL_PA_STREAM_FIX_FORMAT | MAL_PA_STREAM_FIX_RATE | MAL_PA_STREAM_FIX_CHANNELS; + mal_pa_stream_flags_t streamFlags = MA_PA_STREAM_START_CORKED | MA_PA_STREAM_FIX_FORMAT | MA_PA_STREAM_FIX_RATE | MA_PA_STREAM_FIX_CHANNELS; if (devPlayback != NULL) { - streamFlags |= MAL_PA_STREAM_DONT_MOVE; + streamFlags |= MA_PA_STREAM_DONT_MOVE; } error = ((mal_pa_stream_connect_playback_proc)pContext->pulse.pa_stream_connect_playback)((mal_pa_stream*)pDevice->pulse.pStreamPlayback, devPlayback, &attr, streamFlags, NULL, NULL); - if (error != MAL_PA_OK) { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to connect PulseAudio playback stream.", mal_result_from_pulse(error)); + if (error != MA_PA_OK) { + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to connect PulseAudio playback stream.", mal_result_from_pulse(error)); goto on_error6; } - while (((mal_pa_stream_get_state_proc)pContext->pulse.pa_stream_get_state)((mal_pa_stream*)pDevice->pulse.pStreamPlayback) != MAL_PA_STREAM_READY) { + while (((mal_pa_stream_get_state_proc)pContext->pulse.pa_stream_get_state)((mal_pa_stream*)pDevice->pulse.pStreamPlayback) != MA_PA_STREAM_READY) { error = ((mal_pa_mainloop_iterate_proc)pContext->pulse.pa_mainloop_iterate)((mal_pa_mainloop*)pDevice->pulse.pMainLoop, 1, NULL); if (error < 0) { - result = mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] The PulseAudio main loop returned an error while connecting the PulseAudio playback stream.", mal_result_from_pulse(error)); + result = mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] The PulseAudio main loop returned an error while connecting the PulseAudio playback stream.", mal_result_from_pulse(error)); goto on_error7; } } @@ -14450,7 +14450,7 @@ mal_result mal_device_init__pulse(mal_context* pContext, const mal_device_config } pDevice->playback.internalBufferSizeInFrames = attr.maxlength / (mal_get_bytes_per_sample(pDevice->playback.internalFormat) * pDevice->playback.internalChannels); pDevice->playback.internalPeriods = /*pConfig->periods;*/attr.maxlength / attr.tlength; - #ifdef MAL_DEBUG_OUTPUT + #ifdef MA_DEBUG_OUTPUT printf("[PulseAudio] Playback actual attr: maxlength=%d, tlength=%d, prebuf=%d, minreq=%d, fragsize=%d; internalBufferSizeInFrames=%d\n", attr.maxlength, attr.tlength, attr.prebuf, attr.minreq, attr.fragsize, pDevice->playback.internalBufferSizeInFrames); #endif @@ -14465,7 +14465,7 @@ mal_result mal_device_init__pulse(mal_context* pContext, const mal_device_config } } - return MAL_SUCCESS; + return MA_SUCCESS; on_error7: @@ -14507,35 +14507,35 @@ mal_result mal_device__cork_stream__pulse(mal_device* pDevice, mal_device_type d /* This should not be called with a duplex device type. */ if (deviceType == mal_device_type_duplex) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } - mal_bool32 wasSuccessful = MAL_FALSE; + mal_bool32 wasSuccessful = MA_FALSE; mal_pa_stream* pStream = (mal_pa_stream*)((deviceType == mal_device_type_capture) ? pDevice->pulse.pStreamCapture : pDevice->pulse.pStreamPlayback); mal_assert(pStream != NULL); mal_pa_operation* pOP = ((mal_pa_stream_cork_proc)pContext->pulse.pa_stream_cork)(pStream, cork, mal_pulse_operation_complete_callback, &wasSuccessful); if (pOP == NULL) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to cork PulseAudio stream.", (cork == 0) ? MAL_FAILED_TO_START_BACKEND_DEVICE : MAL_FAILED_TO_STOP_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to cork PulseAudio stream.", (cork == 0) ? MA_FAILED_TO_START_BACKEND_DEVICE : MA_FAILED_TO_STOP_BACKEND_DEVICE); } mal_result result = mal_device__wait_for_operation__pulse(pDevice, pOP); ((mal_pa_operation_unref_proc)pContext->pulse.pa_operation_unref)(pOP); - if (result != MAL_SUCCESS) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] An error occurred while waiting for the PulseAudio stream to cork.", result); + if (result != MA_SUCCESS) { + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] An error occurred while waiting for the PulseAudio stream to cork.", result); } if (!wasSuccessful) { if (cork) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to stop PulseAudio stream.", MAL_FAILED_TO_STOP_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to stop PulseAudio stream.", MA_FAILED_TO_STOP_BACKEND_DEVICE); } else { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to start PulseAudio stream.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to start PulseAudio stream.", MA_FAILED_TO_START_BACKEND_DEVICE); } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_stop__pulse(mal_device* pDevice) @@ -14548,7 +14548,7 @@ mal_result mal_device_stop__pulse(mal_device* pDevice) if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { result = mal_device__cork_stream__pulse(pDevice, mal_device_type_capture, 1); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } @@ -14562,12 +14562,12 @@ mal_result mal_device_stop__pulse(mal_device* pDevice) } result = mal_device__cork_stream__pulse(pDevice, mal_device_type_playback, 1); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_write__pulse(mal_device* pDevice, const void* pPCMFrames, mal_uint32 frameCount) @@ -14579,7 +14579,7 @@ mal_result mal_device_write__pulse(mal_device* pDevice, const void* pPCMFrames, /* The stream needs to be uncorked first. */ if (((mal_pa_stream_is_corked_proc)pDevice->pContext->pulse.pa_stream_is_corked)(pDevice->pulse.pStreamPlayback)) { mal_result result = mal_device__cork_stream__pulse(pDevice, mal_device_type_playback, 0); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } @@ -14612,9 +14612,9 @@ mal_result mal_device_write__pulse(mal_device* pDevice, const void* pPCMFrames, size_t nbytes = pDevice->pulse.mappedBufferFramesCapacityPlayback * mal_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); //printf("TRACE: Submitting data. %d\n", nbytes); - int error = ((mal_pa_stream_write_proc)pDevice->pContext->pulse.pa_stream_write)((mal_pa_stream*)pDevice->pulse.pStreamPlayback, pDevice->pulse.pMappedBufferPlayback, nbytes, NULL, 0, MAL_PA_SEEK_RELATIVE); + int error = ((mal_pa_stream_write_proc)pDevice->pContext->pulse.pa_stream_write)((mal_pa_stream*)pDevice->pulse.pStreamPlayback, pDevice->pulse.pMappedBufferPlayback, nbytes, NULL, 0, MA_PA_SEEK_RELATIVE); if (error < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to write data to the PulseAudio stream.", mal_result_from_pulse(error)); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to write data to the PulseAudio stream.", mal_result_from_pulse(error)); } pDevice->pulse.pMappedBufferPlayback = NULL; @@ -14646,7 +14646,7 @@ mal_result mal_device_write__pulse(mal_device* pDevice, const void* pPCMFrames, size_t bytesToMap = periodSizeInBytes; int error = ((mal_pa_stream_begin_write_proc)pDevice->pContext->pulse.pa_stream_begin_write)((mal_pa_stream*)pDevice->pulse.pStreamPlayback, &pDevice->pulse.pMappedBufferPlayback, &bytesToMap); if (error < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to map write buffer.", mal_result_from_pulse(error)); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to map write buffer.", mal_result_from_pulse(error)); } pDevice->pulse.mappedBufferFramesCapacityPlayback = bytesToMap / mal_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); @@ -14665,12 +14665,12 @@ mal_result mal_device_write__pulse(mal_device* pDevice, const void* pPCMFrames, continue; } } else { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to query the stream's writable size.", MAL_ERROR); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to query the stream's writable size.", MA_ERROR); } } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_read__pulse(mal_device* pDevice, void* pPCMFrames, mal_uint32 frameCount) @@ -14682,7 +14682,7 @@ mal_result mal_device_read__pulse(mal_device* pDevice, void* pPCMFrames, mal_uin /* The stream needs to be uncorked first. */ if (((mal_pa_stream_is_corked_proc)pDevice->pContext->pulse.pa_stream_is_corked)(pDevice->pulse.pStreamCapture)) { mal_result result = mal_device__cork_stream__pulse(pDevice, mal_device_type_capture, 0); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } @@ -14721,7 +14721,7 @@ mal_result mal_device_read__pulse(mal_device* pDevice, void* pPCMFrames, mal_uin int error = ((mal_pa_stream_drop_proc)pDevice->pContext->pulse.pa_stream_drop)((mal_pa_stream*)pDevice->pulse.pStreamCapture); if (error != 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to drop fragment.", mal_result_from_pulse(error)); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to drop fragment.", mal_result_from_pulse(error)); } pDevice->pulse.pMappedBufferCapture = NULL; @@ -14751,14 +14751,14 @@ mal_result mal_device_read__pulse(mal_device* pDevice, void* pPCMFrames, mal_uin size_t bytesMapped = (size_t)-1; int error = ((mal_pa_stream_peek_proc)pDevice->pContext->pulse.pa_stream_peek)((mal_pa_stream*)pDevice->pulse.pStreamCapture, &pDevice->pulse.pMappedBufferCapture, &bytesMapped); if (error < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to peek capture buffer.", mal_result_from_pulse(error)); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to peek capture buffer.", mal_result_from_pulse(error)); } //printf("TRACE: Data available: bytesMapped=%d, readableSizeInBytes=%d, periodSizeInBytes=%d.\n", bytesMapped, readableSizeInBytes, periodSizeInBytes); if (pDevice->pulse.pMappedBufferCapture == NULL && bytesMapped == 0) { /* Nothing available. This shouldn't happen because we checked earlier with pa_stream_readable_size(). I'm going to throw an error in this case. */ - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Nothing available after peeking capture buffer.", MAL_ERROR); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Nothing available after peeking capture buffer.", MA_ERROR); } pDevice->pulse.mappedBufferFramesCapacityCapture = bytesMapped / mal_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); @@ -14777,12 +14777,12 @@ mal_result mal_device_read__pulse(mal_device* pDevice, void* pPCMFrames, mal_uin continue; } } else { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[PulseAudio] Failed to query the stream's readable size.", MAL_ERROR); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[PulseAudio] Failed to query the stream's readable size.", MA_ERROR); } } } - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -14791,18 +14791,18 @@ mal_result mal_context_uninit__pulse(mal_context* pContext) mal_assert(pContext != NULL); mal_assert(pContext->backend == mal_backend_pulseaudio); -#ifndef MAL_NO_RUNTIME_LINKING +#ifndef MA_NO_RUNTIME_LINKING mal_dlclose(pContext->pulse.pulseSO); #endif - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_init__pulse(mal_context* pContext) { mal_assert(pContext != NULL); -#ifndef MAL_NO_RUNTIME_LINKING +#ifndef MA_NO_RUNTIME_LINKING // libpulse.so const char* libpulseNames[] = { "libpulse.so", @@ -14817,7 +14817,7 @@ mal_result mal_context_init__pulse(mal_context* pContext) } if (pContext->pulse.pulseSO == NULL) { - return MAL_NO_BACKEND; + return MA_NO_BACKEND; } pContext->pulse.pa_mainloop_new = (mal_proc)mal_dlsym(pContext->pulse.pulseSO, "pa_mainloop_new"); @@ -14973,32 +14973,32 @@ mal_result mal_context_init__pulse(mal_context* pContext) // and connect a dummy PulseAudio context to test PulseAudio's usability. mal_pa_mainloop* pMainLoop = ((mal_pa_mainloop_new_proc)pContext->pulse.pa_mainloop_new)(); if (pMainLoop == NULL) { - return MAL_NO_BACKEND; + return MA_NO_BACKEND; } mal_pa_mainloop_api* pAPI = ((mal_pa_mainloop_get_api_proc)pContext->pulse.pa_mainloop_get_api)(pMainLoop); if (pAPI == NULL) { ((mal_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)(pMainLoop); - return MAL_NO_BACKEND; + return MA_NO_BACKEND; } mal_pa_context* pPulseContext = ((mal_pa_context_new_proc)pContext->pulse.pa_context_new)(pAPI, pContext->config.pulse.pApplicationName); if (pPulseContext == NULL) { ((mal_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)(pMainLoop); - return MAL_NO_BACKEND; + return MA_NO_BACKEND; } int error = ((mal_pa_context_connect_proc)pContext->pulse.pa_context_connect)(pPulseContext, pContext->config.pulse.pServerName, 0, NULL); - if (error != MAL_PA_OK) { + if (error != MA_PA_OK) { ((mal_pa_context_unref_proc)pContext->pulse.pa_context_unref)(pPulseContext); ((mal_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)(pMainLoop); - return MAL_NO_BACKEND; + return MA_NO_BACKEND; } ((mal_pa_context_disconnect_proc)pContext->pulse.pa_context_disconnect)(pPulseContext); ((mal_pa_context_unref_proc)pContext->pulse.pa_context_unref)(pPulseContext); ((mal_pa_mainloop_free_proc)pContext->pulse.pa_mainloop_free)(pMainLoop); - return MAL_SUCCESS; + return MA_SUCCESS; } #endif @@ -15008,10 +15008,10 @@ mal_result mal_context_init__pulse(mal_context* pContext) // JACK Backend // /////////////////////////////////////////////////////////////////////////////// -#ifdef MAL_HAS_JACK +#ifdef MA_HAS_JACK // It is assumed jack.h is available when compile-time linking is being used. -#ifdef MAL_NO_RUNTIME_LINKING +#ifdef MA_NO_RUNTIME_LINKING #include typedef jack_nframes_t mal_jack_nframes_t; @@ -15022,7 +15022,7 @@ typedef jack_port_t mal_jack_port_t; typedef JackProcessCallback mal_JackProcessCallback; typedef JackBufferSizeCallback mal_JackBufferSizeCallback; typedef JackShutdownCallback mal_JackShutdownCallback; -#define MAL_JACK_DEFAULT_AUDIO_TYPE JACK_DEFAULT_AUDIO_TYPE +#define MA_JACK_DEFAULT_AUDIO_TYPE JACK_DEFAULT_AUDIO_TYPE #define mal_JackNoStartServer JackNoStartServer #define mal_JackPortIsInput JackPortIsInput #define mal_JackPortIsOutput JackPortIsOutput @@ -15036,7 +15036,7 @@ typedef struct mal_jack_port_t mal_jack_port_t; typedef int (* mal_JackProcessCallback) (mal_jack_nframes_t nframes, void* arg); typedef int (* mal_JackBufferSizeCallback)(mal_jack_nframes_t nframes, void* arg); typedef void (* mal_JackShutdownCallback) (void* arg); -#define MAL_JACK_DEFAULT_AUDIO_TYPE "32 bit float mono audio" +#define MA_JACK_DEFAULT_AUDIO_TYPE "32 bit float mono audio" #define mal_JackNoStartServer 1 #define mal_JackPortIsInput 1 #define mal_JackPortIsOutput 2 @@ -15077,14 +15077,14 @@ mal_result mal_context_open_client__jack(mal_context* pContext, mal_jack_client_ mal_jack_status_t status; mal_jack_client_t* pClient = ((mal_jack_client_open_proc)pContext->jack.jack_client_open)(clientName, (pContext->config.jack.tryStartServer) ? 0 : mal_JackNoStartServer, &status, NULL); if (pClient == NULL) { - return MAL_FAILED_TO_OPEN_BACKEND_DEVICE; + return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } if (ppClient) { *ppClient = pClient; } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_bool32 mal_context_is_device_id_equal__jack(mal_context* pContext, const mal_device_id* pID0, const mal_device_id* pID1) @@ -15102,13 +15102,13 @@ mal_result mal_context_enumerate_devices__jack(mal_context* pContext, mal_enum_d mal_assert(pContext != NULL); mal_assert(callback != NULL); - mal_bool32 cbResult = MAL_TRUE; + mal_bool32 cbResult = MA_TRUE; // Playback. if (cbResult) { mal_device_info deviceInfo; mal_zero_object(&deviceInfo); - mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MAL_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); cbResult = callback(pContext, mal_device_type_playback, &deviceInfo, pUserData); } @@ -15116,11 +15116,11 @@ mal_result mal_context_enumerate_devices__jack(mal_context* pContext, mal_enum_d if (cbResult) { mal_device_info deviceInfo; mal_zero_object(&deviceInfo); - mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MAL_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); cbResult = callback(pContext, mal_device_type_capture, &deviceInfo, pUserData); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_get_device_info__jack(mal_context* pContext, mal_device_type deviceType, const mal_device_id* pDeviceID, mal_share_mode shareMode, mal_device_info* pDeviceInfo) @@ -15131,18 +15131,18 @@ mal_result mal_context_get_device_info__jack(mal_context* pContext, mal_device_t /* No exclusive mode with the JACK backend. */ if (shareMode == mal_share_mode_exclusive) { - return MAL_SHARE_MODE_NOT_SUPPORTED; + return MA_SHARE_MODE_NOT_SUPPORTED; } if (pDeviceID != NULL && pDeviceID->jack != 0) { - return MAL_NO_DEVICE; // Don't know the device. + return MA_NO_DEVICE; // Don't know the device. } // Name / Description if (deviceType == mal_device_type_playback) { - mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MAL_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { - mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MAL_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } // Jack only supports f32 and has a specific channel count and sample rate. @@ -15152,8 +15152,8 @@ mal_result mal_context_get_device_info__jack(mal_context* pContext, mal_device_t // The channel count and sample rate can only be determined by opening the device. mal_jack_client_t* pClient; mal_result result = mal_context_open_client__jack(pContext, &pClient); - if (result != MAL_SUCCESS) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[JACK] Failed to open client.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + if (result != MA_SUCCESS) { + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[JACK] Failed to open client.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } pDeviceInfo->minSampleRate = ((mal_jack_get_sample_rate_proc)pContext->jack.jack_get_sample_rate)((mal_jack_client_t*)pClient); @@ -15165,7 +15165,7 @@ mal_result mal_context_get_device_info__jack(mal_context* pContext, mal_device_t const char** ppPorts = ((mal_jack_get_ports_proc)pContext->jack.jack_get_ports)((mal_jack_client_t*)pClient, NULL, NULL, mal_JackPortIsPhysical | ((deviceType == mal_device_type_playback) ? mal_JackPortIsInput : mal_JackPortIsOutput)); if (ppPorts == NULL) { ((mal_jack_client_close_proc)pContext->jack.jack_client_close)((mal_jack_client_t*)pClient); - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } while (ppPorts[pDeviceInfo->minChannels] != NULL) { @@ -15176,7 +15176,7 @@ mal_result mal_context_get_device_info__jack(mal_context* pContext, mal_device_t ((mal_jack_free_proc)pContext->jack.jack_free)((void*)ppPorts); ((mal_jack_client_close_proc)pContext->jack.jack_client_close)((mal_jack_client_t*)pClient); - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -15221,7 +15221,7 @@ int mal_device__jack_buffer_size_callback(mal_jack_nframes_t frameCount, void* p if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { float* pNewBuffer = (float*)mal_realloc(pDevice->jack.pIntermediaryBufferCapture, frameCount * (pDevice->capture.internalChannels * mal_get_bytes_per_sample(pDevice->capture.internalFormat))); if (pNewBuffer == NULL) { - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } pDevice->jack.pIntermediaryBufferCapture = pNewBuffer; @@ -15231,7 +15231,7 @@ int mal_device__jack_buffer_size_callback(mal_jack_nframes_t frameCount, void* p if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) { float* pNewBuffer = (float*)mal_realloc(pDevice->jack.pIntermediaryBufferPlayback, frameCount * (pDevice->playback.internalChannels * mal_get_bytes_per_sample(pDevice->playback.internalFormat))); if (pNewBuffer == NULL) { - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } pDevice->jack.pIntermediaryBufferPlayback = pNewBuffer; @@ -15307,27 +15307,27 @@ mal_result mal_device_init__jack(mal_context* pContext, const mal_device_config* /* Only supporting default devices with JACK. */ if (((pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) && pConfig->playback.pDeviceID != NULL && pConfig->playback.pDeviceID->jack != 0) || ((pConfig->deviceType == mal_device_type_capture || pConfig->deviceType == mal_device_type_duplex) && pConfig->capture.pDeviceID != NULL && pConfig->capture.pDeviceID->jack != 0)) { - return MAL_NO_DEVICE; + return MA_NO_DEVICE; } /* No exclusive mode with the JACK backend. */ if (((pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) && pConfig->playback.shareMode == mal_share_mode_exclusive) || ((pConfig->deviceType == mal_device_type_capture || pConfig->deviceType == mal_device_type_duplex) && pConfig->capture.shareMode == mal_share_mode_exclusive)) { - return MAL_SHARE_MODE_NOT_SUPPORTED; + return MA_SHARE_MODE_NOT_SUPPORTED; } /* Open the client. */ mal_result result = mal_context_open_client__jack(pContext, (mal_jack_client_t**)&pDevice->jack.pClient); - if (result != MAL_SUCCESS) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[JACK] Failed to open client.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + if (result != MA_SUCCESS) { + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to open client.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } /* Callbacks. */ if (((mal_jack_set_process_callback_proc)pContext->jack.jack_set_process_callback)((mal_jack_client_t*)pDevice->jack.pClient, mal_device__jack_process_callback, pDevice) != 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[JACK] Failed to set process callback.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to set process callback.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } if (((mal_jack_set_buffer_size_callback_proc)pContext->jack.jack_set_buffer_size_callback)((mal_jack_client_t*)pDevice->jack.pClient, mal_device__jack_buffer_size_callback, pDevice) != 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[JACK] Failed to set buffer size callback.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to set buffer size callback.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } ((mal_jack_on_shutdown_proc)pContext->jack.jack_on_shutdown)((mal_jack_client_t*)pDevice->jack.pClient, mal_device__jack_shutdown_callback, pDevice); @@ -15347,7 +15347,7 @@ mal_result mal_device_init__jack(mal_context* pContext, const mal_device_config* ppPorts = ((mal_jack_get_ports_proc)pContext->jack.jack_get_ports)((mal_jack_client_t*)pDevice->jack.pClient, NULL, NULL, mal_JackPortIsPhysical | mal_JackPortIsOutput); if (ppPorts == NULL) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } while (ppPorts[pDevice->capture.internalChannels] != NULL) { @@ -15355,11 +15355,11 @@ mal_result mal_device_init__jack(mal_context* pContext, const mal_device_config* mal_strcpy_s(name, sizeof(name), "capture"); mal_itoa_s((int)pDevice->capture.internalChannels, name+7, sizeof(name)-7, 10); // 7 = length of "capture" - pDevice->jack.pPortsCapture[pDevice->capture.internalChannels] = ((mal_jack_port_register_proc)pContext->jack.jack_port_register)((mal_jack_client_t*)pDevice->jack.pClient, name, MAL_JACK_DEFAULT_AUDIO_TYPE, mal_JackPortIsInput, 0); + pDevice->jack.pPortsCapture[pDevice->capture.internalChannels] = ((mal_jack_port_register_proc)pContext->jack.jack_port_register)((mal_jack_client_t*)pDevice->jack.pClient, name, MA_JACK_DEFAULT_AUDIO_TYPE, mal_JackPortIsInput, 0); if (pDevice->jack.pPortsCapture[pDevice->capture.internalChannels] == NULL) { ((mal_jack_free_proc)pContext->jack.jack_free)((void*)ppPorts); mal_device_uninit__jack(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[JACK] Failed to register ports.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to register ports.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } pDevice->capture.internalChannels += 1; @@ -15373,7 +15373,7 @@ mal_result mal_device_init__jack(mal_context* pContext, const mal_device_config* pDevice->jack.pIntermediaryBufferCapture = (float*)mal_malloc((pDevice->capture.internalBufferSizeInFrames/pDevice->capture.internalPeriods) * (pDevice->capture.internalChannels * mal_get_bytes_per_sample(pDevice->capture.internalFormat))); if (pDevice->jack.pIntermediaryBufferCapture == NULL) { mal_device_uninit__jack(pDevice); - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } } @@ -15387,7 +15387,7 @@ mal_result mal_device_init__jack(mal_context* pContext, const mal_device_config* ppPorts = ((mal_jack_get_ports_proc)pContext->jack.jack_get_ports)((mal_jack_client_t*)pDevice->jack.pClient, NULL, NULL, mal_JackPortIsPhysical | mal_JackPortIsInput); if (ppPorts == NULL) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to query physical ports.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } while (ppPorts[pDevice->playback.internalChannels] != NULL) { @@ -15395,11 +15395,11 @@ mal_result mal_device_init__jack(mal_context* pContext, const mal_device_config* mal_strcpy_s(name, sizeof(name), "playback"); mal_itoa_s((int)pDevice->playback.internalChannels, name+8, sizeof(name)-8, 10); // 8 = length of "playback" - pDevice->jack.pPortsPlayback[pDevice->playback.internalChannels] = ((mal_jack_port_register_proc)pContext->jack.jack_port_register)((mal_jack_client_t*)pDevice->jack.pClient, name, MAL_JACK_DEFAULT_AUDIO_TYPE, mal_JackPortIsOutput, 0); + pDevice->jack.pPortsPlayback[pDevice->playback.internalChannels] = ((mal_jack_port_register_proc)pContext->jack.jack_port_register)((mal_jack_client_t*)pDevice->jack.pClient, name, MA_JACK_DEFAULT_AUDIO_TYPE, mal_JackPortIsOutput, 0); if (pDevice->jack.pPortsPlayback[pDevice->playback.internalChannels] == NULL) { ((mal_jack_free_proc)pContext->jack.jack_free)((void*)ppPorts); mal_device_uninit__jack(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[JACK] Failed to register ports.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to register ports.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } pDevice->playback.internalChannels += 1; @@ -15413,20 +15413,20 @@ mal_result mal_device_init__jack(mal_context* pContext, const mal_device_config* pDevice->jack.pIntermediaryBufferPlayback = (float*)mal_malloc((pDevice->playback.internalBufferSizeInFrames/pDevice->playback.internalPeriods) * (pDevice->playback.internalChannels * mal_get_bytes_per_sample(pDevice->playback.internalFormat))); if (pDevice->jack.pIntermediaryBufferPlayback == NULL) { mal_device_uninit__jack(pDevice); - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } } if (pDevice->type == mal_device_type_duplex) { mal_uint32 rbSizeInFrames = (mal_uint32)mal_calculate_frame_count_after_src(pDevice->sampleRate, pDevice->capture.internalSampleRate, pDevice->capture.internalBufferSizeInFrames); result = mal_pcm_rb_init(pDevice->capture.format, pDevice->capture.channels, rbSizeInFrames, NULL, &pDevice->jack.duplexRB); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { mal_device_uninit__jack(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[JACK] Failed to initialize ring buffer.", result); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to initialize ring buffer.", result); } } - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -15439,14 +15439,14 @@ mal_result mal_device_start__jack(mal_device* pDevice) int resultJACK = ((mal_jack_activate_proc)pContext->jack.jack_activate)((mal_jack_client_t*)pDevice->jack.pClient); if (resultJACK != 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[JACK] Failed to activate the JACK client.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to activate the JACK client.", MA_FAILED_TO_START_BACKEND_DEVICE); } if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { const char** ppServerPorts = ((mal_jack_get_ports_proc)pContext->jack.jack_get_ports)((mal_jack_client_t*)pDevice->jack.pClient, NULL, NULL, mal_JackPortIsPhysical | mal_JackPortIsOutput); if (ppServerPorts == NULL) { ((mal_jack_deactivate_proc)pContext->jack.jack_deactivate)((mal_jack_client_t*)pDevice->jack.pClient); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[JACK] Failed to retrieve physical ports.", MAL_ERROR); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to retrieve physical ports.", MA_ERROR); } for (size_t i = 0; ppServerPorts[i] != NULL; ++i) { @@ -15457,7 +15457,7 @@ mal_result mal_device_start__jack(mal_device* pDevice) if (resultJACK != 0) { ((mal_jack_free_proc)pContext->jack.jack_free)((void*)ppServerPorts); ((mal_jack_deactivate_proc)pContext->jack.jack_deactivate)((mal_jack_client_t*)pDevice->jack.pClient); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[JACK] Failed to connect ports.", MAL_ERROR); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to connect ports.", MA_ERROR); } } @@ -15468,7 +15468,7 @@ mal_result mal_device_start__jack(mal_device* pDevice) const char** ppServerPorts = ((mal_jack_get_ports_proc)pContext->jack.jack_get_ports)((mal_jack_client_t*)pDevice->jack.pClient, NULL, NULL, mal_JackPortIsPhysical | mal_JackPortIsInput); if (ppServerPorts == NULL) { ((mal_jack_deactivate_proc)pContext->jack.jack_deactivate)((mal_jack_client_t*)pDevice->jack.pClient); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[JACK] Failed to retrieve physical ports.", MAL_ERROR); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to retrieve physical ports.", MA_ERROR); } for (size_t i = 0; ppServerPorts[i] != NULL; ++i) { @@ -15479,14 +15479,14 @@ mal_result mal_device_start__jack(mal_device* pDevice) if (resultJACK != 0) { ((mal_jack_free_proc)pContext->jack.jack_free)((void*)ppServerPorts); ((mal_jack_deactivate_proc)pContext->jack.jack_deactivate)((mal_jack_client_t*)pDevice->jack.pClient); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[JACK] Failed to connect ports.", MAL_ERROR); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] Failed to connect ports.", MA_ERROR); } } ((mal_jack_free_proc)pContext->jack.jack_free)((void*)ppServerPorts); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_stop__jack(mal_device* pDevice) @@ -15497,7 +15497,7 @@ mal_result mal_device_stop__jack(mal_device* pDevice) mal_assert(pContext != NULL); if (((mal_jack_deactivate_proc)pContext->jack.jack_deactivate)((mal_jack_client_t*)pDevice->jack.pClient) != 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[JACK] An error occurred when deactivating the JACK client.", MAL_ERROR); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[JACK] An error occurred when deactivating the JACK client.", MA_ERROR); } mal_stop_proc onStop = pDevice->onStop; @@ -15505,7 +15505,7 @@ mal_result mal_device_stop__jack(mal_device* pDevice) onStop(pDevice); } - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -15514,21 +15514,21 @@ mal_result mal_context_uninit__jack(mal_context* pContext) mal_assert(pContext != NULL); mal_assert(pContext->backend == mal_backend_jack); -#ifndef MAL_NO_RUNTIME_LINKING +#ifndef MA_NO_RUNTIME_LINKING mal_dlclose(pContext->jack.jackSO); #endif - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_init__jack(mal_context* pContext) { mal_assert(pContext != NULL); -#ifndef MAL_NO_RUNTIME_LINKING +#ifndef MA_NO_RUNTIME_LINKING // libjack.so const char* libjackNames[] = { -#ifdef MAL_WIN32 +#ifdef MA_WIN32 "libjack.dll" #else "libjack.so", @@ -15544,7 +15544,7 @@ mal_result mal_context_init__jack(mal_context* pContext) } if (pContext->jack.jackSO == NULL) { - return MAL_NO_BACKEND; + return MA_NO_BACKEND; } pContext->jack.jack_client_open = (mal_proc)mal_dlsym(pContext->jack.jackSO, "jack_client_open"); @@ -15601,7 +15601,7 @@ mal_result mal_context_init__jack(mal_context* pContext) pContext->jack.jack_free = (mal_proc)_jack_free; #endif - pContext->isBackendAsynchronous = MAL_TRUE; + pContext->isBackendAsynchronous = MA_TRUE; pContext->onUninit = mal_context_uninit__jack; pContext->onDeviceIDEqual = mal_context_is_device_id_equal__jack; @@ -15617,12 +15617,12 @@ mal_result mal_context_init__jack(mal_context* pContext) // a temporary client. mal_jack_client_t* pDummyClient; mal_result result = mal_context_open_client__jack(pContext, &pDummyClient); - if (result != MAL_SUCCESS) { - return MAL_NO_BACKEND; + if (result != MA_SUCCESS) { + return MA_NO_BACKEND; } ((mal_jack_client_close_proc)pContext->jack.jack_client_close)((mal_jack_client_t*)pDummyClient); - return MAL_SUCCESS; + return MA_SUCCESS; } #endif // JACK @@ -15633,16 +15633,16 @@ mal_result mal_context_init__jack(mal_context* pContext) // Core Audio Backend // /////////////////////////////////////////////////////////////////////////////// -#ifdef MAL_HAS_COREAUDIO +#ifdef MA_HAS_COREAUDIO #include #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1 - #define MAL_APPLE_MOBILE + #define MA_APPLE_MOBILE #else - #define MAL_APPLE_DESKTOP + #define MA_APPLE_DESKTOP #endif -#if defined(MAL_APPLE_DESKTOP) +#if defined(MA_APPLE_DESKTOP) #include #else #include @@ -15654,7 +15654,7 @@ mal_result mal_context_init__jack(mal_context* pContext) typedef Boolean (* mal_CFStringGetCString_proc)(CFStringRef theString, char* buffer, CFIndex bufferSize, CFStringEncoding encoding); // CoreAudio -#if defined(MAL_APPLE_DESKTOP) +#if defined(MA_APPLE_DESKTOP) typedef OSStatus (* mal_AudioObjectGetPropertyData_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* ioDataSize, void* outData); typedef OSStatus (* mal_AudioObjectGetPropertyDataSize_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32* outDataSize); typedef OSStatus (* mal_AudioObjectSetPropertyData_proc)(AudioObjectID inObjectID, const AudioObjectPropertyAddress* inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData); @@ -15675,8 +15675,8 @@ typedef OSStatus (* mal_AudioUnitInitialize_proc)(AudioUnit inUnit); typedef OSStatus (* mal_AudioUnitRender_proc)(AudioUnit inUnit, AudioUnitRenderActionFlags* ioActionFlags, const AudioTimeStamp* inTimeStamp, UInt32 inOutputBusNumber, UInt32 inNumberFrames, AudioBufferList* ioData); -#define MAL_COREAUDIO_OUTPUT_BUS 0 -#define MAL_COREAUDIO_INPUT_BUS 1 +#define MA_COREAUDIO_OUTPUT_BUS 0 +#define MA_COREAUDIO_INPUT_BUS 1 mal_result mal_device_reinit_internal__coreaudio(mal_device* pDevice, mal_device_type deviceType, mal_bool32 disposePreviousAudioUnit); @@ -15716,21 +15716,21 @@ mal_result mal_result_from_OSStatus(OSStatus status) { switch (status) { - case noErr: return MAL_SUCCESS; - #if defined(MAL_APPLE_DESKTOP) - case kAudioHardwareNotRunningError: return MAL_DEVICE_NOT_STARTED; - case kAudioHardwareUnspecifiedError: return MAL_ERROR; - case kAudioHardwareUnknownPropertyError: return MAL_INVALID_ARGS; - case kAudioHardwareBadPropertySizeError: return MAL_INVALID_OPERATION; - case kAudioHardwareIllegalOperationError: return MAL_INVALID_OPERATION; - case kAudioHardwareBadObjectError: return MAL_INVALID_ARGS; - case kAudioHardwareBadDeviceError: return MAL_INVALID_ARGS; - case kAudioHardwareBadStreamError: return MAL_INVALID_ARGS; - case kAudioHardwareUnsupportedOperationError: return MAL_INVALID_OPERATION; - case kAudioDeviceUnsupportedFormatError: return MAL_FORMAT_NOT_SUPPORTED; - case kAudioDevicePermissionsError: return MAL_ACCESS_DENIED; + case noErr: return MA_SUCCESS; + #if defined(MA_APPLE_DESKTOP) + case kAudioHardwareNotRunningError: return MA_DEVICE_NOT_STARTED; + case kAudioHardwareUnspecifiedError: return MA_ERROR; + case kAudioHardwareUnknownPropertyError: return MA_INVALID_ARGS; + case kAudioHardwareBadPropertySizeError: return MA_INVALID_OPERATION; + case kAudioHardwareIllegalOperationError: return MA_INVALID_OPERATION; + case kAudioHardwareBadObjectError: return MA_INVALID_ARGS; + case kAudioHardwareBadDeviceError: return MA_INVALID_ARGS; + case kAudioHardwareBadStreamError: return MA_INVALID_ARGS; + case kAudioHardwareUnsupportedOperationError: return MA_INVALID_OPERATION; + case kAudioDeviceUnsupportedFormatError: return MA_FORMAT_NOT_SUPPORTED; + case kAudioDevicePermissionsError: return MA_ACCESS_DENIED; #endif - default: return MAL_ERROR; + default: return MA_ERROR; } } @@ -15739,25 +15739,25 @@ mal_channel mal_channel_from_AudioChannelBitmap(AudioChannelBitmap bit) { switch (bit) { - case kAudioChannelBit_Left: return MAL_CHANNEL_LEFT; - case kAudioChannelBit_Right: return MAL_CHANNEL_RIGHT; - case kAudioChannelBit_Center: return MAL_CHANNEL_FRONT_CENTER; - case kAudioChannelBit_LFEScreen: return MAL_CHANNEL_LFE; - case kAudioChannelBit_LeftSurround: return MAL_CHANNEL_BACK_LEFT; - case kAudioChannelBit_RightSurround: return MAL_CHANNEL_BACK_RIGHT; - case kAudioChannelBit_LeftCenter: return MAL_CHANNEL_FRONT_LEFT_CENTER; - case kAudioChannelBit_RightCenter: return MAL_CHANNEL_FRONT_RIGHT_CENTER; - case kAudioChannelBit_CenterSurround: return MAL_CHANNEL_BACK_CENTER; - case kAudioChannelBit_LeftSurroundDirect: return MAL_CHANNEL_SIDE_LEFT; - case kAudioChannelBit_RightSurroundDirect: return MAL_CHANNEL_SIDE_RIGHT; - case kAudioChannelBit_TopCenterSurround: return MAL_CHANNEL_TOP_CENTER; - case kAudioChannelBit_VerticalHeightLeft: return MAL_CHANNEL_TOP_FRONT_LEFT; - case kAudioChannelBit_VerticalHeightCenter: return MAL_CHANNEL_TOP_FRONT_CENTER; - case kAudioChannelBit_VerticalHeightRight: return MAL_CHANNEL_TOP_FRONT_RIGHT; - case kAudioChannelBit_TopBackLeft: return MAL_CHANNEL_TOP_BACK_LEFT; - case kAudioChannelBit_TopBackCenter: return MAL_CHANNEL_TOP_BACK_CENTER; - case kAudioChannelBit_TopBackRight: return MAL_CHANNEL_TOP_BACK_RIGHT; - default: return MAL_CHANNEL_NONE; + case kAudioChannelBit_Left: return MA_CHANNEL_LEFT; + case kAudioChannelBit_Right: return MA_CHANNEL_RIGHT; + case kAudioChannelBit_Center: return MA_CHANNEL_FRONT_CENTER; + case kAudioChannelBit_LFEScreen: return MA_CHANNEL_LFE; + case kAudioChannelBit_LeftSurround: return MA_CHANNEL_BACK_LEFT; + case kAudioChannelBit_RightSurround: return MA_CHANNEL_BACK_RIGHT; + case kAudioChannelBit_LeftCenter: return MA_CHANNEL_FRONT_LEFT_CENTER; + case kAudioChannelBit_RightCenter: return MA_CHANNEL_FRONT_RIGHT_CENTER; + case kAudioChannelBit_CenterSurround: return MA_CHANNEL_BACK_CENTER; + case kAudioChannelBit_LeftSurroundDirect: return MA_CHANNEL_SIDE_LEFT; + case kAudioChannelBit_RightSurroundDirect: return MA_CHANNEL_SIDE_RIGHT; + case kAudioChannelBit_TopCenterSurround: return MA_CHANNEL_TOP_CENTER; + case kAudioChannelBit_VerticalHeightLeft: return MA_CHANNEL_TOP_FRONT_LEFT; + case kAudioChannelBit_VerticalHeightCenter: return MA_CHANNEL_TOP_FRONT_CENTER; + case kAudioChannelBit_VerticalHeightRight: return MA_CHANNEL_TOP_FRONT_RIGHT; + case kAudioChannelBit_TopBackLeft: return MA_CHANNEL_TOP_BACK_LEFT; + case kAudioChannelBit_TopBackCenter: return MA_CHANNEL_TOP_BACK_CENTER; + case kAudioChannelBit_TopBackRight: return MA_CHANNEL_TOP_BACK_RIGHT; + default: return MA_CHANNEL_NONE; } } #endif @@ -15766,93 +15766,93 @@ mal_channel mal_channel_from_AudioChannelLabel(AudioChannelLabel label) { switch (label) { - case kAudioChannelLabel_Unknown: return MAL_CHANNEL_NONE; - case kAudioChannelLabel_Unused: return MAL_CHANNEL_NONE; - case kAudioChannelLabel_UseCoordinates: return MAL_CHANNEL_NONE; - case kAudioChannelLabel_Left: return MAL_CHANNEL_LEFT; - case kAudioChannelLabel_Right: return MAL_CHANNEL_RIGHT; - case kAudioChannelLabel_Center: return MAL_CHANNEL_FRONT_CENTER; - case kAudioChannelLabel_LFEScreen: return MAL_CHANNEL_LFE; - case kAudioChannelLabel_LeftSurround: return MAL_CHANNEL_BACK_LEFT; - case kAudioChannelLabel_RightSurround: return MAL_CHANNEL_BACK_RIGHT; - case kAudioChannelLabel_LeftCenter: return MAL_CHANNEL_FRONT_LEFT_CENTER; - case kAudioChannelLabel_RightCenter: return MAL_CHANNEL_FRONT_RIGHT_CENTER; - case kAudioChannelLabel_CenterSurround: return MAL_CHANNEL_BACK_CENTER; - case kAudioChannelLabel_LeftSurroundDirect: return MAL_CHANNEL_SIDE_LEFT; - case kAudioChannelLabel_RightSurroundDirect: return MAL_CHANNEL_SIDE_RIGHT; - case kAudioChannelLabel_TopCenterSurround: return MAL_CHANNEL_TOP_CENTER; - case kAudioChannelLabel_VerticalHeightLeft: return MAL_CHANNEL_TOP_FRONT_LEFT; - case kAudioChannelLabel_VerticalHeightCenter: return MAL_CHANNEL_TOP_FRONT_CENTER; - case kAudioChannelLabel_VerticalHeightRight: return MAL_CHANNEL_TOP_FRONT_RIGHT; - case kAudioChannelLabel_TopBackLeft: return MAL_CHANNEL_TOP_BACK_LEFT; - case kAudioChannelLabel_TopBackCenter: return MAL_CHANNEL_TOP_BACK_CENTER; - case kAudioChannelLabel_TopBackRight: return MAL_CHANNEL_TOP_BACK_RIGHT; - case kAudioChannelLabel_RearSurroundLeft: return MAL_CHANNEL_BACK_LEFT; - case kAudioChannelLabel_RearSurroundRight: return MAL_CHANNEL_BACK_RIGHT; - case kAudioChannelLabel_LeftWide: return MAL_CHANNEL_SIDE_LEFT; - case kAudioChannelLabel_RightWide: return MAL_CHANNEL_SIDE_RIGHT; - case kAudioChannelLabel_LFE2: return MAL_CHANNEL_LFE; - case kAudioChannelLabel_LeftTotal: return MAL_CHANNEL_LEFT; - case kAudioChannelLabel_RightTotal: return MAL_CHANNEL_RIGHT; - case kAudioChannelLabel_HearingImpaired: return MAL_CHANNEL_NONE; - case kAudioChannelLabel_Narration: return MAL_CHANNEL_MONO; - case kAudioChannelLabel_Mono: return MAL_CHANNEL_MONO; - case kAudioChannelLabel_DialogCentricMix: return MAL_CHANNEL_MONO; - case kAudioChannelLabel_CenterSurroundDirect: return MAL_CHANNEL_BACK_CENTER; - case kAudioChannelLabel_Haptic: return MAL_CHANNEL_NONE; - case kAudioChannelLabel_Ambisonic_W: return MAL_CHANNEL_NONE; - case kAudioChannelLabel_Ambisonic_X: return MAL_CHANNEL_NONE; - case kAudioChannelLabel_Ambisonic_Y: return MAL_CHANNEL_NONE; - case kAudioChannelLabel_Ambisonic_Z: return MAL_CHANNEL_NONE; - case kAudioChannelLabel_MS_Mid: return MAL_CHANNEL_LEFT; - case kAudioChannelLabel_MS_Side: return MAL_CHANNEL_RIGHT; - case kAudioChannelLabel_XY_X: return MAL_CHANNEL_LEFT; - case kAudioChannelLabel_XY_Y: return MAL_CHANNEL_RIGHT; - case kAudioChannelLabel_HeadphonesLeft: return MAL_CHANNEL_LEFT; - case kAudioChannelLabel_HeadphonesRight: return MAL_CHANNEL_RIGHT; - case kAudioChannelLabel_ClickTrack: return MAL_CHANNEL_NONE; - case kAudioChannelLabel_ForeignLanguage: return MAL_CHANNEL_NONE; - case kAudioChannelLabel_Discrete: return MAL_CHANNEL_NONE; - case kAudioChannelLabel_Discrete_0: return MAL_CHANNEL_AUX_0; - case kAudioChannelLabel_Discrete_1: return MAL_CHANNEL_AUX_1; - case kAudioChannelLabel_Discrete_2: return MAL_CHANNEL_AUX_2; - case kAudioChannelLabel_Discrete_3: return MAL_CHANNEL_AUX_3; - case kAudioChannelLabel_Discrete_4: return MAL_CHANNEL_AUX_4; - case kAudioChannelLabel_Discrete_5: return MAL_CHANNEL_AUX_5; - case kAudioChannelLabel_Discrete_6: return MAL_CHANNEL_AUX_6; - case kAudioChannelLabel_Discrete_7: return MAL_CHANNEL_AUX_7; - case kAudioChannelLabel_Discrete_8: return MAL_CHANNEL_AUX_8; - case kAudioChannelLabel_Discrete_9: return MAL_CHANNEL_AUX_9; - case kAudioChannelLabel_Discrete_10: return MAL_CHANNEL_AUX_10; - case kAudioChannelLabel_Discrete_11: return MAL_CHANNEL_AUX_11; - case kAudioChannelLabel_Discrete_12: return MAL_CHANNEL_AUX_12; - case kAudioChannelLabel_Discrete_13: return MAL_CHANNEL_AUX_13; - case kAudioChannelLabel_Discrete_14: return MAL_CHANNEL_AUX_14; - case kAudioChannelLabel_Discrete_15: return MAL_CHANNEL_AUX_15; - case kAudioChannelLabel_Discrete_65535: return MAL_CHANNEL_NONE; + case kAudioChannelLabel_Unknown: return MA_CHANNEL_NONE; + case kAudioChannelLabel_Unused: return MA_CHANNEL_NONE; + case kAudioChannelLabel_UseCoordinates: return MA_CHANNEL_NONE; + case kAudioChannelLabel_Left: return MA_CHANNEL_LEFT; + case kAudioChannelLabel_Right: return MA_CHANNEL_RIGHT; + case kAudioChannelLabel_Center: return MA_CHANNEL_FRONT_CENTER; + case kAudioChannelLabel_LFEScreen: return MA_CHANNEL_LFE; + case kAudioChannelLabel_LeftSurround: return MA_CHANNEL_BACK_LEFT; + case kAudioChannelLabel_RightSurround: return MA_CHANNEL_BACK_RIGHT; + case kAudioChannelLabel_LeftCenter: return MA_CHANNEL_FRONT_LEFT_CENTER; + case kAudioChannelLabel_RightCenter: return MA_CHANNEL_FRONT_RIGHT_CENTER; + case kAudioChannelLabel_CenterSurround: return MA_CHANNEL_BACK_CENTER; + case kAudioChannelLabel_LeftSurroundDirect: return MA_CHANNEL_SIDE_LEFT; + case kAudioChannelLabel_RightSurroundDirect: return MA_CHANNEL_SIDE_RIGHT; + case kAudioChannelLabel_TopCenterSurround: return MA_CHANNEL_TOP_CENTER; + case kAudioChannelLabel_VerticalHeightLeft: return MA_CHANNEL_TOP_FRONT_LEFT; + case kAudioChannelLabel_VerticalHeightCenter: return MA_CHANNEL_TOP_FRONT_CENTER; + case kAudioChannelLabel_VerticalHeightRight: return MA_CHANNEL_TOP_FRONT_RIGHT; + case kAudioChannelLabel_TopBackLeft: return MA_CHANNEL_TOP_BACK_LEFT; + case kAudioChannelLabel_TopBackCenter: return MA_CHANNEL_TOP_BACK_CENTER; + case kAudioChannelLabel_TopBackRight: return MA_CHANNEL_TOP_BACK_RIGHT; + case kAudioChannelLabel_RearSurroundLeft: return MA_CHANNEL_BACK_LEFT; + case kAudioChannelLabel_RearSurroundRight: return MA_CHANNEL_BACK_RIGHT; + case kAudioChannelLabel_LeftWide: return MA_CHANNEL_SIDE_LEFT; + case kAudioChannelLabel_RightWide: return MA_CHANNEL_SIDE_RIGHT; + case kAudioChannelLabel_LFE2: return MA_CHANNEL_LFE; + case kAudioChannelLabel_LeftTotal: return MA_CHANNEL_LEFT; + case kAudioChannelLabel_RightTotal: return MA_CHANNEL_RIGHT; + case kAudioChannelLabel_HearingImpaired: return MA_CHANNEL_NONE; + case kAudioChannelLabel_Narration: return MA_CHANNEL_MONO; + case kAudioChannelLabel_Mono: return MA_CHANNEL_MONO; + case kAudioChannelLabel_DialogCentricMix: return MA_CHANNEL_MONO; + case kAudioChannelLabel_CenterSurroundDirect: return MA_CHANNEL_BACK_CENTER; + case kAudioChannelLabel_Haptic: return MA_CHANNEL_NONE; + case kAudioChannelLabel_Ambisonic_W: return MA_CHANNEL_NONE; + case kAudioChannelLabel_Ambisonic_X: return MA_CHANNEL_NONE; + case kAudioChannelLabel_Ambisonic_Y: return MA_CHANNEL_NONE; + case kAudioChannelLabel_Ambisonic_Z: return MA_CHANNEL_NONE; + case kAudioChannelLabel_MS_Mid: return MA_CHANNEL_LEFT; + case kAudioChannelLabel_MS_Side: return MA_CHANNEL_RIGHT; + case kAudioChannelLabel_XY_X: return MA_CHANNEL_LEFT; + case kAudioChannelLabel_XY_Y: return MA_CHANNEL_RIGHT; + case kAudioChannelLabel_HeadphonesLeft: return MA_CHANNEL_LEFT; + case kAudioChannelLabel_HeadphonesRight: return MA_CHANNEL_RIGHT; + case kAudioChannelLabel_ClickTrack: return MA_CHANNEL_NONE; + case kAudioChannelLabel_ForeignLanguage: return MA_CHANNEL_NONE; + case kAudioChannelLabel_Discrete: return MA_CHANNEL_NONE; + case kAudioChannelLabel_Discrete_0: return MA_CHANNEL_AUX_0; + case kAudioChannelLabel_Discrete_1: return MA_CHANNEL_AUX_1; + case kAudioChannelLabel_Discrete_2: return MA_CHANNEL_AUX_2; + case kAudioChannelLabel_Discrete_3: return MA_CHANNEL_AUX_3; + case kAudioChannelLabel_Discrete_4: return MA_CHANNEL_AUX_4; + case kAudioChannelLabel_Discrete_5: return MA_CHANNEL_AUX_5; + case kAudioChannelLabel_Discrete_6: return MA_CHANNEL_AUX_6; + case kAudioChannelLabel_Discrete_7: return MA_CHANNEL_AUX_7; + case kAudioChannelLabel_Discrete_8: return MA_CHANNEL_AUX_8; + case kAudioChannelLabel_Discrete_9: return MA_CHANNEL_AUX_9; + case kAudioChannelLabel_Discrete_10: return MA_CHANNEL_AUX_10; + case kAudioChannelLabel_Discrete_11: return MA_CHANNEL_AUX_11; + case kAudioChannelLabel_Discrete_12: return MA_CHANNEL_AUX_12; + case kAudioChannelLabel_Discrete_13: return MA_CHANNEL_AUX_13; + case kAudioChannelLabel_Discrete_14: return MA_CHANNEL_AUX_14; + case kAudioChannelLabel_Discrete_15: return MA_CHANNEL_AUX_15; + case kAudioChannelLabel_Discrete_65535: return MA_CHANNEL_NONE; #if 0 // Introduced in a later version of macOS. - case kAudioChannelLabel_HOA_ACN: return MAL_CHANNEL_NONE; - case kAudioChannelLabel_HOA_ACN_0: return MAL_CHANNEL_AUX_0; - case kAudioChannelLabel_HOA_ACN_1: return MAL_CHANNEL_AUX_1; - case kAudioChannelLabel_HOA_ACN_2: return MAL_CHANNEL_AUX_2; - case kAudioChannelLabel_HOA_ACN_3: return MAL_CHANNEL_AUX_3; - case kAudioChannelLabel_HOA_ACN_4: return MAL_CHANNEL_AUX_4; - case kAudioChannelLabel_HOA_ACN_5: return MAL_CHANNEL_AUX_5; - case kAudioChannelLabel_HOA_ACN_6: return MAL_CHANNEL_AUX_6; - case kAudioChannelLabel_HOA_ACN_7: return MAL_CHANNEL_AUX_7; - case kAudioChannelLabel_HOA_ACN_8: return MAL_CHANNEL_AUX_8; - case kAudioChannelLabel_HOA_ACN_9: return MAL_CHANNEL_AUX_9; - case kAudioChannelLabel_HOA_ACN_10: return MAL_CHANNEL_AUX_10; - case kAudioChannelLabel_HOA_ACN_11: return MAL_CHANNEL_AUX_11; - case kAudioChannelLabel_HOA_ACN_12: return MAL_CHANNEL_AUX_12; - case kAudioChannelLabel_HOA_ACN_13: return MAL_CHANNEL_AUX_13; - case kAudioChannelLabel_HOA_ACN_14: return MAL_CHANNEL_AUX_14; - case kAudioChannelLabel_HOA_ACN_15: return MAL_CHANNEL_AUX_15; - case kAudioChannelLabel_HOA_ACN_65024: return MAL_CHANNEL_NONE; + case kAudioChannelLabel_HOA_ACN: return MA_CHANNEL_NONE; + case kAudioChannelLabel_HOA_ACN_0: return MA_CHANNEL_AUX_0; + case kAudioChannelLabel_HOA_ACN_1: return MA_CHANNEL_AUX_1; + case kAudioChannelLabel_HOA_ACN_2: return MA_CHANNEL_AUX_2; + case kAudioChannelLabel_HOA_ACN_3: return MA_CHANNEL_AUX_3; + case kAudioChannelLabel_HOA_ACN_4: return MA_CHANNEL_AUX_4; + case kAudioChannelLabel_HOA_ACN_5: return MA_CHANNEL_AUX_5; + case kAudioChannelLabel_HOA_ACN_6: return MA_CHANNEL_AUX_6; + case kAudioChannelLabel_HOA_ACN_7: return MA_CHANNEL_AUX_7; + case kAudioChannelLabel_HOA_ACN_8: return MA_CHANNEL_AUX_8; + case kAudioChannelLabel_HOA_ACN_9: return MA_CHANNEL_AUX_9; + case kAudioChannelLabel_HOA_ACN_10: return MA_CHANNEL_AUX_10; + case kAudioChannelLabel_HOA_ACN_11: return MA_CHANNEL_AUX_11; + case kAudioChannelLabel_HOA_ACN_12: return MA_CHANNEL_AUX_12; + case kAudioChannelLabel_HOA_ACN_13: return MA_CHANNEL_AUX_13; + case kAudioChannelLabel_HOA_ACN_14: return MA_CHANNEL_AUX_14; + case kAudioChannelLabel_HOA_ACN_15: return MA_CHANNEL_AUX_15; + case kAudioChannelLabel_HOA_ACN_65024: return MA_CHANNEL_NONE; #endif - default: return MAL_CHANNEL_NONE; + default: return MA_CHANNEL_NONE; } } @@ -15865,63 +15865,63 @@ mal_result mal_format_from_AudioStreamBasicDescription(const AudioStreamBasicDes // There's a few things miniaudio doesn't support. if (pDescription->mFormatID != kAudioFormatLinearPCM) { - return MAL_FORMAT_NOT_SUPPORTED; + return MA_FORMAT_NOT_SUPPORTED; } // We don't support any non-packed formats that are aligned high. if ((pDescription->mFormatFlags & kLinearPCMFormatFlagIsAlignedHigh) != 0) { - return MAL_FORMAT_NOT_SUPPORTED; + return MA_FORMAT_NOT_SUPPORTED; } // Only supporting native-endian. if ((mal_is_little_endian() && (pDescription->mFormatFlags & kAudioFormatFlagIsBigEndian) != 0) || (mal_is_big_endian() && (pDescription->mFormatFlags & kAudioFormatFlagIsBigEndian) == 0)) { - return MAL_FORMAT_NOT_SUPPORTED; + return MA_FORMAT_NOT_SUPPORTED; } // We are not currently supporting non-interleaved formats (this will be added in a future version of miniaudio). //if ((pDescription->mFormatFlags & kAudioFormatFlagIsNonInterleaved) != 0) { - // return MAL_FORMAT_NOT_SUPPORTED; + // return MA_FORMAT_NOT_SUPPORTED; //} if ((pDescription->mFormatFlags & kLinearPCMFormatFlagIsFloat) != 0) { if (pDescription->mBitsPerChannel == 32) { *pFormatOut = mal_format_f32; - return MAL_SUCCESS; + return MA_SUCCESS; } } else { if ((pDescription->mFormatFlags & kLinearPCMFormatFlagIsSignedInteger) != 0) { if (pDescription->mBitsPerChannel == 16) { *pFormatOut = mal_format_s16; - return MAL_SUCCESS; + return MA_SUCCESS; } else if (pDescription->mBitsPerChannel == 24) { if (pDescription->mBytesPerFrame == (pDescription->mBitsPerChannel/8 * pDescription->mChannelsPerFrame)) { *pFormatOut = mal_format_s24; - return MAL_SUCCESS; + return MA_SUCCESS; } else { if (pDescription->mBytesPerFrame/pDescription->mChannelsPerFrame == sizeof(mal_int32)) { // TODO: Implement mal_format_s24_32. //*pFormatOut = mal_format_s24_32; - //return MAL_SUCCESS; - return MAL_FORMAT_NOT_SUPPORTED; + //return MA_SUCCESS; + return MA_FORMAT_NOT_SUPPORTED; } } } else if (pDescription->mBitsPerChannel == 32) { *pFormatOut = mal_format_s32; - return MAL_SUCCESS; + return MA_SUCCESS; } } else { if (pDescription->mBitsPerChannel == 8) { *pFormatOut = mal_format_u8; - return MAL_SUCCESS; + return MA_SUCCESS; } } } // Getting here means the format is not supported. - return MAL_FORMAT_NOT_SUPPORTED; + return MA_FORMAT_NOT_SUPPORTED; } -mal_result mal_get_channel_map_from_AudioChannelLayout(AudioChannelLayout* pChannelLayout, mal_channel channelMap[MAL_MAX_CHANNELS]) +mal_result mal_get_channel_map_from_AudioChannelLayout(AudioChannelLayout* pChannelLayout, mal_channel channelMap[MA_MAX_CHANNELS]) { mal_assert(pChannelLayout != NULL); @@ -15963,23 +15963,23 @@ mal_result mal_get_channel_map_from_AudioChannelLayout(AudioChannelLayout* pChan case kAudioChannelLayoutTag_Octagonal: { - channelMap[7] = MAL_CHANNEL_SIDE_RIGHT; - channelMap[6] = MAL_CHANNEL_SIDE_LEFT; + channelMap[7] = MA_CHANNEL_SIDE_RIGHT; + channelMap[6] = MA_CHANNEL_SIDE_LEFT; } // Intentional fallthrough. case kAudioChannelLayoutTag_Hexagonal: { - channelMap[5] = MAL_CHANNEL_BACK_CENTER; + channelMap[5] = MA_CHANNEL_BACK_CENTER; } // Intentional fallthrough. case kAudioChannelLayoutTag_Pentagonal: { - channelMap[4] = MAL_CHANNEL_FRONT_CENTER; + channelMap[4] = MA_CHANNEL_FRONT_CENTER; } // Intentional fallghrough. case kAudioChannelLayoutTag_Quadraphonic: { - channelMap[3] = MAL_CHANNEL_BACK_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_LEFT; - channelMap[1] = MAL_CHANNEL_RIGHT; - channelMap[0] = MAL_CHANNEL_LEFT; + channelMap[3] = MA_CHANNEL_BACK_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_LEFT; + channelMap[1] = MA_CHANNEL_RIGHT; + channelMap[0] = MA_CHANNEL_LEFT; } break; // TODO: Add support for more tags here. @@ -15991,11 +15991,11 @@ mal_result mal_get_channel_map_from_AudioChannelLayout(AudioChannelLayout* pChan } } - return MAL_SUCCESS; + return MA_SUCCESS; } -#if defined(MAL_APPLE_DESKTOP) +#if defined(MA_APPLE_DESKTOP) mal_result mal_get_device_object_ids__coreaudio(mal_context* pContext, UInt32* pDeviceCount, AudioObjectID** ppDeviceObjectIDs) // NOTE: Free the returned buffer with mal_free(). { mal_assert(pContext != NULL); @@ -16020,7 +16020,7 @@ mal_result mal_get_device_object_ids__coreaudio(mal_context* pContext, UInt32* p AudioObjectID* pDeviceObjectIDs = (AudioObjectID*)mal_malloc(deviceObjectsDataSize); if (pDeviceObjectIDs == NULL) { - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } status = ((mal_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(kAudioObjectSystemObject, &propAddressDevices, 0, NULL, &deviceObjectsDataSize, pDeviceObjectIDs); @@ -16031,7 +16031,7 @@ mal_result mal_get_device_object_ids__coreaudio(mal_context* pContext, UInt32* p *pDeviceCount = deviceObjectsDataSize / sizeof(AudioObjectID); *ppDeviceObjectIDs = pDeviceObjectIDs; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_get_AudioObject_uid_as_CFStringRef(mal_context* pContext, AudioObjectID objectID, CFStringRef* pUID) @@ -16049,7 +16049,7 @@ mal_result mal_get_AudioObject_uid_as_CFStringRef(mal_context* pContext, AudioOb return mal_result_from_OSStatus(status); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_get_AudioObject_uid(mal_context* pContext, AudioObjectID objectID, size_t bufferSize, char* bufferOut) @@ -16058,15 +16058,15 @@ mal_result mal_get_AudioObject_uid(mal_context* pContext, AudioObjectID objectID CFStringRef uid; mal_result result = mal_get_AudioObject_uid_as_CFStringRef(pContext, objectID, &uid); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } if (!((mal_CFStringGetCString_proc)pContext->coreaudio.CFStringGetCString)(uid, bufferOut, bufferSize, kCFStringEncodingUTF8)) { - return MAL_ERROR; + return MA_ERROR; } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_get_AudioObject_name(mal_context* pContext, AudioObjectID objectID, size_t bufferSize, char* bufferOut) @@ -16086,10 +16086,10 @@ mal_result mal_get_AudioObject_name(mal_context* pContext, AudioObjectID objectI } if (!((mal_CFStringGetCString_proc)pContext->coreaudio.CFStringGetCString)(deviceName, bufferOut, bufferSize, kCFStringEncodingUTF8)) { - return MAL_ERROR; + return MA_ERROR; } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_bool32 mal_does_AudioObject_support_scope(mal_context* pContext, AudioObjectID deviceObjectID, AudioObjectPropertyScope scope) @@ -16106,23 +16106,23 @@ mal_bool32 mal_does_AudioObject_support_scope(mal_context* pContext, AudioObject UInt32 dataSize; OSStatus status = ((mal_AudioObjectGetPropertyDataSize_proc)pContext->coreaudio.AudioObjectGetPropertyDataSize)(deviceObjectID, &propAddress, 0, NULL, &dataSize); if (status != noErr) { - return MAL_FALSE; + return MA_FALSE; } AudioBufferList* pBufferList = (AudioBufferList*)mal_malloc(dataSize); if (pBufferList == NULL) { - return MAL_FALSE; // Out of memory. + return MA_FALSE; // Out of memory. } status = ((mal_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pBufferList); if (status != noErr) { mal_free(pBufferList); - return MAL_FALSE; + return MA_FALSE; } - mal_bool32 isSupported = MAL_FALSE; + mal_bool32 isSupported = MA_FALSE; if (pBufferList->mNumberBuffers > 0) { - isSupported = MAL_TRUE; + isSupported = MA_TRUE; } mal_free(pBufferList); @@ -16161,7 +16161,7 @@ mal_result mal_get_AudioObject_stream_descriptions(mal_context* pContext, AudioO AudioStreamRangedDescription* pDescriptions = (AudioStreamRangedDescription*)mal_malloc(dataSize); if (pDescriptions == NULL) { - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } status = ((mal_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pDescriptions); @@ -16172,7 +16172,7 @@ mal_result mal_get_AudioObject_stream_descriptions(mal_context* pContext, AudioO *pDescriptionCount = dataSize / sizeof(*pDescriptions); *ppDescriptions = pDescriptions; - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -16196,7 +16196,7 @@ mal_result mal_get_AudioObject_channel_layout(mal_context* pContext, AudioObject AudioChannelLayout* pChannelLayout = (AudioChannelLayout*)mal_malloc(dataSize); if (pChannelLayout == NULL) { - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } status = ((mal_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pChannelLayout); @@ -16206,7 +16206,7 @@ mal_result mal_get_AudioObject_channel_layout(mal_context* pContext, AudioObject } *ppChannelLayout = pChannelLayout; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_get_AudioObject_channel_count(mal_context* pContext, AudioObjectID deviceObjectID, mal_device_type deviceType, mal_uint32* pChannelCount) @@ -16218,7 +16218,7 @@ mal_result mal_get_AudioObject_channel_count(mal_context* pContext, AudioObjectI AudioChannelLayout* pChannelLayout; mal_result result = mal_get_AudioObject_channel_layout(pContext, deviceObjectID, deviceType, &pChannelLayout); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -16231,21 +16231,21 @@ mal_result mal_get_AudioObject_channel_count(mal_context* pContext, AudioObjectI } mal_free(pChannelLayout); - return MAL_SUCCESS; + return MA_SUCCESS; } -mal_result mal_get_AudioObject_channel_map(mal_context* pContext, AudioObjectID deviceObjectID, mal_device_type deviceType, mal_channel channelMap[MAL_MAX_CHANNELS]) +mal_result mal_get_AudioObject_channel_map(mal_context* pContext, AudioObjectID deviceObjectID, mal_device_type deviceType, mal_channel channelMap[MA_MAX_CHANNELS]) { mal_assert(pContext != NULL); AudioChannelLayout* pChannelLayout; mal_result result = mal_get_AudioObject_channel_layout(pContext, deviceObjectID, deviceType, &pChannelLayout); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; // Rather than always failing here, would it be more robust to simply assume a default? } result = mal_get_channel_map_from_AudioChannelLayout(pChannelLayout, channelMap); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { mal_free(pChannelLayout); return result; } @@ -16277,7 +16277,7 @@ mal_result mal_get_AudioObject_sample_rates(mal_context* pContext, AudioObjectID AudioValueRange* pSampleRateRanges = (AudioValueRange*)mal_malloc(dataSize); if (pSampleRateRanges == NULL) { - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } status = ((mal_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(deviceObjectID, &propAddress, 0, NULL, &dataSize, pSampleRateRanges); @@ -16288,7 +16288,7 @@ mal_result mal_get_AudioObject_sample_rates(mal_context* pContext, AudioObjectID *pSampleRateRangesCount = dataSize / sizeof(*pSampleRateRanges); *ppSampleRateRanges = pSampleRateRanges; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_get_AudioObject_get_closest_sample_rate(mal_context* pContext, AudioObjectID deviceObjectID, mal_device_type deviceType, mal_uint32 sampleRateIn, mal_uint32* pSampleRateOut) @@ -16301,13 +16301,13 @@ mal_result mal_get_AudioObject_get_closest_sample_rate(mal_context* pContext, Au UInt32 sampleRateRangeCount; AudioValueRange* pSampleRateRanges; mal_result result = mal_get_AudioObject_sample_rates(pContext, deviceObjectID, deviceType, &sampleRateRangeCount, &pSampleRateRanges); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } if (sampleRateRangeCount == 0) { mal_free(pSampleRateRanges); - return MAL_ERROR; // Should never hit this case should we? + return MA_ERROR; // Should never hit this case should we? } if (sampleRateIn == 0) { @@ -16319,7 +16319,7 @@ mal_result mal_get_AudioObject_get_closest_sample_rate(mal_context* pContext, Au if (caSampleRate.mMinimum <= malSampleRate && caSampleRate.mMaximum >= malSampleRate) { *pSampleRateOut = malSampleRate; mal_free(pSampleRateRanges); - return MAL_SUCCESS; + return MA_SUCCESS; } } } @@ -16330,7 +16330,7 @@ mal_result mal_get_AudioObject_get_closest_sample_rate(mal_context* pContext, Au *pSampleRateOut = pSampleRateRanges[0].mMinimum; mal_free(pSampleRateRanges); - return MAL_SUCCESS; + return MA_SUCCESS; } else { // Find the closest match to this sample rate. UInt32 currentAbsoluteDifference = INT32_MAX; @@ -16339,7 +16339,7 @@ mal_result mal_get_AudioObject_get_closest_sample_rate(mal_context* pContext, Au if (pSampleRateRanges[iRange].mMinimum <= sampleRateIn && pSampleRateRanges[iRange].mMaximum >= sampleRateIn) { *pSampleRateOut = sampleRateIn; mal_free(pSampleRateRanges); - return MAL_SUCCESS; + return MA_SUCCESS; } else { UInt32 absoluteDifference; if (pSampleRateRanges[iRange].mMinimum > sampleRateIn) { @@ -16359,12 +16359,12 @@ mal_result mal_get_AudioObject_get_closest_sample_rate(mal_context* pContext, Au *pSampleRateOut = pSampleRateRanges[iCurrentClosestRange].mMinimum; mal_free(pSampleRateRanges); - return MAL_SUCCESS; + return MA_SUCCESS; } // Should never get here, but it would mean we weren't able to find any suitable sample rates. //mal_free(pSampleRateRanges); - //return MAL_ERROR; + //return MA_ERROR; } @@ -16396,7 +16396,7 @@ mal_result mal_get_AudioObject_closest_buffer_size_in_frames(mal_context* pConte *pBufferSizeInFramesOut = bufferSizeInFramesIn; } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_set_AudioObject_buffer_size_in_frames(mal_context* pContext, AudioObjectID deviceObjectID, mal_device_type deviceType, mal_uint32* pBufferSizeInOut) @@ -16405,7 +16405,7 @@ mal_result mal_set_AudioObject_buffer_size_in_frames(mal_context* pContext, Audi mal_uint32 chosenBufferSizeInFrames; mal_result result = mal_get_AudioObject_closest_buffer_size_in_frames(pContext, deviceObjectID, deviceType, *pBufferSizeInOut, &chosenBufferSizeInFrames); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -16425,7 +16425,7 @@ mal_result mal_set_AudioObject_buffer_size_in_frames(mal_context* pContext, Audi } *pBufferSizeInOut = chosenBufferSizeInFrames; - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -16453,14 +16453,14 @@ mal_result mal_find_AudioObjectID(mal_context* pContext, mal_device_type deviceT OSStatus status = ((mal_AudioObjectGetPropertyData_proc)pContext->coreaudio.AudioObjectGetPropertyData)(kAudioObjectSystemObject, &propAddressDefaultDevice, 0, NULL, &defaultDeviceObjectIDSize, &defaultDeviceObjectID); if (status == noErr) { *pDeviceObjectID = defaultDeviceObjectID; - return MAL_SUCCESS; + return MA_SUCCESS; } } else { // Explicit device. UInt32 deviceCount; AudioObjectID* pDeviceObjectIDs; mal_result result = mal_get_device_object_ids__coreaudio(pContext, &deviceCount, &pDeviceObjectIDs); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -16468,7 +16468,7 @@ mal_result mal_find_AudioObjectID(mal_context* pContext, mal_device_type deviceT AudioObjectID deviceObjectID = pDeviceObjectIDs[iDevice]; char uid[256]; - if (mal_get_AudioObject_uid(pContext, deviceObjectID, sizeof(uid), uid) != MAL_SUCCESS) { + if (mal_get_AudioObject_uid(pContext, deviceObjectID, sizeof(uid), uid) != MA_SUCCESS) { continue; } @@ -16476,14 +16476,14 @@ mal_result mal_find_AudioObjectID(mal_context* pContext, mal_device_type deviceT if (mal_does_AudioObject_support_playback(pContext, deviceObjectID)) { if (strcmp(uid, pDeviceID->coreaudio) == 0) { *pDeviceObjectID = deviceObjectID; - return MAL_SUCCESS; + return MA_SUCCESS; } } } else { if (mal_does_AudioObject_support_capture(pContext, deviceObjectID)) { if (strcmp(uid, pDeviceID->coreaudio) == 0) { *pDeviceObjectID = deviceObjectID; - return MAL_SUCCESS; + return MA_SUCCESS; } } } @@ -16491,7 +16491,7 @@ mal_result mal_find_AudioObjectID(mal_context* pContext, mal_device_type deviceT } // If we get here it means we couldn't find the device. - return MAL_NO_DEVICE; + return MA_NO_DEVICE; } @@ -16500,7 +16500,7 @@ mal_result mal_find_best_format__coreaudio(mal_context* pContext, AudioObjectID UInt32 deviceFormatDescriptionCount; AudioStreamRangedDescription* pDeviceFormatDescriptions; mal_result result = mal_get_AudioObject_stream_descriptions(pContext, deviceObjectID, deviceType, &deviceFormatDescriptionCount, &pDeviceFormatDescriptions); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -16511,13 +16511,13 @@ mal_result mal_find_best_format__coreaudio(mal_context* pContext, AudioObjectID for (mal_uint32 iStandardRate = 0; iStandardRate < mal_countof(g_malStandardSampleRatePriorities); ++iStandardRate) { mal_uint32 standardRate = g_malStandardSampleRatePriorities[iStandardRate]; - mal_bool32 foundRate = MAL_FALSE; + mal_bool32 foundRate = MA_FALSE; for (UInt32 iDeviceRate = 0; iDeviceRate < deviceFormatDescriptionCount; ++iDeviceRate) { mal_uint32 deviceRate = (mal_uint32)pDeviceFormatDescriptions[iDeviceRate].mFormat.mSampleRate; if (deviceRate == standardRate) { desiredSampleRate = standardRate; - foundRate = MAL_TRUE; + foundRate = MA_TRUE; break; } } @@ -16543,19 +16543,19 @@ mal_result mal_find_best_format__coreaudio(mal_context* pContext, AudioObjectID AudioStreamBasicDescription bestDeviceFormatSoFar; mal_zero_object(&bestDeviceFormatSoFar); - mal_bool32 hasSupportedFormat = MAL_FALSE; + mal_bool32 hasSupportedFormat = MA_FALSE; for (UInt32 iFormat = 0; iFormat < deviceFormatDescriptionCount; ++iFormat) { mal_format format; mal_result formatResult = mal_format_from_AudioStreamBasicDescription(&pDeviceFormatDescriptions[iFormat].mFormat, &format); - if (formatResult == MAL_SUCCESS && format != mal_format_unknown) { - hasSupportedFormat = MAL_TRUE; + if (formatResult == MA_SUCCESS && format != mal_format_unknown) { + hasSupportedFormat = MA_TRUE; bestDeviceFormatSoFar = pDeviceFormatDescriptions[iFormat].mFormat; break; } } if (!hasSupportedFormat) { - return MAL_FORMAT_NOT_SUPPORTED; + return MA_FORMAT_NOT_SUPPORTED; } @@ -16565,7 +16565,7 @@ mal_result mal_find_best_format__coreaudio(mal_context* pContext, AudioObjectID // If the format is not supported by miniaudio we need to skip this one entirely. mal_format thisSampleFormat; mal_result formatResult = mal_format_from_AudioStreamBasicDescription(&pDeviceFormatDescriptions[iFormat].mFormat, &thisSampleFormat); - if (formatResult != MAL_SUCCESS || thisSampleFormat == mal_format_unknown) { + if (formatResult != MA_SUCCESS || thisSampleFormat == mal_format_unknown) { continue; // The format is not supported by miniaudio. Skip. } @@ -16664,11 +16664,11 @@ mal_result mal_find_best_format__coreaudio(mal_context* pContext, AudioObjectID } *pFormat = bestDeviceFormatSoFar; - return MAL_SUCCESS; + return MA_SUCCESS; } #endif -mal_result mal_get_AudioUnit_channel_map(mal_context* pContext, AudioUnit audioUnit, mal_device_type deviceType, mal_channel channelMap[MAL_MAX_CHANNELS]) +mal_result mal_get_AudioUnit_channel_map(mal_context* pContext, AudioUnit audioUnit, mal_device_type deviceType, mal_channel channelMap[MA_MAX_CHANNELS]) { mal_assert(pContext != NULL); @@ -16676,10 +16676,10 @@ mal_result mal_get_AudioUnit_channel_map(mal_context* pContext, AudioUnit audioU AudioUnitElement deviceBus; if (deviceType == mal_device_type_playback) { deviceScope = kAudioUnitScope_Output; - deviceBus = MAL_COREAUDIO_OUTPUT_BUS; + deviceBus = MA_COREAUDIO_OUTPUT_BUS; } else { deviceScope = kAudioUnitScope_Input; - deviceBus = MAL_COREAUDIO_INPUT_BUS; + deviceBus = MA_COREAUDIO_INPUT_BUS; } UInt32 channelLayoutSize; @@ -16690,7 +16690,7 @@ mal_result mal_get_AudioUnit_channel_map(mal_context* pContext, AudioUnit audioU AudioChannelLayout* pChannelLayout = (AudioChannelLayout*)mal_malloc(channelLayoutSize); if (pChannelLayout == NULL) { - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } status = ((mal_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(audioUnit, kAudioUnitProperty_AudioChannelLayout, deviceScope, deviceBus, pChannelLayout, &channelLayoutSize); @@ -16700,13 +16700,13 @@ mal_result mal_get_AudioUnit_channel_map(mal_context* pContext, AudioUnit audioU } mal_result result = mal_get_channel_map_from_AudioChannelLayout(pChannelLayout, channelMap); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { mal_free(pChannelLayout); return result; } mal_free(pChannelLayout); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_bool32 mal_context_is_device_id_equal__coreaudio(mal_context* pContext, const mal_device_id* pID0, const mal_device_id* pID1) @@ -16724,11 +16724,11 @@ mal_result mal_context_enumerate_devices__coreaudio(mal_context* pContext, mal_e mal_assert(pContext != NULL); mal_assert(callback != NULL); -#if defined(MAL_APPLE_DESKTOP) +#if defined(MA_APPLE_DESKTOP) UInt32 deviceCount; AudioObjectID* pDeviceObjectIDs; mal_result result = mal_get_device_object_ids__coreaudio(pContext, &deviceCount, &pDeviceObjectIDs); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -16737,10 +16737,10 @@ mal_result mal_context_enumerate_devices__coreaudio(mal_context* pContext, mal_e mal_device_info info; mal_zero_object(&info); - if (mal_get_AudioObject_uid(pContext, deviceObjectID, sizeof(info.id.coreaudio), info.id.coreaudio) != MAL_SUCCESS) { + if (mal_get_AudioObject_uid(pContext, deviceObjectID, sizeof(info.id.coreaudio), info.id.coreaudio) != MA_SUCCESS) { continue; } - if (mal_get_AudioObject_name(pContext, deviceObjectID, sizeof(info.name), info.name) != MAL_SUCCESS) { + if (mal_get_AudioObject_name(pContext, deviceObjectID, sizeof(info.name), info.name) != MA_SUCCESS) { continue; } @@ -16762,19 +16762,19 @@ mal_result mal_context_enumerate_devices__coreaudio(mal_context* pContext, mal_e mal_device_info info; mal_zero_object(&info); - mal_strncpy_s(info.name, sizeof(info.name), MAL_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(info.name, sizeof(info.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); if (!callback(pContext, mal_device_type_playback, &info, pUserData)) { - return MAL_SUCCESS; + return MA_SUCCESS; } mal_zero_object(&info); - mal_strncpy_s(info.name, sizeof(info.name), MAL_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(info.name, sizeof(info.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); if (!callback(pContext, mal_device_type_capture, &info, pUserData)) { - return MAL_SUCCESS; + return MA_SUCCESS; } #endif - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_get_device_info__coreaudio(mal_context* pContext, mal_device_type deviceType, const mal_device_id* pDeviceID, mal_share_mode shareMode, mal_device_info* pDeviceInfo) @@ -16784,25 +16784,25 @@ mal_result mal_context_get_device_info__coreaudio(mal_context* pContext, mal_dev /* No exclusive mode with the Core Audio backend for now. */ if (shareMode == mal_share_mode_exclusive) { - return MAL_SHARE_MODE_NOT_SUPPORTED; + return MA_SHARE_MODE_NOT_SUPPORTED; } -#if defined(MAL_APPLE_DESKTOP) +#if defined(MA_APPLE_DESKTOP) // Desktop // ======= AudioObjectID deviceObjectID; mal_result result = mal_find_AudioObjectID(pContext, deviceType, pDeviceID, &deviceObjectID); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } result = mal_get_AudioObject_uid(pContext, deviceObjectID, sizeof(pDeviceInfo->id.coreaudio), pDeviceInfo->id.coreaudio); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } result = mal_get_AudioObject_name(pContext, deviceObjectID, sizeof(pDeviceInfo->name), pDeviceInfo->name); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -16810,24 +16810,24 @@ mal_result mal_context_get_device_info__coreaudio(mal_context* pContext, mal_dev UInt32 streamDescriptionCount; AudioStreamRangedDescription* pStreamDescriptions; result = mal_get_AudioObject_stream_descriptions(pContext, deviceObjectID, deviceType, &streamDescriptionCount, &pStreamDescriptions); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } for (UInt32 iStreamDescription = 0; iStreamDescription < streamDescriptionCount; ++iStreamDescription) { mal_format format; result = mal_format_from_AudioStreamBasicDescription(&pStreamDescriptions[iStreamDescription].mFormat, &format); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { continue; } mal_assert(format != mal_format_unknown); // Make sure the format isn't already in the output list. - mal_bool32 exists = MAL_FALSE; + mal_bool32 exists = MA_FALSE; for (mal_uint32 iOutputFormat = 0; iOutputFormat < pDeviceInfo->formatCount; ++iOutputFormat) { if (pDeviceInfo->formats[iOutputFormat] == format) { - exists = MAL_TRUE; + exists = MA_TRUE; break; } } @@ -16842,7 +16842,7 @@ mal_result mal_context_get_device_info__coreaudio(mal_context* pContext, mal_dev // Channels. result = mal_get_AudioObject_channel_count(pContext, deviceObjectID, deviceType, &pDeviceInfo->minChannels); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } pDeviceInfo->maxChannels = pDeviceInfo->minChannels; @@ -16852,7 +16852,7 @@ mal_result mal_context_get_device_info__coreaudio(mal_context* pContext, mal_dev UInt32 sampleRateRangeCount; AudioValueRange* pSampleRateRanges; result = mal_get_AudioObject_sample_rates(pContext, deviceObjectID, deviceType, &sampleRateRangeCount, &pSampleRateRanges); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -16872,9 +16872,9 @@ mal_result mal_context_get_device_info__coreaudio(mal_context* pContext, mal_dev // Mobile // ====== if (deviceType == mal_device_type_playback) { - mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MAL_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { - mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MAL_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } // Retrieving device information is more annoying on mobile than desktop. For simplicity I'm locking this down to whatever format is @@ -16889,7 +16889,7 @@ mal_result mal_context_get_device_info__coreaudio(mal_context* pContext, mal_dev AudioComponent component = ((mal_AudioComponentFindNext_proc)pContext->coreaudio.AudioComponentFindNext)(NULL, &desc); if (component == NULL) { - return MAL_FAILED_TO_INIT_BACKEND; + return MA_FAILED_TO_INIT_BACKEND; } AudioUnit audioUnit; @@ -16899,7 +16899,7 @@ mal_result mal_context_get_device_info__coreaudio(mal_context* pContext, mal_dev } AudioUnitScope formatScope = (deviceType == mal_device_type_playback) ? kAudioUnitScope_Input : kAudioUnitScope_Output; - AudioUnitElement formatElement = (deviceType == mal_device_type_playback) ? MAL_COREAUDIO_OUTPUT_BUS : MAL_COREAUDIO_INPUT_BUS; + AudioUnitElement formatElement = (deviceType == mal_device_type_playback) ? MA_COREAUDIO_OUTPUT_BUS : MA_COREAUDIO_INPUT_BUS; AudioStreamBasicDescription bestFormat; UInt32 propSize = sizeof(bestFormat); @@ -16918,7 +16918,7 @@ mal_result mal_context_get_device_info__coreaudio(mal_context* pContext, mal_dev pDeviceInfo->formatCount = 1; mal_result result = mal_format_from_AudioStreamBasicDescription(&bestFormat, &pDeviceInfo->formats[0]); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -16933,14 +16933,14 @@ mal_result mal_context_get_device_info__coreaudio(mal_context* pContext, mal_dev } #endif - return MAL_SUCCESS; + return MA_SUCCESS; } void mal_device_uninit__coreaudio(mal_device* pDevice) { mal_assert(pDevice != NULL); - mal_assert(mal_device__get_state(pDevice) == MAL_STATE_UNINITIALIZED); + mal_assert(mal_device__get_state(pDevice) == MA_STATE_UNINITIALIZED); if (pDevice->coreaudio.audioUnitCapture != NULL) { ((mal_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitCapture); @@ -16968,7 +16968,7 @@ OSStatus mal_on_output__coreaudio(void* pUserData, AudioUnitRenderActionFlags* p mal_device* pDevice = (mal_device*)pUserData; mal_assert(pDevice != NULL); -#if defined(MAL_DEBUG_OUTPUT) +#if defined(MA_DEBUG_OUTPUT) printf("INFO: Output Callback: busNumber=%d, frameCount=%d, mNumberBuffers=%d\n", busNumber, frameCount, pBufferList->mNumberBuffers); #endif @@ -16992,7 +16992,7 @@ OSStatus mal_on_output__coreaudio(void* pUserData, AudioUnitRenderActionFlags* p } } - #if defined(MAL_DEBUG_OUTPUT) + #if defined(MA_DEBUG_OUTPUT) printf(" frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", frameCount, pBufferList->mBuffers[iBuffer].mNumberChannels, pBufferList->mBuffers[iBuffer].mDataByteSize); #endif } else { @@ -17001,7 +17001,7 @@ OSStatus mal_on_output__coreaudio(void* pUserData, AudioUnitRenderActionFlags* p // output silence here. mal_zero_memory(pBufferList->mBuffers[iBuffer].mData, pBufferList->mBuffers[iBuffer].mDataByteSize); - #if defined(MAL_DEBUG_OUTPUT) + #if defined(MA_DEBUG_OUTPUT) printf(" WARNING: Outputting silence. frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", frameCount, pBufferList->mBuffers[iBuffer].mNumberChannels, pBufferList->mBuffers[iBuffer].mDataByteSize); #endif } @@ -17026,7 +17026,7 @@ OSStatus mal_on_output__coreaudio(void* pUserData, AudioUnitRenderActionFlags* p mal_device__read_frames_from_client(pDevice, framesToRead, tempBuffer); } - void* ppDeinterleavedBuffers[MAL_MAX_CHANNELS]; + void* ppDeinterleavedBuffers[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < pDevice->playback.internalChannels; ++iChannel) { ppDeinterleavedBuffers[iChannel] = (void*)mal_offset_ptr(pBufferList->mBuffers[iBuffer].mData, (frameCountPerBuffer - framesRemaining) * mal_get_bytes_per_sample(pDevice->playback.internalFormat)); } @@ -17062,13 +17062,13 @@ OSStatus mal_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFlags* pA layout = mal_stream_layout_deinterleaved; } -#if defined(MAL_DEBUG_OUTPUT) +#if defined(MA_DEBUG_OUTPUT) printf("INFO: Input Callback: busNumber=%d, frameCount=%d, mNumberBuffers=%d\n", busNumber, frameCount, pRenderedBufferList->mNumberBuffers); #endif OSStatus status = ((mal_AudioUnitRender_proc)pDevice->pContext->coreaudio.AudioUnitRender)((AudioUnit)pDevice->coreaudio.audioUnitCapture, pActionFlags, pTimeStamp, busNumber, frameCount, pRenderedBufferList); if (status != noErr) { - #if defined(MAL_DEBUG_OUTPUT) + #if defined(MA_DEBUG_OUTPUT) printf(" ERROR: AudioUnitRender() failed with %d\n", status); #endif return status; @@ -17082,7 +17082,7 @@ OSStatus mal_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFlags* pA } else { mal_device__send_frames_to_client(pDevice, frameCount, pRenderedBufferList->mBuffers[iBuffer].mData); } - #if defined(MAL_DEBUG_OUTPUT) + #if defined(MA_DEBUG_OUTPUT) printf(" mDataByteSize=%d\n", pRenderedBufferList->mBuffers[iBuffer].mDataByteSize); #endif } else { @@ -17108,7 +17108,7 @@ OSStatus mal_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFlags* pA framesRemaining -= framesToSend; } - #if defined(MAL_DEBUG_OUTPUT) + #if defined(MA_DEBUG_OUTPUT) printf(" WARNING: Outputting silence. frameCount=%d, mNumberChannels=%d, mDataByteSize=%d\n", frameCount, pRenderedBufferList->mBuffers[iBuffer].mNumberChannels, pRenderedBufferList->mBuffers[iBuffer].mDataByteSize); #endif } @@ -17125,7 +17125,7 @@ OSStatus mal_on_input__coreaudio(void* pUserData, AudioUnitRenderActionFlags* pA framesToSend = framesRemaining; } - void* ppDeinterleavedBuffers[MAL_MAX_CHANNELS]; + void* ppDeinterleavedBuffers[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < pDevice->capture.internalChannels; ++iChannel) { ppDeinterleavedBuffers[iChannel] = (void*)mal_offset_ptr(pRenderedBufferList->mBuffers[iBuffer].mData, (frameCount - framesRemaining) * mal_get_bytes_per_sample(pDevice->capture.internalFormat)); } @@ -17157,7 +17157,7 @@ void on_start_stop__coreaudio(void* pUserData, AudioUnit audioUnit, AudioUnitPro // AudioUnitGetProprty (called below) and AudioComponentInstanceDispose (called in mal_device_uninit) // can try waiting on the same lock. I'm going to try working around this by not calling any Core // Audio APIs in the callback when the device has been stopped or uninitialized. - if (mal_device__get_state(pDevice) == MAL_STATE_UNINITIALIZED || mal_device__get_state(pDevice) == MAL_STATE_STOPPING || mal_device__get_state(pDevice) == MAL_STATE_STOPPED) { + if (mal_device__get_state(pDevice) == MA_STATE_UNINITIALIZED || mal_device__get_state(pDevice) == MA_STATE_STOPPING || mal_device__get_state(pDevice) == MA_STATE_STOPPED) { mal_stop_proc onStop = pDevice->onStop; if (onStop) { onStop(pDevice); @@ -17207,7 +17207,7 @@ void on_start_stop__coreaudio(void* pUserData, AudioUnit audioUnit, AudioUnitPro } } -#if defined(MAL_APPLE_DESKTOP) +#if defined(MA_APPLE_DESKTOP) OSStatus mal_default_device_changed__coreaudio(AudioObjectID objectID, UInt32 addressCount, const AudioObjectPropertyAddress* pAddresses, void* pUserData) { (void)objectID; @@ -17221,42 +17221,42 @@ OSStatus mal_default_device_changed__coreaudio(AudioObjectID objectID, UInt32 ad } if (pAddresses[0].mSelector == kAudioHardwarePropertyDefaultOutputDevice) { - pDevice->coreaudio.isSwitchingPlaybackDevice = MAL_TRUE; - mal_result reinitResult = mal_device_reinit_internal__coreaudio(pDevice, mal_device_type_playback, MAL_TRUE); - pDevice->coreaudio.isSwitchingPlaybackDevice = MAL_FALSE; + pDevice->coreaudio.isSwitchingPlaybackDevice = MA_TRUE; + mal_result reinitResult = mal_device_reinit_internal__coreaudio(pDevice, mal_device_type_playback, MA_TRUE); + pDevice->coreaudio.isSwitchingPlaybackDevice = MA_FALSE; - if (reinitResult == MAL_SUCCESS) { + if (reinitResult == MA_SUCCESS) { mal_device__post_init_setup(pDevice, mal_device_type_playback); // Restart the device if required. If this fails we need to stop the device entirely. - if (mal_device__get_state(pDevice) == MAL_STATE_STARTED) { + if (mal_device__get_state(pDevice) == MA_STATE_STARTED) { OSStatus status = ((mal_AudioOutputUnitStart_proc)pDevice->pContext->coreaudio.AudioOutputUnitStart)((AudioUnit)pDevice->coreaudio.audioUnitPlayback); if (status != noErr) { if (pDevice->type == mal_device_type_duplex) { ((mal_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitCapture); } - mal_device__set_state(pDevice, MAL_STATE_STOPPED); + mal_device__set_state(pDevice, MA_STATE_STOPPED); } } } } if (pAddresses[0].mSelector == kAudioHardwarePropertyDefaultInputDevice) { - pDevice->coreaudio.isSwitchingPlaybackDevice = MAL_TRUE; - mal_result reinitResult = mal_device_reinit_internal__coreaudio(pDevice, mal_device_type_capture, MAL_TRUE); - pDevice->coreaudio.isSwitchingPlaybackDevice = MAL_FALSE; + pDevice->coreaudio.isSwitchingPlaybackDevice = MA_TRUE; + mal_result reinitResult = mal_device_reinit_internal__coreaudio(pDevice, mal_device_type_capture, MA_TRUE); + pDevice->coreaudio.isSwitchingPlaybackDevice = MA_FALSE; - if (reinitResult == MAL_SUCCESS) { + if (reinitResult == MA_SUCCESS) { mal_device__post_init_setup(pDevice, mal_device_type_capture); // Restart the device if required. If this fails we need to stop the device entirely. - if (mal_device__get_state(pDevice) == MAL_STATE_STARTED) { + if (mal_device__get_state(pDevice) == MA_STATE_STARTED) { OSStatus status = ((mal_AudioOutputUnitStart_proc)pDevice->pContext->coreaudio.AudioOutputUnitStart)((AudioUnit)pDevice->coreaudio.audioUnitCapture); if (status != noErr) { if (pDevice->type == mal_device_type_duplex) { ((mal_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitPlayback); } - mal_device__set_state(pDevice, MAL_STATE_STOPPED); + mal_device__set_state(pDevice, MA_STATE_STOPPED); } } } @@ -17272,7 +17272,7 @@ typedef struct mal_format formatIn; mal_uint32 channelsIn; mal_uint32 sampleRateIn; - mal_channel channelMapIn[MAL_MAX_CHANNELS]; + mal_channel channelMapIn[MA_MAX_CHANNELS]; mal_uint32 bufferSizeInFramesIn; mal_uint32 bufferSizeInMillisecondsIn; mal_uint32 periodsIn; @@ -17284,7 +17284,7 @@ typedef struct mal_bool32 registerStopEvent; // Output. -#if defined(MAL_APPLE_DESKTOP) +#if defined(MA_APPLE_DESKTOP) AudioObjectID deviceObjectID; #endif AudioComponent component; @@ -17293,7 +17293,7 @@ typedef struct mal_format formatOut; mal_uint32 channelsOut; mal_uint32 sampleRateOut; - mal_channel channelMapOut[MAL_MAX_CHANNELS]; + mal_channel channelMapOut[MA_MAX_CHANNELS]; mal_uint32 bufferSizeInFramesOut; mal_uint32 periodsOut; char deviceName[256]; @@ -17303,13 +17303,13 @@ mal_result mal_device_init_internal__coreaudio(mal_context* pContext, mal_device { /* This API should only be used for a single device type: playback or capture. No full-duplex mode. */ if (deviceType == mal_device_type_duplex) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_assert(pContext != NULL); mal_assert(deviceType == mal_device_type_playback || deviceType == mal_device_type_capture); -#if defined(MAL_APPLE_DESKTOP) +#if defined(MA_APPLE_DESKTOP) pData->deviceObjectID = 0; #endif pData->component = NULL; @@ -17318,10 +17318,10 @@ mal_result mal_device_init_internal__coreaudio(mal_context* pContext, mal_device mal_result result; -#if defined(MAL_APPLE_DESKTOP) +#if defined(MA_APPLE_DESKTOP) AudioObjectID deviceObjectID; result = mal_find_AudioObjectID(pContext, deviceType, pDeviceID, &deviceObjectID); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -17351,14 +17351,14 @@ mal_result mal_device_init_internal__coreaudio(mal_context* pContext, mal_device enableIOFlag = 0; } - status = ((mal_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, MAL_COREAUDIO_OUTPUT_BUS, &enableIOFlag, sizeof(enableIOFlag)); + status = ((mal_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, MA_COREAUDIO_OUTPUT_BUS, &enableIOFlag, sizeof(enableIOFlag)); if (status != noErr) { ((mal_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return mal_result_from_OSStatus(status); } enableIOFlag = (enableIOFlag == 0) ? 1 : 0; - status = ((mal_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, MAL_COREAUDIO_INPUT_BUS, &enableIOFlag, sizeof(enableIOFlag)); + status = ((mal_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, MA_COREAUDIO_INPUT_BUS, &enableIOFlag, sizeof(enableIOFlag)); if (status != noErr) { ((mal_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return mal_result_from_OSStatus(status); @@ -17366,8 +17366,8 @@ mal_result mal_device_init_internal__coreaudio(mal_context* pContext, mal_device // Set the device to use with this audio unit. This is only used on desktop since we are using defaults on mobile. -#if defined(MAL_APPLE_DESKTOP) - status = ((mal_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, (deviceType == mal_device_type_playback) ? MAL_COREAUDIO_OUTPUT_BUS : MAL_COREAUDIO_INPUT_BUS, &deviceObjectID, sizeof(AudioDeviceID)); +#if defined(MA_APPLE_DESKTOP) + status = ((mal_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, (deviceType == mal_device_type_playback) ? MA_COREAUDIO_OUTPUT_BUS : MA_COREAUDIO_INPUT_BUS, &deviceObjectID, sizeof(AudioDeviceID)); if (status != noErr) { ((mal_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return mal_result_from_OSStatus(result); @@ -17387,11 +17387,11 @@ mal_result mal_device_init_internal__coreaudio(mal_context* pContext, mal_device AudioStreamBasicDescription bestFormat; { AudioUnitScope formatScope = (deviceType == mal_device_type_playback) ? kAudioUnitScope_Input : kAudioUnitScope_Output; - AudioUnitElement formatElement = (deviceType == mal_device_type_playback) ? MAL_COREAUDIO_OUTPUT_BUS : MAL_COREAUDIO_INPUT_BUS; + AudioUnitElement formatElement = (deviceType == mal_device_type_playback) ? MA_COREAUDIO_OUTPUT_BUS : MA_COREAUDIO_INPUT_BUS; - #if defined(MAL_APPLE_DESKTOP) + #if defined(MA_APPLE_DESKTOP) result = mal_find_best_format__coreaudio(pContext, deviceObjectID, deviceType, pData->formatIn, pData->channelsIn, pData->sampleRateIn, pData->usingDefaultFormat, pData->usingDefaultChannels, pData->usingDefaultSampleRate, &bestFormat); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { ((mal_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return result; } @@ -17400,9 +17400,9 @@ mal_result mal_device_init_internal__coreaudio(mal_context* pContext, mal_device AudioStreamBasicDescription origFormat; UInt32 origFormatSize = sizeof(origFormat); if (deviceType == mal_device_type_playback) { - status = ((mal_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(pData->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, MAL_COREAUDIO_OUTPUT_BUS, &origFormat, &origFormatSize); + status = ((mal_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(pData->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, MA_COREAUDIO_OUTPUT_BUS, &origFormat, &origFormatSize); } else { - status = ((mal_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(pData->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, MAL_COREAUDIO_INPUT_BUS, &origFormat, &origFormatSize); + status = ((mal_AudioUnitGetProperty_proc)pContext->coreaudio.AudioUnitGetProperty)(pData->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, MA_COREAUDIO_INPUT_BUS, &origFormat, &origFormatSize); } if (status != noErr) { @@ -17445,14 +17445,14 @@ mal_result mal_device_init_internal__coreaudio(mal_context* pContext, mal_device #endif result = mal_format_from_AudioStreamBasicDescription(&bestFormat, &pData->formatOut); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { ((mal_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return result; } if (pData->formatOut == mal_format_unknown) { ((mal_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); - return MAL_FORMAT_NOT_SUPPORTED; + return MA_FORMAT_NOT_SUPPORTED; } pData->channelsOut = bestFormat.mChannelsPerFrame; @@ -17465,13 +17465,13 @@ mal_result mal_device_init_internal__coreaudio(mal_context* pContext, mal_device // this it looks like retrieving it from the AudioUnit will work. However, and this is where // it gets weird, it doesn't seem to work with capture devices, nor at all on iOS... Therefore // I'm going to fall back to a default assumption in these cases. -#if defined(MAL_APPLE_DESKTOP) +#if defined(MA_APPLE_DESKTOP) result = mal_get_AudioUnit_channel_map(pContext, pData->audioUnit, deviceType, pData->channelMapOut); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { #if 0 // Try falling back to the channel map from the AudioObject. result = mal_get_AudioObject_channel_map(pContext, deviceObjectID, deviceType, pData->channelMapOut); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } #else @@ -17488,14 +17488,14 @@ mal_result mal_device_init_internal__coreaudio(mal_context* pContext, mal_device // Buffer size. Not allowing this to be configurable on iOS. mal_uint32 actualBufferSizeInFrames = pData->bufferSizeInFramesIn; -#if defined(MAL_APPLE_DESKTOP) +#if defined(MA_APPLE_DESKTOP) if (actualBufferSizeInFrames == 0) { actualBufferSizeInFrames = mal_calculate_buffer_size_in_frames_from_milliseconds(pData->bufferSizeInMillisecondsIn, pData->sampleRateOut); } actualBufferSizeInFrames = actualBufferSizeInFrames / pData->periodsOut; result = mal_set_AudioObject_buffer_size_in_frames(pContext, deviceObjectID, deviceType, &actualBufferSizeInFrames); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -17515,7 +17515,7 @@ mal_result mal_device_init_internal__coreaudio(mal_context* pContext, mal_device // of the size of our buffer, or do it the other way around and set our buffer size to the kAudioUnitProperty_MaximumFramesPerSlice. { /*AudioUnitScope propScope = (deviceType == mal_device_type_playback) ? kAudioUnitScope_Input : kAudioUnitScope_Output; - AudioUnitElement propBus = (deviceType == mal_device_type_playback) ? MAL_COREAUDIO_OUTPUT_BUS : MAL_COREAUDIO_INPUT_BUS; + AudioUnitElement propBus = (deviceType == mal_device_type_playback) ? MA_COREAUDIO_OUTPUT_BUS : MA_COREAUDIO_INPUT_BUS; status = ((mal_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioUnitProperty_MaximumFramesPerSlice, propScope, propBus, &actualBufferSizeInFrames, sizeof(actualBufferSizeInFrames)); if (status != noErr) { @@ -17548,7 +17548,7 @@ mal_result mal_device_init_internal__coreaudio(mal_context* pContext, mal_device AudioBufferList* pBufferList = (AudioBufferList*)mal_malloc(allocationSize); if (pBufferList == NULL) { ((mal_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } if (isInterleaved) { @@ -17573,14 +17573,14 @@ mal_result mal_device_init_internal__coreaudio(mal_context* pContext, mal_device callbackInfo.inputProcRefCon = pDevice_DoNotReference; if (deviceType == mal_device_type_playback) { callbackInfo.inputProc = mal_on_output__coreaudio; - status = ((mal_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Global, MAL_COREAUDIO_OUTPUT_BUS, &callbackInfo, sizeof(callbackInfo)); + status = ((mal_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Global, MA_COREAUDIO_OUTPUT_BUS, &callbackInfo, sizeof(callbackInfo)); if (status != noErr) { ((mal_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return mal_result_from_OSStatus(status); } } else { callbackInfo.inputProc = mal_on_input__coreaudio; - status = ((mal_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, MAL_COREAUDIO_INPUT_BUS, &callbackInfo, sizeof(callbackInfo)); + status = ((mal_AudioUnitSetProperty_proc)pContext->coreaudio.AudioUnitSetProperty)(pData->audioUnit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, MA_COREAUDIO_INPUT_BUS, &callbackInfo, sizeof(callbackInfo)); if (status != noErr) { ((mal_AudioComponentInstanceDispose_proc)pContext->coreaudio.AudioComponentInstanceDispose)(pData->audioUnit); return mal_result_from_OSStatus(status); @@ -17606,13 +17606,13 @@ mal_result mal_device_init_internal__coreaudio(mal_context* pContext, mal_device } // Grab the name. -#if defined(MAL_APPLE_DESKTOP) +#if defined(MA_APPLE_DESKTOP) mal_get_AudioObject_name(pContext, deviceObjectID, sizeof(pData->deviceName), pData->deviceName); #else if (deviceType == mal_device_type_playback) { - mal_strcpy_s(pData->deviceName, sizeof(pData->deviceName), MAL_DEFAULT_PLAYBACK_DEVICE_NAME); + mal_strcpy_s(pData->deviceName, sizeof(pData->deviceName), MA_DEFAULT_PLAYBACK_DEVICE_NAME); } else { - mal_strcpy_s(pData->deviceName, sizeof(pData->deviceName), MAL_DEFAULT_CAPTURE_DEVICE_NAME); + mal_strcpy_s(pData->deviceName, sizeof(pData->deviceName), MA_DEFAULT_CAPTURE_DEVICE_NAME); } #endif @@ -17623,7 +17623,7 @@ mal_result mal_device_reinit_internal__coreaudio(mal_device* pDevice, mal_device { /* This should only be called for playback or capture, not duplex. */ if (deviceType == mal_device_type_duplex) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_device_init_internal_data__coreaudio data; @@ -17637,7 +17637,7 @@ mal_result mal_device_reinit_internal__coreaudio(mal_device* pDevice, mal_device data.usingDefaultSampleRate = pDevice->usingDefaultSampleRate; data.usingDefaultChannelMap = pDevice->capture.usingDefaultChannelMap; data.shareMode = pDevice->capture.shareMode; - data.registerStopEvent = MAL_TRUE; + data.registerStopEvent = MA_TRUE; if (disposePreviousAudioUnit) { ((mal_AudioOutputUnitStop_proc)pDevice->pContext->coreaudio.AudioOutputUnitStop)((AudioUnit)pDevice->coreaudio.audioUnitCapture); @@ -17647,7 +17647,7 @@ mal_result mal_device_reinit_internal__coreaudio(mal_device* pDevice, mal_device mal_free(pDevice->coreaudio.pAudioBufferList); } - #if defined(MAL_APPLE_DESKTOP) + #if defined(MA_APPLE_DESKTOP) pDevice->coreaudio.deviceObjectIDCapture = (mal_uint32)data.deviceObjectID; #endif pDevice->coreaudio.audioUnitCapture = (mal_ptr)data.audioUnit; @@ -17670,7 +17670,7 @@ mal_result mal_device_reinit_internal__coreaudio(mal_device* pDevice, mal_device ((mal_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitPlayback); } - #if defined(MAL_APPLE_DESKTOP) + #if defined(MA_APPLE_DESKTOP) pDevice->coreaudio.deviceObjectIDPlayback = (mal_uint32)data.deviceObjectID; #endif pDevice->coreaudio.audioUnitPlayback = (mal_ptr)data.audioUnit; @@ -17680,11 +17680,11 @@ mal_result mal_device_reinit_internal__coreaudio(mal_device* pDevice, mal_device data.periodsIn = pDevice->coreaudio.originalPeriods; mal_result result = mal_device_init_internal__coreaudio(pDevice->pContext, deviceType, NULL, &data, (void*)pDevice); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -17699,7 +17699,7 @@ mal_result mal_device_init__coreaudio(mal_context* pContext, const mal_device_co /* No exclusive mode with the Core Audio backend for now. */ if (((pConfig->deviceType == mal_device_type_capture || pConfig->deviceType == mal_device_type_duplex) && pConfig->capture.shareMode == mal_share_mode_exclusive) || ((pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) && pConfig->playback.shareMode == mal_share_mode_exclusive)) { - return MAL_SHARE_MODE_NOT_SUPPORTED; + return MA_SHARE_MODE_NOT_SUPPORTED; } /* Capture needs to be initialized first. */ @@ -17716,15 +17716,15 @@ mal_result mal_device_init__coreaudio(mal_context* pContext, const mal_device_co data.shareMode = pConfig->capture.shareMode; data.bufferSizeInFramesIn = pConfig->bufferSizeInFrames; data.bufferSizeInMillisecondsIn = pConfig->bufferSizeInMilliseconds; - data.registerStopEvent = MAL_TRUE; + data.registerStopEvent = MA_TRUE; mal_result result = mal_device_init_internal__coreaudio(pDevice->pContext, mal_device_type_capture, pConfig->capture.pDeviceID, &data, (void*)pDevice); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } pDevice->coreaudio.isDefaultCaptureDevice = (pConfig->capture.pDeviceID == NULL); - #if defined(MAL_APPLE_DESKTOP) + #if defined(MA_APPLE_DESKTOP) pDevice->coreaudio.deviceObjectIDCapture = (mal_uint32)data.deviceObjectID; #endif pDevice->coreaudio.audioUnitCapture = (mal_ptr)data.audioUnit; @@ -17738,7 +17738,7 @@ mal_result mal_device_init__coreaudio(mal_context* pContext, const mal_device_co pDevice->capture.internalPeriods = data.periodsOut; // TODO: This needs to be made global. - #if defined(MAL_APPLE_DESKTOP) + #if defined(MA_APPLE_DESKTOP) // If we are using the default device we'll need to listen for changes to the system's default device so we can seemlessly // switch the device in the background. if (pConfig->capture.pDeviceID == NULL) { @@ -17768,16 +17768,16 @@ mal_result mal_device_init__coreaudio(mal_context* pContext, const mal_device_co if (pConfig->deviceType == mal_device_type_duplex) { data.bufferSizeInFramesIn = pDevice->capture.internalBufferSizeInFrames; data.periodsIn = pDevice->capture.internalPeriods; - data.registerStopEvent = MAL_FALSE; + data.registerStopEvent = MA_FALSE; } else { data.bufferSizeInFramesIn = pConfig->bufferSizeInFrames; data.bufferSizeInMillisecondsIn = pConfig->bufferSizeInMilliseconds; data.periodsIn = pConfig->periods; - data.registerStopEvent = MAL_TRUE; + data.registerStopEvent = MA_TRUE; } mal_result result = mal_device_init_internal__coreaudio(pDevice->pContext, mal_device_type_playback, pConfig->playback.pDeviceID, &data, (void*)pDevice); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { if (pConfig->deviceType == mal_device_type_duplex) { ((mal_AudioComponentInstanceDispose_proc)pDevice->pContext->coreaudio.AudioComponentInstanceDispose)((AudioUnit)pDevice->coreaudio.audioUnitCapture); if (pDevice->coreaudio.pAudioBufferList) { @@ -17788,7 +17788,7 @@ mal_result mal_device_init__coreaudio(mal_context* pContext, const mal_device_co } pDevice->coreaudio.isDefaultPlaybackDevice = (pConfig->playback.pDeviceID == NULL); - #if defined(MAL_APPLE_DESKTOP) + #if defined(MA_APPLE_DESKTOP) pDevice->coreaudio.deviceObjectIDPlayback = (mal_uint32)data.deviceObjectID; #endif pDevice->coreaudio.audioUnitPlayback = (mal_ptr)data.audioUnit; @@ -17801,7 +17801,7 @@ mal_result mal_device_init__coreaudio(mal_context* pContext, const mal_device_co pDevice->playback.internalPeriods = data.periodsOut; // TODO: This needs to be made global. - #if defined(MAL_APPLE_DESKTOP) + #if defined(MA_APPLE_DESKTOP) // If we are using the default device we'll need to listen for changes to the system's default device so we can seemlessly // switch the device in the background. if (pConfig->playback.pDeviceID == NULL) { @@ -17828,12 +17828,12 @@ mal_result mal_device_init__coreaudio(mal_context* pContext, const mal_device_co if (pConfig->deviceType == mal_device_type_duplex) { mal_uint32 rbSizeInFrames = (mal_uint32)mal_calculate_frame_count_after_src(pDevice->sampleRate, pDevice->capture.internalSampleRate, pDevice->capture.internalBufferSizeInFrames); mal_result result = mal_pcm_rb_init(pDevice->capture.format, pDevice->capture.channels, rbSizeInFrames, NULL, &pDevice->coreaudio.duplexRB); - if (result != MAL_SUCCESS) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[Core Audio] Failed to initialize ring buffer.", result); + if (result != MA_SUCCESS) { + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[Core Audio] Failed to initialize ring buffer.", result); } } - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -17858,7 +17858,7 @@ mal_result mal_device_start__coreaudio(mal_device* pDevice) } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_stop__coreaudio(mal_device* pDevice) @@ -17881,7 +17881,7 @@ mal_result mal_device_stop__coreaudio(mal_device* pDevice) /* We need to wait for the callback to finish before returning. */ mal_event_wait(&pDevice->coreaudio.stopEvent); - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -17890,21 +17890,21 @@ mal_result mal_context_uninit__coreaudio(mal_context* pContext) mal_assert(pContext != NULL); mal_assert(pContext->backend == mal_backend_coreaudio); -#if !defined(MAL_NO_RUNTIME_LINKING) && !defined(MAL_APPLE_MOBILE) +#if !defined(MA_NO_RUNTIME_LINKING) && !defined(MA_APPLE_MOBILE) mal_dlclose(pContext->coreaudio.hAudioUnit); mal_dlclose(pContext->coreaudio.hCoreAudio); mal_dlclose(pContext->coreaudio.hCoreFoundation); #endif (void)pContext; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_init__coreaudio(mal_context* pContext) { mal_assert(pContext != NULL); -#if defined(MAL_APPLE_MOBILE) +#if defined(MA_APPLE_MOBILE) @autoreleasepool { AVAudioSession* pAudioSession = [AVAudioSession sharedInstance]; mal_assert(pAudioSession != NULL); @@ -17913,17 +17913,17 @@ mal_result mal_context_init__coreaudio(mal_context* pContext) // By default we want miniaudio to use the speakers instead of the receiver. In the future this may // be customizable. - mal_bool32 useSpeakers = MAL_TRUE; + mal_bool32 useSpeakers = MA_TRUE; if (useSpeakers) { [pAudioSession overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:nil]; } } #endif -#if !defined(MAL_NO_RUNTIME_LINKING) && !defined(MAL_APPLE_MOBILE) +#if !defined(MA_NO_RUNTIME_LINKING) && !defined(MA_APPLE_MOBILE) pContext->coreaudio.hCoreFoundation = mal_dlopen("CoreFoundation.framework/CoreFoundation"); if (pContext->coreaudio.hCoreFoundation == NULL) { - return MAL_API_NOT_FOUND; + return MA_API_NOT_FOUND; } pContext->coreaudio.CFStringGetCString = mal_dlsym(pContext->coreaudio.hCoreFoundation, "CFStringGetCString"); @@ -17932,7 +17932,7 @@ mal_result mal_context_init__coreaudio(mal_context* pContext) pContext->coreaudio.hCoreAudio = mal_dlopen("CoreAudio.framework/CoreAudio"); if (pContext->coreaudio.hCoreAudio == NULL) { mal_dlclose(pContext->coreaudio.hCoreFoundation); - return MAL_API_NOT_FOUND; + return MA_API_NOT_FOUND; } pContext->coreaudio.AudioObjectGetPropertyData = mal_dlsym(pContext->coreaudio.hCoreAudio, "AudioObjectGetPropertyData"); @@ -17949,7 +17949,7 @@ mal_result mal_context_init__coreaudio(mal_context* pContext) if (pContext->coreaudio.hAudioUnit == NULL) { mal_dlclose(pContext->coreaudio.hCoreAudio); mal_dlclose(pContext->coreaudio.hCoreFoundation); - return MAL_API_NOT_FOUND; + return MA_API_NOT_FOUND; } if (mal_dlsym(pContext->coreaudio.hAudioUnit, "AudioComponentFindNext") == NULL) { @@ -17959,7 +17959,7 @@ mal_result mal_context_init__coreaudio(mal_context* pContext) if (pContext->coreaudio.hAudioUnit == NULL) { mal_dlclose(pContext->coreaudio.hCoreAudio); mal_dlclose(pContext->coreaudio.hCoreFoundation); - return MAL_API_NOT_FOUND; + return MA_API_NOT_FOUND; } } @@ -17977,7 +17977,7 @@ mal_result mal_context_init__coreaudio(mal_context* pContext) #else pContext->coreaudio.CFStringGetCString = (mal_proc)CFStringGetCString; - #if defined(MAL_APPLE_DESKTOP) + #if defined(MA_APPLE_DESKTOP) pContext->coreaudio.AudioObjectGetPropertyData = (mal_proc)AudioObjectGetPropertyData; pContext->coreaudio.AudioObjectGetPropertyDataSize = (mal_proc)AudioObjectGetPropertyDataSize; pContext->coreaudio.AudioObjectSetPropertyData = (mal_proc)AudioObjectSetPropertyData; @@ -17997,7 +17997,7 @@ mal_result mal_context_init__coreaudio(mal_context* pContext) pContext->coreaudio.AudioUnitRender = (mal_proc)AudioUnitRender; #endif - pContext->isBackendAsynchronous = MAL_TRUE; + pContext->isBackendAsynchronous = MA_TRUE; pContext->onUninit = mal_context_uninit__coreaudio; pContext->onDeviceIDEqual = mal_context_is_device_id_equal__coreaudio; @@ -18011,7 +18011,7 @@ mal_result mal_context_init__coreaudio(mal_context* pContext) // Audio component. AudioComponentDescription desc; desc.componentType = kAudioUnitType_Output; -#if defined(MAL_APPLE_DESKTOP) +#if defined(MA_APPLE_DESKTOP) desc.componentSubType = kAudioUnitSubType_HALOutput; #else desc.componentSubType = kAudioUnitSubType_RemoteIO; @@ -18022,15 +18022,15 @@ mal_result mal_context_init__coreaudio(mal_context* pContext) pContext->coreaudio.component = ((mal_AudioComponentFindNext_proc)pContext->coreaudio.AudioComponentFindNext)(NULL, &desc); if (pContext->coreaudio.component == NULL) { -#if !defined(MAL_NO_RUNTIME_LINKING) && !defined(MAL_APPLE_MOBILE) +#if !defined(MA_NO_RUNTIME_LINKING) && !defined(MA_APPLE_MOBILE) mal_dlclose(pContext->coreaudio.hAudioUnit); mal_dlclose(pContext->coreaudio.hCoreAudio); mal_dlclose(pContext->coreaudio.hCoreFoundation); #endif - return MAL_FAILED_TO_INIT_BACKEND; + return MA_FAILED_TO_INIT_BACKEND; } - return MAL_SUCCESS; + return MA_SUCCESS; } #endif // Core Audio @@ -18041,7 +18041,7 @@ mal_result mal_context_init__coreaudio(mal_context* pContext) // sndio Backend // /////////////////////////////////////////////////////////////////////////////// -#ifdef MAL_HAS_SNDIO +#ifdef MA_HAS_SNDIO #include #include @@ -18057,13 +18057,13 @@ mal_result mal_context_init__coreaudio(mal_context* pContext) //#include //#endif -#define MAL_SIO_DEVANY "default" -#define MAL_SIO_PLAY 1 -#define MAL_SIO_REC 2 -#define MAL_SIO_NENC 8 -#define MAL_SIO_NCHAN 8 -#define MAL_SIO_NRATE 16 -#define MAL_SIO_NCONF 4 +#define MA_SIO_DEVANY "default" +#define MA_SIO_PLAY 1 +#define MA_SIO_REC 2 +#define MA_SIO_NENC 8 +#define MA_SIO_NCHAN 8 +#define MA_SIO_NRATE 16 +#define MA_SIO_NCONF 4 struct mal_sio_hdl; // <-- Opaque @@ -18104,13 +18104,13 @@ struct mal_sio_conf struct mal_sio_cap { - struct mal_sio_enc enc[MAL_SIO_NENC]; - unsigned int rchan[MAL_SIO_NCHAN]; - unsigned int pchan[MAL_SIO_NCHAN]; - unsigned int rate[MAL_SIO_NRATE]; + struct mal_sio_enc enc[MA_SIO_NENC]; + unsigned int rchan[MA_SIO_NCHAN]; + unsigned int pchan[MA_SIO_NCHAN]; + unsigned int rate[MA_SIO_NRATE]; int __pad[7]; unsigned int nconf; - struct mal_sio_conf confs[MAL_SIO_NCONF]; + struct mal_sio_conf confs[MA_SIO_NCONF]; }; typedef struct mal_sio_hdl* (* mal_sio_open_proc) (const char*, unsigned int, int); @@ -18156,7 +18156,7 @@ mal_format mal_find_best_format_from_sio_cap__sndio(struct mal_sio_cap* caps) mal_format bestFormat = mal_format_unknown; for (unsigned int iConfig = 0; iConfig < caps->nconf; iConfig += 1) { - for (unsigned int iEncoding = 0; iEncoding < MAL_SIO_NENC; iEncoding += 1) { + for (unsigned int iEncoding = 0; iEncoding < MA_SIO_NENC; iEncoding += 1) { if ((caps->confs[iConfig].enc & (1UL << iEncoding)) == 0) { continue; } @@ -18193,7 +18193,7 @@ mal_uint32 mal_find_best_channels_from_sio_cap__sndio(struct mal_sio_cap* caps, mal_uint32 maxChannels = 0; for (unsigned int iConfig = 0; iConfig < caps->nconf; iConfig += 1) { // The encoding should be of requiredFormat. - for (unsigned int iEncoding = 0; iEncoding < MAL_SIO_NENC; iEncoding += 1) { + for (unsigned int iEncoding = 0; iEncoding < MA_SIO_NENC; iEncoding += 1) { if ((caps->confs[iConfig].enc & (1UL << iEncoding)) == 0) { continue; } @@ -18209,7 +18209,7 @@ mal_uint32 mal_find_best_channels_from_sio_cap__sndio(struct mal_sio_cap* caps, } // Getting here means the format is supported. Iterate over each channel count and grab the biggest one. - for (unsigned int iChannel = 0; iChannel < MAL_SIO_NCHAN; iChannel += 1) { + for (unsigned int iChannel = 0; iChannel < MA_SIO_NCHAN; iChannel += 1) { unsigned int chan = 0; if (deviceType == mal_device_type_playback) { chan = caps->confs[iConfig].pchan; @@ -18243,14 +18243,14 @@ mal_uint32 mal_find_best_sample_rate_from_sio_cap__sndio(struct mal_sio_cap* cap mal_assert(caps != NULL); mal_assert(requiredFormat != mal_format_unknown); mal_assert(requiredChannels > 0); - mal_assert(requiredChannels <= MAL_MAX_CHANNELS); + mal_assert(requiredChannels <= MA_MAX_CHANNELS); mal_uint32 firstSampleRate = 0; // <-- If the device does not support a standard rate we'll fall back to the first one that's found. mal_uint32 bestSampleRate = 0; for (unsigned int iConfig = 0; iConfig < caps->nconf; iConfig += 1) { // The encoding should be of requiredFormat. - for (unsigned int iEncoding = 0; iEncoding < MAL_SIO_NENC; iEncoding += 1) { + for (unsigned int iEncoding = 0; iEncoding < MA_SIO_NENC; iEncoding += 1) { if ((caps->confs[iConfig].enc & (1UL << iEncoding)) == 0) { continue; } @@ -18266,7 +18266,7 @@ mal_uint32 mal_find_best_sample_rate_from_sio_cap__sndio(struct mal_sio_cap* cap } // Getting here means the format is supported. Iterate over each channel count and grab the biggest one. - for (unsigned int iChannel = 0; iChannel < MAL_SIO_NCHAN; iChannel += 1) { + for (unsigned int iChannel = 0; iChannel < MA_SIO_NCHAN; iChannel += 1) { unsigned int chan = 0; if (deviceType == mal_device_type_playback) { chan = caps->confs[iConfig].pchan; @@ -18290,7 +18290,7 @@ mal_uint32 mal_find_best_sample_rate_from_sio_cap__sndio(struct mal_sio_cap* cap } // Getting here means we have found a compatible encoding/channel pair. - for (unsigned int iRate = 0; iRate < MAL_SIO_NRATE; iRate += 1) { + for (unsigned int iRate = 0; iRate < MA_SIO_NRATE; iRate += 1) { mal_uint32 rate = (mal_uint32)caps->rate[iRate]; if (firstSampleRate == 0) { @@ -18337,18 +18337,18 @@ mal_result mal_context_enumerate_devices__sndio(mal_context* pContext, mal_enum_ // sndio doesn't seem to have a good device enumeration API, so I'm therefore only enumerating // over default devices for now. - mal_bool32 isTerminating = MAL_FALSE; + mal_bool32 isTerminating = MA_FALSE; struct mal_sio_hdl* handle; // Playback. if (!isTerminating) { - handle = ((mal_sio_open_proc)pContext->sndio.sio_open)(MAL_SIO_DEVANY, MAL_SIO_PLAY, 0); + handle = ((mal_sio_open_proc)pContext->sndio.sio_open)(MA_SIO_DEVANY, MA_SIO_PLAY, 0); if (handle != NULL) { // Supports playback. mal_device_info deviceInfo; mal_zero_object(&deviceInfo); - mal_strcpy_s(deviceInfo.id.sndio, sizeof(deviceInfo.id.sndio), MAL_SIO_DEVANY); - mal_strcpy_s(deviceInfo.name, sizeof(deviceInfo.name), MAL_DEFAULT_PLAYBACK_DEVICE_NAME); + mal_strcpy_s(deviceInfo.id.sndio, sizeof(deviceInfo.id.sndio), MA_SIO_DEVANY); + mal_strcpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME); isTerminating = !callback(pContext, mal_device_type_playback, &deviceInfo, pUserData); @@ -18358,13 +18358,13 @@ mal_result mal_context_enumerate_devices__sndio(mal_context* pContext, mal_enum_ // Capture. if (!isTerminating) { - handle = ((mal_sio_open_proc)pContext->sndio.sio_open)(MAL_SIO_DEVANY, MAL_SIO_REC, 0); + handle = ((mal_sio_open_proc)pContext->sndio.sio_open)(MA_SIO_DEVANY, MA_SIO_REC, 0); if (handle != NULL) { // Supports capture. mal_device_info deviceInfo; mal_zero_object(&deviceInfo); mal_strcpy_s(deviceInfo.id.sndio, sizeof(deviceInfo.id.sndio), "default"); - mal_strcpy_s(deviceInfo.name, sizeof(deviceInfo.name), MAL_DEFAULT_CAPTURE_DEVICE_NAME); + mal_strcpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME); isTerminating = !callback(pContext, mal_device_type_capture, &deviceInfo, pUserData); @@ -18372,7 +18372,7 @@ mal_result mal_context_enumerate_devices__sndio(mal_context* pContext, mal_enum_ } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_get_device_info__sndio(mal_context* pContext, mal_device_type deviceType, const mal_device_id* pDeviceID, mal_share_mode shareMode, mal_device_info* pDeviceInfo) @@ -18383,27 +18383,27 @@ mal_result mal_context_get_device_info__sndio(mal_context* pContext, mal_device_ // We need to open the device before we can get information about it. char devid[256]; if (pDeviceID == NULL) { - mal_strcpy_s(devid, sizeof(devid), MAL_SIO_DEVANY); - mal_strcpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), (deviceType == mal_device_type_playback) ? MAL_DEFAULT_PLAYBACK_DEVICE_NAME : MAL_DEFAULT_CAPTURE_DEVICE_NAME); + mal_strcpy_s(devid, sizeof(devid), MA_SIO_DEVANY); + mal_strcpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), (deviceType == mal_device_type_playback) ? MA_DEFAULT_PLAYBACK_DEVICE_NAME : MA_DEFAULT_CAPTURE_DEVICE_NAME); } else { mal_strcpy_s(devid, sizeof(devid), pDeviceID->sndio); mal_strcpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), devid); } - struct mal_sio_hdl* handle = ((mal_sio_open_proc)pContext->sndio.sio_open)(devid, (deviceType == mal_device_type_playback) ? MAL_SIO_PLAY : MAL_SIO_REC, 0); + struct mal_sio_hdl* handle = ((mal_sio_open_proc)pContext->sndio.sio_open)(devid, (deviceType == mal_device_type_playback) ? MA_SIO_PLAY : MA_SIO_REC, 0); if (handle == NULL) { - return MAL_NO_DEVICE; + return MA_NO_DEVICE; } struct mal_sio_cap caps; if (((mal_sio_getcap_proc)pContext->sndio.sio_getcap)(handle, &caps) == 0) { - return MAL_ERROR; + return MA_ERROR; } for (unsigned int iConfig = 0; iConfig < caps.nconf; iConfig += 1) { // The main thing we care about is that the encoding is supported by miniaudio. If it is, we want to give // preference to some formats over others. - for (unsigned int iEncoding = 0; iEncoding < MAL_SIO_NENC; iEncoding += 1) { + for (unsigned int iEncoding = 0; iEncoding < MA_SIO_NENC; iEncoding += 1) { if ((caps.confs[iConfig].enc & (1UL << iEncoding)) == 0) { continue; } @@ -18419,10 +18419,10 @@ mal_result mal_context_get_device_info__sndio(mal_context* pContext, mal_device_ } // Add this format if it doesn't already exist. - mal_bool32 formatExists = MAL_FALSE; + mal_bool32 formatExists = MA_FALSE; for (mal_uint32 iExistingFormat = 0; iExistingFormat < pDeviceInfo->formatCount; iExistingFormat += 1) { if (pDeviceInfo->formats[iExistingFormat] == format) { - formatExists = MAL_TRUE; + formatExists = MA_TRUE; break; } } @@ -18433,7 +18433,7 @@ mal_result mal_context_get_device_info__sndio(mal_context* pContext, mal_device_ } // Channels. - for (unsigned int iChannel = 0; iChannel < MAL_SIO_NCHAN; iChannel += 1) { + for (unsigned int iChannel = 0; iChannel < MA_SIO_NCHAN; iChannel += 1) { unsigned int chan = 0; if (deviceType == mal_device_type_playback) { chan = caps.confs[iConfig].pchan; @@ -18461,7 +18461,7 @@ mal_result mal_context_get_device_info__sndio(mal_context* pContext, mal_device_ } // Sample rates. - for (unsigned int iRate = 0; iRate < MAL_SIO_NRATE; iRate += 1) { + for (unsigned int iRate = 0; iRate < MA_SIO_NRATE; iRate += 1) { if ((caps.confs[iConfig].rate & (1UL << iRate)) != 0) { unsigned int rate = caps.rate[iRate]; if (pDeviceInfo->minSampleRate > rate) { @@ -18475,7 +18475,7 @@ mal_result mal_context_get_device_info__sndio(mal_context* pContext, mal_device_ } ((mal_sio_close_proc)pContext->sndio.sio_close)(handle); - return MAL_SUCCESS; + return MA_SUCCESS; } void mal_device_uninit__sndio(mal_device* pDevice) @@ -18515,33 +18515,33 @@ mal_result mal_device_init_handle__sndio(mal_context* pContext, const mal_device mal_assert(pDevice != NULL); if (deviceType == mal_device_type_capture) { - openFlags = MAL_SIO_REC; + openFlags = MA_SIO_REC; pDeviceID = pConfig->capture.pDeviceID; format = pConfig->capture.format; channels = pConfig->capture.channels; sampleRate = pConfig->sampleRate; } else { - openFlags = MAL_SIO_PLAY; + openFlags = MA_SIO_PLAY; pDeviceID = pConfig->playback.pDeviceID; format = pConfig->playback.format; channels = pConfig->playback.channels; sampleRate = pConfig->sampleRate; } - pDeviceName = MAL_SIO_DEVANY; + pDeviceName = MA_SIO_DEVANY; if (pDeviceID != NULL) { pDeviceName = pDeviceID->sndio; } handle = (mal_ptr)((mal_sio_open_proc)pContext->sndio.sio_open)(pDeviceName, openFlags, 0); if (handle == NULL) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[sndio] Failed to open device.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to open device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } /* We need to retrieve the device caps to determine the most appropriate format to use. */ if (((mal_sio_getcap_proc)pContext->sndio.sio_getcap)((struct mal_sio_hdl*)handle, &caps) == 0) { ((mal_sio_close_proc)pContext->sndio.sio_close)((struct mal_sio_hdl*)handle); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[sndio] Failed to retrieve device caps.", MAL_ERROR); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to retrieve device caps.", MA_ERROR); } /* @@ -18631,11 +18631,11 @@ mal_result mal_device_init_handle__sndio(mal_context* pContext, const mal_device if (((mal_sio_setpar_proc)pContext->sndio.sio_setpar)((struct mal_sio_hdl*)handle, &par) == 0) { ((mal_sio_close_proc)pContext->sndio.sio_close)((struct mal_sio_hdl*)handle); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[sndio] Failed to set buffer size.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to set buffer size.", MA_FORMAT_NOT_SUPPORTED); } if (((mal_sio_getpar_proc)pContext->sndio.sio_getpar)((struct mal_sio_hdl*)handle, &par) == 0) { ((mal_sio_close_proc)pContext->sndio.sio_close)((struct mal_sio_hdl*)handle); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[sndio] Failed to retrieve buffer size.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to retrieve buffer size.", MA_FORMAT_NOT_SUPPORTED); } internalFormat = mal_format_from_sio_enc__sndio(par.bits, par.bps, par.sig, par.le, par.msb); @@ -18662,7 +18662,7 @@ mal_result mal_device_init_handle__sndio(mal_context* pContext, const mal_device pDevice->playback.internalPeriods = internalPeriods; } -#ifdef MAL_DEBUG_OUTPUT +#ifdef MA_DEBUG_OUTPUT printf("DEVICE INFO\n"); printf(" Format: %s\n", mal_get_format_name(internalFormat)); printf(" Channels: %d\n", internalChannels); @@ -18673,7 +18673,7 @@ mal_result mal_device_init_handle__sndio(mal_context* pContext, const mal_device printf(" round: %d\n", par.round); #endif - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_init__sndio(mal_context* pContext, const mal_device_config* pConfig, mal_device* pDevice) @@ -18684,19 +18684,19 @@ mal_result mal_device_init__sndio(mal_context* pContext, const mal_device_config if (pConfig->deviceType == mal_device_type_capture || pConfig->deviceType == mal_device_type_duplex) { mal_result result = mal_device_init_handle__sndio(pContext, pConfig, mal_device_type_capture, pDevice); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } if (pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) { mal_result result = mal_device_init_handle__sndio(pContext, pConfig, mal_device_type_playback, pDevice); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_stop__sndio(mal_device* pDevice) @@ -18705,15 +18705,15 @@ mal_result mal_device_stop__sndio(mal_device* pDevice) if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { ((mal_sio_stop_proc)pDevice->pContext->sndio.sio_stop)((struct mal_sio_hdl*)pDevice->sndio.handleCapture); - mal_atomic_exchange_32(&pDevice->sndio.isStartedCapture, MAL_FALSE); + mal_atomic_exchange_32(&pDevice->sndio.isStartedCapture, MA_FALSE); } if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) { ((mal_sio_stop_proc)pDevice->pContext->sndio.sio_stop)((struct mal_sio_hdl*)pDevice->sndio.handlePlayback); - mal_atomic_exchange_32(&pDevice->sndio.isStartedPlayback, MAL_FALSE); + mal_atomic_exchange_32(&pDevice->sndio.isStartedPlayback, MA_FALSE); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_write__sndio(mal_device* pDevice, const void* pPCMFrames, mal_uint32 frameCount) @@ -18722,15 +18722,15 @@ mal_result mal_device_write__sndio(mal_device* pDevice, const void* pPCMFrames, if (!pDevice->sndio.isStartedPlayback) { ((mal_sio_start_proc)pDevice->pContext->sndio.sio_start)((struct mal_sio_hdl*)pDevice->sndio.handlePlayback); /* <-- Doesn't actually playback until data is written. */ - mal_atomic_exchange_32(&pDevice->sndio.isStartedPlayback, MAL_TRUE); + mal_atomic_exchange_32(&pDevice->sndio.isStartedPlayback, MA_TRUE); } result = ((mal_sio_write_proc)pDevice->pContext->sndio.sio_write)((struct mal_sio_hdl*)pDevice->sndio.handlePlayback, pPCMFrames, frameCount * mal_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels)); if (result == 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[sndio] Failed to send data from the client to the device.", MAL_FAILED_TO_SEND_DATA_TO_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to send data from the client to the device.", MA_FAILED_TO_SEND_DATA_TO_DEVICE); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_read__sndio(mal_device* pDevice, void* pPCMFrames, mal_uint32 frameCount) @@ -18739,15 +18739,15 @@ mal_result mal_device_read__sndio(mal_device* pDevice, void* pPCMFrames, mal_uin if (!pDevice->sndio.isStartedCapture) { ((mal_sio_start_proc)pDevice->pContext->sndio.sio_start)((struct mal_sio_hdl*)pDevice->sndio.handleCapture); /* <-- Doesn't actually playback until data is written. */ - mal_atomic_exchange_32(&pDevice->sndio.isStartedCapture, MAL_TRUE); + mal_atomic_exchange_32(&pDevice->sndio.isStartedCapture, MA_TRUE); } result = ((mal_sio_read_proc)pDevice->pContext->sndio.sio_read)((struct mal_sio_hdl*)pDevice->sndio.handleCapture, pPCMFrames, frameCount * mal_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels)); if (result == 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[sndio] Failed to read data from the device to be sent to the device.", MAL_FAILED_TO_SEND_DATA_TO_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[sndio] Failed to read data from the device to be sent to the device.", MA_FAILED_TO_SEND_DATA_TO_DEVICE); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_uninit__sndio(mal_context* pContext) @@ -18756,14 +18756,14 @@ mal_result mal_context_uninit__sndio(mal_context* pContext) mal_assert(pContext->backend == mal_backend_sndio); (void)pContext; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_init__sndio(mal_context* pContext) { mal_assert(pContext != NULL); -#ifndef MAL_NO_RUNTIME_LINKING +#ifndef MA_NO_RUNTIME_LINKING // libpulse.so const char* libsndioNames[] = { "libsndio.so" @@ -18777,7 +18777,7 @@ mal_result mal_context_init__sndio(mal_context* pContext) } if (pContext->sndio.sndioSO == NULL) { - return MAL_NO_BACKEND; + return MA_NO_BACKEND; } pContext->sndio.sio_open = (mal_proc)mal_dlsym(pContext->sndio.sndioSO, "sio_open"); @@ -18814,7 +18814,7 @@ mal_result mal_context_init__sndio(mal_context* pContext) pContext->onDeviceWrite = mal_device_write__sndio; pContext->onDeviceRead = mal_device_read__sndio; - return MAL_SUCCESS; + return MA_SUCCESS; } #endif // sndio @@ -18825,7 +18825,7 @@ mal_result mal_context_init__sndio(mal_context* pContext) // audio(4) Backend // /////////////////////////////////////////////////////////////////////////////// -#ifdef MAL_HAS_AUDIO4 +#ifdef MA_HAS_AUDIO4 #include #include #include @@ -18837,7 +18837,7 @@ mal_result mal_context_init__sndio(mal_context* pContext) #if defined(__OpenBSD__) #include #if defined(OpenBSD) && OpenBSD >= 201709 - #define MAL_AUDIO4_USE_NEW_API + #define MA_AUDIO4_USE_NEW_API #endif #endif @@ -18863,23 +18863,23 @@ mal_result mal_extract_device_index_from_id__audio4(const char* id, const char* size_t idLen = strlen(id); size_t baseLen = strlen(base); if (idLen <= baseLen) { - return MAL_ERROR; // Doesn't look like the id starts with the base. + return MA_ERROR; // Doesn't look like the id starts with the base. } if (strncmp(id, base, baseLen) != 0) { - return MAL_ERROR; // ID does not begin with base. + return MA_ERROR; // ID does not begin with base. } const char* deviceIndexStr = id + baseLen; if (deviceIndexStr[0] == '\0') { - return MAL_ERROR; // No index specified in the ID. + return MA_ERROR; // No index specified in the ID. } if (pIndexOut) { *pIndexOut = atoi(deviceIndexStr); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_bool32 mal_context_is_device_id_equal__audio4(mal_context* pContext, const mal_device_id* pID0, const mal_device_id* pID1) @@ -18892,7 +18892,7 @@ mal_bool32 mal_context_is_device_id_equal__audio4(mal_context* pContext, const m return mal_strcmp(pID0->audio4, pID1->audio4) == 0; } -#if !defined(MAL_AUDIO4_USE_NEW_API) /* Old API */ +#if !defined(MA_AUDIO4_USE_NEW_API) /* Old API */ mal_format mal_format_from_encoding__audio4(unsigned int encoding, unsigned int precision) { if (precision == 8 && (encoding == AUDIO_ENCODING_ULINEAR || encoding == AUDIO_ENCODING_ULINEAR || encoding == AUDIO_ENCODING_ULINEAR_LE || encoding == AUDIO_ENCODING_ULINEAR_BE)) { @@ -18992,13 +18992,13 @@ mal_result mal_context_get_device_info_from_fd__audio4(mal_context* pContext, ma audio_device_t fdDevice; if (ioctl(fd, AUDIO_GETDEV, &fdDevice) < 0) { - return MAL_ERROR; // Failed to retrieve device info. + return MA_ERROR; // Failed to retrieve device info. } // Name. mal_strcpy_s(pInfoOut->name, sizeof(pInfoOut->name), fdDevice.name); -#if !defined(MAL_AUDIO4_USE_NEW_API) +#if !defined(MA_AUDIO4_USE_NEW_API) // Supported formats. We get this by looking at the encodings. int counter = 0; for (;;) { @@ -19019,7 +19019,7 @@ mal_result mal_context_get_device_info_from_fd__audio4(mal_context* pContext, ma audio_info_t fdInfo; if (ioctl(fd, AUDIO_GETINFO, &fdInfo) < 0) { - return MAL_ERROR; + return MA_ERROR; } if (deviceType == mal_device_type_playback) { @@ -19036,12 +19036,12 @@ mal_result mal_context_get_device_info_from_fd__audio4(mal_context* pContext, ma #else struct audio_swpar fdPar; if (ioctl(fd, AUDIO_GETPAR, &fdPar) < 0) { - return MAL_ERROR; + return MA_ERROR; } mal_format format = mal_format_from_swpar__audio4(&fdPar); if (format == mal_format_unknown) { - return MAL_FORMAT_NOT_SUPPORTED; + return MA_FORMAT_NOT_SUPPORTED; } pInfoOut->formats[pInfoOut->formatCount++] = format; @@ -19057,7 +19057,7 @@ mal_result mal_context_get_device_info_from_fd__audio4(mal_context* pContext, ma pInfoOut->maxSampleRate = fdPar.rate; #endif - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_enumerate_devices__audio4(mal_context* pContext, mal_enum_devices_callback_proc callback, void* pUserData) @@ -19081,7 +19081,7 @@ mal_result mal_context_enumerate_devices__audio4(mal_context* pContext, mal_enum // The device exists, but we need to check if it's usable as playback and/or capture. int fd; - mal_bool32 isTerminating = MAL_FALSE; + mal_bool32 isTerminating = MA_FALSE; // Playback. if (!isTerminating) { @@ -19091,7 +19091,7 @@ mal_result mal_context_enumerate_devices__audio4(mal_context* pContext, mal_enum mal_device_info deviceInfo; mal_zero_object(&deviceInfo); mal_construct_device_id__audio4(deviceInfo.id.audio4, sizeof(deviceInfo.id.audio4), "/dev/audio", iDevice); - if (mal_context_get_device_info_from_fd__audio4(pContext, mal_device_type_playback, fd, &deviceInfo) == MAL_SUCCESS) { + if (mal_context_get_device_info_from_fd__audio4(pContext, mal_device_type_playback, fd, &deviceInfo) == MA_SUCCESS) { isTerminating = !callback(pContext, mal_device_type_playback, &deviceInfo, pUserData); } @@ -19107,7 +19107,7 @@ mal_result mal_context_enumerate_devices__audio4(mal_context* pContext, mal_enum mal_device_info deviceInfo; mal_zero_object(&deviceInfo); mal_construct_device_id__audio4(deviceInfo.id.audio4, sizeof(deviceInfo.id.audio4), "/dev/audio", iDevice); - if (mal_context_get_device_info_from_fd__audio4(pContext, mal_device_type_capture, fd, &deviceInfo) == MAL_SUCCESS) { + if (mal_context_get_device_info_from_fd__audio4(pContext, mal_device_type_capture, fd, &deviceInfo) == MA_SUCCESS) { isTerminating = !callback(pContext, mal_device_type_capture, &deviceInfo, pUserData); } @@ -19120,7 +19120,7 @@ mal_result mal_context_enumerate_devices__audio4(mal_context* pContext, mal_enum } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_get_device_info__audio4(mal_context* pContext, mal_device_type deviceType, const mal_device_id* pDeviceID, mal_share_mode shareMode, mal_device_info* pDeviceInfo) @@ -19139,7 +19139,7 @@ mal_result mal_context_get_device_info__audio4(mal_context* pContext, mal_device } else { // Specific device. We need to convert from "/dev/audioN" to "/dev/audioctlN". mal_result result = mal_extract_device_index_from_id__audio4(pDeviceID->audio4, "/dev/audio", &deviceIndex); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -19148,7 +19148,7 @@ mal_result mal_context_get_device_info__audio4(mal_context* pContext, mal_device fd = open(ctlid, (deviceType == mal_device_type_playback) ? O_WRONLY : O_RDONLY, 0); if (fd == -1) { - return MAL_NO_DEVICE; + return MA_NO_DEVICE; } if (deviceIndex == -1) { @@ -19184,7 +19184,7 @@ mal_result mal_device_init_fd__audio4(mal_context* pContext, const mal_device_co }; int fd; int fdFlags = 0; -#if !defined(MAL_AUDIO4_USE_NEW_API) /* Old API */ +#if !defined(MA_AUDIO4_USE_NEW_API) /* Old API */ audio_info_t fdInfo; #else struct audio_swpar fdPar; @@ -19224,10 +19224,10 @@ mal_result mal_device_init_fd__audio4(mal_context* pContext, const mal_device_co } if (fd == -1) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[audio4] Failed to open device.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to open device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } -#if !defined(MAL_AUDIO4_USE_NEW_API) /* Old API */ +#if !defined(MA_AUDIO4_USE_NEW_API) /* Old API */ AUDIO_INITINFO(&fdInfo); /* We get the driver to do as much of the data conversion as possible. */ @@ -19245,12 +19245,12 @@ mal_result mal_device_init_fd__audio4(mal_context* pContext, const mal_device_co if (ioctl(fd, AUDIO_SETINFO, &fdInfo) < 0) { close(fd); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[audio4] Failed to set device format. AUDIO_SETINFO failed.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to set device format. AUDIO_SETINFO failed.", MA_FORMAT_NOT_SUPPORTED); } if (ioctl(fd, AUDIO_GETINFO, &fdInfo) < 0) { close(fd); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[audio4] AUDIO_GETINFO failed.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] AUDIO_GETINFO failed.", MA_FORMAT_NOT_SUPPORTED); } if (deviceType == mal_device_type_capture) { @@ -19265,7 +19265,7 @@ mal_result mal_device_init_fd__audio4(mal_context* pContext, const mal_device_co if (internalFormat == mal_format_unknown) { close(fd); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[audio4] The device's internal device format is not supported by miniaudio. The device is unusable.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] The device's internal device format is not supported by miniaudio. The device is unusable.", MA_FORMAT_NOT_SUPPORTED); } /* Buffer. */ @@ -19294,7 +19294,7 @@ mal_result mal_device_init_fd__audio4(mal_context* pContext, const mal_device_co fdInfo.blocksize = internalBufferSizeInBytes / internalPeriods; if (ioctl(fd, AUDIO_SETINFO, &fdInfo) < 0) { close(fd); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[audio4] Failed to set internal buffer size. AUDIO_SETINFO failed.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to set internal buffer size. AUDIO_SETINFO failed.", MA_FORMAT_NOT_SUPPORTED); } internalPeriods = fdInfo.hiwat; @@ -19304,7 +19304,7 @@ mal_result mal_device_init_fd__audio4(mal_context* pContext, const mal_device_co /* We need to retrieve the format of the device so we can know the channel count and sample rate. Then we can calculate the buffer size. */ if (ioctl(fd, AUDIO_GETPAR, &fdPar) < 0) { close(fd); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[audio4] Failed to retrieve initial device parameters.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to retrieve initial device parameters.", MA_FORMAT_NOT_SUPPORTED); } internalFormat = mal_format_from_swpar__audio4(&fdPar); @@ -19313,7 +19313,7 @@ mal_result mal_device_init_fd__audio4(mal_context* pContext, const mal_device_co if (internalFormat == mal_format_unknown) { close(fd); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[audio4] The device's internal device format is not supported by miniaudio. The device is unusable.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] The device's internal device format is not supported by miniaudio. The device is unusable.", MA_FORMAT_NOT_SUPPORTED); } /* Buffer. */ @@ -19336,12 +19336,12 @@ mal_result mal_device_init_fd__audio4(mal_context* pContext, const mal_device_co if (ioctl(fd, AUDIO_SETPAR, &fdPar) < 0) { close(fd); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[audio4] Failed to set device parameters.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to set device parameters.", MA_FORMAT_NOT_SUPPORTED); } if (ioctl(fd, AUDIO_GETPAR, &fdPar) < 0) { close(fd); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[audio4] Failed to retrieve actual device parameters.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to retrieve actual device parameters.", MA_FORMAT_NOT_SUPPORTED); } } @@ -19354,7 +19354,7 @@ mal_result mal_device_init_fd__audio4(mal_context* pContext, const mal_device_co if (internalFormat == mal_format_unknown) { close(fd); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[audio4] The device's internal device format is not supported by miniaudio. The device is unusable.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] The device's internal device format is not supported by miniaudio. The device is unusable.", MA_FORMAT_NOT_SUPPORTED); } if (deviceType == mal_device_type_capture) { @@ -19375,7 +19375,7 @@ mal_result mal_device_init_fd__audio4(mal_context* pContext, const mal_device_co pDevice->playback.internalPeriods = internalPeriods; } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_init__audio4(mal_context* pContext, const mal_device_config* pConfig, mal_device* pDevice) @@ -19394,7 +19394,7 @@ mal_result mal_device_init__audio4(mal_context* pContext, const mal_device_confi /* NetBSD 8.0+ */ if (((pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) && pConfig->playback.shareMode == mal_share_mode_exclusive) || ((pConfig->deviceType == mal_device_type_capture || pConfig->deviceType == mal_device_type_duplex) && pConfig->capture.shareMode == mal_share_mode_exclusive)) { - return MAL_SHARE_MODE_NOT_SUPPORTED; + return MA_SHARE_MODE_NOT_SUPPORTED; } #else /* All other flavors. */ @@ -19402,14 +19402,14 @@ mal_result mal_device_init__audio4(mal_context* pContext, const mal_device_confi if (pConfig->deviceType == mal_device_type_capture || pConfig->deviceType == mal_device_type_duplex) { mal_result result = mal_device_init_fd__audio4(pContext, pConfig, mal_device_type_capture, pDevice); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } if (pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) { mal_result result = mal_device_init_fd__audio4(pContext, pConfig, mal_device_type_playback, pDevice); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { if (pConfig->deviceType == mal_device_type_duplex) { close(pDevice->audio4.fdCapture); } @@ -19417,7 +19417,7 @@ mal_result mal_device_init__audio4(mal_context* pContext, const mal_device_confi } } - return MAL_SUCCESS; + return MA_SUCCESS; } #if 0 @@ -19427,37 +19427,37 @@ mal_result mal_device_start__audio4(mal_device* pDevice) if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { if (pDevice->audio4.fdCapture == -1) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } } if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) { if (pDevice->audio4.fdPlayback == -1) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } } - return MAL_SUCCESS; + return MA_SUCCESS; } #endif mal_result mal_device_stop_fd__audio4(mal_device* pDevice, int fd) { if (fd == -1) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } -#if !defined(MAL_AUDIO4_USE_NEW_API) +#if !defined(MA_AUDIO4_USE_NEW_API) if (ioctl(fd, AUDIO_FLUSH, 0) < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[audio4] Failed to stop device. AUDIO_FLUSH failed.", MAL_FAILED_TO_STOP_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to stop device. AUDIO_FLUSH failed.", MA_FAILED_TO_STOP_BACKEND_DEVICE); } #else if (ioctl(fd, AUDIO_STOP, 0) < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[audio4] Failed to stop device. AUDIO_STOP failed.", MAL_FAILED_TO_STOP_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to stop device. AUDIO_STOP failed.", MA_FAILED_TO_STOP_BACKEND_DEVICE); } #endif - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_stop__audio4(mal_device* pDevice) @@ -19466,39 +19466,39 @@ mal_result mal_device_stop__audio4(mal_device* pDevice) if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { mal_result result = mal_device_stop_fd__audio4(pDevice, pDevice->audio4.fdCapture); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) { mal_result result = mal_device_stop_fd__audio4(pDevice, pDevice->audio4.fdPlayback); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_write__audio4(mal_device* pDevice, const void* pPCMFrames, mal_uint32 frameCount) { int result = write(pDevice->audio4.fdPlayback, pPCMFrames, frameCount * mal_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels)); if (result < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[audio4] Failed to write data to the device.", MAL_FAILED_TO_SEND_DATA_TO_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to write data to the device.", MA_FAILED_TO_SEND_DATA_TO_DEVICE); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_read__audio4(mal_device* pDevice, void* pPCMFrames, mal_uint32 frameCount) { int result = read(pDevice->audio4.fdCapture, pPCMFrames, frameCount * mal_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels)); if (result < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[audio4] Failed to read data from the device.", MAL_FAILED_TO_READ_DATA_FROM_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[audio4] Failed to read data from the device.", MA_FAILED_TO_READ_DATA_FROM_DEVICE); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_uninit__audio4(mal_context* pContext) @@ -19507,7 +19507,7 @@ mal_result mal_context_uninit__audio4(mal_context* pContext) mal_assert(pContext->backend == mal_backend_audio4); (void)pContext; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_init__audio4(mal_context* pContext) @@ -19525,7 +19525,7 @@ mal_result mal_context_init__audio4(mal_context* pContext) pContext->onDeviceWrite = mal_device_write__audio4; pContext->onDeviceRead = mal_device_read__audio4; - return MAL_SUCCESS; + return MA_SUCCESS; } #endif /* audio4 */ @@ -19535,7 +19535,7 @@ mal_result mal_context_init__audio4(mal_context* pContext) // OSS Backend // /////////////////////////////////////////////////////////////////////////////// -#ifdef MAL_HAS_OSS +#ifdef MA_HAS_OSS #include #include #include @@ -19566,7 +19566,7 @@ mal_result mal_context_open_device__oss(mal_context* pContext, mal_device_type d /* This function should only be called for playback or capture, not duplex. */ if (deviceType == mal_device_type_duplex) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } const char* deviceName = "/dev/dsp"; @@ -19581,10 +19581,10 @@ mal_result mal_context_open_device__oss(mal_context* pContext, mal_device_type d *pfd = open(deviceName, flags, 0); if (*pfd == -1) { - return MAL_FAILED_TO_OPEN_BACKEND_DEVICE; + return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_bool32 mal_context_is_device_id_equal__oss(mal_context* pContext, const mal_device_id* pID0, const mal_device_id* pID1) @@ -19604,7 +19604,7 @@ mal_result mal_context_enumerate_devices__oss(mal_context* pContext, mal_enum_de int fd = mal_open_temp_device__oss(); if (fd == -1) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to open a temporary device for retrieving system information used for device enumeration.", MAL_NO_BACKEND); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open a temporary device for retrieving system information used for device enumeration.", MA_NO_BACKEND); } oss_sysinfo si; @@ -19632,7 +19632,7 @@ mal_result mal_context_enumerate_devices__oss(mal_context* pContext, mal_enum_de } // The device can be both playback and capture. - mal_bool32 isTerminating = MAL_FALSE; + mal_bool32 isTerminating = MA_FALSE; if (!isTerminating && (ai.caps & PCM_CAP_OUTPUT) != 0) { isTerminating = !callback(pContext, mal_device_type_playback, &deviceInfo, pUserData); } @@ -19648,11 +19648,11 @@ mal_result mal_context_enumerate_devices__oss(mal_context* pContext, mal_enum_de } } else { close(fd); - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to retrieve system information for device enumeration.", MAL_NO_BACKEND); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to retrieve system information for device enumeration.", MA_NO_BACKEND); } close(fd); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_get_device_info__oss(mal_context* pContext, mal_device_type deviceType, const mal_device_id* pDeviceID, mal_share_mode shareMode, mal_device_info* pDeviceInfo) @@ -19663,21 +19663,21 @@ mal_result mal_context_get_device_info__oss(mal_context* pContext, mal_device_ty // Handle the default device a little differently. if (pDeviceID == NULL) { if (deviceType == mal_device_type_playback) { - mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MAL_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { - mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MAL_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } - return MAL_SUCCESS; + return MA_SUCCESS; } // If we get here it means we are _not_ using the default device. - mal_bool32 foundDevice = MAL_FALSE; + mal_bool32 foundDevice = MA_FALSE; int fdTemp = mal_open_temp_device__oss(); if (fdTemp == -1) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to open a temporary device for retrieving system information used for device enumeration.", MAL_NO_BACKEND); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open a temporary device for retrieving system information used for device enumeration.", MA_NO_BACKEND); } oss_sysinfo si; @@ -19727,7 +19727,7 @@ mal_result mal_context_get_device_info__oss(mal_context* pContext, mal_device_ty pDeviceInfo->formats[pDeviceInfo->formatCount++] = mal_format_s32; } - foundDevice = MAL_TRUE; + foundDevice = MA_TRUE; break; } } @@ -19735,18 +19735,18 @@ mal_result mal_context_get_device_info__oss(mal_context* pContext, mal_device_ty } } else { close(fdTemp); - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to retrieve system information for device enumeration.", MAL_NO_BACKEND); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to retrieve system information for device enumeration.", MA_NO_BACKEND); } close(fdTemp); if (!foundDevice) { - return MAL_NO_DEVICE; + return MA_NO_DEVICE; } - return MAL_SUCCESS; + return MA_SUCCESS; } void mal_device_uninit__oss(mal_device* pDevice) @@ -19834,8 +19834,8 @@ mal_result mal_device_init_fd__oss(mal_context* pContext, const mal_device_confi } result = mal_context_open_device__oss(pContext, deviceType, pDeviceID, shareMode, &fd); - if (result != MAL_SUCCESS) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to open device.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + if (result != MA_SUCCESS) { + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } /* @@ -19849,21 +19849,21 @@ mal_result mal_device_init_fd__oss(mal_context* pContext, const mal_device_confi ossResult = ioctl(fd, SNDCTL_DSP_SETFMT, &ossFormat); if (ossResult == -1) { close(fd); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to set format.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to set format.", MA_FORMAT_NOT_SUPPORTED); } /* Channels. */ ossResult = ioctl(fd, SNDCTL_DSP_CHANNELS, &ossChannels); if (ossResult == -1) { close(fd); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to set channel count.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to set channel count.", MA_FORMAT_NOT_SUPPORTED); } /* Sample Rate. */ ossResult = ioctl(fd, SNDCTL_DSP_SPEED, &ossSampleRate); if (ossResult == -1) { close(fd); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to set sample rate.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to set sample rate.", MA_FORMAT_NOT_SUPPORTED); } /* @@ -19900,7 +19900,7 @@ mal_result mal_device_init_fd__oss(mal_context* pContext, const mal_device_confi ossResult = ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &ossFragment); if (ossResult == -1) { close(fd); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to set fragment size and period count.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to set fragment size and period count.", MA_FORMAT_NOT_SUPPORTED); } } @@ -19915,7 +19915,7 @@ mal_result mal_device_init_fd__oss(mal_context* pContext, const mal_device_confi pDevice->capture.internalBufferSizeInFrames = (((mal_uint32)(1 << (ossFragment & 0xFFFF))) * pDevice->capture.internalPeriods) / mal_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); if (pDevice->capture.internalFormat == mal_format_unknown) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OSS] The device's internal format is not supported by miniaudio.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] The device's internal format is not supported by miniaudio.", MA_FORMAT_NOT_SUPPORTED); } } else { pDevice->oss.fdPlayback = fd; @@ -19927,11 +19927,11 @@ mal_result mal_device_init_fd__oss(mal_context* pContext, const mal_device_confi pDevice->playback.internalBufferSizeInFrames = (((mal_uint32)(1 << (ossFragment & 0xFFFF))) * pDevice->playback.internalPeriods) / mal_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); if (pDevice->playback.internalFormat == mal_format_unknown) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OSS] The device's internal format is not supported by miniaudio.", MAL_FORMAT_NOT_SUPPORTED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] The device's internal format is not supported by miniaudio.", MA_FORMAT_NOT_SUPPORTED); } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_init__oss(mal_context* pContext, const mal_device_config* pConfig, mal_device* pDevice) @@ -19944,19 +19944,19 @@ mal_result mal_device_init__oss(mal_context* pContext, const mal_device_config* if (pConfig->deviceType == mal_device_type_capture || pConfig->deviceType == mal_device_type_duplex) { mal_result result = mal_device_init_fd__oss(pContext, pConfig, mal_device_type_capture, pDevice); - if (result != MAL_SUCCESS) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to open device.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + if (result != MA_SUCCESS) { + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } } if (pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) { mal_result result = mal_device_init_fd__oss(pContext, pConfig, mal_device_type_playback, pDevice); - if (result != MAL_SUCCESS) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to open device.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + if (result != MA_SUCCESS) { + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open device.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_stop__oss(mal_device* pDevice) @@ -19979,38 +19979,38 @@ mal_result mal_device_stop__oss(mal_device* pDevice) if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { int result = ioctl(pDevice->oss.fdCapture, SNDCTL_DSP_HALT, 0); if (result == -1) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to stop device. SNDCTL_DSP_HALT failed.", MAL_FAILED_TO_STOP_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to stop device. SNDCTL_DSP_HALT failed.", MA_FAILED_TO_STOP_BACKEND_DEVICE); } } if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) { int result = ioctl(pDevice->oss.fdPlayback, SNDCTL_DSP_HALT, 0); if (result == -1) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to stop device. SNDCTL_DSP_HALT failed.", MAL_FAILED_TO_STOP_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to stop device. SNDCTL_DSP_HALT failed.", MA_FAILED_TO_STOP_BACKEND_DEVICE); } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_write__oss(mal_device* pDevice, const void* pPCMFrames, mal_uint32 frameCount) { int resultOSS = write(pDevice->oss.fdPlayback, pPCMFrames, frameCount * mal_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels)); if (resultOSS < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to send data from the client to the device.", MAL_FAILED_TO_SEND_DATA_TO_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to send data from the client to the device.", MA_FAILED_TO_SEND_DATA_TO_DEVICE); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_read__oss(mal_device* pDevice, void* pPCMFrames, mal_uint32 frameCount) { int resultOSS = read(pDevice->oss.fdCapture, pPCMFrames, frameCount * mal_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels)); if (resultOSS < 0) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to read data from the device to be sent to the client.", MAL_FAILED_TO_READ_DATA_FROM_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OSS] Failed to read data from the device to be sent to the client.", MA_FAILED_TO_READ_DATA_FROM_DEVICE); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_uninit__oss(mal_context* pContext) @@ -20019,7 +20019,7 @@ mal_result mal_context_uninit__oss(mal_context* pContext) mal_assert(pContext->backend == mal_backend_oss); (void)pContext; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_init__oss(mal_context* pContext) @@ -20029,7 +20029,7 @@ mal_result mal_context_init__oss(mal_context* pContext) /* Try opening a temporary device first so we can get version information. This is closed at the end. */ int fd = mal_open_temp_device__oss(); if (fd == -1) { - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to open temporary device for retrieving system properties.", MAL_NO_BACKEND); /* Looks liks OSS isn't installed, or there are no available devices. */ + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to open temporary device for retrieving system properties.", MA_NO_BACKEND); /* Looks liks OSS isn't installed, or there are no available devices. */ } /* Grab the OSS version. */ @@ -20037,7 +20037,7 @@ mal_result mal_context_init__oss(mal_context* pContext) int result = ioctl(fd, OSS_GETVERSION, &ossVersion); if (result == -1) { close(fd); - return mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_ERROR, "[OSS] Failed to retrieve OSS version.", MAL_NO_BACKEND); + return mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_ERROR, "[OSS] Failed to retrieve OSS version.", MA_NO_BACKEND); } pContext->oss.versionMajor = ((ossVersion & 0xFF0000) >> 16); @@ -20055,7 +20055,7 @@ mal_result mal_context_init__oss(mal_context* pContext) pContext->onDeviceRead = mal_device_read__oss; close(fd); - return MAL_SUCCESS; + return MA_SUCCESS; } #endif /* OSS */ @@ -20065,10 +20065,10 @@ mal_result mal_context_init__oss(mal_context* pContext) // AAudio Backend // /////////////////////////////////////////////////////////////////////////////// -#ifdef MAL_HAS_AAUDIO +#ifdef MA_HAS_AAUDIO //#include -#define MAL_AAUDIO_UNSPECIFIED 0 +#define MA_AAUDIO_UNSPECIFIED 0 typedef int32_t mal_aaudio_result_t; typedef int32_t mal_aaudio_direction_t; @@ -20079,44 +20079,44 @@ typedef int32_t mal_aaudio_performance_mode_t; typedef int32_t mal_aaudio_data_callback_result_t; /* Result codes. miniaudio only cares about the success code. */ -#define MAL_AAUDIO_OK 0 +#define MA_AAUDIO_OK 0 /* Directions. */ -#define MAL_AAUDIO_DIRECTION_OUTPUT 0 -#define MAL_AAUDIO_DIRECTION_INPUT 1 +#define MA_AAUDIO_DIRECTION_OUTPUT 0 +#define MA_AAUDIO_DIRECTION_INPUT 1 /* Sharing modes. */ -#define MAL_AAUDIO_SHARING_MODE_EXCLUSIVE 0 -#define MAL_AAUDIO_SHARING_MODE_SHARED 1 +#define MA_AAUDIO_SHARING_MODE_EXCLUSIVE 0 +#define MA_AAUDIO_SHARING_MODE_SHARED 1 /* Formats. */ -#define MAL_AAUDIO_FORMAT_PCM_I16 1 -#define MAL_AAUDIO_FORMAT_PCM_FLOAT 2 +#define MA_AAUDIO_FORMAT_PCM_I16 1 +#define MA_AAUDIO_FORMAT_PCM_FLOAT 2 /* Stream states. */ -#define MAL_AAUDIO_STREAM_STATE_UNINITIALIZED 0 -#define MAL_AAUDIO_STREAM_STATE_UNKNOWN 1 -#define MAL_AAUDIO_STREAM_STATE_OPEN 2 -#define MAL_AAUDIO_STREAM_STATE_STARTING 3 -#define MAL_AAUDIO_STREAM_STATE_STARTED 4 -#define MAL_AAUDIO_STREAM_STATE_PAUSING 5 -#define MAL_AAUDIO_STREAM_STATE_PAUSED 6 -#define MAL_AAUDIO_STREAM_STATE_FLUSHING 7 -#define MAL_AAUDIO_STREAM_STATE_FLUSHED 8 -#define MAL_AAUDIO_STREAM_STATE_STOPPING 9 -#define MAL_AAUDIO_STREAM_STATE_STOPPED 10 -#define MAL_AAUDIO_STREAM_STATE_CLOSING 11 -#define MAL_AAUDIO_STREAM_STATE_CLOSED 12 -#define MAL_AAUDIO_STREAM_STATE_DISCONNECTED 13 +#define MA_AAUDIO_STREAM_STATE_UNINITIALIZED 0 +#define MA_AAUDIO_STREAM_STATE_UNKNOWN 1 +#define MA_AAUDIO_STREAM_STATE_OPEN 2 +#define MA_AAUDIO_STREAM_STATE_STARTING 3 +#define MA_AAUDIO_STREAM_STATE_STARTED 4 +#define MA_AAUDIO_STREAM_STATE_PAUSING 5 +#define MA_AAUDIO_STREAM_STATE_PAUSED 6 +#define MA_AAUDIO_STREAM_STATE_FLUSHING 7 +#define MA_AAUDIO_STREAM_STATE_FLUSHED 8 +#define MA_AAUDIO_STREAM_STATE_STOPPING 9 +#define MA_AAUDIO_STREAM_STATE_STOPPED 10 +#define MA_AAUDIO_STREAM_STATE_CLOSING 11 +#define MA_AAUDIO_STREAM_STATE_CLOSED 12 +#define MA_AAUDIO_STREAM_STATE_DISCONNECTED 13 /* Performance modes. */ -#define MAL_AAUDIO_PERFORMANCE_MODE_NONE 10 -#define MAL_AAUDIO_PERFORMANCE_MODE_POWER_SAVING 11 -#define MAL_AAUDIO_PERFORMANCE_MODE_LOW_LATENCY 12 +#define MA_AAUDIO_PERFORMANCE_MODE_NONE 10 +#define MA_AAUDIO_PERFORMANCE_MODE_POWER_SAVING 11 +#define MA_AAUDIO_PERFORMANCE_MODE_LOW_LATENCY 12 /* Callback results. */ -#define MAL_AAUDIO_CALLBACK_RESULT_CONTINUE 0 -#define MAL_AAUDIO_CALLBACK_RESULT_STOP 1 +#define MA_AAUDIO_CALLBACK_RESULT_CONTINUE 0 +#define MA_AAUDIO_CALLBACK_RESULT_STOP 1 /* Objects. */ typedef struct mal_AAudioStreamBuilder_t* mal_AAudioStreamBuilder; @@ -20124,40 +20124,40 @@ typedef struct mal_AAudioStream_t* mal_AAudioStream; typedef mal_aaudio_data_callback_result_t (*mal_AAudioStream_dataCallback)(mal_AAudioStream* pStream, void* pUserData, void* pAudioData, int32_t numFrames); -typedef mal_aaudio_result_t (* MAL_PFN_AAudio_createStreamBuilder) (mal_AAudioStreamBuilder** ppBuilder); -typedef mal_aaudio_result_t (* MAL_PFN_AAudioStreamBuilder_delete) (mal_AAudioStreamBuilder* pBuilder); -typedef void (* MAL_PFN_AAudioStreamBuilder_setDeviceId) (mal_AAudioStreamBuilder* pBuilder, int32_t deviceId); -typedef void (* MAL_PFN_AAudioStreamBuilder_setDirection) (mal_AAudioStreamBuilder* pBuilder, mal_aaudio_direction_t direction); -typedef void (* MAL_PFN_AAudioStreamBuilder_setSharingMode) (mal_AAudioStreamBuilder* pBuilder, mal_aaudio_sharing_mode_t sharingMode); -typedef void (* MAL_PFN_AAudioStreamBuilder_setFormat) (mal_AAudioStreamBuilder* pBuilder, mal_aaudio_format_t format); -typedef void (* MAL_PFN_AAudioStreamBuilder_setChannelCount) (mal_AAudioStreamBuilder* pBuilder, int32_t channelCount); -typedef void (* MAL_PFN_AAudioStreamBuilder_setSampleRate) (mal_AAudioStreamBuilder* pBuilder, int32_t sampleRate); -typedef void (* MAL_PFN_AAudioStreamBuilder_setBufferCapacityInFrames)(mal_AAudioStreamBuilder* pBuilder, int32_t numFrames); -typedef void (* MAL_PFN_AAudioStreamBuilder_setFramesPerDataCallback) (mal_AAudioStreamBuilder* pBuilder, int32_t numFrames); -typedef void (* MAL_PFN_AAudioStreamBuilder_setDataCallback) (mal_AAudioStreamBuilder* pBuilder, mal_AAudioStream_dataCallback callback, void* pUserData); -typedef void (* MAL_PFN_AAudioStreamBuilder_setPerformanceMode) (mal_AAudioStreamBuilder* pBuilder, mal_aaudio_performance_mode_t mode); -typedef mal_aaudio_result_t (* MAL_PFN_AAudioStreamBuilder_openStream) (mal_AAudioStreamBuilder* pBuilder, mal_AAudioStream** ppStream); -typedef mal_aaudio_result_t (* MAL_PFN_AAudioStream_close) (mal_AAudioStream* pStream); -typedef mal_aaudio_stream_state_t (* MAL_PFN_AAudioStream_getState) (mal_AAudioStream* pStream); -typedef mal_aaudio_result_t (* MAL_PFN_AAudioStream_waitForStateChange) (mal_AAudioStream* pStream, mal_aaudio_stream_state_t inputState, mal_aaudio_stream_state_t* pNextState, int64_t timeoutInNanoseconds); -typedef mal_aaudio_format_t (* MAL_PFN_AAudioStream_getFormat) (mal_AAudioStream* pStream); -typedef int32_t (* MAL_PFN_AAudioStream_getChannelCount) (mal_AAudioStream* pStream); -typedef int32_t (* MAL_PFN_AAudioStream_getSampleRate) (mal_AAudioStream* pStream); -typedef int32_t (* MAL_PFN_AAudioStream_getBufferCapacityInFrames) (mal_AAudioStream* pStream); -typedef int32_t (* MAL_PFN_AAudioStream_getFramesPerDataCallback) (mal_AAudioStream* pStream); -typedef int32_t (* MAL_PFN_AAudioStream_getFramesPerBurst) (mal_AAudioStream* pStream); -typedef mal_aaudio_result_t (* MAL_PFN_AAudioStream_requestStart) (mal_AAudioStream* pStream); -typedef mal_aaudio_result_t (* MAL_PFN_AAudioStream_requestStop) (mal_AAudioStream* pStream); +typedef mal_aaudio_result_t (* MA_PFN_AAudio_createStreamBuilder) (mal_AAudioStreamBuilder** ppBuilder); +typedef mal_aaudio_result_t (* MA_PFN_AAudioStreamBuilder_delete) (mal_AAudioStreamBuilder* pBuilder); +typedef void (* MA_PFN_AAudioStreamBuilder_setDeviceId) (mal_AAudioStreamBuilder* pBuilder, int32_t deviceId); +typedef void (* MA_PFN_AAudioStreamBuilder_setDirection) (mal_AAudioStreamBuilder* pBuilder, mal_aaudio_direction_t direction); +typedef void (* MA_PFN_AAudioStreamBuilder_setSharingMode) (mal_AAudioStreamBuilder* pBuilder, mal_aaudio_sharing_mode_t sharingMode); +typedef void (* MA_PFN_AAudioStreamBuilder_setFormat) (mal_AAudioStreamBuilder* pBuilder, mal_aaudio_format_t format); +typedef void (* MA_PFN_AAudioStreamBuilder_setChannelCount) (mal_AAudioStreamBuilder* pBuilder, int32_t channelCount); +typedef void (* MA_PFN_AAudioStreamBuilder_setSampleRate) (mal_AAudioStreamBuilder* pBuilder, int32_t sampleRate); +typedef void (* MA_PFN_AAudioStreamBuilder_setBufferCapacityInFrames)(mal_AAudioStreamBuilder* pBuilder, int32_t numFrames); +typedef void (* MA_PFN_AAudioStreamBuilder_setFramesPerDataCallback) (mal_AAudioStreamBuilder* pBuilder, int32_t numFrames); +typedef void (* MA_PFN_AAudioStreamBuilder_setDataCallback) (mal_AAudioStreamBuilder* pBuilder, mal_AAudioStream_dataCallback callback, void* pUserData); +typedef void (* MA_PFN_AAudioStreamBuilder_setPerformanceMode) (mal_AAudioStreamBuilder* pBuilder, mal_aaudio_performance_mode_t mode); +typedef mal_aaudio_result_t (* MA_PFN_AAudioStreamBuilder_openStream) (mal_AAudioStreamBuilder* pBuilder, mal_AAudioStream** ppStream); +typedef mal_aaudio_result_t (* MA_PFN_AAudioStream_close) (mal_AAudioStream* pStream); +typedef mal_aaudio_stream_state_t (* MA_PFN_AAudioStream_getState) (mal_AAudioStream* pStream); +typedef mal_aaudio_result_t (* MA_PFN_AAudioStream_waitForStateChange) (mal_AAudioStream* pStream, mal_aaudio_stream_state_t inputState, mal_aaudio_stream_state_t* pNextState, int64_t timeoutInNanoseconds); +typedef mal_aaudio_format_t (* MA_PFN_AAudioStream_getFormat) (mal_AAudioStream* pStream); +typedef int32_t (* MA_PFN_AAudioStream_getChannelCount) (mal_AAudioStream* pStream); +typedef int32_t (* MA_PFN_AAudioStream_getSampleRate) (mal_AAudioStream* pStream); +typedef int32_t (* MA_PFN_AAudioStream_getBufferCapacityInFrames) (mal_AAudioStream* pStream); +typedef int32_t (* MA_PFN_AAudioStream_getFramesPerDataCallback) (mal_AAudioStream* pStream); +typedef int32_t (* MA_PFN_AAudioStream_getFramesPerBurst) (mal_AAudioStream* pStream); +typedef mal_aaudio_result_t (* MA_PFN_AAudioStream_requestStart) (mal_AAudioStream* pStream); +typedef mal_aaudio_result_t (* MA_PFN_AAudioStream_requestStop) (mal_AAudioStream* pStream); mal_result mal_result_from_aaudio(mal_aaudio_result_t resultAA) { switch (resultAA) { - case MAL_AAUDIO_OK: return MAL_SUCCESS; + case MA_AAUDIO_OK: return MA_SUCCESS; default: break; } - return MAL_ERROR; + return MA_ERROR; } mal_aaudio_data_callback_result_t mal_stream_data_callback_capture__aaudio(mal_AAudioStream* pStream, void* pUserData, void* pAudioData, int32_t frameCount) @@ -20172,7 +20172,7 @@ mal_aaudio_data_callback_result_t mal_stream_data_callback_capture__aaudio(mal_A } (void)pStream; - return MAL_AAUDIO_CALLBACK_RESULT_CONTINUE; + return MA_AAUDIO_CALLBACK_RESULT_CONTINUE; } mal_aaudio_data_callback_result_t mal_stream_data_callback_playback__aaudio(mal_AAudioStream* pStream, void* pUserData, void* pAudioData, int32_t frameCount) @@ -20187,7 +20187,7 @@ mal_aaudio_data_callback_result_t mal_stream_data_callback_playback__aaudio(mal_ } (void)pStream; - return MAL_AAUDIO_CALLBACK_RESULT_CONTINUE; + return MA_AAUDIO_CALLBACK_RESULT_CONTINUE; } mal_result mal_open_stream__aaudio(mal_context* pContext, mal_device_type deviceType, const mal_device_id* pDeviceID, mal_share_mode shareMode, const mal_device_config* pConfig, const mal_device* pDevice, mal_AAudioStream** ppStream) @@ -20199,36 +20199,36 @@ mal_result mal_open_stream__aaudio(mal_context* pContext, mal_device_type device *ppStream = NULL; - resultAA = ((MAL_PFN_AAudio_createStreamBuilder)pContext->aaudio.AAudio_createStreamBuilder)(&pBuilder); - if (resultAA != MAL_AAUDIO_OK) { + resultAA = ((MA_PFN_AAudio_createStreamBuilder)pContext->aaudio.AAudio_createStreamBuilder)(&pBuilder); + if (resultAA != MA_AAUDIO_OK) { return mal_result_from_aaudio(resultAA); } if (pDeviceID != NULL) { - ((MAL_PFN_AAudioStreamBuilder_setDeviceId)pContext->aaudio.AAudioStreamBuilder_setDeviceId)(pBuilder, pDeviceID->aaudio); + ((MA_PFN_AAudioStreamBuilder_setDeviceId)pContext->aaudio.AAudioStreamBuilder_setDeviceId)(pBuilder, pDeviceID->aaudio); } - ((MAL_PFN_AAudioStreamBuilder_setDirection)pContext->aaudio.AAudioStreamBuilder_setDirection)(pBuilder, (deviceType == mal_device_type_playback) ? MAL_AAUDIO_DIRECTION_OUTPUT : MAL_AAUDIO_DIRECTION_INPUT); - ((MAL_PFN_AAudioStreamBuilder_setSharingMode)pContext->aaudio.AAudioStreamBuilder_setSharingMode)(pBuilder, (shareMode == mal_share_mode_shared) ? MAL_AAUDIO_SHARING_MODE_SHARED : MAL_AAUDIO_SHARING_MODE_EXCLUSIVE); + ((MA_PFN_AAudioStreamBuilder_setDirection)pContext->aaudio.AAudioStreamBuilder_setDirection)(pBuilder, (deviceType == mal_device_type_playback) ? MA_AAUDIO_DIRECTION_OUTPUT : MA_AAUDIO_DIRECTION_INPUT); + ((MA_PFN_AAudioStreamBuilder_setSharingMode)pContext->aaudio.AAudioStreamBuilder_setSharingMode)(pBuilder, (shareMode == mal_share_mode_shared) ? MA_AAUDIO_SHARING_MODE_SHARED : MA_AAUDIO_SHARING_MODE_EXCLUSIVE); if (pConfig != NULL) { if (pDevice == NULL || !pDevice->usingDefaultSampleRate) { - ((MAL_PFN_AAudioStreamBuilder_setSampleRate)pContext->aaudio.AAudioStreamBuilder_setSampleRate)(pBuilder, pConfig->sampleRate); + ((MA_PFN_AAudioStreamBuilder_setSampleRate)pContext->aaudio.AAudioStreamBuilder_setSampleRate)(pBuilder, pConfig->sampleRate); } if (deviceType == mal_device_type_capture) { if (pDevice == NULL || !pDevice->capture.usingDefaultChannels) { - ((MAL_PFN_AAudioStreamBuilder_setChannelCount)pContext->aaudio.AAudioStreamBuilder_setChannelCount)(pBuilder, pConfig->capture.channels); + ((MA_PFN_AAudioStreamBuilder_setChannelCount)pContext->aaudio.AAudioStreamBuilder_setChannelCount)(pBuilder, pConfig->capture.channels); } if (pDevice == NULL || !pDevice->capture.usingDefaultFormat) { - ((MAL_PFN_AAudioStreamBuilder_setFormat)pContext->aaudio.AAudioStreamBuilder_setFormat)(pBuilder, (pConfig->capture.format == mal_format_s16) ? MAL_AAUDIO_FORMAT_PCM_I16 : MAL_AAUDIO_FORMAT_PCM_FLOAT); + ((MA_PFN_AAudioStreamBuilder_setFormat)pContext->aaudio.AAudioStreamBuilder_setFormat)(pBuilder, (pConfig->capture.format == mal_format_s16) ? MA_AAUDIO_FORMAT_PCM_I16 : MA_AAUDIO_FORMAT_PCM_FLOAT); } } else { if (pDevice == NULL || !pDevice->playback.usingDefaultChannels) { - ((MAL_PFN_AAudioStreamBuilder_setChannelCount)pContext->aaudio.AAudioStreamBuilder_setChannelCount)(pBuilder, pConfig->playback.channels); + ((MA_PFN_AAudioStreamBuilder_setChannelCount)pContext->aaudio.AAudioStreamBuilder_setChannelCount)(pBuilder, pConfig->playback.channels); } if (pDevice == NULL || !pDevice->playback.usingDefaultFormat) { - ((MAL_PFN_AAudioStreamBuilder_setFormat)pContext->aaudio.AAudioStreamBuilder_setFormat)(pBuilder, (pConfig->playback.format == mal_format_s16) ? MAL_AAUDIO_FORMAT_PCM_I16 : MAL_AAUDIO_FORMAT_PCM_FLOAT); + ((MA_PFN_AAudioStreamBuilder_setFormat)pContext->aaudio.AAudioStreamBuilder_setFormat)(pBuilder, (pConfig->playback.format == mal_format_s16) ? MA_AAUDIO_FORMAT_PCM_I16 : MA_AAUDIO_FORMAT_PCM_FLOAT); } } @@ -20236,34 +20236,34 @@ mal_result mal_open_stream__aaudio(mal_context* pContext, mal_device_type device if (bufferCapacityInFrames == 0) { bufferCapacityInFrames = mal_calculate_buffer_size_in_frames_from_milliseconds(pConfig->bufferSizeInMilliseconds, pConfig->sampleRate); } - ((MAL_PFN_AAudioStreamBuilder_setBufferCapacityInFrames)pContext->aaudio.AAudioStreamBuilder_setBufferCapacityInFrames)(pBuilder, bufferCapacityInFrames); + ((MA_PFN_AAudioStreamBuilder_setBufferCapacityInFrames)pContext->aaudio.AAudioStreamBuilder_setBufferCapacityInFrames)(pBuilder, bufferCapacityInFrames); - ((MAL_PFN_AAudioStreamBuilder_setFramesPerDataCallback)pContext->aaudio.AAudioStreamBuilder_setFramesPerDataCallback)(pBuilder, bufferCapacityInFrames / pConfig->periods); + ((MA_PFN_AAudioStreamBuilder_setFramesPerDataCallback)pContext->aaudio.AAudioStreamBuilder_setFramesPerDataCallback)(pBuilder, bufferCapacityInFrames / pConfig->periods); if (deviceType == mal_device_type_capture) { - ((MAL_PFN_AAudioStreamBuilder_setDataCallback)pContext->aaudio.AAudioStreamBuilder_setDataCallback)(pBuilder, mal_stream_data_callback_capture__aaudio, (void*)pDevice); + ((MA_PFN_AAudioStreamBuilder_setDataCallback)pContext->aaudio.AAudioStreamBuilder_setDataCallback)(pBuilder, mal_stream_data_callback_capture__aaudio, (void*)pDevice); } else { - ((MAL_PFN_AAudioStreamBuilder_setDataCallback)pContext->aaudio.AAudioStreamBuilder_setDataCallback)(pBuilder, mal_stream_data_callback_playback__aaudio, (void*)pDevice); + ((MA_PFN_AAudioStreamBuilder_setDataCallback)pContext->aaudio.AAudioStreamBuilder_setDataCallback)(pBuilder, mal_stream_data_callback_playback__aaudio, (void*)pDevice); } /* Not sure how this affects things, but since there's a mapping between miniaudio's performance profiles and AAudio's performance modes, let go ahead and set it. */ - ((MAL_PFN_AAudioStreamBuilder_setPerformanceMode)pContext->aaudio.AAudioStreamBuilder_setPerformanceMode)(pBuilder, (pConfig->performanceProfile == mal_performance_profile_low_latency) ? MAL_AAUDIO_PERFORMANCE_MODE_LOW_LATENCY : MAL_AAUDIO_PERFORMANCE_MODE_NONE); + ((MA_PFN_AAudioStreamBuilder_setPerformanceMode)pContext->aaudio.AAudioStreamBuilder_setPerformanceMode)(pBuilder, (pConfig->performanceProfile == mal_performance_profile_low_latency) ? MA_AAUDIO_PERFORMANCE_MODE_LOW_LATENCY : MA_AAUDIO_PERFORMANCE_MODE_NONE); } - resultAA = ((MAL_PFN_AAudioStreamBuilder_openStream)pContext->aaudio.AAudioStreamBuilder_openStream)(pBuilder, ppStream); - if (resultAA != MAL_AAUDIO_OK) { + resultAA = ((MA_PFN_AAudioStreamBuilder_openStream)pContext->aaudio.AAudioStreamBuilder_openStream)(pBuilder, ppStream); + if (resultAA != MA_AAUDIO_OK) { *ppStream = NULL; - ((MAL_PFN_AAudioStreamBuilder_delete)pContext->aaudio.AAudioStreamBuilder_delete)(pBuilder); + ((MA_PFN_AAudioStreamBuilder_delete)pContext->aaudio.AAudioStreamBuilder_delete)(pBuilder); return mal_result_from_aaudio(resultAA); } - ((MAL_PFN_AAudioStreamBuilder_delete)pContext->aaudio.AAudioStreamBuilder_delete)(pBuilder); - return MAL_SUCCESS; + ((MA_PFN_AAudioStreamBuilder_delete)pContext->aaudio.AAudioStreamBuilder_delete)(pBuilder); + return MA_SUCCESS; } mal_result mal_close_stream__aaudio(mal_context* pContext, mal_AAudioStream* pStream) { - return mal_result_from_aaudio(((MAL_PFN_AAudioStream_close)pContext->aaudio.AAudioStream_close)(pStream)); + return mal_result_from_aaudio(((MA_PFN_AAudioStream_close)pContext->aaudio.AAudioStream_close)(pStream)); } mal_bool32 mal_has_default_device__aaudio(mal_context* pContext, mal_device_type deviceType) @@ -20271,27 +20271,27 @@ mal_bool32 mal_has_default_device__aaudio(mal_context* pContext, mal_device_type /* The only way to know this is to try creating a stream. */ mal_AAudioStream* pStream; mal_result result = mal_open_stream__aaudio(pContext, deviceType, NULL, mal_share_mode_shared, NULL, NULL, &pStream); - if (result != MAL_SUCCESS) { - return MAL_FALSE; + if (result != MA_SUCCESS) { + return MA_FALSE; } mal_close_stream__aaudio(pContext, pStream); - return MAL_TRUE; + return MA_TRUE; } mal_result mal_wait_for_simple_state_transition__aaudio(mal_context* pContext, mal_AAudioStream* pStream, mal_aaudio_stream_state_t oldState, mal_aaudio_stream_state_t newState) { mal_aaudio_stream_state_t actualNewState; - mal_aaudio_result_t resultAA = ((MAL_PFN_AAudioStream_waitForStateChange)pContext->aaudio.AAudioStream_waitForStateChange)(pStream, oldState, &actualNewState, 5000000000); /* 5 second timeout. */ - if (resultAA != MAL_AAUDIO_OK) { + mal_aaudio_result_t resultAA = ((MA_PFN_AAudioStream_waitForStateChange)pContext->aaudio.AAudioStream_waitForStateChange)(pStream, oldState, &actualNewState, 5000000000); /* 5 second timeout. */ + if (resultAA != MA_AAUDIO_OK) { return mal_result_from_aaudio(resultAA); } if (newState != actualNewState) { - return MAL_ERROR; /* Failed to transition into the expected state. */ + return MA_ERROR; /* Failed to transition into the expected state. */ } - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -20307,7 +20307,7 @@ mal_bool32 mal_context_is_device_id_equal__aaudio(mal_context* pContext, const m mal_result mal_context_enumerate_devices__aaudio(mal_context* pContext, mal_enum_devices_callback_proc callback, void* pUserData) { - mal_bool32 cbResult = MAL_TRUE; + mal_bool32 cbResult = MA_TRUE; mal_assert(pContext != NULL); mal_assert(callback != NULL); @@ -20318,8 +20318,8 @@ mal_result mal_context_enumerate_devices__aaudio(mal_context* pContext, mal_enum if (cbResult) { mal_device_info deviceInfo; mal_zero_object(&deviceInfo); - deviceInfo.id.aaudio = MAL_AAUDIO_UNSPECIFIED; - mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MAL_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); + deviceInfo.id.aaudio = MA_AAUDIO_UNSPECIFIED; + mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); if (mal_has_default_device__aaudio(pContext, mal_device_type_playback)) { cbResult = callback(pContext, mal_device_type_playback, &deviceInfo, pUserData); @@ -20330,15 +20330,15 @@ mal_result mal_context_enumerate_devices__aaudio(mal_context* pContext, mal_enum if (cbResult) { mal_device_info deviceInfo; mal_zero_object(&deviceInfo); - deviceInfo.id.aaudio = MAL_AAUDIO_UNSPECIFIED; - mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MAL_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); + deviceInfo.id.aaudio = MA_AAUDIO_UNSPECIFIED; + mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); if (mal_has_default_device__aaudio(pContext, mal_device_type_capture)) { cbResult = callback(pContext, mal_device_type_capture, &deviceInfo, pUserData); } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_get_device_info__aaudio(mal_context* pContext, mal_device_type deviceType, const mal_device_id* pDeviceID, mal_share_mode shareMode, mal_device_info* pDeviceInfo) @@ -20350,33 +20350,33 @@ mal_result mal_context_get_device_info__aaudio(mal_context* pContext, mal_device /* No exclusive mode with AAudio. */ if (shareMode == mal_share_mode_exclusive) { - return MAL_SHARE_MODE_NOT_SUPPORTED; + return MA_SHARE_MODE_NOT_SUPPORTED; } /* ID */ if (pDeviceID != NULL) { pDeviceInfo->id.aaudio = pDeviceID->aaudio; } else { - pDeviceInfo->id.aaudio = MAL_AAUDIO_UNSPECIFIED; + pDeviceInfo->id.aaudio = MA_AAUDIO_UNSPECIFIED; } /* Name */ if (deviceType == mal_device_type_playback) { - mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MAL_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { - mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MAL_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } /* We'll need to open the device to get accurate sample rate and channel count information. */ result = mal_open_stream__aaudio(pContext, deviceType, pDeviceID, shareMode, NULL, NULL, &pStream); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } - pDeviceInfo->minChannels = ((MAL_PFN_AAudioStream_getChannelCount)pContext->aaudio.AAudioStream_getChannelCount)(pStream); + pDeviceInfo->minChannels = ((MA_PFN_AAudioStream_getChannelCount)pContext->aaudio.AAudioStream_getChannelCount)(pStream); pDeviceInfo->maxChannels = pDeviceInfo->minChannels; - pDeviceInfo->minSampleRate = ((MAL_PFN_AAudioStream_getSampleRate)pContext->aaudio.AAudioStream_getSampleRate)(pStream); + pDeviceInfo->minSampleRate = ((MA_PFN_AAudioStream_getSampleRate)pContext->aaudio.AAudioStream_getSampleRate)(pStream); pDeviceInfo->maxSampleRate = pDeviceInfo->minSampleRate; mal_close_stream__aaudio(pContext, pStream); @@ -20388,7 +20388,7 @@ mal_result mal_context_get_device_info__aaudio(mal_context* pContext, mal_device pDeviceInfo->formats[0] = mal_format_s16; pDeviceInfo->formats[1] = mal_format_f32; - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -20420,25 +20420,25 @@ mal_result mal_device_init__aaudio(mal_context* pContext, const mal_device_confi /* No exclusive mode with AAudio. */ if (((pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) && pConfig->playback.shareMode == mal_share_mode_exclusive) || ((pConfig->deviceType == mal_device_type_capture || pConfig->deviceType == mal_device_type_duplex) && pConfig->capture.shareMode == mal_share_mode_exclusive)) { - return MAL_SHARE_MODE_NOT_SUPPORTED; + return MA_SHARE_MODE_NOT_SUPPORTED; } /* We first need to try opening the stream. */ if (pConfig->deviceType == mal_device_type_capture || pConfig->deviceType == mal_device_type_duplex) { result = mal_open_stream__aaudio(pContext, mal_device_type_capture, pConfig->capture.pDeviceID, pConfig->capture.shareMode, pConfig, pDevice, (mal_AAudioStream**)&pDevice->aaudio.pStreamCapture); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; /* Failed to open the AAudio stream. */ } - pDevice->capture.internalFormat = (((MAL_PFN_AAudioStream_getFormat)pContext->aaudio.AAudioStream_getFormat)((mal_AAudioStream*)pDevice->aaudio.pStreamCapture) == MAL_AAUDIO_FORMAT_PCM_I16) ? mal_format_s16 : mal_format_f32; - pDevice->capture.internalChannels = ((MAL_PFN_AAudioStream_getChannelCount)pContext->aaudio.AAudioStream_getChannelCount)((mal_AAudioStream*)pDevice->aaudio.pStreamCapture); - pDevice->capture.internalSampleRate = ((MAL_PFN_AAudioStream_getSampleRate)pContext->aaudio.AAudioStream_getSampleRate)((mal_AAudioStream*)pDevice->aaudio.pStreamCapture); + pDevice->capture.internalFormat = (((MA_PFN_AAudioStream_getFormat)pContext->aaudio.AAudioStream_getFormat)((mal_AAudioStream*)pDevice->aaudio.pStreamCapture) == MA_AAUDIO_FORMAT_PCM_I16) ? mal_format_s16 : mal_format_f32; + pDevice->capture.internalChannels = ((MA_PFN_AAudioStream_getChannelCount)pContext->aaudio.AAudioStream_getChannelCount)((mal_AAudioStream*)pDevice->aaudio.pStreamCapture); + pDevice->capture.internalSampleRate = ((MA_PFN_AAudioStream_getSampleRate)pContext->aaudio.AAudioStream_getSampleRate)((mal_AAudioStream*)pDevice->aaudio.pStreamCapture); mal_get_standard_channel_map(mal_standard_channel_map_default, pDevice->capture.internalChannels, pDevice->capture.internalChannelMap); /* <-- Cannot find info on channel order, so assuming a default. */ - pDevice->capture.internalBufferSizeInFrames = ((MAL_PFN_AAudioStream_getBufferCapacityInFrames)pContext->aaudio.AAudioStream_getBufferCapacityInFrames)((mal_AAudioStream*)pDevice->aaudio.pStreamCapture); + pDevice->capture.internalBufferSizeInFrames = ((MA_PFN_AAudioStream_getBufferCapacityInFrames)pContext->aaudio.AAudioStream_getBufferCapacityInFrames)((mal_AAudioStream*)pDevice->aaudio.pStreamCapture); /* TODO: When synchronous reading and writing is supported, use AAudioStream_getFramesPerBurst() instead of AAudioStream_getFramesPerDataCallback(). Keep * using AAudioStream_getFramesPerDataCallback() for asynchronous mode, though. */ - int32_t framesPerPeriod = ((MAL_PFN_AAudioStream_getFramesPerDataCallback)pContext->aaudio.AAudioStream_getFramesPerDataCallback)((mal_AAudioStream*)pDevice->aaudio.pStreamCapture); + int32_t framesPerPeriod = ((MA_PFN_AAudioStream_getFramesPerDataCallback)pContext->aaudio.AAudioStream_getFramesPerDataCallback)((mal_AAudioStream*)pDevice->aaudio.pStreamCapture); if (framesPerPeriod > 0) { pDevice->capture.internalPeriods = 1; } else { @@ -20448,17 +20448,17 @@ mal_result mal_device_init__aaudio(mal_context* pContext, const mal_device_confi if (pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) { result = mal_open_stream__aaudio(pContext, mal_device_type_playback, pConfig->playback.pDeviceID, pConfig->playback.shareMode, pConfig, pDevice, (mal_AAudioStream**)&pDevice->aaudio.pStreamPlayback); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; /* Failed to open the AAudio stream. */ } - pDevice->playback.internalFormat = (((MAL_PFN_AAudioStream_getFormat)pContext->aaudio.AAudioStream_getFormat)((mal_AAudioStream*)pDevice->aaudio.pStreamPlayback) == MAL_AAUDIO_FORMAT_PCM_I16) ? mal_format_s16 : mal_format_f32; - pDevice->playback.internalChannels = ((MAL_PFN_AAudioStream_getChannelCount)pContext->aaudio.AAudioStream_getChannelCount)((mal_AAudioStream*)pDevice->aaudio.pStreamPlayback); - pDevice->playback.internalSampleRate = ((MAL_PFN_AAudioStream_getSampleRate)pContext->aaudio.AAudioStream_getSampleRate)((mal_AAudioStream*)pDevice->aaudio.pStreamPlayback); + pDevice->playback.internalFormat = (((MA_PFN_AAudioStream_getFormat)pContext->aaudio.AAudioStream_getFormat)((mal_AAudioStream*)pDevice->aaudio.pStreamPlayback) == MA_AAUDIO_FORMAT_PCM_I16) ? mal_format_s16 : mal_format_f32; + pDevice->playback.internalChannels = ((MA_PFN_AAudioStream_getChannelCount)pContext->aaudio.AAudioStream_getChannelCount)((mal_AAudioStream*)pDevice->aaudio.pStreamPlayback); + pDevice->playback.internalSampleRate = ((MA_PFN_AAudioStream_getSampleRate)pContext->aaudio.AAudioStream_getSampleRate)((mal_AAudioStream*)pDevice->aaudio.pStreamPlayback); mal_get_standard_channel_map(mal_standard_channel_map_default, pDevice->playback.internalChannels, pDevice->playback.internalChannelMap); /* <-- Cannot find info on channel order, so assuming a default. */ - pDevice->playback.internalBufferSizeInFrames = ((MAL_PFN_AAudioStream_getBufferCapacityInFrames)pContext->aaudio.AAudioStream_getBufferCapacityInFrames)((mal_AAudioStream*)pDevice->aaudio.pStreamPlayback); + pDevice->playback.internalBufferSizeInFrames = ((MA_PFN_AAudioStream_getBufferCapacityInFrames)pContext->aaudio.AAudioStream_getBufferCapacityInFrames)((mal_AAudioStream*)pDevice->aaudio.pStreamPlayback); - int32_t framesPerPeriod = ((MAL_PFN_AAudioStream_getFramesPerDataCallback)pContext->aaudio.AAudioStream_getFramesPerDataCallback)((mal_AAudioStream*)pDevice->aaudio.pStreamPlayback); + int32_t framesPerPeriod = ((MA_PFN_AAudioStream_getFramesPerDataCallback)pContext->aaudio.AAudioStream_getFramesPerDataCallback)((mal_AAudioStream*)pDevice->aaudio.pStreamPlayback); if (framesPerPeriod > 0) { pDevice->playback.internalPeriods = 1; } else { @@ -20469,18 +20469,18 @@ mal_result mal_device_init__aaudio(mal_context* pContext, const mal_device_confi if (pConfig->deviceType == mal_device_type_duplex) { mal_uint32 rbSizeInFrames = (mal_uint32)mal_calculate_frame_count_after_src(pDevice->sampleRate, pDevice->capture.internalSampleRate, pDevice->capture.internalBufferSizeInFrames); mal_result result = mal_pcm_rb_init(pDevice->capture.format, pDevice->capture.channels, rbSizeInFrames, NULL, &pDevice->aaudio.duplexRB); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { mal_close_stream__aaudio(pDevice->pContext, (mal_AAudioStream*)pDevice->aaudio.pStreamCapture); } if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) { mal_close_stream__aaudio(pDevice->pContext, (mal_AAudioStream*)pDevice->aaudio.pStreamPlayback); } - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[AAudio] Failed to initialize ring buffer.", result); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[AAudio] Failed to initialize ring buffer.", result); } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_start_stream__aaudio(mal_device* pDevice, mal_AAudioStream* pStream) @@ -20489,29 +20489,29 @@ mal_result mal_device_start_stream__aaudio(mal_device* pDevice, mal_AAudioStream mal_assert(pDevice != NULL); - resultAA = ((MAL_PFN_AAudioStream_requestStart)pDevice->pContext->aaudio.AAudioStream_requestStart)(pStream); - if (resultAA != MAL_AAUDIO_OK) { + resultAA = ((MA_PFN_AAudioStream_requestStart)pDevice->pContext->aaudio.AAudioStream_requestStart)(pStream); + if (resultAA != MA_AAUDIO_OK) { return mal_result_from_aaudio(resultAA); } /* Do we actually need to wait for the device to transition into it's started state? */ /* The device should be in either a starting or started state. If it's not set to started we need to wait for it to transition. It should go from starting to started. */ - mal_aaudio_stream_state_t currentState = ((MAL_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream); - if (currentState != MAL_AAUDIO_STREAM_STATE_STARTED) { + mal_aaudio_stream_state_t currentState = ((MA_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream); + if (currentState != MA_AAUDIO_STREAM_STATE_STARTED) { mal_result result; - if (currentState != MAL_AAUDIO_STREAM_STATE_STARTING) { - return MAL_ERROR; /* Expecting the stream to be a starting or started state. */ + if (currentState != MA_AAUDIO_STREAM_STATE_STARTING) { + return MA_ERROR; /* Expecting the stream to be a starting or started state. */ } - result = mal_wait_for_simple_state_transition__aaudio(pDevice->pContext, pStream, currentState, MAL_AAUDIO_STREAM_STATE_STARTED); - if (result != MAL_SUCCESS) { + result = mal_wait_for_simple_state_transition__aaudio(pDevice->pContext, pStream, currentState, MA_AAUDIO_STREAM_STATE_STARTED); + if (result != MA_SUCCESS) { return result; } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_stop_stream__aaudio(mal_device* pDevice, mal_AAudioStream* pStream) @@ -20520,27 +20520,27 @@ mal_result mal_device_stop_stream__aaudio(mal_device* pDevice, mal_AAudioStream* mal_assert(pDevice != NULL); - resultAA = ((MAL_PFN_AAudioStream_requestStop)pDevice->pContext->aaudio.AAudioStream_requestStop)(pStream); - if (resultAA != MAL_AAUDIO_OK) { + resultAA = ((MA_PFN_AAudioStream_requestStop)pDevice->pContext->aaudio.AAudioStream_requestStop)(pStream); + if (resultAA != MA_AAUDIO_OK) { return mal_result_from_aaudio(resultAA); } /* The device should be in either a stopping or stopped state. If it's not set to started we need to wait for it to transition. It should go from stopping to stopped. */ - mal_aaudio_stream_state_t currentState = ((MAL_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream); - if (currentState != MAL_AAUDIO_STREAM_STATE_STOPPED) { + mal_aaudio_stream_state_t currentState = ((MA_PFN_AAudioStream_getState)pDevice->pContext->aaudio.AAudioStream_getState)(pStream); + if (currentState != MA_AAUDIO_STREAM_STATE_STOPPED) { mal_result result; - if (currentState != MAL_AAUDIO_STREAM_STATE_STOPPING) { - return MAL_ERROR; /* Expecting the stream to be a stopping or stopped state. */ + if (currentState != MA_AAUDIO_STREAM_STATE_STOPPING) { + return MA_ERROR; /* Expecting the stream to be a stopping or stopped state. */ } - result = mal_wait_for_simple_state_transition__aaudio(pDevice->pContext, pStream, currentState, MAL_AAUDIO_STREAM_STATE_STOPPED); - if (result != MAL_SUCCESS) { + result = mal_wait_for_simple_state_transition__aaudio(pDevice->pContext, pStream, currentState, MA_AAUDIO_STREAM_STATE_STOPPED); + if (result != MA_SUCCESS) { return result; } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_start__aaudio(mal_device* pDevice) @@ -20549,14 +20549,14 @@ mal_result mal_device_start__aaudio(mal_device* pDevice) if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { mal_result result = mal_device_start_stream__aaudio(pDevice, (mal_AAudioStream*)pDevice->aaudio.pStreamCapture); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) { mal_result result = mal_device_start_stream__aaudio(pDevice, (mal_AAudioStream*)pDevice->aaudio.pStreamPlayback); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { if (pDevice->type == mal_device_type_duplex) { mal_device_stop_stream__aaudio(pDevice, (mal_AAudioStream*)pDevice->aaudio.pStreamCapture); } @@ -20564,7 +20564,7 @@ mal_result mal_device_start__aaudio(mal_device* pDevice) } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_stop__aaudio(mal_device* pDevice) @@ -20573,14 +20573,14 @@ mal_result mal_device_stop__aaudio(mal_device* pDevice) if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { mal_result result = mal_device_stop_stream__aaudio(pDevice, (mal_AAudioStream*)pDevice->aaudio.pStreamCapture); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) { mal_result result = mal_device_stop_stream__aaudio(pDevice, (mal_AAudioStream*)pDevice->aaudio.pStreamPlayback); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } @@ -20590,7 +20590,7 @@ mal_result mal_device_stop__aaudio(mal_device* pDevice) onStop(pDevice); } - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -20602,7 +20602,7 @@ mal_result mal_context_uninit__aaudio(mal_context* pContext) mal_dlclose(pContext->aaudio.hAAudio); pContext->aaudio.hAAudio = NULL; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_init__aaudio(mal_context* pContext) @@ -20622,7 +20622,7 @@ mal_result mal_context_init__aaudio(mal_context* pContext) } if (pContext->aaudio.hAAudio == NULL) { - return MAL_FAILED_TO_INIT_BACKEND; + return MA_FAILED_TO_INIT_BACKEND; } pContext->aaudio.AAudio_createStreamBuilder = (mal_proc)mal_dlsym(pContext->aaudio.hAAudio, "AAudio_createStreamBuilder"); @@ -20650,7 +20650,7 @@ mal_result mal_context_init__aaudio(mal_context* pContext) pContext->aaudio.AAudioStream_requestStart = (mal_proc)mal_dlsym(pContext->aaudio.hAAudio, "AAudioStream_requestStart"); pContext->aaudio.AAudioStream_requestStop = (mal_proc)mal_dlsym(pContext->aaudio.hAAudio, "AAudioStream_requestStop"); - pContext->isBackendAsynchronous = MAL_TRUE; + pContext->isBackendAsynchronous = MA_TRUE; pContext->onUninit = mal_context_uninit__aaudio; pContext->onDeviceIDEqual = mal_context_is_device_id_equal__aaudio; @@ -20661,7 +20661,7 @@ mal_result mal_context_init__aaudio(mal_context* pContext) pContext->onDeviceStart = mal_device_start__aaudio; pContext->onDeviceStop = mal_device_stop__aaudio; - return MAL_SUCCESS; + return MA_SUCCESS; } #endif // AAudio @@ -20671,9 +20671,9 @@ mal_result mal_context_init__aaudio(mal_context* pContext) // OpenSL|ES Backend // /////////////////////////////////////////////////////////////////////////////// -#ifdef MAL_HAS_OPENSL +#ifdef MA_HAS_OPENSL #include -#ifdef MAL_ANDROID +#ifdef MA_ANDROID #include #endif @@ -20682,15 +20682,15 @@ SLObjectItf g_malEngineObjectSL = NULL; SLEngineItf g_malEngineSL = NULL; mal_uint32 g_malOpenSLInitCounter = 0; -#define MAL_OPENSL_OBJ(p) (*((SLObjectItf)(p))) -#define MAL_OPENSL_OUTPUTMIX(p) (*((SLOutputMixItf)(p))) -#define MAL_OPENSL_PLAY(p) (*((SLPlayItf)(p))) -#define MAL_OPENSL_RECORD(p) (*((SLRecordItf)(p))) +#define MA_OPENSL_OBJ(p) (*((SLObjectItf)(p))) +#define MA_OPENSL_OUTPUTMIX(p) (*((SLOutputMixItf)(p))) +#define MA_OPENSL_PLAY(p) (*((SLPlayItf)(p))) +#define MA_OPENSL_RECORD(p) (*((SLRecordItf)(p))) -#ifdef MAL_ANDROID -#define MAL_OPENSL_BUFFERQUEUE(p) (*((SLAndroidSimpleBufferQueueItf)(p))) +#ifdef MA_ANDROID +#define MA_OPENSL_BUFFERQUEUE(p) (*((SLAndroidSimpleBufferQueueItf)(p))) #else -#define MAL_OPENSL_BUFFERQUEUE(p) (*((SLBufferQueueItf)(p))) +#define MA_OPENSL_BUFFERQUEUE(p) (*((SLBufferQueueItf)(p))) #endif // Converts an individual OpenSL-style channel identifier (SL_SPEAKER_FRONT_LEFT, etc.) to miniaudio. @@ -20698,58 +20698,58 @@ mal_uint8 mal_channel_id_to_mal__opensl(SLuint32 id) { switch (id) { - case SL_SPEAKER_FRONT_LEFT: return MAL_CHANNEL_FRONT_LEFT; - case SL_SPEAKER_FRONT_RIGHT: return MAL_CHANNEL_FRONT_RIGHT; - case SL_SPEAKER_FRONT_CENTER: return MAL_CHANNEL_FRONT_CENTER; - case SL_SPEAKER_LOW_FREQUENCY: return MAL_CHANNEL_LFE; - case SL_SPEAKER_BACK_LEFT: return MAL_CHANNEL_BACK_LEFT; - case SL_SPEAKER_BACK_RIGHT: return MAL_CHANNEL_BACK_RIGHT; - case SL_SPEAKER_FRONT_LEFT_OF_CENTER: return MAL_CHANNEL_FRONT_LEFT_CENTER; - case SL_SPEAKER_FRONT_RIGHT_OF_CENTER: return MAL_CHANNEL_FRONT_RIGHT_CENTER; - case SL_SPEAKER_BACK_CENTER: return MAL_CHANNEL_BACK_CENTER; - case SL_SPEAKER_SIDE_LEFT: return MAL_CHANNEL_SIDE_LEFT; - case SL_SPEAKER_SIDE_RIGHT: return MAL_CHANNEL_SIDE_RIGHT; - case SL_SPEAKER_TOP_CENTER: return MAL_CHANNEL_TOP_CENTER; - case SL_SPEAKER_TOP_FRONT_LEFT: return MAL_CHANNEL_TOP_FRONT_LEFT; - case SL_SPEAKER_TOP_FRONT_CENTER: return MAL_CHANNEL_TOP_FRONT_CENTER; - case SL_SPEAKER_TOP_FRONT_RIGHT: return MAL_CHANNEL_TOP_FRONT_RIGHT; - case SL_SPEAKER_TOP_BACK_LEFT: return MAL_CHANNEL_TOP_BACK_LEFT; - case SL_SPEAKER_TOP_BACK_CENTER: return MAL_CHANNEL_TOP_BACK_CENTER; - case SL_SPEAKER_TOP_BACK_RIGHT: return MAL_CHANNEL_TOP_BACK_RIGHT; + case SL_SPEAKER_FRONT_LEFT: return MA_CHANNEL_FRONT_LEFT; + case SL_SPEAKER_FRONT_RIGHT: return MA_CHANNEL_FRONT_RIGHT; + case SL_SPEAKER_FRONT_CENTER: return MA_CHANNEL_FRONT_CENTER; + case SL_SPEAKER_LOW_FREQUENCY: return MA_CHANNEL_LFE; + case SL_SPEAKER_BACK_LEFT: return MA_CHANNEL_BACK_LEFT; + case SL_SPEAKER_BACK_RIGHT: return MA_CHANNEL_BACK_RIGHT; + case SL_SPEAKER_FRONT_LEFT_OF_CENTER: return MA_CHANNEL_FRONT_LEFT_CENTER; + case SL_SPEAKER_FRONT_RIGHT_OF_CENTER: return MA_CHANNEL_FRONT_RIGHT_CENTER; + case SL_SPEAKER_BACK_CENTER: return MA_CHANNEL_BACK_CENTER; + case SL_SPEAKER_SIDE_LEFT: return MA_CHANNEL_SIDE_LEFT; + case SL_SPEAKER_SIDE_RIGHT: return MA_CHANNEL_SIDE_RIGHT; + case SL_SPEAKER_TOP_CENTER: return MA_CHANNEL_TOP_CENTER; + case SL_SPEAKER_TOP_FRONT_LEFT: return MA_CHANNEL_TOP_FRONT_LEFT; + case SL_SPEAKER_TOP_FRONT_CENTER: return MA_CHANNEL_TOP_FRONT_CENTER; + case SL_SPEAKER_TOP_FRONT_RIGHT: return MA_CHANNEL_TOP_FRONT_RIGHT; + case SL_SPEAKER_TOP_BACK_LEFT: return MA_CHANNEL_TOP_BACK_LEFT; + case SL_SPEAKER_TOP_BACK_CENTER: return MA_CHANNEL_TOP_BACK_CENTER; + case SL_SPEAKER_TOP_BACK_RIGHT: return MA_CHANNEL_TOP_BACK_RIGHT; default: return 0; } } -// Converts an individual miniaudio channel identifier (MAL_CHANNEL_FRONT_LEFT, etc.) to OpenSL-style. +// Converts an individual miniaudio channel identifier (MA_CHANNEL_FRONT_LEFT, etc.) to OpenSL-style. SLuint32 mal_channel_id_to_opensl(mal_uint8 id) { switch (id) { - case MAL_CHANNEL_MONO: return SL_SPEAKER_FRONT_CENTER; - case MAL_CHANNEL_FRONT_LEFT: return SL_SPEAKER_FRONT_LEFT; - case MAL_CHANNEL_FRONT_RIGHT: return SL_SPEAKER_FRONT_RIGHT; - case MAL_CHANNEL_FRONT_CENTER: return SL_SPEAKER_FRONT_CENTER; - case MAL_CHANNEL_LFE: return SL_SPEAKER_LOW_FREQUENCY; - case MAL_CHANNEL_BACK_LEFT: return SL_SPEAKER_BACK_LEFT; - case MAL_CHANNEL_BACK_RIGHT: return SL_SPEAKER_BACK_RIGHT; - case MAL_CHANNEL_FRONT_LEFT_CENTER: return SL_SPEAKER_FRONT_LEFT_OF_CENTER; - case MAL_CHANNEL_FRONT_RIGHT_CENTER: return SL_SPEAKER_FRONT_RIGHT_OF_CENTER; - case MAL_CHANNEL_BACK_CENTER: return SL_SPEAKER_BACK_CENTER; - case MAL_CHANNEL_SIDE_LEFT: return SL_SPEAKER_SIDE_LEFT; - case MAL_CHANNEL_SIDE_RIGHT: return SL_SPEAKER_SIDE_RIGHT; - case MAL_CHANNEL_TOP_CENTER: return SL_SPEAKER_TOP_CENTER; - case MAL_CHANNEL_TOP_FRONT_LEFT: return SL_SPEAKER_TOP_FRONT_LEFT; - case MAL_CHANNEL_TOP_FRONT_CENTER: return SL_SPEAKER_TOP_FRONT_CENTER; - case MAL_CHANNEL_TOP_FRONT_RIGHT: return SL_SPEAKER_TOP_FRONT_RIGHT; - case MAL_CHANNEL_TOP_BACK_LEFT: return SL_SPEAKER_TOP_BACK_LEFT; - case MAL_CHANNEL_TOP_BACK_CENTER: return SL_SPEAKER_TOP_BACK_CENTER; - case MAL_CHANNEL_TOP_BACK_RIGHT: return SL_SPEAKER_TOP_BACK_RIGHT; + case MA_CHANNEL_MONO: return SL_SPEAKER_FRONT_CENTER; + case MA_CHANNEL_FRONT_LEFT: return SL_SPEAKER_FRONT_LEFT; + case MA_CHANNEL_FRONT_RIGHT: return SL_SPEAKER_FRONT_RIGHT; + case MA_CHANNEL_FRONT_CENTER: return SL_SPEAKER_FRONT_CENTER; + case MA_CHANNEL_LFE: return SL_SPEAKER_LOW_FREQUENCY; + case MA_CHANNEL_BACK_LEFT: return SL_SPEAKER_BACK_LEFT; + case MA_CHANNEL_BACK_RIGHT: return SL_SPEAKER_BACK_RIGHT; + case MA_CHANNEL_FRONT_LEFT_CENTER: return SL_SPEAKER_FRONT_LEFT_OF_CENTER; + case MA_CHANNEL_FRONT_RIGHT_CENTER: return SL_SPEAKER_FRONT_RIGHT_OF_CENTER; + case MA_CHANNEL_BACK_CENTER: return SL_SPEAKER_BACK_CENTER; + case MA_CHANNEL_SIDE_LEFT: return SL_SPEAKER_SIDE_LEFT; + case MA_CHANNEL_SIDE_RIGHT: return SL_SPEAKER_SIDE_RIGHT; + case MA_CHANNEL_TOP_CENTER: return SL_SPEAKER_TOP_CENTER; + case MA_CHANNEL_TOP_FRONT_LEFT: return SL_SPEAKER_TOP_FRONT_LEFT; + case MA_CHANNEL_TOP_FRONT_CENTER: return SL_SPEAKER_TOP_FRONT_CENTER; + case MA_CHANNEL_TOP_FRONT_RIGHT: return SL_SPEAKER_TOP_FRONT_RIGHT; + case MA_CHANNEL_TOP_BACK_LEFT: return SL_SPEAKER_TOP_BACK_LEFT; + case MA_CHANNEL_TOP_BACK_CENTER: return SL_SPEAKER_TOP_BACK_CENTER; + case MA_CHANNEL_TOP_BACK_RIGHT: return SL_SPEAKER_TOP_BACK_RIGHT; default: return 0; } } // Converts a channel mapping to an OpenSL-style channel mask. -SLuint32 mal_channel_map_to_channel_mask__opensl(const mal_channel channelMap[MAL_MAX_CHANNELS], mal_uint32 channels) +SLuint32 mal_channel_map_to_channel_mask__opensl(const mal_channel channelMap[MA_MAX_CHANNELS], mal_uint32 channels) { SLuint32 channelMask = 0; for (mal_uint32 iChannel = 0; iChannel < channels; ++iChannel) { @@ -20760,16 +20760,16 @@ SLuint32 mal_channel_map_to_channel_mask__opensl(const mal_channel channelMap[MA } // Converts an OpenSL-style channel mask to a miniaudio channel map. -void mal_channel_mask_to_channel_map__opensl(SLuint32 channelMask, mal_uint32 channels, mal_channel channelMap[MAL_MAX_CHANNELS]) +void mal_channel_mask_to_channel_map__opensl(SLuint32 channelMask, mal_uint32 channels, mal_channel channelMap[MA_MAX_CHANNELS]) { if (channels == 1 && channelMask == 0) { - channelMap[0] = MAL_CHANNEL_MONO; + channelMap[0] = MA_CHANNEL_MONO; } else if (channels == 2 && channelMask == 0) { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; } else { if (channels == 1 && (channelMask & SL_SPEAKER_FRONT_CENTER) != 0) { - channelMap[0] = MAL_CHANNEL_MONO; + channelMap[0] = MA_CHANNEL_MONO; } else { // Just iterate over each bit. mal_uint32 iChannel = 0; @@ -20816,7 +20816,7 @@ SLuint32 mal_round_to_standard_sample_rate__opensl(SLuint32 samplesPerSec) } // Android doesn't support more than 48000. -#ifndef MAL_ANDROID +#ifndef MA_ANDROID if (samplesPerSec <= SL_SAMPLINGRATE_64) { return SL_SAMPLINGRATE_64; } @@ -20852,14 +20852,14 @@ mal_result mal_context_enumerate_devices__opensl(mal_context* pContext, mal_enum mal_assert(g_malOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to enumerate devices. */ if (g_malOpenSLInitCounter == 0) { - return MAL_INVALID_OPERATION; + return MA_INVALID_OPERATION; } // TODO: Test Me. // // This is currently untested, so for now we are just returning default devices. -#if 0 && !defined(MAL_ANDROID) - mal_bool32 isTerminated = MAL_FALSE; +#if 0 && !defined(MA_ANDROID) + mal_bool32 isTerminated = MA_FALSE; SLuint32 pDeviceIDs[128]; SLint32 deviceCount = sizeof(pDeviceIDs) / sizeof(pDeviceIDs[0]); @@ -20875,7 +20875,7 @@ mal_result mal_context_enumerate_devices__opensl(mal_context* pContext, mal_enum if (!isTerminated) { resultSL = (*deviceCaps)->GetAvailableAudioOutputs(deviceCaps, &deviceCount, pDeviceIDs); if (resultSL != SL_RESULT_SUCCESS) { - return MAL_NO_DEVICE; + return MA_NO_DEVICE; } for (SLint32 iDevice = 0; iDevice < deviceCount; ++iDevice) { @@ -20889,8 +20889,8 @@ mal_result mal_context_enumerate_devices__opensl(mal_context* pContext, mal_enum mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), (const char*)desc.pDeviceName, (size_t)-1); mal_bool32 cbResult = callback(pContext, mal_device_type_playback, &deviceInfo, pUserData); - if (cbResult == MAL_FALSE) { - isTerminated = MAL_TRUE; + if (cbResult == MA_FALSE) { + isTerminated = MA_TRUE; break; } } @@ -20901,7 +20901,7 @@ mal_result mal_context_enumerate_devices__opensl(mal_context* pContext, mal_enum if (!isTerminated) { resultSL = (*deviceCaps)->GetAvailableAudioInputs(deviceCaps, &deviceCount, pDeviceIDs); if (resultSL != SL_RESULT_SUCCESS) { - return MAL_NO_DEVICE; + return MA_NO_DEVICE; } for (SLint32 iDevice = 0; iDevice < deviceCount; ++iDevice) { @@ -20915,27 +20915,27 @@ mal_result mal_context_enumerate_devices__opensl(mal_context* pContext, mal_enum mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), (const char*)desc.deviceName, (size_t)-1); mal_bool32 cbResult = callback(pContext, mal_device_type_capture, &deviceInfo, pUserData); - if (cbResult == MAL_FALSE) { - isTerminated = MAL_TRUE; + if (cbResult == MA_FALSE) { + isTerminated = MA_TRUE; break; } } } } - return MAL_SUCCESS; + return MA_SUCCESS; #else goto return_default_device; #endif return_default_device:; - mal_bool32 cbResult = MAL_TRUE; + mal_bool32 cbResult = MA_TRUE; // Playback. if (cbResult) { mal_device_info deviceInfo; mal_zero_object(&deviceInfo); - mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MAL_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); cbResult = callback(pContext, mal_device_type_playback, &deviceInfo, pUserData); } @@ -20943,11 +20943,11 @@ return_default_device:; if (cbResult) { mal_device_info deviceInfo; mal_zero_object(&deviceInfo); - mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MAL_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); cbResult = callback(pContext, mal_device_type_capture, &deviceInfo, pUserData); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_get_device_info__opensl(mal_context* pContext, mal_device_type deviceType, const mal_device_id* pDeviceID, mal_share_mode shareMode, mal_device_info* pDeviceInfo) @@ -20956,18 +20956,18 @@ mal_result mal_context_get_device_info__opensl(mal_context* pContext, mal_device mal_assert(g_malOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to get device info. */ if (g_malOpenSLInitCounter == 0) { - return MAL_INVALID_OPERATION; + return MA_INVALID_OPERATION; } /* No exclusive mode with OpenSL|ES. */ if (shareMode == mal_share_mode_exclusive) { - return MAL_SHARE_MODE_NOT_SUPPORTED; + return MA_SHARE_MODE_NOT_SUPPORTED; } // TODO: Test Me. // // This is currently untested, so for now we are just returning default devices. -#if 0 && !defined(MAL_ANDROID) +#if 0 && !defined(MA_ANDROID) SLAudioIODeviceCapabilitiesItf deviceCaps; SLresult resultSL = (*g_malEngineObjectSL)->GetInterface(g_malEngineObjectSL, SL_IID_AUDIOIODEVICECAPABILITIES, &deviceCaps); if (resultSL != SL_RESULT_SUCCESS) { @@ -20979,7 +20979,7 @@ mal_result mal_context_get_device_info__opensl(mal_context* pContext, mal_device SLAudioOutputDescriptor desc; resultSL = (*deviceCaps)->QueryAudioOutputCapabilities(deviceCaps, pDeviceID->opensl, &desc); if (resultSL != SL_RESULT_SUCCESS) { - return MAL_NO_DEVICE; + return MA_NO_DEVICE; } mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), (const char*)desc.pDeviceName, (size_t)-1); @@ -20987,7 +20987,7 @@ mal_result mal_context_get_device_info__opensl(mal_context* pContext, mal_device SLAudioInputDescriptor desc; resultSL = (*deviceCaps)->QueryAudioInputCapabilities(deviceCaps, pDeviceID->opensl, &desc); if (resultSL != SL_RESULT_SUCCESS) { - return MAL_NO_DEVICE; + return MA_NO_DEVICE; } mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), (const char*)desc.deviceName, (size_t)-1); @@ -21002,15 +21002,15 @@ return_default_device: if (pDeviceID != NULL) { if ((deviceType == mal_device_type_playback && pDeviceID->opensl != SL_DEFAULTDEVICEID_AUDIOOUTPUT) || (deviceType == mal_device_type_capture && pDeviceID->opensl != SL_DEFAULTDEVICEID_AUDIOINPUT)) { - return MAL_NO_DEVICE; // Don't know the device. + return MA_NO_DEVICE; // Don't know the device. } } // Name / Description if (deviceType == mal_device_type_playback) { - mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MAL_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { - mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MAL_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } goto return_detailed_info; @@ -21028,16 +21028,16 @@ return_detailed_info: pDeviceInfo->formatCount = 2; pDeviceInfo->formats[0] = mal_format_u8; pDeviceInfo->formats[1] = mal_format_s16; -#if defined(MAL_ANDROID) && __ANDROID_API__ >= 21 +#if defined(MA_ANDROID) && __ANDROID_API__ >= 21 pDeviceInfo->formats[pDeviceInfo->formatCount] = mal_format_f32; pDeviceInfo->formatCount += 1; #endif - return MAL_SUCCESS; + return MA_SUCCESS; } -#ifdef MAL_ANDROID +#ifdef MA_ANDROID //void mal_buffer_queue_callback_capture__opensl_android(SLAndroidSimpleBufferQueueItf pBufferQueue, SLuint32 eventFlags, const void* pBuffer, SLuint32 bufferSize, SLuint32 dataUsed, void* pContext) void mal_buffer_queue_callback_capture__opensl_android(SLAndroidSimpleBufferQueueItf pBufferQueue, void* pUserData) { @@ -21051,7 +21051,7 @@ void mal_buffer_queue_callback_capture__opensl_android(SLAndroidSimpleBufferQueu // but unfortunately it looks like Android is only supporting OpenSL|ES 1.0.1 for now :( /* Don't do anything if the device is not started. */ - if (pDevice->state != MAL_STATE_STARTED) { + if (pDevice->state != MA_STATE_STARTED) { return; } @@ -21064,7 +21064,7 @@ void mal_buffer_queue_callback_capture__opensl_android(SLAndroidSimpleBufferQueu mal_device__send_frames_to_client(pDevice, (pDevice->capture.internalBufferSizeInFrames / pDevice->capture.internalPeriods), pBuffer); } - SLresult resultSL = MAL_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture, pBuffer, periodSizeInBytes); + SLresult resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture, pBuffer, periodSizeInBytes); if (resultSL != SL_RESULT_SUCCESS) { return; } @@ -21080,7 +21080,7 @@ void mal_buffer_queue_callback_playback__opensl_android(SLAndroidSimpleBufferQue (void)pBufferQueue; /* Don't do anything if the device is not started. */ - if (pDevice->state != MAL_STATE_STARTED) { + if (pDevice->state != MA_STATE_STARTED) { return; } @@ -21093,7 +21093,7 @@ void mal_buffer_queue_callback_playback__opensl_android(SLAndroidSimpleBufferQue mal_device__read_frames_from_client(pDevice, (pDevice->playback.internalBufferSizeInFrames / pDevice->playback.internalPeriods), pBuffer); } - SLresult resultSL = MAL_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback, pBuffer, periodSizeInBytes); + SLresult resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback, pBuffer, periodSizeInBytes); if (resultSL != SL_RESULT_SUCCESS) { return; } @@ -21113,7 +21113,7 @@ void mal_device_uninit__opensl(mal_device* pDevice) if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { if (pDevice->opensl.pAudioRecorderObj) { - MAL_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->Destroy((SLObjectItf)pDevice->opensl.pAudioRecorderObj); + MA_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->Destroy((SLObjectItf)pDevice->opensl.pAudioRecorderObj); } mal_free(pDevice->opensl.pBufferCapture); @@ -21121,10 +21121,10 @@ void mal_device_uninit__opensl(mal_device* pDevice) if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) { if (pDevice->opensl.pAudioPlayerObj) { - MAL_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->Destroy((SLObjectItf)pDevice->opensl.pAudioPlayerObj); + MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->Destroy((SLObjectItf)pDevice->opensl.pAudioPlayerObj); } if (pDevice->opensl.pOutputMixObj) { - MAL_OPENSL_OBJ(pDevice->opensl.pOutputMixObj)->Destroy((SLObjectItf)pDevice->opensl.pOutputMixObj); + MA_OPENSL_OBJ(pDevice->opensl.pOutputMixObj)->Destroy((SLObjectItf)pDevice->opensl.pOutputMixObj); } mal_free(pDevice->opensl.pBufferPlayback); @@ -21135,7 +21135,7 @@ void mal_device_uninit__opensl(mal_device* pDevice) } } -#if defined(MAL_ANDROID) && __ANDROID_API__ >= 21 +#if defined(MA_ANDROID) && __ANDROID_API__ >= 21 typedef SLAndroidDataFormat_PCM_EX mal_SLDataFormat_PCM; #else typedef SLDataFormat_PCM mal_SLDataFormat_PCM; @@ -21143,7 +21143,7 @@ typedef SLDataFormat_PCM mal_SLDataFormat_PCM; mal_result mal_SLDataFormat_PCM_init__opensl(mal_format format, mal_uint32 channels, mal_uint32 sampleRate, const mal_channel* channelMap, mal_SLDataFormat_PCM* pDataFormat) { -#if defined(MAL_ANDROID) && __ANDROID_API__ >= 21 +#if defined(MA_ANDROID) && __ANDROID_API__ >= 21 if (format == mal_format_f32) { pDataFormat->formatType = SL_ANDROID_DATAFORMAT_PCM_EX; pDataFormat->representation = SL_ANDROID_PCM_REPRESENTATION_FLOAT; @@ -21166,7 +21166,7 @@ mal_result mal_SLDataFormat_PCM_init__opensl(mal_format format, mal_uint32 chann - Only u8 and s16 formats are supported. - Maximum sample rate of 48000. */ -#ifdef MAL_ANDROID +#ifdef MA_ANDROID if (pDataFormat->numChannels > 2) { pDataFormat->numChannels = 2; } @@ -21194,16 +21194,16 @@ mal_result mal_SLDataFormat_PCM_init__opensl(mal_format format, mal_uint32 chann pDataFormat->containerSize = pDataFormat->bitsPerSample; /* Always tightly packed for now. */ - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_deconstruct_SLDataFormat_PCM__opensl(mal_SLDataFormat_PCM* pDataFormat, mal_format* pFormat, mal_uint32* pChannels, mal_uint32* pSampleRate, mal_channel* pChannelMap) { - mal_bool32 isFloatingPoint = MAL_FALSE; -#if defined(MAL_ANDROID) && __ANDROID_API__ >= 21 + mal_bool32 isFloatingPoint = MA_FALSE; +#if defined(MA_ANDROID) && __ANDROID_API__ >= 21 if (pDataFormat->formatType == SL_ANDROID_DATAFORMAT_PCM_EX) { mal_assert(pDataFormat->representation == SL_ANDROID_PCM_REPRESENTATION_FLOAT); - isFloatingPoint = MAL_TRUE; + isFloatingPoint = MA_TRUE; } #endif if (isFloatingPoint) { @@ -21226,7 +21226,7 @@ mal_result mal_deconstruct_SLDataFormat_PCM__opensl(mal_SLDataFormat_PCM* pDataF *pSampleRate = ((SLDataFormat_PCM*)pDataFormat)->samplesPerSec / 1000; mal_channel_mask_to_channel_map__opensl(pDataFormat->channelMask, pDataFormat->numChannels, pChannelMap); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_init__opensl(mal_context* pContext, const mal_device_config* pConfig, mal_device* pDevice) @@ -21235,7 +21235,7 @@ mal_result mal_device_init__opensl(mal_context* pContext, const mal_device_confi mal_assert(g_malOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to initialize a new device. */ if (g_malOpenSLInitCounter == 0) { - return MAL_INVALID_OPERATION; + return MA_INVALID_OPERATION; } /* @@ -21243,14 +21243,14 @@ mal_result mal_device_init__opensl(mal_context* pContext, const mal_device_confi been able to test with and I currently depend on Android-specific extensions (simple buffer queues). */ -#ifndef MAL_ANDROID - return MAL_NO_BACKEND; +#ifndef MA_ANDROID + return MA_NO_BACKEND; #endif /* No exclusive mode with OpenSL|ES. */ if (((pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) && pConfig->playback.shareMode == mal_share_mode_exclusive) || ((pConfig->deviceType == mal_device_type_capture || pConfig->deviceType == mal_device_type_duplex) && pConfig->capture.shareMode == mal_share_mode_exclusive)) { - return MAL_SHARE_MODE_NOT_SUPPORTED; + return MA_SHARE_MODE_NOT_SUPPORTED; } /* Now we can start initializing the device properly. */ @@ -21296,27 +21296,27 @@ mal_result mal_device_init__opensl(mal_context* pContext, const mal_device_confi if (resultSL != SL_RESULT_SUCCESS) { mal_device_uninit__opensl(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to create audio recorder.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to create audio recorder.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } - if (MAL_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->Realize((SLObjectItf)pDevice->opensl.pAudioRecorderObj, SL_BOOLEAN_FALSE) != SL_RESULT_SUCCESS) { + if (MA_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->Realize((SLObjectItf)pDevice->opensl.pAudioRecorderObj, SL_BOOLEAN_FALSE) != SL_RESULT_SUCCESS) { mal_device_uninit__opensl(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to realize audio recorder.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to realize audio recorder.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } - if (MAL_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioRecorderObj, SL_IID_RECORD, &pDevice->opensl.pAudioRecorder) != SL_RESULT_SUCCESS) { + if (MA_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioRecorderObj, SL_IID_RECORD, &pDevice->opensl.pAudioRecorder) != SL_RESULT_SUCCESS) { mal_device_uninit__opensl(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_RECORD interface.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_RECORD interface.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } - if (MAL_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioRecorderObj, SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &pDevice->opensl.pBufferQueueCapture) != SL_RESULT_SUCCESS) { + if (MA_OPENSL_OBJ(pDevice->opensl.pAudioRecorderObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioRecorderObj, SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &pDevice->opensl.pBufferQueueCapture) != SL_RESULT_SUCCESS) { mal_device_uninit__opensl(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_ANDROIDSIMPLEBUFFERQUEUE interface.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_ANDROIDSIMPLEBUFFERQUEUE interface.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } - if (MAL_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->RegisterCallback((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture, mal_buffer_queue_callback_capture__opensl_android, pDevice) != SL_RESULT_SUCCESS) { + if (MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->RegisterCallback((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture, mal_buffer_queue_callback_capture__opensl_android, pDevice) != SL_RESULT_SUCCESS) { mal_device_uninit__opensl(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to register buffer queue callback.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to register buffer queue callback.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } /* The internal format is determined by the "pcm" object. */ @@ -21335,9 +21335,9 @@ mal_result mal_device_init__opensl(mal_context* pContext, const mal_device_confi pDevice->opensl.pBufferCapture = (mal_uint8*)mal_malloc(bufferSizeInBytes); if (pDevice->opensl.pBufferCapture == NULL) { mal_device_uninit__opensl(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to allocate memory for data buffer.", MAL_OUT_OF_MEMORY); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to allocate memory for data buffer.", MA_OUT_OF_MEMORY); } - MAL_ZERO_MEMORY(pDevice->opensl.pBufferCapture, bufferSizeInBytes); + MA_ZERO_MEMORY(pDevice->opensl.pBufferCapture, bufferSizeInBytes); } if (pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) { @@ -21347,23 +21347,23 @@ mal_result mal_device_init__opensl(mal_context* pContext, const mal_device_confi SLresult resultSL = (*g_malEngineSL)->CreateOutputMix(g_malEngineSL, (SLObjectItf*)&pDevice->opensl.pOutputMixObj, 0, NULL, NULL); if (resultSL != SL_RESULT_SUCCESS) { mal_device_uninit__opensl(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to create output mix.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to create output mix.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } - if (MAL_OPENSL_OBJ(pDevice->opensl.pOutputMixObj)->Realize((SLObjectItf)pDevice->opensl.pOutputMixObj, SL_BOOLEAN_FALSE)) { + if (MA_OPENSL_OBJ(pDevice->opensl.pOutputMixObj)->Realize((SLObjectItf)pDevice->opensl.pOutputMixObj, SL_BOOLEAN_FALSE)) { mal_device_uninit__opensl(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to realize output mix object.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to realize output mix object.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } - if (MAL_OPENSL_OBJ(pDevice->opensl.pOutputMixObj)->GetInterface((SLObjectItf)pDevice->opensl.pOutputMixObj, SL_IID_OUTPUTMIX, &pDevice->opensl.pOutputMix) != SL_RESULT_SUCCESS) { + if (MA_OPENSL_OBJ(pDevice->opensl.pOutputMixObj)->GetInterface((SLObjectItf)pDevice->opensl.pOutputMixObj, SL_IID_OUTPUTMIX, &pDevice->opensl.pOutputMix) != SL_RESULT_SUCCESS) { mal_device_uninit__opensl(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_OUTPUTMIX interface.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_OUTPUTMIX interface.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } /* Set the output device. */ if (pConfig->playback.pDeviceID != NULL) { SLuint32 deviceID_OpenSL = pConfig->playback.pDeviceID->opensl; - MAL_OPENSL_OUTPUTMIX(pDevice->opensl.pOutputMix)->ReRoute((SLOutputMixItf)pDevice->opensl.pOutputMix, 1, &deviceID_OpenSL); + MA_OPENSL_OUTPUTMIX(pDevice->opensl.pOutputMix)->ReRoute((SLOutputMixItf)pDevice->opensl.pOutputMix, 1, &deviceID_OpenSL); } SLDataSource source; @@ -21394,27 +21394,27 @@ mal_result mal_device_init__opensl(mal_context* pContext, const mal_device_confi if (resultSL != SL_RESULT_SUCCESS) { mal_device_uninit__opensl(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to create audio player.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to create audio player.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } - if (MAL_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->Realize((SLObjectItf)pDevice->opensl.pAudioPlayerObj, SL_BOOLEAN_FALSE) != SL_RESULT_SUCCESS) { + if (MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->Realize((SLObjectItf)pDevice->opensl.pAudioPlayerObj, SL_BOOLEAN_FALSE) != SL_RESULT_SUCCESS) { mal_device_uninit__opensl(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to realize audio player.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to realize audio player.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } - if (MAL_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioPlayerObj, SL_IID_PLAY, &pDevice->opensl.pAudioPlayer) != SL_RESULT_SUCCESS) { + if (MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioPlayerObj, SL_IID_PLAY, &pDevice->opensl.pAudioPlayer) != SL_RESULT_SUCCESS) { mal_device_uninit__opensl(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_PLAY interface.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_PLAY interface.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } - if (MAL_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioPlayerObj, SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &pDevice->opensl.pBufferQueuePlayback) != SL_RESULT_SUCCESS) { + if (MA_OPENSL_OBJ(pDevice->opensl.pAudioPlayerObj)->GetInterface((SLObjectItf)pDevice->opensl.pAudioPlayerObj, SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &pDevice->opensl.pBufferQueuePlayback) != SL_RESULT_SUCCESS) { mal_device_uninit__opensl(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_ANDROIDSIMPLEBUFFERQUEUE interface.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to retrieve SL_IID_ANDROIDSIMPLEBUFFERQUEUE interface.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } - if (MAL_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->RegisterCallback((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback, mal_buffer_queue_callback_playback__opensl_android, pDevice) != SL_RESULT_SUCCESS) { + if (MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->RegisterCallback((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback, mal_buffer_queue_callback_playback__opensl_android, pDevice) != SL_RESULT_SUCCESS) { mal_device_uninit__opensl(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to register buffer queue callback.", MAL_FAILED_TO_OPEN_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to register buffer queue callback.", MA_FAILED_TO_OPEN_BACKEND_DEVICE); } /* The internal format is determined by the "pcm" object. */ @@ -21433,21 +21433,21 @@ mal_result mal_device_init__opensl(mal_context* pContext, const mal_device_confi pDevice->opensl.pBufferPlayback = (mal_uint8*)mal_malloc(bufferSizeInBytes); if (pDevice->opensl.pBufferPlayback == NULL) { mal_device_uninit__opensl(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to allocate memory for data buffer.", MAL_OUT_OF_MEMORY); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to allocate memory for data buffer.", MA_OUT_OF_MEMORY); } - MAL_ZERO_MEMORY(pDevice->opensl.pBufferPlayback, bufferSizeInBytes); + MA_ZERO_MEMORY(pDevice->opensl.pBufferPlayback, bufferSizeInBytes); } if (pConfig->deviceType == mal_device_type_duplex) { mal_uint32 rbSizeInFrames = (mal_uint32)mal_calculate_frame_count_after_src(pDevice->sampleRate, pDevice->capture.internalSampleRate, pDevice->capture.internalBufferSizeInFrames); mal_result result = mal_pcm_rb_init(pDevice->capture.format, pDevice->capture.channels, rbSizeInFrames, NULL, &pDevice->opensl.duplexRB); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { mal_device_uninit__opensl(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to initialize ring buffer.", result); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to initialize ring buffer.", result); } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_start__opensl(mal_device* pDevice) @@ -21456,49 +21456,49 @@ mal_result mal_device_start__opensl(mal_device* pDevice) mal_assert(g_malOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it and then attempted to start the device. */ if (g_malOpenSLInitCounter == 0) { - return MAL_INVALID_OPERATION; + return MA_INVALID_OPERATION; } if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { - SLresult resultSL = MAL_OPENSL_RECORD(pDevice->opensl.pAudioRecorder)->SetRecordState((SLRecordItf)pDevice->opensl.pAudioRecorder, SL_RECORDSTATE_RECORDING); + SLresult resultSL = MA_OPENSL_RECORD(pDevice->opensl.pAudioRecorder)->SetRecordState((SLRecordItf)pDevice->opensl.pAudioRecorder, SL_RECORDSTATE_RECORDING); if (resultSL != SL_RESULT_SUCCESS) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to start internal capture device.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to start internal capture device.", MA_FAILED_TO_START_BACKEND_DEVICE); } size_t periodSizeInBytes = (pDevice->capture.internalBufferSizeInFrames / pDevice->capture.internalPeriods) * mal_get_bytes_per_frame(pDevice->capture.internalFormat, pDevice->capture.internalChannels); for (mal_uint32 iPeriod = 0; iPeriod < pDevice->capture.internalPeriods; ++iPeriod) { - resultSL = MAL_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture, pDevice->opensl.pBufferCapture + (periodSizeInBytes * iPeriod), periodSizeInBytes); + resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture, pDevice->opensl.pBufferCapture + (periodSizeInBytes * iPeriod), periodSizeInBytes); if (resultSL != SL_RESULT_SUCCESS) { - MAL_OPENSL_RECORD(pDevice->opensl.pAudioRecorder)->SetRecordState((SLRecordItf)pDevice->opensl.pAudioRecorder, SL_RECORDSTATE_STOPPED); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to enqueue buffer for capture device.", MAL_FAILED_TO_START_BACKEND_DEVICE); + MA_OPENSL_RECORD(pDevice->opensl.pAudioRecorder)->SetRecordState((SLRecordItf)pDevice->opensl.pAudioRecorder, SL_RECORDSTATE_STOPPED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to enqueue buffer for capture device.", MA_FAILED_TO_START_BACKEND_DEVICE); } } } if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) { - SLresult resultSL = MAL_OPENSL_PLAY(pDevice->opensl.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->opensl.pAudioPlayer, SL_PLAYSTATE_PLAYING); + SLresult resultSL = MA_OPENSL_PLAY(pDevice->opensl.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->opensl.pAudioPlayer, SL_PLAYSTATE_PLAYING); if (resultSL != SL_RESULT_SUCCESS) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to start internal playback device.", MAL_FAILED_TO_START_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to start internal playback device.", MA_FAILED_TO_START_BACKEND_DEVICE); } /* In playback mode (no duplex) we need to load some initial buffers. In duplex mode we need to enqueu silent buffers. */ if (pDevice->type == mal_device_type_duplex) { - MAL_ZERO_MEMORY(pDevice->opensl.pBufferPlayback, pDevice->playback.internalBufferSizeInFrames * mal_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels)); + MA_ZERO_MEMORY(pDevice->opensl.pBufferPlayback, pDevice->playback.internalBufferSizeInFrames * mal_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels)); } else { mal_device__read_frames_from_client(pDevice, pDevice->playback.internalBufferSizeInFrames, pDevice->opensl.pBufferPlayback); } size_t periodSizeInBytes = (pDevice->playback.internalBufferSizeInFrames / pDevice->playback.internalPeriods) * mal_get_bytes_per_frame(pDevice->playback.internalFormat, pDevice->playback.internalChannels); for (mal_uint32 iPeriod = 0; iPeriod < pDevice->playback.internalPeriods; ++iPeriod) { - resultSL = MAL_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback, pDevice->opensl.pBufferPlayback + (periodSizeInBytes * iPeriod), periodSizeInBytes); + resultSL = MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Enqueue((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback, pDevice->opensl.pBufferPlayback + (periodSizeInBytes * iPeriod), periodSizeInBytes); if (resultSL != SL_RESULT_SUCCESS) { - MAL_OPENSL_PLAY(pDevice->opensl.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->opensl.pAudioPlayer, SL_PLAYSTATE_STOPPED); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to enqueue buffer for playback device.", MAL_FAILED_TO_START_BACKEND_DEVICE); + MA_OPENSL_PLAY(pDevice->opensl.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->opensl.pAudioPlayer, SL_PLAYSTATE_STOPPED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to enqueue buffer for playback device.", MA_FAILED_TO_START_BACKEND_DEVICE); } } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_stop__opensl(mal_device* pDevice) @@ -21507,27 +21507,27 @@ mal_result mal_device_stop__opensl(mal_device* pDevice) mal_assert(g_malOpenSLInitCounter > 0); /* <-- If you trigger this it means you've either not initialized the context, or you've uninitialized it before stopping/uninitializing the device. */ if (g_malOpenSLInitCounter == 0) { - return MAL_INVALID_OPERATION; + return MA_INVALID_OPERATION; } /* TODO: Wait until all buffers have been processed. Hint: Maybe SLAndroidSimpleBufferQueue::GetState() could be used in a loop? */ if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { - SLresult resultSL = MAL_OPENSL_RECORD(pDevice->opensl.pAudioRecorder)->SetRecordState((SLRecordItf)pDevice->opensl.pAudioRecorder, SL_RECORDSTATE_STOPPED); + SLresult resultSL = MA_OPENSL_RECORD(pDevice->opensl.pAudioRecorder)->SetRecordState((SLRecordItf)pDevice->opensl.pAudioRecorder, SL_RECORDSTATE_STOPPED); if (resultSL != SL_RESULT_SUCCESS) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to stop internal capture device.", MAL_FAILED_TO_STOP_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to stop internal capture device.", MA_FAILED_TO_STOP_BACKEND_DEVICE); } - MAL_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->Clear((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture); + MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueueCapture)->Clear((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueueCapture); } if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) { - SLresult resultSL = MAL_OPENSL_PLAY(pDevice->opensl.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->opensl.pAudioPlayer, SL_PLAYSTATE_STOPPED); + SLresult resultSL = MA_OPENSL_PLAY(pDevice->opensl.pAudioPlayer)->SetPlayState((SLPlayItf)pDevice->opensl.pAudioPlayer, SL_PLAYSTATE_STOPPED); if (resultSL != SL_RESULT_SUCCESS) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "[OpenSL] Failed to stop internal playback device.", MAL_FAILED_TO_STOP_BACKEND_DEVICE); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "[OpenSL] Failed to stop internal playback device.", MA_FAILED_TO_STOP_BACKEND_DEVICE); } - MAL_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Clear((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback); + MA_OPENSL_BUFFERQUEUE(pDevice->opensl.pBufferQueuePlayback)->Clear((SLAndroidSimpleBufferQueueItf)pDevice->opensl.pBufferQueuePlayback); } /* Make sure the client is aware that the device has stopped. There may be an OpenSL|ES callback for this, but I haven't found it. */ @@ -21536,7 +21536,7 @@ mal_result mal_device_stop__opensl(mal_device* pDevice) onStop(pDevice); } - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -21553,7 +21553,7 @@ mal_result mal_context_uninit__opensl(mal_context* pContext) } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_init__opensl(mal_context* pContext) @@ -21566,7 +21566,7 @@ mal_result mal_context_init__opensl(mal_context* pContext) SLresult resultSL = slCreateEngine(&g_malEngineObjectSL, 0, NULL, 0, NULL, NULL); if (resultSL != SL_RESULT_SUCCESS) { mal_atomic_decrement_32(&g_malOpenSLInitCounter); - return MAL_NO_BACKEND; + return MA_NO_BACKEND; } (*g_malEngineObjectSL)->Realize(g_malEngineObjectSL, SL_BOOLEAN_FALSE); @@ -21575,11 +21575,11 @@ mal_result mal_context_init__opensl(mal_context* pContext) if (resultSL != SL_RESULT_SUCCESS) { (*g_malEngineObjectSL)->Destroy(g_malEngineObjectSL); mal_atomic_decrement_32(&g_malOpenSLInitCounter); - return MAL_NO_BACKEND; + return MA_NO_BACKEND; } } - pContext->isBackendAsynchronous = MAL_TRUE; + pContext->isBackendAsynchronous = MA_TRUE; pContext->onUninit = mal_context_uninit__opensl; pContext->onDeviceIDEqual = mal_context_is_device_id_equal__opensl; @@ -21590,7 +21590,7 @@ mal_result mal_context_init__opensl(mal_context* pContext) pContext->onDeviceStart = mal_device_start__opensl; pContext->onDeviceStop = mal_device_stop__opensl; - return MAL_SUCCESS; + return MA_SUCCESS; } #endif /* OpenSL|ES */ @@ -21600,7 +21600,7 @@ mal_result mal_context_init__opensl(mal_context* pContext) // Web Audio Backend // /////////////////////////////////////////////////////////////////////////////// -#ifdef MAL_HAS_WEBAUDIO +#ifdef MA_HAS_WEBAUDIO #include mal_bool32 mal_is_capture_supported__webaudio() @@ -21652,13 +21652,13 @@ mal_result mal_context_enumerate_devices__webaudio(mal_context* pContext, mal_en mal_assert(callback != NULL); // Only supporting default devices for now. - mal_bool32 cbResult = MAL_TRUE; + mal_bool32 cbResult = MA_TRUE; // Playback. if (cbResult) { mal_device_info deviceInfo; mal_zero_object(&deviceInfo); - mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MAL_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); cbResult = callback(pContext, mal_device_type_playback, &deviceInfo, pUserData); } @@ -21667,12 +21667,12 @@ mal_result mal_context_enumerate_devices__webaudio(mal_context* pContext, mal_en if (mal_is_capture_supported__webaudio()) { mal_device_info deviceInfo; mal_zero_object(&deviceInfo); - mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MAL_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(deviceInfo.name, sizeof(deviceInfo.name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); cbResult = callback(pContext, mal_device_type_capture, &deviceInfo, pUserData); } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_get_device_info__webaudio(mal_context* pContext, mal_device_type deviceType, const mal_device_id* pDeviceID, mal_share_mode shareMode, mal_device_info* pDeviceInfo) @@ -21681,11 +21681,11 @@ mal_result mal_context_get_device_info__webaudio(mal_context* pContext, mal_devi /* No exclusive mode with Web Audio. */ if (shareMode == mal_share_mode_exclusive) { - return MAL_SHARE_MODE_NOT_SUPPORTED; + return MA_SHARE_MODE_NOT_SUPPORTED; } if (deviceType == mal_device_type_capture && !mal_is_capture_supported__webaudio()) { - return MAL_NO_DEVICE; + return MA_NO_DEVICE; } @@ -21693,14 +21693,14 @@ mal_result mal_context_get_device_info__webaudio(mal_context* pContext, mal_devi /* Only supporting default devices for now. */ if (deviceType == mal_device_type_playback) { - mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MAL_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_PLAYBACK_DEVICE_NAME, (size_t)-1); } else { - mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MAL_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); + mal_strncpy_s(pDeviceInfo->name, sizeof(pDeviceInfo->name), MA_DEFAULT_CAPTURE_DEVICE_NAME, (size_t)-1); } /* Web Audio can support any number of channels and sample rates. It only supports f32 formats, however. */ pDeviceInfo->minChannels = 1; - pDeviceInfo->maxChannels = MAL_MAX_CHANNELS; + pDeviceInfo->maxChannels = MA_MAX_CHANNELS; if (pDeviceInfo->maxChannels > 32) { pDeviceInfo->maxChannels = 32; /* Maximum output channel count is 32 for createScriptProcessor() (JavaScript). */ } @@ -21718,14 +21718,14 @@ mal_result mal_context_get_device_info__webaudio(mal_context* pContext, mal_devi }, 0); /* Must pass in a dummy argument for C99 compatibility. */ pDeviceInfo->maxSampleRate = pDeviceInfo->minSampleRate; if (pDeviceInfo->minSampleRate == 0) { - return MAL_NO_DEVICE; + return MA_NO_DEVICE; } /* Web Audio only supports f32. */ pDeviceInfo->formatCount = 1; pDeviceInfo->formats[0] = mal_format_f32; - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -21795,7 +21795,7 @@ mal_result mal_device_init_by_type__webaudio(mal_context* pContext, const mal_de mal_assert(pDevice != NULL); if (deviceType == mal_device_type_capture && !mal_is_capture_supported__webaudio()) { - return MAL_NO_DEVICE; + return MA_NO_DEVICE; } /* Try calculating an appropriate buffer size. */ @@ -21968,7 +21968,7 @@ mal_result mal_device_init_by_type__webaudio(mal_context* pContext, const mal_de }, (deviceType == mal_device_type_capture) ? pConfig->capture.channels : pConfig->playback.channels, pConfig->sampleRate, internalBufferSizeInFrames, deviceType == mal_device_type_capture, pDevice); if (deviceIndex < 0) { - return MAL_FAILED_TO_OPEN_BACKEND_DEVICE; + return MA_FAILED_TO_OPEN_BACKEND_DEVICE; } if (deviceType == mal_device_type_capture) { @@ -21989,7 +21989,7 @@ mal_result mal_device_init_by_type__webaudio(mal_context* pContext, const mal_de pDevice->playback.internalPeriods = 1; } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_init__webaudio(mal_context* pContext, const mal_device_config* pConfig, mal_device* pDevice) @@ -21999,19 +21999,19 @@ mal_result mal_device_init__webaudio(mal_context* pContext, const mal_device_con /* No exclusive mode with Web Audio. */ if (((pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) && pConfig->playback.shareMode == mal_share_mode_exclusive) || ((pConfig->deviceType == mal_device_type_capture || pConfig->deviceType == mal_device_type_duplex) && pConfig->capture.shareMode == mal_share_mode_exclusive)) { - return MAL_SHARE_MODE_NOT_SUPPORTED; + return MA_SHARE_MODE_NOT_SUPPORTED; } if (pConfig->deviceType == mal_device_type_capture || pConfig->deviceType == mal_device_type_duplex) { result = mal_device_init_by_type__webaudio(pContext, pConfig, mal_device_type_capture, pDevice); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } if (pConfig->deviceType == mal_device_type_playback || pConfig->deviceType == mal_device_type_duplex) { result = mal_device_init_by_type__webaudio(pContext, pConfig, mal_device_type_playback, pDevice); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { if (pConfig->deviceType == mal_device_type_duplex) { mal_device_uninit_by_index__webaudio(pDevice, mal_device_type_capture, pDevice->webaudio.indexCapture); } @@ -22027,7 +22027,7 @@ mal_result mal_device_init__webaudio(mal_context* pContext, const mal_device_con if (pConfig->deviceType == mal_device_type_duplex) { mal_uint32 rbSizeInFrames = (mal_uint32)mal_calculate_frame_count_after_src(pDevice->sampleRate, pDevice->capture.internalSampleRate, pDevice->capture.internalBufferSizeInFrames) * 2; result = mal_pcm_rb_init(pDevice->capture.format, pDevice->capture.channels, rbSizeInFrames, NULL, &pDevice->webaudio.duplexRB); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { mal_device_uninit_by_index__webaudio(pDevice, mal_device_type_capture, pDevice->webaudio.indexCapture); } @@ -22038,7 +22038,7 @@ mal_result mal_device_init__webaudio(mal_context* pContext, const mal_device_con } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_start__webaudio(mal_device* pDevice) @@ -22057,7 +22057,7 @@ mal_result mal_device_start__webaudio(mal_device* pDevice) }, pDevice->webaudio.indexPlayback); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_device_stop__webaudio(mal_device* pDevice) @@ -22081,7 +22081,7 @@ mal_result mal_device_stop__webaudio(mal_device* pDevice) onStop(pDevice); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_uninit__webaudio(mal_context* pContext) @@ -22092,7 +22092,7 @@ mal_result mal_context_uninit__webaudio(mal_context* pContext) /* Nothing needs to be done here. */ (void)pContext; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_init__webaudio(mal_context* pContext) @@ -22154,11 +22154,11 @@ mal_result mal_context_init__webaudio(mal_context* pContext) }, 0); /* Must pass in a dummy argument for C99 compatibility. */ if (resultFromJS != 1) { - return MAL_FAILED_TO_INIT_BACKEND; + return MA_FAILED_TO_INIT_BACKEND; } - pContext->isBackendAsynchronous = MAL_TRUE; + pContext->isBackendAsynchronous = MA_TRUE; pContext->onUninit = mal_context_uninit__webaudio; pContext->onDeviceIDEqual = mal_context_is_device_id_equal__webaudio; @@ -22169,7 +22169,7 @@ mal_result mal_context_init__webaudio(mal_context* pContext) pContext->onDeviceStart = mal_device_start__webaudio; pContext->onDeviceStop = mal_device_stop__webaudio; - return MAL_SUCCESS; + return MA_SUCCESS; } #endif // Web Audio @@ -22178,22 +22178,22 @@ mal_result mal_context_init__webaudio(mal_context* pContext) mal_bool32 mal__is_channel_map_valid(const mal_channel* channelMap, mal_uint32 channels) { // A blank channel map should be allowed, in which case it should use an appropriate default which will depend on context. - if (channelMap[0] != MAL_CHANNEL_NONE) { + if (channelMap[0] != MA_CHANNEL_NONE) { if (channels == 0) { - return MAL_FALSE; // No channels. + return MA_FALSE; // No channels. } // A channel cannot be present in the channel map more than once. for (mal_uint32 iChannel = 0; iChannel < channels; ++iChannel) { for (mal_uint32 jChannel = iChannel + 1; jChannel < channels; ++jChannel) { if (channelMap[iChannel] == channelMap[jChannel]) { - return MAL_FALSE; + return MA_FALSE; } } } } - return MAL_TRUE; + return MA_TRUE; } @@ -22245,7 +22245,7 @@ void mal_device__post_init_setup(mal_device* pDevice, mal_device_type deviceType if (deviceType == mal_device_type_capture || deviceType == mal_device_type_duplex) { /* Converting from internal device format to public format. */ mal_pcm_converter_config converterConfig = mal_pcm_converter_config_init_new(); - converterConfig.neverConsumeEndOfInput = MAL_TRUE; + converterConfig.neverConsumeEndOfInput = MA_TRUE; converterConfig.pUserData = pDevice; converterConfig.formatIn = pDevice->capture.internalFormat; converterConfig.channelsIn = pDevice->capture.internalChannels; @@ -22262,7 +22262,7 @@ void mal_device__post_init_setup(mal_device* pDevice, mal_device_type deviceType if (deviceType == mal_device_type_playback || deviceType == mal_device_type_duplex) { /* Converting from public format to device format. */ mal_pcm_converter_config converterConfig = mal_pcm_converter_config_init_new(); - converterConfig.neverConsumeEndOfInput = MAL_TRUE; + converterConfig.neverConsumeEndOfInput = MA_TRUE; converterConfig.pUserData = pDevice; converterConfig.formatIn = pDevice->playback.format; converterConfig.channelsIn = pDevice->playback.channels; @@ -22286,20 +22286,20 @@ void mal_device__post_init_setup(mal_device* pDevice, mal_device_type deviceType } -mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData) +mal_thread_result MA_THREADCALL mal_worker_thread(void* pData) { mal_device* pDevice = (mal_device*)pData; mal_assert(pDevice != NULL); -#ifdef MAL_WIN32 - mal_CoInitializeEx(pDevice->pContext, NULL, MAL_COINIT_VALUE); +#ifdef MA_WIN32 + mal_CoInitializeEx(pDevice->pContext, NULL, MA_COINIT_VALUE); #endif - // When the device is being initialized it's initial state is set to MAL_STATE_UNINITIALIZED. Before returning from + // When the device is being initialized it's initial state is set to MA_STATE_UNINITIALIZED. Before returning from // mal_device_init(), the state needs to be set to something valid. In miniaudio the device's default state immediately // after initialization is stopped, so therefore we need to mark the device as such. miniaudio will wait on the worker // thread to signal an event to know when the worker thread is ready for action. - mal_device__set_state(pDevice, MAL_STATE_STOPPED); + mal_device__set_state(pDevice, MA_STATE_STOPPED); mal_event_signal(&pDevice->stopEvent); for (;;) { /* <-- This loop just keeps the thread alive. The main audio loop is inside. */ @@ -22307,20 +22307,20 @@ mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData) mal_event_wait(&pDevice->wakeupEvent); // Default result code. - pDevice->workResult = MAL_SUCCESS; + pDevice->workResult = MA_SUCCESS; // If the reason for the wake up is that we are terminating, just break from the loop. - if (mal_device__get_state(pDevice) == MAL_STATE_UNINITIALIZED) { + if (mal_device__get_state(pDevice) == MA_STATE_UNINITIALIZED) { break; } // Getting to this point means the device is wanting to get started. The function that has requested that the device // be started will be waiting on an event (pDevice->startEvent) which means we need to make sure we signal the event // in both the success and error case. It's important that the state of the device is set _before_ signaling the event. - mal_assert(mal_device__get_state(pDevice) == MAL_STATE_STARTING); + mal_assert(mal_device__get_state(pDevice) == MA_STATE_STARTING); /* Make sure the state is set appropriately. */ - mal_device__set_state(pDevice, MAL_STATE_STARTED); + mal_device__set_state(pDevice, MA_STATE_STARTED); mal_event_signal(&pDevice->startEvent); if (pDevice->pContext->onDeviceMainLoop != NULL) { @@ -22356,8 +22356,8 @@ mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData) /* Main Loop */ mal_assert(periodSizeInFrames >= 1); - while (mal_device__get_state(pDevice) == MAL_STATE_STARTED) { - mal_result result = MAL_SUCCESS; + while (mal_device__get_state(pDevice) == MA_STATE_STARTED) { + mal_result result = MA_SUCCESS; mal_uint32 totalFramesProcessed = 0; if (pDevice->type == mal_device_type_duplex) { @@ -22373,7 +22373,7 @@ mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData) } result = pDevice->pContext->onDeviceRead(pDevice, captureDeviceData, framesToProcess); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { break; } @@ -22411,7 +22411,7 @@ mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData) } result = pDevice->pContext->onDeviceWrite(pDevice, playbackDeviceData, playbackDeviceFramesCount); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { break; } @@ -22425,7 +22425,7 @@ mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData) } /* In case an error happened from onDeviceWrite()... */ - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { break; } } @@ -22462,7 +22462,7 @@ mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData) } /* Get out of the loop if read()/write() returned an error. It probably means the device has been stopped. */ - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { break; } } @@ -22472,7 +22472,7 @@ mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData) // Getting here means we have broken from the main loop which happens the application has requested that device be stopped. Note that this // may have actually already happened above if the device was lost and miniaudio has attempted to re-initialize the device. In this case we // don't want to be doing this a second time. - if (mal_device__get_state(pDevice) != MAL_STATE_UNINITIALIZED) { + if (mal_device__get_state(pDevice) != MA_STATE_UNINITIALIZED) { if (pDevice->pContext->onDeviceStop) { pDevice->pContext->onDeviceStop(pDevice); } @@ -22487,8 +22487,8 @@ mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData) // A function somewhere is waiting for the device to have stopped for real so we need to signal an event to allow it to continue. Note that // it's possible that the device has been uninitialized which means we need to _not_ change the status to stopped. We cannot go from an // uninitialized state to stopped state. - if (mal_device__get_state(pDevice) != MAL_STATE_UNINITIALIZED) { - mal_device__set_state(pDevice, MAL_STATE_STOPPED); + if (mal_device__get_state(pDevice) != MA_STATE_UNINITIALIZED) { + mal_device__set_state(pDevice, MA_STATE_STOPPED); mal_event_signal(&pDevice->stopEvent); } } @@ -22496,7 +22496,7 @@ mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData) // Make sure we aren't continuously waiting on a stop event. mal_event_signal(&pDevice->stopEvent); // <-- Is this still needed? -#ifdef MAL_WIN32 +#ifdef MA_WIN32 mal_CoUninitialize(pDevice->pContext); #endif @@ -22507,12 +22507,12 @@ mal_thread_result MAL_THREADCALL mal_worker_thread(void* pData) // Helper for determining whether or not the given device is initialized. mal_bool32 mal_device__is_initialized(mal_device* pDevice) { - if (pDevice == NULL) return MAL_FALSE; - return mal_device__get_state(pDevice) != MAL_STATE_UNINITIALIZED; + if (pDevice == NULL) return MA_FALSE; + return mal_device__get_state(pDevice) != MA_STATE_UNINITIALIZED; } -#ifdef MAL_WIN32 +#ifdef MA_WIN32 mal_result mal_context_uninit_backend_apis__win32(mal_context* pContext) { mal_CoUninitialize(pContext); @@ -22520,16 +22520,16 @@ mal_result mal_context_uninit_backend_apis__win32(mal_context* pContext) mal_dlclose(pContext->win32.hOle32DLL); mal_dlclose(pContext->win32.hAdvapi32DLL); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_init_backend_apis__win32(mal_context* pContext) { -#ifdef MAL_WIN32_DESKTOP +#ifdef MA_WIN32_DESKTOP // Ole32.dll pContext->win32.hOle32DLL = mal_dlopen("ole32.dll"); if (pContext->win32.hOle32DLL == NULL) { - return MAL_FAILED_TO_INIT_BACKEND; + return MA_FAILED_TO_INIT_BACKEND; } pContext->win32.CoInitializeEx = (mal_proc)mal_dlsym(pContext->win32.hOle32DLL, "CoInitializeEx"); @@ -22543,7 +22543,7 @@ mal_result mal_context_init_backend_apis__win32(mal_context* pContext) // User32.dll pContext->win32.hUser32DLL = mal_dlopen("user32.dll"); if (pContext->win32.hUser32DLL == NULL) { - return MAL_FAILED_TO_INIT_BACKEND; + return MA_FAILED_TO_INIT_BACKEND; } pContext->win32.GetForegroundWindow = (mal_proc)mal_dlsym(pContext->win32.hUser32DLL, "GetForegroundWindow"); @@ -22553,7 +22553,7 @@ mal_result mal_context_init_backend_apis__win32(mal_context* pContext) // Advapi32.dll pContext->win32.hAdvapi32DLL = mal_dlopen("advapi32.dll"); if (pContext->win32.hAdvapi32DLL == NULL) { - return MAL_FAILED_TO_INIT_BACKEND; + return MA_FAILED_TO_INIT_BACKEND; } pContext->win32.RegOpenKeyExA = (mal_proc)mal_dlsym(pContext->win32.hAdvapi32DLL, "RegOpenKeyExA"); @@ -22561,25 +22561,25 @@ mal_result mal_context_init_backend_apis__win32(mal_context* pContext) pContext->win32.RegQueryValueExA = (mal_proc)mal_dlsym(pContext->win32.hAdvapi32DLL, "RegQueryValueExA"); #endif - mal_CoInitializeEx(pContext, NULL, MAL_COINIT_VALUE); - return MAL_SUCCESS; + mal_CoInitializeEx(pContext, NULL, MA_COINIT_VALUE); + return MA_SUCCESS; } #else mal_result mal_context_uninit_backend_apis__nix(mal_context* pContext) { -#if defined(MAL_USE_RUNTIME_LINKING_FOR_PTHREAD) && !defined(MAL_NO_RUNTIME_LINKING) +#if defined(MA_USE_RUNTIME_LINKING_FOR_PTHREAD) && !defined(MA_NO_RUNTIME_LINKING) mal_dlclose(pContext->posix.pthreadSO); #else (void)pContext; #endif - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_init_backend_apis__nix(mal_context* pContext) { // pthread -#if defined(MAL_USE_RUNTIME_LINKING_FOR_PTHREAD) && !defined(MAL_NO_RUNTIME_LINKING) +#if defined(MA_USE_RUNTIME_LINKING_FOR_PTHREAD) && !defined(MA_NO_RUNTIME_LINKING) const char* libpthreadFileNames[] = { "libpthread.so", "libpthread.so.0", @@ -22594,7 +22594,7 @@ mal_result mal_context_init_backend_apis__nix(mal_context* pContext) } if (pContext->posix.pthreadSO == NULL) { - return MAL_FAILED_TO_INIT_BACKEND; + return MA_FAILED_TO_INIT_BACKEND; } pContext->posix.pthread_create = (mal_proc)mal_dlsym(pContext->posix.pthreadSO, "pthread_create"); @@ -22632,14 +22632,14 @@ mal_result mal_context_init_backend_apis__nix(mal_context* pContext) #endif #endif - return MAL_SUCCESS; + return MA_SUCCESS; } #endif mal_result mal_context_init_backend_apis(mal_context* pContext) { mal_result result; -#ifdef MAL_WIN32 +#ifdef MA_WIN32 result = mal_context_init_backend_apis__win32(pContext); #else result = mal_context_init_backend_apis__nix(pContext); @@ -22651,7 +22651,7 @@ mal_result mal_context_init_backend_apis(mal_context* pContext) mal_result mal_context_uninit_backend_apis(mal_context* pContext) { mal_result result; -#ifdef MAL_WIN32 +#ifdef MA_WIN32 result = mal_context_uninit_backend_apis__win32(pContext); #else result = mal_context_uninit_backend_apis__nix(pContext); @@ -22669,7 +22669,7 @@ mal_bool32 mal_context_is_backend_asynchronous(mal_context* pContext) mal_result mal_context_init(const mal_backend backends[], mal_uint32 backendCount, const mal_context_config* pConfig, mal_context* pContext) { if (pContext == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_zero_object(pContext); @@ -22683,7 +22683,7 @@ mal_result mal_context_init(const mal_backend backends[], mal_uint32 backendCoun // Backend APIs need to be initialized first. This is where external libraries will be loaded and linked. mal_result result = mal_context_init_backend_apis(pContext); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -22704,87 +22704,87 @@ mal_result mal_context_init(const mal_backend backends[], mal_uint32 backendCoun for (mal_uint32 iBackend = 0; iBackend < backendsToIterateCount; ++iBackend) { mal_backend backend = pBackendsToIterate[iBackend]; - result = MAL_NO_BACKEND; + result = MA_NO_BACKEND; switch (backend) { - #ifdef MAL_HAS_WASAPI + #ifdef MA_HAS_WASAPI case mal_backend_wasapi: { result = mal_context_init__wasapi(pContext); } break; #endif - #ifdef MAL_HAS_DSOUND + #ifdef MA_HAS_DSOUND case mal_backend_dsound: { result = mal_context_init__dsound(pContext); } break; #endif - #ifdef MAL_HAS_WINMM + #ifdef MA_HAS_WINMM case mal_backend_winmm: { result = mal_context_init__winmm(pContext); } break; #endif - #ifdef MAL_HAS_ALSA + #ifdef MA_HAS_ALSA case mal_backend_alsa: { result = mal_context_init__alsa(pContext); } break; #endif - #ifdef MAL_HAS_PULSEAUDIO + #ifdef MA_HAS_PULSEAUDIO case mal_backend_pulseaudio: { result = mal_context_init__pulse(pContext); } break; #endif - #ifdef MAL_HAS_JACK + #ifdef MA_HAS_JACK case mal_backend_jack: { result = mal_context_init__jack(pContext); } break; #endif - #ifdef MAL_HAS_COREAUDIO + #ifdef MA_HAS_COREAUDIO case mal_backend_coreaudio: { result = mal_context_init__coreaudio(pContext); } break; #endif - #ifdef MAL_HAS_SNDIO + #ifdef MA_HAS_SNDIO case mal_backend_sndio: { result = mal_context_init__sndio(pContext); } break; #endif - #ifdef MAL_HAS_AUDIO4 + #ifdef MA_HAS_AUDIO4 case mal_backend_audio4: { result = mal_context_init__audio4(pContext); } break; #endif - #ifdef MAL_HAS_OSS + #ifdef MA_HAS_OSS case mal_backend_oss: { result = mal_context_init__oss(pContext); } break; #endif - #ifdef MAL_HAS_AAUDIO + #ifdef MA_HAS_AAUDIO case mal_backend_aaudio: { result = mal_context_init__aaudio(pContext); } break; #endif - #ifdef MAL_HAS_OPENSL + #ifdef MA_HAS_OPENSL case mal_backend_opensl: { result = mal_context_init__opensl(pContext); } break; #endif - #ifdef MAL_HAS_WEBAUDIO + #ifdef MA_HAS_WEBAUDIO case mal_backend_webaudio: { result = mal_context_init__webaudio(pContext); } break; #endif - #ifdef MAL_HAS_NULL + #ifdef MA_HAS_NULL case mal_backend_null: { result = mal_context_init__null(pContext); @@ -22795,17 +22795,17 @@ mal_result mal_context_init(const mal_backend backends[], mal_uint32 backendCoun } // If this iteration was successful, return. - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { result = mal_mutex_init(pContext, &pContext->deviceEnumLock); - if (result != MAL_SUCCESS) { - mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_WARNING, "Failed to initialize mutex for device enumeration. mal_context_get_devices() is not thread safe.", MAL_FAILED_TO_CREATE_MUTEX); + if (result != MA_SUCCESS) { + mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_WARNING, "Failed to initialize mutex for device enumeration. mal_context_get_devices() is not thread safe.", MA_FAILED_TO_CREATE_MUTEX); } result = mal_mutex_init(pContext, &pContext->deviceInfoLock); - if (result != MAL_SUCCESS) { - mal_context_post_error(pContext, NULL, MAL_LOG_LEVEL_WARNING, "Failed to initialize mutex for device info retrieval. mal_context_get_device_info() is not thread safe.", MAL_FAILED_TO_CREATE_MUTEX); + if (result != MA_SUCCESS) { + mal_context_post_error(pContext, NULL, MA_LOG_LEVEL_WARNING, "Failed to initialize mutex for device info retrieval. mal_context_get_device_info() is not thread safe.", MA_FAILED_TO_CREATE_MUTEX); } -#ifdef MAL_DEBUG_OUTPUT +#ifdef MA_DEBUG_OUTPUT printf("[miniaudio] Endian: %s\n", mal_is_little_endian() ? "LE" : "BE"); printf("[miniaudio] SSE2: %s\n", mal_has_sse2() ? "YES" : "NO"); printf("[miniaudio] AVX2: %s\n", mal_has_avx2() ? "YES" : "NO"); @@ -22820,13 +22820,13 @@ mal_result mal_context_init(const mal_backend backends[], mal_uint32 backendCoun // If we get here it means an error occurred. mal_zero_object(pContext); // Safety. - return MAL_NO_BACKEND; + return MA_NO_BACKEND; } mal_result mal_context_uninit(mal_context* pContext) { if (pContext == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } pContext->onUninit(pContext); @@ -22836,14 +22836,14 @@ mal_result mal_context_uninit(mal_context* pContext) mal_mutex_uninit(&pContext->deviceInfoLock); mal_free(pContext->pDeviceInfos); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_context_enumerate_devices(mal_context* pContext, mal_enum_devices_callback_proc callback, void* pUserData) { if (pContext == NULL || pContext->onEnumDevices == NULL || callback == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_result result; @@ -22873,7 +22873,7 @@ mal_bool32 mal_context_get_devices__enum_callback(mal_context* pContext, mal_dev mal_uint32 newCapacity = totalDeviceInfoCount + bufferExpansionCount; mal_device_info* pNewInfos = (mal_device_info*)mal_realloc(pContext->pDeviceInfos, sizeof(*pContext->pDeviceInfos)*newCapacity); if (pNewInfos == NULL) { - return MAL_FALSE; // Out of memory. + return MA_FALSE; // Out of memory. } pContext->pDeviceInfos = pNewInfos; @@ -22898,7 +22898,7 @@ mal_bool32 mal_context_get_devices__enum_callback(mal_context* pContext, mal_dev pContext->captureDeviceInfoCount += 1; } - return MAL_TRUE; + return MA_TRUE; } mal_result mal_context_get_devices(mal_context* pContext, mal_device_info** ppPlaybackDeviceInfos, mal_uint32* pPlaybackDeviceCount, mal_device_info** ppCaptureDeviceInfos, mal_uint32* pCaptureDeviceCount) @@ -22910,7 +22910,7 @@ mal_result mal_context_get_devices(mal_context* pContext, mal_device_info** ppPl if (pCaptureDeviceCount != NULL) *pCaptureDeviceCount = 0; if (pContext == NULL || pContext->onEnumDevices == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } // Note that we don't use mal_context_enumerate_devices() here because we want to do locking at a higher level. @@ -22923,7 +22923,7 @@ mal_result mal_context_get_devices(mal_context* pContext, mal_device_info** ppPl // Now enumerate over available devices. result = pContext->onEnumDevices(pContext, mal_context_get_devices__enum_callback, NULL); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { // Playback devices. if (ppPlaybackDeviceInfos != NULL) { *ppPlaybackDeviceInfos = pContext->pDeviceInfos; @@ -22950,7 +22950,7 @@ mal_result mal_context_get_device_info(mal_context* pContext, mal_device_type de { // NOTE: Do not clear pDeviceInfo on entry. The reason is the pDeviceID may actually point to pDeviceInfo->id which will break things. if (pContext == NULL || pDeviceInfo == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_device_info deviceInfo; @@ -22971,17 +22971,17 @@ mal_result mal_context_get_device_info(mal_context* pContext, mal_device_type de mal_mutex_unlock(&pContext->deviceInfoLock); // Clamp ranges. - deviceInfo.minChannels = mal_max(deviceInfo.minChannels, MAL_MIN_CHANNELS); - deviceInfo.maxChannels = mal_min(deviceInfo.maxChannels, MAL_MAX_CHANNELS); - deviceInfo.minSampleRate = mal_max(deviceInfo.minSampleRate, MAL_MIN_SAMPLE_RATE); - deviceInfo.maxSampleRate = mal_min(deviceInfo.maxSampleRate, MAL_MAX_SAMPLE_RATE); + deviceInfo.minChannels = mal_max(deviceInfo.minChannels, MA_MIN_CHANNELS); + deviceInfo.maxChannels = mal_min(deviceInfo.maxChannels, MA_MAX_CHANNELS); + deviceInfo.minSampleRate = mal_max(deviceInfo.minSampleRate, MA_MIN_SAMPLE_RATE); + deviceInfo.maxSampleRate = mal_min(deviceInfo.maxSampleRate, MA_MAX_SAMPLE_RATE); *pDeviceInfo = deviceInfo; return result; } // Getting here means onGetDeviceInfo has not been set. - return MAL_ERROR; + return MA_ERROR; } @@ -22991,10 +22991,10 @@ mal_result mal_device_init(mal_context* pContext, const mal_device_config* pConf return mal_device_init_ex(NULL, 0, NULL, pConfig, pDevice); } if (pDevice == NULL) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "mal_device_init() called with invalid arguments (pDevice == NULL).", MAL_INVALID_ARGS); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "mal_device_init() called with invalid arguments (pDevice == NULL).", MA_INVALID_ARGS); } if (pConfig == NULL) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "mal_device_init() called with invalid arguments (pConfig == NULL).", MAL_INVALID_ARGS); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "mal_device_init() called with invalid arguments (pConfig == NULL).", MA_INVALID_ARGS); } /* We need to make a copy of the config so we can set default values if they were left unset in the input config. */ @@ -23002,24 +23002,24 @@ mal_result mal_device_init(mal_context* pContext, const mal_device_config* pConf /* Basic config validation. */ if (config.deviceType != mal_device_type_playback && config.deviceType != mal_device_type_capture && config.deviceType != mal_device_type_duplex) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "mal_device_init() called with an invalid config. Device type is invalid. Make sure the device type has been set in the config.", MAL_INVALID_DEVICE_CONFIG); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "mal_device_init() called with an invalid config. Device type is invalid. Make sure the device type has been set in the config.", MA_INVALID_DEVICE_CONFIG); } if (config.deviceType == mal_device_type_capture || config.deviceType == mal_device_type_duplex) { - if (config.capture.channels > MAL_MAX_CHANNELS) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "mal_device_init() called with an invalid config. Capture channel count cannot exceed 32.", MAL_INVALID_DEVICE_CONFIG); + if (config.capture.channels > MA_MAX_CHANNELS) { + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "mal_device_init() called with an invalid config. Capture channel count cannot exceed 32.", MA_INVALID_DEVICE_CONFIG); } if (!mal__is_channel_map_valid(config.capture.channelMap, config.capture.channels)) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "mal_device_init() called with invalid config. Capture channel map is invalid.", MAL_INVALID_DEVICE_CONFIG); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "mal_device_init() called with invalid config. Capture channel map is invalid.", MA_INVALID_DEVICE_CONFIG); } } if (config.deviceType == mal_device_type_playback || config.deviceType == mal_device_type_duplex) { - if (config.playback.channels > MAL_MAX_CHANNELS) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "mal_device_init() called with an invalid config. Playback channel count cannot exceed 32.", MAL_INVALID_DEVICE_CONFIG); + if (config.playback.channels > MA_MAX_CHANNELS) { + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "mal_device_init() called with an invalid config. Playback channel count cannot exceed 32.", MA_INVALID_DEVICE_CONFIG); } if (!mal__is_channel_map_valid(config.playback.channelMap, config.playback.channels)) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "mal_device_init() called with invalid config. Playback channel map is invalid.", MAL_INVALID_DEVICE_CONFIG); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "mal_device_init() called with invalid config. Playback channel map is invalid.", MA_INVALID_DEVICE_CONFIG); } } @@ -23034,52 +23034,52 @@ mal_result mal_device_init(mal_context* pContext, const mal_device_config* pConf if (((mal_uintptr)pDevice % sizeof(pDevice)) != 0) { if (pContext->config.logCallback) { - pContext->config.logCallback(pContext, pDevice, MAL_LOG_LEVEL_WARNING, "WARNING: mal_device_init() called for a device that is not properly aligned. Thread safety is not supported."); + pContext->config.logCallback(pContext, pDevice, MA_LOG_LEVEL_WARNING, "WARNING: mal_device_init() called for a device that is not properly aligned. Thread safety is not supported."); } } // When passing in 0 for the format/channels/rate/chmap it means the device will be using whatever is chosen by the backend. If everything is set // to defaults it means the format conversion pipeline will run on a fast path where data transfer is just passed straight through to the backend. if (config.sampleRate == 0) { - config.sampleRate = MAL_DEFAULT_SAMPLE_RATE; - pDevice->usingDefaultSampleRate = MAL_TRUE; + config.sampleRate = MA_DEFAULT_SAMPLE_RATE; + pDevice->usingDefaultSampleRate = MA_TRUE; } if (config.capture.format == mal_format_unknown) { - config.capture.format = MAL_DEFAULT_FORMAT; - pDevice->capture.usingDefaultFormat = MAL_TRUE; + config.capture.format = MA_DEFAULT_FORMAT; + pDevice->capture.usingDefaultFormat = MA_TRUE; } if (config.capture.channels == 0) { - config.capture.channels = MAL_DEFAULT_CHANNELS; - pDevice->capture.usingDefaultChannels = MAL_TRUE; + config.capture.channels = MA_DEFAULT_CHANNELS; + pDevice->capture.usingDefaultChannels = MA_TRUE; } - if (config.capture.channelMap[0] == MAL_CHANNEL_NONE) { - pDevice->capture.usingDefaultChannelMap = MAL_TRUE; + if (config.capture.channelMap[0] == MA_CHANNEL_NONE) { + pDevice->capture.usingDefaultChannelMap = MA_TRUE; } if (config.playback.format == mal_format_unknown) { - config.playback.format = MAL_DEFAULT_FORMAT; - pDevice->playback.usingDefaultFormat = MAL_TRUE; + config.playback.format = MA_DEFAULT_FORMAT; + pDevice->playback.usingDefaultFormat = MA_TRUE; } if (config.playback.channels == 0) { - config.playback.channels = MAL_DEFAULT_CHANNELS; - pDevice->playback.usingDefaultChannels = MAL_TRUE; + config.playback.channels = MA_DEFAULT_CHANNELS; + pDevice->playback.usingDefaultChannels = MA_TRUE; } - if (config.playback.channelMap[0] == MAL_CHANNEL_NONE) { - pDevice->playback.usingDefaultChannelMap = MAL_TRUE; + if (config.playback.channelMap[0] == MA_CHANNEL_NONE) { + pDevice->playback.usingDefaultChannelMap = MA_TRUE; } // Default buffer size. if (config.bufferSizeInMilliseconds == 0 && config.bufferSizeInFrames == 0) { - config.bufferSizeInMilliseconds = (config.performanceProfile == mal_performance_profile_low_latency) ? MAL_BASE_BUFFER_SIZE_IN_MILLISECONDS_LOW_LATENCY : MAL_BASE_BUFFER_SIZE_IN_MILLISECONDS_CONSERVATIVE; - pDevice->usingDefaultBufferSize = MAL_TRUE; + config.bufferSizeInMilliseconds = (config.performanceProfile == mal_performance_profile_low_latency) ? MA_BASE_BUFFER_SIZE_IN_MILLISECONDS_LOW_LATENCY : MA_BASE_BUFFER_SIZE_IN_MILLISECONDS_CONSERVATIVE; + pDevice->usingDefaultBufferSize = MA_TRUE; } // Default periods. if (config.periods == 0) { - config.periods = MAL_DEFAULT_PERIODS; - pDevice->usingDefaultPeriods = MAL_TRUE; + config.periods = MA_DEFAULT_PERIODS; + pDevice->usingDefaultPeriods = MA_TRUE; } /* @@ -23117,8 +23117,8 @@ mal_result mal_device_init(mal_context* pContext, const mal_device_config* pConf mal_channel_map_copy(pDevice->playback.internalChannelMap, pDevice->playback.channelMap, pDevice->playback.channels); - if (mal_mutex_init(pContext, &pDevice->lock) != MAL_SUCCESS) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "Failed to create mutex.", MAL_FAILED_TO_CREATE_MUTEX); + if (mal_mutex_init(pContext, &pDevice->lock) != MA_SUCCESS) { + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "Failed to create mutex.", MA_FAILED_TO_CREATE_MUTEX); } // When the device is started, the worker thread is the one that does the actual startup of the backend device. We @@ -23126,26 +23126,26 @@ mal_result mal_device_init(mal_context* pContext, const mal_device_config* pConf // // Each of these semaphores is released internally by the worker thread when the work is completed. The start // semaphore is also used to wake up the worker thread. - if (mal_event_init(pContext, &pDevice->wakeupEvent) != MAL_SUCCESS) { + if (mal_event_init(pContext, &pDevice->wakeupEvent) != MA_SUCCESS) { mal_mutex_uninit(&pDevice->lock); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "Failed to create worker thread wakeup event.", MAL_FAILED_TO_CREATE_EVENT); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "Failed to create worker thread wakeup event.", MA_FAILED_TO_CREATE_EVENT); } - if (mal_event_init(pContext, &pDevice->startEvent) != MAL_SUCCESS) { + if (mal_event_init(pContext, &pDevice->startEvent) != MA_SUCCESS) { mal_event_uninit(&pDevice->wakeupEvent); mal_mutex_uninit(&pDevice->lock); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "Failed to create worker thread start event.", MAL_FAILED_TO_CREATE_EVENT); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "Failed to create worker thread start event.", MA_FAILED_TO_CREATE_EVENT); } - if (mal_event_init(pContext, &pDevice->stopEvent) != MAL_SUCCESS) { + if (mal_event_init(pContext, &pDevice->stopEvent) != MA_SUCCESS) { mal_event_uninit(&pDevice->startEvent); mal_event_uninit(&pDevice->wakeupEvent); mal_mutex_uninit(&pDevice->lock); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "Failed to create worker thread stop event.", MAL_FAILED_TO_CREATE_EVENT); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "Failed to create worker thread stop event.", MA_FAILED_TO_CREATE_EVENT); } mal_result result = pContext->onDeviceInit(pContext, &config, pDevice); - if (result != MAL_SUCCESS) { - return MAL_NO_BACKEND; // The error message will have been posted with mal_post_error() by the source of the error so don't bother calling it here. + if (result != MA_SUCCESS) { + return MA_NO_BACKEND; // The error message will have been posted with mal_post_error() by the source of the error so don't bother calling it here. } mal_device__post_init_setup(pDevice, pConfig->deviceType); @@ -23154,15 +23154,15 @@ mal_result mal_device_init(mal_context* pContext, const mal_device_config* pConf // If the backend did not fill out a name for the device, try a generic method. if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { if (pDevice->capture.name[0] == '\0') { - if (mal_context__try_get_device_name_by_id(pContext, mal_device_type_capture, config.capture.pDeviceID, pDevice->capture.name, sizeof(pDevice->capture.name)) != MAL_SUCCESS) { - mal_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), (config.capture.pDeviceID == NULL) ? MAL_DEFAULT_CAPTURE_DEVICE_NAME : "Capture Device", (size_t)-1); + if (mal_context__try_get_device_name_by_id(pContext, mal_device_type_capture, config.capture.pDeviceID, pDevice->capture.name, sizeof(pDevice->capture.name)) != MA_SUCCESS) { + mal_strncpy_s(pDevice->capture.name, sizeof(pDevice->capture.name), (config.capture.pDeviceID == NULL) ? MA_DEFAULT_CAPTURE_DEVICE_NAME : "Capture Device", (size_t)-1); } } } if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) { if (pDevice->playback.name[0] == '\0') { - if (mal_context__try_get_device_name_by_id(pContext, mal_device_type_playback, config.playback.pDeviceID, pDevice->playback.name, sizeof(pDevice->playback.name)) != MAL_SUCCESS) { - mal_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), (config.playback.pDeviceID == NULL) ? MAL_DEFAULT_PLAYBACK_DEVICE_NAME : "Playback Device", (size_t)-1); + if (mal_context__try_get_device_name_by_id(pContext, mal_device_type_playback, config.playback.pDeviceID, pDevice->playback.name, sizeof(pDevice->playback.name)) != MA_SUCCESS) { + mal_strncpy_s(pDevice->playback.name, sizeof(pDevice->playback.name), (config.playback.pDeviceID == NULL) ? MA_DEFAULT_PLAYBACK_DEVICE_NAME : "Playback Device", (size_t)-1); } } } @@ -23171,19 +23171,19 @@ mal_result mal_device_init(mal_context* pContext, const mal_device_config* pConf // Some backends don't require the worker thread. if (!mal_context_is_backend_asynchronous(pContext)) { // The worker thread. - if (mal_thread_create(pContext, &pDevice->thread, mal_worker_thread, pDevice) != MAL_SUCCESS) { + if (mal_thread_create(pContext, &pDevice->thread, mal_worker_thread, pDevice) != MA_SUCCESS) { mal_device_uninit(pDevice); - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "Failed to create worker thread.", MAL_FAILED_TO_CREATE_THREAD); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "Failed to create worker thread.", MA_FAILED_TO_CREATE_THREAD); } // Wait for the worker thread to put the device into it's stopped state for real. mal_event_wait(&pDevice->stopEvent); } else { - mal_device__set_state(pDevice, MAL_STATE_STOPPED); + mal_device__set_state(pDevice, MA_STATE_STOPPED); } -#ifdef MAL_DEBUG_OUTPUT +#ifdef MA_DEBUG_OUTPUT printf("[%s]\n", mal_get_backend_name(pDevice->pContext->backend)); if (pDevice->type == mal_device_type_capture || pDevice->type == mal_device_type_duplex) { printf(" %s (%s)\n", pDevice->capture.name, "Capture"); @@ -23216,19 +23216,19 @@ mal_result mal_device_init(mal_context* pContext, const mal_device_config* pConf #endif - mal_assert(mal_device__get_state(pDevice) == MAL_STATE_STOPPED); - return MAL_SUCCESS; + mal_assert(mal_device__get_state(pDevice) == MA_STATE_STOPPED); + return MA_SUCCESS; } mal_result mal_device_init_ex(const mal_backend backends[], mal_uint32 backendCount, const mal_context_config* pContextConfig, const mal_device_config* pConfig, mal_device* pDevice) { if (pConfig == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_context* pContext = (mal_context*)mal_malloc(sizeof(*pContext)); if (pContext == NULL) { - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } mal_backend defaultBackends[mal_backend_null+1]; @@ -23243,13 +23243,13 @@ mal_result mal_device_init_ex(const mal_backend backends[], mal_uint32 backendCo backendsToIterateCount = mal_countof(defaultBackends); } - mal_result result = MAL_NO_BACKEND; + mal_result result = MA_NO_BACKEND; for (mal_uint32 iBackend = 0; iBackend < backendsToIterateCount; ++iBackend) { result = mal_context_init(&pBackendsToIterate[iBackend], 1, pContextConfig, pContext); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { result = mal_device_init(pContext, pConfig, pDevice); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { break; // Success. } else { mal_context_uninit(pContext); // Failure. @@ -23257,12 +23257,12 @@ mal_result mal_device_init_ex(const mal_backend backends[], mal_uint32 backendCo } } - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { mal_free(pContext); return result; } - pDevice->isOwnerOfContext = MAL_TRUE; + pDevice->isOwnerOfContext = MA_TRUE; return result; } @@ -23279,7 +23279,7 @@ void mal_device_uninit(mal_device* pDevice) } // Putting the device into an uninitialized state will make the worker thread return. - mal_device__set_state(pDevice, MAL_STATE_UNINITIALIZED); + mal_device__set_state(pDevice, MA_STATE_UNINITIALIZED); // Wake up the worker thread and wait for it to properly terminate. if (!mal_context_is_backend_asynchronous(pDevice->pContext)) { @@ -23311,11 +23311,11 @@ void mal_device_set_stop_callback(mal_device* pDevice, mal_stop_proc proc) mal_result mal_device_start(mal_device* pDevice) { if (pDevice == NULL) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "mal_device_start() called with invalid arguments (pDevice == NULL).", MAL_INVALID_ARGS); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "mal_device_start() called with invalid arguments (pDevice == NULL).", MA_INVALID_ARGS); } - if (mal_device__get_state(pDevice) == MAL_STATE_UNINITIALIZED) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "mal_device_start() called for an uninitialized device.", MAL_DEVICE_NOT_INITIALIZED); + if (mal_device__get_state(pDevice) == MA_STATE_UNINITIALIZED) { + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "mal_device_start() called for an uninitialized device.", MA_DEVICE_NOT_INITIALIZED); } /* @@ -23324,22 +23324,22 @@ mal_result mal_device_start(mal_device* pDevice) it's not doing it right. */ if (!mal_device__is_async(pDevice)) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "mal_device_start() called in synchronous mode. This should only be used in asynchronous/callback mode.", MAL_DEVICE_NOT_INITIALIZED); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "mal_device_start() called in synchronous mode. This should only be used in asynchronous/callback mode.", MA_DEVICE_NOT_INITIALIZED); } - mal_result result = MAL_ERROR; + mal_result result = MA_ERROR; mal_mutex_lock(&pDevice->lock); { // Starting and stopping are wrapped in a mutex which means we can assert that the device is in a stopped or paused state. - mal_assert(mal_device__get_state(pDevice) == MAL_STATE_STOPPED); + mal_assert(mal_device__get_state(pDevice) == MA_STATE_STOPPED); - mal_device__set_state(pDevice, MAL_STATE_STARTING); + mal_device__set_state(pDevice, MA_STATE_STARTING); // Asynchronous backends need to be handled differently. if (mal_context_is_backend_asynchronous(pDevice->pContext)) { result = pDevice->pContext->onDeviceStart(pDevice); - if (result == MAL_SUCCESS) { - mal_device__set_state(pDevice, MAL_STATE_STARTED); + if (result == MA_SUCCESS) { + mal_device__set_state(pDevice, MA_STATE_STARTED); } } else { // Synchronous backends are started by signaling an event that's being waited on in the worker thread. We first wake up the @@ -23360,11 +23360,11 @@ mal_result mal_device_start(mal_device* pDevice) mal_result mal_device_stop(mal_device* pDevice) { if (pDevice == NULL) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "mal_device_stop() called with invalid arguments (pDevice == NULL).", MAL_INVALID_ARGS); + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "mal_device_stop() called with invalid arguments (pDevice == NULL).", MA_INVALID_ARGS); } - if (mal_device__get_state(pDevice) == MAL_STATE_UNINITIALIZED) { - return mal_post_error(pDevice, MAL_LOG_LEVEL_ERROR, "mal_device_stop() called for an uninitialized device.", MAL_DEVICE_NOT_INITIALIZED); + if (mal_device__get_state(pDevice) == MA_STATE_UNINITIALIZED) { + return mal_post_error(pDevice, MA_LOG_LEVEL_ERROR, "mal_device_stop() called for an uninitialized device.", MA_DEVICE_NOT_INITIALIZED); } /* @@ -23377,13 +23377,13 @@ mal_result mal_device_stop(mal_device* pDevice) } } - mal_result result = MAL_ERROR; + mal_result result = MA_ERROR; mal_mutex_lock(&pDevice->lock); { // Starting and stopping are wrapped in a mutex which means we can assert that the device is in a started or paused state. - mal_assert(mal_device__get_state(pDevice) == MAL_STATE_STARTED); + mal_assert(mal_device__get_state(pDevice) == MA_STATE_STARTED); - mal_device__set_state(pDevice, MAL_STATE_STOPPING); + mal_device__set_state(pDevice, MA_STATE_STOPPING); // There's no need to wake up the thread like we do when starting. @@ -23392,17 +23392,17 @@ mal_result mal_device_stop(mal_device* pDevice) if (pDevice->pContext->onDeviceStop) { result = pDevice->pContext->onDeviceStop(pDevice); } else { - result = MAL_SUCCESS; + result = MA_SUCCESS; } - mal_device__set_state(pDevice, MAL_STATE_STOPPED); + mal_device__set_state(pDevice, MA_STATE_STOPPED); } else { // Synchronous backends. // We need to wait for the worker thread to become available for work before returning. Note that the worker thread will be // the one who puts the device into the stopped state. Don't call mal_device__set_state() here. mal_event_wait(&pDevice->stopEvent); - result = MAL_SUCCESS; + result = MA_SUCCESS; } } mal_mutex_unlock(&pDevice->lock); @@ -23412,8 +23412,8 @@ mal_result mal_device_stop(mal_device* pDevice) mal_bool32 mal_device_is_started(mal_device* pDevice) { - if (pDevice == NULL) return MAL_FALSE; - return mal_device__get_state(pDevice) == MAL_STATE_STARTED; + if (pDevice == NULL) return MA_FALSE; + return mal_device__get_state(pDevice) == MA_STATE_STARTED; } @@ -23433,325 +23433,325 @@ mal_device_config mal_device_config_init(mal_device_type deviceType) return config; } -#endif // MAL_NO_DEVICE_IO +#endif // MA_NO_DEVICE_IO -void mal_get_standard_channel_map_microsoft(mal_uint32 channels, mal_channel channelMap[MAL_MAX_CHANNELS]) +void mal_get_standard_channel_map_microsoft(mal_uint32 channels, mal_channel channelMap[MA_MAX_CHANNELS]) { // Based off the speaker configurations mentioned here: https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ksmedia/ns-ksmedia-ksaudio_channel_config switch (channels) { case 1: { - channelMap[0] = MAL_CHANNEL_MONO; + channelMap[0] = MA_CHANNEL_MONO; } break; case 2: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; } break; case 3: // Not defined, but best guess. { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_FRONT_CENTER; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_FRONT_CENTER; } break; case 4: { -#ifndef MAL_USE_QUAD_MICROSOFT_CHANNEL_MAP - // Surround. Using the Surround profile has the advantage of the 3rd channel (MAL_CHANNEL_FRONT_CENTER) mapping nicely +#ifndef MA_USE_QUAD_MICROSOFT_CHANNEL_MAP + // Surround. Using the Surround profile has the advantage of the 3rd channel (MA_CHANNEL_FRONT_CENTER) mapping nicely // with higher channel counts. - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_FRONT_CENTER; - channelMap[3] = MAL_CHANNEL_BACK_CENTER; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_FRONT_CENTER; + channelMap[3] = MA_CHANNEL_BACK_CENTER; #else // Quad. - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_LEFT; - channelMap[3] = MAL_CHANNEL_BACK_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_LEFT; + channelMap[3] = MA_CHANNEL_BACK_RIGHT; #endif } break; case 5: // Not defined, but best guess. { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_FRONT_CENTER; - channelMap[3] = MAL_CHANNEL_BACK_LEFT; - channelMap[4] = MAL_CHANNEL_BACK_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_FRONT_CENTER; + channelMap[3] = MA_CHANNEL_BACK_LEFT; + channelMap[4] = MA_CHANNEL_BACK_RIGHT; } break; case 6: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_FRONT_CENTER; - channelMap[3] = MAL_CHANNEL_LFE; - channelMap[4] = MAL_CHANNEL_SIDE_LEFT; - channelMap[5] = MAL_CHANNEL_SIDE_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_FRONT_CENTER; + channelMap[3] = MA_CHANNEL_LFE; + channelMap[4] = MA_CHANNEL_SIDE_LEFT; + channelMap[5] = MA_CHANNEL_SIDE_RIGHT; } break; case 7: // Not defined, but best guess. { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_FRONT_CENTER; - channelMap[3] = MAL_CHANNEL_LFE; - channelMap[4] = MAL_CHANNEL_BACK_CENTER; - channelMap[5] = MAL_CHANNEL_SIDE_LEFT; - channelMap[6] = MAL_CHANNEL_SIDE_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_FRONT_CENTER; + channelMap[3] = MA_CHANNEL_LFE; + channelMap[4] = MA_CHANNEL_BACK_CENTER; + channelMap[5] = MA_CHANNEL_SIDE_LEFT; + channelMap[6] = MA_CHANNEL_SIDE_RIGHT; } break; case 8: default: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_FRONT_CENTER; - channelMap[3] = MAL_CHANNEL_LFE; - channelMap[4] = MAL_CHANNEL_BACK_LEFT; - channelMap[5] = MAL_CHANNEL_BACK_RIGHT; - channelMap[6] = MAL_CHANNEL_SIDE_LEFT; - channelMap[7] = MAL_CHANNEL_SIDE_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_FRONT_CENTER; + channelMap[3] = MA_CHANNEL_LFE; + channelMap[4] = MA_CHANNEL_BACK_LEFT; + channelMap[5] = MA_CHANNEL_BACK_RIGHT; + channelMap[6] = MA_CHANNEL_SIDE_LEFT; + channelMap[7] = MA_CHANNEL_SIDE_RIGHT; } break; } // Remainder. if (channels > 8) { - for (mal_uint32 iChannel = 8; iChannel < MAL_MAX_CHANNELS; ++iChannel) { - channelMap[iChannel] = (mal_channel)(MAL_CHANNEL_AUX_0 + (iChannel-8)); + for (mal_uint32 iChannel = 8; iChannel < MA_MAX_CHANNELS; ++iChannel) { + channelMap[iChannel] = (mal_channel)(MA_CHANNEL_AUX_0 + (iChannel-8)); } } } -void mal_get_standard_channel_map_alsa(mal_uint32 channels, mal_channel channelMap[MAL_MAX_CHANNELS]) +void mal_get_standard_channel_map_alsa(mal_uint32 channels, mal_channel channelMap[MA_MAX_CHANNELS]) { switch (channels) { case 1: { - channelMap[0] = MAL_CHANNEL_MONO; + channelMap[0] = MA_CHANNEL_MONO; } break; case 2: { - channelMap[0] = MAL_CHANNEL_LEFT; - channelMap[1] = MAL_CHANNEL_RIGHT; + channelMap[0] = MA_CHANNEL_LEFT; + channelMap[1] = MA_CHANNEL_RIGHT; } break; case 3: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_FRONT_CENTER; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_FRONT_CENTER; } break; case 4: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_LEFT; - channelMap[3] = MAL_CHANNEL_BACK_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_LEFT; + channelMap[3] = MA_CHANNEL_BACK_RIGHT; } break; case 5: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_LEFT; - channelMap[3] = MAL_CHANNEL_BACK_RIGHT; - channelMap[4] = MAL_CHANNEL_FRONT_CENTER; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_LEFT; + channelMap[3] = MA_CHANNEL_BACK_RIGHT; + channelMap[4] = MA_CHANNEL_FRONT_CENTER; } break; case 6: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_LEFT; - channelMap[3] = MAL_CHANNEL_BACK_RIGHT; - channelMap[4] = MAL_CHANNEL_FRONT_CENTER; - channelMap[5] = MAL_CHANNEL_LFE; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_LEFT; + channelMap[3] = MA_CHANNEL_BACK_RIGHT; + channelMap[4] = MA_CHANNEL_FRONT_CENTER; + channelMap[5] = MA_CHANNEL_LFE; } break; case 7: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_LEFT; - channelMap[3] = MAL_CHANNEL_BACK_RIGHT; - channelMap[4] = MAL_CHANNEL_FRONT_CENTER; - channelMap[5] = MAL_CHANNEL_LFE; - channelMap[6] = MAL_CHANNEL_BACK_CENTER; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_LEFT; + channelMap[3] = MA_CHANNEL_BACK_RIGHT; + channelMap[4] = MA_CHANNEL_FRONT_CENTER; + channelMap[5] = MA_CHANNEL_LFE; + channelMap[6] = MA_CHANNEL_BACK_CENTER; } break; case 8: default: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_LEFT; - channelMap[3] = MAL_CHANNEL_BACK_RIGHT; - channelMap[4] = MAL_CHANNEL_FRONT_CENTER; - channelMap[5] = MAL_CHANNEL_LFE; - channelMap[6] = MAL_CHANNEL_SIDE_LEFT; - channelMap[7] = MAL_CHANNEL_SIDE_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_LEFT; + channelMap[3] = MA_CHANNEL_BACK_RIGHT; + channelMap[4] = MA_CHANNEL_FRONT_CENTER; + channelMap[5] = MA_CHANNEL_LFE; + channelMap[6] = MA_CHANNEL_SIDE_LEFT; + channelMap[7] = MA_CHANNEL_SIDE_RIGHT; } break; } // Remainder. if (channels > 8) { - for (mal_uint32 iChannel = 8; iChannel < MAL_MAX_CHANNELS; ++iChannel) { - channelMap[iChannel] = (mal_channel)(MAL_CHANNEL_AUX_0 + (iChannel-8)); + for (mal_uint32 iChannel = 8; iChannel < MA_MAX_CHANNELS; ++iChannel) { + channelMap[iChannel] = (mal_channel)(MA_CHANNEL_AUX_0 + (iChannel-8)); } } } -void mal_get_standard_channel_map_rfc3551(mal_uint32 channels, mal_channel channelMap[MAL_MAX_CHANNELS]) +void mal_get_standard_channel_map_rfc3551(mal_uint32 channels, mal_channel channelMap[MA_MAX_CHANNELS]) { switch (channels) { case 1: { - channelMap[0] = MAL_CHANNEL_MONO; + channelMap[0] = MA_CHANNEL_MONO; } break; case 2: { - channelMap[0] = MAL_CHANNEL_LEFT; - channelMap[1] = MAL_CHANNEL_RIGHT; + channelMap[0] = MA_CHANNEL_LEFT; + channelMap[1] = MA_CHANNEL_RIGHT; } break; case 3: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_FRONT_CENTER; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_FRONT_CENTER; } break; case 4: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_CENTER; - channelMap[2] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[3] = MAL_CHANNEL_BACK_CENTER; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_CENTER; + channelMap[2] = MA_CHANNEL_FRONT_RIGHT; + channelMap[3] = MA_CHANNEL_BACK_CENTER; } break; case 5: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_FRONT_CENTER; - channelMap[3] = MAL_CHANNEL_BACK_LEFT; - channelMap[4] = MAL_CHANNEL_BACK_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_FRONT_CENTER; + channelMap[3] = MA_CHANNEL_BACK_LEFT; + channelMap[4] = MA_CHANNEL_BACK_RIGHT; } break; case 6: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_SIDE_LEFT; - channelMap[2] = MAL_CHANNEL_FRONT_CENTER; - channelMap[3] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[4] = MAL_CHANNEL_SIDE_RIGHT; - channelMap[5] = MAL_CHANNEL_BACK_CENTER; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_SIDE_LEFT; + channelMap[2] = MA_CHANNEL_FRONT_CENTER; + channelMap[3] = MA_CHANNEL_FRONT_RIGHT; + channelMap[4] = MA_CHANNEL_SIDE_RIGHT; + channelMap[5] = MA_CHANNEL_BACK_CENTER; } break; } // Remainder. if (channels > 8) { - for (mal_uint32 iChannel = 6; iChannel < MAL_MAX_CHANNELS; ++iChannel) { - channelMap[iChannel] = (mal_channel)(MAL_CHANNEL_AUX_0 + (iChannel-6)); + for (mal_uint32 iChannel = 6; iChannel < MA_MAX_CHANNELS; ++iChannel) { + channelMap[iChannel] = (mal_channel)(MA_CHANNEL_AUX_0 + (iChannel-6)); } } } -void mal_get_standard_channel_map_flac(mal_uint32 channels, mal_channel channelMap[MAL_MAX_CHANNELS]) +void mal_get_standard_channel_map_flac(mal_uint32 channels, mal_channel channelMap[MA_MAX_CHANNELS]) { switch (channels) { case 1: { - channelMap[0] = MAL_CHANNEL_MONO; + channelMap[0] = MA_CHANNEL_MONO; } break; case 2: { - channelMap[0] = MAL_CHANNEL_LEFT; - channelMap[1] = MAL_CHANNEL_RIGHT; + channelMap[0] = MA_CHANNEL_LEFT; + channelMap[1] = MA_CHANNEL_RIGHT; } break; case 3: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_FRONT_CENTER; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_FRONT_CENTER; } break; case 4: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_LEFT; - channelMap[3] = MAL_CHANNEL_BACK_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_LEFT; + channelMap[3] = MA_CHANNEL_BACK_RIGHT; } break; case 5: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_FRONT_CENTER; - channelMap[3] = MAL_CHANNEL_BACK_LEFT; - channelMap[4] = MAL_CHANNEL_BACK_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_FRONT_CENTER; + channelMap[3] = MA_CHANNEL_BACK_LEFT; + channelMap[4] = MA_CHANNEL_BACK_RIGHT; } break; case 6: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_FRONT_CENTER; - channelMap[3] = MAL_CHANNEL_LFE; - channelMap[4] = MAL_CHANNEL_BACK_LEFT; - channelMap[5] = MAL_CHANNEL_BACK_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_FRONT_CENTER; + channelMap[3] = MA_CHANNEL_LFE; + channelMap[4] = MA_CHANNEL_BACK_LEFT; + channelMap[5] = MA_CHANNEL_BACK_RIGHT; } break; case 7: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_FRONT_CENTER; - channelMap[3] = MAL_CHANNEL_LFE; - channelMap[4] = MAL_CHANNEL_BACK_CENTER; - channelMap[5] = MAL_CHANNEL_SIDE_LEFT; - channelMap[6] = MAL_CHANNEL_SIDE_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_FRONT_CENTER; + channelMap[3] = MA_CHANNEL_LFE; + channelMap[4] = MA_CHANNEL_BACK_CENTER; + channelMap[5] = MA_CHANNEL_SIDE_LEFT; + channelMap[6] = MA_CHANNEL_SIDE_RIGHT; } break; case 8: default: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_FRONT_CENTER; - channelMap[3] = MAL_CHANNEL_LFE; - channelMap[4] = MAL_CHANNEL_BACK_LEFT; - channelMap[5] = MAL_CHANNEL_BACK_RIGHT; - channelMap[6] = MAL_CHANNEL_SIDE_LEFT; - channelMap[7] = MAL_CHANNEL_SIDE_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_FRONT_CENTER; + channelMap[3] = MA_CHANNEL_LFE; + channelMap[4] = MA_CHANNEL_BACK_LEFT; + channelMap[5] = MA_CHANNEL_BACK_RIGHT; + channelMap[6] = MA_CHANNEL_SIDE_LEFT; + channelMap[7] = MA_CHANNEL_SIDE_RIGHT; } break; } // Remainder. if (channels > 8) { - for (mal_uint32 iChannel = 8; iChannel < MAL_MAX_CHANNELS; ++iChannel) { - channelMap[iChannel] = (mal_channel)(MAL_CHANNEL_AUX_0 + (iChannel-8)); + for (mal_uint32 iChannel = 8; iChannel < MA_MAX_CHANNELS; ++iChannel) { + channelMap[iChannel] = (mal_channel)(MA_CHANNEL_AUX_0 + (iChannel-8)); } } } -void mal_get_standard_channel_map_vorbis(mal_uint32 channels, mal_channel channelMap[MAL_MAX_CHANNELS]) +void mal_get_standard_channel_map_vorbis(mal_uint32 channels, mal_channel channelMap[MA_MAX_CHANNELS]) { // In Vorbis' type 0 channel mapping, the first two channels are not always the standard left/right - it // will have the center speaker where the right usually goes. Why?! @@ -23759,224 +23759,224 @@ void mal_get_standard_channel_map_vorbis(mal_uint32 channels, mal_channel channe { case 1: { - channelMap[0] = MAL_CHANNEL_MONO; + channelMap[0] = MA_CHANNEL_MONO; } break; case 2: { - channelMap[0] = MAL_CHANNEL_LEFT; - channelMap[1] = MAL_CHANNEL_RIGHT; + channelMap[0] = MA_CHANNEL_LEFT; + channelMap[1] = MA_CHANNEL_RIGHT; } break; case 3: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_CENTER; - channelMap[2] = MAL_CHANNEL_FRONT_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_CENTER; + channelMap[2] = MA_CHANNEL_FRONT_RIGHT; } break; case 4: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_LEFT; - channelMap[3] = MAL_CHANNEL_BACK_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_LEFT; + channelMap[3] = MA_CHANNEL_BACK_RIGHT; } break; case 5: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_CENTER; - channelMap[2] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[3] = MAL_CHANNEL_BACK_LEFT; - channelMap[4] = MAL_CHANNEL_BACK_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_CENTER; + channelMap[2] = MA_CHANNEL_FRONT_RIGHT; + channelMap[3] = MA_CHANNEL_BACK_LEFT; + channelMap[4] = MA_CHANNEL_BACK_RIGHT; } break; case 6: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_CENTER; - channelMap[2] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[3] = MAL_CHANNEL_BACK_LEFT; - channelMap[4] = MAL_CHANNEL_BACK_RIGHT; - channelMap[5] = MAL_CHANNEL_LFE; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_CENTER; + channelMap[2] = MA_CHANNEL_FRONT_RIGHT; + channelMap[3] = MA_CHANNEL_BACK_LEFT; + channelMap[4] = MA_CHANNEL_BACK_RIGHT; + channelMap[5] = MA_CHANNEL_LFE; } break; case 7: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_CENTER; - channelMap[2] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[3] = MAL_CHANNEL_SIDE_LEFT; - channelMap[4] = MAL_CHANNEL_SIDE_RIGHT; - channelMap[5] = MAL_CHANNEL_BACK_CENTER; - channelMap[6] = MAL_CHANNEL_LFE; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_CENTER; + channelMap[2] = MA_CHANNEL_FRONT_RIGHT; + channelMap[3] = MA_CHANNEL_SIDE_LEFT; + channelMap[4] = MA_CHANNEL_SIDE_RIGHT; + channelMap[5] = MA_CHANNEL_BACK_CENTER; + channelMap[6] = MA_CHANNEL_LFE; } break; case 8: default: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_CENTER; - channelMap[2] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[3] = MAL_CHANNEL_SIDE_LEFT; - channelMap[4] = MAL_CHANNEL_SIDE_RIGHT; - channelMap[5] = MAL_CHANNEL_BACK_LEFT; - channelMap[6] = MAL_CHANNEL_BACK_RIGHT; - channelMap[7] = MAL_CHANNEL_LFE; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_CENTER; + channelMap[2] = MA_CHANNEL_FRONT_RIGHT; + channelMap[3] = MA_CHANNEL_SIDE_LEFT; + channelMap[4] = MA_CHANNEL_SIDE_RIGHT; + channelMap[5] = MA_CHANNEL_BACK_LEFT; + channelMap[6] = MA_CHANNEL_BACK_RIGHT; + channelMap[7] = MA_CHANNEL_LFE; } break; } // Remainder. if (channels > 8) { - for (mal_uint32 iChannel = 8; iChannel < MAL_MAX_CHANNELS; ++iChannel) { - channelMap[iChannel] = (mal_channel)(MAL_CHANNEL_AUX_0 + (iChannel-8)); + for (mal_uint32 iChannel = 8; iChannel < MA_MAX_CHANNELS; ++iChannel) { + channelMap[iChannel] = (mal_channel)(MA_CHANNEL_AUX_0 + (iChannel-8)); } } } -void mal_get_standard_channel_map_sound4(mal_uint32 channels, mal_channel channelMap[MAL_MAX_CHANNELS]) +void mal_get_standard_channel_map_sound4(mal_uint32 channels, mal_channel channelMap[MA_MAX_CHANNELS]) { switch (channels) { case 1: { - channelMap[0] = MAL_CHANNEL_MONO; + channelMap[0] = MA_CHANNEL_MONO; } break; case 2: { - channelMap[0] = MAL_CHANNEL_LEFT; - channelMap[1] = MAL_CHANNEL_RIGHT; + channelMap[0] = MA_CHANNEL_LEFT; + channelMap[1] = MA_CHANNEL_RIGHT; } break; case 3: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_CENTER; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_CENTER; } break; case 4: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_LEFT; - channelMap[3] = MAL_CHANNEL_BACK_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_LEFT; + channelMap[3] = MA_CHANNEL_BACK_RIGHT; } break; case 5: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_LEFT; - channelMap[3] = MAL_CHANNEL_BACK_RIGHT; - channelMap[4] = MAL_CHANNEL_FRONT_CENTER; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_LEFT; + channelMap[3] = MA_CHANNEL_BACK_RIGHT; + channelMap[4] = MA_CHANNEL_FRONT_CENTER; } break; case 6: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_LEFT; - channelMap[3] = MAL_CHANNEL_BACK_RIGHT; - channelMap[4] = MAL_CHANNEL_FRONT_CENTER; - channelMap[5] = MAL_CHANNEL_LFE; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_LEFT; + channelMap[3] = MA_CHANNEL_BACK_RIGHT; + channelMap[4] = MA_CHANNEL_FRONT_CENTER; + channelMap[5] = MA_CHANNEL_LFE; } break; case 7: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_LEFT; - channelMap[3] = MAL_CHANNEL_BACK_RIGHT; - channelMap[4] = MAL_CHANNEL_FRONT_CENTER; - channelMap[5] = MAL_CHANNEL_BACK_CENTER; - channelMap[6] = MAL_CHANNEL_LFE; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_LEFT; + channelMap[3] = MA_CHANNEL_BACK_RIGHT; + channelMap[4] = MA_CHANNEL_FRONT_CENTER; + channelMap[5] = MA_CHANNEL_BACK_CENTER; + channelMap[6] = MA_CHANNEL_LFE; } break; case 8: default: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_LEFT; - channelMap[3] = MAL_CHANNEL_BACK_RIGHT; - channelMap[4] = MAL_CHANNEL_FRONT_CENTER; - channelMap[5] = MAL_CHANNEL_LFE; - channelMap[6] = MAL_CHANNEL_SIDE_LEFT; - channelMap[7] = MAL_CHANNEL_SIDE_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_LEFT; + channelMap[3] = MA_CHANNEL_BACK_RIGHT; + channelMap[4] = MA_CHANNEL_FRONT_CENTER; + channelMap[5] = MA_CHANNEL_LFE; + channelMap[6] = MA_CHANNEL_SIDE_LEFT; + channelMap[7] = MA_CHANNEL_SIDE_RIGHT; } break; } // Remainder. if (channels > 8) { - for (mal_uint32 iChannel = 8; iChannel < MAL_MAX_CHANNELS; ++iChannel) { - channelMap[iChannel] = (mal_channel)(MAL_CHANNEL_AUX_0 + (iChannel-8)); + for (mal_uint32 iChannel = 8; iChannel < MA_MAX_CHANNELS; ++iChannel) { + channelMap[iChannel] = (mal_channel)(MA_CHANNEL_AUX_0 + (iChannel-8)); } } } -void mal_get_standard_channel_map_sndio(mal_uint32 channels, mal_channel channelMap[MAL_MAX_CHANNELS]) +void mal_get_standard_channel_map_sndio(mal_uint32 channels, mal_channel channelMap[MA_MAX_CHANNELS]) { switch (channels) { case 1: { - channelMap[0] = MAL_CHANNEL_MONO; + channelMap[0] = MA_CHANNEL_MONO; } break; case 2: { - channelMap[0] = MAL_CHANNEL_LEFT; - channelMap[1] = MAL_CHANNEL_RIGHT; + channelMap[0] = MA_CHANNEL_LEFT; + channelMap[1] = MA_CHANNEL_RIGHT; } break; case 3: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_FRONT_CENTER; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_FRONT_CENTER; } break; case 4: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_LEFT; - channelMap[3] = MAL_CHANNEL_BACK_RIGHT; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_LEFT; + channelMap[3] = MA_CHANNEL_BACK_RIGHT; } break; case 5: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_LEFT; - channelMap[3] = MAL_CHANNEL_BACK_RIGHT; - channelMap[4] = MAL_CHANNEL_FRONT_CENTER; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_LEFT; + channelMap[3] = MA_CHANNEL_BACK_RIGHT; + channelMap[4] = MA_CHANNEL_FRONT_CENTER; } break; case 6: default: { - channelMap[0] = MAL_CHANNEL_FRONT_LEFT; - channelMap[1] = MAL_CHANNEL_FRONT_RIGHT; - channelMap[2] = MAL_CHANNEL_BACK_LEFT; - channelMap[3] = MAL_CHANNEL_BACK_RIGHT; - channelMap[4] = MAL_CHANNEL_FRONT_CENTER; - channelMap[5] = MAL_CHANNEL_LFE; + channelMap[0] = MA_CHANNEL_FRONT_LEFT; + channelMap[1] = MA_CHANNEL_FRONT_RIGHT; + channelMap[2] = MA_CHANNEL_BACK_LEFT; + channelMap[3] = MA_CHANNEL_BACK_RIGHT; + channelMap[4] = MA_CHANNEL_FRONT_CENTER; + channelMap[5] = MA_CHANNEL_LFE; } break; } // Remainder. if (channels > 6) { - for (mal_uint32 iChannel = 6; iChannel < MAL_MAX_CHANNELS; ++iChannel) { - channelMap[iChannel] = (mal_channel)(MAL_CHANNEL_AUX_0 + (iChannel-6)); + for (mal_uint32 iChannel = 6; iChannel < MA_MAX_CHANNELS; ++iChannel) { + channelMap[iChannel] = (mal_channel)(MA_CHANNEL_AUX_0 + (iChannel-6)); } } } -void mal_get_standard_channel_map(mal_standard_channel_map standardChannelMap, mal_uint32 channels, mal_channel channelMap[MAL_MAX_CHANNELS]) +void mal_get_standard_channel_map(mal_standard_channel_map standardChannelMap, mal_uint32 channels, mal_channel channelMap[MA_MAX_CHANNELS]) { switch (standardChannelMap) { @@ -24025,68 +24025,68 @@ void mal_channel_map_copy(mal_channel* pOut, const mal_channel* pIn, mal_uint32 } } -mal_bool32 mal_channel_map_valid(mal_uint32 channels, const mal_channel channelMap[MAL_MAX_CHANNELS]) +mal_bool32 mal_channel_map_valid(mal_uint32 channels, const mal_channel channelMap[MA_MAX_CHANNELS]) { if (channelMap == NULL) { - return MAL_FALSE; + return MA_FALSE; } // A channel count of 0 is invalid. if (channels == 0) { - return MAL_FALSE; + return MA_FALSE; } // It does not make sense to have a mono channel when there is more than 1 channel. if (channels > 1) { for (mal_uint32 iChannel = 0; iChannel < channels; ++iChannel) { - if (channelMap[iChannel] == MAL_CHANNEL_MONO) { - return MAL_FALSE; + if (channelMap[iChannel] == MA_CHANNEL_MONO) { + return MA_FALSE; } } } - return MAL_TRUE; + return MA_TRUE; } -mal_bool32 mal_channel_map_equal(mal_uint32 channels, const mal_channel channelMapA[MAL_MAX_CHANNELS], const mal_channel channelMapB[MAL_MAX_CHANNELS]) +mal_bool32 mal_channel_map_equal(mal_uint32 channels, const mal_channel channelMapA[MA_MAX_CHANNELS], const mal_channel channelMapB[MA_MAX_CHANNELS]) { if (channelMapA == channelMapB) { - return MAL_FALSE; + return MA_FALSE; } - if (channels == 0 || channels > MAL_MAX_CHANNELS) { - return MAL_FALSE; + if (channels == 0 || channels > MA_MAX_CHANNELS) { + return MA_FALSE; } for (mal_uint32 iChannel = 0; iChannel < channels; ++iChannel) { if (channelMapA[iChannel] != channelMapB[iChannel]) { - return MAL_FALSE; + return MA_FALSE; } } - return MAL_TRUE; + return MA_TRUE; } -mal_bool32 mal_channel_map_blank(mal_uint32 channels, const mal_channel channelMap[MAL_MAX_CHANNELS]) +mal_bool32 mal_channel_map_blank(mal_uint32 channels, const mal_channel channelMap[MA_MAX_CHANNELS]) { for (mal_uint32 iChannel = 0; iChannel < channels; ++iChannel) { - if (channelMap[iChannel] != MAL_CHANNEL_NONE) { - return MAL_FALSE; + if (channelMap[iChannel] != MA_CHANNEL_NONE) { + return MA_FALSE; } } - return MAL_TRUE; + return MA_TRUE; } -mal_bool32 mal_channel_map_contains_channel_position(mal_uint32 channels, const mal_channel channelMap[MAL_MAX_CHANNELS], mal_channel channelPosition) +mal_bool32 mal_channel_map_contains_channel_position(mal_uint32 channels, const mal_channel channelMap[MA_MAX_CHANNELS], mal_channel channelPosition) { for (mal_uint32 iChannel = 0; iChannel < channels; ++iChannel) { if (channelMap[iChannel] == channelPosition) { - return MAL_TRUE; + return MA_TRUE; } } - return MAL_FALSE; + return MA_FALSE; } @@ -24098,18 +24098,18 @@ mal_bool32 mal_channel_map_contains_channel_position(mal_uint32 channels, const // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//#define MAL_USE_REFERENCE_CONVERSION_APIS 1 -//#define MAL_USE_SSE +//#define MA_USE_REFERENCE_CONVERSION_APIS 1 +//#define MA_USE_SSE void mal_copy_memory_64(void* dst, const void* src, mal_uint64 sizeInBytes) { -#if 0xFFFFFFFFFFFFFFFF <= MAL_SIZE_MAX +#if 0xFFFFFFFFFFFFFFFF <= MA_SIZE_MAX mal_copy_memory(dst, src, (size_t)sizeInBytes); #else while (sizeInBytes > 0) { mal_uint64 bytesToCopyNow = sizeInBytes; - if (bytesToCopyNow > MAL_SIZE_MAX) { - bytesToCopyNow = MAL_SIZE_MAX; + if (bytesToCopyNow > MA_SIZE_MAX) { + bytesToCopyNow = MA_SIZE_MAX; } mal_copy_memory(dst, src, (size_t)bytesToCopyNow); // Safe cast to size_t. @@ -24123,13 +24123,13 @@ void mal_copy_memory_64(void* dst, const void* src, mal_uint64 sizeInBytes) void mal_zero_memory_64(void* dst, mal_uint64 sizeInBytes) { -#if 0xFFFFFFFFFFFFFFFF <= MAL_SIZE_MAX +#if 0xFFFFFFFFFFFFFFFF <= MA_SIZE_MAX mal_zero_memory(dst, (size_t)sizeInBytes); #else while (sizeInBytes > 0) { mal_uint64 bytesToZeroNow = sizeInBytes; - if (bytesToZeroNow > MAL_SIZE_MAX) { - bytesToZeroNow = MAL_SIZE_MAX; + if (bytesToZeroNow > MA_SIZE_MAX) { + bytesToZeroNow = MA_SIZE_MAX; } mal_zero_memory(dst, (size_t)bytesToZeroNow); // Safe cast to size_t. @@ -24170,25 +24170,25 @@ void mal_pcm_u8_to_s16__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_u8_to_s16__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_u8_to_s16__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_u8_to_s16__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_u8_to_s16__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_u8_to_s16__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_u8_to_s16__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_u8_to_s16__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_u8_to_s16__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_u8_to_s16__optimized(dst, src, count, ditherMode); @@ -24197,7 +24197,7 @@ void mal_pcm_u8_to_s16__neon(void* dst, const void* src, mal_uint64 count, mal_d void mal_pcm_u8_to_s16(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_u8_to_s16__reference(dst, src, count, ditherMode); #else mal_pcm_u8_to_s16__optimized(dst, src, count, ditherMode); @@ -24228,25 +24228,25 @@ void mal_pcm_u8_to_s24__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_u8_to_s24__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_u8_to_s24__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_u8_to_s24__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_u8_to_s24__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_u8_to_s24__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_u8_to_s24__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_u8_to_s24__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_u8_to_s24__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_u8_to_s24__optimized(dst, src, count, ditherMode); @@ -24255,7 +24255,7 @@ void mal_pcm_u8_to_s24__neon(void* dst, const void* src, mal_uint64 count, mal_d void mal_pcm_u8_to_s24(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_u8_to_s24__reference(dst, src, count, ditherMode); #else mal_pcm_u8_to_s24__optimized(dst, src, count, ditherMode); @@ -24284,25 +24284,25 @@ void mal_pcm_u8_to_s32__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_u8_to_s32__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_u8_to_s32__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_u8_to_s32__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_u8_to_s32__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_u8_to_s32__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_u8_to_s32__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_u8_to_s32__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_u8_to_s32__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_u8_to_s32__optimized(dst, src, count, ditherMode); @@ -24311,7 +24311,7 @@ void mal_pcm_u8_to_s32__neon(void* dst, const void* src, mal_uint64 count, mal_d void mal_pcm_u8_to_s32(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_u8_to_s32__reference(dst, src, count, ditherMode); #else mal_pcm_u8_to_s32__optimized(dst, src, count, ditherMode); @@ -24341,25 +24341,25 @@ void mal_pcm_u8_to_f32__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_u8_to_f32__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_u8_to_f32__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_u8_to_f32__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_u8_to_f32__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_u8_to_f32__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_u8_to_f32__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_u8_to_f32__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_u8_to_f32__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_u8_to_f32__optimized(dst, src, count, ditherMode); @@ -24368,7 +24368,7 @@ void mal_pcm_u8_to_f32__neon(void* dst, const void* src, mal_uint64 count, mal_d void mal_pcm_u8_to_f32(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_u8_to_f32__reference(dst, src, count, ditherMode); #else mal_pcm_u8_to_f32__optimized(dst, src, count, ditherMode); @@ -24417,7 +24417,7 @@ void mal_pcm_interleave_u8__optimized(void* dst, const void** src, mal_uint64 fr void mal_pcm_interleave_u8(void* dst, const void** src, mal_uint64 frameCount, mal_uint32 channels) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_interleave_u8__reference(dst, src, frameCount, channels); #else mal_pcm_interleave_u8__optimized(dst, src, frameCount, channels); @@ -24446,7 +24446,7 @@ void mal_pcm_deinterleave_u8__optimized(void** dst, const void* src, mal_uint64 void mal_pcm_deinterleave_u8(void** dst, const void* src, mal_uint64 frameCount, mal_uint32 channels) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_deinterleave_u8__reference(dst, src, frameCount, channels); #else mal_pcm_deinterleave_u8__optimized(dst, src, frameCount, channels); @@ -24493,25 +24493,25 @@ void mal_pcm_s16_to_u8__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_s16_to_u8__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_s16_to_u8__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s16_to_u8__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_s16_to_u8__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s16_to_u8__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_s16_to_u8__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s16_to_u8__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_s16_to_u8__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s16_to_u8__optimized(dst, src, count, ditherMode); @@ -24520,7 +24520,7 @@ void mal_pcm_s16_to_u8__neon(void* dst, const void* src, mal_uint64 count, mal_d void mal_pcm_s16_to_u8(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_s16_to_u8__reference(dst, src, count, ditherMode); #else mal_pcm_s16_to_u8__optimized(dst, src, count, ditherMode); @@ -24555,25 +24555,25 @@ void mal_pcm_s16_to_s24__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_s16_to_s24__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_s16_to_s24__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s16_to_s24__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_s16_to_s24__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s16_to_s24__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_s16_to_s24__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s16_to_s24__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_s16_to_s24__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s16_to_s24__optimized(dst, src, count, ditherMode); @@ -24582,7 +24582,7 @@ void mal_pcm_s16_to_s24__neon(void* dst, const void* src, mal_uint64 count, mal_ void mal_pcm_s16_to_s24(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_s16_to_s24__reference(dst, src, count, ditherMode); #else mal_pcm_s16_to_s24__optimized(dst, src, count, ditherMode); @@ -24608,25 +24608,25 @@ void mal_pcm_s16_to_s32__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_s16_to_s32__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_s16_to_s32__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s16_to_s32__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_s16_to_s32__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s16_to_s32__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_s16_to_s32__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s16_to_s32__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_s16_to_s32__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s16_to_s32__optimized(dst, src, count, ditherMode); @@ -24635,7 +24635,7 @@ void mal_pcm_s16_to_s32__neon(void* dst, const void* src, mal_uint64 count, mal_ void mal_pcm_s16_to_s32(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_s16_to_s32__reference(dst, src, count, ditherMode); #else mal_pcm_s16_to_s32__optimized(dst, src, count, ditherMode); @@ -24673,25 +24673,25 @@ void mal_pcm_s16_to_f32__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_s16_to_f32__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_s16_to_f32__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s16_to_f32__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_s16_to_f32__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s16_to_f32__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_s16_to_f32__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s16_to_f32__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_s16_to_f32__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s16_to_f32__optimized(dst, src, count, ditherMode); @@ -24700,7 +24700,7 @@ void mal_pcm_s16_to_f32__neon(void* dst, const void* src, mal_uint64 count, mal_ void mal_pcm_s16_to_f32(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_s16_to_f32__reference(dst, src, count, ditherMode); #else mal_pcm_s16_to_f32__optimized(dst, src, count, ditherMode); @@ -24729,7 +24729,7 @@ void mal_pcm_interleave_s16__optimized(void* dst, const void** src, mal_uint64 f void mal_pcm_interleave_s16(void* dst, const void** src, mal_uint64 frameCount, mal_uint32 channels) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_interleave_s16__reference(dst, src, frameCount, channels); #else mal_pcm_interleave_s16__optimized(dst, src, frameCount, channels); @@ -24758,7 +24758,7 @@ void mal_pcm_deinterleave_s16__optimized(void** dst, const void* src, mal_uint64 void mal_pcm_deinterleave_s16(void** dst, const void* src, mal_uint64 frameCount, mal_uint32 channels) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_deinterleave_s16__reference(dst, src, frameCount, channels); #else mal_pcm_deinterleave_s16__optimized(dst, src, frameCount, channels); @@ -24803,25 +24803,25 @@ void mal_pcm_s24_to_u8__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_s24_to_u8__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_s24_to_u8__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s24_to_u8__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_s24_to_u8__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s24_to_u8__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_s24_to_u8__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s24_to_u8__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_s24_to_u8__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s24_to_u8__optimized(dst, src, count, ditherMode); @@ -24830,7 +24830,7 @@ void mal_pcm_s24_to_u8__neon(void* dst, const void* src, mal_uint64 count, mal_d void mal_pcm_s24_to_u8(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_s24_to_u8__reference(dst, src, count, ditherMode); #else mal_pcm_s24_to_u8__optimized(dst, src, count, ditherMode); @@ -24874,25 +24874,25 @@ void mal_pcm_s24_to_s16__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_s24_to_s16__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_s24_to_s16__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s24_to_s16__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_s24_to_s16__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s24_to_s16__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_s24_to_s16__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s24_to_s16__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_s24_to_s16__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s24_to_s16__optimized(dst, src, count, ditherMode); @@ -24901,7 +24901,7 @@ void mal_pcm_s24_to_s16__neon(void* dst, const void* src, mal_uint64 count, mal_ void mal_pcm_s24_to_s16(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_s24_to_s16__reference(dst, src, count, ditherMode); #else mal_pcm_s24_to_s16__optimized(dst, src, count, ditherMode); @@ -24935,25 +24935,25 @@ void mal_pcm_s24_to_s32__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_s24_to_s32__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_s24_to_s32__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s24_to_s32__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_s24_to_s32__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s24_to_s32__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_s24_to_s32__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s24_to_s32__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_s24_to_s32__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s24_to_s32__optimized(dst, src, count, ditherMode); @@ -24962,7 +24962,7 @@ void mal_pcm_s24_to_s32__neon(void* dst, const void* src, mal_uint64 count, mal_ void mal_pcm_s24_to_s32(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_s24_to_s32__reference(dst, src, count, ditherMode); #else mal_pcm_s24_to_s32__optimized(dst, src, count, ditherMode); @@ -25000,25 +25000,25 @@ void mal_pcm_s24_to_f32__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_s24_to_f32__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_s24_to_f32__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s24_to_f32__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_s24_to_f32__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s24_to_f32__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_s24_to_f32__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s24_to_f32__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_s24_to_f32__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s24_to_f32__optimized(dst, src, count, ditherMode); @@ -25027,7 +25027,7 @@ void mal_pcm_s24_to_f32__neon(void* dst, const void* src, mal_uint64 count, mal_ void mal_pcm_s24_to_f32(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_s24_to_f32__reference(dst, src, count, ditherMode); #else mal_pcm_s24_to_f32__optimized(dst, src, count, ditherMode); @@ -25058,7 +25058,7 @@ void mal_pcm_interleave_s24__optimized(void* dst, const void** src, mal_uint64 f void mal_pcm_interleave_s24(void* dst, const void** src, mal_uint64 frameCount, mal_uint32 channels) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_interleave_s24__reference(dst, src, frameCount, channels); #else mal_pcm_interleave_s24__optimized(dst, src, frameCount, channels); @@ -25089,7 +25089,7 @@ void mal_pcm_deinterleave_s24__optimized(void** dst, const void* src, mal_uint64 void mal_pcm_deinterleave_s24(void** dst, const void* src, mal_uint64 frameCount, mal_uint32 channels) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_deinterleave_s24__reference(dst, src, frameCount, channels); #else mal_pcm_deinterleave_s24__optimized(dst, src, frameCount, channels); @@ -25137,25 +25137,25 @@ void mal_pcm_s32_to_u8__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_s32_to_u8__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_s32_to_u8__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s32_to_u8__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_s32_to_u8__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s32_to_u8__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_s32_to_u8__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s32_to_u8__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_s32_to_u8__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s32_to_u8__optimized(dst, src, count, ditherMode); @@ -25164,7 +25164,7 @@ void mal_pcm_s32_to_u8__neon(void* dst, const void* src, mal_uint64 count, mal_d void mal_pcm_s32_to_u8(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_s32_to_u8__reference(dst, src, count, ditherMode); #else mal_pcm_s32_to_u8__optimized(dst, src, count, ditherMode); @@ -25208,25 +25208,25 @@ void mal_pcm_s32_to_s16__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_s32_to_s16__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_s32_to_s16__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s32_to_s16__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_s32_to_s16__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s32_to_s16__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_s32_to_s16__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s32_to_s16__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_s32_to_s16__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s32_to_s16__optimized(dst, src, count, ditherMode); @@ -25235,7 +25235,7 @@ void mal_pcm_s32_to_s16__neon(void* dst, const void* src, mal_uint64 count, mal_ void mal_pcm_s32_to_s16(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_s32_to_s16__reference(dst, src, count, ditherMode); #else mal_pcm_s32_to_s16__optimized(dst, src, count, ditherMode); @@ -25264,25 +25264,25 @@ void mal_pcm_s32_to_s24__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_s32_to_s24__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_s32_to_s24__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s32_to_s24__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_s32_to_s24__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s32_to_s24__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_s32_to_s24__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s32_to_s24__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_s32_to_s24__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s32_to_s24__optimized(dst, src, count, ditherMode); @@ -25291,7 +25291,7 @@ void mal_pcm_s32_to_s24__neon(void* dst, const void* src, mal_uint64 count, mal_ void mal_pcm_s32_to_s24(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_s32_to_s24__reference(dst, src, count, ditherMode); #else mal_pcm_s32_to_s24__optimized(dst, src, count, ditherMode); @@ -25335,25 +25335,25 @@ void mal_pcm_s32_to_f32__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_s32_to_f32__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_s32_to_f32__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s32_to_f32__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_s32_to_f32__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s32_to_f32__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_s32_to_f32__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s32_to_f32__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_s32_to_f32__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_s32_to_f32__optimized(dst, src, count, ditherMode); @@ -25362,7 +25362,7 @@ void mal_pcm_s32_to_f32__neon(void* dst, const void* src, mal_uint64 count, mal_ void mal_pcm_s32_to_f32(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_s32_to_f32__reference(dst, src, count, ditherMode); #else mal_pcm_s32_to_f32__optimized(dst, src, count, ditherMode); @@ -25391,7 +25391,7 @@ void mal_pcm_interleave_s32__optimized(void* dst, const void** src, mal_uint64 f void mal_pcm_interleave_s32(void* dst, const void** src, mal_uint64 frameCount, mal_uint32 channels) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_interleave_s32__reference(dst, src, frameCount, channels); #else mal_pcm_interleave_s32__optimized(dst, src, frameCount, channels); @@ -25420,7 +25420,7 @@ void mal_pcm_deinterleave_s32__optimized(void** dst, const void* src, mal_uint64 void mal_pcm_deinterleave_s32(void** dst, const void* src, mal_uint64 frameCount, mal_uint32 channels) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_deinterleave_s32__reference(dst, src, frameCount, channels); #else mal_pcm_deinterleave_s32__optimized(dst, src, frameCount, channels); @@ -25458,25 +25458,25 @@ void mal_pcm_f32_to_u8__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_f32_to_u8__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_f32_to_u8__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_f32_to_u8__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_f32_to_u8__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_f32_to_u8__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_f32_to_u8__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_f32_to_u8__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_f32_to_u8__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_f32_to_u8__optimized(dst, src, count, ditherMode); @@ -25485,7 +25485,7 @@ void mal_pcm_f32_to_u8__neon(void* dst, const void* src, mal_uint64 count, mal_d void mal_pcm_f32_to_u8(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_f32_to_u8__reference(dst, src, count, ditherMode); #else mal_pcm_f32_to_u8__optimized(dst, src, count, ditherMode); @@ -25586,7 +25586,7 @@ void mal_pcm_f32_to_s16__optimized(void* dst, const void* src, mal_uint64 count, } } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_f32_to_s16__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { // Both the input and output buffers need to be aligned to 16 bytes. @@ -25669,7 +25669,7 @@ void mal_pcm_f32_to_s16__sse2(void* dst, const void* src, mal_uint64 count, mal_ } } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_f32_to_s16__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { // Both the input and output buffers need to be aligned to 32 bytes. @@ -25775,14 +25775,14 @@ void mal_pcm_f32_to_s16__avx2(void* dst, const void* src, mal_uint64 count, mal_ } } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_f32_to_s16__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { // TODO: Convert this from AVX to AVX-512. mal_pcm_f32_to_s16__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_f32_to_s16__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { // Both the input and output buffers need to be aligned to 16 bytes. @@ -25872,7 +25872,7 @@ void mal_pcm_f32_to_s16__neon(void* dst, const void* src, mal_uint64 count, mal_ void mal_pcm_f32_to_s16(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_f32_to_s16__reference(dst, src, count, ditherMode); #else mal_pcm_f32_to_s16__optimized(dst, src, count, ditherMode); @@ -25914,25 +25914,25 @@ void mal_pcm_f32_to_s24__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_f32_to_s24__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_f32_to_s24__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_f32_to_s24__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_f32_to_s24__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_f32_to_s24__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_f32_to_s24__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_f32_to_s24__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_f32_to_s24__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_f32_to_s24__optimized(dst, src, count, ditherMode); @@ -25941,7 +25941,7 @@ void mal_pcm_f32_to_s24__neon(void* dst, const void* src, mal_uint64 count, mal_ void mal_pcm_f32_to_s24(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_f32_to_s24__reference(dst, src, count, ditherMode); #else mal_pcm_f32_to_s24__optimized(dst, src, count, ditherMode); @@ -25980,25 +25980,25 @@ void mal_pcm_f32_to_s32__optimized(void* dst, const void* src, mal_uint64 count, mal_pcm_f32_to_s32__reference(dst, src, count, ditherMode); } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_pcm_f32_to_s32__sse2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_f32_to_s32__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_pcm_f32_to_s32__avx2(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_f32_to_s32__optimized(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_pcm_f32_to_s32__avx512(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_f32_to_s32__avx2(dst, src, count, ditherMode); } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_pcm_f32_to_s32__neon(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { mal_pcm_f32_to_s32__optimized(dst, src, count, ditherMode); @@ -26007,7 +26007,7 @@ void mal_pcm_f32_to_s32__neon(void* dst, const void* src, mal_uint64 count, mal_ void mal_pcm_f32_to_s32(void* dst, const void* src, mal_uint64 count, mal_dither_mode ditherMode) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_f32_to_s32__reference(dst, src, count, ditherMode); #else mal_pcm_f32_to_s32__optimized(dst, src, count, ditherMode); @@ -26044,7 +26044,7 @@ void mal_pcm_interleave_f32__optimized(void* dst, const void** src, mal_uint64 f void mal_pcm_interleave_f32(void* dst, const void** src, mal_uint64 frameCount, mal_uint32 channels) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_interleave_f32__reference(dst, src, frameCount, channels); #else mal_pcm_interleave_f32__optimized(dst, src, frameCount, channels); @@ -26073,7 +26073,7 @@ void mal_pcm_deinterleave_f32__optimized(void** dst, const void* src, mal_uint64 void mal_pcm_deinterleave_f32(void** dst, const void* src, mal_uint64 frameCount, mal_uint32 channels) { -#ifdef MAL_USE_REFERENCE_CONVERSION_APIS +#ifdef MA_USE_REFERENCE_CONVERSION_APIS mal_pcm_deinterleave_f32__reference(dst, src, frameCount, channels); #else mal_pcm_deinterleave_f32__optimized(dst, src, frameCount, channels); @@ -26165,7 +26165,7 @@ void mal_format_converter_init_callbacks__default(mal_format_converter* pConvert } } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void mal_format_converter_init_callbacks__sse2(mal_format_converter* pConverter) { mal_assert(pConverter != NULL); @@ -26251,7 +26251,7 @@ void mal_format_converter_init_callbacks__sse2(mal_format_converter* pConverter) } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void mal_format_converter_init_callbacks__avx2(mal_format_converter* pConverter) { mal_assert(pConverter != NULL); @@ -26337,7 +26337,7 @@ void mal_format_converter_init_callbacks__avx2(mal_format_converter* pConverter) } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void mal_format_converter_init_callbacks__avx512(mal_format_converter* pConverter) { mal_assert(pConverter != NULL); @@ -26423,7 +26423,7 @@ void mal_format_converter_init_callbacks__avx512(mal_format_converter* pConverte } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void mal_format_converter_init_callbacks__neon(mal_format_converter* pConverter) { mal_assert(pConverter != NULL); @@ -26512,12 +26512,12 @@ void mal_format_converter_init_callbacks__neon(mal_format_converter* pConverter) mal_result mal_format_converter_init(const mal_format_converter_config* pConfig, mal_format_converter* pConverter) { if (pConverter == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_zero_object(pConverter); if (pConfig == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } pConverter->config = *pConfig; @@ -26528,22 +26528,22 @@ mal_result mal_format_converter_init(const mal_format_converter_config* pConfig, pConverter->useAVX512 = mal_has_avx512f() && !pConfig->noAVX512; pConverter->useNEON = mal_has_neon() && !pConfig->noNEON; -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) if (pConverter->useAVX512) { mal_format_converter_init_callbacks__avx512(pConverter); } else #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) if (pConverter->useAVX2) { mal_format_converter_init_callbacks__avx2(pConverter); } else #endif -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) if (pConverter->useSSE2) { mal_format_converter_init_callbacks__sse2(pConverter); } else #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) if (pConverter->useNEON) { mal_format_converter_init_callbacks__neon(pConverter); } else @@ -26582,7 +26582,7 @@ mal_result mal_format_converter_init(const mal_format_converter_config* pConfig, } break; } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_uint64 mal_format_converter_read(mal_format_converter* pConverter, mal_uint64 frameCount, void* pFramesOut, void* pUserData) @@ -26623,7 +26623,7 @@ mal_uint64 mal_format_converter_read(mal_format_converter* pConverter, mal_uint6 } } else { // Conversion required. - MAL_ALIGN(MAL_SIMD_ALIGNMENT) mal_uint8 temp[MAL_MAX_CHANNELS * MAL_MAX_PCM_SAMPLE_SIZE_IN_BYTES * 128]; + MA_ALIGN(MA_SIMD_ALIGNMENT) mal_uint8 temp[MA_MAX_CHANNELS * MA_MAX_PCM_SAMPLE_SIZE_IN_BYTES * 128]; mal_assert(sizeof(temp) <= 0xFFFFFFFF); mal_uint32 maxFramesToReadAtATime = sizeof(temp) / sampleSizeIn / pConverter->config.channels; @@ -26652,12 +26652,12 @@ mal_uint64 mal_format_converter_read(mal_format_converter* pConverter, mal_uint6 } } else { // Input data is deinterleaved. If a conversion is required we need to do an intermediary step. - MAL_ALIGN(MAL_SIMD_ALIGNMENT) mal_uint8 tempSamplesOfOutFormat[MAL_MAX_CHANNELS * MAL_MAX_PCM_SAMPLE_SIZE_IN_BYTES * 128]; + MA_ALIGN(MA_SIMD_ALIGNMENT) mal_uint8 tempSamplesOfOutFormat[MA_MAX_CHANNELS * MA_MAX_PCM_SAMPLE_SIZE_IN_BYTES * 128]; mal_assert(sizeof(tempSamplesOfOutFormat) <= 0xFFFFFFFFF); - void* ppTempSamplesOfOutFormat[MAL_MAX_CHANNELS]; + void* ppTempSamplesOfOutFormat[MA_MAX_CHANNELS]; size_t splitBufferSizeOut; - mal_split_buffer(tempSamplesOfOutFormat, sizeof(tempSamplesOfOutFormat), pConverter->config.channels, MAL_SIMD_ALIGNMENT, (void**)&ppTempSamplesOfOutFormat, &splitBufferSizeOut); + mal_split_buffer(tempSamplesOfOutFormat, sizeof(tempSamplesOfOutFormat), pConverter->config.channels, MA_SIMD_ALIGNMENT, (void**)&ppTempSamplesOfOutFormat, &splitBufferSizeOut); mal_uint32 maxFramesToReadAtATime = (mal_uint32)(splitBufferSizeOut / sampleSizeIn); @@ -26678,11 +26678,11 @@ mal_uint64 mal_format_converter_read(mal_format_converter* pConverter, mal_uint6 } } else { // Interleaving + Conversion. Convert first, then interleave. - MAL_ALIGN(MAL_SIMD_ALIGNMENT) mal_uint8 tempSamplesOfInFormat[MAL_MAX_CHANNELS * MAL_MAX_PCM_SAMPLE_SIZE_IN_BYTES * 128]; + MA_ALIGN(MA_SIMD_ALIGNMENT) mal_uint8 tempSamplesOfInFormat[MA_MAX_CHANNELS * MA_MAX_PCM_SAMPLE_SIZE_IN_BYTES * 128]; - void* ppTempSamplesOfInFormat[MAL_MAX_CHANNELS]; + void* ppTempSamplesOfInFormat[MA_MAX_CHANNELS]; size_t splitBufferSizeIn; - mal_split_buffer(tempSamplesOfInFormat, sizeof(tempSamplesOfInFormat), pConverter->config.channels, MAL_SIMD_ALIGNMENT, (void**)&ppTempSamplesOfInFormat, &splitBufferSizeIn); + mal_split_buffer(tempSamplesOfInFormat, sizeof(tempSamplesOfInFormat), pConverter->config.channels, MA_SIMD_ALIGNMENT, (void**)&ppTempSamplesOfInFormat, &splitBufferSizeIn); if (framesToReadRightNow > (splitBufferSizeIn / sampleSizeIn)) { framesToReadRightNow = (splitBufferSizeIn / sampleSizeIn); @@ -26722,12 +26722,12 @@ mal_uint64 mal_format_converter_read_deinterleaved(mal_format_converter* pConver mal_uint32 sampleSizeIn = mal_get_bytes_per_sample(pConverter->config.formatIn); mal_uint32 sampleSizeOut = mal_get_bytes_per_sample(pConverter->config.formatOut); - mal_uint8* ppNextSamplesOut[MAL_MAX_CHANNELS]; + mal_uint8* ppNextSamplesOut[MA_MAX_CHANNELS]; mal_copy_memory(ppNextSamplesOut, ppSamplesOut, sizeof(void*) * pConverter->config.channels); if (pConverter->config.onRead != NULL) { // Input data is interleaved. - MAL_ALIGN(MAL_SIMD_ALIGNMENT) mal_uint8 tempSamplesOfOutFormat[MAL_MAX_CHANNELS * MAL_MAX_PCM_SAMPLE_SIZE_IN_BYTES * 128]; + MA_ALIGN(MA_SIMD_ALIGNMENT) mal_uint8 tempSamplesOfOutFormat[MA_MAX_CHANNELS * MA_MAX_PCM_SAMPLE_SIZE_IN_BYTES * 128]; mal_assert(sizeof(tempSamplesOfOutFormat) <= 0xFFFFFFFF); mal_uint32 maxFramesToReadAtATime = sizeof(tempSamplesOfOutFormat) / sampleSizeIn / pConverter->config.channels; @@ -26749,7 +26749,7 @@ mal_uint64 mal_format_converter_read_deinterleaved(mal_format_converter* pConver } } else { // De-interleaving + Conversion. Convert first, then de-interleave. - MAL_ALIGN(MAL_SIMD_ALIGNMENT) mal_uint8 tempSamplesOfInFormat[sizeof(tempSamplesOfOutFormat)]; + MA_ALIGN(MA_SIMD_ALIGNMENT) mal_uint8 tempSamplesOfInFormat[sizeof(tempSamplesOfOutFormat)]; framesJustRead = (mal_uint32)pConverter->config.onRead(pConverter, (mal_uint32)framesToReadRightNow, tempSamplesOfInFormat, pUserData); if (framesJustRead == 0) { @@ -26797,12 +26797,12 @@ mal_uint64 mal_format_converter_read_deinterleaved(mal_format_converter* pConver } } else { // Conversion required. - MAL_ALIGN(MAL_SIMD_ALIGNMENT) mal_uint8 temp[MAL_MAX_CHANNELS][MAL_MAX_PCM_SAMPLE_SIZE_IN_BYTES * 128]; + MA_ALIGN(MA_SIMD_ALIGNMENT) mal_uint8 temp[MA_MAX_CHANNELS][MA_MAX_PCM_SAMPLE_SIZE_IN_BYTES * 128]; mal_assert(sizeof(temp) <= 0xFFFFFFFF); - void* ppTemp[MAL_MAX_CHANNELS]; + void* ppTemp[MA_MAX_CHANNELS]; size_t splitBufferSize; - mal_split_buffer(temp, sizeof(temp), pConverter->config.channels, MAL_SIMD_ALIGNMENT, (void**)&ppTemp, &splitBufferSize); + mal_split_buffer(temp, sizeof(temp), pConverter->config.channels, MA_SIMD_ALIGNMENT, (void**)&ppTemp, &splitBufferSize); mal_uint32 maxFramesToReadAtATime = (mal_uint32)(splitBufferSize / sampleSizeIn); @@ -26883,7 +26883,7 @@ typedef struct float z; } mal_vec3; -static MAL_INLINE mal_vec3 mal_vec3f(float x, float y, float z) +static MA_INLINE mal_vec3 mal_vec3f(float x, float y, float z) { mal_vec3 r; r.x = x; @@ -26893,7 +26893,7 @@ static MAL_INLINE mal_vec3 mal_vec3f(float x, float y, float z) return r; } -static MAL_INLINE mal_vec3 mal_vec3_add(mal_vec3 a, mal_vec3 b) +static MA_INLINE mal_vec3 mal_vec3_add(mal_vec3 a, mal_vec3 b) { return mal_vec3f( a.x + b.x, @@ -26902,7 +26902,7 @@ static MAL_INLINE mal_vec3 mal_vec3_add(mal_vec3 a, mal_vec3 b) ); } -static MAL_INLINE mal_vec3 mal_vec3_sub(mal_vec3 a, mal_vec3 b) +static MA_INLINE mal_vec3 mal_vec3_sub(mal_vec3 a, mal_vec3 b) { return mal_vec3f( a.x - b.x, @@ -26911,7 +26911,7 @@ static MAL_INLINE mal_vec3 mal_vec3_sub(mal_vec3 a, mal_vec3 b) ); } -static MAL_INLINE mal_vec3 mal_vec3_mul(mal_vec3 a, mal_vec3 b) +static MA_INLINE mal_vec3 mal_vec3_mul(mal_vec3 a, mal_vec3 b) { return mal_vec3f( a.x * b.x, @@ -26920,7 +26920,7 @@ static MAL_INLINE mal_vec3 mal_vec3_mul(mal_vec3 a, mal_vec3 b) ); } -static MAL_INLINE mal_vec3 mal_vec3_div(mal_vec3 a, mal_vec3 b) +static MA_INLINE mal_vec3 mal_vec3_div(mal_vec3 a, mal_vec3 b) { return mal_vec3f( a.x / b.x, @@ -26929,22 +26929,22 @@ static MAL_INLINE mal_vec3 mal_vec3_div(mal_vec3 a, mal_vec3 b) ); } -static MAL_INLINE float mal_vec3_dot(mal_vec3 a, mal_vec3 b) +static MA_INLINE float mal_vec3_dot(mal_vec3 a, mal_vec3 b) { return a.x*b.x + a.y*b.y + a.z*b.z; } -static MAL_INLINE float mal_vec3_length2(mal_vec3 a) +static MA_INLINE float mal_vec3_length2(mal_vec3 a) { return mal_vec3_dot(a, a); } -static MAL_INLINE float mal_vec3_length(mal_vec3 a) +static MA_INLINE float mal_vec3_length(mal_vec3 a) { return (float)sqrt(mal_vec3_length2(a)); } -static MAL_INLINE mal_vec3 mal_vec3_normalize(mal_vec3 a) +static MA_INLINE mal_vec3 mal_vec3_normalize(mal_vec3 a) { float len = 1 / mal_vec3_length(a); @@ -26956,72 +26956,72 @@ static MAL_INLINE mal_vec3 mal_vec3_normalize(mal_vec3 a) return r; } -static MAL_INLINE float mal_vec3_distance(mal_vec3 a, mal_vec3 b) +static MA_INLINE float mal_vec3_distance(mal_vec3 a, mal_vec3 b) { return mal_vec3_length(mal_vec3_sub(a, b)); } -#define MAL_PLANE_LEFT 0 -#define MAL_PLANE_RIGHT 1 -#define MAL_PLANE_FRONT 2 -#define MAL_PLANE_BACK 3 -#define MAL_PLANE_BOTTOM 4 -#define MAL_PLANE_TOP 5 +#define MA_PLANE_LEFT 0 +#define MA_PLANE_RIGHT 1 +#define MA_PLANE_FRONT 2 +#define MA_PLANE_BACK 3 +#define MA_PLANE_BOTTOM 4 +#define MA_PLANE_TOP 5 -float g_malChannelPlaneRatios[MAL_CHANNEL_POSITION_COUNT][6] = { - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_NONE - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_MONO - { 0.5f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_FRONT_LEFT - { 0.0f, 0.5f, 0.5f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_FRONT_RIGHT - { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_FRONT_CENTER - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_LFE - { 0.5f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f}, // MAL_CHANNEL_BACK_LEFT - { 0.0f, 0.5f, 0.0f, 0.5f, 0.0f, 0.0f}, // MAL_CHANNEL_BACK_RIGHT - { 0.25f, 0.0f, 0.75f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_FRONT_LEFT_CENTER - { 0.0f, 0.25f, 0.75f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_FRONT_RIGHT_CENTER - { 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f}, // MAL_CHANNEL_BACK_CENTER - { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_SIDE_LEFT - { 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_SIDE_RIGHT - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, // MAL_CHANNEL_TOP_CENTER - { 0.33f, 0.0f, 0.33f, 0.0f, 0.0f, 0.34f}, // MAL_CHANNEL_TOP_FRONT_LEFT - { 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.5f}, // MAL_CHANNEL_TOP_FRONT_CENTER - { 0.0f, 0.33f, 0.33f, 0.0f, 0.0f, 0.34f}, // MAL_CHANNEL_TOP_FRONT_RIGHT - { 0.33f, 0.0f, 0.0f, 0.33f, 0.0f, 0.34f}, // MAL_CHANNEL_TOP_BACK_LEFT - { 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.5f}, // MAL_CHANNEL_TOP_BACK_CENTER - { 0.0f, 0.33f, 0.0f, 0.33f, 0.0f, 0.34f}, // MAL_CHANNEL_TOP_BACK_RIGHT - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_0 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_1 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_2 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_3 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_4 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_5 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_6 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_7 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_8 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_9 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_10 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_11 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_12 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_13 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_14 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_15 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_16 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_17 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_18 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_19 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_20 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_21 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_22 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_23 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_24 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_25 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_26 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_27 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_28 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_29 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_30 - { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MAL_CHANNEL_AUX_31 +float g_malChannelPlaneRatios[MA_CHANNEL_POSITION_COUNT][6] = { + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_NONE + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_MONO + { 0.5f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_FRONT_LEFT + { 0.0f, 0.5f, 0.5f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_FRONT_RIGHT + { 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_FRONT_CENTER + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_LFE + { 0.5f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f}, // MA_CHANNEL_BACK_LEFT + { 0.0f, 0.5f, 0.0f, 0.5f, 0.0f, 0.0f}, // MA_CHANNEL_BACK_RIGHT + { 0.25f, 0.0f, 0.75f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_FRONT_LEFT_CENTER + { 0.0f, 0.25f, 0.75f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_FRONT_RIGHT_CENTER + { 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f}, // MA_CHANNEL_BACK_CENTER + { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_SIDE_LEFT + { 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_SIDE_RIGHT + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, // MA_CHANNEL_TOP_CENTER + { 0.33f, 0.0f, 0.33f, 0.0f, 0.0f, 0.34f}, // MA_CHANNEL_TOP_FRONT_LEFT + { 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.5f}, // MA_CHANNEL_TOP_FRONT_CENTER + { 0.0f, 0.33f, 0.33f, 0.0f, 0.0f, 0.34f}, // MA_CHANNEL_TOP_FRONT_RIGHT + { 0.33f, 0.0f, 0.0f, 0.33f, 0.0f, 0.34f}, // MA_CHANNEL_TOP_BACK_LEFT + { 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.5f}, // MA_CHANNEL_TOP_BACK_CENTER + { 0.0f, 0.33f, 0.0f, 0.33f, 0.0f, 0.34f}, // MA_CHANNEL_TOP_BACK_RIGHT + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_0 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_1 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_2 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_3 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_4 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_5 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_6 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_7 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_8 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_9 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_10 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_11 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_12 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_13 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_14 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_15 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_16 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_17 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_18 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_19 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_20 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_21 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_22 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_23 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_24 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_25 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_26 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_27 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_28 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_29 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_30 + { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, // MA_CHANNEL_AUX_31 }; float mal_calculate_channel_position_planar_weight(mal_channel channelPositionA, mal_channel channelPositionB) @@ -27078,39 +27078,39 @@ mal_bool32 mal_channel_router__is_spatial_channel_position(const mal_channel_rou mal_assert(pRouter != NULL); (void)pRouter; - if (channelPosition == MAL_CHANNEL_NONE || channelPosition == MAL_CHANNEL_MONO || channelPosition == MAL_CHANNEL_LFE) { - return MAL_FALSE; + if (channelPosition == MA_CHANNEL_NONE || channelPosition == MA_CHANNEL_MONO || channelPosition == MA_CHANNEL_LFE) { + return MA_FALSE; } for (int i = 0; i < 6; ++i) { if (g_malChannelPlaneRatios[channelPosition][i] != 0) { - return MAL_TRUE; + return MA_TRUE; } } - return MAL_FALSE; + return MA_FALSE; } mal_result mal_channel_router_init(const mal_channel_router_config* pConfig, mal_channel_router* pRouter) { if (pRouter == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_zero_object(pRouter); if (pConfig == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } if (pConfig->onReadDeinterleaved == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } if (!mal_channel_map_valid(pConfig->channelsIn, pConfig->channelMapIn)) { - return MAL_INVALID_ARGS; // Invalid input channel map. + return MA_INVALID_ARGS; // Invalid input channel map. } if (!mal_channel_map_valid(pConfig->channelsOut, pConfig->channelMapOut)) { - return MAL_INVALID_ARGS; // Invalid output channel map. + return MA_INVALID_ARGS; // Invalid output channel map. } pRouter->config = *pConfig; @@ -27124,10 +27124,10 @@ mal_result mal_channel_router_init(const mal_channel_router_config* pConfig, mal // If the input and output channels and channel maps are the same we should use a passthrough. if (pRouter->config.channelsIn == pRouter->config.channelsOut) { if (mal_channel_map_equal(pRouter->config.channelsIn, pRouter->config.channelMapIn, pRouter->config.channelMapOut)) { - pRouter->isPassthrough = MAL_TRUE; + pRouter->isPassthrough = MA_TRUE; } if (mal_channel_map_blank(pRouter->config.channelsIn, pRouter->config.channelMapIn) || mal_channel_map_blank(pRouter->config.channelsOut, pRouter->config.channelMapOut)) { - pRouter->isPassthrough = MAL_TRUE; + pRouter->isPassthrough = MA_TRUE; } } @@ -27139,24 +27139,24 @@ mal_result mal_channel_router_init(const mal_channel_router_config* pConfig, mal // 3) Otherwise channels are blended based on spatial locality. if (!pRouter->isPassthrough) { if (pRouter->config.channelsIn == pRouter->config.channelsOut) { - mal_bool32 areAllChannelPositionsPresent = MAL_TRUE; + mal_bool32 areAllChannelPositionsPresent = MA_TRUE; for (mal_uint32 iChannelIn = 0; iChannelIn < pRouter->config.channelsIn; ++iChannelIn) { - mal_bool32 isInputChannelPositionInOutput = MAL_FALSE; + mal_bool32 isInputChannelPositionInOutput = MA_FALSE; for (mal_uint32 iChannelOut = 0; iChannelOut < pRouter->config.channelsOut; ++iChannelOut) { if (pRouter->config.channelMapIn[iChannelIn] == pRouter->config.channelMapOut[iChannelOut]) { - isInputChannelPositionInOutput = MAL_TRUE; + isInputChannelPositionInOutput = MA_TRUE; break; } } if (!isInputChannelPositionInOutput) { - areAllChannelPositionsPresent = MAL_FALSE; + areAllChannelPositionsPresent = MA_FALSE; break; } } if (areAllChannelPositionsPresent) { - pRouter->isSimpleShuffle = MAL_TRUE; + pRouter->isSimpleShuffle = MA_TRUE; // All the router will be doing is rearranging channels which means all we need to do is use a shuffling table which is just // a mapping between the index of the input channel to the index of the output channel. @@ -27198,11 +27198,11 @@ mal_result mal_channel_router_init(const mal_channel_router_config* pConfig, mal for (mal_uint32 iChannelIn = 0; iChannelIn < pRouter->config.channelsIn; ++iChannelIn) { mal_channel channelPosIn = pRouter->config.channelMapIn[iChannelIn]; - if (channelPosIn == MAL_CHANNEL_MONO) { + if (channelPosIn == MA_CHANNEL_MONO) { for (mal_uint32 iChannelOut = 0; iChannelOut < pRouter->config.channelsOut; ++iChannelOut) { mal_channel channelPosOut = pRouter->config.channelMapOut[iChannelOut]; - if (channelPosOut != MAL_CHANNEL_NONE && channelPosOut != MAL_CHANNEL_MONO && channelPosOut != MAL_CHANNEL_LFE) { + if (channelPosOut != MA_CHANNEL_NONE && channelPosOut != MA_CHANNEL_MONO && channelPosOut != MA_CHANNEL_LFE) { pRouter->config.weights[iChannelIn][iChannelOut] = 1; } } @@ -27215,7 +27215,7 @@ mal_result mal_channel_router_init(const mal_channel_router_config* pConfig, mal for (mal_uint32 iChannelIn = 0; iChannelIn < pRouter->config.channelsIn; ++iChannelIn) { mal_channel channelPosIn = pRouter->config.channelMapIn[iChannelIn]; - if (channelPosIn != MAL_CHANNEL_NONE && channelPosIn != MAL_CHANNEL_MONO && channelPosIn != MAL_CHANNEL_LFE) { + if (channelPosIn != MA_CHANNEL_NONE && channelPosIn != MA_CHANNEL_MONO && channelPosIn != MA_CHANNEL_LFE) { len += 1; } } @@ -27226,11 +27226,11 @@ mal_result mal_channel_router_init(const mal_channel_router_config* pConfig, mal for (mal_uint32 iChannelOut = 0; iChannelOut < pRouter->config.channelsOut; ++iChannelOut) { mal_channel channelPosOut = pRouter->config.channelMapOut[iChannelOut]; - if (channelPosOut == MAL_CHANNEL_MONO) { + if (channelPosOut == MA_CHANNEL_MONO) { for (mal_uint32 iChannelIn = 0; iChannelIn < pRouter->config.channelsIn; ++iChannelIn) { mal_channel channelPosIn = pRouter->config.channelMapIn[iChannelIn]; - if (channelPosIn != MAL_CHANNEL_NONE && channelPosIn != MAL_CHANNEL_MONO && channelPosIn != MAL_CHANNEL_LFE) { + if (channelPosIn != MA_CHANNEL_NONE && channelPosIn != MA_CHANNEL_MONO && channelPosIn != MA_CHANNEL_LFE) { pRouter->config.weights[iChannelIn][iChannelOut] += monoWeight; } } @@ -27304,25 +27304,25 @@ mal_result mal_channel_router_init(const mal_channel_router_config* pConfig, mal } break; } - return MAL_SUCCESS; + return MA_SUCCESS; } -static MAL_INLINE mal_bool32 mal_channel_router__can_use_sse2(mal_channel_router* pRouter, const float* pSamplesOut, const float* pSamplesIn) +static MA_INLINE mal_bool32 mal_channel_router__can_use_sse2(mal_channel_router* pRouter, const float* pSamplesOut, const float* pSamplesIn) { return pRouter->useSSE2 && (((mal_uintptr)pSamplesOut & 15) == 0) && (((mal_uintptr)pSamplesIn & 15) == 0); } -static MAL_INLINE mal_bool32 mal_channel_router__can_use_avx2(mal_channel_router* pRouter, const float* pSamplesOut, const float* pSamplesIn) +static MA_INLINE mal_bool32 mal_channel_router__can_use_avx2(mal_channel_router* pRouter, const float* pSamplesOut, const float* pSamplesIn) { return pRouter->useAVX2 && (((mal_uintptr)pSamplesOut & 31) == 0) && (((mal_uintptr)pSamplesIn & 31) == 0); } -static MAL_INLINE mal_bool32 mal_channel_router__can_use_avx512(mal_channel_router* pRouter, const float* pSamplesOut, const float* pSamplesIn) +static MA_INLINE mal_bool32 mal_channel_router__can_use_avx512(mal_channel_router* pRouter, const float* pSamplesOut, const float* pSamplesIn) { return pRouter->useAVX512 && (((mal_uintptr)pSamplesOut & 63) == 0) && (((mal_uintptr)pSamplesIn & 63) == 0); } -static MAL_INLINE mal_bool32 mal_channel_router__can_use_neon(mal_channel_router* pRouter, const float* pSamplesOut, const float* pSamplesIn) +static MA_INLINE mal_bool32 mal_channel_router__can_use_neon(mal_channel_router* pRouter, const float* pSamplesOut, const float* pSamplesIn) { return pRouter->useNEON && (((mal_uintptr)pSamplesOut & 15) == 0) && (((mal_uintptr)pSamplesIn & 15) == 0); } @@ -27330,7 +27330,7 @@ static MAL_INLINE mal_bool32 mal_channel_router__can_use_neon(mal_channel_router void mal_channel_router__do_routing(mal_channel_router* pRouter, mal_uint64 frameCount, float** ppSamplesOut, const float** ppSamplesIn) { mal_assert(pRouter != NULL); - mal_assert(pRouter->isPassthrough == MAL_FALSE); + mal_assert(pRouter->isPassthrough == MA_FALSE); if (pRouter->isSimpleShuffle) { // A shuffle is just a re-arrangement of channels and does not require any arithmetic. @@ -27351,7 +27351,7 @@ void mal_channel_router__do_routing(mal_channel_router* pRouter, mal_uint64 fram for (mal_uint32 iChannelIn = 0; iChannelIn < pRouter->config.channelsIn; ++iChannelIn) { for (mal_uint32 iChannelOut = 0; iChannelOut < pRouter->config.channelsOut; ++iChannelOut) { mal_uint64 iFrame = 0; -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) if (mal_channel_router__can_use_neon(pRouter, ppSamplesOut[iChannelOut], ppSamplesIn[iChannelIn])) { float32x4_t weight = vmovq_n_f32(pRouter->config.weights[iChannelIn][iChannelOut]); @@ -27366,7 +27366,7 @@ void mal_channel_router__do_routing(mal_channel_router* pRouter, mal_uint64 fram } else #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) if (mal_channel_router__can_use_avx512(pRouter, ppSamplesOut[iChannelOut], ppSamplesIn[iChannelIn])) { __m512 weight = _mm512_set1_ps(pRouter->config.weights[iChannelIn][iChannelOut]); @@ -27381,7 +27381,7 @@ void mal_channel_router__do_routing(mal_channel_router* pRouter, mal_uint64 fram } else #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) if (mal_channel_router__can_use_avx2(pRouter, ppSamplesOut[iChannelOut], ppSamplesIn[iChannelIn])) { __m256 weight = _mm256_set1_ps(pRouter->config.weights[iChannelIn][iChannelOut]); @@ -27396,7 +27396,7 @@ void mal_channel_router__do_routing(mal_channel_router* pRouter, mal_uint64 fram } else #endif -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) if (mal_channel_router__can_use_sse2(pRouter, ppSamplesOut[iChannelOut], ppSamplesIn[iChannelIn])) { __m128 weight = _mm_set1_ps(pRouter->config.weights[iChannelIn][iChannelOut]); @@ -27446,7 +27446,7 @@ mal_uint64 mal_channel_router_read_deinterleaved(mal_channel_router* pRouter, ma if (frameCount <= 0xFFFFFFFF) { return (mal_uint32)pRouter->config.onReadDeinterleaved(pRouter, (mal_uint32)frameCount, ppSamplesOut, pUserData); } else { - float* ppNextSamplesOut[MAL_MAX_CHANNELS]; + float* ppNextSamplesOut[MA_MAX_CHANNELS]; mal_copy_memory(ppNextSamplesOut, ppSamplesOut, sizeof(float*) * pRouter->config.channelsOut); mal_uint64 totalFramesRead = 0; @@ -27475,15 +27475,15 @@ mal_uint64 mal_channel_router_read_deinterleaved(mal_channel_router* pRouter, ma } // Slower path for a non-passthrough. - float* ppNextSamplesOut[MAL_MAX_CHANNELS]; + float* ppNextSamplesOut[MA_MAX_CHANNELS]; mal_copy_memory(ppNextSamplesOut, ppSamplesOut, sizeof(float*) * pRouter->config.channelsOut); - MAL_ALIGN(MAL_SIMD_ALIGNMENT) float temp[MAL_MAX_CHANNELS * 256]; + MA_ALIGN(MA_SIMD_ALIGNMENT) float temp[MA_MAX_CHANNELS * 256]; mal_assert(sizeof(temp) <= 0xFFFFFFFF); - float* ppTemp[MAL_MAX_CHANNELS]; + float* ppTemp[MA_MAX_CHANNELS]; size_t maxBytesToReadPerFrameEachIteration; - mal_split_buffer(temp, sizeof(temp), pRouter->config.channelsIn, MAL_SIMD_ALIGNMENT, (void**)&ppTemp, &maxBytesToReadPerFrameEachIteration); + mal_split_buffer(temp, sizeof(temp), pRouter->config.channelsIn, MA_SIMD_ALIGNMENT, (void**)&ppTemp, &maxBytesToReadPerFrameEachIteration); size_t maxFramesToReadEachIteration = maxBytesToReadPerFrameEachIteration/sizeof(float); @@ -27517,7 +27517,7 @@ mal_uint64 mal_channel_router_read_deinterleaved(mal_channel_router* pRouter, ma return totalFramesRead; } -mal_channel_router_config mal_channel_router_config_init(mal_uint32 channelsIn, const mal_channel channelMapIn[MAL_MAX_CHANNELS], mal_uint32 channelsOut, const mal_channel channelMapOut[MAL_MAX_CHANNELS], mal_channel_mix_mode mixingMode, mal_channel_router_read_deinterleaved_proc onRead, void* pUserData) +mal_channel_router_config mal_channel_router_config_init(mal_uint32 channelsIn, const mal_channel channelMapIn[MA_MAX_CHANNELS], mal_uint32 channelsOut, const mal_channel channelMapOut[MA_MAX_CHANNELS], mal_channel_mix_mode mixingMode, mal_channel_router_read_deinterleaved_proc onRead, void* pUserData) { mal_channel_router_config config; mal_zero_object(&config); @@ -27551,10 +27551,10 @@ mal_channel_router_config mal_channel_router_config_init(mal_uint32 channelsIn, #define mal_sinf(x) ((float)sin((double)(x))) #define mal_cosf(x) ((float)cos((double)(x))) -static MAL_INLINE double mal_sinc(double x) +static MA_INLINE double mal_sinc(double x) { if (x != 0) { - return sin(MAL_PI_D*x) / (MAL_PI_D*x); + return sin(MA_PI_D*x) / (MA_PI_D*x); } else { return 1; } @@ -27573,7 +27573,7 @@ void mal_src__build_sinc_table__sinc(mal_src* pSRC) pSRC->sinc.table[0] = 1.0f; for (mal_uint32 i = 1; i < mal_countof(pSRC->sinc.table); i += 1) { - double x = i*MAL_PI_D / MAL_SRC_SINC_LOOKUP_TABLE_RESOLUTION; + double x = i*MA_PI_D / MA_SRC_SINC_LOOKUP_TABLE_RESOLUTION; pSRC->sinc.table[i] = (float)(sin(x)/x); } } @@ -27590,9 +27590,9 @@ void mal_src__build_sinc_table__hann(mal_src* pSRC) for (mal_uint32 i = 0; i < mal_countof(pSRC->sinc.table); i += 1) { double x = pSRC->sinc.table[i]; - double N = MAL_SRC_SINC_MAX_WINDOW_WIDTH*2; - double n = ((double)(i) / MAL_SRC_SINC_LOOKUP_TABLE_RESOLUTION) + MAL_SRC_SINC_MAX_WINDOW_WIDTH; - double w = 0.5 * (1 - cos((2*MAL_PI_D*n) / (N))); + double N = MA_SRC_SINC_MAX_WINDOW_WIDTH*2; + double n = ((double)(i) / MA_SRC_SINC_LOOKUP_TABLE_RESOLUTION) + MA_SRC_SINC_MAX_WINDOW_WIDTH; + double w = 0.5 * (1 - cos((2*MA_PI_D*n) / (N))); pSRC->sinc.table[i] = (float)(x * w); } @@ -27601,16 +27601,16 @@ void mal_src__build_sinc_table__hann(mal_src* pSRC) mal_result mal_src_init(const mal_src_config* pConfig, mal_src* pSRC) { if (pSRC == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_zero_object(pSRC); if (pConfig == NULL || pConfig->onReadDeinterleaved == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } - if (pConfig->channels == 0 || pConfig->channels > MAL_MAX_CHANNELS) { - return MAL_INVALID_ARGS; + if (pConfig->channels == 0 || pConfig->channels > MA_MAX_CHANNELS) { + return MA_INVALID_ARGS; } pSRC->config = *pConfig; @@ -27624,41 +27624,41 @@ mal_result mal_src_init(const mal_src_config* pConfig, mal_src* pSRC) if (pSRC->config.algorithm == mal_src_algorithm_sinc) { // Make sure the window width within bounds. if (pSRC->config.sinc.windowWidth == 0) { - pSRC->config.sinc.windowWidth = MAL_SRC_SINC_DEFAULT_WINDOW_WIDTH; + pSRC->config.sinc.windowWidth = MA_SRC_SINC_DEFAULT_WINDOW_WIDTH; } - if (pSRC->config.sinc.windowWidth < MAL_SRC_SINC_MIN_WINDOW_WIDTH) { - pSRC->config.sinc.windowWidth = MAL_SRC_SINC_MIN_WINDOW_WIDTH; + if (pSRC->config.sinc.windowWidth < MA_SRC_SINC_MIN_WINDOW_WIDTH) { + pSRC->config.sinc.windowWidth = MA_SRC_SINC_MIN_WINDOW_WIDTH; } - if (pSRC->config.sinc.windowWidth > MAL_SRC_SINC_MAX_WINDOW_WIDTH) { - pSRC->config.sinc.windowWidth = MAL_SRC_SINC_MAX_WINDOW_WIDTH; + if (pSRC->config.sinc.windowWidth > MA_SRC_SINC_MAX_WINDOW_WIDTH) { + pSRC->config.sinc.windowWidth = MA_SRC_SINC_MAX_WINDOW_WIDTH; } // Set up the lookup table. switch (pSRC->config.sinc.windowFunction) { case mal_src_sinc_window_function_hann: mal_src__build_sinc_table__hann(pSRC); break; case mal_src_sinc_window_function_rectangular: mal_src__build_sinc_table__rectangular(pSRC); break; - default: return MAL_INVALID_ARGS; // <-- Hitting this means the window function is unknown to miniaudio. + default: return MA_INVALID_ARGS; // <-- Hitting this means the window function is unknown to miniaudio. } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_src_set_sample_rate(mal_src* pSRC, mal_uint32 sampleRateIn, mal_uint32 sampleRateOut) { if (pSRC == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } // Must have a sample rate of > 0. if (sampleRateIn == 0 || sampleRateOut == 0) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_atomic_exchange_32(&pSRC->config.sampleRateIn, sampleRateIn); mal_atomic_exchange_32(&pSRC->config.sampleRateOut, sampleRateOut); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_uint64 mal_src_read_deinterleaved(mal_src* pSRC, mal_uint64 frameCount, void** ppSamplesOut, void* pUserData) @@ -27686,7 +27686,7 @@ mal_uint64 mal_src_read_deinterleaved__passthrough(mal_src* pSRC, mal_uint64 fra if (frameCount <= 0xFFFFFFFF) { return pSRC->config.onReadDeinterleaved(pSRC, (mal_uint32)frameCount, ppSamplesOut, pUserData); } else { - float* ppNextSamplesOut[MAL_MAX_CHANNELS]; + float* ppNextSamplesOut[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < pSRC->config.channels; ++iChannel) { ppNextSamplesOut[iChannel] = (float*)ppSamplesOut[iChannel]; } @@ -27724,7 +27724,7 @@ mal_uint64 mal_src_read_deinterleaved__linear(mal_src* pSRC, mal_uint64 frameCou mal_assert(frameCount > 0); mal_assert(ppSamplesOut != NULL); - float* ppNextSamplesOut[MAL_MAX_CHANNELS]; + float* ppNextSamplesOut[MA_MAX_CHANNELS]; mal_copy_memory(ppNextSamplesOut, ppSamplesOut, sizeof(void*) * pSRC->config.channels); @@ -27751,7 +27751,7 @@ mal_uint64 mal_src_read_deinterleaved__linear(mal_src* pSRC, mal_uint64 frameCou framesToReadFromClient = maxFrameCountPerChunkIn; } - float* ppSamplesFromClient[MAL_MAX_CHANNELS]; + float* ppSamplesFromClient[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < pSRC->config.channels; ++iChannel) { ppSamplesFromClient[iChannel] = pSRC->linear.input[iChannel] + pSRC->linear.leftoverFrames; } @@ -27916,7 +27916,7 @@ mal_src_config mal_src_config_init(mal_uint32 sampleRateIn, mal_uint32 sampleRat // which I realize is a bit ambigous with the mathematical "window", but it works for me when I need to conceptualize things in my head. The window is made up // of two halves. The first half contains past input samples (initialized to zero), and the second half contains future input samples. As time moves forward // and input samples are consumed, the window moves forward. The larger the window, the better the quality at the expense of slower processing. The window is -// limited the range [MAL_SRC_SINC_MIN_WINDOW_WIDTH, MAL_SRC_SINC_MAX_WINDOW_WIDTH] and defaults to MAL_SRC_SINC_DEFAULT_WINDOW_WIDTH. +// limited the range [MA_SRC_SINC_MIN_WINDOW_WIDTH, MA_SRC_SINC_MAX_WINDOW_WIDTH] and defaults to MA_SRC_SINC_DEFAULT_WINDOW_WIDTH. // // Input samples are cached for efficiency (to prevent frequently requesting tiny numbers of samples from the client). When the window gets to the end of the // cache, it's moved back to the start, and more samples are read from the client. If the client has no more data to give, the cache is filled with zeros and @@ -27932,10 +27932,10 @@ mal_src_config mal_src_config_init(mal_uint32 sampleRateIn, mal_uint32 sampleRat /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Comment this to disable interpolation of table lookups. Less accurate, but faster. -#define MAL_USE_SINC_TABLE_INTERPOLATION +#define MA_USE_SINC_TABLE_INTERPOLATION // Retrieves a sample from the input buffer's window. Values >= 0 retrieve future samples. Negative values return past samples. -static MAL_INLINE float mal_src_sinc__get_input_sample_from_window(const mal_src* pSRC, mal_uint32 channel, mal_uint32 windowPosInSamples, mal_int32 sampleIndex) +static MA_INLINE float mal_src_sinc__get_input_sample_from_window(const mal_src* pSRC, mal_uint32 channel, mal_uint32 windowPosInSamples, mal_int32 sampleIndex) { mal_assert(pSRC != NULL); mal_assert(channel < pSRC->config.channels); @@ -27948,19 +27948,19 @@ static MAL_INLINE float mal_src_sinc__get_input_sample_from_window(const mal_src return pSRC->sinc.input[channel][windowPosInSamples + pSRC->config.sinc.windowWidth + sampleIndex]; } -static MAL_INLINE float mal_src_sinc__interpolation_factor(const mal_src* pSRC, float x) +static MA_INLINE float mal_src_sinc__interpolation_factor(const mal_src* pSRC, float x) { mal_assert(pSRC != NULL); float xabs = (float)fabs(x); - //if (xabs >= MAL_SRC_SINC_MAX_WINDOW_WIDTH /*pSRC->config.sinc.windowWidth*/) { + //if (xabs >= MA_SRC_SINC_MAX_WINDOW_WIDTH /*pSRC->config.sinc.windowWidth*/) { // xabs = 1; // <-- A non-zero integer will always return 0. //} - xabs = xabs * MAL_SRC_SINC_LOOKUP_TABLE_RESOLUTION; + xabs = xabs * MA_SRC_SINC_LOOKUP_TABLE_RESOLUTION; mal_int32 ixabs = (mal_int32)xabs; -#if defined(MAL_USE_SINC_TABLE_INTERPOLATION) +#if defined(MA_USE_SINC_TABLE_INTERPOLATION) float a = xabs - ixabs; return mal_mix_f32_fast(pSRC->sinc.table[ixabs], pSRC->sinc.table[ixabs+1], a); #else @@ -27968,26 +27968,26 @@ static MAL_INLINE float mal_src_sinc__interpolation_factor(const mal_src* pSRC, #endif } -#if defined(MAL_SUPPORT_SSE2) -static MAL_INLINE __m128 mal_fabsf_sse2(__m128 x) +#if defined(MA_SUPPORT_SSE2) +static MA_INLINE __m128 mal_fabsf_sse2(__m128 x) { return _mm_and_ps(_mm_castsi128_ps(_mm_set1_epi32(0x7FFFFFFF)), x); } -static MAL_INLINE __m128 mal_truncf_sse2(__m128 x) +static MA_INLINE __m128 mal_truncf_sse2(__m128 x) { return _mm_cvtepi32_ps(_mm_cvttps_epi32(x)); } -static MAL_INLINE __m128 mal_src_sinc__interpolation_factor__sse2(const mal_src* pSRC, __m128 x) +static MA_INLINE __m128 mal_src_sinc__interpolation_factor__sse2(const mal_src* pSRC, __m128 x) { - //__m128 windowWidth128 = _mm_set1_ps(MAL_SRC_SINC_MAX_WINDOW_WIDTH); - __m128 resolution128 = _mm_set1_ps(MAL_SRC_SINC_LOOKUP_TABLE_RESOLUTION); + //__m128 windowWidth128 = _mm_set1_ps(MA_SRC_SINC_MAX_WINDOW_WIDTH); + __m128 resolution128 = _mm_set1_ps(MA_SRC_SINC_LOOKUP_TABLE_RESOLUTION); //__m128 one = _mm_set1_ps(1); __m128 xabs = mal_fabsf_sse2(x); - // if (MAL_SRC_SINC_MAX_WINDOW_WIDTH <= xabs) xabs = 1 else xabs = xabs; + // if (MA_SRC_SINC_MAX_WINDOW_WIDTH <= xabs) xabs = 1 else xabs = xabs; //__m128 xcmp = _mm_cmp_ps(windowWidth128, xabs, 2); // 2 = Less than or equal = _mm_cmple_ps. //xabs = _mm_or_ps(_mm_and_ps(one, xcmp), _mm_andnot_ps(xcmp, xabs)); // xabs = (xcmp) ? 1 : xabs; @@ -28017,22 +28017,22 @@ static MAL_INLINE __m128 mal_src_sinc__interpolation_factor__sse2(const mal_src* } #endif -#if defined(MAL_SUPPORT_AVX2) -static MAL_INLINE __m256 mal_fabsf_avx2(__m256 x) +#if defined(MA_SUPPORT_AVX2) +static MA_INLINE __m256 mal_fabsf_avx2(__m256 x) { return _mm256_and_ps(_mm256_castsi256_ps(_mm256_set1_epi32(0x7FFFFFFF)), x); } #if 0 -static MAL_INLINE __m256 mal_src_sinc__interpolation_factor__avx2(const mal_src* pSRC, __m256 x) +static MA_INLINE __m256 mal_src_sinc__interpolation_factor__avx2(const mal_src* pSRC, __m256 x) { - //__m256 windowWidth256 = _mm256_set1_ps(MAL_SRC_SINC_MAX_WINDOW_WIDTH); - __m256 resolution256 = _mm256_set1_ps(MAL_SRC_SINC_LOOKUP_TABLE_RESOLUTION); + //__m256 windowWidth256 = _mm256_set1_ps(MA_SRC_SINC_MAX_WINDOW_WIDTH); + __m256 resolution256 = _mm256_set1_ps(MA_SRC_SINC_LOOKUP_TABLE_RESOLUTION); //__m256 one = _mm256_set1_ps(1); __m256 xabs = mal_fabsf_avx2(x); - // if (MAL_SRC_SINC_MAX_WINDOW_WIDTH <= xabs) xabs = 1 else xabs = xabs; + // if (MA_SRC_SINC_MAX_WINDOW_WIDTH <= xabs) xabs = 1 else xabs = xabs; //__m256 xcmp = _mm256_cmp_ps(windowWidth256, xabs, 2); // 2 = Less than or equal = _mm_cmple_ps. //xabs = _mm256_or_ps(_mm256_and_ps(one, xcmp), _mm256_andnot_ps(xcmp, xabs)); // xabs = (xcmp) ? 1 : xabs; @@ -28074,16 +28074,16 @@ static MAL_INLINE __m256 mal_src_sinc__interpolation_factor__avx2(const mal_src* #endif -#if defined(MAL_SUPPORT_NEON) -static MAL_INLINE float32x4_t mal_fabsf_neon(float32x4_t x) +#if defined(MA_SUPPORT_NEON) +static MA_INLINE float32x4_t mal_fabsf_neon(float32x4_t x) { return vabdq_f32(vmovq_n_f32(0), x); } -static MAL_INLINE float32x4_t mal_src_sinc__interpolation_factor__neon(const mal_src* pSRC, float32x4_t x) +static MA_INLINE float32x4_t mal_src_sinc__interpolation_factor__neon(const mal_src* pSRC, float32x4_t x) { float32x4_t xabs = mal_fabsf_neon(x); - xabs = vmulq_n_f32(xabs, MAL_SRC_SINC_LOOKUP_TABLE_RESOLUTION); + xabs = vmulq_n_f32(xabs, MA_SRC_SINC_LOOKUP_TABLE_RESOLUTION); int32x4_t ixabs = vcvtq_s32_f32(xabs); @@ -28136,16 +28136,16 @@ mal_uint64 mal_src_read_deinterleaved__sinc(mal_src* pSRC, mal_uint64 frameCount mal_int32 windowWidthSIMD2 = windowWidthSIMD*2; (void)windowWidthSIMD2; // <-- Silence a warning when SIMD is disabled. - float* ppNextSamplesOut[MAL_MAX_CHANNELS]; + float* ppNextSamplesOut[MA_MAX_CHANNELS]; mal_copy_memory(ppNextSamplesOut, ppSamplesOut, sizeof(void*) * pSRC->config.channels); - float _windowSamplesUnaligned[MAL_SRC_SINC_MAX_WINDOW_WIDTH*2 + MAL_SIMD_ALIGNMENT]; - float* windowSamples = (float*)(((mal_uintptr)_windowSamplesUnaligned + MAL_SIMD_ALIGNMENT-1) & ~(MAL_SIMD_ALIGNMENT-1)); - mal_zero_memory(windowSamples, MAL_SRC_SINC_MAX_WINDOW_WIDTH*2 * sizeof(float)); + float _windowSamplesUnaligned[MA_SRC_SINC_MAX_WINDOW_WIDTH*2 + MA_SIMD_ALIGNMENT]; + float* windowSamples = (float*)(((mal_uintptr)_windowSamplesUnaligned + MA_SIMD_ALIGNMENT-1) & ~(MA_SIMD_ALIGNMENT-1)); + mal_zero_memory(windowSamples, MA_SRC_SINC_MAX_WINDOW_WIDTH*2 * sizeof(float)); - float _iWindowFUnaligned[MAL_SRC_SINC_MAX_WINDOW_WIDTH*2 + MAL_SIMD_ALIGNMENT]; - float* iWindowF = (float*)(((mal_uintptr)_iWindowFUnaligned + MAL_SIMD_ALIGNMENT-1) & ~(MAL_SIMD_ALIGNMENT-1)); - mal_zero_memory(iWindowF, MAL_SRC_SINC_MAX_WINDOW_WIDTH*2 * sizeof(float)); + float _iWindowFUnaligned[MA_SRC_SINC_MAX_WINDOW_WIDTH*2 + MA_SIMD_ALIGNMENT]; + float* iWindowF = (float*)(((mal_uintptr)_iWindowFUnaligned + MA_SIMD_ALIGNMENT-1) & ~(MA_SIMD_ALIGNMENT-1)); + mal_zero_memory(iWindowF, MA_SRC_SINC_MAX_WINDOW_WIDTH*2 * sizeof(float)); for (mal_int32 i = 0; i < windowWidth2; ++i) { iWindowF[i] = (float)(i - windowWidth); } @@ -28198,11 +28198,11 @@ mal_uint64 mal_src_read_deinterleaved__sinc(mal_src* pSRC, mal_uint64 frameCount windowSamples[i] = pSRC->sinc.input[iChannel][iTimeIn + i]; } -#if defined(MAL_SUPPORT_AVX2) || defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX2) || defined(MA_SUPPORT_AVX512) if (pSRC->useAVX2 || pSRC->useAVX512) { - __m256i ixabs[MAL_SRC_SINC_MAX_WINDOW_WIDTH*2/8]; - __m256 a[MAL_SRC_SINC_MAX_WINDOW_WIDTH*2/8]; - __m256 resolution256 = _mm256_set1_ps(MAL_SRC_SINC_LOOKUP_TABLE_RESOLUTION); + __m256i ixabs[MA_SRC_SINC_MAX_WINDOW_WIDTH*2/8]; + __m256 a[MA_SRC_SINC_MAX_WINDOW_WIDTH*2/8]; + __m256 resolution256 = _mm256_set1_ps(MA_SRC_SINC_LOOKUP_TABLE_RESOLUTION); __m256 t = _mm256_set1_ps((timeIn - iTimeInF)); __m256 r = _mm256_set1_ps(0); @@ -28258,7 +28258,7 @@ mal_uint64 mal_src_read_deinterleaved__sinc(mal_src* pSRC, mal_uint64 frameCount } else #endif -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) if (pSRC->useSSE2) { __m128 t = _mm_set1_ps((timeIn - iTimeInF)); __m128 r = _mm_set1_ps(0); @@ -28281,7 +28281,7 @@ mal_uint64 mal_src_read_deinterleaved__sinc(mal_src* pSRC, mal_uint64 frameCount } else #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) if (pSRC->useNEON) { float32x4_t t = vmovq_n_f32((timeIn - iTimeInF)); float32x4_t r = vmovq_n_f32(0); @@ -28353,16 +28353,16 @@ mal_uint64 mal_src_read_deinterleaved__sinc(mal_src* pSRC, mal_uint64 frameCount // Read more data from the client if required. if (pSRC->isEndOfInputLoaded) { - pSRC->isEndOfInputLoaded = MAL_FALSE; + pSRC->isEndOfInputLoaded = MA_FALSE; break; } // Everything beyond this point is reloading. If we're at the end of the input data we do _not_ want to try reading any more in this function call. If the // caller wants to keep trying, they can reload their internal data sources and call this function again. We should never be - mal_assert(pSRC->isEndOfInputLoaded == MAL_FALSE); + mal_assert(pSRC->isEndOfInputLoaded == MA_FALSE); if (pSRC->sinc.inputFrameCount <= pSRC->config.sinc.windowWidth || availableOutputFrames == 0) { - float* ppInputDst[MAL_MAX_CHANNELS] = {0}; + float* ppInputDst[MA_MAX_CHANNELS] = {0}; for (mal_uint32 iChannel = 0; iChannel < pSRC->config.channels; iChannel += 1) { ppInputDst[iChannel] = pSRC->sinc.input[iChannel] + pSRC->config.sinc.windowWidth + pSRC->sinc.inputFrameCount; } @@ -28376,9 +28376,9 @@ mal_uint64 mal_src_read_deinterleaved__sinc(mal_src* pSRC, mal_uint64 frameCount } if (framesReadFromClient != framesToReadFromClient) { - pSRC->isEndOfInputLoaded = MAL_TRUE; + pSRC->isEndOfInputLoaded = MA_TRUE; } else { - pSRC->isEndOfInputLoaded = MAL_FALSE; + pSRC->isEndOfInputLoaded = MA_FALSE; } if (framesReadFromClient != 0) { @@ -28610,9 +28610,9 @@ mal_uint32 mal_pcm_converter__post_format_converter_on_read(mal_format_converter mal_assert(pDSP != NULL); // When this version of this callback is used it means we're reading directly from the client. - mal_assert(pDSP->isPreFormatConversionRequired == MAL_FALSE); - mal_assert(pDSP->isChannelRoutingRequired == MAL_FALSE); - mal_assert(pDSP->isSRCRequired == MAL_FALSE); + mal_assert(pDSP->isPreFormatConversionRequired == MA_FALSE); + mal_assert(pDSP->isChannelRoutingRequired == MA_FALSE); + mal_assert(pDSP->isSRCRequired == MA_FALSE); return pDSP->onRead(pDSP, pFramesOut, frameCount, pData->pUserDataForClient); } @@ -28681,7 +28681,7 @@ mal_uint32 mal_pcm_converter__channel_router_on_read_deinterleaved(mal_channel_r mal_result mal_pcm_converter_init(const mal_pcm_converter_config* pConfig, mal_pcm_converter* pDSP) { if (pDSP == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_zero_object(pDSP); @@ -28744,37 +28744,37 @@ mal_result mal_pcm_converter_init(const mal_pcm_converter_config* pConfig, mal_p // First we need to determine what's required and what's not. if (pConfig->sampleRateIn != pConfig->sampleRateOut || pConfig->allowDynamicSampleRate) { - pDSP->isSRCRequired = MAL_TRUE; + pDSP->isSRCRequired = MA_TRUE; } if (pConfig->channelsIn != pConfig->channelsOut || !mal_channel_map_equal(pConfig->channelsIn, pConfig->channelMapIn, pConfig->channelMapOut)) { - pDSP->isChannelRoutingRequired = MAL_TRUE; + pDSP->isChannelRoutingRequired = MA_TRUE; } // If neither a sample rate conversion nor channel conversion is necessary we can skip the pre format conversion. if (!pDSP->isSRCRequired && !pDSP->isChannelRoutingRequired) { // We don't need a pre format conversion stage, but we may still need a post format conversion stage. if (pConfig->formatIn != pConfig->formatOut) { - pDSP->isPostFormatConversionRequired = MAL_TRUE; + pDSP->isPostFormatConversionRequired = MA_TRUE; } } else { - pDSP->isPreFormatConversionRequired = MAL_TRUE; - pDSP->isPostFormatConversionRequired = MAL_TRUE; + pDSP->isPreFormatConversionRequired = MA_TRUE; + pDSP->isPostFormatConversionRequired = MA_TRUE; } // Use a passthrough if none of the stages are being used. if (!pDSP->isPreFormatConversionRequired && !pDSP->isPostFormatConversionRequired && !pDSP->isChannelRoutingRequired && !pDSP->isSRCRequired) { - pDSP->isPassthrough = MAL_TRUE; + pDSP->isPassthrough = MA_TRUE; } // Move the channel conversion stage to the start of the pipeline if we are reducing the channel count. if (pConfig->channelsOut < pConfig->channelsIn) { - pDSP->isChannelRoutingAtStart = MAL_TRUE; + pDSP->isChannelRoutingAtStart = MA_TRUE; } // We always initialize every stage of the pipeline regardless of whether or not the stage is used because it simplifies // a few things when it comes to dynamically changing properties post-initialization. - mal_result result = MAL_SUCCESS; + mal_result result = MA_SUCCESS; // Pre format conversion. { @@ -28792,7 +28792,7 @@ mal_result mal_pcm_converter_init(const mal_pcm_converter_config* pConfig, mal_p preFormatConverterConfig.noNEON = pConfig->noNEON; result = mal_format_converter_init(&preFormatConverterConfig, &pDSP->formatConverterIn); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } @@ -28817,7 +28817,7 @@ mal_result mal_pcm_converter_init(const mal_pcm_converter_config* pConfig, mal_p } result = mal_format_converter_init(&postFormatConverterConfig, &pDSP->formatConverterOut); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } @@ -28840,7 +28840,7 @@ mal_result mal_pcm_converter_init(const mal_pcm_converter_config* pConfig, mal_p mal_copy_memory(&srcConfig.sinc, &pConfig->sinc, sizeof(pConfig->sinc)); result = mal_src_init(&srcConfig, &pDSP->src); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } @@ -28861,12 +28861,12 @@ mal_result mal_pcm_converter_init(const mal_pcm_converter_config* pConfig, mal_p routerConfig.noNEON = pConfig->noNEON; result = mal_channel_router_init(&routerConfig, &pDSP->channelRouter); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -28874,23 +28874,23 @@ mal_result mal_pcm_converter_refresh_sample_rate(mal_pcm_converter* pDSP) { // The SRC stage will already have been initialized so we can just set it there. mal_src_set_sample_rate(&pDSP->src, pDSP->src.config.sampleRateIn, pDSP->src.config.sampleRateOut); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_pcm_converter_set_input_sample_rate(mal_pcm_converter* pDSP, mal_uint32 sampleRateIn) { if (pDSP == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } // Must have a sample rate of > 0. if (sampleRateIn == 0) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } // Must have been initialized with allowDynamicSampleRate. if (!pDSP->isDynamicSampleRateAllowed) { - return MAL_INVALID_OPERATION; + return MA_INVALID_OPERATION; } mal_atomic_exchange_32(&pDSP->src.config.sampleRateIn, sampleRateIn); @@ -28900,17 +28900,17 @@ mal_result mal_pcm_converter_set_input_sample_rate(mal_pcm_converter* pDSP, mal_ mal_result mal_pcm_converter_set_output_sample_rate(mal_pcm_converter* pDSP, mal_uint32 sampleRateOut) { if (pDSP == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } // Must have a sample rate of > 0. if (sampleRateOut == 0) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } // Must have been initialized with allowDynamicSampleRate. if (!pDSP->isDynamicSampleRateAllowed) { - return MAL_INVALID_OPERATION; + return MA_INVALID_OPERATION; } mal_atomic_exchange_32(&pDSP->src.config.sampleRateOut, sampleRateOut); @@ -28920,17 +28920,17 @@ mal_result mal_pcm_converter_set_output_sample_rate(mal_pcm_converter* pDSP, mal mal_result mal_pcm_converter_set_sample_rate(mal_pcm_converter* pDSP, mal_uint32 sampleRateIn, mal_uint32 sampleRateOut) { if (pDSP == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } // Must have a sample rate of > 0. if (sampleRateIn == 0 || sampleRateOut == 0) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } // Must have been initialized with allowDynamicSampleRate. if (!pDSP->isDynamicSampleRateAllowed) { - return MAL_INVALID_OPERATION; + return MA_INVALID_OPERATION; } mal_atomic_exchange_32(&pDSP->src.config.sampleRateIn, sampleRateIn); @@ -28974,7 +28974,7 @@ mal_uint64 mal_pcm_converter_read(mal_pcm_converter* pDSP, void* pFramesOut, mal } // Slower path. The real work is done here. To do this all we need to do is read from the last stage in the pipeline. - mal_assert(pDSP->isPostFormatConversionRequired == MAL_TRUE); + mal_assert(pDSP->isPostFormatConversionRequired == MA_TRUE); mal_pcm_converter_callback_data data; data.pDSP = pDSP; @@ -29032,7 +29032,7 @@ mal_pcm_converter_config mal_pcm_converter_config_init(mal_format formatIn, mal_ return mal_pcm_converter_config_init_ex(formatIn, channelsIn, sampleRateIn, NULL, formatOut, channelsOut, sampleRateOut, NULL, onRead, pUserData); } -mal_pcm_converter_config mal_pcm_converter_config_init_ex(mal_format formatIn, mal_uint32 channelsIn, mal_uint32 sampleRateIn, mal_channel channelMapIn[MAL_MAX_CHANNELS], mal_format formatOut, mal_uint32 channelsOut, mal_uint32 sampleRateOut, mal_channel channelMapOut[MAL_MAX_CHANNELS], mal_pcm_converter_read_proc onRead, void* pUserData) +mal_pcm_converter_config mal_pcm_converter_config_init_ex(mal_format formatIn, mal_uint32 channelsIn, mal_uint32 sampleRateIn, mal_channel channelMapIn[MA_MAX_CHANNELS], mal_format formatOut, mal_uint32 channelsOut, mal_uint32 sampleRateOut, mal_channel channelMapOut[MA_MAX_CHANNELS], mal_pcm_converter_read_proc onRead, void* pUserData) { mal_pcm_converter_config config; mal_zero_object(&config); @@ -29058,16 +29058,16 @@ mal_pcm_converter_config mal_pcm_converter_config_init_ex(mal_format formatIn, m mal_uint64 mal_convert_frames(void* pOut, mal_format formatOut, mal_uint32 channelsOut, mal_uint32 sampleRateOut, const void* pIn, mal_format formatIn, mal_uint32 channelsIn, mal_uint32 sampleRateIn, mal_uint64 frameCount) { - mal_channel channelMapOut[MAL_MAX_CHANNELS]; + mal_channel channelMapOut[MA_MAX_CHANNELS]; mal_get_standard_channel_map(mal_standard_channel_map_default, channelsOut, channelMapOut); - mal_channel channelMapIn[MAL_MAX_CHANNELS]; + mal_channel channelMapIn[MA_MAX_CHANNELS]; mal_get_standard_channel_map(mal_standard_channel_map_default, channelsIn, channelMapIn); return mal_convert_frames_ex(pOut, formatOut, channelsOut, sampleRateOut, channelMapOut, pIn, formatIn, channelsIn, sampleRateIn, channelMapIn, frameCount); } -mal_uint64 mal_convert_frames_ex(void* pOut, mal_format formatOut, mal_uint32 channelsOut, mal_uint32 sampleRateOut, mal_channel channelMapOut[MAL_MAX_CHANNELS], const void* pIn, mal_format formatIn, mal_uint32 channelsIn, mal_uint32 sampleRateIn, mal_channel channelMapIn[MAL_MAX_CHANNELS], mal_uint64 frameCount) +mal_uint64 mal_convert_frames_ex(void* pOut, mal_format formatOut, mal_uint32 channelsOut, mal_uint32 sampleRateOut, mal_channel channelMapOut[MA_MAX_CHANNELS], const void* pIn, mal_format formatIn, mal_uint32 channelsIn, mal_uint32 sampleRateIn, mal_channel channelMapIn[MA_MAX_CHANNELS], mal_uint64 frameCount) { if (frameCount == 0) { return 0; @@ -29084,7 +29084,7 @@ mal_uint64 mal_convert_frames_ex(void* pOut, mal_format formatOut, mal_uint32 ch data.channelsIn = channelsIn; data.totalFrameCount = frameCount; data.iNextFrame = 0; - data.isFeedingZeros = MAL_FALSE; + data.isFeedingZeros = MA_FALSE; mal_pcm_converter_config config; mal_zero_object(&config); @@ -29111,7 +29111,7 @@ mal_uint64 mal_convert_frames_ex(void* pOut, mal_format formatOut, mal_uint32 ch config.pUserData = &data; mal_pcm_converter dsp; - if (mal_pcm_converter_init(&config, &dsp) != MAL_SUCCESS) { + if (mal_pcm_converter_init(&config, &dsp) != MA_SUCCESS) { return 0; } @@ -29122,7 +29122,7 @@ mal_uint64 mal_convert_frames_ex(void* pOut, mal_format formatOut, mal_uint32 ch if (totalFramesRead < frameCountOut) { mal_uint32 bpf = mal_get_bytes_per_frame(formatIn, channelsIn); - data.isFeedingZeros = MAL_TRUE; + data.isFeedingZeros = MA_TRUE; data.totalFrameCount = 0xFFFFFFFFFFFFFFFF; data.pDataIn = NULL; @@ -29157,34 +29157,34 @@ mal_uint64 mal_convert_frames_ex(void* pOut, mal_format formatOut, mal_uint32 ch // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -MAL_INLINE mal_uint32 mal_rb__extract_offset_in_bytes(mal_uint32 encodedOffset) +MA_INLINE mal_uint32 mal_rb__extract_offset_in_bytes(mal_uint32 encodedOffset) { return encodedOffset & 0x7FFFFFFF; } -MAL_INLINE mal_uint32 mal_rb__extract_offset_loop_flag(mal_uint32 encodedOffset) +MA_INLINE mal_uint32 mal_rb__extract_offset_loop_flag(mal_uint32 encodedOffset) { return encodedOffset & 0x80000000; } -MAL_INLINE void* mal_rb__get_read_ptr(mal_rb* pRB) +MA_INLINE void* mal_rb__get_read_ptr(mal_rb* pRB) { mal_assert(pRB != NULL); return mal_offset_ptr(pRB->pBuffer, mal_rb__extract_offset_in_bytes(pRB->encodedReadOffset)); } -MAL_INLINE void* mal_rb__get_write_ptr(mal_rb* pRB) +MA_INLINE void* mal_rb__get_write_ptr(mal_rb* pRB) { mal_assert(pRB != NULL); return mal_offset_ptr(pRB->pBuffer, mal_rb__extract_offset_in_bytes(pRB->encodedWriteOffset)); } -MAL_INLINE mal_uint32 mal_rb__construct_offset(mal_uint32 offsetInBytes, mal_uint32 offsetLoopFlag) +MA_INLINE mal_uint32 mal_rb__construct_offset(mal_uint32 offsetInBytes, mal_uint32 offsetLoopFlag) { return offsetLoopFlag | offsetInBytes; } -MAL_INLINE void mal_rb__deconstruct_offset(mal_uint32 encodedOffset, mal_uint32* pOffsetInBytes, mal_uint32* pOffsetLoopFlag) +MA_INLINE void mal_rb__deconstruct_offset(mal_uint32 encodedOffset, mal_uint32* pOffsetInBytes, mal_uint32* pOffsetLoopFlag) { mal_assert(pOffsetInBytes != NULL); mal_assert(pOffsetLoopFlag != NULL); @@ -29197,16 +29197,16 @@ MAL_INLINE void mal_rb__deconstruct_offset(mal_uint32 encodedOffset, mal_uint32* mal_result mal_rb_init_ex(size_t subbufferSizeInBytes, size_t subbufferCount, size_t subbufferStrideInBytes, void* pOptionalPreallocatedBuffer, mal_rb* pRB) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } if (subbufferSizeInBytes == 0 || subbufferCount == 0) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } - const mal_uint32 maxSubBufferSize = 0x7FFFFFFF - (MAL_SIMD_ALIGNMENT-1); + const mal_uint32 maxSubBufferSize = 0x7FFFFFFF - (MA_SIMD_ALIGNMENT-1); if (subbufferSizeInBytes > maxSubBufferSize) { - return MAL_INVALID_ARGS; // Maximum buffer size is ~2GB. The most significant bit is a flag for use internally. + return MA_INVALID_ARGS; // Maximum buffer size is ~2GB. The most significant bit is a flag for use internally. } @@ -29218,21 +29218,21 @@ mal_result mal_rb_init_ex(size_t subbufferSizeInBytes, size_t subbufferCount, si pRB->subbufferStrideInBytes = (mal_uint32)subbufferStrideInBytes; pRB->pBuffer = pOptionalPreallocatedBuffer; } else { - // Here is where we allocate our own buffer. We always want to align this to MAL_SIMD_ALIGNMENT for future SIMD optimization opportunity. To do this - // we need to make sure the stride is a multiple of MAL_SIMD_ALIGNMENT. - pRB->subbufferStrideInBytes = (pRB->subbufferSizeInBytes + (MAL_SIMD_ALIGNMENT-1)) & ~MAL_SIMD_ALIGNMENT; + // Here is where we allocate our own buffer. We always want to align this to MA_SIMD_ALIGNMENT for future SIMD optimization opportunity. To do this + // we need to make sure the stride is a multiple of MA_SIMD_ALIGNMENT. + pRB->subbufferStrideInBytes = (pRB->subbufferSizeInBytes + (MA_SIMD_ALIGNMENT-1)) & ~MA_SIMD_ALIGNMENT; size_t bufferSizeInBytes = (size_t)pRB->subbufferCount*pRB->subbufferStrideInBytes; - pRB->pBuffer = mal_aligned_malloc(bufferSizeInBytes, MAL_SIMD_ALIGNMENT); + pRB->pBuffer = mal_aligned_malloc(bufferSizeInBytes, MA_SIMD_ALIGNMENT); if (pRB->pBuffer == NULL) { - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } mal_zero_memory(pRB->pBuffer, bufferSizeInBytes); - pRB->ownsBuffer = MAL_TRUE; + pRB->ownsBuffer = MA_TRUE; } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_rb_init(size_t bufferSizeInBytes, void* pOptionalPreallocatedBuffer, mal_rb* pRB) @@ -29254,7 +29254,7 @@ void mal_rb_uninit(mal_rb* pRB) mal_result mal_rb_acquire_read(mal_rb* pRB, size_t* pSizeInBytes, void** ppBufferOut) { if (pRB == NULL || pSizeInBytes == NULL || ppBufferOut == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } // The returned buffer should never move ahead of the write pointer. @@ -29285,18 +29285,18 @@ mal_result mal_rb_acquire_read(mal_rb* pRB, size_t* pSizeInBytes, void** ppBuffe *pSizeInBytes = bytesRequested; (*ppBufferOut) = mal_rb__get_read_ptr(pRB); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_rb_commit_read(mal_rb* pRB, size_t sizeInBytes, void* pBufferOut) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } // Validate the buffer. if (pBufferOut != mal_rb__get_read_ptr(pRB)) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_uint32 readOffset = pRB->encodedReadOffset; @@ -29307,7 +29307,7 @@ mal_result mal_rb_commit_read(mal_rb* pRB, size_t sizeInBytes, void* pBufferOut) // Check that sizeInBytes is correct. It should never go beyond the end of the buffer. mal_uint32 newReadOffsetInBytes = (mal_uint32)(readOffsetInBytes + sizeInBytes); if (newReadOffsetInBytes > pRB->subbufferSizeInBytes) { - return MAL_INVALID_ARGS; // <-- sizeInBytes will cause the read offset to overflow. + return MA_INVALID_ARGS; // <-- sizeInBytes will cause the read offset to overflow. } // Move the read pointer back to the start if necessary. @@ -29318,13 +29318,13 @@ mal_result mal_rb_commit_read(mal_rb* pRB, size_t sizeInBytes, void* pBufferOut) } mal_atomic_exchange_32(&pRB->encodedReadOffset, mal_rb__construct_offset(newReadOffsetLoopFlag, newReadOffsetInBytes)); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_rb_acquire_write(mal_rb* pRB, size_t* pSizeInBytes, void** ppBufferOut) { if (pRB == NULL || pSizeInBytes == NULL || ppBufferOut == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } // The returned buffer should never overtake the read buffer. @@ -29361,18 +29361,18 @@ mal_result mal_rb_acquire_write(mal_rb* pRB, size_t* pSizeInBytes, void** ppBuff mal_zero_memory(*ppBufferOut, *pSizeInBytes); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_rb_commit_write(mal_rb* pRB, size_t sizeInBytes, void* pBufferOut) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } // Validate the buffer. if (pBufferOut != mal_rb__get_write_ptr(pRB)) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_uint32 writeOffset = pRB->encodedWriteOffset; @@ -29383,7 +29383,7 @@ mal_result mal_rb_commit_write(mal_rb* pRB, size_t sizeInBytes, void* pBufferOut // Check that sizeInBytes is correct. It should never go beyond the end of the buffer. mal_uint32 newWriteOffsetInBytes = (mal_uint32)(writeOffsetInBytes + sizeInBytes); if (newWriteOffsetInBytes > pRB->subbufferSizeInBytes) { - return MAL_INVALID_ARGS; // <-- sizeInBytes will cause the read offset to overflow. + return MA_INVALID_ARGS; // <-- sizeInBytes will cause the read offset to overflow. } // Move the read pointer back to the start if necessary. @@ -29394,13 +29394,13 @@ mal_result mal_rb_commit_write(mal_rb* pRB, size_t sizeInBytes, void* pBufferOut } mal_atomic_exchange_32(&pRB->encodedWriteOffset, mal_rb__construct_offset(newWriteOffsetLoopFlag, newWriteOffsetInBytes)); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_rb_seek_read(mal_rb* pRB, size_t offsetInBytes) { if (pRB == NULL || offsetInBytes > pRB->subbufferSizeInBytes) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_uint32 readOffset = pRB->encodedReadOffset; @@ -29434,13 +29434,13 @@ mal_result mal_rb_seek_read(mal_rb* pRB, size_t offsetInBytes) } mal_atomic_exchange_32(&pRB->encodedReadOffset, mal_rb__construct_offset(newReadOffsetInBytes, newReadOffsetLoopFlag)); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_rb_seek_write(mal_rb* pRB, size_t offsetInBytes) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_uint32 readOffset = pRB->encodedReadOffset; @@ -29474,7 +29474,7 @@ mal_result mal_rb_seek_write(mal_rb* pRB, size_t offsetInBytes) } mal_atomic_exchange_32(&pRB->encodedWriteOffset, mal_rb__construct_offset(newWriteOffsetInBytes, newWriteOffsetLoopFlag)); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_int32 mal_rb_pointer_distance(mal_rb* pRB) @@ -29541,7 +29541,7 @@ void* mal_rb_get_subbuffer_ptr(mal_rb* pRB, size_t subbufferIndex, void* pBuffer } -static MAL_INLINE mal_uint32 mal_pcm_rb_get_bpf(mal_pcm_rb* pRB) +static MA_INLINE mal_uint32 mal_pcm_rb_get_bpf(mal_pcm_rb* pRB) { mal_assert(pRB != NULL); @@ -29551,25 +29551,25 @@ static MAL_INLINE mal_uint32 mal_pcm_rb_get_bpf(mal_pcm_rb* pRB) mal_result mal_pcm_rb_init_ex(mal_format format, mal_uint32 channels, mal_uint32 subbufferSizeInFrames, mal_uint32 subbufferCount, mal_uint32 subbufferStrideInFrames, void* pOptionalPreallocatedBuffer, mal_pcm_rb* pRB) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_zero_object(pRB); mal_uint32 bpf = mal_get_bytes_per_frame(format, channels); if (bpf == 0) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_result result = mal_rb_init_ex(subbufferSizeInFrames*bpf, subbufferCount, subbufferStrideInFrames*bpf, pOptionalPreallocatedBuffer, &pRB->rb); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } pRB->format = format; pRB->channels = channels; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_pcm_rb_init(mal_format format, mal_uint32 channels, mal_uint32 bufferSizeInFrames, void* pOptionalPreallocatedBuffer, mal_pcm_rb* pRB) @@ -29592,24 +29592,24 @@ mal_result mal_pcm_rb_acquire_read(mal_pcm_rb* pRB, mal_uint32* pSizeInFrames, v mal_result result; if (pRB == NULL || pSizeInFrames == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } sizeInBytes = *pSizeInFrames * mal_pcm_rb_get_bpf(pRB); result = mal_rb_acquire_read(&pRB->rb, &sizeInBytes, ppBufferOut); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } *pSizeInFrames = (mal_uint32)(sizeInBytes / (size_t)mal_pcm_rb_get_bpf(pRB)); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_pcm_rb_commit_read(mal_pcm_rb* pRB, mal_uint32 sizeInFrames, void* pBufferOut) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } return mal_rb_commit_read(&pRB->rb, sizeInFrames * mal_pcm_rb_get_bpf(pRB), pBufferOut); @@ -29621,24 +29621,24 @@ mal_result mal_pcm_rb_acquire_write(mal_pcm_rb* pRB, mal_uint32* pSizeInFrames, mal_result result; if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } sizeInBytes = *pSizeInFrames * mal_pcm_rb_get_bpf(pRB); result = mal_rb_acquire_write(&pRB->rb, &sizeInBytes, ppBufferOut); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } *pSizeInFrames = (mal_uint32)(sizeInBytes / mal_pcm_rb_get_bpf(pRB)); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_pcm_rb_commit_write(mal_pcm_rb* pRB, mal_uint32 sizeInFrames, void* pBufferOut) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } return mal_rb_commit_write(&pRB->rb, sizeInFrames * mal_pcm_rb_get_bpf(pRB), pBufferOut); @@ -29647,7 +29647,7 @@ mal_result mal_pcm_rb_commit_write(mal_pcm_rb* pRB, mal_uint32 sizeInFrames, voi mal_result mal_pcm_rb_seek_read(mal_pcm_rb* pRB, mal_uint32 offsetInFrames) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } return mal_rb_seek_read(&pRB->rb, offsetInFrames * mal_pcm_rb_get_bpf(pRB)); @@ -29656,7 +29656,7 @@ mal_result mal_pcm_rb_seek_read(mal_pcm_rb* pRB, mal_uint32 offsetInFrames) mal_result mal_pcm_rb_seek_write(mal_pcm_rb* pRB, mal_uint32 offsetInFrames) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } return mal_rb_seek_write(&pRB->rb, offsetInFrames * mal_pcm_rb_get_bpf(pRB)); @@ -29665,7 +29665,7 @@ mal_result mal_pcm_rb_seek_write(mal_pcm_rb* pRB, mal_uint32 offsetInFrames) mal_int32 mal_pcm_rb_pointer_disance(mal_pcm_rb* pRB) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } return mal_rb_pointer_distance(&pRB->rb) / mal_pcm_rb_get_bpf(pRB); @@ -29719,17 +29719,17 @@ void* mal_pcm_rb_get_subbuffer_ptr(mal_pcm_rb* pRB, mal_uint32 subbufferIndex, v void* mal_malloc(size_t sz) { - return MAL_MALLOC(sz); + return MA_MALLOC(sz); } void* mal_realloc(void* p, size_t sz) { - return MAL_REALLOC(p, sz); + return MA_REALLOC(p, sz); } void mal_free(void* p) { - MAL_FREE(p); + MA_FREE(p); } void* mal_aligned_malloc(size_t sz, size_t alignment) @@ -29799,7 +29799,7 @@ mal_uint32 mal_get_bytes_per_sample(mal_format format) // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#ifndef MAL_NO_DECODING +#ifndef MA_NO_DECODING mal_decoder_config mal_decoder_config_init(mal_format outputFormat, mal_uint32 outputChannels, mal_uint32 outputSampleRate) { @@ -29870,7 +29870,7 @@ mal_result mal_decoder__init_dsp(mal_decoder* pDecoder, const mal_decoder_config // WAV #ifdef dr_wav_h -#define MAL_HAS_WAV +#define MA_HAS_WAV size_t mal_decoder_internal_on_read__wav(void* pUserData, void* pBufferOut, size_t bytesToRead) { @@ -29908,7 +29908,7 @@ mal_uint32 mal_decoder_internal_on_read_pcm_frames__wav(mal_pcm_converter* pDSP, } // Should never get here. If we do, it means the internal format was not set correctly at initialization time. - mal_assert(MAL_FALSE); + mal_assert(MA_FALSE); return 0; } @@ -29919,16 +29919,16 @@ mal_result mal_decoder_internal_on_seek_to_pcm_frame__wav(mal_decoder* pDecoder, drwav_bool32 result = drwav_seek_to_pcm_frame(pWav, frameIndex); if (result) { - return MAL_SUCCESS; + return MA_SUCCESS; } else { - return MAL_ERROR; + return MA_ERROR; } } mal_result mal_decoder_internal_on_uninit__wav(mal_decoder* pDecoder) { drwav_close((drwav*)pDecoder->pInternalDecoder); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_decoder_init_wav__internal(const mal_decoder_config* pConfig, mal_decoder* pDecoder) @@ -29939,7 +29939,7 @@ mal_result mal_decoder_init_wav__internal(const mal_decoder_config* pConfig, mal // Try opening the decoder first. drwav* pWav = drwav_open(mal_decoder_internal_on_read__wav, mal_decoder_internal_on_seek__wav, pDecoder); if (pWav == NULL) { - return MAL_ERROR; + return MA_ERROR; } // If we get here it means we successfully initialized the WAV decoder. We can now initialize the rest of the mal_decoder. @@ -29986,18 +29986,18 @@ mal_result mal_decoder_init_wav__internal(const mal_decoder_config* pConfig, mal mal_get_standard_channel_map(mal_standard_channel_map_microsoft, pDecoder->internalChannels, pDecoder->internalChannelMap); mal_result result = mal_decoder__init_dsp(pDecoder, pConfig, mal_decoder_internal_on_read_pcm_frames__wav); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { drwav_close(pWav); return result; } - return MAL_SUCCESS; + return MA_SUCCESS; } #endif // FLAC #ifdef dr_flac_h -#define MAL_HAS_FLAC +#define MA_HAS_FLAC size_t mal_decoder_internal_on_read__flac(void* pUserData, void* pBufferOut, size_t bytesToRead) { @@ -30035,7 +30035,7 @@ mal_uint32 mal_decoder_internal_on_read_pcm_frames__flac(mal_pcm_converter* pDSP } // Should never get here. If we do, it means the internal format was not set correctly at initialization time. - mal_assert(MAL_FALSE); + mal_assert(MA_FALSE); return 0; } @@ -30046,16 +30046,16 @@ mal_result mal_decoder_internal_on_seek_to_pcm_frame__flac(mal_decoder* pDecoder drflac_bool32 result = drflac_seek_to_pcm_frame(pFlac, frameIndex); if (result) { - return MAL_SUCCESS; + return MA_SUCCESS; } else { - return MAL_ERROR; + return MA_ERROR; } } mal_result mal_decoder_internal_on_uninit__flac(mal_decoder* pDecoder) { drflac_close((drflac*)pDecoder->pInternalDecoder); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_decoder_init_flac__internal(const mal_decoder_config* pConfig, mal_decoder* pDecoder) @@ -30066,7 +30066,7 @@ mal_result mal_decoder_init_flac__internal(const mal_decoder_config* pConfig, ma // Try opening the decoder first. drflac* pFlac = drflac_open(mal_decoder_internal_on_read__flac, mal_decoder_internal_on_seek__flac, pDecoder); if (pFlac == NULL) { - return MAL_ERROR; + return MA_ERROR; } // If we get here it means we successfully initialized the FLAC decoder. We can now initialize the rest of the mal_decoder. @@ -30088,21 +30088,21 @@ mal_result mal_decoder_init_flac__internal(const mal_decoder_config* pConfig, ma mal_get_standard_channel_map(mal_standard_channel_map_flac, pDecoder->internalChannels, pDecoder->internalChannelMap); mal_result result = mal_decoder__init_dsp(pDecoder, pConfig, mal_decoder_internal_on_read_pcm_frames__flac); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { drflac_close(pFlac); return result; } - return MAL_SUCCESS; + return MA_SUCCESS; } #endif // Vorbis #ifdef STB_VORBIS_INCLUDE_STB_VORBIS_H -#define MAL_HAS_VORBIS +#define MA_HAS_VORBIS // The size in bytes of each chunk of data to read from the Vorbis stream. -#define MAL_VORBIS_DATA_CHUNK_SIZE 4096 +#define MA_VORBIS_DATA_CHUNK_SIZE 4096 typedef struct { @@ -30168,7 +30168,7 @@ mal_uint32 mal_vorbis_decoder_read_pcm_frames(mal_vorbis_decoder* pVorbis, mal_d // Need more data. If there's any room in the existing buffer allocation fill that first. Otherwise expand. if (pVorbis->dataCapacity == pVorbis->dataSize) { // No room. Expand. - pVorbis->dataCapacity += MAL_VORBIS_DATA_CHUNK_SIZE; + pVorbis->dataCapacity += MA_VORBIS_DATA_CHUNK_SIZE; mal_uint8* pNewData = (mal_uint8*)mal_realloc(pVorbis->pData, pVorbis->dataCapacity); if (pNewData == NULL) { return totalFramesRead; // Out of memory. @@ -30185,7 +30185,7 @@ mal_uint32 mal_vorbis_decoder_read_pcm_frames(mal_vorbis_decoder* pVorbis, mal_d pVorbis->dataSize += bytesRead; } - } while (MAL_TRUE); + } while (MA_TRUE); } return totalFramesRead; @@ -30202,7 +30202,7 @@ mal_result mal_vorbis_decoder_seek_to_pcm_frame(mal_vorbis_decoder* pVorbis, mal // a full decode right from the start of the stream. Later on I'll need to write a layer that goes through all of the Ogg pages until we // find the one containing the sample we need. Then we know exactly where to seek for stb_vorbis. if (!pDecoder->onSeek(pDecoder, 0, mal_seek_origin_start)) { - return MAL_ERROR; + return MA_ERROR; } stb_vorbis_flush_pushdata(pVorbis->pInternalVorbis); @@ -30219,13 +30219,13 @@ mal_result mal_vorbis_decoder_seek_to_pcm_frame(mal_vorbis_decoder* pVorbis, mal mal_uint32 framesRead = mal_vorbis_decoder_read_pcm_frames(pVorbis, pDecoder, buffer, framesToRead); if (framesRead == 0) { - return MAL_ERROR; + return MA_ERROR; } frameIndex -= framesRead; } - return MAL_SUCCESS; + return MA_SUCCESS; } @@ -30250,7 +30250,7 @@ mal_result mal_decoder_internal_on_uninit__vorbis(mal_decoder* pDecoder) mal_free(pVorbis->pData); mal_free(pVorbis); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_uint32 mal_decoder_internal_on_read_pcm_frames__vorbis(mal_pcm_converter* pDSP, void* pSamplesOut, mal_uint32 frameCount, void* pUserData) @@ -30285,11 +30285,11 @@ mal_result mal_decoder_init_vorbis__internal(const mal_decoder_config* pConfig, do { // Allocate memory for a new chunk. - dataCapacity += MAL_VORBIS_DATA_CHUNK_SIZE; + dataCapacity += MA_VORBIS_DATA_CHUNK_SIZE; mal_uint8* pNewData = (mal_uint8*)mal_realloc(pData, dataCapacity); if (pNewData == NULL) { mal_free(pData); - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } pData = pNewData; @@ -30297,12 +30297,12 @@ mal_result mal_decoder_init_vorbis__internal(const mal_decoder_config* pConfig, // Fill in a chunk. size_t bytesRead = pDecoder->onRead(pDecoder, pData + dataSize, (dataCapacity - dataSize)); if (bytesRead == 0) { - return MAL_ERROR; + return MA_ERROR; } dataSize += bytesRead; if (dataSize > INT_MAX) { - return MAL_ERROR; // Too big. + return MA_ERROR; // Too big. } int vorbisError = 0; @@ -30322,20 +30322,20 @@ mal_result mal_decoder_init_vorbis__internal(const mal_decoder_config* pConfig, if (vorbisError == VORBIS_need_more_data) { continue; } else { - return MAL_ERROR; // Failed to open the stb_vorbis decoder. + return MA_ERROR; // Failed to open the stb_vorbis decoder. } } - } while (MAL_TRUE); + } while (MA_TRUE); // If we get here it means we successfully opened the Vorbis decoder. stb_vorbis_info vorbisInfo = stb_vorbis_get_info(pInternalVorbis); - // Don't allow more than MAL_MAX_CHANNELS channels. - if (vorbisInfo.channels > MAL_MAX_CHANNELS) { + // Don't allow more than MA_MAX_CHANNELS channels. + if (vorbisInfo.channels > MA_MAX_CHANNELS) { stb_vorbis_close(pInternalVorbis); mal_free(pData); - return MAL_ERROR; // Too many channels. + return MA_ERROR; // Too many channels. } size_t vorbisDataSize = sizeof(mal_vorbis_decoder) + sizeof(float)*vorbisInfo.max_frame_size; @@ -30343,7 +30343,7 @@ mal_result mal_decoder_init_vorbis__internal(const mal_decoder_config* pConfig, if (pVorbis == NULL) { stb_vorbis_close(pInternalVorbis); mal_free(pData); - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } mal_zero_memory(pVorbis, vorbisDataSize); @@ -30363,20 +30363,20 @@ mal_result mal_decoder_init_vorbis__internal(const mal_decoder_config* pConfig, mal_get_standard_channel_map(mal_standard_channel_map_vorbis, pDecoder->internalChannels, pDecoder->internalChannelMap); mal_result result = mal_decoder__init_dsp(pDecoder, pConfig, mal_decoder_internal_on_read_pcm_frames__vorbis); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { stb_vorbis_close(pVorbis->pInternalVorbis); mal_free(pVorbis->pData); mal_free(pVorbis); return result; } - return MAL_SUCCESS; + return MA_SUCCESS; } #endif // MP3 #ifdef dr_mp3_h -#define MAL_HAS_MP3 +#define MA_HAS_MP3 size_t mal_decoder_internal_on_read__mp3(void* pUserData, void* pBufferOut, size_t bytesToRead) { @@ -30417,9 +30417,9 @@ mal_result mal_decoder_internal_on_seek_to_pcm_frame__mp3(mal_decoder* pDecoder, drmp3_bool32 result = drmp3_seek_to_pcm_frame(pMP3, frameIndex); if (result) { - return MAL_SUCCESS; + return MA_SUCCESS; } else { - return MAL_ERROR; + return MA_ERROR; } } @@ -30427,7 +30427,7 @@ mal_result mal_decoder_internal_on_uninit__mp3(mal_decoder* pDecoder) { drmp3_uninit((drmp3*)pDecoder->pInternalDecoder); mal_free(pDecoder->pInternalDecoder); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_decoder_init_mp3__internal(const mal_decoder_config* pConfig, mal_decoder* pDecoder) @@ -30437,7 +30437,7 @@ mal_result mal_decoder_init_mp3__internal(const mal_decoder_config* pConfig, mal drmp3* pMP3 = (drmp3*)mal_malloc(sizeof(*pMP3)); if (pMP3 == NULL) { - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } // Try opening the decoder first. MP3 can have variable sample rates (it's per frame/packet). We therefore need @@ -30454,7 +30454,7 @@ mal_result mal_decoder_init_mp3__internal(const mal_decoder_config* pConfig, mal mp3Config.outputChannels = 2; mp3Config.outputSampleRate = (pConfig->sampleRate != 0) ? pConfig->sampleRate : 44100; if (!drmp3_init(pMP3, mal_decoder_internal_on_read__mp3, mal_decoder_internal_on_seek__mp3, pDecoder, &mp3Config)) { - return MAL_ERROR; + return MA_ERROR; } // If we get here it means we successfully initialized the MP3 decoder. We can now initialize the rest of the mal_decoder. @@ -30469,12 +30469,12 @@ mal_result mal_decoder_init_mp3__internal(const mal_decoder_config* pConfig, mal mal_get_standard_channel_map(mal_standard_channel_map_default, pDecoder->internalChannels, pDecoder->internalChannelMap); mal_result result = mal_decoder__init_dsp(pDecoder, pConfig, mal_decoder_internal_on_read_pcm_frames__mp3); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { mal_free(pMP3); return result; } - return MAL_SUCCESS; + return MA_SUCCESS; } #endif @@ -30496,10 +30496,10 @@ mal_result mal_decoder_internal_on_seek_to_pcm_frame__raw(mal_decoder* pDecoder, mal_assert(pDecoder != NULL); if (pDecoder->onSeek == NULL) { - return MAL_ERROR; + return MA_ERROR; } - mal_bool32 result = MAL_FALSE; + mal_bool32 result = MA_FALSE; // The callback uses a 32 bit integer whereas we use a 64 bit unsigned integer. We just need to continuously seek until we're at the correct position. mal_uint64 totalBytesToSeek = frameIndex * mal_get_bytes_per_frame(pDecoder->internalFormat, pDecoder->internalChannels); @@ -30509,7 +30509,7 @@ mal_result mal_decoder_internal_on_seek_to_pcm_frame__raw(mal_decoder* pDecoder, } else { // Complex case. Start by doing a seek relative to the start. Then keep looping using offset seeking. result = pDecoder->onSeek(pDecoder, 0x7FFFFFFF, mal_seek_origin_start); - if (result == MAL_TRUE) { + if (result == MA_TRUE) { totalBytesToSeek -= 0x7FFFFFFF; while (totalBytesToSeek > 0) { @@ -30519,7 +30519,7 @@ mal_result mal_decoder_internal_on_seek_to_pcm_frame__raw(mal_decoder* pDecoder, } result = pDecoder->onSeek(pDecoder, (int)bytesToSeekThisIteration, mal_seek_origin_current); - if (result != MAL_TRUE) { + if (result != MA_TRUE) { break; } @@ -30529,16 +30529,16 @@ mal_result mal_decoder_internal_on_seek_to_pcm_frame__raw(mal_decoder* pDecoder, } if (result) { - return MAL_SUCCESS; + return MA_SUCCESS; } else { - return MAL_ERROR; + return MA_ERROR; } } mal_result mal_decoder_internal_on_uninit__raw(mal_decoder* pDecoder) { (void)pDecoder; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_decoder_init_raw__internal(const mal_decoder_config* pConfigIn, const mal_decoder_config* pConfigOut, mal_decoder* pDecoder) @@ -30557,11 +30557,11 @@ mal_result mal_decoder_init_raw__internal(const mal_decoder_config* pConfigIn, c mal_channel_map_copy(pDecoder->internalChannelMap, pConfigIn->channelMap, pConfigIn->channels); mal_result result = mal_decoder__init_dsp(pDecoder, pConfigOut, mal_decoder_internal_on_read_pcm_frames__raw); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_decoder__preinit(mal_decoder_read_proc onRead, mal_decoder_seek_proc onSeek, void* pUserData, const mal_decoder_config* pConfig, mal_decoder* pDecoder) @@ -30569,13 +30569,13 @@ mal_result mal_decoder__preinit(mal_decoder_read_proc onRead, mal_decoder_seek_p mal_assert(pConfig != NULL); if (pDecoder == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_zero_object(pDecoder); if (onRead == NULL || onSeek == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } pDecoder->onRead = onRead; @@ -30583,7 +30583,7 @@ mal_result mal_decoder__preinit(mal_decoder_read_proc onRead, mal_decoder_seek_p pDecoder->pUserData = pUserData; (void)pConfig; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_decoder_init_wav(mal_decoder_read_proc onRead, mal_decoder_seek_proc onSeek, void* pUserData, const mal_decoder_config* pConfig, mal_decoder* pDecoder) @@ -30591,14 +30591,14 @@ mal_result mal_decoder_init_wav(mal_decoder_read_proc onRead, mal_decoder_seek_p mal_decoder_config config = mal_decoder_config_init_copy(pConfig); mal_result result = mal_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } -#ifdef MAL_HAS_WAV +#ifdef MA_HAS_WAV return mal_decoder_init_wav__internal(&config, pDecoder); #else - return MAL_NO_BACKEND; + return MA_NO_BACKEND; #endif } @@ -30607,14 +30607,14 @@ mal_result mal_decoder_init_flac(mal_decoder_read_proc onRead, mal_decoder_seek_ mal_decoder_config config = mal_decoder_config_init_copy(pConfig); mal_result result = mal_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } -#ifdef MAL_HAS_FLAC +#ifdef MA_HAS_FLAC return mal_decoder_init_flac__internal(&config, pDecoder); #else - return MAL_NO_BACKEND; + return MA_NO_BACKEND; #endif } @@ -30623,14 +30623,14 @@ mal_result mal_decoder_init_vorbis(mal_decoder_read_proc onRead, mal_decoder_see mal_decoder_config config = mal_decoder_config_init_copy(pConfig); mal_result result = mal_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } -#ifdef MAL_HAS_VORBIS +#ifdef MA_HAS_VORBIS return mal_decoder_init_vorbis__internal(&config, pDecoder); #else - return MAL_NO_BACKEND; + return MA_NO_BACKEND; #endif } @@ -30639,14 +30639,14 @@ mal_result mal_decoder_init_mp3(mal_decoder_read_proc onRead, mal_decoder_seek_p mal_decoder_config config = mal_decoder_config_init_copy(pConfig); mal_result result = mal_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } -#ifdef MAL_HAS_MP3 +#ifdef MA_HAS_MP3 return mal_decoder_init_mp3__internal(&config, pDecoder); #else - return MAL_NO_BACKEND; + return MA_NO_BACKEND; #endif } @@ -30655,7 +30655,7 @@ mal_result mal_decoder_init_raw(mal_decoder_read_proc onRead, mal_decoder_seek_p mal_decoder_config config = mal_decoder_config_init_copy(pConfigOut); mal_result result = mal_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -30675,42 +30675,42 @@ mal_result mal_decoder_init__internal(mal_decoder_read_proc onRead, mal_decoder_ (void)pDecoder; // We use trial and error to open a decoder. - mal_result result = MAL_NO_BACKEND; + mal_result result = MA_NO_BACKEND; -#ifdef MAL_HAS_WAV - if (result != MAL_SUCCESS) { +#ifdef MA_HAS_WAV + if (result != MA_SUCCESS) { result = mal_decoder_init_wav__internal(pConfig, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { onSeek(pDecoder, 0, mal_seek_origin_start); } } #endif -#ifdef MAL_HAS_FLAC - if (result != MAL_SUCCESS) { +#ifdef MA_HAS_FLAC + if (result != MA_SUCCESS) { result = mal_decoder_init_flac__internal(pConfig, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { onSeek(pDecoder, 0, mal_seek_origin_start); } } #endif -#ifdef MAL_HAS_VORBIS - if (result != MAL_SUCCESS) { +#ifdef MA_HAS_VORBIS + if (result != MA_SUCCESS) { result = mal_decoder_init_vorbis__internal(pConfig, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { onSeek(pDecoder, 0, mal_seek_origin_start); } } #endif -#ifdef MAL_HAS_MP3 - if (result != MAL_SUCCESS) { +#ifdef MA_HAS_MP3 + if (result != MA_SUCCESS) { result = mal_decoder_init_mp3__internal(pConfig, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { onSeek(pDecoder, 0, mal_seek_origin_start); } } #endif - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -30722,7 +30722,7 @@ mal_result mal_decoder_init(mal_decoder_read_proc onRead, mal_decoder_seek_proc mal_decoder_config config = mal_decoder_config_init_copy(pConfig); mal_result result = mal_decoder__preinit(onRead, onSeek, pUserData, &config, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -30770,18 +30770,18 @@ mal_bool32 mal_decoder__on_seek_memory(mal_decoder* pDecoder, int byteOffset, ma } } - return MAL_TRUE; + return MA_TRUE; } mal_result mal_decoder__preinit_memory(const void* pData, size_t dataSize, const mal_decoder_config* pConfig, mal_decoder* pDecoder) { mal_result result = mal_decoder__preinit(mal_decoder__on_read_memory, mal_decoder__on_seek_memory, NULL, pConfig, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } if (pData == NULL || dataSize == 0) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } pDecoder->memory.pData = (const mal_uint8*)pData; @@ -30789,7 +30789,7 @@ mal_result mal_decoder__preinit_memory(const void* pData, size_t dataSize, const pDecoder->memory.currentReadPos = 0; (void)pConfig; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_decoder_init_memory(const void* pData, size_t dataSize, const mal_decoder_config* pConfig, mal_decoder* pDecoder) @@ -30797,7 +30797,7 @@ mal_result mal_decoder_init_memory(const void* pData, size_t dataSize, const mal mal_decoder_config config = mal_decoder_config_init_copy(pConfig); // Make sure the config is not NULL. mal_result result = mal_decoder__preinit_memory(pData, dataSize, &config, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -30809,14 +30809,14 @@ mal_result mal_decoder_init_memory_wav(const void* pData, size_t dataSize, const mal_decoder_config config = mal_decoder_config_init_copy(pConfig); // Make sure the config is not NULL. mal_result result = mal_decoder__preinit_memory(pData, dataSize, &config, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } -#ifdef MAL_HAS_WAV +#ifdef MA_HAS_WAV return mal_decoder_init_wav__internal(&config, pDecoder); #else - return MAL_NO_BACKEND; + return MA_NO_BACKEND; #endif } @@ -30825,14 +30825,14 @@ mal_result mal_decoder_init_memory_flac(const void* pData, size_t dataSize, cons mal_decoder_config config = mal_decoder_config_init_copy(pConfig); // Make sure the config is not NULL. mal_result result = mal_decoder__preinit_memory(pData, dataSize, &config, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } -#ifdef MAL_HAS_FLAC +#ifdef MA_HAS_FLAC return mal_decoder_init_flac__internal(&config, pDecoder); #else - return MAL_NO_BACKEND; + return MA_NO_BACKEND; #endif } @@ -30841,14 +30841,14 @@ mal_result mal_decoder_init_memory_vorbis(const void* pData, size_t dataSize, co mal_decoder_config config = mal_decoder_config_init_copy(pConfig); // Make sure the config is not NULL. mal_result result = mal_decoder__preinit_memory(pData, dataSize, &config, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } -#ifdef MAL_HAS_VORBIS +#ifdef MA_HAS_VORBIS return mal_decoder_init_vorbis__internal(&config, pDecoder); #else - return MAL_NO_BACKEND; + return MA_NO_BACKEND; #endif } @@ -30857,14 +30857,14 @@ mal_result mal_decoder_init_memory_mp3(const void* pData, size_t dataSize, const mal_decoder_config config = mal_decoder_config_init_copy(pConfig); // Make sure the config is not NULL. mal_result result = mal_decoder__preinit_memory(pData, dataSize, &config, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } -#ifdef MAL_HAS_MP3 +#ifdef MA_HAS_MP3 return mal_decoder_init_mp3__internal(&config, pDecoder); #else - return MAL_NO_BACKEND; + return MA_NO_BACKEND; #endif } @@ -30873,14 +30873,14 @@ mal_result mal_decoder_init_memory_raw(const void* pData, size_t dataSize, const mal_decoder_config config = mal_decoder_config_init_copy(pConfigOut); // Make sure the config is not NULL. mal_result result = mal_decoder__preinit_memory(pData, dataSize, &config, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } return mal_decoder_init_raw__internal(pConfigIn, &config, pDecoder); } -#ifndef MAL_NO_STDIO +#ifndef MA_NO_STDIO #include #if !defined(_MSC_VER) && !defined(__DMC__) #include // For strcasecmp(). @@ -30936,7 +30936,7 @@ const char* mal_path_extension(const char* path) mal_bool32 mal_path_extension_equal(const char* path, const char* extension) { if (path == NULL || extension == NULL) { - return MAL_FALSE; + return MA_FALSE; } const char* ext1 = extension; @@ -30962,24 +30962,24 @@ mal_bool32 mal_decoder__on_seek_stdio(mal_decoder* pDecoder, int byteOffset, mal mal_result mal_decoder__preinit_file(const char* pFilePath, const mal_decoder_config* pConfig, mal_decoder* pDecoder) { if (pDecoder == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_zero_object(pDecoder); if (pFilePath == NULL || pFilePath[0] == '\0') { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } FILE* pFile; #if defined(_MSC_VER) && _MSC_VER >= 1400 if (fopen_s(&pFile, pFilePath, "rb") != 0) { - return MAL_ERROR; + return MA_ERROR; } #else pFile = fopen(pFilePath, "rb"); if (pFile == NULL) { - return MAL_ERROR; + return MA_ERROR; } #endif @@ -30987,21 +30987,21 @@ mal_result mal_decoder__preinit_file(const char* pFilePath, const mal_decoder_co pDecoder->pUserData = pFile; (void)pConfig; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_decoder_init_file(const char* pFilePath, const mal_decoder_config* pConfig, mal_decoder* pDecoder) { mal_result result = mal_decoder__preinit_file(pFilePath, pConfig, pDecoder); // This sets pDecoder->pUserData to a FILE*. - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } // WAV if (mal_path_extension_equal(pFilePath, "wav")) { result = mal_decoder_init_wav(mal_decoder__on_read_stdio, mal_decoder__on_seek_stdio, pDecoder->pUserData, pConfig, pDecoder); - if (result == MAL_SUCCESS) { - return MAL_SUCCESS; + if (result == MA_SUCCESS) { + return MA_SUCCESS; } mal_decoder__on_seek_stdio(pDecoder, 0, mal_seek_origin_start); @@ -31010,8 +31010,8 @@ mal_result mal_decoder_init_file(const char* pFilePath, const mal_decoder_config // FLAC if (mal_path_extension_equal(pFilePath, "flac")) { result = mal_decoder_init_flac(mal_decoder__on_read_stdio, mal_decoder__on_seek_stdio, pDecoder->pUserData, pConfig, pDecoder); - if (result == MAL_SUCCESS) { - return MAL_SUCCESS; + if (result == MA_SUCCESS) { + return MA_SUCCESS; } mal_decoder__on_seek_stdio(pDecoder, 0, mal_seek_origin_start); @@ -31020,8 +31020,8 @@ mal_result mal_decoder_init_file(const char* pFilePath, const mal_decoder_config // MP3 if (mal_path_extension_equal(pFilePath, "mp3")) { result = mal_decoder_init_mp3(mal_decoder__on_read_stdio, mal_decoder__on_seek_stdio, pDecoder->pUserData, pConfig, pDecoder); - if (result == MAL_SUCCESS) { - return MAL_SUCCESS; + if (result == MA_SUCCESS) { + return MA_SUCCESS; } mal_decoder__on_seek_stdio(pDecoder, 0, mal_seek_origin_start); @@ -31034,7 +31034,7 @@ mal_result mal_decoder_init_file(const char* pFilePath, const mal_decoder_config mal_result mal_decoder_init_file_wav(const char* pFilePath, const mal_decoder_config* pConfig, mal_decoder* pDecoder) { mal_result result = mal_decoder__preinit_file(pFilePath, pConfig, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -31044,7 +31044,7 @@ mal_result mal_decoder_init_file_wav(const char* pFilePath, const mal_decoder_co mal_result mal_decoder_init_file_flac(const char* pFilePath, const mal_decoder_config* pConfig, mal_decoder* pDecoder) { mal_result result = mal_decoder__preinit_file(pFilePath, pConfig, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -31054,7 +31054,7 @@ mal_result mal_decoder_init_file_flac(const char* pFilePath, const mal_decoder_c mal_result mal_decoder_init_file_vorbis(const char* pFilePath, const mal_decoder_config* pConfig, mal_decoder* pDecoder) { mal_result result = mal_decoder__preinit_file(pFilePath, pConfig, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -31064,7 +31064,7 @@ mal_result mal_decoder_init_file_vorbis(const char* pFilePath, const mal_decoder mal_result mal_decoder_init_file_mp3(const char* pFilePath, const mal_decoder_config* pConfig, mal_decoder* pDecoder) { mal_result result = mal_decoder__preinit_file(pFilePath, pConfig, pDecoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -31075,21 +31075,21 @@ mal_result mal_decoder_init_file_mp3(const char* pFilePath, const mal_decoder_co mal_result mal_decoder_uninit(mal_decoder* pDecoder) { if (pDecoder == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } if (pDecoder->onUninit) { pDecoder->onUninit(pDecoder); } -#ifndef MAL_NO_STDIO +#ifndef MA_NO_STDIO // If we have a file handle, close it. if (pDecoder->onRead == mal_decoder__on_read_stdio) { fclose((FILE*)pDecoder->pUserData); } #endif - return MAL_SUCCESS; + return MA_SUCCESS; } mal_uint64 mal_decoder_read_pcm_frames(mal_decoder* pDecoder, void* pFramesOut, mal_uint64 frameCount) @@ -31108,7 +31108,7 @@ mal_result mal_decoder_seek_to_pcm_frame(mal_decoder* pDecoder, mal_uint64 frame } // Should never get here, but if we do it means onSeekToPCMFrame was not set by the backend. - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } @@ -31130,16 +31130,16 @@ mal_result mal_decoder__full_decode_and_uninit(mal_decoder* pDecoder, mal_decode newDataCapInFrames = 4096; } - if ((newDataCapInFrames * bpf) > MAL_SIZE_MAX) { + if ((newDataCapInFrames * bpf) > MA_SIZE_MAX) { mal_free(pPCMFramesOut); - return MAL_TOO_LARGE; + return MA_TOO_LARGE; } void* pNewPCMFramesOut = (void*)mal_realloc(pPCMFramesOut, (size_t)(newDataCapInFrames * bpf)); if (pNewPCMFramesOut == NULL) { mal_free(pPCMFramesOut); - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } dataCapInFrames = newDataCapInFrames; @@ -31176,10 +31176,10 @@ mal_result mal_decoder__full_decode_and_uninit(mal_decoder* pDecoder, mal_decode } mal_decoder_uninit(pDecoder); - return MAL_SUCCESS; + return MA_SUCCESS; } -#ifndef MAL_NO_STDIO +#ifndef MA_NO_STDIO mal_result mal_decode_file(const char* pFilePath, mal_decoder_config* pConfig, mal_uint64* pFrameCountOut, void** ppPCMFramesOut) { if (pFrameCountOut != NULL) { @@ -31190,14 +31190,14 @@ mal_result mal_decode_file(const char* pFilePath, mal_decoder_config* pConfig, m } if (pFilePath == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_decoder_config config = mal_decoder_config_init_copy(pConfig); mal_decoder decoder; mal_result result = mal_decoder_init_file(pFilePath, &config, &decoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -31215,21 +31215,21 @@ mal_result mal_decode_memory(const void* pData, size_t dataSize, mal_decoder_con } if (pData == NULL || dataSize == 0) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_decoder_config config = mal_decoder_config_init_copy(pConfig); mal_decoder decoder; mal_result result = mal_decoder_init_memory(pData, dataSize, &config, &decoder); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } return mal_decoder__full_decode_and_uninit(&decoder, pConfig, pFrameCountOut, ppPCMFramesOut); } -#endif // MAL_NO_DECODING +#endif // MA_NO_DECODING @@ -31245,12 +31245,12 @@ mal_result mal_decode_memory(const void* pData, size_t dataSize, mal_decoder_con mal_result mal_sine_wave_init(double amplitude, double periodsPerSecond, mal_uint32 sampleRate, mal_sine_wave* pSineWave) { if (pSineWave == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_zero_object(pSineWave); if (amplitude == 0 || periodsPerSecond == 0) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } if (amplitude > 1) { @@ -31262,10 +31262,10 @@ mal_result mal_sine_wave_init(double amplitude, double periodsPerSecond, mal_uin pSineWave->amplitude = amplitude; pSineWave->periodsPerSecond = periodsPerSecond; - pSineWave->delta = MAL_TAU_D / sampleRate; + pSineWave->delta = MA_TAU_D / sampleRate; pSineWave->time = 0; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_uint64 mal_sine_wave_read_f32(mal_sine_wave* pSineWave, mal_uint64 count, float* pSamples) @@ -31318,8 +31318,8 @@ Context Device ------ - If a full-duplex device is requested and the backend does not support full duplex devices, have mal_device_init__[backend]() - return MAL_DEVICE_TYPE_NOT_SUPPORTED. -- If exclusive mode is requested, but the backend does not support it, return MAL_SHARE_MODE_NOT_SUPPORTED. If practical, try + return MA_DEVICE_TYPE_NOT_SUPPORTED. +- If exclusive mode is requested, but the backend does not support it, return MA_SHARE_MODE_NOT_SUPPORTED. If practical, try not to fall back to a different share mode - give the client exactly what they asked for. Some backends, such as ALSA, may not have a practical way to distinguish between the two. - If pDevice->usingDefault* is set, prefer the device's native value if the backend supports it. Otherwise use the relevant @@ -31479,7 +31479,7 @@ v0.8.1 - 2018-07-06 - Fix compilation errors and warnings. v0.8 - 2018-07-05 - - Changed MAL_IMPLEMENTATION to MINI_AL_IMPLEMENTATION for consistency with other libraries. The old + - Changed MA_IMPLEMENTATION to MINI_AL_IMPLEMENTATION for consistency with other libraries. The old way is still supported for now, but you should update as it may be removed in the future. - API CHANGE: Replace device enumeration APIs. mal_enumerate_devices() has been replaced with mal_context_get_devices(). An additional low-level device enumration API has been introduced called @@ -31489,7 +31489,7 @@ v0.8 - 2018-07-05 - API CHANGE: Replace mal_device_config.preferExclusiveMode with mal_device_config.shareMode. - This new config can be set to mal_share_mode_shared (default) or mal_share_mode_exclusive. - API CHANGE: Remove excludeNullDevice from mal_context_config.alsa. - - API CHANGE: Rename MAL_MAX_SAMPLE_SIZE_IN_BYTES to MAL_MAX_PCM_SAMPLE_SIZE_IN_BYTES. + - API CHANGE: Rename MA_MAX_SAMPLE_SIZE_IN_BYTES to MA_MAX_PCM_SAMPLE_SIZE_IN_BYTES. - API CHANGE: Change the default channel mapping to the standard Microsoft mapping. - API CHANGE: Remove backend-specific result codes. - API CHANGE: Changes to the format conversion APIs (mal_pcm_f32_to_s16(), etc.) diff --git a/research/mal_resampler.h b/research/mal_resampler.h index 23a6541d..7342484e 100644 --- a/research/mal_resampler.h +++ b/research/mal_resampler.h @@ -44,19 +44,19 @@ Other Notes: Random Notes: - You cannot change the algorithm after initialization. -- It is recommended to keep the mal_resampler object aligned to MAL_SIMD_ALIGNMENT, though it is not necessary. -- Ratios need to be in the range of MAL_RESAMPLER_MIN_RATIO and MAL_RESAMPLER_MAX_RATIO. This is enough to convert +- It is recommended to keep the mal_resampler object aligned to MA_SIMD_ALIGNMENT, though it is not necessary. +- Ratios need to be in the range of MA_RESAMPLER_MIN_RATIO and MA_RESAMPLER_MAX_RATIO. This is enough to convert to and from 8000 and 384000, which is the smallest and largest standard rates supported by miniaudio. If you need extreme ratios then you will need to chain resamplers together. */ #ifndef mal_resampler_h #define mal_resampler_h -#define MAL_RESAMPLER_SEEK_NO_CLIENT_READ (1 << 0) /* When set, does not read anything from the client when seeking. This does _not_ call onRead(). */ -#define MAL_RESAMPLER_SEEK_INPUT_RATE (1 << 1) /* When set, treats the specified frame count based on the input sample rate rather than the output sample rate. */ +#define MA_RESAMPLER_SEEK_NO_CLIENT_READ (1 << 0) /* When set, does not read anything from the client when seeking. This does _not_ call onRead(). */ +#define MA_RESAMPLER_SEEK_INPUT_RATE (1 << 1) /* When set, treats the specified frame count based on the input sample rate rather than the output sample rate. */ -#ifndef MAL_RESAMPLER_CACHE_SIZE_IN_BYTES -#define MAL_RESAMPLER_CACHE_SIZE_IN_BYTES 4096 +#ifndef MA_RESAMPLER_CACHE_SIZE_IN_BYTES +#define MA_RESAMPLER_CACHE_SIZE_IN_BYTES 4096 #endif typedef struct mal_resampler mal_resampler; @@ -100,8 +100,8 @@ struct mal_resampler { union { - float f32[MAL_RESAMPLER_CACHE_SIZE_IN_BYTES/sizeof(float)]; - mal_int16 s16[MAL_RESAMPLER_CACHE_SIZE_IN_BYTES/sizeof(mal_int16)]; + float f32[MA_RESAMPLER_CACHE_SIZE_IN_BYTES/sizeof(float)]; + mal_int16 s16[MA_RESAMPLER_CACHE_SIZE_IN_BYTES/sizeof(mal_int16)]; } cache; /* Keep this as the first member of this structure for SIMD alignment purposes. */ mal_uint32 cacheStrideInFrames; /* The number of the samples between channels in the cache. The first sample for channel 0 is cacheStrideInFrames*0. The first sample for channel 1 is cacheStrideInFrames*1, etc. */ mal_uint16 cacheLengthInFrames; /* The number of valid frames sitting in the cache, including the filter window. May be less than the cache's capacity. */ @@ -147,9 +147,9 @@ mal_uint64 mal_resampler_read(mal_resampler* pResampler, mal_uint64 frameCount, Seeks forward by the specified number of PCM frames. "options" can be a cobination of the following: - MAL_RESAMPLER_SEEK_NO_CLIENT_READ + MA_RESAMPLER_SEEK_NO_CLIENT_READ Leaves the contents of the internal cached undefined instead of reading in data from the onRead callback. - MAL_RESAMPLER_SEEK_INPUT_RATE + MA_RESAMPLER_SEEK_INPUT_RATE Treats "frameCount" as input samples instead of output samples. */ mal_uint64 mal_resampler_seek(mal_resampler* pResampler, mal_uint64 frameCount, mal_uint32 options); @@ -222,11 +222,11 @@ mal_uint64 mal_resampler_get_expected_output_frame_count(mal_resampler* pResampl #ifdef MINIAUDIO_IMPLEMENTATION -#ifndef MAL_RESAMPLER_MIN_RATIO -#define MAL_RESAMPLER_MIN_RATIO 0.02083333 +#ifndef MA_RESAMPLER_MIN_RATIO +#define MA_RESAMPLER_MIN_RATIO 0.02083333 #endif -#ifndef MAL_RESAMPLER_MAX_RATIO -#define MAL_RESAMPLER_MAX_RATIO 48.0 +#ifndef MA_RESAMPLER_MAX_RATIO +#define MA_RESAMPLER_MAX_RATIO 48.0 #endif mal_result mal_resampler_init__linear(mal_resampler* pResampler); @@ -239,36 +239,36 @@ mal_uint64 mal_resampler_read_f32__sinc(mal_resampler* pResampler, mal_uint64 fr mal_uint64 mal_resampler_read_s16__sinc(mal_resampler* pResampler, mal_uint64 frameCount, mal_int16** ppFrames); mal_uint64 mal_resampler_seek__sinc(mal_resampler* pResampler, mal_uint64 frameCount, mal_uint32 options); -static MAL_INLINE float mal_fractional_part_f32(float x) +static MA_INLINE float mal_fractional_part_f32(float x) { return x - ((mal_int32)x); } -static MAL_INLINE double mal_fractional_part_f64(double x) +static MA_INLINE double mal_fractional_part_f64(double x) { return x - ((mal_int64)x); } #if 0 -#define MAL_ALIGN_INT(val, alignment) (((val) + ((alignment)-1)) & ~((alignment)-1)) -#define MAL_ALIGN_PTR(ptr, alignment) (void*)MAL_ALIGN_INT(((mal_uintptr)(ptr)), (alignment)) +#define MA_ALIGN_INT(val, alignment) (((val) + ((alignment)-1)) & ~((alignment)-1)) +#define MA_ALIGN_PTR(ptr, alignment) (void*)MA_ALIGN_INT(((mal_uintptr)(ptr)), (alignment)) /* This macro declares a set of variables on the stack of a given size in bytes. The variables it creates are: - - mal_uint8 Unaligned[size + MAL_SIMD_ALIGNMENT]; - - * [MAL_MAX_CHANNELS]; + - mal_uint8 Unaligned[size + MA_SIMD_ALIGNMENT]; + - * [MA_MAX_CHANNELS]; - size_t FrameCount; <-- This is the number of samples contained within each sub-buffer of This does not work for formats that do not have a clean mapping to a primitive C type. s24 will not work here. */ -#define MAL_DECLARE_ALIGNED_STACK_BUFFER(type, name, size, channels) \ - mal_uint8 name##Unaligned[(size) + MAL_SIMD_ALIGNMENT]; \ - type* name[MAL_MAX_CHANNELS]; \ - size_t name##FrameCount = ((size) & ~((MAL_SIMD_ALIGNMENT)-1)) / sizeof(type); \ +#define MA_DECLARE_ALIGNED_STACK_BUFFER(type, name, size, channels) \ + mal_uint8 name##Unaligned[(size) + MA_SIMD_ALIGNMENT]; \ + type* name[MA_MAX_CHANNELS]; \ + size_t name##FrameCount = ((size) & ~((MA_SIMD_ALIGNMENT)-1)) / sizeof(type); \ do { \ mal_uint32 iChannel; \ for (iChannel = 0; iChannel < channels; ++iChannel) { \ - name[iChannel] = (type*)((mal_uint8*)MAL_ALIGN_PTR(name##Unaligned, MAL_SIMD_ALIGNMENT) + (iChannel*((size) & ~((MAL_SIMD_ALIGNMENT)-1)))); \ + name[iChannel] = (type*)((mal_uint8*)MA_ALIGN_PTR(name##Unaligned, MA_SIMD_ALIGNMENT) + (iChannel*((size) & ~((MA_SIMD_ALIGNMENT)-1)))); \ } \ } while (0) #endif @@ -276,17 +276,17 @@ This does not work for formats that do not have a clean mapping to a primitive C #define mal_filter_window_length_left(length) ((length) >> 1) #define mal_filter_window_length_right(length) ((length) - mal_filter_window_length_left(length)) -static MAL_INLINE mal_uint16 mal_resampler__window_length_left(const mal_resampler* pResampler) +static MA_INLINE mal_uint16 mal_resampler__window_length_left(const mal_resampler* pResampler) { return mal_filter_window_length_left(pResampler->windowLength); } -static MAL_INLINE mal_uint16 mal_resampler__window_length_right(const mal_resampler* pResampler) +static MA_INLINE mal_uint16 mal_resampler__window_length_right(const mal_resampler* pResampler) { return mal_filter_window_length_right(pResampler->windowLength); } -static MAL_INLINE double mal_resampler__calculate_cached_input_time_by_mode(mal_resampler* pResampler, mal_resampler_end_of_input_mode mode) +static MA_INLINE double mal_resampler__calculate_cached_input_time_by_mode(mal_resampler* pResampler, mal_resampler_end_of_input_mode mode) { /* The cached input time depends on whether or not the end of the input is being consumed. If so, it's the difference between the @@ -303,24 +303,24 @@ static MAL_INLINE double mal_resampler__calculate_cached_input_time_by_mode(mal_ return cachedInputTime; } -static MAL_INLINE double mal_resampler__calculate_cached_input_time(mal_resampler* pResampler) +static MA_INLINE double mal_resampler__calculate_cached_input_time(mal_resampler* pResampler) { return mal_resampler__calculate_cached_input_time_by_mode(pResampler, pResampler->config.endOfInputMode); } -static MAL_INLINE double mal_resampler__calculate_cached_output_time_by_mode(mal_resampler* pResampler, mal_resampler_end_of_input_mode mode) +static MA_INLINE double mal_resampler__calculate_cached_output_time_by_mode(mal_resampler* pResampler, mal_resampler_end_of_input_mode mode) { return mal_resampler__calculate_cached_input_time_by_mode(pResampler, mode) / pResampler->config.ratio; } -static MAL_INLINE double mal_resampler__calculate_cached_output_time(mal_resampler* pResampler) +static MA_INLINE double mal_resampler__calculate_cached_output_time(mal_resampler* pResampler) { return mal_resampler__calculate_cached_output_time_by_mode(pResampler, pResampler->config.endOfInputMode); } -static MAL_INLINE mal_result mal_resampler__slide_cache_down(mal_resampler* pResampler) +static MA_INLINE mal_result mal_resampler__slide_cache_down(mal_resampler* pResampler) { /* This function moves everything from the start of the window to the last loaded frame in the cache down to the front. */ @@ -344,13 +344,13 @@ static MAL_INLINE mal_result mal_resampler__slide_cache_down(mal_resampler* pRes } } - return MAL_SUCCESS; + return MA_SUCCESS; } typedef union { - float* f32[MAL_MAX_CHANNELS]; - mal_int16* s16[MAL_MAX_CHANNELS]; + float* f32[MA_MAX_CHANNELS]; + mal_int16* s16[MA_MAX_CHANNELS]; } mal_resampler_deinterleaved_pointers; typedef union @@ -366,7 +366,7 @@ mal_result mal_resampler__reload_cache(mal_resampler* pResampler, mal_bool32* pL mal_result result; mal_uint32 framesToReadFromClient; mal_uint32 framesReadFromClient; - mal_bool32 loadedEndOfInput = MAL_FALSE; + mal_bool32 loadedEndOfInput = MA_FALSE; mal_assert(pLoadedEndOfInput != NULL); mal_assert(pResampler->windowTime < 65536); @@ -374,7 +374,7 @@ mal_result mal_resampler__reload_cache(mal_resampler* pResampler, mal_bool32* pL /* Before loading anything from the client we need to move anything left in the cache down the front. */ result = mal_resampler__slide_cache_down(pResampler); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; /* Should never actually happen. */ } @@ -422,7 +422,7 @@ mal_result mal_resampler__reload_cache(mal_resampler* pResampler, mal_bool32* pL mal_assert(framesReadFromClient <= framesToReadFromClient); if (framesReadFromClient < framesToReadFromClient) { /* We have reached the end of the input buffer. We do _not_ want to attempt to read any more data from the client in this case. */ - loadedEndOfInput = MAL_TRUE; + loadedEndOfInput = MA_TRUE; *pLoadedEndOfInput = loadedEndOfInput; } @@ -451,36 +451,36 @@ mal_result mal_resampler__reload_cache(mal_resampler* pResampler, mal_bool32* pL } } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_resampler_init(const mal_resampler_config* pConfig, mal_resampler* pResampler) { if (pResampler == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_zero_object(pResampler); if (pConfig == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } pResampler->config = *pConfig; if (pResampler->config.format != mal_format_f32 && pResampler->config.format != mal_format_s16) { - return MAL_INVALID_ARGS; /* Unsupported format. */ + return MA_INVALID_ARGS; /* Unsupported format. */ } if (pResampler->config.channels == 0) { - return MAL_INVALID_ARGS; /* Unsupported channel count. */ + return MA_INVALID_ARGS; /* Unsupported channel count. */ } if (pResampler->config.ratio == 0) { if (pResampler->config.sampleRateIn == 0 || pResampler->config.sampleRateOut == 0) { - return MAL_INVALID_ARGS; /* Unsupported sample rate. */ + return MA_INVALID_ARGS; /* Unsupported sample rate. */ } pResampler->config.ratio = (double)pResampler->config.sampleRateIn / (double)pResampler->config.sampleRateOut; } if (pResampler->config.onRead == NULL) { - return MAL_INVALID_ARGS; /* No input callback specified. */ + return MA_INVALID_ARGS; /* No input callback specified. */ } switch (pResampler->config.algorithm) { @@ -509,7 +509,7 @@ mal_result mal_resampler_init(const mal_resampler_config* pConfig, mal_resampler if (pResampler->init != NULL) { mal_result result = pResampler->init(pResampler); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } } @@ -520,7 +520,7 @@ mal_result mal_resampler_init(const mal_resampler_config* pConfig, mal_resampler */ pResampler->cacheLengthInFrames = mal_resampler__window_length_left(pResampler); - return MAL_SUCCESS; + return MA_SUCCESS; } void mal_resampler_uninit(mal_resampler* pResampler) @@ -531,38 +531,38 @@ void mal_resampler_uninit(mal_resampler* pResampler) mal_result mal_resampler_set_rate(mal_resampler* pResampler, mal_uint32 sampleRateIn, mal_uint32 sampleRateOut) { if (pResampler == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } if (sampleRateIn == 0 || sampleRateOut == 0) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } double ratio = (double)pResampler->config.sampleRateIn / (double)pResampler->config.sampleRateOut; - if (ratio < MAL_RESAMPLER_MIN_RATIO || ratio > MAL_RESAMPLER_MAX_RATIO) { - return MAL_INVALID_ARGS; /* Ratio is too extreme. */ + if (ratio < MA_RESAMPLER_MIN_RATIO || ratio > MA_RESAMPLER_MAX_RATIO) { + return MA_INVALID_ARGS; /* Ratio is too extreme. */ } pResampler->config.sampleRateIn = sampleRateIn; pResampler->config.sampleRateOut = sampleRateOut; pResampler->config.ratio = ratio; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_resampler_set_rate_ratio(mal_resampler* pResampler, double ratio) { if (pResampler == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } - if (ratio < MAL_RESAMPLER_MIN_RATIO || ratio > MAL_RESAMPLER_MAX_RATIO) { - return MAL_INVALID_ARGS; /* Ratio is too extreme. */ + if (ratio < MA_RESAMPLER_MIN_RATIO || ratio > MA_RESAMPLER_MAX_RATIO) { + return MA_INVALID_ARGS; /* Ratio is too extreme. */ } pResampler->config.ratio = ratio; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_uint64 mal_resampler_read(mal_resampler* pResampler, mal_uint64 frameCount, void** ppFrames) @@ -571,7 +571,7 @@ mal_uint64 mal_resampler_read(mal_resampler* pResampler, mal_uint64 frameCount, mal_uint64 totalFramesRead; mal_resampler_deinterleaved_pointers runningFramesOutDeinterleaved; mal_resampler_interleaved_pointers runningFramesOutInterleaved; - mal_bool32 loadedEndOfInput = MAL_FALSE; + mal_bool32 loadedEndOfInput = MA_FALSE; if (pResampler == NULL) { return 0; /* Invalid arguments. */ @@ -669,7 +669,7 @@ mal_uint64 mal_resampler_read(mal_resampler* pResampler, mal_uint64 frameCount, framesJustRead = pResampler->readF32(pResampler, framesToReadRightNow, runningFramesOutDeinterleaved.f32); } else { float buffer[mal_countof(pResampler->cache.f32)]; - float* ppDeinterleavedFrames[MAL_MAX_CHANNELS]; + float* ppDeinterleavedFrames[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < pResampler->config.channels; ++iChannel) { ppDeinterleavedFrames[iChannel] = buffer + (pResampler->cacheStrideInFrames*iChannel); } @@ -682,7 +682,7 @@ mal_uint64 mal_resampler_read(mal_resampler* pResampler, mal_uint64 frameCount, framesJustRead = pResampler->readS16(pResampler, framesToReadRightNow, runningFramesOutDeinterleaved.s16); } else { mal_int16 buffer[mal_countof(pResampler->cache.s16)]; - mal_int16* ppDeinterleavedFrames[MAL_MAX_CHANNELS]; + mal_int16* ppDeinterleavedFrames[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < pResampler->config.channels; ++iChannel) { ppDeinterleavedFrames[iChannel] = buffer + (pResampler->cacheStrideInFrames*iChannel); } @@ -693,7 +693,7 @@ mal_uint64 mal_resampler_read(mal_resampler* pResampler, mal_uint64 frameCount, } if (framesJustRead != framesToReadRightNow) { - mal_assert(MAL_FALSE); + mal_assert(MA_FALSE); break; /* Should never hit this. */ } } @@ -740,7 +740,7 @@ mal_uint64 mal_resampler_read(mal_resampler* pResampler, mal_uint64 frameCount, client. If we have already reached the end of the client's data, we don't want to attempt to read more. */ result = mal_resampler__reload_cache(pResampler, &loadedEndOfInput); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { break; /* An error occurred when trying to reload the cache from the client. This does _not_ indicate that the end of the input has been reached. */ } } @@ -761,9 +761,9 @@ mal_uint64 mal_resampler_seek(mal_resampler* pResampler, mal_uint64 frameCount, } /* Seeking is slightly different depending on whether or not we are seeking by the output or input rate. */ - if ((options & MAL_RESAMPLER_SEEK_INPUT_RATE) != 0 || pResampler->config.ratio == 1) { + if ((options & MA_RESAMPLER_SEEK_INPUT_RATE) != 0 || pResampler->config.ratio == 1) { /* Seeking by input rate. This is a simpler case because we don't need to care about the ratio. */ - if ((options & MAL_RESAMPLER_SEEK_NO_CLIENT_READ) != 0) { + if ((options & MA_RESAMPLER_SEEK_NO_CLIENT_READ) != 0) { /* Not reading from the client. This is the fast path. We can do this in constant time. Because in this mode the contents of the cache are left undefined and the fractional part of the window time is left exactly the same (since we're seeking @@ -780,7 +780,7 @@ mal_uint64 mal_resampler_seek(mal_resampler* pResampler, mal_uint64 frameCount, } } else { /* Seeking by output rate. */ - if ((options & MAL_RESAMPLER_SEEK_NO_CLIENT_READ) != 0) { + if ((options & MA_RESAMPLER_SEEK_NO_CLIENT_READ) != 0) { /* Not reading from the client. This is a fast-ish path, though I'm not doing this in constant time like when seeking by input rate. It's easier to just loop. */ } else { /* Reading from the client. This case is basically the same as reading, but without the filtering. */ @@ -880,7 +880,7 @@ mal_result mal_resampler_init__linear(mal_resampler* pResampler) /* The linear implementation always has a window length of 2. */ pResampler->windowLength = 2; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_uint64 mal_resampler_read_f32__linear(mal_resampler* pResampler, mal_uint64 frameCount, float** ppFrames) @@ -908,7 +908,7 @@ mal_uint64 mal_resampler_read_s16__linear(mal_resampler* pResampler, mal_uint64 /* I'm cheating here and just using the f32 implementation and converting to s16. This will be changed later - for now just focusing on getting it working. */ float bufferF32[mal_countof(pResampler->cache.s16)]; - float* ppFramesF32[MAL_MAX_CHANNELS]; + float* ppFramesF32[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < pResampler->config.channels; ++iChannel) { ppFramesF32[iChannel] = bufferF32 + (pResampler->cacheStrideInFrames*iChannel); } @@ -944,7 +944,7 @@ mal_result mal_resampler_init__sinc(mal_resampler* pResampler) mal_assert(pResampler != NULL); /* TODO: Implement me. Need to initialize the sinc table. */ - return MAL_SUCCESS; + return MA_SUCCESS; } mal_uint64 mal_resampler_read_f32__sinc(mal_resampler* pResampler, mal_uint64 frameCount, float** ppFrames) @@ -972,7 +972,7 @@ mal_uint64 mal_resampler_read_s16__sinc(mal_resampler* pResampler, mal_uint64 fr /* I'm cheating here and just using the f32 implementation and converting to s16. This will be changed later - for now just focusing on getting it working. */ float bufferF32[mal_countof(pResampler->cache.s16)]; - float* ppFramesF32[MAL_MAX_CHANNELS]; + float* ppFramesF32[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < pResampler->config.channels; ++iChannel) { ppFramesF32[iChannel] = bufferF32 + (pResampler->cacheStrideInFrames*iChannel); } diff --git a/research/mal_ring_buffer.h b/research/mal_ring_buffer.h index 93ce9ee5..98b62a53 100644 --- a/research/mal_ring_buffer.h +++ b/research/mal_ring_buffer.h @@ -4,7 +4,7 @@ // - Lock free (assuming single producer, single consumer) // - Support for interleaved and deinterleaved streams // - Must allow the caller to allocate their own block of memory -// - Buffers allocated internally must be aligned to MAL_SIMD_ALIGNMENT +// - Buffers allocated internally must be aligned to MA_SIMD_ALIGNMENT // USAGE // @@ -43,7 +43,7 @@ // consumer is the only one allowed to move the read pointer. // - Thread safety not fully tested - may even be completely broken. // - Operates on bytes. May end up adding to higher level helpers for doing everything per audio frame. -// - Maximum buffer size is 0x7FFFFFFF-(MAL_SIMD_ALIGNMENT-1) because of reasons. +// - Maximum buffer size is 0x7FFFFFFF-(MA_SIMD_ALIGNMENT-1) because of reasons. #ifndef mal_ring_buffer_h #define mal_ring_buffer_h @@ -100,34 +100,34 @@ void* mal_pcm_rb_get_subbuffer_ptr(mal_pcm_rb* pRB, size_t subbufferIndex, void* #endif // mal_ring_buffer_h #ifdef MINIAUDIO_IMPLEMENTATION -MAL_INLINE mal_uint32 mal_rb__extract_offset_in_bytes(mal_uint32 encodedOffset) +MA_INLINE mal_uint32 mal_rb__extract_offset_in_bytes(mal_uint32 encodedOffset) { return encodedOffset & 0x7FFFFFFF; } -MAL_INLINE mal_uint32 mal_rb__extract_offset_loop_flag(mal_uint32 encodedOffset) +MA_INLINE mal_uint32 mal_rb__extract_offset_loop_flag(mal_uint32 encodedOffset) { return encodedOffset & 0x80000000; } -MAL_INLINE void* mal_rb__get_read_ptr(mal_rb* pRB) +MA_INLINE void* mal_rb__get_read_ptr(mal_rb* pRB) { mal_assert(pRB != NULL); return mal_offset_ptr(pRB->pBuffer, mal_rb__extract_offset_in_bytes(pRB->encodedReadOffset)); } -MAL_INLINE void* mal_rb__get_write_ptr(mal_rb* pRB) +MA_INLINE void* mal_rb__get_write_ptr(mal_rb* pRB) { mal_assert(pRB != NULL); return mal_offset_ptr(pRB->pBuffer, mal_rb__extract_offset_in_bytes(pRB->encodedWriteOffset)); } -MAL_INLINE mal_uint32 mal_rb__construct_offset(mal_uint32 offsetInBytes, mal_uint32 offsetLoopFlag) +MA_INLINE mal_uint32 mal_rb__construct_offset(mal_uint32 offsetInBytes, mal_uint32 offsetLoopFlag) { return offsetLoopFlag | offsetInBytes; } -MAL_INLINE void mal_rb__deconstruct_offset(mal_uint32 encodedOffset, mal_uint32* pOffsetInBytes, mal_uint32* pOffsetLoopFlag) +MA_INLINE void mal_rb__deconstruct_offset(mal_uint32 encodedOffset, mal_uint32* pOffsetInBytes, mal_uint32* pOffsetLoopFlag) { mal_assert(pOffsetInBytes != NULL); mal_assert(pOffsetLoopFlag != NULL); @@ -140,16 +140,16 @@ MAL_INLINE void mal_rb__deconstruct_offset(mal_uint32 encodedOffset, mal_uint32* mal_result mal_rb_init_ex(size_t subbufferSizeInBytes, size_t subbufferCount, size_t subbufferStrideInBytes, void* pOptionalPreallocatedBuffer, mal_rb* pRB) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } if (subbufferSizeInBytes == 0 || subbufferCount == 0) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } - const mal_uint32 maxSubBufferSize = 0x7FFFFFFF - (MAL_SIMD_ALIGNMENT-1); + const mal_uint32 maxSubBufferSize = 0x7FFFFFFF - (MA_SIMD_ALIGNMENT-1); if (subbufferSizeInBytes > maxSubBufferSize) { - return MAL_INVALID_ARGS; // Maximum buffer size is ~2GB. The most significant bit is a flag for use internally. + return MA_INVALID_ARGS; // Maximum buffer size is ~2GB. The most significant bit is a flag for use internally. } @@ -161,21 +161,21 @@ mal_result mal_rb_init_ex(size_t subbufferSizeInBytes, size_t subbufferCount, si pRB->subbufferStrideInBytes = (mal_uint32)subbufferStrideInBytes; pRB->pBuffer = pOptionalPreallocatedBuffer; } else { - // Here is where we allocate our own buffer. We always want to align this to MAL_SIMD_ALIGNMENT for future SIMD optimization opportunity. To do this - // we need to make sure the stride is a multiple of MAL_SIMD_ALIGNMENT. - pRB->subbufferStrideInBytes = (pRB->subbufferSizeInBytes + (MAL_SIMD_ALIGNMENT-1)) & ~MAL_SIMD_ALIGNMENT; + // Here is where we allocate our own buffer. We always want to align this to MA_SIMD_ALIGNMENT for future SIMD optimization opportunity. To do this + // we need to make sure the stride is a multiple of MA_SIMD_ALIGNMENT. + pRB->subbufferStrideInBytes = (pRB->subbufferSizeInBytes + (MA_SIMD_ALIGNMENT-1)) & ~MA_SIMD_ALIGNMENT; size_t bufferSizeInBytes = (size_t)pRB->subbufferCount*pRB->subbufferStrideInBytes; - pRB->pBuffer = mal_aligned_malloc(bufferSizeInBytes, MAL_SIMD_ALIGNMENT); + pRB->pBuffer = mal_aligned_malloc(bufferSizeInBytes, MA_SIMD_ALIGNMENT); if (pRB->pBuffer == NULL) { - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } mal_zero_memory(pRB->pBuffer, bufferSizeInBytes); - pRB->ownsBuffer = MAL_TRUE; + pRB->ownsBuffer = MA_TRUE; } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_rb_init(size_t bufferSizeInBytes, void* pOptionalPreallocatedBuffer, mal_rb* pRB) @@ -197,7 +197,7 @@ void mal_rb_uninit(mal_rb* pRB) mal_result mal_rb_acquire_read(mal_rb* pRB, size_t* pSizeInBytes, void** ppBufferOut) { if (pRB == NULL || pSizeInBytes == NULL || ppBufferOut == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } // The returned buffer should never move ahead of the write pointer. @@ -228,18 +228,18 @@ mal_result mal_rb_acquire_read(mal_rb* pRB, size_t* pSizeInBytes, void** ppBuffe *pSizeInBytes = bytesRequested; (*ppBufferOut) = mal_rb__get_read_ptr(pRB); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_rb_commit_read(mal_rb* pRB, size_t sizeInBytes, void* pBufferOut) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } // Validate the buffer. if (pBufferOut != mal_rb__get_read_ptr(pRB)) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_uint32 readOffset = pRB->encodedReadOffset; @@ -250,7 +250,7 @@ mal_result mal_rb_commit_read(mal_rb* pRB, size_t sizeInBytes, void* pBufferOut) // Check that sizeInBytes is correct. It should never go beyond the end of the buffer. mal_uint32 newReadOffsetInBytes = (mal_uint32)(readOffsetInBytes + sizeInBytes); if (newReadOffsetInBytes > pRB->subbufferSizeInBytes) { - return MAL_INVALID_ARGS; // <-- sizeInBytes will cause the read offset to overflow. + return MA_INVALID_ARGS; // <-- sizeInBytes will cause the read offset to overflow. } // Move the read pointer back to the start if necessary. @@ -261,13 +261,13 @@ mal_result mal_rb_commit_read(mal_rb* pRB, size_t sizeInBytes, void* pBufferOut) } mal_atomic_exchange_32(&pRB->encodedReadOffset, mal_rb__construct_offset(newReadOffsetLoopFlag, newReadOffsetInBytes)); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_rb_acquire_write(mal_rb* pRB, size_t* pSizeInBytes, void** ppBufferOut) { if (pRB == NULL || pSizeInBytes == NULL || ppBufferOut == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } // The returned buffer should never overtake the read buffer. @@ -304,18 +304,18 @@ mal_result mal_rb_acquire_write(mal_rb* pRB, size_t* pSizeInBytes, void** ppBuff mal_zero_memory(*ppBufferOut, *pSizeInBytes); } - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_rb_commit_write(mal_rb* pRB, size_t sizeInBytes, void* pBufferOut) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } // Validate the buffer. if (pBufferOut != mal_rb__get_write_ptr(pRB)) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_uint32 writeOffset = pRB->encodedWriteOffset; @@ -326,7 +326,7 @@ mal_result mal_rb_commit_write(mal_rb* pRB, size_t sizeInBytes, void* pBufferOut // Check that sizeInBytes is correct. It should never go beyond the end of the buffer. mal_uint32 newWriteOffsetInBytes = (mal_uint32)(writeOffsetInBytes + sizeInBytes); if (newWriteOffsetInBytes > pRB->subbufferSizeInBytes) { - return MAL_INVALID_ARGS; // <-- sizeInBytes will cause the read offset to overflow. + return MA_INVALID_ARGS; // <-- sizeInBytes will cause the read offset to overflow. } // Move the read pointer back to the start if necessary. @@ -337,13 +337,13 @@ mal_result mal_rb_commit_write(mal_rb* pRB, size_t sizeInBytes, void* pBufferOut } mal_atomic_exchange_32(&pRB->encodedWriteOffset, mal_rb__construct_offset(newWriteOffsetLoopFlag, newWriteOffsetInBytes)); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_rb_seek_read(mal_rb* pRB, size_t offsetInBytes) { if (pRB == NULL || offsetInBytes > pRB->subbufferSizeInBytes) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_uint32 readOffset = pRB->encodedReadOffset; @@ -377,13 +377,13 @@ mal_result mal_rb_seek_read(mal_rb* pRB, size_t offsetInBytes) } mal_atomic_exchange_32(&pRB->encodedReadOffset, mal_rb__construct_offset(newReadOffsetInBytes, newReadOffsetLoopFlag)); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_rb_seek_write(mal_rb* pRB, size_t offsetInBytes) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_uint32 readOffset = pRB->encodedReadOffset; @@ -417,7 +417,7 @@ mal_result mal_rb_seek_write(mal_rb* pRB, size_t offsetInBytes) } mal_atomic_exchange_32(&pRB->encodedWriteOffset, mal_rb__construct_offset(newWriteOffsetInBytes, newWriteOffsetLoopFlag)); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_int32 mal_rb_pointer_distance(mal_rb* pRB) @@ -487,25 +487,25 @@ mal_uint32 mal_pcm_rb_get_bpf(mal_pcm_rb* pRB) mal_result mal_pcm_rb_init_ex(mal_format format, mal_uint32 channels, size_t subbufferSizeInFrames, size_t subbufferCount, size_t subbufferStrideInFrames, void* pOptionalPreallocatedBuffer, mal_pcm_rb* pRB) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_zero_object(pRB); mal_uint32 bpf = mal_get_bytes_per_frame(format, channels); if (bpf == 0) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_result result = mal_rb_init_ex(subbufferSizeInFrames*bpf, subbufferCount, subbufferStrideInFrames*bpf, pOptionalPreallocatedBuffer, &pRB->rb); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } pRB->format = format; pRB->channels = channels; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_pcm_rb_init(mal_format format, mal_uint32 channels, size_t bufferSizeInFrames, void* pOptionalPreallocatedBuffer, mal_pcm_rb* pRB) @@ -528,24 +528,24 @@ mal_result mal_pcm_rb_acquire_read(mal_pcm_rb* pRB, size_t* pSizeInFrames, void* mal_result result; if (pRB == NULL || pSizeInFrames == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } sizeInBytes = *pSizeInFrames * mal_pcm_rb_get_bpf(pRB); result = mal_rb_acquire_read(&pRB->rb, &sizeInBytes, ppBufferOut); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } *pSizeInFrames = sizeInBytes / mal_pcm_rb_get_bpf(pRB); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_pcm_rb_commit_read(mal_pcm_rb* pRB, size_t sizeInFrames, void* pBufferOut) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } return mal_rb_commit_read(&pRB->rb, sizeInFrames * mal_pcm_rb_get_bpf(pRB), pBufferOut); @@ -557,24 +557,24 @@ mal_result mal_pcm_rb_acquire_write(mal_pcm_rb* pRB, size_t* pSizeInFrames, void mal_result result; if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } sizeInBytes = *pSizeInFrames * mal_pcm_rb_get_bpf(pRB); result = mal_rb_acquire_write(&pRB->rb, &sizeInBytes, ppBufferOut); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } *pSizeInFrames = sizeInBytes / mal_pcm_rb_get_bpf(pRB); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result mal_pcm_rb_commit_write(mal_pcm_rb* pRB, size_t sizeInFrames, void* pBufferOut) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } return mal_rb_commit_write(&pRB->rb, sizeInFrames * mal_pcm_rb_get_bpf(pRB), pBufferOut); @@ -583,7 +583,7 @@ mal_result mal_pcm_rb_commit_write(mal_pcm_rb* pRB, size_t sizeInFrames, void* p mal_result mal_pcm_rb_seek_read(mal_pcm_rb* pRB, size_t offsetInFrames) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } return mal_rb_seek_read(&pRB->rb, offsetInFrames * mal_pcm_rb_get_bpf(pRB)); @@ -592,7 +592,7 @@ mal_result mal_pcm_rb_seek_read(mal_pcm_rb* pRB, size_t offsetInFrames) mal_result mal_pcm_rb_seek_write(mal_pcm_rb* pRB, size_t offsetInFrames) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } return mal_rb_seek_write(&pRB->rb, offsetInFrames * mal_pcm_rb_get_bpf(pRB)); @@ -601,7 +601,7 @@ mal_result mal_pcm_rb_seek_write(mal_pcm_rb* pRB, size_t offsetInFrames) mal_int32 mal_pcm_rb_pointer_disance(mal_pcm_rb* pRB) { if (pRB == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } return mal_rb_pointer_distance(&pRB->rb) / mal_pcm_rb_get_bpf(pRB); diff --git a/research/tests/mal_resampler_test_0.c b/research/tests/mal_resampler_test_0.c index eeaf4d16..637d6322 100644 --- a/research/tests/mal_resampler_test_0.c +++ b/research/tests/mal_resampler_test_0.c @@ -1,7 +1,7 @@ #define DR_WAV_IMPLEMENTATION #include "../../../../dr_libs/dr_wav.h" -#define MAL_DEBUG_OUTPUT +#define MA_DEBUG_OUTPUT #define MINIAUDIO_IMPLEMENTATION #include "../../miniaudio.h" #include "../mal_resampler.h" @@ -38,7 +38,7 @@ int main(int argc, char** argv) resamplerConfig.pUserData = NULL; result = mal_resampler_init(&resamplerConfig, &resampler); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize resampler.\n"); return -1; } diff --git a/tests/mal_debug_playback.c b/tests/mal_debug_playback.c index d0519137..d42ad70e 100644 --- a/tests/mal_debug_playback.c +++ b/tests/mal_debug_playback.c @@ -1,12 +1,12 @@ -#define MAL_LOG_LEVEL MAL_LOG_LEVEL_VERBOSE -#define MAL_DEBUG_OUTPUT +#define MA_LOG_LEVEL MA_LOG_LEVEL_VERBOSE +#define MA_DEBUG_OUTPUT #define MINIAUDIO_IMPLEMENTATION #include "../miniaudio.h" int print_context_info(mal_context* pContext) { - mal_result result = MAL_SUCCESS; + mal_result result = MA_SUCCESS; mal_device_info* pPlaybackDeviceInfos; mal_uint32 playbackDeviceCount; mal_device_info* pCaptureDeviceInfos; @@ -18,7 +18,7 @@ int print_context_info(mal_context* pContext) printf(" Enumerating Devices... "); { result = mal_context_get_devices(pContext, &pPlaybackDeviceInfos, &playbackDeviceCount, &pCaptureDeviceInfos, &captureDeviceCount); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { printf("Done\n"); } else { printf("Failed\n"); @@ -44,7 +44,7 @@ int print_context_info(mal_context* pContext) printf(" %d: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name); result = mal_context_get_device_info(pContext, mal_device_type_playback, &pPlaybackDeviceInfos[iDevice].id, mal_share_mode_shared, &pPlaybackDeviceInfos[iDevice]); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { printf(" Name: %s\n", pPlaybackDeviceInfos[iDevice].name); printf(" Min Channels: %d\n", pPlaybackDeviceInfos[iDevice].minChannels); printf(" Max Channels: %d\n", pPlaybackDeviceInfos[iDevice].maxChannels); @@ -64,7 +64,7 @@ int print_context_info(mal_context* pContext) printf(" %d: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name); result = mal_context_get_device_info(pContext, mal_device_type_capture, &pCaptureDeviceInfos[iDevice].id, mal_share_mode_shared, &pCaptureDeviceInfos[iDevice]); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { printf(" Name: %s\n", pCaptureDeviceInfos[iDevice].name); printf(" Min Channels: %d\n", pCaptureDeviceInfos[iDevice].minChannels); printf(" Max Channels: %d\n", pCaptureDeviceInfos[iDevice].maxChannels); @@ -82,7 +82,7 @@ int print_context_info(mal_context* pContext) done: printf("\n"); - return (result == MAL_SUCCESS) ? 0 : -1; + return (result == MA_SUCCESS) ? 0 : -1; } int print_device_info(mal_device* pDevice) @@ -123,7 +123,7 @@ int main(int argc, char** argv) mal_sine_wave sineWave; result = mal_sine_wave_init(0.2, 400, 44100, &sineWave); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize sine wave.\n"); return -1; } @@ -132,7 +132,7 @@ int main(int argc, char** argv) mal_context_config contextConfig = mal_context_config_init(NULL); // <-- Don't need a log callback because we're using debug output instead. mal_context context; result = mal_context_init(NULL, 0, &contextConfig, &context); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize context.\n"); return -1; } @@ -146,7 +146,7 @@ int main(int argc, char** argv) mal_device device; result = mal_device_init(&context, mal_device_type_playback, NULL, &deviceConfig, &sineWave, &device); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { mal_context_uninit(&context); printf("Failed to initialize device.\n"); return -1; @@ -157,7 +157,7 @@ int main(int argc, char** argv) // Start playback. result = mal_device_start(&device); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { mal_device_uninit(&device); mal_context_uninit(&context); printf("Failed to start device.\n"); diff --git a/tests/mal_dithering.c b/tests/mal_dithering.c index 72f1166c..78aa8a70 100644 --- a/tests/mal_dithering.c +++ b/tests/mal_dithering.c @@ -1,5 +1,5 @@ -#define MAL_DEBUG_OUTPUT -#define MAL_USE_REFERENCE_CONVERSION_APIS +#define MA_DEBUG_OUTPUT +#define MA_USE_REFERENCE_CONVERSION_APIS #define MINIAUDIO_IMPLEMENTATION #include "../miniaudio.h" @@ -68,14 +68,14 @@ int do_dithering_test() // We first play the sound the way it's meant to be played. result = mal_device_init(NULL, &config, &device); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return -1; } mal_sine_wave_init(0.5, 400, device.sampleRate, &sineWave); result = mal_device_start(&device); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return -2; } @@ -96,7 +96,7 @@ int do_dithering_test() converterInConfig.onRead = on_convert_samples_in; converterInConfig.pUserData = &sineWave; result = mal_format_converter_init(&converterInConfig, &converterIn); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return -3; } @@ -108,7 +108,7 @@ int do_dithering_test() converterOutConfig.onRead = on_convert_samples_out; converterOutConfig.pUserData = &converterIn; result = mal_format_converter_init(&converterOutConfig, &converterOut); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return -3; } @@ -117,7 +117,7 @@ int do_dithering_test() config.pUserData = &converterOut; result = mal_device_init(NULL, &config, &device); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return -1; } @@ -125,7 +125,7 @@ int do_dithering_test() mal_sine_wave_init(0.5, 400, device.sampleRate, &sineWave); result = mal_device_start(&device); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return -2; } diff --git a/tests/mal_duplex.c b/tests/mal_duplex.c index 56668a7a..2f99daa5 100644 --- a/tests/mal_duplex.c +++ b/tests/mal_duplex.c @@ -1,6 +1,6 @@ #include -#define MAL_DEBUG_OUTPUT +#define MA_DEBUG_OUTPUT #define MINIAUDIO_IMPLEMENTATION #include "../miniaudio.h" @@ -68,7 +68,7 @@ int main(int argc, char** argv) mal_context context; result = mal_context_init(&backend, 1, &contextConfig, &context); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize context.\n"); return result; } @@ -91,7 +91,7 @@ int main(int argc, char** argv) mal_device device; result = mal_device_init(&context, &deviceConfig, &device); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } diff --git a/tests/mal_no_device_io.c b/tests/mal_no_device_io.c index d6435b78..f23f0446 100644 --- a/tests/mal_no_device_io.c +++ b/tests/mal_no_device_io.c @@ -1,10 +1,10 @@ -// Just a simple test to check that MAL_NO_DEVICE_IO compiles. +// Just a simple test to check that MA_NO_DEVICE_IO compiles. #include "../extras/dr_flac.h" #include "../extras/dr_mp3.h" #include "../extras/dr_wav.h" -#define MAL_NO_DEVICE_IO +#define MA_NO_DEVICE_IO #define MINIAUDIO_IMPLEMENTATION #include "../miniaudio.h" @@ -13,7 +13,7 @@ int main(int argc, char** argv) (void)argc; (void)argv; - mal_result result = MAL_ERROR; + mal_result result = MA_ERROR; mal_pcm_converter_config dspConfig = mal_pcm_converter_config_init_new(); mal_pcm_converter converter; diff --git a/tests/mal_profiling.c b/tests/mal_profiling.c index 4732e0e2..a0b49302 100644 --- a/tests/mal_profiling.c +++ b/tests/mal_profiling.c @@ -196,7 +196,7 @@ void pcm_convert__optimized(void* pOut, mal_format formatOut, const void* pIn, m } } -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) void pcm_convert__sse2(void* pOut, mal_format formatOut, const void* pIn, mal_format formatIn, mal_uint64 sampleCount, mal_dither_mode ditherMode) { switch (formatIn) @@ -266,7 +266,7 @@ void pcm_convert__sse2(void* pOut, mal_format formatOut, const void* pIn, mal_fo } #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) void pcm_convert__avx(void* pOut, mal_format formatOut, const void* pIn, mal_format formatIn, mal_uint64 sampleCount, mal_dither_mode ditherMode) { switch (formatIn) @@ -336,7 +336,7 @@ void pcm_convert__avx(void* pOut, mal_format formatOut, const void* pIn, mal_for } #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) void pcm_convert__avx512(void* pOut, mal_format formatOut, const void* pIn, mal_format formatIn, mal_uint64 sampleCount, mal_dither_mode ditherMode) { switch (formatIn) @@ -406,7 +406,7 @@ void pcm_convert__avx512(void* pOut, mal_format formatOut, const void* pIn, mal_ } #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) void pcm_convert__neon(void* pOut, mal_format formatOut, const void* pIn, mal_format formatIn, mal_uint64 sampleCount, mal_dither_mode ditherMode) { switch (formatIn) @@ -488,28 +488,28 @@ void pcm_convert(void* pOut, mal_format formatOut, const void* pIn, mal_format f pcm_convert__optimized(pOut, formatOut, pIn, formatIn, sampleCount, ditherMode); } break; -#if defined(MAL_SUPPORT_SSE2) +#if defined(MA_SUPPORT_SSE2) case simd_mode_sse2: { pcm_convert__sse2(pOut, formatOut, pIn, formatIn, sampleCount, ditherMode); } break; #endif -#if defined(MAL_SUPPORT_AVX2) +#if defined(MA_SUPPORT_AVX2) case simd_mode_avx2: { pcm_convert__avx(pOut, formatOut, pIn, formatIn, sampleCount, ditherMode); } break; #endif -#if defined(MAL_SUPPORT_AVX512) +#if defined(MA_SUPPORT_AVX512) case simd_mode_avx512: { pcm_convert__avx512(pOut, formatOut, pIn, formatIn, sampleCount, ditherMode); } break; #endif -#if defined(MAL_SUPPORT_NEON) +#if defined(MA_SUPPORT_NEON) case simd_mode_neon: { pcm_convert__neon(pOut, formatOut, pIn, formatIn, sampleCount, ditherMode); @@ -523,7 +523,7 @@ void pcm_convert(void* pOut, mal_format formatOut, const void* pIn, mal_format f int do_profiling__format_conversion__profile_individual(mal_format formatIn, mal_format formatOut, mal_dither_mode ditherMode, const void* pBaseData, mal_uint64 sampleCount, simd_mode mode, const void* pReferenceData, double referenceTime) { - void* pTestData = mal_aligned_malloc((size_t)(sampleCount * mal_get_bytes_per_sample(formatOut)), MAL_SIMD_ALIGNMENT); + void* pTestData = mal_aligned_malloc((size_t)(sampleCount * mal_get_bytes_per_sample(formatOut)), MA_SIMD_ALIGNMENT); if (pTestData == NULL) { printf("Out of memory.\n"); return -1; @@ -539,7 +539,7 @@ int do_profiling__format_conversion__profile_individual(mal_format formatIn, mal // Compare with the reference for correctness. - mal_bool32 passed = MAL_TRUE; + mal_bool32 passed = MA_TRUE; for (mal_uint64 iSample = 0; iSample < sampleCount; ++iSample) { mal_uint32 bps = mal_get_bytes_per_sample(formatOut); @@ -552,7 +552,7 @@ int do_profiling__format_conversion__profile_individual(mal_format formatIn, mal mal_int16 b = ((const mal_int16*)pTestData)[iSample]; if (abs(a-b) > 0) { printf("Incorrect Sample: (%d) %d != %d\n", (int)iSample, a, b); - passed = MAL_FALSE; + passed = MA_FALSE; } } break; @@ -560,7 +560,7 @@ int do_profiling__format_conversion__profile_individual(mal_format formatIn, mal { if (memcmp(mal_offset_ptr(pReferenceData, iSample*bps), mal_offset_ptr(pTestData, iSample*bps), bps) != 0) { printf("Incorrect Sample: (%d)\n", (int)iSample); - passed = MAL_FALSE; + passed = MA_FALSE; } } break; } @@ -582,7 +582,7 @@ int do_profiling__format_conversion__profile_set(mal_format formatIn, mal_format // Generate our base data to begin with. This is generated from an f32 sine wave which is converted to formatIn. That then becomes our base data. mal_uint32 sampleCount = 10000000; - float* pSourceData = (float*)mal_aligned_malloc(sampleCount*sizeof(*pSourceData), MAL_SIMD_ALIGNMENT); + float* pSourceData = (float*)mal_aligned_malloc(sampleCount*sizeof(*pSourceData), MA_SIMD_ALIGNMENT); if (pSourceData == NULL) { printf("Out of memory.\n"); return -1; @@ -592,12 +592,12 @@ int do_profiling__format_conversion__profile_set(mal_format formatIn, mal_format mal_sine_wave_init(1.0, 400, 48000, &sineWave); mal_sine_wave_read_f32(&sineWave, sampleCount, pSourceData); - void* pBaseData = mal_aligned_malloc(sampleCount * mal_get_bytes_per_sample(formatIn), MAL_SIMD_ALIGNMENT); + void* pBaseData = mal_aligned_malloc(sampleCount * mal_get_bytes_per_sample(formatIn), MA_SIMD_ALIGNMENT); mal_pcm_convert(pBaseData, formatIn, pSourceData, mal_format_f32, sampleCount, mal_dither_mode_none); // Reference first so we can get a benchmark. - void* pReferenceData = mal_aligned_malloc(sampleCount * mal_get_bytes_per_sample(formatOut), MAL_SIMD_ALIGNMENT); + void* pReferenceData = mal_aligned_malloc(sampleCount * mal_get_bytes_per_sample(formatOut), MA_SIMD_ALIGNMENT); mal_timer timer; mal_timer_init(&timer); double referenceTime = mal_timer_get_time_in_seconds(&timer); @@ -664,12 +664,12 @@ mal_bool32 channel_router_test(mal_uint32 channels, mal_uint64 frameCount, float for (mal_uint32 iChannel = 0; iChannel < channels; ++iChannel) { for (mal_uint32 iFrame = 0; iFrame < frameCount; ++iFrame) { if (ppFramesA[iChannel][iFrame] != ppFramesB[iChannel][iFrame]) { - return MAL_FALSE; + return MA_FALSE; } } } - return MAL_TRUE; + return MA_TRUE; } mal_uint32 channel_router_on_read(mal_channel_router* pRouter, mal_uint32 frameCount, void** ppSamplesOut, void* pUserData) @@ -694,26 +694,26 @@ int do_profiling__channel_routing() // When profiling we need to compare against a benchmark to ensure the optimization is implemented correctly. We always // use the reference implementation for our benchmark. mal_uint32 channels = mal_countof(g_ChannelRouterProfilingOutputBenchmark); - mal_channel channelMapIn[MAL_MAX_CHANNELS]; + mal_channel channelMapIn[MA_MAX_CHANNELS]; mal_get_standard_channel_map(mal_standard_channel_map_default, channels, channelMapIn); - mal_channel channelMapOut[MAL_MAX_CHANNELS]; + mal_channel channelMapOut[MA_MAX_CHANNELS]; mal_get_standard_channel_map(mal_standard_channel_map_default, channels, channelMapOut); mal_channel_router_config routerConfig = mal_channel_router_config_init(channels, channelMapIn, channels, channelMapOut, mal_channel_mix_mode_planar_blend, channel_router_on_read, NULL); mal_channel_router router; result = mal_channel_router_init(&routerConfig, &router); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return -1; } // Disable optimizations for our tests. - router.isPassthrough = MAL_FALSE; - router.isSimpleShuffle = MAL_FALSE; - router.useSSE2 = MAL_FALSE; - router.useAVX2 = MAL_FALSE; - router.useAVX512 = MAL_FALSE; - router.useNEON = MAL_FALSE; + router.isPassthrough = MA_FALSE; + router.isSimpleShuffle = MA_FALSE; + router.useSSE2 = MA_FALSE; + router.useAVX2 = MA_FALSE; + router.useAVX512 = MA_FALSE; + router.useNEON = MA_FALSE; mal_uint64 framesToRead = mal_countof(g_ChannelRouterProfilingOutputBenchmark[0]); @@ -761,7 +761,7 @@ int do_profiling__channel_routing() // SSE2 if (mal_has_sse2()) { - router.useSSE2 = MAL_TRUE; + router.useSSE2 = MA_TRUE; mal_timer timer; mal_timer_init(&timer); double startTime = mal_timer_get_time_in_seconds(&timer); @@ -772,7 +772,7 @@ int do_profiling__channel_routing() } g_ChannelRouterTime_SSE2 = mal_timer_get_time_in_seconds(&timer) - startTime; - router.useSSE2 = MAL_FALSE; + router.useSSE2 = MA_FALSE; if (!channel_router_test(channels, framesRead, (float**)ppOutBenchmark, (float**)ppOut)) { printf(" [ERROR] "); @@ -785,7 +785,7 @@ int do_profiling__channel_routing() // AVX2 if (mal_has_avx2()) { - router.useAVX2 = MAL_TRUE; + router.useAVX2 = MA_TRUE; mal_timer timer; mal_timer_init(&timer); double startTime = mal_timer_get_time_in_seconds(&timer); @@ -796,7 +796,7 @@ int do_profiling__channel_routing() } g_ChannelRouterTime_AVX2 = mal_timer_get_time_in_seconds(&timer) - startTime; - router.useAVX2 = MAL_FALSE; + router.useAVX2 = MA_FALSE; if (!channel_router_test(channels, framesRead, (float**)ppOutBenchmark, (float**)ppOut)) { printf(" [ERROR] "); @@ -809,7 +809,7 @@ int do_profiling__channel_routing() // NEON if (mal_has_neon()) { - router.useNEON = MAL_TRUE; + router.useNEON = MA_TRUE; mal_timer timer; mal_timer_init(&timer); double startTime = mal_timer_get_time_in_seconds(&timer); @@ -820,7 +820,7 @@ int do_profiling__channel_routing() } g_ChannelRouterTime_NEON = mal_timer_get_time_in_seconds(&timer) - startTime; - router.useNEON = MAL_FALSE; + router.useNEON = MA_FALSE; if (!channel_router_test(channels, framesRead, (float**)ppOutBenchmark, (float**)ppOut)) { printf(" [ERROR] "); @@ -843,7 +843,7 @@ int do_profiling__channel_routing() typedef struct { - float* pFrameData[MAL_MAX_CHANNELS]; + float* pFrameData[MA_MAX_CHANNELS]; mal_uint64 frameCount; mal_uint32 channels; double timeTaken; @@ -851,7 +851,7 @@ typedef struct typedef struct { - float* pFrameData[MAL_MAX_CHANNELS]; + float* pFrameData[MA_MAX_CHANNELS]; mal_uint64 frameCount; mal_uint64 iNextFrame; mal_uint32 channels; @@ -888,21 +888,21 @@ mal_result init_src(src_data* pBaseData, mal_uint32 sampleRateIn, mal_uint32 sam mal_src_config srcConfig = mal_src_config_init(sampleRateIn, sampleRateOut, pBaseData->channels, do_profiling__src__on_read, pBaseData); srcConfig.sinc.windowWidth = 17; // <-- Make this an odd number to test unaligned section in the SIMD implementations. srcConfig.algorithm = algorithm; - srcConfig.noSSE2 = MAL_TRUE; - srcConfig.noAVX2 = MAL_TRUE; - srcConfig.noAVX512 = MAL_TRUE; - srcConfig.noNEON = MAL_TRUE; + srcConfig.noSSE2 = MA_TRUE; + srcConfig.noAVX2 = MA_TRUE; + srcConfig.noAVX512 = MA_TRUE; + srcConfig.noNEON = MA_TRUE; switch (mode) { - case simd_mode_sse2: srcConfig.noSSE2 = MAL_FALSE; break; - case simd_mode_avx2: srcConfig.noAVX2 = MAL_FALSE; break; - case simd_mode_avx512: srcConfig.noAVX512 = MAL_FALSE; break; - case simd_mode_neon: srcConfig.noNEON = MAL_FALSE; break; + case simd_mode_sse2: srcConfig.noSSE2 = MA_FALSE; break; + case simd_mode_avx2: srcConfig.noAVX2 = MA_FALSE; break; + case simd_mode_avx512: srcConfig.noAVX512 = MA_FALSE; break; + case simd_mode_neon: srcConfig.noNEON = MA_FALSE; break; case simd_mode_scalar: default: break; } mal_result result = mal_src_init(&srcConfig, pSRC); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize sample rate converter.\n"); return (int)result; } @@ -915,14 +915,14 @@ int do_profiling__src__profile_individual(src_data* pBaseData, mal_uint32 sample mal_assert(pBaseData != NULL); mal_assert(pReferenceData != NULL); - mal_result result = MAL_ERROR; + mal_result result = MA_ERROR; // Make sure the base data is moved back to the start. pBaseData->iNextFrame = 0; mal_src src; result = init_src(pBaseData, sampleRateIn, sampleRateOut, algorithm, mode, &src); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return (int)result; } @@ -931,9 +931,9 @@ int do_profiling__src__profile_individual(src_data* pBaseData, mal_uint32 sample mal_uint64 sz = pReferenceData->frameCount * sizeof(float); mal_assert(sz <= SIZE_MAX); - float* pFrameData[MAL_MAX_CHANNELS]; + float* pFrameData[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < pBaseData->channels; iChannel += 1) { - pFrameData[iChannel] = (float*)mal_aligned_malloc((size_t)sz, MAL_SIMD_ALIGNMENT); + pFrameData[iChannel] = (float*)mal_aligned_malloc((size_t)sz, MA_SIMD_ALIGNMENT); if (pFrameData[iChannel] == NULL) { printf("Out of memory.\n"); return -2; @@ -951,7 +951,7 @@ int do_profiling__src__profile_individual(src_data* pBaseData, mal_uint32 sample // Correctness test. - mal_bool32 passed = MAL_TRUE; + mal_bool32 passed = MA_TRUE; for (mal_uint32 iChannel = 0; iChannel < pReferenceData->channels; iChannel += 1) { for (mal_uint32 iFrame = 0; iFrame < pReferenceData->frameCount; iFrame += 1) { float s0 = pReferenceData->pFrameData[iChannel][iFrame]; @@ -959,7 +959,7 @@ int do_profiling__src__profile_individual(src_data* pBaseData, mal_uint32 sample //if (s0 != s1) { if (fabs(s0 - s1) > 0.000001) { printf("(Channel %d, Sample %d) %f != %f\n", iChannel, iFrame, s0, s1); - passed = MAL_FALSE; + passed = MA_FALSE; } } } @@ -1004,7 +1004,7 @@ int do_profiling__src__profile_set(src_data* pBaseData, mal_uint32 sampleRateIn, mal_assert(sz <= SIZE_MAX); for (mal_uint32 iChannel = 0; iChannel < referenceData.channels; iChannel += 1) { - referenceData.pFrameData[iChannel] = (float*)mal_aligned_malloc((size_t)sz, MAL_SIMD_ALIGNMENT); + referenceData.pFrameData[iChannel] = (float*)mal_aligned_malloc((size_t)sz, MA_SIMD_ALIGNMENT); if (referenceData.pFrameData[iChannel] == NULL) { printf("Out of memory.\n"); return -2; @@ -1016,7 +1016,7 @@ int do_profiling__src__profile_set(src_data* pBaseData, mal_uint32 sampleRateIn, // Generate the reference data. mal_src src; mal_result result = init_src(pBaseData, sampleRateIn, sampleRateOut, algorithm, simd_mode_scalar, &src); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return (int)result; } @@ -1063,7 +1063,7 @@ int do_profiling__src() baseData.channels = 8; baseData.frameCount = 100000; for (mal_uint32 iChannel = 0; iChannel < baseData.channels; ++iChannel) { - baseData.pFrameData[iChannel] = (float*)mal_aligned_malloc((size_t)(baseData.frameCount * sizeof(float)), MAL_SIMD_ALIGNMENT); + baseData.pFrameData[iChannel] = (float*)mal_aligned_malloc((size_t)(baseData.frameCount * sizeof(float)), MA_SIMD_ALIGNMENT); if (baseData.pFrameData[iChannel] == NULL) { printf("Out of memory.\n"); return -1; diff --git a/tests/mal_resampling.c b/tests/mal_resampling.c index b0e3947e..abb4d8c0 100644 --- a/tests/mal_resampling.c +++ b/tests/mal_resampling.c @@ -1,8 +1,8 @@ // We're using sigvis for visualizations. This will include miniaudio for us, so no need to include miniaudio in this file. #define NO_SIGVIS -#define MAL_NO_SSE2 -#define MAL_NO_AVX2 +#define MA_NO_SSE2 +#define MA_NO_AVX2 #ifdef NO_SIGVIS #define MINIAUDIO_IMPLEMENTATION @@ -117,7 +117,7 @@ int main(int argc, char** argv) // We first play the sound the way it's meant to be played. result = mal_device_init(NULL, &config, &device); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return -1; } @@ -129,10 +129,10 @@ int main(int argc, char** argv) mal_src_config srcConfig = mal_src_config_init(sampleRateIn, sampleRateOut, 1, on_src, NULL); srcConfig.algorithm = mal_src_algorithm_sinc; - srcConfig.neverConsumeEndOfInput = MAL_TRUE; + srcConfig.neverConsumeEndOfInput = MA_TRUE; result = mal_src_init(&srcConfig, &src); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to create SRC.\n"); return -1; } @@ -142,14 +142,14 @@ int main(int argc, char** argv) #ifndef NO_SIGVIS msigvis_context sigvis; result = msigvis_init(&sigvis); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize mini_sigvis context.\n"); return -1; } msigvis_screen screen; result = msigvis_screen_init(&sigvis, 1280, 720, &screen); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize mini_sigvis screen.\n"); return -2; } @@ -159,7 +159,7 @@ int main(int argc, char** argv) msigvis_channel channelSineWave; result = msigvis_channel_init(&sigvis, mal_format_f32, sampleRateOut, &channelSineWave); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize mini_sigvis channel.\n"); return -3; } @@ -198,7 +198,7 @@ int main(int argc, char** argv) #else result = mal_device_start(&device); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return -2; } diff --git a/tests/mal_stop.c b/tests/mal_stop.c index f83637b9..83e514fc 100644 --- a/tests/mal_stop.c +++ b/tests/mal_stop.c @@ -6,7 +6,7 @@ mal_sine_wave sineWave; mal_uint32 framesWritten; mal_event stopEvent; -mal_bool32 isInitialRun = MAL_TRUE; +mal_bool32 isInitialRun = MA_TRUE; void on_stop(mal_device* pDevice) { @@ -35,7 +35,7 @@ void on_data(mal_device* pDevice, void* pOutput, const void* pInput, mal_uint32 if (isInitialRun) { printf("STOPPING [AUDIO THREAD]...\n"); mal_event_signal(&stopEvent); - isInitialRun = MAL_FALSE; + isInitialRun = MA_FALSE; } } } @@ -61,13 +61,13 @@ int main(int argc, char** argv) mal_device device; result = mal_device_init_ex(&backend, 1, NULL, &config, &device); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize device.\n"); return result; } result = mal_event_init(device.pContext, &stopEvent); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize stop event.\n"); return result; } @@ -84,7 +84,7 @@ int main(int argc, char** argv) getchar(); result = mal_device_start(&device); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to restart the device.\n"); mal_device_uninit(&device); return -1; diff --git a/tests/mal_test_0.c b/tests/mal_test_0.c index 5e1dface..2ca4fbe2 100644 --- a/tests/mal_test_0.c +++ b/tests/mal_test_0.c @@ -1,16 +1,16 @@ // Uncomment this to include Vorbis decoding tests, albeit with some annoying warnings with MinGW. -//#define MAL_INCLUDE_VORBIS_TESTS +//#define MA_INCLUDE_VORBIS_TESTS #include "../extras/dr_flac.h" #include "../extras/dr_mp3.h" #include "../extras/dr_wav.h" -#ifdef MAL_INCLUDE_VORBIS_TESTS +#ifdef MA_INCLUDE_VORBIS_TESTS #define STB_VORBIS_HEADER_ONLY #include "../extras/stb_vorbis.c" #endif -//#define MAL_DEBUG_OUTPUT +//#define MA_DEBUG_OUTPUT #define MINIAUDIO_IMPLEMENTATION #include "../miniaudio.h" @@ -88,7 +88,7 @@ void* open_and_read_file_data(const char* filePath, size_t* pSizeOut) mal_uint64 fileSize = ftell(pFile); fseek(pFile, 0, SEEK_SET); - if (fileSize > MAL_SIZE_MAX) { + if (fileSize > MA_SIZE_MAX) { fclose(pFile); return NULL; } @@ -225,7 +225,7 @@ int do_aligned_malloc_tests() // We just do a whole bunch of malloc's and check them. This can probably be made more exhaustive. void* p[1024]; for (mal_uint32 i = 0; i < mal_countof(p); ++i) { - mal_uintptr alignment = MAL_SIMD_ALIGNMENT; + mal_uintptr alignment = MA_SIMD_ALIGNMENT; p[i] = mal_aligned_malloc(1024, alignment); if (((mal_uintptr)p[i] & (alignment-1)) != 0) { @@ -597,7 +597,7 @@ int do_format_conversion_test(mal_format formatIn, mal_format formatOut) // We need to allow a very small amount of difference to each sample because the software that generated our testing benchmarks can use slightly // different (but still correct) algorithms which produce slightly different results. I'm allowing for this variability in my basic comparison // tests, but testing things like dithering will require more detailed testing which I'll probably do separate to this test project. - mal_bool32 allowSmallDifference = MAL_TRUE; + mal_bool32 allowSmallDifference = MA_TRUE; float allowedDifference = 0; if (allowSmallDifference) { if (formatOut == mal_format_f32) { @@ -863,11 +863,11 @@ int do_interleaving_test(mal_format format) { case mal_format_u8: { - mal_uint8 src [MAL_MAX_CHANNELS][64]; - mal_uint8 dst [MAL_MAX_CHANNELS][64]; - mal_uint8 dsti[MAL_MAX_CHANNELS*64]; - void* ppSrc[MAL_MAX_CHANNELS]; - void* ppDst[MAL_MAX_CHANNELS]; + mal_uint8 src [MA_MAX_CHANNELS][64]; + mal_uint8 dst [MA_MAX_CHANNELS][64]; + mal_uint8 dsti[MA_MAX_CHANNELS*64]; + void* ppSrc[MA_MAX_CHANNELS]; + void* ppDst[MA_MAX_CHANNELS]; mal_uint32 frameCount = mal_countof(src[0]); mal_uint32 channelCount = mal_countof(src); @@ -904,11 +904,11 @@ int do_interleaving_test(mal_format format) case mal_format_s16: { - mal_int16 src [MAL_MAX_CHANNELS][64]; - mal_int16 dst [MAL_MAX_CHANNELS][64]; - mal_int16 dsti[MAL_MAX_CHANNELS*64]; - void* ppSrc[MAL_MAX_CHANNELS]; - void* ppDst[MAL_MAX_CHANNELS]; + mal_int16 src [MA_MAX_CHANNELS][64]; + mal_int16 dst [MA_MAX_CHANNELS][64]; + mal_int16 dsti[MA_MAX_CHANNELS*64]; + void* ppSrc[MA_MAX_CHANNELS]; + void* ppDst[MA_MAX_CHANNELS]; mal_uint32 frameCount = mal_countof(src[0]); mal_uint32 channelCount = mal_countof(src); @@ -945,11 +945,11 @@ int do_interleaving_test(mal_format format) case mal_format_s24: { - mal_uint8 src [MAL_MAX_CHANNELS][64*3]; - mal_uint8 dst [MAL_MAX_CHANNELS][64*3]; - mal_uint8 dsti[MAL_MAX_CHANNELS*64*3]; - void* ppSrc[MAL_MAX_CHANNELS]; - void* ppDst[MAL_MAX_CHANNELS]; + mal_uint8 src [MA_MAX_CHANNELS][64*3]; + mal_uint8 dst [MA_MAX_CHANNELS][64*3]; + mal_uint8 dsti[MA_MAX_CHANNELS*64*3]; + void* ppSrc[MA_MAX_CHANNELS]; + void* ppDst[MA_MAX_CHANNELS]; mal_uint32 frameCount = mal_countof(src[0])/3; mal_uint32 channelCount = mal_countof(src); @@ -988,11 +988,11 @@ int do_interleaving_test(mal_format format) case mal_format_s32: { - mal_int32 src [MAL_MAX_CHANNELS][64]; - mal_int32 dst [MAL_MAX_CHANNELS][64]; - mal_int32 dsti[MAL_MAX_CHANNELS*64]; - void* ppSrc[MAL_MAX_CHANNELS]; - void* ppDst[MAL_MAX_CHANNELS]; + mal_int32 src [MA_MAX_CHANNELS][64]; + mal_int32 dst [MA_MAX_CHANNELS][64]; + mal_int32 dsti[MA_MAX_CHANNELS*64]; + void* ppSrc[MA_MAX_CHANNELS]; + void* ppDst[MA_MAX_CHANNELS]; mal_uint32 frameCount = mal_countof(src[0]); mal_uint32 channelCount = mal_countof(src); @@ -1029,11 +1029,11 @@ int do_interleaving_test(mal_format format) case mal_format_f32: { - float src [MAL_MAX_CHANNELS][64]; - float dst [MAL_MAX_CHANNELS][64]; - float dsti[MAL_MAX_CHANNELS*64]; - void* ppSrc[MAL_MAX_CHANNELS]; - void* ppDst[MAL_MAX_CHANNELS]; + float src [MA_MAX_CHANNELS][64]; + float dst [MA_MAX_CHANNELS][64]; + float dsti[MA_MAX_CHANNELS*64]; + void* ppSrc[MA_MAX_CHANNELS]; + void* ppDst[MA_MAX_CHANNELS]; mal_uint32 frameCount = mal_countof(src[0]); mal_uint32 channelCount = mal_countof(src); @@ -1156,7 +1156,7 @@ int do_format_converter_tests() double periodsPerSecond = 400; mal_uint32 sampleRate = 48000; - mal_result result = MAL_SUCCESS; + mal_result result = MA_SUCCESS; mal_sine_wave sineWave; mal_format_converter converter; @@ -1179,12 +1179,12 @@ int do_format_converter_tests() { mal_sine_wave_init(amplitude, periodsPerSecond, sampleRate, &sineWave); result = mal_format_converter_init(&config, &converter); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize converter.\n"); return -1; } - mal_int16 interleavedFrames[MAL_MAX_CHANNELS * 1024]; + mal_int16 interleavedFrames[MA_MAX_CHANNELS * 1024]; mal_uint64 framesRead = mal_format_converter_read(&converter, 1024, interleavedFrames, converter.config.pUserData); if (framesRead != 1024) { printf("Failed to read interleaved data from converter.\n"); @@ -1205,13 +1205,13 @@ int do_format_converter_tests() { mal_sine_wave_init(amplitude, periodsPerSecond, sampleRate, &sineWave); result = mal_format_converter_init(&config, &converter); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize converter.\n"); return -1; } - mal_int16 deinterleavedFrames[MAL_MAX_CHANNELS][1024]; - void* ppDeinterleavedFrames[MAL_MAX_CHANNELS]; + mal_int16 deinterleavedFrames[MA_MAX_CHANNELS][1024]; + void* ppDeinterleavedFrames[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < converter.config.channels; iChannel += 1) { ppDeinterleavedFrames[iChannel] = &deinterleavedFrames[iChannel]; } @@ -1246,12 +1246,12 @@ int do_format_converter_tests() { mal_sine_wave_init(amplitude, periodsPerSecond, sampleRate, &sineWave); result = mal_format_converter_init(&config, &converter); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize converter.\n"); return -1; } - mal_int16 interleavedFrames[MAL_MAX_CHANNELS * 1024]; + mal_int16 interleavedFrames[MA_MAX_CHANNELS * 1024]; mal_uint64 framesRead = mal_format_converter_read(&converter, 1024, interleavedFrames, converter.config.pUserData); if (framesRead != 1024) { printf("Failed to read interleaved data from converter.\n"); @@ -1272,13 +1272,13 @@ int do_format_converter_tests() { mal_sine_wave_init(amplitude, periodsPerSecond, sampleRate, &sineWave); result = mal_format_converter_init(&config, &converter); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize converter.\n"); return -1; } - mal_int16 deinterleavedFrames[MAL_MAX_CHANNELS][1024]; - void* ppDeinterleavedFrames[MAL_MAX_CHANNELS]; + mal_int16 deinterleavedFrames[MA_MAX_CHANNELS][1024]; + void* ppDeinterleavedFrames[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < converter.config.channels; iChannel += 1) { ppDeinterleavedFrames[iChannel] = &deinterleavedFrames[iChannel]; } @@ -1314,12 +1314,12 @@ int do_format_converter_tests() { mal_sine_wave_init(amplitude, periodsPerSecond, sampleRate, &sineWave); result = mal_format_converter_init(&config, &converter); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize converter.\n"); return -1; } - float interleavedFrames[MAL_MAX_CHANNELS * 1024]; + float interleavedFrames[MA_MAX_CHANNELS * 1024]; mal_uint64 framesRead = mal_format_converter_read(&converter, 1024, interleavedFrames, converter.config.pUserData); if (framesRead != 1024) { printf("Failed to read interleaved data from converter.\n"); @@ -1340,13 +1340,13 @@ int do_format_converter_tests() { mal_sine_wave_init(amplitude, periodsPerSecond, sampleRate, &sineWave); result = mal_format_converter_init(&config, &converter); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize converter.\n"); return -1; } - float deinterleavedFrames[MAL_MAX_CHANNELS][1024]; - void* ppDeinterleavedFrames[MAL_MAX_CHANNELS]; + float deinterleavedFrames[MA_MAX_CHANNELS][1024]; + void* ppDeinterleavedFrames[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < converter.config.channels; iChannel += 1) { ppDeinterleavedFrames[iChannel] = &deinterleavedFrames[iChannel]; } @@ -1381,12 +1381,12 @@ int do_format_converter_tests() { mal_sine_wave_init(amplitude, periodsPerSecond, sampleRate, &sineWave); result = mal_format_converter_init(&config, &converter); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize converter.\n"); return -1; } - float interleavedFrames[MAL_MAX_CHANNELS * 1024]; + float interleavedFrames[MA_MAX_CHANNELS * 1024]; mal_uint64 framesRead = mal_format_converter_read(&converter, 1024, interleavedFrames, converter.config.pUserData); if (framesRead != 1024) { printf("Failed to read interleaved data from converter.\n"); @@ -1407,13 +1407,13 @@ int do_format_converter_tests() { mal_sine_wave_init(amplitude, periodsPerSecond, sampleRate, &sineWave); result = mal_format_converter_init(&config, &converter); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to initialize converter.\n"); return -1; } - float deinterleavedFrames[MAL_MAX_CHANNELS][1024]; - void* ppDeinterleavedFrames[MAL_MAX_CHANNELS]; + float deinterleavedFrames[MA_MAX_CHANNELS][1024]; + void* ppDeinterleavedFrames[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < converter.config.channels; iChannel += 1) { ppDeinterleavedFrames[iChannel] = &deinterleavedFrames[iChannel]; } @@ -1460,7 +1460,7 @@ mal_uint32 channel_router_callback__passthrough_test(mal_channel_router* pRouter int do_channel_routing_tests() { - mal_bool32 hasError = MAL_FALSE; + mal_bool32 hasError = MA_FALSE; printf("Passthrough... "); { @@ -1471,19 +1471,19 @@ int do_channel_routing_tests() routerConfig.mixingMode = mal_channel_mix_mode_planar_blend; routerConfig.channelsIn = 6; routerConfig.channelsOut = routerConfig.channelsIn; - routerConfig.noSSE2 = MAL_TRUE; - routerConfig.noAVX2 = MAL_TRUE; - routerConfig.noAVX512 = MAL_TRUE; - routerConfig.noNEON = MAL_TRUE; + routerConfig.noSSE2 = MA_TRUE; + routerConfig.noAVX2 = MA_TRUE; + routerConfig.noAVX512 = MA_TRUE; + routerConfig.noNEON = MA_TRUE; mal_get_standard_channel_map(mal_standard_channel_map_microsoft, routerConfig.channelsIn, routerConfig.channelMapIn); mal_get_standard_channel_map(mal_standard_channel_map_microsoft, routerConfig.channelsOut, routerConfig.channelMapOut); mal_channel_router router; mal_result result = mal_channel_router_init(&routerConfig, &router); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { if (!router.isPassthrough) { printf("Failed to init router as passthrough.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } // Expecting the weights to all be equal to 1 for each channel. @@ -1496,21 +1496,21 @@ int do_channel_routing_tests() if (router.config.weights[iChannelIn][iChannelOut] != expectedWeight) { printf("Failed. Channel weight incorrect: %f\n", expectedWeight); - hasError = MAL_TRUE; + hasError = MA_TRUE; } } } } else { printf("Failed to init router.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } // Here is where we check that the passthrough optimization works correctly. What we do is compare the output of the passthrough // optimization with the non-passthrough output. We don't use a real sound here, but instead use values that makes it easier for // us to check results. Each channel is given a value equal to it's index, plus 1. - float testData[MAL_MAX_CHANNELS][MAL_SIMD_ALIGNMENT * 2]; - float* ppTestData[MAL_MAX_CHANNELS]; + float testData[MA_MAX_CHANNELS][MA_SIMD_ALIGNMENT * 2]; + float* ppTestData[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < routerConfig.channelsIn; ++iChannel) { ppTestData[iChannel] = testData[iChannel]; for (mal_uint32 iFrame = 0; iFrame < mal_countof(testData[0]); ++iFrame) { @@ -1521,10 +1521,10 @@ int do_channel_routing_tests() routerConfig.pUserData = ppTestData; mal_channel_router_init(&routerConfig, &router); - MAL_ALIGN(MAL_SIMD_ALIGNMENT) float outputA[MAL_MAX_CHANNELS][MAL_SIMD_ALIGNMENT * 2]; - MAL_ALIGN(MAL_SIMD_ALIGNMENT) float outputB[MAL_MAX_CHANNELS][MAL_SIMD_ALIGNMENT * 2]; - float* ppOutputA[MAL_MAX_CHANNELS]; - float* ppOutputB[MAL_MAX_CHANNELS]; + MA_ALIGN(MA_SIMD_ALIGNMENT) float outputA[MA_MAX_CHANNELS][MA_SIMD_ALIGNMENT * 2]; + MA_ALIGN(MA_SIMD_ALIGNMENT) float outputB[MA_MAX_CHANNELS][MA_SIMD_ALIGNMENT * 2]; + float* ppOutputA[MA_MAX_CHANNELS]; + float* ppOutputB[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < routerConfig.channelsOut; ++iChannel) { ppOutputA[iChannel] = outputA[iChannel]; ppOutputB[iChannel] = outputB[iChannel]; @@ -1534,16 +1534,16 @@ int do_channel_routing_tests() mal_uint64 framesRead = mal_channel_router_read_deinterleaved(&router, mal_countof(outputA[0]), (void**)ppOutputA, router.config.pUserData); if (framesRead != mal_countof(outputA[0])) { printf("Returned frame count for optimized incorrect."); - hasError = MAL_TRUE; + hasError = MA_TRUE; } // Without optimizations. - router.isPassthrough = MAL_FALSE; - router.isSimpleShuffle = MAL_FALSE; + router.isPassthrough = MA_FALSE; + router.isSimpleShuffle = MA_FALSE; framesRead = mal_channel_router_read_deinterleaved(&router, mal_countof(outputA[0]), (void**)ppOutputB, router.config.pUserData); if (framesRead != mal_countof(outputA[0])) { printf("Returned frame count for unoptimized path incorrect."); - hasError = MAL_TRUE; + hasError = MA_TRUE; } // Compare. @@ -1551,7 +1551,7 @@ int do_channel_routing_tests() for (mal_uint32 iFrame = 0; iFrame < mal_countof(outputA[0]); ++iFrame) { if (ppOutputA[iChannel][iFrame] != ppOutputB[iChannel][iFrame]) { printf("Sample incorrect [%d][%d]\n", iChannel, iFrame); - hasError = MAL_TRUE; + hasError = MA_TRUE; } } } @@ -1574,10 +1574,10 @@ int do_channel_routing_tests() routerConfig.mixingMode = mal_channel_mix_mode_planar_blend; routerConfig.channelsIn = 6; routerConfig.channelsOut = routerConfig.channelsIn; - routerConfig.noSSE2 = MAL_TRUE; - routerConfig.noAVX2 = MAL_TRUE; - routerConfig.noAVX512 = MAL_TRUE; - routerConfig.noNEON = MAL_TRUE; + routerConfig.noSSE2 = MA_TRUE; + routerConfig.noAVX2 = MA_TRUE; + routerConfig.noAVX512 = MA_TRUE; + routerConfig.noNEON = MA_TRUE; mal_get_standard_channel_map(mal_standard_channel_map_microsoft, routerConfig.channelsIn, routerConfig.channelMapIn); for (mal_uint32 iChannel = 0; iChannel < routerConfig.channelsIn; ++iChannel) { routerConfig.channelMapOut[iChannel] = routerConfig.channelMapIn[routerConfig.channelsIn - iChannel - 1]; @@ -1585,14 +1585,14 @@ int do_channel_routing_tests() mal_channel_router router; mal_result result = mal_channel_router_init(&routerConfig, &router); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { if (router.isPassthrough) { printf("Router incorrectly configured as a passthrough.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } if (!router.isSimpleShuffle) { printf("Router not configured as a simple shuffle.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } // Expecting the weights to all be equal to 1 for each channel. @@ -1605,21 +1605,21 @@ int do_channel_routing_tests() if (router.config.weights[iChannelIn][iChannelOut] != expectedWeight) { printf("Failed. Channel weight incorrect: %f\n", expectedWeight); - hasError = MAL_TRUE; + hasError = MA_TRUE; } } } } else { printf("Failed to init router.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } // Here is where we check that the shuffle optimization works correctly. What we do is compare the output of the shuffle // optimization with the non-shuffle output. We don't use a real sound here, but instead use values that makes it easier // for us to check results. Each channel is given a value equal to it's index, plus 1. - float testData[MAL_MAX_CHANNELS][100]; - float* ppTestData[MAL_MAX_CHANNELS]; + float testData[MA_MAX_CHANNELS][100]; + float* ppTestData[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < routerConfig.channelsIn; ++iChannel) { ppTestData[iChannel] = testData[iChannel]; for (mal_uint32 iFrame = 0; iFrame < 100; ++iFrame) { @@ -1630,10 +1630,10 @@ int do_channel_routing_tests() routerConfig.pUserData = ppTestData; mal_channel_router_init(&routerConfig, &router); - float outputA[MAL_MAX_CHANNELS][100]; - float outputB[MAL_MAX_CHANNELS][100]; - float* ppOutputA[MAL_MAX_CHANNELS]; - float* ppOutputB[MAL_MAX_CHANNELS]; + float outputA[MA_MAX_CHANNELS][100]; + float outputB[MA_MAX_CHANNELS][100]; + float* ppOutputA[MA_MAX_CHANNELS]; + float* ppOutputB[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < routerConfig.channelsOut; ++iChannel) { ppOutputA[iChannel] = outputA[iChannel]; ppOutputB[iChannel] = outputB[iChannel]; @@ -1643,16 +1643,16 @@ int do_channel_routing_tests() mal_uint64 framesRead = mal_channel_router_read_deinterleaved(&router, 100, (void**)ppOutputA, router.config.pUserData); if (framesRead != 100) { printf("Returned frame count for optimized incorrect."); - hasError = MAL_TRUE; + hasError = MA_TRUE; } // Without optimizations. - router.isPassthrough = MAL_FALSE; - router.isSimpleShuffle = MAL_FALSE; + router.isPassthrough = MA_FALSE; + router.isSimpleShuffle = MA_FALSE; framesRead = mal_channel_router_read_deinterleaved(&router, 100, (void**)ppOutputB, router.config.pUserData); if (framesRead != 100) { printf("Returned frame count for unoptimized path incorrect."); - hasError = MAL_TRUE; + hasError = MA_TRUE; } // Compare. @@ -1660,7 +1660,7 @@ int do_channel_routing_tests() for (mal_uint32 iFrame = 0; iFrame < 100; ++iFrame) { if (ppOutputA[iChannel][iFrame] != ppOutputB[iChannel][iFrame]) { printf("Sample incorrect [%d][%d]\n", iChannel, iFrame); - hasError = MAL_TRUE; + hasError = MA_TRUE; } } } @@ -1683,23 +1683,23 @@ int do_channel_routing_tests() routerConfig.mixingMode = mal_channel_mix_mode_simple; routerConfig.channelsIn = 2; routerConfig.channelsOut = 6; - routerConfig.noSSE2 = MAL_TRUE; - routerConfig.noAVX2 = MAL_TRUE; - routerConfig.noAVX512 = MAL_TRUE; - routerConfig.noNEON = MAL_TRUE; + routerConfig.noSSE2 = MA_TRUE; + routerConfig.noAVX2 = MA_TRUE; + routerConfig.noAVX512 = MA_TRUE; + routerConfig.noNEON = MA_TRUE; mal_get_standard_channel_map(mal_standard_channel_map_microsoft, routerConfig.channelsIn, routerConfig.channelMapIn); mal_get_standard_channel_map(mal_standard_channel_map_microsoft, routerConfig.channelsOut, routerConfig.channelMapOut); mal_channel_router router; mal_result result = mal_channel_router_init(&routerConfig, &router); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { if (router.isPassthrough) { printf("Router incorrectly configured as a passthrough.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } if (router.isSimpleShuffle) { printf("Router incorrectly configured as a simple shuffle.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } // Expecting the weights to all be equal to 1 for each channel. @@ -1712,13 +1712,13 @@ int do_channel_routing_tests() if (router.config.weights[iChannelIn][iChannelOut] != expectedWeight) { printf("Failed. Channel weight incorrect: %f\n", expectedWeight); - hasError = MAL_TRUE; + hasError = MA_TRUE; } } } } else { printf("Failed to init router.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } if (!hasError) { @@ -1735,23 +1735,23 @@ int do_channel_routing_tests() routerConfig.mixingMode = mal_channel_mix_mode_simple; routerConfig.channelsIn = 6; routerConfig.channelsOut = 2; - routerConfig.noSSE2 = MAL_TRUE; - routerConfig.noAVX2 = MAL_TRUE; - routerConfig.noAVX512 = MAL_TRUE; - routerConfig.noNEON = MAL_TRUE; + routerConfig.noSSE2 = MA_TRUE; + routerConfig.noAVX2 = MA_TRUE; + routerConfig.noAVX512 = MA_TRUE; + routerConfig.noNEON = MA_TRUE; mal_get_standard_channel_map(mal_standard_channel_map_microsoft, routerConfig.channelsIn, routerConfig.channelMapIn); mal_get_standard_channel_map(mal_standard_channel_map_microsoft, routerConfig.channelsOut, routerConfig.channelMapOut); mal_channel_router router; mal_result result = mal_channel_router_init(&routerConfig, &router); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { if (router.isPassthrough) { printf("Router incorrectly configured as a passthrough.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } if (router.isSimpleShuffle) { printf("Router incorrectly configured as a simple shuffle.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } // Expecting the weights to all be equal to 1 for each channel. @@ -1764,13 +1764,13 @@ int do_channel_routing_tests() if (router.config.weights[iChannelIn][iChannelOut] != expectedWeight) { printf("Failed. Channel weight incorrect: %f\n", expectedWeight); - hasError = MAL_TRUE; + hasError = MA_TRUE; } } } } else { printf("Failed to init router.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } if (!hasError) { @@ -1785,39 +1785,39 @@ int do_channel_routing_tests() routerConfig.onReadDeinterleaved = channel_router_callback__passthrough_test; routerConfig.pUserData = NULL; routerConfig.mixingMode = mal_channel_mix_mode_planar_blend; - routerConfig.noSSE2 = MAL_TRUE; - routerConfig.noAVX2 = MAL_TRUE; - routerConfig.noAVX512 = MAL_TRUE; - routerConfig.noNEON = MAL_TRUE; + routerConfig.noSSE2 = MA_TRUE; + routerConfig.noAVX2 = MA_TRUE; + routerConfig.noAVX512 = MA_TRUE; + routerConfig.noNEON = MA_TRUE; // Use very specific mappings for this test. routerConfig.channelsIn = 2; - routerConfig.channelMapIn[0] = MAL_CHANNEL_FRONT_LEFT; - routerConfig.channelMapIn[1] = MAL_CHANNEL_FRONT_RIGHT; + routerConfig.channelMapIn[0] = MA_CHANNEL_FRONT_LEFT; + routerConfig.channelMapIn[1] = MA_CHANNEL_FRONT_RIGHT; routerConfig.channelsOut = 8; - routerConfig.channelMapOut[0] = MAL_CHANNEL_FRONT_LEFT; - routerConfig.channelMapOut[1] = MAL_CHANNEL_FRONT_RIGHT; - routerConfig.channelMapOut[2] = MAL_CHANNEL_FRONT_CENTER; - routerConfig.channelMapOut[3] = MAL_CHANNEL_LFE; - routerConfig.channelMapOut[4] = MAL_CHANNEL_BACK_LEFT; - routerConfig.channelMapOut[5] = MAL_CHANNEL_BACK_RIGHT; - routerConfig.channelMapOut[6] = MAL_CHANNEL_SIDE_LEFT; - routerConfig.channelMapOut[7] = MAL_CHANNEL_SIDE_RIGHT; + routerConfig.channelMapOut[0] = MA_CHANNEL_FRONT_LEFT; + routerConfig.channelMapOut[1] = MA_CHANNEL_FRONT_RIGHT; + routerConfig.channelMapOut[2] = MA_CHANNEL_FRONT_CENTER; + routerConfig.channelMapOut[3] = MA_CHANNEL_LFE; + routerConfig.channelMapOut[4] = MA_CHANNEL_BACK_LEFT; + routerConfig.channelMapOut[5] = MA_CHANNEL_BACK_RIGHT; + routerConfig.channelMapOut[6] = MA_CHANNEL_SIDE_LEFT; + routerConfig.channelMapOut[7] = MA_CHANNEL_SIDE_RIGHT; mal_channel_router router; mal_result result = mal_channel_router_init(&routerConfig, &router); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { if (router.isPassthrough) { printf("Router incorrectly configured as a passthrough.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } if (router.isSimpleShuffle) { printf("Router incorrectly configured as a simple shuffle.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } - float expectedWeights[MAL_MAX_CHANNELS][MAL_MAX_CHANNELS]; + float expectedWeights[MA_MAX_CHANNELS][MA_MAX_CHANNELS]; mal_zero_memory(expectedWeights, sizeof(expectedWeights)); expectedWeights[0][0] = 1.0f; // FRONT_LEFT -> FRONT_LEFT expectedWeights[0][1] = 0.0f; // FRONT_LEFT -> FRONT_RIGHT @@ -1840,19 +1840,19 @@ int do_channel_routing_tests() for (mal_uint32 iChannelOut = 0; iChannelOut < routerConfig.channelsOut; ++iChannelOut) { if (router.config.weights[iChannelIn][iChannelOut] != expectedWeights[iChannelIn][iChannelOut]) { printf("Failed. Channel weight incorrect for [%d][%d]. Expected %f, got %f\n", iChannelIn, iChannelOut, expectedWeights[iChannelIn][iChannelOut], router.config.weights[iChannelIn][iChannelOut]); - hasError = MAL_TRUE; + hasError = MA_TRUE; } } } } else { printf("Failed to init router.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } // Test the actual conversion. The test data is set to +1 for the left channel, and -1 for the right channel. - float testData[MAL_MAX_CHANNELS][100]; - float* ppTestData[MAL_MAX_CHANNELS]; + float testData[MA_MAX_CHANNELS][100]; + float* ppTestData[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < routerConfig.channelsIn; ++iChannel) { ppTestData[iChannel] = testData[iChannel]; } @@ -1865,8 +1865,8 @@ int do_channel_routing_tests() routerConfig.pUserData = ppTestData; mal_channel_router_init(&routerConfig, &router); - float output[MAL_MAX_CHANNELS][100]; - float* ppOutput[MAL_MAX_CHANNELS]; + float output[MA_MAX_CHANNELS][100]; + float* ppOutput[MA_MAX_CHANNELS]; for (mal_uint32 iChannel = 0; iChannel < routerConfig.channelsOut; ++iChannel) { ppOutput[iChannel] = output[iChannel]; } @@ -1874,10 +1874,10 @@ int do_channel_routing_tests() mal_uint64 framesRead = mal_channel_router_read_deinterleaved(&router, 100, (void**)ppOutput, router.config.pUserData); if (framesRead != 100) { printf("Returned frame count for optimized incorrect.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } - float expectedOutput[MAL_MAX_CHANNELS]; + float expectedOutput[MA_MAX_CHANNELS]; expectedOutput[0] = -1.0f; // FRONT_LEFT expectedOutput[1] = +1.0f; // FRONT_RIGHT expectedOutput[2] = 0.0f; // FRONT_CENTER (left and right should cancel out, totalling 0). @@ -1890,7 +1890,7 @@ int do_channel_routing_tests() for (mal_uint32 iFrame = 0; iFrame < framesRead; ++iFrame) { if (output[iChannel][iFrame] != expectedOutput[iChannel]) { printf("Incorrect sample [%d][%d]. Expecting %f, got %f\n", iChannel, iFrame, expectedOutput[iChannel], output[iChannel][iFrame]); - hasError = MAL_TRUE; + hasError = MA_TRUE; } } } @@ -1907,39 +1907,39 @@ int do_channel_routing_tests() routerConfig.onReadDeinterleaved = channel_router_callback__passthrough_test; routerConfig.pUserData = NULL; routerConfig.mixingMode = mal_channel_mix_mode_planar_blend; - routerConfig.noSSE2 = MAL_TRUE; - routerConfig.noAVX2 = MAL_TRUE; - routerConfig.noAVX512 = MAL_TRUE; - routerConfig.noNEON = MAL_TRUE; + routerConfig.noSSE2 = MA_TRUE; + routerConfig.noAVX2 = MA_TRUE; + routerConfig.noAVX512 = MA_TRUE; + routerConfig.noNEON = MA_TRUE; // Use very specific mappings for this test. routerConfig.channelsIn = 8; - routerConfig.channelMapIn[0] = MAL_CHANNEL_FRONT_LEFT; - routerConfig.channelMapIn[1] = MAL_CHANNEL_FRONT_RIGHT; - routerConfig.channelMapIn[2] = MAL_CHANNEL_FRONT_CENTER; - routerConfig.channelMapIn[3] = MAL_CHANNEL_LFE; - routerConfig.channelMapIn[4] = MAL_CHANNEL_BACK_LEFT; - routerConfig.channelMapIn[5] = MAL_CHANNEL_BACK_RIGHT; - routerConfig.channelMapIn[6] = MAL_CHANNEL_SIDE_LEFT; - routerConfig.channelMapIn[7] = MAL_CHANNEL_SIDE_RIGHT; + routerConfig.channelMapIn[0] = MA_CHANNEL_FRONT_LEFT; + routerConfig.channelMapIn[1] = MA_CHANNEL_FRONT_RIGHT; + routerConfig.channelMapIn[2] = MA_CHANNEL_FRONT_CENTER; + routerConfig.channelMapIn[3] = MA_CHANNEL_LFE; + routerConfig.channelMapIn[4] = MA_CHANNEL_BACK_LEFT; + routerConfig.channelMapIn[5] = MA_CHANNEL_BACK_RIGHT; + routerConfig.channelMapIn[6] = MA_CHANNEL_SIDE_LEFT; + routerConfig.channelMapIn[7] = MA_CHANNEL_SIDE_RIGHT; routerConfig.channelsOut = 2; - routerConfig.channelMapOut[0] = MAL_CHANNEL_FRONT_LEFT; - routerConfig.channelMapOut[1] = MAL_CHANNEL_FRONT_RIGHT; + routerConfig.channelMapOut[0] = MA_CHANNEL_FRONT_LEFT; + routerConfig.channelMapOut[1] = MA_CHANNEL_FRONT_RIGHT; mal_channel_router router; mal_result result = mal_channel_router_init(&routerConfig, &router); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { if (router.isPassthrough) { printf("Router incorrectly configured as a passthrough.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } if (router.isSimpleShuffle) { printf("Router incorrectly configured as a simple shuffle.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } - float expectedWeights[MAL_MAX_CHANNELS][MAL_MAX_CHANNELS]; + float expectedWeights[MA_MAX_CHANNELS][MA_MAX_CHANNELS]; mal_zero_memory(expectedWeights, sizeof(expectedWeights)); expectedWeights[0][0] = 1.0f; // FRONT_LEFT -> FRONT_LEFT expectedWeights[1][0] = 0.0f; // FRONT_RIGHT -> FRONT_LEFT @@ -1962,13 +1962,13 @@ int do_channel_routing_tests() for (mal_uint32 iChannelOut = 0; iChannelOut < routerConfig.channelsOut; ++iChannelOut) { if (router.config.weights[iChannelIn][iChannelOut] != expectedWeights[iChannelIn][iChannelOut]) { printf("Failed. Channel weight incorrect for [%d][%d]. Expected %f, got %f\n", iChannelIn, iChannelOut, expectedWeights[iChannelIn][iChannelOut], router.config.weights[iChannelIn][iChannelOut]); - hasError = MAL_TRUE; + hasError = MA_TRUE; } } } } else { printf("Failed to init router.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } if (!hasError) { @@ -1983,34 +1983,34 @@ int do_channel_routing_tests() routerConfig.onReadDeinterleaved = channel_router_callback__passthrough_test; routerConfig.pUserData = NULL; routerConfig.mixingMode = mal_channel_mix_mode_planar_blend; - routerConfig.noSSE2 = MAL_TRUE; - routerConfig.noAVX2 = MAL_TRUE; - routerConfig.noAVX512 = MAL_TRUE; - routerConfig.noNEON = MAL_TRUE; + routerConfig.noSSE2 = MA_TRUE; + routerConfig.noAVX2 = MA_TRUE; + routerConfig.noAVX512 = MA_TRUE; + routerConfig.noNEON = MA_TRUE; // Use very specific mappings for this test. routerConfig.channelsIn = 1; - routerConfig.channelMapIn[0] = MAL_CHANNEL_MONO; + routerConfig.channelMapIn[0] = MA_CHANNEL_MONO; routerConfig.channelsOut = 4; - routerConfig.channelMapOut[0] = MAL_CHANNEL_FRONT_LEFT; - routerConfig.channelMapOut[1] = MAL_CHANNEL_FRONT_RIGHT; - routerConfig.channelMapOut[2] = MAL_CHANNEL_NONE; - routerConfig.channelMapOut[3] = MAL_CHANNEL_LFE; + routerConfig.channelMapOut[0] = MA_CHANNEL_FRONT_LEFT; + routerConfig.channelMapOut[1] = MA_CHANNEL_FRONT_RIGHT; + routerConfig.channelMapOut[2] = MA_CHANNEL_NONE; + routerConfig.channelMapOut[3] = MA_CHANNEL_LFE; mal_channel_router router; mal_result result = mal_channel_router_init(&routerConfig, &router); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { if (router.isPassthrough) { printf("Router incorrectly configured as a passthrough.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } if (router.isSimpleShuffle) { printf("Router incorrectly configured as a simple shuffle.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } - float expectedWeights[MAL_MAX_CHANNELS][MAL_MAX_CHANNELS]; + float expectedWeights[MA_MAX_CHANNELS][MA_MAX_CHANNELS]; mal_zero_memory(expectedWeights, sizeof(expectedWeights)); expectedWeights[0][0] = 1.0f; // MONO -> FRONT_LEFT expectedWeights[0][1] = 1.0f; // MONO -> FRONT_RIGHT @@ -2021,13 +2021,13 @@ int do_channel_routing_tests() for (mal_uint32 iChannelOut = 0; iChannelOut < routerConfig.channelsOut; ++iChannelOut) { if (router.config.weights[iChannelIn][iChannelOut] != expectedWeights[iChannelIn][iChannelOut]) { printf("Failed. Channel weight incorrect for [%d][%d]. Expected %f, got %f\n", iChannelIn, iChannelOut, expectedWeights[iChannelIn][iChannelOut], router.config.weights[iChannelIn][iChannelOut]); - hasError = MAL_TRUE; + hasError = MA_TRUE; } } } } else { printf("Failed to init router.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } if (!hasError) { @@ -2042,34 +2042,34 @@ int do_channel_routing_tests() routerConfig.onReadDeinterleaved = channel_router_callback__passthrough_test; routerConfig.pUserData = NULL; routerConfig.mixingMode = mal_channel_mix_mode_planar_blend; - routerConfig.noSSE2 = MAL_TRUE; - routerConfig.noAVX2 = MAL_TRUE; - routerConfig.noAVX512 = MAL_TRUE; - routerConfig.noNEON = MAL_TRUE; + routerConfig.noSSE2 = MA_TRUE; + routerConfig.noAVX2 = MA_TRUE; + routerConfig.noAVX512 = MA_TRUE; + routerConfig.noNEON = MA_TRUE; // Use very specific mappings for this test. routerConfig.channelsIn = 4; - routerConfig.channelMapIn[0] = MAL_CHANNEL_FRONT_LEFT; - routerConfig.channelMapIn[1] = MAL_CHANNEL_FRONT_RIGHT; - routerConfig.channelMapIn[2] = MAL_CHANNEL_NONE; - routerConfig.channelMapIn[3] = MAL_CHANNEL_LFE; + routerConfig.channelMapIn[0] = MA_CHANNEL_FRONT_LEFT; + routerConfig.channelMapIn[1] = MA_CHANNEL_FRONT_RIGHT; + routerConfig.channelMapIn[2] = MA_CHANNEL_NONE; + routerConfig.channelMapIn[3] = MA_CHANNEL_LFE; routerConfig.channelsOut = 1; - routerConfig.channelMapOut[0] = MAL_CHANNEL_MONO; + routerConfig.channelMapOut[0] = MA_CHANNEL_MONO; mal_channel_router router; mal_result result = mal_channel_router_init(&routerConfig, &router); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { if (router.isPassthrough) { printf("Router incorrectly configured as a passthrough.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } if (router.isSimpleShuffle) { printf("Router incorrectly configured as a simple shuffle.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } - float expectedWeights[MAL_MAX_CHANNELS][MAL_MAX_CHANNELS]; + float expectedWeights[MA_MAX_CHANNELS][MA_MAX_CHANNELS]; mal_zero_memory(expectedWeights, sizeof(expectedWeights)); expectedWeights[0][0] = 0.5f; // FRONT_LEFT -> MONO expectedWeights[1][0] = 0.5f; // FRONT_RIGHT -> MONO @@ -2080,13 +2080,13 @@ int do_channel_routing_tests() for (mal_uint32 iChannelOut = 0; iChannelOut < routerConfig.channelsOut; ++iChannelOut) { if (router.config.weights[iChannelIn][iChannelOut] != expectedWeights[iChannelIn][iChannelOut]) { printf("Failed. Channel weight incorrect for [%d][%d]. Expected %f, got %f\n", iChannelIn, iChannelOut, expectedWeights[iChannelIn][iChannelOut], router.config.weights[iChannelIn][iChannelOut]); - hasError = MAL_TRUE; + hasError = MA_TRUE; } } } } else { printf("Failed to init router.\n"); - hasError = MAL_TRUE; + hasError = MA_TRUE; } if (!hasError) { @@ -2105,7 +2105,7 @@ int do_channel_routing_tests() int do_backend_test(mal_backend backend) { - mal_result result = MAL_SUCCESS; + mal_result result = MA_SUCCESS; mal_context context; mal_device_info* pPlaybackDeviceInfos; mal_uint32 playbackDeviceCount; @@ -2121,10 +2121,10 @@ int do_backend_test(mal_backend backend) contextConfig.logCallback = on_log; result = mal_context_init(&backend, 1, &contextConfig, &context); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { printf(" Done\n"); } else { - if (result == MAL_NO_BACKEND) { + if (result == MA_NO_BACKEND) { printf(" Not supported\n"); printf("--- End %s ---\n", mal_get_backend_name(backend)); printf("\n"); @@ -2140,7 +2140,7 @@ int do_backend_test(mal_backend backend) printf(" Enumerating Devices... "); { result = mal_context_get_devices(&context, &pPlaybackDeviceInfos, &playbackDeviceCount, &pCaptureDeviceInfos, &captureDeviceCount); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { printf("Done\n"); } else { printf("Failed\n"); @@ -2166,7 +2166,7 @@ int do_backend_test(mal_backend backend) printf(" %d: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name); result = mal_context_get_device_info(&context, mal_device_type_playback, &pPlaybackDeviceInfos[iDevice].id, mal_share_mode_shared, &pPlaybackDeviceInfos[iDevice]); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { printf(" Name: %s\n", pPlaybackDeviceInfos[iDevice].name); printf(" Min Channels: %d\n", pPlaybackDeviceInfos[iDevice].minChannels); printf(" Max Channels: %d\n", pPlaybackDeviceInfos[iDevice].maxChannels); @@ -2186,7 +2186,7 @@ int do_backend_test(mal_backend backend) printf(" %d: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name); result = mal_context_get_device_info(&context, mal_device_type_capture, &pCaptureDeviceInfos[iDevice].id, mal_share_mode_shared, &pCaptureDeviceInfos[iDevice]); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { printf(" Name: %s\n", pCaptureDeviceInfos[iDevice].name); printf(" Min Channels: %d\n", pCaptureDeviceInfos[iDevice].minChannels); printf(" Max Channels: %d\n", pCaptureDeviceInfos[iDevice].maxChannels); @@ -2207,18 +2207,18 @@ done: printf("\n"); mal_context_uninit(&context); - return (result == MAL_SUCCESS) ? 0 : -1; + return (result == MA_SUCCESS) ? 0 : -1; } int do_backend_tests() { - mal_bool32 hasErrorOccurred = MAL_FALSE; + mal_bool32 hasErrorOccurred = MA_FALSE; // Tests are performed on a per-backend basis. for (size_t iBackend = 0; iBackend < mal_countof(g_Backends); ++iBackend) { int result = do_backend_test(g_Backends[iBackend]); if (result < 0) { - hasErrorOccurred = MAL_TRUE; + hasErrorOccurred = MA_TRUE; } } @@ -2270,12 +2270,12 @@ void on_stop__playback_test(mal_device* pDevice) int do_playback_test(mal_backend backend) { - mal_result result = MAL_SUCCESS; + mal_result result = MA_SUCCESS; mal_device device; mal_decoder decoder; mal_sine_wave sineWave; - mal_bool32 haveDevice = MAL_FALSE; - mal_bool32 haveDecoder = MAL_FALSE; + mal_bool32 haveDevice = MA_FALSE; + mal_bool32 haveDecoder = MA_FALSE; playback_test_callback_data callbackData; callbackData.pDecoder = &decoder; @@ -2300,10 +2300,10 @@ int do_playback_test(mal_backend backend) #endif result = mal_device_init_ex(&backend, 1, &contextConfig, &deviceConfig, &device); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { printf("Done\n"); } else { - if (result == MAL_NO_BACKEND) { + if (result == MA_NO_BACKEND) { printf(" Not supported\n"); printf("--- End %s ---\n", mal_get_backend_name(backend)); printf("\n"); @@ -2313,7 +2313,7 @@ int do_playback_test(mal_backend backend) goto done; } } - haveDevice = MAL_TRUE; + haveDevice = MA_TRUE; printf(" Is Passthrough: %s\n", (device.playback.converter.isPassthrough) ? "YES" : "NO"); printf(" Buffer Size in Frames: %d\n", device.playback.internalBufferSizeInFrames); @@ -2322,7 +2322,7 @@ int do_playback_test(mal_backend backend) printf(" Opening Decoder... "); { result = mal_event_init(device.pContext, &callbackData.endOfPlaybackEvent); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to init event.\n"); goto done; } @@ -2330,16 +2330,16 @@ int do_playback_test(mal_backend backend) #if !defined(__EMSCRIPTEN__) mal_decoder_config decoderConfig = mal_decoder_config_init(device.playback.format, device.playback.channels, device.sampleRate); result = mal_decoder_init_file("res/sine_s16_mono_48000.wav", &decoderConfig, &decoder); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { printf("Done\n"); } else { printf("Failed to init decoder.\n"); goto done; } - haveDecoder = MAL_TRUE; + haveDecoder = MA_TRUE; #else result = mal_sine_wave_init(0.5f, 400, device.sampleRate, &sineWave); - if (result == MAL_SUCCESS) { + if (result == MA_SUCCESS) { printf("Done\n"); } else { printf("Failed to init sine wave.\n"); @@ -2354,7 +2354,7 @@ int do_playback_test(mal_backend backend) getchar(); { result = mal_device_start(&device); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { printf("Failed to start device.\n"); goto done; } @@ -2381,17 +2381,17 @@ done: if (haveDecoder) { mal_decoder_uninit(&decoder); } - return (result == MAL_SUCCESS) ? 0 : -1; + return (result == MA_SUCCESS) ? 0 : -1; } int do_playback_tests() { - mal_bool32 hasErrorOccurred = MAL_FALSE; + mal_bool32 hasErrorOccurred = MA_FALSE; for (size_t iBackend = 0; iBackend < mal_countof(g_Backends); ++iBackend) { int result = do_playback_test(g_Backends[iBackend]); if (result < 0) { - hasErrorOccurred = MAL_TRUE; + hasErrorOccurred = MA_TRUE; } } @@ -2403,7 +2403,7 @@ int main(int argc, char** argv) (void)argc; (void)argv; - mal_bool32 hasErrorOccurred = MAL_FALSE; + mal_bool32 hasErrorOccurred = MA_FALSE; int result = 0; // Print the compiler. @@ -2450,7 +2450,7 @@ int main(int argc, char** argv) printf("=== TESTING CORE ===\n"); result = do_core_tests(); if (result < 0) { - hasErrorOccurred = MAL_TRUE; + hasErrorOccurred = MA_TRUE; } printf("=== END TESTING CORE ===\n"); @@ -2460,7 +2460,7 @@ int main(int argc, char** argv) printf("=== TESTING FORMAT CONVERSION ===\n"); result = do_format_conversion_tests(); if (result < 0) { - hasErrorOccurred = MAL_TRUE; + hasErrorOccurred = MA_TRUE; } printf("=== END TESTING FORMAT CONVERSION ===\n"); @@ -2470,7 +2470,7 @@ int main(int argc, char** argv) printf("=== TESTING INTERLEAVING/DEINTERLEAVING ===\n"); result = do_interleaving_tests(); if (result < 0) { - hasErrorOccurred = MAL_TRUE; + hasErrorOccurred = MA_TRUE; } printf("=== END TESTING INTERLEAVING/DEINTERLEAVING ===\n"); @@ -2480,7 +2480,7 @@ int main(int argc, char** argv) printf("=== TESTING FORMAT CONVERTER ===\n"); result = do_format_converter_tests(); if (result < 0) { - hasErrorOccurred = MAL_TRUE; + hasErrorOccurred = MA_TRUE; } printf("=== END TESTING FORMAT CONVERTER ===\n"); @@ -2490,7 +2490,7 @@ int main(int argc, char** argv) printf("=== TESTING CHANNEL ROUTING ===\n"); result = do_channel_routing_tests(); if (result < 0) { - hasErrorOccurred = MAL_TRUE; + hasErrorOccurred = MA_TRUE; } printf("=== END TESTING CHANNEL ROUTING ===\n"); @@ -2500,7 +2500,7 @@ int main(int argc, char** argv) printf("=== TESTING BACKENDS ===\n"); result = do_backend_tests(); if (result < 0) { - hasErrorOccurred = MAL_TRUE; + hasErrorOccurred = MA_TRUE; } printf("=== END TESTING BACKENDS ===\n"); @@ -2510,7 +2510,7 @@ int main(int argc, char** argv) printf("=== TESTING DEFAULT PLAYBACK DEVICES ===\n"); result = do_playback_tests(); if (result < 0) { - hasErrorOccurred = MAL_TRUE; + hasErrorOccurred = MA_TRUE; } printf("=== END TESTING DEFAULT PLAYBACK DEVICES ===\n"); @@ -2524,7 +2524,7 @@ int main(int argc, char** argv) #define DR_WAV_IMPLEMENTATION #include "../extras/dr_wav.h" -#ifdef MAL_INCLUDE_VORBIS_TESTS +#ifdef MA_INCLUDE_VORBIS_TESTS #if defined(_MSC_VER) #pragma warning(push) #pragma warning(disable:4456) diff --git a/tools/mini_sigvis/mini_sigvis.h b/tools/mini_sigvis/mini_sigvis.h index 615eac7b..ad278a1c 100644 --- a/tools/mini_sigvis/mini_sigvis.h +++ b/tools/mini_sigvis/mini_sigvis.h @@ -95,7 +95,7 @@ mal_result msigvis_result_from_dtk(dtk_result resultDTK) mal_result msigvis_init(msigvis_context* pContext) { if (pContext == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_zero_object(pContext); @@ -106,7 +106,7 @@ mal_result msigvis_init(msigvis_context* pContext) return msigvis_result_from_dtk(resultDTK); } - return MAL_SUCCESS; + return MA_SUCCESS; } void msigvis_uninit(msigvis_context* pContext) @@ -261,7 +261,7 @@ void msigvis_screen_uninit(msigvis_screen* pScreen) mal_result msigvis_screen_show(msigvis_screen* pScreen) { if (pScreen == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } return msigvis_result_from_dtk(dtk_window_show(&pScreen->window, DTK_SHOW_NORMAL)); @@ -270,7 +270,7 @@ mal_result msigvis_screen_show(msigvis_screen* pScreen) mal_result msigvis_screen_hide(msigvis_screen* pScreen) { if (pScreen == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } return msigvis_result_from_dtk(dtk_window_hide(&pScreen->window)); @@ -279,7 +279,7 @@ mal_result msigvis_screen_hide(msigvis_screen* pScreen) mal_result msigvis_screen_add_channel(msigvis_screen* pScreen, msigvis_channel* pChannel) { if (pScreen == NULL || pChannel == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } // Expand if necessary. @@ -291,7 +291,7 @@ mal_result msigvis_screen_add_channel(msigvis_screen* pScreen, msigvis_channel* msigvis_channel** ppNewBuffer = (msigvis_channel**)mal_realloc(pScreen->ppChannels, sizeof(*pScreen->ppChannels)*newCap); if (ppNewBuffer == NULL) { - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } pScreen->channelCap = newCap; @@ -302,18 +302,18 @@ mal_result msigvis_screen_add_channel(msigvis_screen* pScreen, msigvis_channel* pScreen->channelCount += 1; msigvis_screen_redraw(pScreen); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result msigvis_screen_remove_channel(msigvis_screen* pScreen, msigvis_channel* pChannel) { if (pScreen == NULL || pChannel == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_uint32 iChannel; mal_result result = msigvis_screen_find_channel_index(pScreen, pChannel, &iChannel); - if (result != MAL_SUCCESS) { + if (result != MA_SUCCESS) { return result; } @@ -323,11 +323,11 @@ mal_result msigvis_screen_remove_channel(msigvis_screen* pScreen, msigvis_channe mal_result msigvis_screen_remove_channel_by_index(msigvis_screen* pScreen, mal_uint32 iChannel) { if (pScreen == NULL || iChannel > pScreen->channelCount) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } if (pScreen->channelCount == 0) { - return MAL_INVALID_OPERATION; + return MA_INVALID_OPERATION; } if (iChannel < pScreen->channelCount-1) { @@ -337,29 +337,29 @@ mal_result msigvis_screen_remove_channel_by_index(msigvis_screen* pScreen, mal_u pScreen->channelCount -= 1; msigvis_screen_redraw(pScreen); - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result msigvis_screen_find_channel_index(msigvis_screen* pScreen, msigvis_channel* pChannel, mal_uint32* pIndex) { if (pScreen == NULL || pChannel == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } for (mal_uint32 iChannel = 0; iChannel < pScreen->channelCount; ++iChannel) { if (pScreen->ppChannels[iChannel] == pChannel) { *pIndex = iChannel; - return MAL_SUCCESS; + return MA_SUCCESS; } } - return MAL_ERROR; + return MA_ERROR; } mal_result msigvis_screen_redraw(msigvis_screen* pScreen) { if (pScreen == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } return msigvis_result_from_dtk(dtk_window_scheduled_redraw(&pScreen->window, dtk_window_get_client_rect(&pScreen->window))); @@ -376,20 +376,20 @@ mal_result msigvis_channel_init(msigvis_context* pContext, mal_format format, ma (void)pContext; if (pChannel == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_zero_object(pChannel); if (format == mal_format_unknown || sampleRate == 0) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } pChannel->format = format; pChannel->sampleRate = sampleRate; pChannel->color = dtk_rgb(255, 255, 255); - return MAL_SUCCESS; + return MA_SUCCESS; } void msigvis_channel_uninit(msigvis_channel* pChannel) @@ -404,7 +404,7 @@ void msigvis_channel_uninit(msigvis_channel* pChannel) mal_result msigvis_channel_push_samples(msigvis_channel* pChannel, mal_uint32 sampleCount, const void* pSamples) { if (pChannel == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } mal_uint32 bps = mal_get_bytes_per_sample(pChannel->format); @@ -418,7 +418,7 @@ mal_result msigvis_channel_push_samples(msigvis_channel* pChannel, mal_uint32 sa mal_uint8* pNewBuffer = (mal_uint8*)mal_realloc(pChannel->pBuffer, newBufferCapInSamples*bps); if (pNewBuffer == NULL) { - return MAL_OUT_OF_MEMORY; + return MA_OUT_OF_MEMORY; } pChannel->pBuffer = pNewBuffer; @@ -428,13 +428,13 @@ mal_result msigvis_channel_push_samples(msigvis_channel* pChannel, mal_uint32 sa mal_copy_memory(pChannel->pBuffer + pChannel->sampleCount*bps, pSamples, sampleCount*bps); pChannel->sampleCount += sampleCount; - return MAL_SUCCESS; + return MA_SUCCESS; } mal_result msigvis_channel_pop_samples(msigvis_channel* pChannel, mal_uint32 sampleCount) { if (pChannel == NULL) { - return MAL_INVALID_ARGS; + return MA_INVALID_ARGS; } if (sampleCount > pChannel->sampleCount) { @@ -450,7 +450,7 @@ mal_result msigvis_channel_pop_samples(msigvis_channel* pChannel, mal_uint32 sam memmove(pChannel->pBuffer, pChannel->pBuffer + bytesToRemove, pChannel->sampleCount*bps - bytesToRemove); pChannel->sampleCount -= sampleCount; - return MAL_SUCCESS; + return MA_SUCCESS; } float msigvis_channel_get_sample_f32(msigvis_channel* pChannel, mal_uint32 iSample)