detect MP3/Ogg support at runtime

This commit is contained in:
tildearrow 2025-10-23 19:02:19 -05:00
parent 3778f764d4
commit af6eb35f2d
3 changed files with 19 additions and 14 deletions

View file

@ -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();
}

View file

@ -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),

View file

@ -2494,6 +2494,7 @@ class FurnaceGUI {
std::vector<FurnaceGUISysCategory> sysCategories;
std::vector<String> audioLoadFormats;
bool supportsOgg, supportsMP3;
bool wavePreviewOn;
SDL_Scancode wavePreviewKey;