From bc23d565e7ea20a1fd802a4539ce9c8a1202645b Mon Sep 17 00:00:00 2001 From: David Reid Date: Sat, 6 Jun 2020 18:16:45 +1000 Subject: [PATCH] Minor optimization to ma_copy_pcm_frames() and update to documentation. This changes makes ma_copy_pcm_frames() a no-op when the input and output buffers are both set to the same pointer. This is useful for some in-place no-ops for effects and filters. --- miniaudio.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/miniaudio.h b/miniaudio.h index 9e9fa0fe..769f6660 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -7475,11 +7475,15 @@ static MA_INLINE ma_int32 ma_dither_s32(ma_dither_mode ditherMode, ma_int32 dith } -/****************************************************************************** +/************************************************************************************************************************************************************** Atomics -******************************************************************************/ +ma_atomic_increment/decrement_*() takes a pointer to the variable being incremented and returns the new value. Usage: + + ma_uint32 newValue = ma_atomic_increment_32(&theValueToIncrement); + +**************************************************************************************************************************************************************/ #if defined(__clang__) #if defined(__has_builtin) #if __has_builtin(__sync_swap) @@ -30791,6 +30795,10 @@ MA_API ma_uint32 ma_calculate_buffer_size_in_frames_from_milliseconds(ma_uint32 MA_API void ma_copy_pcm_frames(void* dst, const void* src, ma_uint64 frameCount, ma_format format, ma_uint32 channels) { + if (dst == src) { + return; /* No-op. */ + } + ma_copy_memory_64(dst, src, frameCount * ma_get_bytes_per_frame(format, channels)); }