mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-29 19:54:05 +02:00
Update dr_libs.
This commit is contained in:
+24
-21
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
WAV audio loader and writer. Choice of public domain or MIT-0. See license statements at the end of this file.
|
||||
dr_wav - v0.12.17 - 2021-01-17
|
||||
dr_wav - v0.12.19 - 2021-02-21
|
||||
|
||||
David Reid - mackron@gmail.com
|
||||
|
||||
@@ -144,7 +144,7 @@ extern "C" {
|
||||
|
||||
#define DRWAV_VERSION_MAJOR 0
|
||||
#define DRWAV_VERSION_MINOR 12
|
||||
#define DRWAV_VERSION_REVISION 17
|
||||
#define DRWAV_VERSION_REVISION 19
|
||||
#define DRWAV_VERSION_STRING DRWAV_XSTRINGIFY(DRWAV_VERSION_MAJOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_MINOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_REVISION)
|
||||
|
||||
#include <stddef.h> /* For size_t. */
|
||||
@@ -535,7 +535,7 @@ typedef struct
|
||||
/* The size in bytes of the data chunk. */
|
||||
drwav_uint64 dataChunkDataSize;
|
||||
|
||||
/* The position in the stream of the first byte of the data chunk. This is used for seeking. */
|
||||
/* The position in the stream of the first data byte of the data chunk. This is used for seeking. */
|
||||
drwav_uint64 dataChunkDataPos;
|
||||
|
||||
/* The number of bytes remaining in the data chunk. */
|
||||
@@ -2411,8 +2411,6 @@ DRWAV_PRIVATE drwav_bool32 drwav_init_write__internal(drwav* pWav, const drwav_d
|
||||
runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.blockAlign);
|
||||
runningPos += drwav__write_u16ne_to_le(pWav, pWav->fmt.bitsPerSample);
|
||||
|
||||
pWav->dataChunkDataPos = runningPos;
|
||||
|
||||
/* "data" chunk. */
|
||||
if (pFormat->container == drwav_container_riff) {
|
||||
drwav_uint32 chunkSizeDATA = (drwav_uint32)initialDataChunkSize;
|
||||
@@ -2427,19 +2425,13 @@ DRWAV_PRIVATE drwav_bool32 drwav_init_write__internal(drwav* pWav, const drwav_d
|
||||
runningPos += drwav__write_u32ne_to_le(pWav, 0xFFFFFFFF); /* Always set to 0xFFFFFFFF for RF64. The true size of the data chunk is specified in the ds64 chunk. */
|
||||
}
|
||||
|
||||
/*
|
||||
The runningPos variable is incremented in the section above but is left unused which is causing some static analysis tools to detect it
|
||||
as a dead store. I'm leaving this as-is for safety just in case I want to expand this function later to include other tags and want to
|
||||
keep track of the running position for whatever reason. The line below should silence the static analysis tools.
|
||||
*/
|
||||
(void)runningPos;
|
||||
|
||||
/* Set some properties for the client's convenience. */
|
||||
pWav->container = pFormat->container;
|
||||
pWav->channels = (drwav_uint16)pFormat->channels;
|
||||
pWav->sampleRate = pFormat->sampleRate;
|
||||
pWav->bitsPerSample = (drwav_uint16)pFormat->bitsPerSample;
|
||||
pWav->translatedFormatTag = (drwav_uint16)pFormat->format;
|
||||
pWav->dataChunkDataPos = runningPos;
|
||||
|
||||
return DRWAV_TRUE;
|
||||
}
|
||||
@@ -2902,7 +2894,7 @@ DRWAV_PRIVATE drwav_result drwav_result_from_errno(int e)
|
||||
|
||||
DRWAV_PRIVATE drwav_result drwav_fopen(FILE** ppFile, const char* pFilePath, const char* pOpenMode)
|
||||
{
|
||||
#if _MSC_VER && _MSC_VER >= 1400
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
errno_t err;
|
||||
#endif
|
||||
|
||||
@@ -2914,7 +2906,7 @@ DRWAV_PRIVATE drwav_result drwav_fopen(FILE** ppFile, const char* pFilePath, con
|
||||
return DRWAV_INVALID_ARGS;
|
||||
}
|
||||
|
||||
#if _MSC_VER && _MSC_VER >= 1400
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
err = fopen_s(ppFile, pFilePath, pOpenMode);
|
||||
if (err != 0) {
|
||||
return drwav_result_from_errno(err);
|
||||
@@ -3417,8 +3409,8 @@ DRWAV_API drwav_result drwav_uninit(drwav* pWav)
|
||||
drwav__write_u32ne_to_le(pWav, riffChunkSize);
|
||||
}
|
||||
|
||||
/* the "data" chunk size. */
|
||||
if (pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos + 4, drwav_seek_origin_start)) {
|
||||
/* The "data" chunk size. */
|
||||
if (pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos - 4, drwav_seek_origin_start)) {
|
||||
drwav_uint32 dataChunkSize = drwav__data_chunk_size_riff(pWav->dataChunkDataSize);
|
||||
drwav__write_u32ne_to_le(pWav, dataChunkSize);
|
||||
}
|
||||
@@ -3430,7 +3422,7 @@ DRWAV_API drwav_result drwav_uninit(drwav* pWav)
|
||||
}
|
||||
|
||||
/* The "data" chunk size. */
|
||||
if (pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos + 16, drwav_seek_origin_start)) {
|
||||
if (pWav->onSeek(pWav->pUserData, (int)pWav->dataChunkDataPos - 8, drwav_seek_origin_start)) {
|
||||
drwav_uint64 dataChunkSize = drwav__data_chunk_size_w64(pWav->dataChunkDataSize);
|
||||
drwav__write_u64ne_to_le(pWav, dataChunkSize);
|
||||
}
|
||||
@@ -3846,7 +3838,9 @@ DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__msadpcm(drwav* pWav, drwav
|
||||
|
||||
/* TODO: Lots of room for optimization here. */
|
||||
|
||||
while (framesToRead > 0 && pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
|
||||
while (pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
|
||||
DRWAV_ASSERT(framesToRead > 0); /* This loop iteration will never get hit with framesToRead == 0 because it's asserted at the top, and we check for 0 inside the loop just below. */
|
||||
|
||||
/* If there are no cached frames we need to load a new block. */
|
||||
if (pWav->msadpcm.cachedFrameCount == 0 && pWav->msadpcm.bytesRemainingInBlock == 0) {
|
||||
if (pWav->channels == 1) {
|
||||
@@ -3907,7 +3901,7 @@ DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__msadpcm(drwav* pWav, drwav
|
||||
}
|
||||
|
||||
if (framesToRead == 0) {
|
||||
return totalFramesRead;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -4044,7 +4038,9 @@ DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__ima(drwav* pWav, drwav_uin
|
||||
|
||||
/* TODO: Lots of room for optimization here. */
|
||||
|
||||
while (framesToRead > 0 && pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
|
||||
while (pWav->compressed.iCurrentPCMFrame < pWav->totalPCMFrameCount) {
|
||||
DRWAV_ASSERT(framesToRead > 0); /* This loop iteration will never get hit with framesToRead == 0 because it's asserted at the top, and we check for 0 inside the loop just below. */
|
||||
|
||||
/* If there are no cached samples we need to load a new block. */
|
||||
if (pWav->ima.cachedFrameCount == 0 && pWav->ima.bytesRemainingInBlock == 0) {
|
||||
if (pWav->channels == 1) {
|
||||
@@ -4107,7 +4103,7 @@ DRWAV_PRIVATE drwav_uint64 drwav_read_pcm_frames_s16__ima(drwav* pWav, drwav_uin
|
||||
}
|
||||
|
||||
if (framesToRead == 0) {
|
||||
return totalFramesRead;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -6018,6 +6014,13 @@ two different ways to initialize a drwav object.
|
||||
/*
|
||||
REVISION HISTORY
|
||||
================
|
||||
v0.12.19 - 2021-02-21
|
||||
- Fix a warning due to referencing _MSC_VER when it is undefined.
|
||||
- Minor improvements to the management of some internal state concerning the data chunk cursor.
|
||||
|
||||
v0.12.18 - 2021-01-31
|
||||
- Clean up some static analysis warnings.
|
||||
|
||||
v0.12.17 - 2021-01-17
|
||||
- Minor fix to sample code in documentation.
|
||||
- Correctly qualify a private API as private rather than public.
|
||||
|
||||
Reference in New Issue
Block a user