Version 0.10.26

This commit is contained in:
David Reid
2020-11-24 17:55:09 +10:00
parent 992128da9f
commit d6864c5ab5
3 changed files with 1235 additions and 665 deletions
File diff suppressed because it is too large Load Diff
+57 -55
View File
@@ -1,6 +1,6 @@
/* /*
Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file. Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
miniaudio - v0.10.25 - 2020-11-15 miniaudio - v0.10.26 - 2020-11-24
David Reid - mackron@gmail.com David Reid - mackron@gmail.com
@@ -20,7 +20,7 @@ extern "C" {
#define MA_VERSION_MAJOR 0 #define MA_VERSION_MAJOR 0
#define MA_VERSION_MINOR 10 #define MA_VERSION_MINOR 10
#define MA_VERSION_REVISION 25 #define MA_VERSION_REVISION 26
#define MA_VERSION_STRING MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION) #define MA_VERSION_STRING MA_XSTRINGIFY(MA_VERSION_MAJOR) "." MA_XSTRINGIFY(MA_VERSION_MINOR) "." MA_XSTRINGIFY(MA_VERSION_REVISION)
#if defined(_MSC_VER) && !defined(__clang__) #if defined(_MSC_VER) && !defined(__clang__)
@@ -140,6 +140,8 @@ typedef ma_uint16 wchar_t;
#else #else
#define MA_INLINE inline __attribute__((always_inline)) #define MA_INLINE inline __attribute__((always_inline))
#endif #endif
#elif defined(__WATCOMC__)
#define MA_INLINE __inline
#else #else
#define MA_INLINE #define MA_INLINE
#endif #endif
@@ -1075,11 +1077,11 @@ typedef struct
float f32[MA_MAX_CHANNELS][MA_MAX_CHANNELS]; float f32[MA_MAX_CHANNELS][MA_MAX_CHANNELS];
ma_int32 s16[MA_MAX_CHANNELS][MA_MAX_CHANNELS]; ma_int32 s16[MA_MAX_CHANNELS][MA_MAX_CHANNELS];
} weights; } weights;
ma_bool32 isPassthrough : 1; ma_bool8 isPassthrough;
ma_bool32 isSimpleShuffle : 1; ma_bool8 isSimpleShuffle;
ma_bool32 isSimpleMonoExpansion : 1; ma_bool8 isSimpleMonoExpansion;
ma_bool32 isStereoToMono : 1; ma_bool8 isStereoToMono;
ma_uint8 shuffleTable[MA_MAX_CHANNELS]; ma_uint8 shuffleTable[MA_MAX_CHANNELS];
} ma_channel_converter; } ma_channel_converter;
MA_API ma_result ma_channel_converter_init(const ma_channel_converter_config* pConfig, ma_channel_converter* pConverter); MA_API ma_result ma_channel_converter_init(const ma_channel_converter_config* pConfig, ma_channel_converter* pConverter);
@@ -1129,11 +1131,11 @@ typedef struct
ma_data_converter_config config; ma_data_converter_config config;
ma_channel_converter channelConverter; ma_channel_converter channelConverter;
ma_resampler resampler; ma_resampler resampler;
ma_bool32 hasPreFormatConversion : 1; ma_bool8 hasPreFormatConversion;
ma_bool32 hasPostFormatConversion : 1; ma_bool8 hasPostFormatConversion;
ma_bool32 hasChannelConverter : 1; ma_bool8 hasChannelConverter;
ma_bool32 hasResampler : 1; ma_bool8 hasResampler;
ma_bool32 isPassthrough : 1; ma_bool8 isPassthrough;
} ma_data_converter; } ma_data_converter;
MA_API ma_result ma_data_converter_init(const ma_data_converter_config* pConfig, ma_data_converter* pConverter); MA_API ma_result ma_data_converter_init(const ma_data_converter_config* pConfig, ma_data_converter* pConverter);
@@ -1283,8 +1285,8 @@ typedef struct
ma_uint32 subbufferStrideInBytes; ma_uint32 subbufferStrideInBytes;
volatile ma_uint32 encodedReadOffset; /* Most significant bit is the loop flag. Lower 31 bits contains the actual offset in bytes. */ volatile ma_uint32 encodedReadOffset; /* Most significant bit is the loop flag. Lower 31 bits contains the actual offset in bytes. */
volatile ma_uint32 encodedWriteOffset; /* Most significant bit is the loop flag. Lower 31 bits contains the actual offset in bytes. */ volatile ma_uint32 encodedWriteOffset; /* Most significant bit is the loop flag. Lower 31 bits contains the actual offset in bytes. */
ma_bool32 ownsBuffer : 1; /* Used to know whether or not miniaudio is responsible for free()-ing the buffer. */ ma_bool8 ownsBuffer; /* Used to know whether or not miniaudio is responsible for free()-ing the buffer. */
ma_bool32 clearOnWriteAcquire : 1; /* When set, clears the acquired write buffer before returning from ma_rb_acquire_write(). */ ma_bool8 clearOnWriteAcquire; /* When set, clears the acquired write buffer before returning from ma_rb_acquire_write(). */
ma_allocation_callbacks allocationCallbacks; ma_allocation_callbacks allocationCallbacks;
} ma_rb; } ma_rb;
@@ -1841,8 +1843,8 @@ struct ma_device_config
ma_uint32 periodSizeInMilliseconds; ma_uint32 periodSizeInMilliseconds;
ma_uint32 periods; ma_uint32 periods;
ma_performance_profile performanceProfile; ma_performance_profile performanceProfile;
ma_bool32 noPreZeroedOutputBuffer; /* When set to true, the contents of the output buffer passed into the data callback will be left undefined rather than initialized to zero. */ ma_bool8 noPreZeroedOutputBuffer; /* When set to true, the contents of the output buffer passed into the data callback will be left undefined rather than initialized to zero. */
ma_bool32 noClip; /* When set to true, the contents of the output buffer passed into the data callback will be clipped after returning. Only applies when the playback sample format is f32. */ ma_bool8 noClip; /* When set to true, the contents of the output buffer passed into the data callback will be clipped after returning. Only applies when the playback sample format is f32. */
ma_device_callback_proc dataCallback; ma_device_callback_proc dataCallback;
ma_stop_proc stopCallback; ma_stop_proc stopCallback;
void* pUserData; void* pUserData;
@@ -1877,10 +1879,10 @@ struct ma_device_config
struct struct
{ {
ma_bool32 noAutoConvertSRC; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. */ ma_bool8 noAutoConvertSRC; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. */
ma_bool32 noDefaultQualitySRC; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY. */ ma_bool8 noDefaultQualitySRC; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY. */
ma_bool32 noAutoStreamRouting; /* Disables automatic stream routing. */ ma_bool8 noAutoStreamRouting; /* Disables automatic stream routing. */
ma_bool32 noHardwareOffloading; /* Disables WASAPI's hardware offloading feature. */ ma_bool8 noHardwareOffloading; /* Disables WASAPI's hardware offloading feature. */
} wasapi; } wasapi;
struct struct
{ {
@@ -2068,19 +2070,19 @@ struct ma_context_config
struct ma_context struct ma_context
{ {
ma_backend_callbacks callbacks; ma_backend_callbacks callbacks;
ma_backend backend; /* DirectSound, ALSA, etc. */ ma_backend backend; /* DirectSound, ALSA, etc. */
ma_log_proc logCallback; ma_log_proc logCallback;
ma_thread_priority threadPriority; ma_thread_priority threadPriority;
size_t threadStackSize; size_t threadStackSize;
void* pUserData; void* pUserData;
ma_allocation_callbacks allocationCallbacks; ma_allocation_callbacks allocationCallbacks;
ma_mutex deviceEnumLock; /* Used to make ma_context_get_devices() thread safe. */ ma_mutex deviceEnumLock; /* Used to make ma_context_get_devices() thread safe. */
ma_mutex deviceInfoLock; /* Used to make ma_context_get_device_info() thread safe. */ ma_mutex deviceInfoLock; /* Used to make ma_context_get_device_info() thread safe. */
ma_uint32 deviceInfoCapacity; /* Total capacity of pDeviceInfos. */ ma_uint32 deviceInfoCapacity; /* Total capacity of pDeviceInfos. */
ma_uint32 playbackDeviceInfoCount; ma_uint32 playbackDeviceInfoCount;
ma_uint32 captureDeviceInfoCount; ma_uint32 captureDeviceInfoCount;
ma_device_info* pDeviceInfos; /* Playback devices first, then capture. */ ma_device_info* pDeviceInfos; /* Playback devices first, then capture. */
ma_bool32 isBackendAsynchronous : 1; /* Set when the context is initialized. Set to 1 for asynchronous backends such as Core Audio and JACK. Do not modify. */ ma_bool8 isBackendAsynchronous; /* Set when the context is initialized. Set to 1 for asynchronous backends such as Core Audio and JACK. Do not modify. */
ma_result (* onUninit )(ma_context* pContext); ma_result (* onUninit )(ma_context* pContext);
ma_result (* onEnumDevices )(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData); /* Return false from the callback to stop enumeration. */ ma_result (* onEnumDevices )(ma_context* pContext, ma_enum_devices_callback_proc callback, void* pUserData); /* Return false from the callback to stop enumeration. */
@@ -2481,12 +2483,12 @@ struct ma_device
ma_event stopEvent; ma_event stopEvent;
ma_thread thread; ma_thread thread;
ma_result workResult; /* This is set by the worker thread after it's finished doing a job. */ ma_result workResult; /* This is set by the worker thread after it's finished doing a job. */
ma_bool32 usingDefaultSampleRate : 1; ma_bool8 usingDefaultSampleRate;
ma_bool32 usingDefaultBufferSize : 1; ma_bool8 usingDefaultBufferSize;
ma_bool32 usingDefaultPeriods : 1; ma_bool8 usingDefaultPeriods;
ma_bool32 isOwnerOfContext : 1; /* When set to true, uninitializing the device will also uninitialize the context. Set to true when NULL is passed into ma_device_init(). */ ma_bool8 isOwnerOfContext; /* When set to true, uninitializing the device will also uninitialize the context. Set to true when NULL is passed into ma_device_init(). */
ma_bool32 noPreZeroedOutputBuffer : 1; ma_bool8 noPreZeroedOutputBuffer;
ma_bool32 noClip : 1; ma_bool8 noClip;
volatile float masterVolumeFactor; /* Volatile so we can use some thread safety when applying volume to periods. */ volatile float masterVolumeFactor; /* Volatile so we can use some thread safety when applying volume to periods. */
ma_duplex_rb duplexRB; /* Intermediary buffer for duplex device on asynchronous backends. */ ma_duplex_rb duplexRB; /* Intermediary buffer for duplex device on asynchronous backends. */
struct struct
@@ -2506,9 +2508,6 @@ struct ma_device
ma_device_id id; /* If using an explicit device, will be set to a copy of the ID used for initialization. Otherwise cleared to 0. */ ma_device_id id; /* If using an explicit device, will be set to a copy of the ID used for initialization. Otherwise cleared to 0. */
char name[256]; /* Maybe temporary. Likely to be replaced with a query API. */ char name[256]; /* Maybe temporary. Likely to be replaced with a query API. */
ma_share_mode shareMode; /* Set to whatever was passed in when the device was initialized. */ ma_share_mode shareMode; /* Set to whatever was passed in when the device was initialized. */
ma_bool32 usingDefaultFormat : 1;
ma_bool32 usingDefaultChannels : 1;
ma_bool32 usingDefaultChannelMap : 1;
ma_format format; ma_format format;
ma_uint32 channels; ma_uint32 channels;
ma_channel channelMap[MA_MAX_CHANNELS]; ma_channel channelMap[MA_MAX_CHANNELS];
@@ -2519,15 +2518,15 @@ struct ma_device
ma_uint32 internalPeriodSizeInFrames; ma_uint32 internalPeriodSizeInFrames;
ma_uint32 internalPeriods; ma_uint32 internalPeriods;
ma_data_converter converter; ma_data_converter converter;
ma_bool8 usingDefaultFormat;
ma_bool8 usingDefaultChannels;
ma_bool8 usingDefaultChannelMap;
} playback; } playback;
struct struct
{ {
ma_device_id id; /* If using an explicit device, will be set to a copy of the ID used for initialization. Otherwise cleared to 0. */ ma_device_id id; /* If using an explicit device, will be set to a copy of the ID used for initialization. Otherwise cleared to 0. */
char name[256]; /* Maybe temporary. Likely to be replaced with a query API. */ char name[256]; /* Maybe temporary. Likely to be replaced with a query API. */
ma_share_mode shareMode; /* Set to whatever was passed in when the device was initialized. */ ma_share_mode shareMode; /* Set to whatever was passed in when the device was initialized. */
ma_bool32 usingDefaultFormat : 1;
ma_bool32 usingDefaultChannels : 1;
ma_bool32 usingDefaultChannelMap : 1;
ma_format format; ma_format format;
ma_uint32 channels; ma_uint32 channels;
ma_channel channelMap[MA_MAX_CHANNELS]; ma_channel channelMap[MA_MAX_CHANNELS];
@@ -2538,6 +2537,9 @@ struct ma_device
ma_uint32 internalPeriodSizeInFrames; ma_uint32 internalPeriodSizeInFrames;
ma_uint32 internalPeriods; ma_uint32 internalPeriods;
ma_data_converter converter; ma_data_converter converter;
ma_bool8 usingDefaultFormat;
ma_bool8 usingDefaultChannels;
ma_bool8 usingDefaultChannelMap;
} capture; } capture;
union union
@@ -2549,26 +2551,27 @@ struct ma_device
/*IAudioClient**/ ma_ptr pAudioClientCapture; /*IAudioClient**/ ma_ptr pAudioClientCapture;
/*IAudioRenderClient**/ ma_ptr pRenderClient; /*IAudioRenderClient**/ ma_ptr pRenderClient;
/*IAudioCaptureClient**/ ma_ptr pCaptureClient; /*IAudioCaptureClient**/ ma_ptr pCaptureClient;
/*IMMDeviceEnumerator**/ ma_ptr pDeviceEnumerator; /* Used for IMMNotificationClient notifications. Required for detecting default device changes. */ /*IMMDeviceEnumerator**/ ma_ptr pDeviceEnumerator; /* Used for IMMNotificationClient notifications. Required for detecting default device changes. */
ma_IMMNotificationClient notificationClient; ma_IMMNotificationClient notificationClient;
/*HANDLE*/ ma_handle hEventPlayback; /* Auto reset. Initialized to signaled. */ /*HANDLE*/ ma_handle hEventPlayback; /* Auto reset. Initialized to signaled. */
/*HANDLE*/ ma_handle hEventCapture; /* Auto reset. Initialized to unsignaled. */ /*HANDLE*/ ma_handle hEventCapture; /* Auto reset. Initialized to unsignaled. */
ma_uint32 actualPeriodSizeInFramesPlayback; /* Value from GetBufferSize(). internalPeriodSizeInFrames is not set to the _actual_ buffer size when low-latency shared mode is being used due to the way the IAudioClient3 API works. */ ma_uint32 actualPeriodSizeInFramesPlayback; /* Value from GetBufferSize(). internalPeriodSizeInFrames is not set to the _actual_ buffer size when low-latency shared mode is being used due to the way the IAudioClient3 API works. */
ma_uint32 actualPeriodSizeInFramesCapture; ma_uint32 actualPeriodSizeInFramesCapture;
ma_uint32 originalPeriodSizeInFrames; ma_uint32 originalPeriodSizeInFrames;
ma_uint32 originalPeriodSizeInMilliseconds; ma_uint32 originalPeriodSizeInMilliseconds;
ma_uint32 originalPeriods; ma_uint32 originalPeriods;
ma_bool32 hasDefaultPlaybackDeviceChanged; /* <-- Make sure this is always a whole 32-bits because we use atomic assignments. */ ma_performance_profile originalPerformanceProfile;
ma_bool32 hasDefaultCaptureDeviceChanged; /* <-- Make sure this is always a whole 32-bits because we use atomic assignments. */ ma_bool32 hasDefaultPlaybackDeviceChanged; /* <-- Make sure this is always a whole 32-bits because we use atomic assignments. */
ma_bool32 hasDefaultCaptureDeviceChanged; /* <-- Make sure this is always a whole 32-bits because we use atomic assignments. */
ma_uint32 periodSizeInFramesPlayback; ma_uint32 periodSizeInFramesPlayback;
ma_uint32 periodSizeInFramesCapture; ma_uint32 periodSizeInFramesCapture;
ma_bool32 isStartedCapture; /* <-- Make sure this is always a whole 32-bits because we use atomic assignments. */ ma_bool32 isStartedCapture; /* <-- Make sure this is always a whole 32-bits because we use atomic assignments. */
ma_bool32 isStartedPlayback; /* <-- Make sure this is always a whole 32-bits because we use atomic assignments. */ ma_bool32 isStartedPlayback; /* <-- Make sure this is always a whole 32-bits because we use atomic assignments. */
ma_bool32 noAutoConvertSRC : 1; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. */ ma_bool8 noAutoConvertSRC; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM. */
ma_bool32 noDefaultQualitySRC : 1; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY. */ ma_bool8 noDefaultQualitySRC; /* When set to true, disables the use of AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY. */
ma_bool32 noHardwareOffloading : 1; ma_bool8 noHardwareOffloading;
ma_bool32 allowCaptureAutoStreamRouting : 1; ma_bool8 allowCaptureAutoStreamRouting;
ma_bool32 allowPlaybackAutoStreamRouting : 1; ma_bool8 allowPlaybackAutoStreamRouting;
} wasapi; } wasapi;
#endif #endif
#ifdef MA_SUPPORT_DSOUND #ifdef MA_SUPPORT_DSOUND
@@ -2605,8 +2608,8 @@ struct ma_device
{ {
/*snd_pcm_t**/ ma_ptr pPCMPlayback; /*snd_pcm_t**/ ma_ptr pPCMPlayback;
/*snd_pcm_t**/ ma_ptr pPCMCapture; /*snd_pcm_t**/ ma_ptr pPCMCapture;
ma_bool32 isUsingMMapPlayback : 1; ma_bool8 isUsingMMapPlayback;
ma_bool32 isUsingMMapCapture : 1; ma_bool8 isUsingMMapCapture;
} alsa; } alsa;
#endif #endif
#ifdef MA_SUPPORT_PULSEAUDIO #ifdef MA_SUPPORT_PULSEAUDIO
@@ -2625,7 +2628,6 @@ struct ma_device
/*jack_port_t**/ ma_ptr pPortsCapture[MA_MAX_CHANNELS]; /*jack_port_t**/ ma_ptr pPortsCapture[MA_MAX_CHANNELS];
float* pIntermediaryBufferPlayback; /* Typed as a float because JACK is always floating point. */ float* pIntermediaryBufferPlayback; /* Typed as a float because JACK is always floating point. */
float* pIntermediaryBufferCapture; float* pIntermediaryBufferCapture;
ma_pcm_rb duplexRB;
} jack; } jack;
#endif #endif
#ifdef MA_SUPPORT_COREAUDIO #ifdef MA_SUPPORT_COREAUDIO
@@ -2705,7 +2707,6 @@ struct ma_device
{ {
int indexPlayback; /* We use a factory on the JavaScript side to manage devices and use an index for JS/C interop. */ int indexPlayback; /* We use a factory on the JavaScript side to manage devices and use an index for JS/C interop. */
int indexCapture; int indexCapture;
ma_pcm_rb duplexRB; /* In external capture format. */
} webaudio; } webaudio;
#endif #endif
#ifdef MA_SUPPORT_NULL #ifdef MA_SUPPORT_NULL
@@ -4676,6 +4677,7 @@ MA_API ma_uint64 ma_waveform_read_pcm_frames(ma_waveform* pWaveform, void* pFram
MA_API ma_result ma_waveform_seek_to_pcm_frame(ma_waveform* pWaveform, ma_uint64 frameIndex); MA_API ma_result ma_waveform_seek_to_pcm_frame(ma_waveform* pWaveform, ma_uint64 frameIndex);
MA_API ma_result ma_waveform_set_amplitude(ma_waveform* pWaveform, double amplitude); MA_API ma_result ma_waveform_set_amplitude(ma_waveform* pWaveform, double amplitude);
MA_API ma_result ma_waveform_set_frequency(ma_waveform* pWaveform, double frequency); MA_API ma_result ma_waveform_set_frequency(ma_waveform* pWaveform, double frequency);
MA_API ma_result ma_waveform_set_type(ma_waveform* pWaveform, ma_waveform_type type);
MA_API ma_result ma_waveform_set_sample_rate(ma_waveform* pWaveform, ma_uint32 sampleRate); MA_API ma_result ma_waveform_set_sample_rate(ma_waveform* pWaveform, ma_uint32 sampleRate);
+2 -2
View File
@@ -1,6 +1,6 @@
/* /*
Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file. Audio playback and capture library. Choice of public domain or MIT-0. See license statements at the end of this file.
miniaudio - v0.10.26 - TBD miniaudio - v0.10.26 - 2020-11-24
David Reid - mackron@gmail.com David Reid - mackron@gmail.com
@@ -64249,7 +64249,7 @@ The following miscellaneous changes have also been made.
/* /*
REVISION HISTORY REVISION HISTORY
================ ================
v0.10.26 - TBD v0.10.26 - 2020-11-24
- WASAPI: Fix a bug where the exclusive mode format may not be retrieved correctly due to accessing freed memory. - WASAPI: Fix a bug where the exclusive mode format may not be retrieved correctly due to accessing freed memory.
- Fix a bug with ma_waveform where glitching occurs after changing frequency. - Fix a bug with ma_waveform where glitching occurs after changing frequency.
- Fix compilation with OpenWatcom. - Fix compilation with OpenWatcom.