mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-24 09:14:04 +02:00
Update dr_wav and dr_mp3.
This commit is contained in:
+8
-2
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
MP3 audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
|
MP3 audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
|
||||||
dr_mp3 - v0.6.18 - 2020-11-01
|
dr_mp3 - v0.6.19 - 2020-11-13
|
||||||
|
|
||||||
David Reid - mackron@gmail.com
|
David Reid - mackron@gmail.com
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ extern "C" {
|
|||||||
|
|
||||||
#define DRMP3_VERSION_MAJOR 0
|
#define DRMP3_VERSION_MAJOR 0
|
||||||
#define DRMP3_VERSION_MINOR 6
|
#define DRMP3_VERSION_MINOR 6
|
||||||
#define DRMP3_VERSION_REVISION 18
|
#define DRMP3_VERSION_REVISION 19
|
||||||
#define DRMP3_VERSION_STRING DRMP3_XSTRINGIFY(DRMP3_VERSION_MAJOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_MINOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_REVISION)
|
#define DRMP3_VERSION_STRING DRMP3_XSTRINGIFY(DRMP3_VERSION_MAJOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_MINOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_REVISION)
|
||||||
|
|
||||||
#include <stddef.h> /* For size_t. */
|
#include <stddef.h> /* For size_t. */
|
||||||
@@ -2691,6 +2691,9 @@ static drmp3_uint32 drmp3_decode_next_frame_ex__callbacks(drmp3* pMP3, drmp3d_sa
|
|||||||
return 0; /* File too big. */
|
return 0; /* File too big. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DRMP3_ASSERT(pMP3->pData != NULL);
|
||||||
|
DRMP3_ASSERT(pMP3->dataCapacity > 0);
|
||||||
|
|
||||||
pcmFramesRead = drmp3dec_decode_frame(&pMP3->decoder, pMP3->pData + pMP3->dataConsumed, (int)pMP3->dataSize, pPCMFrames, &info); /* <-- Safe size_t -> int conversion thanks to the check above. */
|
pcmFramesRead = drmp3dec_decode_frame(&pMP3->decoder, pMP3->pData + pMP3->dataConsumed, (int)pMP3->dataSize, pPCMFrames, &info); /* <-- Safe size_t -> int conversion thanks to the check above. */
|
||||||
|
|
||||||
/* Consume the data. */
|
/* Consume the data. */
|
||||||
@@ -4432,6 +4435,9 @@ counts rather than sample counts.
|
|||||||
/*
|
/*
|
||||||
REVISION HISTORY
|
REVISION HISTORY
|
||||||
================
|
================
|
||||||
|
v0.6.19 - 2020-11-13
|
||||||
|
- Minor code clean up.
|
||||||
|
|
||||||
v0.6.18 - 2020-11-01
|
v0.6.18 - 2020-11-01
|
||||||
- Improve compiler support for older versions of GCC.
|
- Improve compiler support for older versions of GCC.
|
||||||
|
|
||||||
|
|||||||
+24
-4
@@ -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.
|
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.13 - 2020-11-01
|
dr_wav - v0.12.14 - 2020-11-13
|
||||||
|
|
||||||
David Reid - mackron@gmail.com
|
David Reid - mackron@gmail.com
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ extern "C" {
|
|||||||
|
|
||||||
#define DRWAV_VERSION_MAJOR 0
|
#define DRWAV_VERSION_MAJOR 0
|
||||||
#define DRWAV_VERSION_MINOR 12
|
#define DRWAV_VERSION_MINOR 12
|
||||||
#define DRWAV_VERSION_REVISION 13
|
#define DRWAV_VERSION_REVISION 14
|
||||||
#define DRWAV_VERSION_STRING DRWAV_XSTRINGIFY(DRWAV_VERSION_MAJOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_MINOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_REVISION)
|
#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. */
|
#include <stddef.h> /* For size_t. */
|
||||||
@@ -2478,6 +2478,13 @@ static drwav_bool32 drwav_init_write__internal(drwav* pWav, const drwav_data_for
|
|||||||
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. */
|
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. */
|
/* Set some properties for the client's convenience. */
|
||||||
pWav->container = pFormat->container;
|
pWav->container = pFormat->container;
|
||||||
pWav->channels = (drwav_uint16)pFormat->channels;
|
pWav->channels = (drwav_uint16)pFormat->channels;
|
||||||
@@ -3575,6 +3582,7 @@ DRWAV_API size_t drwav_read_raw(drwav* pWav, size_t bytesToRead, void* pBufferOu
|
|||||||
DRWAV_API drwav_uint64 drwav_read_pcm_frames_le(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
|
DRWAV_API drwav_uint64 drwav_read_pcm_frames_le(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
|
||||||
{
|
{
|
||||||
drwav_uint32 bytesPerFrame;
|
drwav_uint32 bytesPerFrame;
|
||||||
|
drwav_uint64 bytesToRead; /* Intentionally uint64 instead of size_t so we can do a check that we're not reading too much on 32-bit builds. */
|
||||||
|
|
||||||
if (pWav == NULL || framesToRead == 0) {
|
if (pWav == NULL || framesToRead == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -3591,11 +3599,20 @@ DRWAV_API drwav_uint64 drwav_read_pcm_frames_le(drwav* pWav, drwav_uint64 frames
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Don't try to read more samples than can potentially fit in the output buffer. */
|
/* Don't try to read more samples than can potentially fit in the output buffer. */
|
||||||
if (framesToRead * bytesPerFrame > DRWAV_SIZE_MAX) {
|
bytesToRead = framesToRead * bytesPerFrame;
|
||||||
|
if (bytesToRead > DRWAV_SIZE_MAX) {
|
||||||
framesToRead = DRWAV_SIZE_MAX / bytesPerFrame;
|
framesToRead = DRWAV_SIZE_MAX / bytesPerFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
return drwav_read_raw(pWav, (size_t)(framesToRead * bytesPerFrame), pBufferOut) / bytesPerFrame;
|
/*
|
||||||
|
Doing an explicit check here just to make it clear that we don't want to be attempt to read anything if there's no bytes to read. There
|
||||||
|
*could* be a time where it evaluates to 0 due to overflowing.
|
||||||
|
*/
|
||||||
|
if (bytesToRead == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return drwav_read_raw(pWav, (size_t)bytesToRead, pBufferOut) / bytesPerFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
DRWAV_API drwav_uint64 drwav_read_pcm_frames_be(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
|
DRWAV_API drwav_uint64 drwav_read_pcm_frames_be(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
|
||||||
@@ -6033,6 +6050,9 @@ two different ways to initialize a drwav object.
|
|||||||
/*
|
/*
|
||||||
REVISION HISTORY
|
REVISION HISTORY
|
||||||
================
|
================
|
||||||
|
v0.12.14 - 2020-11-13
|
||||||
|
- Minor code clean up.
|
||||||
|
|
||||||
v0.12.13 - 2020-11-01
|
v0.12.13 - 2020-11-01
|
||||||
- Improve compiler support for older versions of GCC.
|
- Improve compiler support for older versions of GCC.
|
||||||
|
|
||||||
|
|||||||
+12
-4
@@ -43662,7 +43662,7 @@ extern "C" {
|
|||||||
#define DRWAV_XSTRINGIFY(x) DRWAV_STRINGIFY(x)
|
#define DRWAV_XSTRINGIFY(x) DRWAV_STRINGIFY(x)
|
||||||
#define DRWAV_VERSION_MAJOR 0
|
#define DRWAV_VERSION_MAJOR 0
|
||||||
#define DRWAV_VERSION_MINOR 12
|
#define DRWAV_VERSION_MINOR 12
|
||||||
#define DRWAV_VERSION_REVISION 13
|
#define DRWAV_VERSION_REVISION 14
|
||||||
#define DRWAV_VERSION_STRING DRWAV_XSTRINGIFY(DRWAV_VERSION_MAJOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_MINOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_REVISION)
|
#define DRWAV_VERSION_STRING DRWAV_XSTRINGIFY(DRWAV_VERSION_MAJOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_MINOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_REVISION)
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
typedef signed char drwav_int8;
|
typedef signed char drwav_int8;
|
||||||
@@ -44396,7 +44396,7 @@ extern "C" {
|
|||||||
#define DRMP3_XSTRINGIFY(x) DRMP3_STRINGIFY(x)
|
#define DRMP3_XSTRINGIFY(x) DRMP3_STRINGIFY(x)
|
||||||
#define DRMP3_VERSION_MAJOR 0
|
#define DRMP3_VERSION_MAJOR 0
|
||||||
#define DRMP3_VERSION_MINOR 6
|
#define DRMP3_VERSION_MINOR 6
|
||||||
#define DRMP3_VERSION_REVISION 18
|
#define DRMP3_VERSION_REVISION 19
|
||||||
#define DRMP3_VERSION_STRING DRMP3_XSTRINGIFY(DRMP3_VERSION_MAJOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_MINOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_REVISION)
|
#define DRMP3_VERSION_STRING DRMP3_XSTRINGIFY(DRMP3_VERSION_MAJOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_MINOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_REVISION)
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
typedef signed char drmp3_int8;
|
typedef signed char drmp3_int8;
|
||||||
@@ -49332,6 +49332,7 @@ static drwav_bool32 drwav_init_write__internal(drwav* pWav, const drwav_data_for
|
|||||||
runningPos += drwav__write(pWav, "data", 4);
|
runningPos += drwav__write(pWav, "data", 4);
|
||||||
runningPos += drwav__write_u32ne_to_le(pWav, 0xFFFFFFFF);
|
runningPos += drwav__write_u32ne_to_le(pWav, 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
(void)runningPos;
|
||||||
pWav->container = pFormat->container;
|
pWav->container = pFormat->container;
|
||||||
pWav->channels = (drwav_uint16)pFormat->channels;
|
pWav->channels = (drwav_uint16)pFormat->channels;
|
||||||
pWav->sampleRate = pFormat->sampleRate;
|
pWav->sampleRate = pFormat->sampleRate;
|
||||||
@@ -50241,6 +50242,7 @@ DRWAV_API size_t drwav_read_raw(drwav* pWav, size_t bytesToRead, void* pBufferOu
|
|||||||
DRWAV_API drwav_uint64 drwav_read_pcm_frames_le(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
|
DRWAV_API drwav_uint64 drwav_read_pcm_frames_le(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
|
||||||
{
|
{
|
||||||
drwav_uint32 bytesPerFrame;
|
drwav_uint32 bytesPerFrame;
|
||||||
|
drwav_uint64 bytesToRead;
|
||||||
if (pWav == NULL || framesToRead == 0) {
|
if (pWav == NULL || framesToRead == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -50251,10 +50253,14 @@ DRWAV_API drwav_uint64 drwav_read_pcm_frames_le(drwav* pWav, drwav_uint64 frames
|
|||||||
if (bytesPerFrame == 0) {
|
if (bytesPerFrame == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (framesToRead * bytesPerFrame > DRWAV_SIZE_MAX) {
|
bytesToRead = framesToRead * bytesPerFrame;
|
||||||
|
if (bytesToRead > DRWAV_SIZE_MAX) {
|
||||||
framesToRead = DRWAV_SIZE_MAX / bytesPerFrame;
|
framesToRead = DRWAV_SIZE_MAX / bytesPerFrame;
|
||||||
}
|
}
|
||||||
return drwav_read_raw(pWav, (size_t)(framesToRead * bytesPerFrame), pBufferOut) / bytesPerFrame;
|
if (bytesToRead == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return drwav_read_raw(pWav, (size_t)bytesToRead, pBufferOut) / bytesPerFrame;
|
||||||
}
|
}
|
||||||
DRWAV_API drwav_uint64 drwav_read_pcm_frames_be(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
|
DRWAV_API drwav_uint64 drwav_read_pcm_frames_be(drwav* pWav, drwav_uint64 framesToRead, void* pBufferOut)
|
||||||
{
|
{
|
||||||
@@ -62046,6 +62052,8 @@ static drmp3_uint32 drmp3_decode_next_frame_ex__callbacks(drmp3* pMP3, drmp3d_sa
|
|||||||
pMP3->atEnd = DRMP3_TRUE;
|
pMP3->atEnd = DRMP3_TRUE;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
DRMP3_ASSERT(pMP3->pData != NULL);
|
||||||
|
DRMP3_ASSERT(pMP3->dataCapacity > 0);
|
||||||
pcmFramesRead = drmp3dec_decode_frame(&pMP3->decoder, pMP3->pData + pMP3->dataConsumed, (int)pMP3->dataSize, pPCMFrames, &info);
|
pcmFramesRead = drmp3dec_decode_frame(&pMP3->decoder, pMP3->pData + pMP3->dataConsumed, (int)pMP3->dataSize, pPCMFrames, &info);
|
||||||
if (info.frame_bytes > 0) {
|
if (info.frame_bytes > 0) {
|
||||||
pMP3->dataConsumed += (size_t)info.frame_bytes;
|
pMP3->dataConsumed += (size_t)info.frame_bytes;
|
||||||
|
|||||||
Reference in New Issue
Block a user