Switch Linux/Dolphin MP3 decode from minimp3 to libmad

minimp3's sliding-window frame confirmation could spuriously discard real
frames near the tail of a not-yet-full window, losing ~5.5% of a real
VBR file's content even at a tuned 256KB window (~0.3% residual) -
audible as the whole track finishing early with stutters at each drop.

libmad's mad_stream/mad_frame/mad_synth API reports "need more data"
(MAD_ERROR_BUFLEN) and "genuinely bad data" separately rather than
overloading one return value, which was the actual ambiguity minimp3
couldn't resolve. Verified against the same real file with a 32KB window
(vs minimp3's 256KB): frame count and duration match the Xing header
exactly. Confirmed building for Linux, GameCube, and Wii (the latter two
via the project's real devkitPPC/libogc Docker toolchain) - libmad ships
inside libogc itself on Dolphin, no separate fetch needed there.

libmad is GPL-licensed, unlike the rest of this MIT project - a
deliberate tradeoff, noted at each site that pulls it in.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
2026-09-02 09:47:15 -05:00
co-authored by Claude Sonnet 5
parent 3ee0a53688
commit fd5bcfae90
11 changed files with 256 additions and 151 deletions
+7 -5
View File
@@ -10,14 +10,16 @@ target_sources(${DUSK_LIBRARY_TARGET_NAME}
audiostreamlinux.c
)
# No hardware MP3 decoder on Linux - use the shared minimp3-based software
# No hardware MP3 decoder on Linux - use the shared libmad-based software
# backend (also used by Dolphin), sourced directly from src/dusk/audio
# rather than through its own unconditional CMakeLists.txt so platforms
# with a hardware decoder (PSP) never pull minimp3 in at all.
if(NOT minimp3_FOUND)
find_package(minimp3 REQUIRED)
# with a hardware decoder (PSP) never pull libmad in at all. See
# audiostreammp3decodersw.h's own comment on why libmad (GPL-licensed)
# replaced this project's original minimp3-based implementation.
if(NOT libmad_FOUND)
find_package(libmad REQUIRED)
endif()
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC minimp3)
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC libmad::mad)
target_sources(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
"${DUSK_SOURCES_DIR}/dusk/audio/stream/audiostreammp3decodersw.c"
+4 -2
View File
@@ -8,6 +8,8 @@
#pragma once
// Linux has no hardware MP3 decoder to prefer, so it uses the shared
// minimp3-based software backend (also used by Dolphin) - see that
// header's own documentation for the actual struct/interface.
// libmad-based software backend (also used by Dolphin) - see that
// header's own documentation for the actual struct/interface, including
// why libmad (GPL-licensed) was chosen over the MIT-licensed minimp3 this
// used to be.
#include "audio/stream/audiostreammp3decodersw.h"