From af6eb35f2dfdc4f1e28f661b9912a9143b8b1037 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 23 Oct 2025 19:02:19 -0500 Subject: [PATCH] detect MP3/Ogg support at runtime --- src/gui/exportOptions.cpp | 28 ++++++++++++++-------------- src/gui/gui.cpp | 4 ++++ src/gui/gui.h | 1 + 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/gui/exportOptions.cpp b/src/gui/exportOptions.cpp index bbeba44b2..759111d9c 100644 --- a/src/gui/exportOptions.cpp +++ b/src/gui/exportOptions.cpp @@ -50,22 +50,22 @@ void FurnaceGUI::drawExportAudio(bool onWindow) { if (ImGui::RadioButton(_("Wave (32-bit float)"),audioExportOptions.format==DIV_EXPORT_FORMAT_F32)) { audioExportOptions.format=DIV_EXPORT_FORMAT_F32; } -#ifdef HAVE_OGG - if (ImGui::RadioButton(_("Opus (lossy compression)"),audioExportOptions.format==DIV_EXPORT_FORMAT_OPUS)) { - audioExportOptions.format=DIV_EXPORT_FORMAT_OPUS; + if (supportsOgg) { + if (ImGui::RadioButton(_("Opus"),audioExportOptions.format==DIV_EXPORT_FORMAT_OPUS)) { + audioExportOptions.format=DIV_EXPORT_FORMAT_OPUS; + } + if (ImGui::RadioButton(_("FLAC (Free Lossless Audio Codec)"),audioExportOptions.format==DIV_EXPORT_FORMAT_FLAC)) { + audioExportOptions.format=DIV_EXPORT_FORMAT_FLAC; + } + if (ImGui::RadioButton(_("Vorbis"),audioExportOptions.format==DIV_EXPORT_FORMAT_VORBIS)) { + audioExportOptions.format=DIV_EXPORT_FORMAT_VORBIS; + } } - if (ImGui::RadioButton(_("FLAC (Free Lossless Audio Codec)"),audioExportOptions.format==DIV_EXPORT_FORMAT_FLAC)) { - audioExportOptions.format=DIV_EXPORT_FORMAT_FLAC; + if (supportsMP3) { + if (ImGui::RadioButton(_("MP3"),audioExportOptions.format==DIV_EXPORT_FORMAT_MPEG_L3)) { + audioExportOptions.format=DIV_EXPORT_FORMAT_MPEG_L3; + } } - if (ImGui::RadioButton(_("Vorbis (lossy compression)"),audioExportOptions.format==DIV_EXPORT_FORMAT_VORBIS)) { - audioExportOptions.format=DIV_EXPORT_FORMAT_VORBIS; - } -#endif -#ifdef HAVE_MP3_EXPORT - if (ImGui::RadioButton(_("MP3 (lossy compression)"),audioExportOptions.format==DIV_EXPORT_FORMAT_MPEG_L3)) { - audioExportOptions.format=DIV_EXPORT_FORMAT_MPEG_L3; - } -#endif ImGui::Unindent(); } diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 5f61529c6..a523bb3c8 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -8086,10 +8086,12 @@ bool FurnaceGUI::init() { // special treatment for Ogg and MPEG if (strcmp(f.extension,"oga")==0) { + supportsOgg=true; audioLoadFormats.push_back(f.name); audioLoadFormats.push_back("*.ogg *.oga *.opus"); compatFormats+="*.ogg *.oga *.opus "; } else if (strcmp(f.extension,"m1a")==0) { + supportsMP3=true; audioLoadFormats.push_back(f.name); audioLoadFormats.push_back("*.m1a *.mp1 *.mp2 *.mp3"); compatFormats+="*.m1a *.mp1 *.mp2 *.mp3 "; @@ -8846,6 +8848,8 @@ FurnaceGUI::FurnaceGUI(): queryReplaceInsDo(false), queryReplaceVolDo(false), queryViewingResults(false), + supportsOgg(false), + supportsMP3(false), wavePreviewOn(false), wavePreviewKey((SDL_Scancode)0), wavePreviewNote(0), diff --git a/src/gui/gui.h b/src/gui/gui.h index 6d2c51fdf..6aaaf741e 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -2494,6 +2494,7 @@ class FurnaceGUI { std::vector sysCategories; std::vector audioLoadFormats; + bool supportsOgg, supportsMP3; bool wavePreviewOn; SDL_Scancode wavePreviewKey;