Skip to content

Commit

Permalink
Add OpenMPT support
Browse files Browse the repository at this point in the history
  • Loading branch information
SiegeLordEx authored and SiegeLord committed Apr 11, 2024
1 parent 90d9131 commit 3cf6786
Show file tree
Hide file tree
Showing 7 changed files with 405 additions and 2 deletions.
33 changes: 33 additions & 0 deletions addons/acodec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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_OPENMPT "Enable OpenMPT Audio support" on)
option(WANT_ACODEC_DYNAMIC_LOAD "Enable DLL loading in acodec (Windows)" off)
option(WANT_MP3 "Enable MP3 support" on)

Expand Down Expand Up @@ -204,6 +205,38 @@ endif()

acodec_summary(" - DUMB" SUPPORT_MODAUDIO)

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)

#
# Vorbis/Tremor
#
Expand Down
4 changes: 4 additions & 0 deletions addons/acodec/acodec.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ bool al_init_acodec_addon(void)
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
4 changes: 4 additions & 0 deletions addons/acodec/acodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ ALLEGRO_AUDIO_STREAM *_al_load_ogg_opus_audio_stream_f(ALLEGRO_FILE* file,
bool _al_identify_ogg_opus(ALLEGRO_FILE *f);
#endif

#ifdef ALLEGRO_CFG_ACODEC_OPENMPT
bool _al_register_openmpt_loaders(void);
#endif

#ifdef ALLEGRO_CFG_ACODEC_MP3
ALLEGRO_SAMPLE *_al_load_mp3(const char *filename);
ALLEGRO_SAMPLE *_al_load_mp3_f(ALLEGRO_FILE *f);
Expand Down
1 change: 1 addition & 0 deletions addons/acodec/allegro5/internal/aintern_acodec_cfg.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#cmakedefine ALLEGRO_CFG_ACODEC_VORBIS
#cmakedefine ALLEGRO_CFG_ACODEC_TREMOR
#cmakedefine ALLEGRO_CFG_ACODEC_OPUS
#cmakedefine ALLEGRO_CFG_ACODEC_OPENMPT
#cmakedefine ALLEGRO_CFG_ACODEC_MP3


Expand Down
4 changes: 2 additions & 2 deletions addons/acodec/modaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -863,8 +863,8 @@ bool _al_register_dumb_loaders(void)
ret &= al_register_audio_stream_loader(".stm", load_dumb_audio_stream);
ret &= al_register_audio_stream_loader_f(".stm", load_dumb_audio_stream_f);
ret &= al_register_sample_identifier(".stm", _al_identify_stm);
ret &= al_register_audio_stream_loader(".xm", load_dumb_audio_stream);
ret &= al_register_audio_stream_loader_f(".xm", load_dumb_audio_stream_f);
//ret &= al_register_audio_stream_loader(".xm", load_dumb_audio_stream);
//ret &= al_register_audio_stream_loader_f(".xm", load_dumb_audio_stream_f);
ret &= al_register_sample_identifier(".xm", _al_identify_xm);
#else
/*
Expand Down
Loading

0 comments on commit 3cf6786

Please sign in to comment.