New upstream version 2.5.0~git20220509.g5c43733+dfsg
Simon McVittie
1 year, 11 months ago
5 | 5 | |
6 | 6 | # Enable this if you want to support loading FLAC music with libFLAC |
7 | 7 | SUPPORT_FLAC ?= true |
8 | FLAC_LIBRARY_PATH := external/flac-1.3.3 | |
8 | FLAC_LIBRARY_PATH := external/flac | |
9 | 9 | |
10 | 10 | # Enable this if you want to support loading OGG Vorbis music via Tremor |
11 | 11 | SUPPORT_OGG ?= true |
12 | OGG_LIBRARY_PATH := external/libogg-1.3.2 | |
13 | VORBIS_LIBRARY_PATH := external/libvorbisidec-1.2.1 | |
12 | OGG_LIBRARY_PATH := external/ogg | |
13 | VORBIS_LIBRARY_PATH := external/tremor | |
14 | 14 | |
15 | 15 | # Enable this if you want to support loading MP3 music via MPG123 |
16 | 16 | SUPPORT_MP3_MPG123 ?= true |
17 | MPG123_LIBRARY_PATH := external/mpg123-1.25.13 | |
17 | MPG123_LIBRARY_PATH := external/mpg123 | |
18 | 18 | |
19 | 19 | # Enable this if you want to support loading MOD music via modplug |
20 | 20 | SUPPORT_MOD_MODPLUG ?= true |
21 | MODPLUG_LIBRARY_PATH := external/libmodplug-0.8.9.0 | |
21 | MODPLUG_LIBRARY_PATH := external/libmodplug | |
22 | 22 | |
23 | 23 | # Enable this if you want to support TiMidity |
24 | 24 | SUPPORT_MID_TIMIDITY ?= true |
38 | 38 | PLAYWAVE_OBJECTS = @PLAYWAVE_OBJECTS@ |
39 | 39 | PLAYMUS_OBJECTS = @PLAYMUS_OBJECTS@ |
40 | 40 | |
41 | SRC_DIST = LICENSE.txt README.txt CHANGES.txt Android.mk Makefile.in Makefile.os2 SDL2_mixer.pc.in SDL2_mixer.spec.in include/SDL_mixer.h VisualC VisualC-WinRT Xcode Xcode-iOS acinclude autogen.sh build-scripts configure configure.ac external gcc-fat.sh src/utils.c src/utils.h src/effect_position.c src/effect_stereoreverse.c src/effects_internal.c src/effects_internal.h src/codecs/load_aiff.c src/codecs/load_aiff.h src/codecs/load_voc.c src/codecs/load_voc.h src/codecs/mp3utils.c src/codecs/mp3utils.h src/mixer.c src/mixer.h src/music.c src/music.h src/codecs/music_cmd.c src/codecs/music_cmd.h src/codecs/music_flac.c src/codecs/music_flac.h src/codecs/music_fluidsynth.c src/codecs/music_fluidsynth.h src/codecs/music_mad.c src/codecs/music_mad.h src/codecs/music_mikmod.c src/codecs/music_mikmod.h src/codecs/music_modplug.c src/codecs/music_modplug.h src/codecs/music_xmp.c src/codecs/music_xmp.h src/codecs/music_mpg123.c src/codecs/music_mpg123.h src/codecs/music_nativemidi.c src/codecs/music_nativemidi.h src/codecs/music_ogg.c src/codecs/music_ogg.h src/codecs/music_opus.c src/codecs/music_opus.h src/codecs/music_timidity.c src/codecs/music_timidity.h src/codecs/music_wav.c src/codecs/music_wav.h src/codecs/native_midi playmus.c playwave.c src/codecs/timidity version.rc | |
41 | SRC_DIST = LICENSE.txt README.txt CHANGES.txt Android.mk Makefile.in Makefile.os2 SDL2_mixer.pc.in SDL2_mixer.spec.in include/SDL_mixer.h VisualC VisualC-WinRT Xcode acinclude autogen.sh build-scripts configure configure.ac external gcc-fat.sh src/utils.c src/utils.h src/effect_position.c src/effect_stereoreverse.c src/effects_internal.c src/effects_internal.h src/codecs/load_aiff.c src/codecs/load_aiff.h src/codecs/load_voc.c src/codecs/load_voc.h src/codecs/mp3utils.c src/codecs/mp3utils.h src/mixer.c src/mixer.h src/music.c src/music.h src/codecs/music_cmd.c src/codecs/music_cmd.h src/codecs/music_flac.c src/codecs/music_flac.h src/codecs/music_fluidsynth.c src/codecs/music_fluidsynth.h src/codecs/music_mad.c src/codecs/music_mad.h src/codecs/music_mikmod.c src/codecs/music_mikmod.h src/codecs/music_modplug.c src/codecs/music_modplug.h src/codecs/music_xmp.c src/codecs/music_xmp.h src/codecs/music_mpg123.c src/codecs/music_mpg123.h src/codecs/music_nativemidi.c src/codecs/music_nativemidi.h src/codecs/music_ogg.c src/codecs/music_ogg.h src/codecs/music_opus.c src/codecs/music_opus.h src/codecs/music_timidity.c src/codecs/music_timidity.h src/codecs/music_wav.c src/codecs/music_wav.h src/codecs/native_midi playmus.c playwave.c src/codecs/timidity version.rc | |
42 | 42 | GEN_DIST = SDL2_mixer.spec |
43 | 43 | |
44 | 44 | LT_AGE = @LT_AGE@ |
124 | 124 | $(SHELL) $(auxdir)/mkinstalldirs $(distdir) |
125 | 125 | (cd $(srcdir); tar cf - $(SRC_DIST)) | (cd $(distdir); tar xf -) |
126 | 126 | tar cf - $(GEN_DIST) | (cd $(distdir); tar xf -) |
127 | rm -rf `find $(distdir) -name .svn` | |
128 | rm -f `find $(distdir) -name '.#*'` | |
129 | tar cvf - $(distdir) | gzip --best >$(distfile) | |
127 | -rm -rf `find $(distdir)/external -name '.git*'` | |
128 | -rm -rf `find $(distdir)/external -name '.ci*'` | |
129 | -rm -rf `find $(distdir)/external -name '*.yml'` | |
130 | -rm -rf `find $(distdir)/external -name ci` | |
131 | -rm -f `find $(distdir) -name '.#*'` | |
132 | tar cf - $(distdir) | gzip --best >$(distfile) | |
130 | 133 | rm -rf $(distdir) |
131 | 134 | |
132 | 135 | rpm: $(distfile) |
4 | 4 | # your own environment!. |
5 | 5 | |
6 | 6 | LIBNAME = SDL2mix |
7 | VERSION = 2.0.4 | |
7 | MAJOR_VERSION = 2 | |
8 | MINOR_VERSION = 5 | |
9 | MICRO_VERSION = 0 | |
10 | VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) | |
8 | 11 | |
9 | 12 | TITLENAME = $(LIBNAME) $(VERSION) |
10 | 13 | |
134 | 137 | LIBS+= modplug.lib |
135 | 138 | !endif |
136 | 139 | |
140 | # For the static assertions in mixer.c | |
141 | CFLAGS+= -DSDL_BUILD_MAJOR_VERSION=$(MAJOR_VERSION) | |
142 | CFLAGS+= -DSDL_BUILD_MINOR_VERSION=$(MINOR_VERSION) | |
143 | CFLAGS+= -DSDL_BUILD_MICRO_VERSION=$(MICRO_VERSION) | |
144 | ||
137 | 145 | all: $(DLLFILE) playwave.exe playmus.exe |
138 | 146 | |
139 | 147 | $(LIBFILE): $(DLLFILE) |
0 | 0 | %define name SDL2_mixer |
1 | %define version 2.0.4 | |
1 | %define version 2.5.0 | |
2 | 2 | %define release 1 |
3 | 3 | |
4 | 4 | Summary: Simple DirectMedia Layer - Sample Mixer Library |
0 | 0 | #!/bin/sh |
1 | # | |
1 | ||
2 | set -e | |
3 | ||
2 | 4 | echo "Generating build information using autoconf" |
3 | 5 | echo "This may take a while ..." |
4 | 6 | |
5 | # Regenerate configuration files | |
6 | 7 | cat acinclude/* >aclocal.m4 |
7 | found=false | |
8 | for autoconf in autoconf autoconf259 autoconf-2.59 | |
9 | do if which $autoconf >/dev/null 2>&1; then $autoconf && found=true; break; fi | |
10 | done | |
11 | if test x$found = xfalse; then | |
12 | echo "Couldn't find autoconf, aborting" | |
13 | exit 1 | |
14 | fi | |
8 | "${AUTOCONF:-autoconf}" | |
9 | rm aclocal.m4 | |
10 | rm -rf autom4te.cache | |
15 | 11 | |
16 | 12 | # Run configure for this platform |
17 | 13 | echo "Now you are ready to run ./configure" |
4 | 4 | |
5 | 5 | dnl Set various version strings - taken gratefully from the GTk sources |
6 | 6 | |
7 | # Making releases: | |
8 | # MICRO_VERSION += 1; | |
9 | # INTERFACE_AGE += 1; | |
10 | # BINARY_AGE += 1; | |
11 | # if any functions have been added, set INTERFACE_AGE to 0. | |
12 | # if backwards compatibility has been broken, | |
13 | # set BINARY_AGE and INTERFACE_AGE to 0. | |
14 | # | |
7 | # See release_checklist.md | |
15 | 8 | MAJOR_VERSION=2 |
16 | MINOR_VERSION=0 | |
17 | MICRO_VERSION=4 | |
18 | INTERFACE_AGE=2 | |
19 | BINARY_AGE=4 | |
9 | MINOR_VERSION=5 | |
10 | MICRO_VERSION=0 | |
20 | 11 | VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION |
12 | ||
13 | BINARY_AGE=`expr $MINOR_VERSION \* 100 + $MICRO_VERSION` | |
14 | AS_CASE(["$MINOR_VERSION"], | |
15 | [*@<:@02468@:>@], | |
16 | dnl Stable branch, 2.6.1 -> libSDL2_mixer-2.0.so.0.600.1 | |
17 | [INTERFACE_AGE="$MICRO_VERSION"], | |
18 | [*], | |
19 | dnl Development branch, 2.5.1 -> libSDL2_mixer-2.0.so.0.501.0 | |
20 | [INTERFACE_AGE=0]) | |
21 | 21 | |
22 | 22 | AC_SUBST(MAJOR_VERSION) |
23 | 23 | AC_SUBST(MINOR_VERSION) |
29 | 29 | dnl libtool versioning |
30 | 30 | LT_INIT([win32-dll]) |
31 | 31 | |
32 | LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION | |
33 | LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE` | |
32 | # For historical reasons, the library name redundantly includes the major | |
33 | # version twice: libSDL2_mixer-2.0.so.0. | |
34 | # TODO: in SDL 3, stop using -release, which will simplify it to libSDL3_mixer.so.0 | |
35 | LT_RELEASE=2.0 | |
36 | ||
37 | # Increment this if there is an incompatible change - but if that happens, | |
38 | # we should rename the library from SDL2 to SDL3, at which point this would | |
39 | # reset to 0 anyway. | |
40 | LT_MAJOR=0 | |
41 | ||
34 | 42 | LT_REVISION=$INTERFACE_AGE |
35 | 43 | LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE` |
44 | LT_CURRENT=`expr $LT_MAJOR + $LT_AGE` | |
45 | ||
36 | 46 | LT_EXTRA="" dnl for OS2 dll name |
37 | 47 | m4_pattern_allow([^LT_]) |
38 | 48 | |
41 | 51 | AC_SUBST(LT_REVISION) |
42 | 52 | AC_SUBST(LT_AGE) |
43 | 53 | AC_SUBST(LT_EXTRA) |
54 | ||
55 | dnl For use in static assertions | |
56 | AC_DEFINE_UNQUOTED([SDL_BUILD_MAJOR_VERSION], $MAJOR_VERSION, [ ]) | |
57 | AC_DEFINE_UNQUOTED([SDL_BUILD_MINOR_VERSION], $MINOR_VERSION, [ ]) | |
58 | AC_DEFINE_UNQUOTED([SDL_BUILD_MICRO_VERSION], $MICRO_VERSION, [ ]) | |
44 | 59 | |
45 | 60 | dnl Detect the canonical build and host environments |
46 | 61 | dnl AC_CANONICAL_HOST |
51 | 66 | AC_PROG_INSTALL |
52 | 67 | AC_PROG_MAKE_SET |
53 | 68 | LT_PROG_RC |
69 | PKG_PROG_PKG_CONFIG | |
54 | 70 | |
55 | 71 | dnl Set up the compiler and linker flags |
56 | 72 | case "$host" in |
135 | 151 | # Look for the location of the tools and install there |
136 | 152 | if test "$BUILD_PREFIX" != ""; then |
137 | 153 | ac_default_prefix=$BUILD_PREFIX |
154 | elif test "$MINGW_PREFIX" != ""; then | |
155 | ac_default_prefix=$MINGW_PREFIX | |
138 | 156 | fi |
139 | 157 | fi |
140 | 158 | ;; |
150 | 168 | SOURCES=`ls $srcdir/src/*.c $srcdir/src/codecs/*.c | fgrep -v playwave.c | fgrep -v playmus.c` |
151 | 169 | |
152 | 170 | dnl set this to use on systems that use lib64 instead of lib |
171 | base_bindir=`echo \${bindir} | sed 's/.*\/\(.*\)/\1/; q'` | |
153 | 172 | base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'` |
154 | 173 | |
155 | 174 | dnl See if GCC's -Wall is supported. |
219 | 238 | if test "$cross_compiling" = yes; then |
220 | 239 | host_lib_path="" |
221 | 240 | else |
222 | host_lib_path="/usr/$base_libdir /usr/local/$base_libdir" | |
241 | host_lib_path="$ac_default_prefix/$base_libdir $ac_default_prefix/$base_bindir /usr/$base_libdir /usr/local/$base_libdir" | |
223 | 242 | fi |
224 | 243 | for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do |
225 | 244 | lib=[`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1`] |
707 | 726 | flac_lib=[`find_lib libFLAC.dylib`] |
708 | 727 | ;; |
709 | 728 | *-*-cygwin* | *-*-mingw*) |
710 | flac_lib=[`find_lib "libFLAC-*.dll"`] | |
729 | flac_lib=[`find_lib "libFLAC*.dll"`] | |
711 | 730 | ;; |
712 | 731 | *) |
713 | 732 | flac_lib=[`find_lib "libFLAC[0-9]*.so.*"`] |
36 | 36 | /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL |
37 | 37 | */ |
38 | 38 | #define SDL_MIXER_MAJOR_VERSION 2 |
39 | #define SDL_MIXER_MINOR_VERSION 0 | |
40 | #define SDL_MIXER_PATCHLEVEL 4 | |
39 | #define SDL_MIXER_MINOR_VERSION 5 | |
40 | #define SDL_MIXER_PATCHLEVEL 0 | |
41 | 41 | |
42 | 42 | /* This macro can be used to fill a version structure with the compile-time |
43 | 43 | * version of the SDL_mixer library. |
55 | 55 | #define MIX_PATCHLEVEL SDL_MIXER_PATCHLEVEL |
56 | 56 | #define MIX_VERSION(X) SDL_MIXER_VERSION(X) |
57 | 57 | |
58 | #if SDL_MIXER_MAJOR_VERSION < 3 && SDL_MAJOR_VERSION < 3 | |
58 | 59 | /** |
59 | 60 | * This is the version number macro for the current SDL_mixer version. |
61 | * | |
62 | * In versions higher than 2.9.0, the minor version overflows into | |
63 | * the thousands digit: for example, 2.23.0 is encoded as 4300. | |
64 | * This macro will not be available in SDL 3.x or SDL_mixer 3.x. | |
65 | * | |
66 | * Deprecated, use SDL_MIXER_VERSION_ATLEAST or SDL_MIXER_VERSION instead. | |
60 | 67 | */ |
61 | 68 | #define SDL_MIXER_COMPILEDVERSION \ |
62 | 69 | SDL_VERSIONNUM(SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL) |
70 | #endif /* SDL_MIXER_MAJOR_VERSION < 3 && SDL_MAJOR_VERSION < 3 */ | |
63 | 71 | |
64 | 72 | /** |
65 | 73 | * This macro will evaluate to true if compiled with SDL_mixer at least X.Y.Z. |
66 | 74 | */ |
67 | 75 | #define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \ |
68 | (SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) | |
76 | ((SDL_MIXER_MAJOR_VERSION >= X) && \ | |
77 | (SDL_MIXER_MAJOR_VERSION > X || SDL_MIXER_MINOR_VERSION >= Y) && \ | |
78 | (SDL_MIXER_MAJOR_VERSION > X || SDL_MIXER_MINOR_VERSION > Y || SDL_MIXER_PATCHLEVEL >= Z)) | |
69 | 79 | |
70 | 80 | /* This function gets the version of the dynamically linked SDL_mixer library. |
71 | 81 | it should NOT be used to fill a version structure, instead you should |
76 | 76 | if (flac.FUNC == NULL) { SDL_UnloadObject(flac.handle); return -1; } |
77 | 77 | #else |
78 | 78 | #define FUNCTION_LOADER(FUNC, SIG) \ |
79 | flac.FUNC = FUNC; | |
79 | flac.FUNC = FUNC; \ | |
80 | if (flac.FUNC == NULL) { Mix_SetError("Missing FLAC.framework"); return -1; } | |
80 | 81 | #endif |
81 | 82 | |
82 | 83 | static int FLAC_Load(void) |
85 | 86 | #ifdef FLAC_DYNAMIC |
86 | 87 | flac.handle = SDL_LoadObject(FLAC_DYNAMIC); |
87 | 88 | if (flac.handle == NULL) { |
88 | return -1; | |
89 | } | |
90 | #elif defined(__MACOSX__) | |
91 | extern FLAC__StreamDecoder *FLAC__stream_decoder_new(void) __attribute__((weak_import)); | |
92 | if (FLAC__stream_decoder_new == NULL) | |
93 | { | |
94 | /* Missing weakly linked framework */ | |
95 | Mix_SetError("Missing FLAC.framework"); | |
96 | 89 | return -1; |
97 | 90 | } |
98 | 91 | #endif |
79 | 79 | if (mikmod.NAME == NULL) { SDL_UnloadObject(mikmod.handle); return -1; } |
80 | 80 | #else |
81 | 81 | #define FUNCTION_LOADER(FUNC, SIG) \ |
82 | mikmod.FUNC = FUNC; | |
82 | mikmod.FUNC = FUNC; \ | |
83 | if (mikmod.FUNC == NULL) { Mix_SetError("Missing mikmod.framework"); return -1; } | |
83 | 84 | #define VARIABLE_LOADER(NAME, SIG) \ |
84 | 85 | mikmod.NAME = &NAME; |
85 | 86 | #endif |
90 | 91 | #ifdef MIKMOD_DYNAMIC |
91 | 92 | mikmod.handle = SDL_LoadObject(MIKMOD_DYNAMIC); |
92 | 93 | if (mikmod.handle == NULL) { |
93 | return -1; | |
94 | } | |
95 | #elif defined(__MACOSX__) | |
96 | extern void Player_Start(MODULE*) __attribute__((weak_import)); | |
97 | if (Player_Start == NULL) | |
98 | { | |
99 | /* Missing weakly linked framework */ | |
100 | Mix_SetError("Missing mikmod.framework"); | |
101 | 94 | return -1; |
102 | 95 | } |
103 | 96 | #endif |
56 | 56 | if (modplug.FUNC == NULL) { SDL_UnloadObject(modplug.handle); return -1; } |
57 | 57 | #else |
58 | 58 | #define FUNCTION_LOADER(FUNC, SIG) \ |
59 | modplug.FUNC = FUNC; | |
59 | modplug.FUNC = FUNC; \ | |
60 | if (modplug.FUNC == NULL) { Mix_SetError("Missing libmodplug.framework"); return -1; } | |
60 | 61 | #endif |
61 | 62 | |
62 | 63 | static int MODPLUG_Load(void) |
65 | 66 | #ifdef MODPLUG_DYNAMIC |
66 | 67 | modplug.handle = SDL_LoadObject(MODPLUG_DYNAMIC); |
67 | 68 | if (modplug.handle == NULL) { |
68 | return -1; | |
69 | } | |
70 | #elif defined(__MACOSX__) | |
71 | extern ModPlugFile* ModPlug_Load(const void* data, int size) __attribute__((weak_import)); | |
72 | if (ModPlug_Load == NULL) { | |
73 | /* Missing weakly linked framework */ | |
74 | Mix_SetError("Missing modplug.framework"); | |
75 | 69 | return -1; |
76 | 70 | } |
77 | 71 | #endif |
29 | 29 | #include "mp3utils.h" |
30 | 30 | |
31 | 31 | #include <stdio.h> /* For SEEK_SET */ |
32 | #ifdef MPG123_HEADER | |
33 | #include MPG123_HEADER | |
34 | #else | |
32 | 35 | #include <mpg123.h> |
36 | #endif | |
33 | 37 | #ifdef _MSC_VER |
34 | 38 | typedef ptrdiff_t MIX_SSIZE_T; |
35 | 39 | #else |
72 | 76 | if (mpg123.FUNC == NULL) { SDL_UnloadObject(mpg123.handle); return -1; } |
73 | 77 | #else |
74 | 78 | #define FUNCTION_LOADER(FUNC, SIG) \ |
75 | mpg123.FUNC = FUNC; | |
79 | mpg123.FUNC = FUNC; \ | |
80 | if (mpg123.FUNC == NULL) { Mix_SetError("Missing mpg123.framework"); return -1; } | |
76 | 81 | #endif |
77 | 82 | |
78 | 83 | static int MPG123_Load(void) |
81 | 86 | #ifdef MPG123_DYNAMIC |
82 | 87 | mpg123.handle = SDL_LoadObject(MPG123_DYNAMIC); |
83 | 88 | if (mpg123.handle == NULL) { |
84 | return -1; | |
85 | } | |
86 | #elif defined(__MACOSX__) | |
87 | extern int mpg123_init(void) __attribute__((weak_import)); | |
88 | if (mpg123_init == NULL) | |
89 | { | |
90 | /* Missing weakly linked framework */ | |
91 | Mix_SetError("Missing mpg123.framework"); | |
92 | 89 | return -1; |
93 | 90 | } |
94 | 91 | #endif |
68 | 68 | if (vorbis.FUNC == NULL) { SDL_UnloadObject(vorbis.handle); return -1; } |
69 | 69 | #else |
70 | 70 | #define FUNCTION_LOADER(FUNC, SIG) \ |
71 | vorbis.FUNC = FUNC; | |
71 | vorbis.FUNC = FUNC; \ | |
72 | if (vorbis.FUNC == NULL) { Mix_SetError("Missing vorbis.framework or tremor.framework"); return -1; } | |
72 | 73 | #endif |
73 | 74 | |
74 | 75 | static int OGG_Load(void) |
77 | 78 | #ifdef OGG_DYNAMIC |
78 | 79 | vorbis.handle = SDL_LoadObject(OGG_DYNAMIC); |
79 | 80 | if (vorbis.handle == NULL) { |
80 | return -1; | |
81 | } | |
82 | #elif defined(__MACOSX__) | |
83 | extern int ov_open_callbacks(void*, OggVorbis_File*, const char*, long, ov_callbacks) __attribute__((weak_import)); | |
84 | if (ov_open_callbacks == NULL) | |
85 | { | |
86 | /* Missing weakly linked framework */ | |
87 | Mix_SetError("Missing Vorbis.framework"); | |
88 | 81 | return -1; |
89 | 82 | } |
90 | 83 | #endif |
177 | 170 | |
178 | 171 | static int sdl_seek_func(void *datasource, ogg_int64_t offset, int whence) |
179 | 172 | { |
180 | return (int)SDL_RWseek((SDL_RWops*)datasource, offset, whence); | |
173 | return (SDL_RWseek((SDL_RWops*)datasource, offset, whence) < 0)? -1 : 0; | |
181 | 174 | } |
182 | 175 | |
183 | 176 | static long sdl_tell_func(void *datasource) |
27 | 27 | #include "music_opus.h" |
28 | 28 | #include "utils.h" |
29 | 29 | |
30 | #if defined(OPUS_HEADER) | |
31 | #include OPUS_HEADER | |
32 | #else | |
33 | 30 | #include <opus/opusfile.h> |
34 | #endif | |
35 | 31 | |
36 | 32 | typedef struct { |
37 | 33 | int loaded; |
55 | 51 | if (opus.FUNC == NULL) { SDL_UnloadObject(opus.handle); return -1; } |
56 | 52 | #else |
57 | 53 | #define FUNCTION_LOADER(FUNC, SIG) \ |
58 | opus.FUNC = FUNC; | |
54 | opus.FUNC = FUNC; \ | |
55 | if (opus.FUNC == NULL) { Mix_SetError("Missing opus.framework"); return -1; } | |
59 | 56 | #endif |
60 | 57 | |
61 | 58 | static int OPUS_Load(void) |
64 | 61 | #ifdef OPUS_DYNAMIC |
65 | 62 | opus.handle = SDL_LoadObject(OPUS_DYNAMIC); |
66 | 63 | if (opus.handle == NULL) { |
67 | return -1; | |
68 | } | |
69 | #elif defined(__MACOSX__) | |
70 | extern OggOpusFile *op_open_callbacks(void *,const OpusFileCallbacks *,const unsigned char *,size_t,int *) __attribute__((weak_import)); | |
71 | if (op_open_callbacks == NULL) { | |
72 | /* Missing weakly linked framework */ | |
73 | Mix_SetError("Missing OpusFile.framework"); | |
74 | 64 | return -1; |
75 | 65 | } |
76 | 66 | #endif |
31 | 31 | #endif |
32 | 32 | |
33 | 33 | /* libxmp >= 4.5.0 constified several funcs */ |
34 | /* and also added load using file callbacks */ | |
34 | 35 | #if (XMP_VERCODE < 0x040500) |
36 | struct xmp_callbacks { | |
37 | unsigned long (*read_func)(void *, unsigned long, unsigned long, void *); | |
38 | int (*seek_func)(void *, long, int); | |
39 | long (*tell_func)(void *); | |
40 | int (*close_func)(void*); | |
41 | }; | |
35 | 42 | #define LIBXMP_CONST |
36 | 43 | #else |
37 | 44 | #define LIBXMP_CONST const |
43 | 50 | |
44 | 51 | xmp_context (*xmp_create_context)(void); |
45 | 52 | int (*xmp_load_module_from_memory)(xmp_context, LIBXMP_CONST void *, long); |
53 | int (*xmp_load_module_from_callbacks)(xmp_context, void *, struct xmp_callbacks); | |
46 | 54 | int (*xmp_start_player)(xmp_context, int, int); |
47 | 55 | void (*xmp_end_player)(xmp_context); |
48 | 56 | void (*xmp_get_module_info)(xmp_context, struct xmp_module_info *); |
63 | 71 | if (libxmp.FUNC == NULL) { SDL_UnloadObject(libxmp.handle); return -1; } |
64 | 72 | #else |
65 | 73 | #define FUNCTION_LOADER(FUNC, SIG) \ |
66 | libxmp.FUNC = FUNC; | |
74 | libxmp.FUNC = FUNC; \ | |
75 | if (libxmp.FUNC == NULL) { Mix_SetError("Missing xmp.framework"); return -1; } | |
67 | 76 | #endif |
68 | 77 | |
69 | 78 | static int XMP_Load(void) |
72 | 81 | #ifdef XMP_DYNAMIC |
73 | 82 | libxmp.handle = SDL_LoadObject(XMP_DYNAMIC); |
74 | 83 | if (libxmp.handle == NULL) { |
75 | return -1; | |
76 | } | |
77 | #elif defined(__MACOSX__) | |
78 | extern xmp_context xmp_create_context(void) __attribute__((weak_import)); | |
79 | if (xmp_create_context == NULL) { | |
80 | /* Missing weakly linked framework */ | |
81 | Mix_SetError("Missing xmp.framework"); | |
82 | 84 | return -1; |
83 | 85 | } |
84 | 86 | #endif |
94 | 96 | FUNCTION_LOADER(xmp_stop_module, void(*)(xmp_context)) |
95 | 97 | FUNCTION_LOADER(xmp_release_module, void(*)(xmp_context)) |
96 | 98 | FUNCTION_LOADER(xmp_free_context, void(*)(xmp_context)) |
99 | #if defined(XMP_DYNAMIC) | |
100 | libxmp.xmp_load_module_from_callbacks = (int (*)(xmp_context,void*,struct xmp_callbacks)) SDL_LoadFunction(libxmp.handle, "xmp_load_module_from_callbacks"); | |
101 | #elif (XMP_VERCODE >= 0x040500) | |
102 | libxmp.xmp_load_module_from_callbacks = xmp_load_module_from_callbacks; | |
103 | #else | |
104 | libxmp.xmp_load_module_from_callbacks = NULL; | |
105 | #endif | |
97 | 106 | } |
98 | 107 | ++libxmp.loaded; |
99 | 108 | |
163 | 172 | Mix_SetError("XMP: %s", msg); |
164 | 173 | } |
165 | 174 | |
175 | static unsigned long xmp_fread(void *dst, unsigned long len, unsigned long nmemb, void *src) { | |
176 | return SDL_RWread((SDL_RWops*)src, dst, len, nmemb); | |
177 | } | |
178 | static int xmp_fseek(void *src, long offset, int whence) { | |
179 | return (SDL_RWseek((SDL_RWops*)src, offset, whence) < 0)? -1 : 0; | |
180 | } | |
181 | static long xmp_ftell(void *src) { | |
182 | return SDL_RWtell((SDL_RWops*)src); | |
183 | } | |
184 | ||
166 | 185 | /* Load a libxmp stream from an SDL_RWops object */ |
167 | 186 | void *XMP_CreateFromRW(SDL_RWops *src, int freesrc) |
168 | 187 | { |
169 | 188 | XMP_Music *music; |
170 | void *mem; | |
171 | size_t size; | |
172 | int err; | |
189 | struct xmp_callbacks file_callbacks = { | |
190 | xmp_fread, xmp_fseek, xmp_ftell, NULL | |
191 | }; | |
192 | int err = 0; | |
173 | 193 | |
174 | 194 | music = (XMP_Music *)SDL_calloc(1, sizeof(*music)); |
175 | 195 | if (!music) { |
190 | 210 | goto e1; |
191 | 211 | } |
192 | 212 | |
193 | mem = SDL_LoadFile_RW(src, &size, SDL_FALSE); | |
194 | if (mem) { | |
213 | if (libxmp.xmp_load_module_from_callbacks) { | |
214 | err = libxmp.xmp_load_module_from_callbacks(music->ctx, src, file_callbacks); | |
215 | } else { | |
216 | size_t size; | |
217 | void *mem = SDL_LoadFile_RW(src, &size, SDL_FALSE); | |
218 | if (!mem) { | |
219 | SDL_OutOfMemory(); | |
220 | goto e1; | |
221 | } | |
195 | 222 | err = libxmp.xmp_load_module_from_memory(music->ctx, mem, (long)size); |
196 | 223 | SDL_free(mem); |
197 | if (err < 0) { | |
198 | libxmp_set_error(err); | |
199 | goto e1; | |
200 | } | |
201 | } else { | |
202 | SDL_OutOfMemory(); | |
224 | } | |
225 | ||
226 | if (err < 0) { | |
227 | libxmp_set_error(err); | |
203 | 228 | goto e1; |
204 | 229 | } |
205 | 230 |
0 | cmake_minimum_required(VERSION 2.8.11) | |
1 | project(timidity_sdl C) | |
2 | ||
3 | include(${CMAKE_CURRENT_SOURCE_DIR}/../../../external/audio_codec_common.cmake) | |
4 | ||
5 | find_package(SDL2 REQUIRED) | |
6 | ||
7 | add_library(timidity STATIC | |
8 | common.c | |
9 | instrum.c | |
10 | mix.c | |
11 | output.c | |
12 | playmidi.c | |
13 | readmidi.c | |
14 | resample.c | |
15 | tables.c | |
16 | timidity.c | |
17 | ) | |
18 | ||
19 | target_include_directories(timidity PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) | |
20 | target_include_directories(timidity PUBLIC ${SDL2_INCLUDE_DIRS}) | |
21 | ||
22 | install(TARGETS timidity | |
23 | LIBRARY DESTINATION "lib" | |
24 | ARCHIVE DESTINATION "lib" | |
25 | INCLUDES DESTINATION "include") | |
26 | ||
27 | install(FILES | |
28 | timidity.h | |
29 | DESTINATION include/) |
34 | 34 | #define WAVE 0x45564157 /* "WAVE" */ |
35 | 35 | #define FORM 0x4d524f46 /* "FORM" */ |
36 | 36 | #define CREA 0x61657243 /* "Crea" */ |
37 | ||
38 | #if defined(SDL_BUILD_MAJOR_VERSION) && defined(SDL_COMPILE_TIME_ASSERT) | |
39 | SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MAJOR_VERSION, | |
40 | SDL_MIXER_MAJOR_VERSION == SDL_BUILD_MAJOR_VERSION); | |
41 | SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MINOR_VERSION, | |
42 | SDL_MIXER_MINOR_VERSION == SDL_BUILD_MINOR_VERSION); | |
43 | SDL_COMPILE_TIME_ASSERT(SDL_BUILD_MICRO_VERSION, | |
44 | SDL_MIXER_PATCHLEVEL == SDL_BUILD_MICRO_VERSION); | |
45 | #endif | |
46 | ||
47 | #if defined(SDL_COMPILE_TIME_ASSERT) | |
48 | SDL_COMPILE_TIME_ASSERT(SDL_MIXER_MAJOR_VERSION_min, SDL_MIXER_MAJOR_VERSION >= 0); | |
49 | /* Limited only by the need to fit in SDL_version */ | |
50 | SDL_COMPILE_TIME_ASSERT(SDL_MIXER_MAJOR_VERSION_max, SDL_MIXER_MAJOR_VERSION <= 255); | |
51 | ||
52 | SDL_COMPILE_TIME_ASSERT(SDL_MIXER_MINOR_VERSION_min, SDL_MIXER_MINOR_VERSION >= 0); | |
53 | /* Limited only by the need to fit in SDL_version */ | |
54 | SDL_COMPILE_TIME_ASSERT(SDL_MIXER_MINOR_VERSION_max, SDL_MIXER_MINOR_VERSION <= 255); | |
55 | ||
56 | SDL_COMPILE_TIME_ASSERT(SDL_MIXER_PATCHLEVEL_min, SDL_MIXER_PATCHLEVEL >= 0); | |
57 | /* Limited by its encoding in SDL_VERSIONNUM and in the ABI versions */ | |
58 | SDL_COMPILE_TIME_ASSERT(SDL_MIXER_PATCHLEVEL_max, SDL_MIXER_PATCHLEVEL <= 99); | |
59 | #endif | |
37 | 60 | |
38 | 61 | static int audio_opened = 0; |
39 | 62 | static SDL_AudioSpec mixer; |
8 | 8 | // |
9 | 9 | |
10 | 10 | VS_VERSION_INFO VERSIONINFO |
11 | FILEVERSION 2,0,4,0 | |
12 | PRODUCTVERSION 2,0,4,0 | |
11 | FILEVERSION 2,5,0,0 | |
12 | PRODUCTVERSION 2,5,0,0 | |
13 | 13 | FILEFLAGSMASK 0x3fL |
14 | 14 | FILEFLAGS 0x0L |
15 | 15 | FILEOS 0x40004L |
22 | 22 | BEGIN |
23 | 23 | VALUE "CompanyName", "\0" |
24 | 24 | VALUE "FileDescription", "SDL_mixer\0" |
25 | VALUE "FileVersion", "2, 0, 4, 0\0" | |
25 | VALUE "FileVersion", "2, 5, 0, 0\0" | |
26 | 26 | VALUE "InternalName", "SDL_mixer\0" |
27 | 27 | VALUE "LegalCopyright", "Copyright © 2022 Sam Lantinga\0" |
28 | 28 | VALUE "OriginalFilename", "SDL_mixer.dll\0" |
29 | 29 | VALUE "ProductName", "Simple DirectMedia Layer\0" |
30 | VALUE "ProductVersion", "2, 0, 4, 0\0" | |
30 | VALUE "ProductVersion", "2, 5, 0, 0\0" | |
31 | 31 | END |
32 | 32 | END |
33 | 33 | BLOCK "VarFileInfo" |