mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 09:14:04 +02:00
Merge branch 'master' into dev-0.11
This commit is contained in:
+67
-53
@@ -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.
|
||||
miniaudio - v0.10.41 - 2021-08-15
|
||||
miniaudio - v0.10.42 - 2021-08-22
|
||||
|
||||
David Reid - mackron@gmail.com
|
||||
|
||||
@@ -3282,7 +3282,7 @@ extern "C" {
|
||||
|
||||
#define MA_VERSION_MAJOR 0
|
||||
#define MA_VERSION_MINOR 10
|
||||
#define MA_VERSION_REVISION 41
|
||||
#define MA_VERSION_REVISION 42
|
||||
#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__)
|
||||
@@ -55144,7 +55144,7 @@ extern "C" {
|
||||
#define DRFLAC_XSTRINGIFY(x) DRFLAC_STRINGIFY(x)
|
||||
#define DRFLAC_VERSION_MAJOR 0
|
||||
#define DRFLAC_VERSION_MINOR 12
|
||||
#define DRFLAC_VERSION_REVISION 30
|
||||
#define DRFLAC_VERSION_REVISION 31
|
||||
#define DRFLAC_VERSION_STRING DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MAJOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_MINOR) "." DRFLAC_XSTRINGIFY(DRFLAC_VERSION_REVISION)
|
||||
#include <stddef.h>
|
||||
typedef signed char drflac_int8;
|
||||
@@ -55505,7 +55505,7 @@ extern "C" {
|
||||
#define DRMP3_XSTRINGIFY(x) DRMP3_STRINGIFY(x)
|
||||
#define DRMP3_VERSION_MAJOR 0
|
||||
#define DRMP3_VERSION_MINOR 6
|
||||
#define DRMP3_VERSION_REVISION 29
|
||||
#define DRMP3_VERSION_REVISION 31
|
||||
#define DRMP3_VERSION_STRING DRMP3_XSTRINGIFY(DRMP3_VERSION_MAJOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_MINOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_REVISION)
|
||||
#include <stddef.h>
|
||||
typedef signed char drmp3_int8;
|
||||
@@ -83761,7 +83761,7 @@ static type* drflac__full_read_and_close_ ## extension (drflac* pFlac, unsigned
|
||||
DRFLAC_ZERO_MEMORY(pSampleData + (totalPCMFrameCount*pFlac->channels), (size_t)(sampleDataBufferSize - totalPCMFrameCount*pFlac->channels*sizeof(type))); \
|
||||
} else { \
|
||||
drflac_uint64 dataSize = totalPCMFrameCount*pFlac->channels*sizeof(type); \
|
||||
if (dataSize > DRFLAC_SIZE_MAX) { \
|
||||
if (dataSize > (drflac_uint64)DRFLAC_SIZE_MAX) { \
|
||||
goto on_error; \
|
||||
} \
|
||||
\
|
||||
@@ -84204,6 +84204,29 @@ static __inline__ __attribute__((always_inline)) drmp3_int32 drmp3_clip_int16_ar
|
||||
#else
|
||||
#define DRMP3_HAVE_ARMV6 0
|
||||
#endif
|
||||
#ifndef DRMP3_ASSERT
|
||||
#include <assert.h>
|
||||
#define DRMP3_ASSERT(expression) assert(expression)
|
||||
#endif
|
||||
#ifndef DRMP3_COPY_MEMORY
|
||||
#define DRMP3_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz))
|
||||
#endif
|
||||
#ifndef DRMP3_MOVE_MEMORY
|
||||
#define DRMP3_MOVE_MEMORY(dst, src, sz) memmove((dst), (src), (sz))
|
||||
#endif
|
||||
#ifndef DRMP3_ZERO_MEMORY
|
||||
#define DRMP3_ZERO_MEMORY(p, sz) memset((p), 0, (sz))
|
||||
#endif
|
||||
#define DRMP3_ZERO_OBJECT(p) DRMP3_ZERO_MEMORY((p), sizeof(*(p)))
|
||||
#ifndef DRMP3_MALLOC
|
||||
#define DRMP3_MALLOC(sz) malloc((sz))
|
||||
#endif
|
||||
#ifndef DRMP3_REALLOC
|
||||
#define DRMP3_REALLOC(p, sz) realloc((p), (sz))
|
||||
#endif
|
||||
#ifndef DRMP3_FREE
|
||||
#define DRMP3_FREE(p) free((p))
|
||||
#endif
|
||||
typedef struct
|
||||
{
|
||||
const drmp3_uint8 *buf;
|
||||
@@ -84443,7 +84466,7 @@ static int drmp3_L12_dequantize_granule(float *grbuf, drmp3_bs *bs, drmp3_L12_sc
|
||||
static void drmp3_L12_apply_scf_384(drmp3_L12_scale_info *sci, const float *scf, float *dst)
|
||||
{
|
||||
int i, k;
|
||||
memcpy(dst + 576 + sci->stereo_bands*18, dst + sci->stereo_bands*18, (sci->total_bands - sci->stereo_bands)*18*sizeof(float));
|
||||
DRMP3_COPY_MEMORY(dst + 576 + sci->stereo_bands*18, dst + sci->stereo_bands*18, (sci->total_bands - sci->stereo_bands)*18*sizeof(float));
|
||||
for (i = 0; i < sci->total_bands; i++, dst += 18, scf += 6)
|
||||
{
|
||||
for (k = 0; k < 12; k++)
|
||||
@@ -84581,14 +84604,14 @@ static void drmp3_L3_read_scalefactors(drmp3_uint8 *scf, drmp3_uint8 *ist_pos, c
|
||||
int cnt = scf_count[i];
|
||||
if (scfsi & 8)
|
||||
{
|
||||
memcpy(scf, ist_pos, cnt);
|
||||
DRMP3_COPY_MEMORY(scf, ist_pos, cnt);
|
||||
} else
|
||||
{
|
||||
int bits = scf_size[i];
|
||||
if (!bits)
|
||||
{
|
||||
memset(scf, 0, cnt);
|
||||
memset(ist_pos, 0, cnt);
|
||||
DRMP3_ZERO_MEMORY(scf, cnt);
|
||||
DRMP3_ZERO_MEMORY(ist_pos, cnt);
|
||||
} else
|
||||
{
|
||||
int max_scf = (scfsi < 0) ? (1 << bits) - 1 : -1;
|
||||
@@ -84941,7 +84964,7 @@ static void drmp3_L3_reorder(float *grbuf, float *scratch, const drmp3_uint8 *sf
|
||||
*dst++ = src[2*len];
|
||||
}
|
||||
}
|
||||
memcpy(grbuf, scratch, (dst - scratch)*sizeof(float));
|
||||
DRMP3_COPY_MEMORY(grbuf, scratch, (dst - scratch)*sizeof(float));
|
||||
}
|
||||
static void drmp3_L3_antialias(float *grbuf, int nbands)
|
||||
{
|
||||
@@ -85091,8 +85114,8 @@ static void drmp3_L3_imdct_short(float *grbuf, float *overlap, int nbands)
|
||||
for (;nbands > 0; nbands--, overlap += 9, grbuf += 18)
|
||||
{
|
||||
float tmp[18];
|
||||
memcpy(tmp, grbuf, sizeof(tmp));
|
||||
memcpy(grbuf, overlap, 6*sizeof(float));
|
||||
DRMP3_COPY_MEMORY(tmp, grbuf, sizeof(tmp));
|
||||
DRMP3_COPY_MEMORY(grbuf, overlap, 6*sizeof(float));
|
||||
drmp3_L3_imdct12(tmp, grbuf + 6, overlap + 6);
|
||||
drmp3_L3_imdct12(tmp + 1, grbuf + 12, overlap + 6);
|
||||
drmp3_L3_imdct12(tmp + 2, overlap, overlap + 6);
|
||||
@@ -85133,7 +85156,7 @@ static void drmp3_L3_save_reservoir(drmp3dec *h, drmp3dec_scratch *s)
|
||||
}
|
||||
if (remains > 0)
|
||||
{
|
||||
memmove(h->reserv_buf, s->maindata + pos, remains);
|
||||
DRMP3_MOVE_MEMORY(h->reserv_buf, s->maindata + pos, remains);
|
||||
}
|
||||
h->reserv = remains;
|
||||
}
|
||||
@@ -85141,8 +85164,8 @@ static int drmp3_L3_restore_reservoir(drmp3dec *h, drmp3_bs *bs, drmp3dec_scratc
|
||||
{
|
||||
int frame_bytes = (bs->limit - bs->pos)/8;
|
||||
int bytes_have = DRMP3_MIN(h->reserv, main_data_begin);
|
||||
memcpy(s->maindata, h->reserv_buf + DRMP3_MAX(0, h->reserv - main_data_begin), DRMP3_MIN(h->reserv, main_data_begin));
|
||||
memcpy(s->maindata + bytes_have, bs->buf + bs->pos/8, frame_bytes);
|
||||
DRMP3_COPY_MEMORY(s->maindata, h->reserv_buf + DRMP3_MAX(0, h->reserv - main_data_begin), DRMP3_MIN(h->reserv, main_data_begin));
|
||||
DRMP3_COPY_MEMORY(s->maindata + bytes_have, bs->buf + bs->pos/8, frame_bytes);
|
||||
drmp3_bs_init(&s->bs, s->maindata, bytes_have + frame_bytes);
|
||||
return h->reserv >= main_data_begin;
|
||||
}
|
||||
@@ -85520,7 +85543,7 @@ static void drmp3d_synth_granule(float *qmf_state, float *grbuf, int nbands, int
|
||||
{
|
||||
drmp3d_DCT_II(grbuf + 576*i, nbands);
|
||||
}
|
||||
memcpy(lins, qmf_state, sizeof(float)*15*64);
|
||||
DRMP3_COPY_MEMORY(lins, qmf_state, sizeof(float)*15*64);
|
||||
for (i = 0; i < nbands; i += 2)
|
||||
{
|
||||
drmp3d_synth(grbuf + i, pcm + 32*nch*i, nch, lins + i*64);
|
||||
@@ -85535,7 +85558,7 @@ static void drmp3d_synth_granule(float *qmf_state, float *grbuf, int nbands, int
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
memcpy(qmf_state, lins + nbands*64, sizeof(float)*15*64);
|
||||
DRMP3_COPY_MEMORY(qmf_state, lins + nbands*64, sizeof(float)*15*64);
|
||||
}
|
||||
}
|
||||
static int drmp3d_match_frame(const drmp3_uint8 *hdr, int mp3_bytes, int frame_bytes)
|
||||
@@ -85606,7 +85629,7 @@ DRMP3_API int drmp3dec_decode_frame(drmp3dec *dec, const drmp3_uint8 *mp3, int m
|
||||
}
|
||||
if (!frame_size)
|
||||
{
|
||||
memset(dec, 0, sizeof(drmp3dec));
|
||||
DRMP3_ZERO_MEMORY(dec, sizeof(drmp3dec));
|
||||
i = drmp3d_find_frame(mp3, mp3_bytes, &dec->free_format_bytes, &frame_size);
|
||||
if (!frame_size || i + frame_size > mp3_bytes)
|
||||
{
|
||||
@@ -85615,7 +85638,7 @@ DRMP3_API int drmp3dec_decode_frame(drmp3dec *dec, const drmp3_uint8 *mp3, int m
|
||||
}
|
||||
}
|
||||
hdr = mp3 + i;
|
||||
memcpy(dec->header, hdr, DRMP3_HDR_SIZE);
|
||||
DRMP3_COPY_MEMORY(dec->header, hdr, DRMP3_HDR_SIZE);
|
||||
info->frame_bytes = i + frame_size;
|
||||
info->channels = DRMP3_HDR_IS_MONO(hdr) ? 1 : 2;
|
||||
info->hz = drmp3_hdr_sample_rate_hz(hdr);
|
||||
@@ -85639,7 +85662,7 @@ DRMP3_API int drmp3dec_decode_frame(drmp3dec *dec, const drmp3_uint8 *mp3, int m
|
||||
{
|
||||
for (igr = 0; igr < (DRMP3_HDR_TEST_MPEG1(hdr) ? 2 : 1); igr++, pcm = DRMP3_OFFSET_PTR(pcm, sizeof(drmp3d_sample_t)*576*info->channels))
|
||||
{
|
||||
memset(scratch.grbuf[0], 0, 576*2*sizeof(float));
|
||||
DRMP3_ZERO_MEMORY(scratch.grbuf[0], 576*2*sizeof(float));
|
||||
drmp3_L3_decode(dec, &scratch, scratch.gr_info + igr*info->channels, info->channels);
|
||||
drmp3d_synth_granule(dec->qmf_state, scratch.grbuf[0], 18, info->channels, (drmp3d_sample_t*)pcm, scratch.syn[0]);
|
||||
}
|
||||
@@ -85655,7 +85678,7 @@ DRMP3_API int drmp3dec_decode_frame(drmp3dec *dec, const drmp3_uint8 *mp3, int m
|
||||
return drmp3_hdr_frame_samples(hdr);
|
||||
}
|
||||
drmp3_L12_read_scale_info(hdr, bs_frame, sci);
|
||||
memset(scratch.grbuf[0], 0, 576*2*sizeof(float));
|
||||
DRMP3_ZERO_MEMORY(scratch.grbuf[0], 576*2*sizeof(float));
|
||||
for (i = 0, igr = 0; igr < 3; igr++)
|
||||
{
|
||||
if (12 == (i += drmp3_L12_dequantize_granule(scratch.grbuf[0] + i, bs_frame, sci, info->layer | 1)))
|
||||
@@ -85663,7 +85686,7 @@ DRMP3_API int drmp3dec_decode_frame(drmp3dec *dec, const drmp3_uint8 *mp3, int m
|
||||
i = 0;
|
||||
drmp3_L12_apply_scf_384(sci, sci->scf + igr, scratch.grbuf[0]);
|
||||
drmp3d_synth_granule(dec->qmf_state, scratch.grbuf[0], 12, info->channels, (drmp3d_sample_t*)pcm, scratch.syn[0]);
|
||||
memset(scratch.grbuf[0], 0, 576*2*sizeof(float));
|
||||
DRMP3_ZERO_MEMORY(scratch.grbuf[0], 576*2*sizeof(float));
|
||||
pcm = DRMP3_OFFSET_PTR(pcm, sizeof(drmp3d_sample_t)*384*info->channels);
|
||||
}
|
||||
if (bs_frame->pos > bs_frame->limit)
|
||||
@@ -85748,26 +85771,6 @@ DRMP3_API void drmp3dec_f32_to_s16(const float *in, drmp3_int16 *out, size_t num
|
||||
#ifndef DRMP3_DATA_CHUNK_SIZE
|
||||
#define DRMP3_DATA_CHUNK_SIZE DRMP3_MIN_DATA_CHUNK_SIZE*4
|
||||
#endif
|
||||
#ifndef DRMP3_ASSERT
|
||||
#include <assert.h>
|
||||
#define DRMP3_ASSERT(expression) assert(expression)
|
||||
#endif
|
||||
#ifndef DRMP3_COPY_MEMORY
|
||||
#define DRMP3_COPY_MEMORY(dst, src, sz) memcpy((dst), (src), (sz))
|
||||
#endif
|
||||
#ifndef DRMP3_ZERO_MEMORY
|
||||
#define DRMP3_ZERO_MEMORY(p, sz) memset((p), 0, (sz))
|
||||
#endif
|
||||
#define DRMP3_ZERO_OBJECT(p) DRMP3_ZERO_MEMORY((p), sizeof(*(p)))
|
||||
#ifndef DRMP3_MALLOC
|
||||
#define DRMP3_MALLOC(sz) malloc((sz))
|
||||
#endif
|
||||
#ifndef DRMP3_REALLOC
|
||||
#define DRMP3_REALLOC(p, sz) realloc((p), (sz))
|
||||
#endif
|
||||
#ifndef DRMP3_FREE
|
||||
#define DRMP3_FREE(p) free((p))
|
||||
#endif
|
||||
#define DRMP3_COUNTOF(x) (sizeof(x) / sizeof(x[0]))
|
||||
#define DRMP3_CLAMP(x, lo, hi) (DRMP3_MAX(lo, DRMP3_MIN(x, hi)))
|
||||
#ifndef DRMP3_PI_D
|
||||
@@ -85937,7 +85940,7 @@ static drmp3_uint32 drmp3_decode_next_frame_ex__callbacks(drmp3* pMP3, drmp3d_sa
|
||||
if (pMP3->dataSize < DRMP3_MIN_DATA_CHUNK_SIZE) {
|
||||
size_t bytesRead;
|
||||
if (pMP3->pData != NULL) {
|
||||
memmove(pMP3->pData, pMP3->pData + pMP3->dataConsumed, pMP3->dataSize);
|
||||
DRMP3_MOVE_MEMORY(pMP3->pData, pMP3->pData + pMP3->dataConsumed, pMP3->dataSize);
|
||||
}
|
||||
pMP3->dataConsumed = 0;
|
||||
if (pMP3->dataCapacity < DRMP3_DATA_CHUNK_SIZE) {
|
||||
@@ -85980,7 +85983,7 @@ static drmp3_uint32 drmp3_decode_next_frame_ex__callbacks(drmp3* pMP3, drmp3d_sa
|
||||
break;
|
||||
} else if (info.frame_bytes == 0) {
|
||||
size_t bytesRead;
|
||||
memmove(pMP3->pData, pMP3->pData + pMP3->dataConsumed, pMP3->dataSize);
|
||||
DRMP3_MOVE_MEMORY(pMP3->pData, pMP3->pData + pMP3->dataConsumed, pMP3->dataSize);
|
||||
pMP3->dataConsumed = 0;
|
||||
if (pMP3->dataCapacity == pMP3->dataSize) {
|
||||
drmp3_uint8* pNewData;
|
||||
@@ -86012,12 +86015,20 @@ static drmp3_uint32 drmp3_decode_next_frame_ex__memory(drmp3* pMP3, drmp3d_sampl
|
||||
if (pMP3->atEnd) {
|
||||
return 0;
|
||||
}
|
||||
pcmFramesRead = drmp3dec_decode_frame(&pMP3->decoder, pMP3->memory.pData + pMP3->memory.currentReadPos, (int)(pMP3->memory.dataSize - pMP3->memory.currentReadPos), pPCMFrames, &info);
|
||||
if (pcmFramesRead > 0) {
|
||||
pMP3->pcmFramesConsumedInMP3Frame = 0;
|
||||
pMP3->pcmFramesRemainingInMP3Frame = pcmFramesRead;
|
||||
pMP3->mp3FrameChannels = info.channels;
|
||||
pMP3->mp3FrameSampleRate = info.hz;
|
||||
for (;;) {
|
||||
pcmFramesRead = drmp3dec_decode_frame(&pMP3->decoder, pMP3->memory.pData + pMP3->memory.currentReadPos, (int)(pMP3->memory.dataSize - pMP3->memory.currentReadPos), pPCMFrames, &info);
|
||||
if (pcmFramesRead > 0) {
|
||||
pcmFramesRead = drmp3_hdr_frame_samples(pMP3->decoder.header);
|
||||
pMP3->pcmFramesConsumedInMP3Frame = 0;
|
||||
pMP3->pcmFramesRemainingInMP3Frame = pcmFramesRead;
|
||||
pMP3->mp3FrameChannels = info.channels;
|
||||
pMP3->mp3FrameSampleRate = info.hz;
|
||||
break;
|
||||
} else if (info.frame_bytes > 0) {
|
||||
pMP3->memory.currentReadPos += (size_t)info.frame_bytes;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
pMP3->memory.currentReadPos += (size_t)info.frame_bytes;
|
||||
return pcmFramesRead;
|
||||
@@ -86062,7 +86073,7 @@ static drmp3_bool32 drmp3_init_internal(drmp3* pMP3, drmp3_read_proc onRead, drm
|
||||
if (pMP3->allocationCallbacks.onFree == NULL || (pMP3->allocationCallbacks.onMalloc == NULL && pMP3->allocationCallbacks.onRealloc == NULL)) {
|
||||
return DRMP3_FALSE;
|
||||
}
|
||||
if (!drmp3_decode_next_frame(pMP3)) {
|
||||
if (drmp3_decode_next_frame(pMP3) == 0) {
|
||||
drmp3__free_from_callbacks(pMP3->pData, &pMP3->allocationCallbacks);
|
||||
return DRMP3_FALSE;
|
||||
}
|
||||
@@ -87144,7 +87155,7 @@ static float* drmp3__full_read_and_close_f32(drmp3* pMP3, drmp3_config* pConfig,
|
||||
}
|
||||
oldFramesBufferSize = framesCapacity * pMP3->channels * sizeof(float);
|
||||
newFramesBufferSize = newFramesCap * pMP3->channels * sizeof(float);
|
||||
if (newFramesBufferSize > DRMP3_SIZE_MAX) {
|
||||
if (newFramesBufferSize > (drmp3_uint64)DRMP3_SIZE_MAX) {
|
||||
break;
|
||||
}
|
||||
pNewFrames = (float*)drmp3__realloc_from_callbacks(pFrames, (size_t)newFramesBufferSize, (size_t)oldFramesBufferSize, &pMP3->allocationCallbacks);
|
||||
@@ -87195,7 +87206,7 @@ static drmp3_int16* drmp3__full_read_and_close_s16(drmp3* pMP3, drmp3_config* pC
|
||||
}
|
||||
oldFramesBufferSize = framesCapacity * pMP3->channels * sizeof(drmp3_int16);
|
||||
newFramesBufferSize = newFramesCap * pMP3->channels * sizeof(drmp3_int16);
|
||||
if (newFramesBufferSize > DRMP3_SIZE_MAX) {
|
||||
if (newFramesBufferSize > (drmp3_uint64)DRMP3_SIZE_MAX) {
|
||||
break;
|
||||
}
|
||||
pNewFrames = (drmp3_int16*)drmp3__realloc_from_callbacks(pFrames, (size_t)newFramesBufferSize, (size_t)oldFramesBufferSize, &pMP3->allocationCallbacks);
|
||||
@@ -87616,6 +87627,9 @@ issues with certain devices and configurations. These can be individually enable
|
||||
/*
|
||||
REVISION HISTORY
|
||||
================
|
||||
v0.10.42 - 2021-08-22
|
||||
- Fix a possible deadlock when stopping devices.
|
||||
|
||||
v0.10.41 - 2021-08-15
|
||||
- Core Audio: Fix some deadlock errors.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user