From 15e57bae4cbd94beb3dc7176ec4c735ed766e3f1 Mon Sep 17 00:00:00 2001 From: CrackedPixel <5776225+CrackedPixel@users.noreply.github.com> Date: Wed, 22 Apr 2026 20:00:05 -0500 Subject: [PATCH] revert stack change, update drmp3 --- examples/Makefile.Web | 3 +- examples/audio/audio_spectrum_visualizer.c | 2 +- src/external/dr_mp3.h | 37 +++++++++++----------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/examples/Makefile.Web b/examples/Makefile.Web index 95ea17290..709072be1 100644 --- a/examples/Makefile.Web +++ b/examples/Makefile.Web @@ -1596,9 +1596,8 @@ audio/audio_sound_positioning: audio/audio_sound_positioning.c $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ --preload-file audio/resources/coin.wav@resources/coin.wav -# spectrum example needs a higher stack, 128kb from the default 64kb audio/audio_spectrum_visualizer: audio/audio_spectrum_visualizer.c - $(CC) -o $@$(EXT) $< -sSTACK_SIZE=131072 $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ + $(CC) -o $@$(EXT) $< $(CFLAGS) $(INCLUDE_PATHS) $(LDFLAGS) $(LDLIBS) -D$(PLATFORM) \ --preload-file audio/resources/shaders/glsl100/fft.fs@resources/shaders/glsl100/fft.fs \ --preload-file audio/resources/country.mp3@resources/country.mp3 diff --git a/examples/audio/audio_spectrum_visualizer.c b/examples/audio/audio_spectrum_visualizer.c index ec6118fac..f5ffe2f2d 100644 --- a/examples/audio/audio_spectrum_visualizer.c +++ b/examples/audio/audio_spectrum_visualizer.c @@ -95,7 +95,7 @@ int main(void) InitAudioDevice(); SetAudioStreamBufferSizeDefault(AUDIO_STREAM_RING_BUFFER_SIZE); - // WARNING: PLATFORM_WEB requires an increased -sSTACK_SIZE + // WARNING: Memory out-of-bounds on PLATFORM_WEB Wave wav = LoadWave("resources/country.mp3"); WaveFormat(&wav, SAMPLE_RATE, PER_SAMPLE_BIT_DEPTH, MONO); diff --git a/src/external/dr_mp3.h b/src/external/dr_mp3.h index c0969c476..62e4880d1 100644 --- a/src/external/dr_mp3.h +++ b/src/external/dr_mp3.h @@ -3910,22 +3910,22 @@ static drmp3_result drmp3_wfopen(FILE** ppFile, const wchar_t* pFilePath, const #else /* Use fopen() on anything other than Windows. Requires a conversion. This is annoying because - fopen() is locale specific. The only real way I can think of to do this is with wcsrtombs(). Note - that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for + fopen() is locale specific. The only real way I can think of to do this is with wcsrtombs(). Note + that wcstombs() is apparently not thread-safe because it uses a static global mbstate_t object for maintaining state. I've checked this with -std=c89 and it works, but if somebody get's a compiler - error I'll look into improving compatibility. + error I'll look into improving compatibility. */ - /* - Some compilers don't support wchar_t or wcsrtombs() which we're using below. In this case we just - need to abort with an error. If you encounter a compiler lacking such support, add it to this list - and submit a bug report and it'll be added to the library upstream. - */ - #if defined(__DJGPP__) - { - /* Nothing to do here. This will fall through to the error check below. */ - } - #else + /* + Some compilers don't support wchar_t or wcsrtombs() which we're using below. In this case we just + need to abort with an error. If you encounter a compiler lacking such support, add it to this list + and submit a bug report and it'll be added to the library upstream. + */ + #if defined(__DJGPP__) + { + /* Nothing to do here. This will fall through to the error check below. */ + } + #else { mbstate_t mbs; size_t lenMB; @@ -3967,7 +3967,7 @@ static drmp3_result drmp3_wfopen(FILE** ppFile, const wchar_t* pFilePath, const drmp3__free_from_callbacks(pFilePathMB, pAllocationCallbacks); } - #endif + #endif if (*ppFile == NULL) { return DRMP3_ERROR; @@ -4247,7 +4247,7 @@ DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_f32(drmp3* pMP3, drmp3_uint64 frame #else /* Slow path. Convert from s16 to f32. */ { - drmp3_int16 pTempS16[8192]; + drmp3_int16 pTempS16[1152*2]; /* MP3 frames have a maximum per-channel sample count of 1152. Times 2 to account for stereo. */ drmp3_uint64 totalPCMFramesRead = 0; while (totalPCMFramesRead < framesToRead) { @@ -4284,7 +4284,7 @@ DRMP3_API drmp3_uint64 drmp3_read_pcm_frames_s16(drmp3* pMP3, drmp3_uint64 frame #else /* Slow path. Convert from f32 to s16. */ { - float pTempF32[4096]; + float pTempF32[1152*2]; /* MP3 frames have a maximum per-channel sample count of 1152. Times 2 to account for stereo. */ drmp3_uint64 totalPCMFramesRead = 0; while (totalPCMFramesRead < framesToRead) { @@ -4772,7 +4772,7 @@ static float* drmp3__full_read_and_close_f32(drmp3* pMP3, drmp3_config* pConfig, drmp3_uint64 totalFramesRead = 0; drmp3_uint64 framesCapacity = 0; float* pFrames = NULL; - float temp[4096]; + float temp[1152*2]; /* MP3 frames have a maximum per-channel sample count of 1152. Times 2 to account for stereo. */ DRMP3_ASSERT(pMP3 != NULL); @@ -4841,7 +4841,7 @@ static drmp3_int16* drmp3__full_read_and_close_s16(drmp3* pMP3, drmp3_config* pC drmp3_uint64 totalFramesRead = 0; drmp3_uint64 framesCapacity = 0; drmp3_int16* pFrames = NULL; - drmp3_int16 temp[4096]; + drmp3_int16 temp[1152*2]; /* MP3 frames have a maximum per-channel sample count of 1152. Times 2 to account for stereo. */ DRMP3_ASSERT(pMP3 != NULL); @@ -5010,6 +5010,7 @@ DIFFERENCES BETWEEN minimp3 AND dr_mp3 REVISION HISTORY ================ v0.7.4 - TBD + - Reduce size of some stack allocations. - Improvements to SIMD detection. v0.7.3 - 2026-01-17