mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-21 15:56:58 +02:00
"MAL_" to "MA_".
This commit is contained in:
@@ -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.
|
||||
}
|
||||
```
|
||||
|
||||
+11
-11
@@ -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;
|
||||
|
||||
+4121
-4121
File diff suppressed because it is too large
Load Diff
+68
-68
@@ -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);
|
||||
}
|
||||
|
||||
+50
-50
@@ -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);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#define DR_WAV_IMPLEMENTATION
|
||||
#include "../../../../dr_libs/dr_wav.h"
|
||||
|
||||
#define MAL_DEBUG_OUTPUT
|
||||
#define MA_DEBUG_OUTPUT
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#include "../../miniaudio.h"
|
||||
#include "../mal_resampler.h"
|
||||
@@ -38,7 +38,7 @@ int main(int argc, char** argv)
|
||||
resamplerConfig.pUserData = NULL;
|
||||
|
||||
result = mal_resampler_init(&resamplerConfig, &resampler);
|
||||
if (result != MAL_SUCCESS) {
|
||||
if (result != MA_SUCCESS) {
|
||||
printf("Failed to initialize resampler.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
+11
-11
@@ -1,12 +1,12 @@
|
||||
|
||||
#define MAL_LOG_LEVEL MAL_LOG_LEVEL_VERBOSE
|
||||
#define MAL_DEBUG_OUTPUT
|
||||
#define MA_LOG_LEVEL MA_LOG_LEVEL_VERBOSE
|
||||
#define MA_DEBUG_OUTPUT
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#include "../miniaudio.h"
|
||||
|
||||
int print_context_info(mal_context* pContext)
|
||||
{
|
||||
mal_result result = MAL_SUCCESS;
|
||||
mal_result result = MA_SUCCESS;
|
||||
mal_device_info* pPlaybackDeviceInfos;
|
||||
mal_uint32 playbackDeviceCount;
|
||||
mal_device_info* pCaptureDeviceInfos;
|
||||
@@ -18,7 +18,7 @@ int print_context_info(mal_context* pContext)
|
||||
printf(" Enumerating Devices... ");
|
||||
{
|
||||
result = mal_context_get_devices(pContext, &pPlaybackDeviceInfos, &playbackDeviceCount, &pCaptureDeviceInfos, &captureDeviceCount);
|
||||
if (result == MAL_SUCCESS) {
|
||||
if (result == MA_SUCCESS) {
|
||||
printf("Done\n");
|
||||
} else {
|
||||
printf("Failed\n");
|
||||
@@ -44,7 +44,7 @@ int print_context_info(mal_context* pContext)
|
||||
printf(" %d: %s\n", iDevice, pPlaybackDeviceInfos[iDevice].name);
|
||||
|
||||
result = mal_context_get_device_info(pContext, mal_device_type_playback, &pPlaybackDeviceInfos[iDevice].id, mal_share_mode_shared, &pPlaybackDeviceInfos[iDevice]);
|
||||
if (result == MAL_SUCCESS) {
|
||||
if (result == MA_SUCCESS) {
|
||||
printf(" Name: %s\n", pPlaybackDeviceInfos[iDevice].name);
|
||||
printf(" Min Channels: %d\n", pPlaybackDeviceInfos[iDevice].minChannels);
|
||||
printf(" Max Channels: %d\n", pPlaybackDeviceInfos[iDevice].maxChannels);
|
||||
@@ -64,7 +64,7 @@ int print_context_info(mal_context* pContext)
|
||||
printf(" %d: %s\n", iDevice, pCaptureDeviceInfos[iDevice].name);
|
||||
|
||||
result = mal_context_get_device_info(pContext, mal_device_type_capture, &pCaptureDeviceInfos[iDevice].id, mal_share_mode_shared, &pCaptureDeviceInfos[iDevice]);
|
||||
if (result == MAL_SUCCESS) {
|
||||
if (result == MA_SUCCESS) {
|
||||
printf(" Name: %s\n", pCaptureDeviceInfos[iDevice].name);
|
||||
printf(" Min Channels: %d\n", pCaptureDeviceInfos[iDevice].minChannels);
|
||||
printf(" Max Channels: %d\n", pCaptureDeviceInfos[iDevice].maxChannels);
|
||||
@@ -82,7 +82,7 @@ int print_context_info(mal_context* pContext)
|
||||
|
||||
done:
|
||||
printf("\n");
|
||||
return (result == MAL_SUCCESS) ? 0 : -1;
|
||||
return (result == MA_SUCCESS) ? 0 : -1;
|
||||
}
|
||||
|
||||
int print_device_info(mal_device* pDevice)
|
||||
@@ -123,7 +123,7 @@ int main(int argc, char** argv)
|
||||
|
||||
mal_sine_wave sineWave;
|
||||
result = mal_sine_wave_init(0.2, 400, 44100, &sineWave);
|
||||
if (result != MAL_SUCCESS) {
|
||||
if (result != MA_SUCCESS) {
|
||||
printf("Failed to initialize sine wave.\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ int main(int argc, char** argv)
|
||||
mal_context_config contextConfig = mal_context_config_init(NULL); // <-- Don't need a log callback because we're using debug output instead.
|
||||
mal_context context;
|
||||
result = mal_context_init(NULL, 0, &contextConfig, &context);
|
||||
if (result != MAL_SUCCESS) {
|
||||
if (result != MA_SUCCESS) {
|
||||
printf("Failed to initialize context.\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ int main(int argc, char** argv)
|
||||
|
||||
mal_device device;
|
||||
result = mal_device_init(&context, mal_device_type_playback, NULL, &deviceConfig, &sineWave, &device);
|
||||
if (result != MAL_SUCCESS) {
|
||||
if (result != MA_SUCCESS) {
|
||||
mal_context_uninit(&context);
|
||||
printf("Failed to initialize device.\n");
|
||||
return -1;
|
||||
@@ -157,7 +157,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// Start playback.
|
||||
result = mal_device_start(&device);
|
||||
if (result != MAL_SUCCESS) {
|
||||
if (result != MA_SUCCESS) {
|
||||
mal_device_uninit(&device);
|
||||
mal_context_uninit(&context);
|
||||
printf("Failed to start device.\n");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#define MAL_DEBUG_OUTPUT
|
||||
#define MAL_USE_REFERENCE_CONVERSION_APIS
|
||||
#define MA_DEBUG_OUTPUT
|
||||
#define MA_USE_REFERENCE_CONVERSION_APIS
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#include "../miniaudio.h"
|
||||
|
||||
@@ -68,14 +68,14 @@ int do_dithering_test()
|
||||
|
||||
// We first play the sound the way it's meant to be played.
|
||||
result = mal_device_init(NULL, &config, &device);
|
||||
if (result != MAL_SUCCESS) {
|
||||
if (result != MA_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
mal_sine_wave_init(0.5, 400, device.sampleRate, &sineWave);
|
||||
|
||||
result = mal_device_start(&device);
|
||||
if (result != MAL_SUCCESS) {
|
||||
if (result != MA_SUCCESS) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ int do_dithering_test()
|
||||
converterInConfig.onRead = on_convert_samples_in;
|
||||
converterInConfig.pUserData = &sineWave;
|
||||
result = mal_format_converter_init(&converterInConfig, &converterIn);
|
||||
if (result != MAL_SUCCESS) {
|
||||
if (result != MA_SUCCESS) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ int do_dithering_test()
|
||||
converterOutConfig.onRead = on_convert_samples_out;
|
||||
converterOutConfig.pUserData = &converterIn;
|
||||
result = mal_format_converter_init(&converterOutConfig, &converterOut);
|
||||
if (result != MAL_SUCCESS) {
|
||||
if (result != MA_SUCCESS) {
|
||||
return -3;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ int do_dithering_test()
|
||||
config.pUserData = &converterOut;
|
||||
|
||||
result = mal_device_init(NULL, &config, &device);
|
||||
if (result != MAL_SUCCESS) {
|
||||
if (result != MA_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ int do_dithering_test()
|
||||
mal_sine_wave_init(0.5, 400, device.sampleRate, &sineWave);
|
||||
|
||||
result = mal_device_start(&device);
|
||||
if (result != MAL_SUCCESS) {
|
||||
if (result != MA_SUCCESS) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// Just a simple test to check that MAL_NO_DEVICE_IO compiles.
|
||||
// Just a simple test to check that MA_NO_DEVICE_IO compiles.
|
||||
|
||||
#include "../extras/dr_flac.h"
|
||||
#include "../extras/dr_mp3.h"
|
||||
#include "../extras/dr_wav.h"
|
||||
|
||||
#define MAL_NO_DEVICE_IO
|
||||
#define MA_NO_DEVICE_IO
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
#include "../miniaudio.h"
|
||||
|
||||
@@ -13,7 +13,7 @@ int main(int argc, char** argv)
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
|
||||
mal_result result = MAL_ERROR;
|
||||
mal_result result = MA_ERROR;
|
||||
|
||||
mal_pcm_converter_config dspConfig = mal_pcm_converter_config_init_new();
|
||||
mal_pcm_converter converter;
|
||||
|
||||
+52
-52
@@ -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;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// We're using sigvis for visualizations. This will include miniaudio for us, so no need to include miniaudio in this file.
|
||||
#define NO_SIGVIS
|
||||
|
||||
#define MAL_NO_SSE2
|
||||
#define MAL_NO_AVX2
|
||||
#define MA_NO_SSE2
|
||||
#define MA_NO_AVX2
|
||||
|
||||
#ifdef NO_SIGVIS
|
||||
#define MINIAUDIO_IMPLEMENTATION
|
||||
@@ -117,7 +117,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// We first play the sound the way it's meant to be played.
|
||||
result = mal_device_init(NULL, &config, &device);
|
||||
if (result != MAL_SUCCESS) {
|
||||
if (result != MA_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -129,10 +129,10 @@ int main(int argc, char** argv)
|
||||
|
||||
mal_src_config srcConfig = mal_src_config_init(sampleRateIn, sampleRateOut, 1, on_src, NULL);
|
||||
srcConfig.algorithm = mal_src_algorithm_sinc;
|
||||
srcConfig.neverConsumeEndOfInput = MAL_TRUE;
|
||||
srcConfig.neverConsumeEndOfInput = MA_TRUE;
|
||||
|
||||
result = mal_src_init(&srcConfig, &src);
|
||||
if (result != MAL_SUCCESS) {
|
||||
if (result != MA_SUCCESS) {
|
||||
printf("Failed to create SRC.\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -142,14 +142,14 @@ int main(int argc, char** argv)
|
||||
#ifndef NO_SIGVIS
|
||||
msigvis_context sigvis;
|
||||
result = msigvis_init(&sigvis);
|
||||
if (result != MAL_SUCCESS) {
|
||||
if (result != MA_SUCCESS) {
|
||||
printf("Failed to initialize mini_sigvis context.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
msigvis_screen screen;
|
||||
result = msigvis_screen_init(&sigvis, 1280, 720, &screen);
|
||||
if (result != MAL_SUCCESS) {
|
||||
if (result != MA_SUCCESS) {
|
||||
printf("Failed to initialize mini_sigvis screen.\n");
|
||||
return -2;
|
||||
}
|
||||
@@ -159,7 +159,7 @@ int main(int argc, char** argv)
|
||||
|
||||
msigvis_channel channelSineWave;
|
||||
result = msigvis_channel_init(&sigvis, mal_format_f32, sampleRateOut, &channelSineWave);
|
||||
if (result != MAL_SUCCESS) {
|
||||
if (result != MA_SUCCESS) {
|
||||
printf("Failed to initialize mini_sigvis channel.\n");
|
||||
return -3;
|
||||
}
|
||||
@@ -198,7 +198,7 @@ int main(int argc, char** argv)
|
||||
#else
|
||||
|
||||
result = mal_device_start(&device);
|
||||
if (result != MAL_SUCCESS) {
|
||||
if (result != MA_SUCCESS) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -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;
|
||||
|
||||
+219
-219
File diff suppressed because it is too large
Load Diff
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user