Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenMPT support #1551

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 47 additions & 10 deletions addons/acodec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ endif()
option(WANT_VORBIS "Enable Ogg Vorbis support using libvorbis" on)
option(WANT_TREMOR "Enable Ogg Vorbis support using Tremor" off)
option(WANT_OPUS "Enable Opus support using libopus" on)
option(WANT_MODAUDIO "Enable MOD Audio support" on)
option(WANT_DUMB "Enable mod audio support using DUMB" on)
option(WANT_OPENMPT "Enable mod audio support using OpenMPT" on)
option(WANT_ACODEC_DYNAMIC_LOAD "Enable DLL loading in acodec (Windows)" off)
option(WANT_MP3 "Enable MP3 support" on)

Expand Down Expand Up @@ -150,7 +151,7 @@ acodec_summary(" - FLAC" SUPPORT_FLAC)
# MOD audio
#

if(WANT_MODAUDIO)
if(WANT_DUMB)
find_package(DUMB)
if(DUMB_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${DUMB_INCLUDE_DIR})
Expand All @@ -170,21 +171,21 @@ if(WANT_MODAUDIO)
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES)
if(DUMB_COMPILES)
set(SUPPORT_MODAUDIO 1)
set(SUPPORT_DUMB 1)
endif(DUMB_COMPILES)
endif(DUMB_FOUND)
if(NOT SUPPORT_MODAUDIO)
if(NOT SUPPORT_DUMB)
message("WARNING: libdumb >= 2.0 or <= 0.9.3 not found or compile "
"test failed, disabling support. See "
"<https://github.com/kode54/dumb> for 2.0 or "
"<http://dumb.sourceforge.net/> for 0.9.3.")
endif(NOT SUPPORT_MODAUDIO)
endif(WANT_MODAUDIO)
endif(NOT SUPPORT_DUMB)
endif(WANT_DUMB)

if(SUPPORT_MODAUDIO)
if(SUPPORT_DUMB)
include_directories(SYSTEM ${DUMB_INCLUDE_DIR})
set(ALLEGRO_CFG_ACODEC_MODAUDIO 1)
list(APPEND ACODEC_SOURCES modaudio.c)
set(ALLEGRO_CFG_ACODEC_DUMB 1)
list(APPEND ACODEC_SOURCES dumb.c)

list(APPEND ACODEC_INCLUDE_DIRECTORIES ${DUMB_INCLUDE_DIR})

Expand All @@ -202,7 +203,43 @@ if(SUPPORT_MODAUDIO)
endif()
endif()

acodec_summary(" - DUMB" SUPPORT_MODAUDIO)
acodec_summary(" - DUMB" SUPPORT_DUMB)

if(WANT_OPENMPT)
find_package(OpenMPT)
if(OPENMPT_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${OPENMPT_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${OPENMPT_LIBRARIES})
run_c_compile_test("
#include <libopenmpt/libopenmpt.h>
#include <libopenmpt/libopenmpt_stream_callbacks_file.h>
int main(void)
{
openmpt_stream_get_file_callbacks();
return 0;
}"
OPENMPT_COMPILES)
set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_LIBRARIES)
if(OPENMPT_COMPILES)
set(SUPPORT_OPENMPT 1)
endif()
endif()
endif()

if(SUPPORT_OPENMPT)
include_directories(SYSTEM ${OPENMPT_INCLUDE_DIR})
set(ALLEGRO_CFG_ACODEC_OPENMPT 1)
list(APPEND ACODEC_SOURCES openmpt.c)
list(APPEND ACODEC_INCLUDE_DIRECTORIES ${OPENMPT_INCLUDE_DIR})
list(APPEND ACODEC_LIBRARIES ${OPENMPT_LIBRARIES})
endif()

acodec_summary(" - OpenMPT" SUPPORT_OPENMPT)

if(SUPPORT_OPENMPT OR SUPPORT_DUMB)
list(APPEND ACODEC_SOURCES modaudio.c)
endif(SUPPORT_OPENMPT OR SUPPORT_DUMB)

#
# Vorbis/Tremor
Expand Down
6 changes: 5 additions & 1 deletion addons/acodec/acodec.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,14 @@ bool al_init_acodec_addon(void)
ret &= al_register_sample_identifier(".opus", _al_identify_ogg_opus);
#endif

#ifdef ALLEGRO_CFG_ACODEC_MODAUDIO
#ifdef ALLEGRO_CFG_ACODEC_DUMB
ret &= _al_register_dumb_loaders();
#endif

#ifdef ALLEGRO_CFG_ACODEC_OPENMPT
ret &= _al_register_openmpt_loaders();
#endif

/* MP3 will mis-identify a lot of mod files, so put its identifier last */
#ifdef ALLEGRO_CFG_ACODEC_MP3
ret &= al_register_sample_loader(".mp3", _al_load_mp3);
Expand Down
22 changes: 21 additions & 1 deletion addons/acodec/acodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,30 @@ ALLEGRO_AUDIO_STREAM *_al_load_flac_audio_stream_f(ALLEGRO_FILE* f,
bool _al_identify_flac(ALLEGRO_FILE *f);
#endif

#ifdef ALLEGRO_CFG_ACODEC_MODAUDIO
#ifdef ALLEGRO_CFG_ACODEC_DUMB
bool _al_register_dumb_loaders(void);
#endif

#ifdef ALLEGRO_CFG_ACODEC_OPENMPT
bool _al_register_openmpt_loaders(void);
#endif

#if defined(ALLEGRO_CFG_ACODEC_DUMB) || defined(ALLEGRO_CFG_ACODEC_OPENMPT)
bool _al_identify_it(ALLEGRO_FILE *f);
bool _al_identify_669(ALLEGRO_FILE *f);
bool _al_identify_amf(ALLEGRO_FILE *f);
bool _al_identify_asy(ALLEGRO_FILE *f);
bool _al_identify_mtm(ALLEGRO_FILE *f);
bool _al_identify_okt(ALLEGRO_FILE *f);
bool _al_identify_psm(ALLEGRO_FILE *f);
bool _al_identify_ptm(ALLEGRO_FILE *f);
bool _al_identify_riff(ALLEGRO_FILE *f);
bool _al_identify_stm(ALLEGRO_FILE *f);
bool _al_identify_mod(ALLEGRO_FILE *f);
bool _al_identify_s3m(ALLEGRO_FILE *f);
bool _al_identify_xm(ALLEGRO_FILE *f);
#endif

#ifdef ALLEGRO_CFG_ACODEC_VORBIS
ALLEGRO_SAMPLE *_al_load_ogg_vorbis(const char *filename);
ALLEGRO_SAMPLE *_al_load_ogg_vorbis_f(ALLEGRO_FILE *file);
Expand Down
3 changes: 2 additions & 1 deletion addons/acodec/allegro5/internal/aintern_acodec_cfg.h.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#cmakedefine ALLEGRO_CFG_ACODEC_FLAC
#cmakedefine ALLEGRO_CFG_ACODEC_MODAUDIO
#cmakedefine ALLEGRO_CFG_ACODEC_DUMB
#cmakedefine ALLEGRO_CFG_ACODEC_OPENMPT
#cmakedefine ALLEGRO_CFG_ACODEC_VORBIS
#cmakedefine ALLEGRO_CFG_ACODEC_TREMOR
#cmakedefine ALLEGRO_CFG_ACODEC_OPUS
Expand Down
Loading
Loading