Skip to content

Commit

Permalink
Add Opus support to CMake builds
Browse files Browse the repository at this point in the history
  • Loading branch information
ccawley2011 authored and slouken committed May 20, 2022
1 parent 853f76e commit 3251942
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ jobs:
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DSUPPORT_FLAC=ON \
-DSUPPORT_OGG=ON \
-DSUPPORT_OPUS=ON \
-DSUPPORT_MP3_MPG123=ON \
-DSUPPORT_MOD_MODPLUG=ON \
${{ matrix.platform.cmake }}
Expand Down
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set(FULL_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}")
option(SUPPORT_WAV "Support loading WAVE music" ON)
option(SUPPORT_FLAC "Support loading FLAC music with libFLAC" OFF)
option(SUPPORT_OGG "Support loading OGG Vorbis music via libvorbis" OFF)
option(SUPPORT_OPUS "Support loading OGG Opus music via libopusfile" OFF)
option(SUPPORT_MP3_MPG123 "Support loading MP3 music via MPG123" OFF)
option(SUPPORT_MOD_MODPLUG "Support loading MOD music via modplug" OFF)
option(SUPPORT_MID_TIMIDITY "Support loading MIDI music via TiMidity" ON)
Expand Down Expand Up @@ -125,7 +126,7 @@ if (SUPPORT_WAV)
target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_WAV)
endif()

if (SUPPORT_OGG OR SUPPORT_FLAC)
if (SUPPORT_OGG OR SUPPORT_FLAC OR SUPPORT_OPUS)
add_subdirectory(external/ogg)
endif()

Expand All @@ -143,6 +144,16 @@ if (SUPPORT_OGG)
target_link_libraries(SDL2_mixer PRIVATE vorbisfile vorbis ogg)
endif()

if (SUPPORT_OPUS)
target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_OPUS -DOPUSFILE_HEADER=<opusfile.h>)
set(OP_DISABLE_HTTP ON CACHE BOOL "Disable HTTP support")
set(OP_DISABLE_EXAMPLES ON CACHE BOOL "Do not build example applications")
set(OP_DISABLE_DOCS ON CACHE BOOL "Do not build API documentation")
add_subdirectory(external/opus)
add_subdirectory(external/opusfile)
target_link_libraries(SDL2_mixer PRIVATE opusfile)
endif()

if (SUPPORT_MP3_MPG123)
target_compile_definitions(SDL2_mixer PRIVATE -DMUSIC_MP3_MPG123)
add_subdirectory(external/mpg123)
Expand Down
5 changes: 5 additions & 0 deletions src/codecs/music_opus.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
#include "music_opus.h"
#include "utils.h"

#ifdef OPUSFILE_HEADER
#include OPUSFILE_HEADER
#else
#include <opus/opusfile.h>
#endif


typedef struct {
int loaded;
Expand Down

0 comments on commit 3251942

Please sign in to comment.