Commit f1bf58d0 authored by David Reid's avatar David Reid

"MAL_" to "MA_".

parent b93faa46
......@@ -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.
}
```
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -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 <name>Unaligned[size + MAL_SIMD_ALIGNMENT];
- <type>* <name>[MAL_MAX_CHANNELS];
- mal_uint8 <name>Unaligned[size + MA_SIMD_ALIGNMENT];
- <type>* <name>[MA_MAX_CHANNELS];
- size_t <name>FrameCount; <-- This is the number of samples contained within each sub-buffer of <name>
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);
}
......
......@@ -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);
......
#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;
}
......
#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");
......
#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;
}
......
#include <stdio.h>
#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;
}
......
// 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;
......
......@@ -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;
......
// 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;
}
......
......@@ -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;
......
// 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)
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment