New upstream version 2.0.5~20220103.g3f5a050+dfsg
Simon McVittie
1 year, 10 months ago
0 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
0 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
1 | 1 | |
2 | 2 | This software is provided 'as-is', without any express or implied |
3 | 3 | warranty. In no event will the authors be held liable for any damages |
23 | 23 | USE_FLAC=yes |
24 | 24 | # opus music support |
25 | 25 | USE_OPUS=yes |
26 | # mp3 music support (using libmad) | |
26 | # mp3 music support (using libmad - Note: GPL license!) | |
27 | 27 | USE_LIBMAD=no |
28 | 28 | # mp3 music support (using mpg123) |
29 | 29 | USE_MPG123=yes |
61 | 61 | CFLAGS_BASE = -bt=os2 -d0 -q -bm -5s -fp5 -fpi87 -sg -oteanbmier -ei -j |
62 | 62 | # warnings: |
63 | 63 | CFLAGS_BASE+= -wx |
64 | # newer OpenWatcom versions enable W303 by default | |
65 | CFLAGS_BASE+= -wcd=303 | |
64 | 66 | # include paths: |
65 | 67 | CFLAGS_BASE+= -Iinclude -Isrc -I"src/codecs" -I"src/codecs/timidity" $(DEPS_INC) |
66 | 68 | CFLAGS_BASE+= -I"$(%WATCOM)/h/os2" -I"$(%WATCOM)/h" |
148 | 150 | @%append $@ NAME $(LIBNAME) |
149 | 151 | @for %i in ($(OBJS)) do @%append $@ FILE %i |
150 | 152 | @%append $@ OPTION QUIET |
151 | @%append $@ OPTION DESCRIPTION '@$#libsdl org:$(VERSION)$#@Simple DirectMedia Layer Mixer' | |
153 | @%append $@ OPTION DESCRIPTION '@$#libsdl org:$(VERSION)$#@Simple DirectMedia Layer Mixer Library' | |
152 | 154 | @%append $@ LIBPATH $(DEPS_LIB) |
153 | 155 | @for %i in ($(LIBS)) do @%append $@ LIB %i |
154 | 156 | @%append $@ OPTION MAP=$* |
152 | 152 | base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'` |
153 | 153 | |
154 | 154 | dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually). |
155 | dnl Details of this flag are here: http://gcc.gnu.org/wiki/Visibility | |
156 | 155 | CheckVisibilityHidden() |
157 | 156 | { |
158 | 157 | AC_MSG_CHECKING(for GCC -fvisibility=hidden option) |
159 | 158 | have_gcc_fvisibility=no |
159 | case "$host" in | |
160 | *-*-cygwin* | *-*-mingw* | *-*-os2*) | |
161 | AC_MSG_RESULT([ignored for $host_os]) | |
162 | return | |
163 | ;; | |
164 | esac | |
160 | 165 | |
161 | 166 | visibility_CFLAGS="-fvisibility=hidden" |
162 | 167 | save_CFLAGS="$CFLAGS" |
174 | 179 | fi |
175 | 180 | } |
176 | 181 | |
177 | ||
178 | 182 | dnl Function to find a library in the compiler search path |
179 | 183 | find_lib() |
180 | 184 | { |
204 | 208 | EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS" |
205 | 209 | EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS" |
206 | 210 | |
211 | dnl check for GCC visibility attributes | |
212 | CheckVisibilityHidden | |
213 | ||
207 | 214 | dnl Check for math library |
208 | 215 | AC_CHECK_LIB(m, pow, [LIBM="-lm"]) |
209 | 216 | |
211 | 218 | AC_CHECK_FUNCS(setbuf, [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SETBUF"]) |
212 | 219 | |
213 | 220 | dnl Check command-line options |
214 | ||
215 | CheckVisibilityHidden | |
216 | 221 | |
217 | 222 | AC_ARG_ENABLE([music-cmd], |
218 | 223 | [AS_HELP_STRING([--enable-music-cmd], [support an external music player [default=yes]])], |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
689 | 689 | #define Mix_SetError SDL_SetError |
690 | 690 | #define Mix_GetError SDL_GetError |
691 | 691 | #define Mix_ClearError SDL_ClearError |
692 | #define Mix_OutOfMemory SDL_OutOfMemory | |
692 | 693 | |
693 | 694 | /* Ends C function definitions when using C++ */ |
694 | 695 | #ifdef __cplusplus |
0 | 0 | /* |
1 | 1 | PLAYMUS: A test application for the SDL mixer library. |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | PLAYWAVE: A test application for the SDL mixer library. |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
107 | 107 | AIFFmagic = SDL_ReadLE32(src); |
108 | 108 | } |
109 | 109 | if ((FORMchunk != FORM) || ((AIFFmagic != AIFF) && (AIFFmagic != _8SVX))) { |
110 | SDL_SetError("Unrecognized file type (not AIFF nor 8SVX)"); | |
110 | Mix_SetError("Unrecognized file type (not AIFF nor 8SVX)"); | |
111 | 111 | was_error = 1; |
112 | 112 | goto done; |
113 | 113 | } |
144 | 144 | SDL_RWread(src, sane_freq, sizeof(sane_freq), 1); |
145 | 145 | frequency = SANE_to_Uint32(sane_freq); |
146 | 146 | if (frequency == 0) { |
147 | SDL_SetError("Bad AIFF sample frequency"); | |
147 | Mix_SetError("Bad AIFF sample frequency"); | |
148 | 148 | was_error = 1; |
149 | 149 | goto done; |
150 | 150 | } |
177 | 177 | && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != 1); |
178 | 178 | |
179 | 179 | if ((AIFFmagic == AIFF) && !found_SSND) { |
180 | SDL_SetError("Bad AIFF (no SSND chunk)"); | |
180 | Mix_SetError("Bad AIFF (no SSND chunk)"); | |
181 | 181 | was_error = 1; |
182 | 182 | goto done; |
183 | 183 | } |
184 | 184 | |
185 | 185 | if ((AIFFmagic == AIFF) && !found_COMM) { |
186 | SDL_SetError("Bad AIFF (no COMM chunk)"); | |
186 | Mix_SetError("Bad AIFF (no COMM chunk)"); | |
187 | 187 | was_error = 1; |
188 | 188 | goto done; |
189 | 189 | } |
190 | 190 | |
191 | 191 | if ((AIFFmagic == _8SVX) && !found_VHDR) { |
192 | SDL_SetError("Bad 8SVX (no VHDR chunk)"); | |
192 | Mix_SetError("Bad 8SVX (no VHDR chunk)"); | |
193 | 193 | was_error = 1; |
194 | 194 | goto done; |
195 | 195 | } |
196 | 196 | |
197 | 197 | if ((AIFFmagic == _8SVX) && !found_BODY) { |
198 | SDL_SetError("Bad 8SVX (no BODY chunk)"); | |
198 | Mix_SetError("Bad 8SVX (no BODY chunk)"); | |
199 | 199 | was_error = 1; |
200 | 200 | goto done; |
201 | 201 | } |
211 | 211 | spec->format = AUDIO_S16MSB; |
212 | 212 | break; |
213 | 213 | default: |
214 | SDL_SetError("Unsupported AIFF samplesize"); | |
214 | Mix_SetError("Unsupported AIFF samplesize"); | |
215 | 215 | was_error = 1; |
216 | 216 | goto done; |
217 | 217 | } |
221 | 221 | *audio_len = channels * numsamples * (samplesize / 8); |
222 | 222 | *audio_buf = (Uint8 *)SDL_malloc(*audio_len); |
223 | 223 | if (*audio_buf == NULL) { |
224 | SDL_SetError("Out of memory"); | |
224 | Mix_OutOfMemory(); | |
225 | 225 | return(NULL); |
226 | 226 | } |
227 | 227 | SDL_RWseek(src, start, RW_SEEK_SET); |
228 | 228 | if (SDL_RWread(src, *audio_buf, *audio_len, 1) != 1) { |
229 | SDL_SetError("Unable to read audio data"); | |
229 | Mix_SetError("Unable to read audio data"); | |
230 | 230 | return(NULL); |
231 | 231 | } |
232 | 232 |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
64 | 64 | /* Allocate and fill the music structure */ |
65 | 65 | music = (MusicCMD *)SDL_calloc(1, sizeof *music); |
66 | 66 | if (music == NULL) { |
67 | Mix_SetError("Out of memory"); | |
67 | Mix_OutOfMemory(); | |
68 | 68 | return NULL; |
69 | 69 | } |
70 | 70 | music->file = SDL_strdup(file); |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
68 | 68 | FLAC__MetadataType type); |
69 | 69 | } flac_loader; |
70 | 70 | |
71 | static flac_loader flac = { | |
72 | 0, NULL | |
73 | }; | |
71 | static flac_loader flac; | |
74 | 72 | |
75 | 73 | #ifdef FLAC_DYNAMIC |
76 | 74 | #define FUNCTION_LOADER(FUNC, SIG) \ |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
61 | 61 | fluid_synth_t* (*new_fluid_synth)(fluid_settings_t*); |
62 | 62 | } fluidsynth_loader; |
63 | 63 | |
64 | static fluidsynth_loader fluidsynth = { | |
65 | 0, NULL | |
66 | }; | |
64 | static fluidsynth_loader fluidsynth; | |
67 | 65 | |
68 | 66 | #ifdef FLUIDSYNTH_DYNAMIC |
69 | 67 | #define FUNCTION_LOADER(FUNC, SIG) \ |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
68 | 68 | UBYTE* md_volume; |
69 | 69 | } mikmod_loader; |
70 | 70 | |
71 | static mikmod_loader mikmod = { | |
72 | 0, NULL | |
73 | }; | |
71 | static mikmod_loader mikmod; | |
74 | 72 | |
75 | 73 | #ifdef MIKMOD_DYNAMIC |
76 | 74 | #define FUNCTION_LOADER(FUNC, SIG) \ |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
46 | 46 | const char* (*ModPlug_GetName)(ModPlugFile* file); |
47 | 47 | } modplug_loader; |
48 | 48 | |
49 | static modplug_loader modplug = { | |
50 | 0, NULL | |
51 | }; | |
52 | ||
49 | static modplug_loader modplug; | |
53 | 50 | |
54 | 51 | static ModPlug_Settings settings; |
55 | 52 |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
60 | 60 | const char* (*mpg123_strerror)(mpg123_handle *mh); |
61 | 61 | } mpg123_loader; |
62 | 62 | |
63 | static mpg123_loader mpg123 = { | |
64 | 0, NULL | |
65 | }; | |
63 | static mpg123_loader mpg123; | |
66 | 64 | |
67 | 65 | #ifdef MPG123_DYNAMIC |
68 | 66 | #define FUNCTION_LOADER(FUNC, SIG) \ |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
60 | 60 | ogg_int64_t (*ov_pcm_tell)(OggVorbis_File *vf); |
61 | 61 | } vorbis_loader; |
62 | 62 | |
63 | static vorbis_loader vorbis = { | |
64 | 0, NULL | |
65 | }; | |
63 | static vorbis_loader vorbis; | |
66 | 64 | |
67 | 65 | #ifdef OGG_DYNAMIC |
68 | 66 | #define FUNCTION_LOADER(FUNC, SIG) \ |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
47 | 47 | ogg_int64_t (*op_pcm_total)(const OggOpusFile *, int); |
48 | 48 | } opus_loader; |
49 | 49 | |
50 | static opus_loader opus = { | |
51 | 0, NULL | |
52 | }; | |
50 | static opus_loader opus; | |
53 | 51 | |
54 | 52 | #ifdef OPUS_DYNAMIC |
55 | 53 | #define FUNCTION_LOADER(FUNC, SIG) \ |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
78 | 78 | #define WAVE_MONO 1 |
79 | 79 | #define WAVE_STEREO 2 |
80 | 80 | |
81 | #pragma pack(push, 1) | |
81 | 82 | typedef struct { |
82 | 83 | /* Not saved in the chunk we read: |
83 | 84 | Uint32 chunkID; |
92 | 93 | } WaveFMT; |
93 | 94 | |
94 | 95 | typedef struct { |
96 | WaveFMT format; | |
95 | 97 | Uint16 cbSize; |
96 | 98 | union { |
97 | 99 | Uint16 validbitspersample; /* bits of precision */ |
104 | 106 | Uint16 sub_data2; |
105 | 107 | Uint16 sub_data3; |
106 | 108 | Uint8 sub_data[8]; |
107 | } WaveFMTex; | |
109 | } WaveFMTEx; | |
108 | 110 | |
109 | 111 | typedef struct { |
110 | 112 | Uint32 identifier; |
131 | 133 | Uint32 sampler_data; |
132 | 134 | SampleLoop loops[1]; |
133 | 135 | } SamplerChunk; |
136 | #pragma pack(pop) | |
134 | 137 | |
135 | 138 | /*********************************************/ |
136 | 139 | /* Define values for AIFF (IFF audio) format */ |
177 | 180 | |
178 | 181 | music = (WAV_Music *)SDL_calloc(1, sizeof(*music)); |
179 | 182 | if (!music) { |
180 | SDL_OutOfMemory(); | |
183 | Mix_OutOfMemory(); | |
181 | 184 | return NULL; |
182 | 185 | } |
183 | 186 | music->src = src; |
200 | 203 | } |
201 | 204 | music->buffer = (Uint8*)SDL_malloc(music->spec.size); |
202 | 205 | if (!music->buffer) { |
206 | Mix_OutOfMemory(); | |
203 | 207 | WAV_Delete(music); |
204 | 208 | return NULL; |
205 | 209 | } |
542 | 546 | if (loop->current_play_count > 0) { |
543 | 547 | --loop->current_play_count; |
544 | 548 | } |
545 | SDL_RWseek(music->src, loop_start, RW_SEEK_SET); | |
549 | if (SDL_RWseek(music->src, loop_start, RW_SEEK_SET) < 0) | |
550 | return -1; | |
546 | 551 | looped = SDL_TRUE; |
547 | 552 | } |
548 | 553 | } |
581 | 586 | destpos -= dest_offset % sample_size; |
582 | 587 | if (destpos > music->stop) |
583 | 588 | return -1; |
584 | SDL_RWseek(music->src, destpos, RW_SEEK_SET); | |
589 | if (SDL_RWseek(music->src, destpos, RW_SEEK_SET) < 0) | |
590 | return -1; | |
585 | 591 | return 0; |
586 | 592 | } |
587 | 593 | |
631 | 637 | static SDL_bool ParseFMT(WAV_Music *wave, Uint32 chunk_length) |
632 | 638 | { |
633 | 639 | SDL_AudioSpec *spec = &wave->spec; |
634 | WaveFMT *format; | |
635 | WaveFMTex *formatEx = NULL; | |
636 | Uint8 *data; | |
640 | WaveFMTEx fmt; | |
641 | size_t size; | |
637 | 642 | int bits; |
638 | SDL_bool loaded = SDL_FALSE; | |
639 | ||
640 | if (chunk_length < sizeof(*format)) { | |
643 | ||
644 | if (chunk_length < sizeof(fmt.format)) { | |
641 | 645 | Mix_SetError("Wave format chunk too small"); |
642 | 646 | return SDL_FALSE; |
643 | 647 | } |
644 | 648 | |
645 | data = (Uint8 *)SDL_malloc(chunk_length); | |
646 | if (!data) { | |
647 | Mix_SetError("Out of memory"); | |
648 | return SDL_FALSE; | |
649 | } | |
650 | if (!SDL_RWread(wave->src, data, chunk_length, 1)) { | |
649 | size = (chunk_length >= sizeof(fmt)) ? sizeof(fmt) : sizeof(fmt.format); | |
650 | if (!SDL_RWread(wave->src, &fmt, size, 1)) { | |
651 | 651 | Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length); |
652 | goto done; | |
653 | } | |
654 | format = (WaveFMT *)data; | |
655 | ||
656 | wave->encoding = SDL_SwapLE16(format->encoding); | |
652 | return SDL_FALSE; | |
653 | } | |
654 | chunk_length -= size; | |
655 | if (chunk_length != 0 && SDL_RWseek(wave->src, chunk_length, RW_SEEK_CUR) < 0) { | |
656 | Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length); | |
657 | return SDL_FALSE; | |
658 | } | |
659 | ||
660 | wave->encoding = SDL_SwapLE16(fmt.format.encoding); | |
657 | 661 | |
658 | 662 | if (wave->encoding == EXT_CODE) { |
659 | formatEx = (WaveFMTex*)(data + sizeof(WaveFMT)); | |
660 | wave->encoding = (Uint16)SDL_SwapLE32(formatEx->subencoding); | |
663 | if (size < sizeof(fmt)) { | |
664 | Mix_SetError("Wave format chunk too small"); | |
665 | return SDL_FALSE; | |
666 | } | |
667 | wave->encoding = (Uint16)SDL_SwapLE32(fmt.subencoding); | |
661 | 668 | } |
662 | 669 | |
663 | 670 | /* Decode the audio data format */ |
678 | 685 | default: |
679 | 686 | /* but NOT this */ |
680 | 687 | Mix_SetError("Unknown WAVE data format"); |
681 | goto done; | |
682 | } | |
683 | spec->freq = (int)SDL_SwapLE32(format->frequency); | |
684 | bits = (int) SDL_SwapLE16(format->bitspersample); | |
688 | return SDL_FALSE; | |
689 | } | |
690 | spec->freq = (int)SDL_SwapLE32(fmt.format.frequency); | |
691 | bits = (int) SDL_SwapLE16(fmt.format.bitspersample); | |
685 | 692 | switch (bits) { |
686 | 693 | case 8: |
687 | 694 | switch(wave->encoding) { |
725 | 732 | default: |
726 | 733 | unknown_bits: |
727 | 734 | Mix_SetError("Unknown PCM format with %d bits", bits); |
728 | goto done; | |
729 | } | |
730 | spec->channels = (Uint8) SDL_SwapLE16(format->channels); | |
735 | return SDL_FALSE; | |
736 | } | |
737 | spec->channels = (Uint8) SDL_SwapLE16(fmt.format.channels); | |
731 | 738 | spec->samples = 4096; /* Good default buffer size */ |
732 | 739 | wave->samplesize = spec->channels * (bits / 8); |
733 | 740 | /* SDL_CalculateAudioSpec */ |
735 | 742 | spec->size *= spec->channels; |
736 | 743 | spec->size *= spec->samples; |
737 | 744 | |
738 | loaded = SDL_TRUE; | |
739 | ||
740 | done: | |
741 | SDL_free(data); | |
742 | return loaded; | |
745 | return SDL_TRUE; | |
743 | 746 | } |
744 | 747 | |
745 | 748 | static SDL_bool ParseDATA(WAV_Music *wave, Uint32 chunk_length) |
746 | 749 | { |
747 | 750 | wave->start = SDL_RWtell(wave->src); |
748 | 751 | wave->stop = wave->start + chunk_length; |
749 | SDL_RWseek(wave->src, chunk_length, RW_SEEK_CUR); | |
752 | if (SDL_RWseek(wave->src, chunk_length, RW_SEEK_CUR) < 0) | |
753 | return SDL_FALSE; | |
750 | 754 | return SDL_TRUE; |
751 | 755 | } |
752 | 756 | |
755 | 759 | WAVLoopPoint *loop; |
756 | 760 | WAVLoopPoint *loops = SDL_realloc(wave->loops, (wave->numloops + 1) * sizeof(*wave->loops)); |
757 | 761 | if (!loops) { |
758 | Mix_SetError("Out of memory"); | |
762 | Mix_OutOfMemory(); | |
759 | 763 | return SDL_FALSE; |
760 | 764 | } |
761 | 765 | |
779 | 783 | |
780 | 784 | data = (Uint8 *)SDL_malloc(chunk_length); |
781 | 785 | if (!data) { |
782 | Mix_SetError("Out of memory"); | |
786 | Mix_OutOfMemory(); | |
783 | 787 | return SDL_FALSE; |
784 | 788 | } |
785 | 789 | if (!SDL_RWread(wave->src, data, chunk_length, 1)) { |
829 | 833 | |
830 | 834 | data = (Uint8 *)SDL_malloc(chunk_length); |
831 | 835 | if (!data) { |
832 | Mix_SetError("Out of memory"); | |
836 | Mix_OutOfMemory(); | |
833 | 837 | return SDL_FALSE; |
834 | 838 | } |
835 | 839 | |
914 | 918 | return SDL_FALSE; |
915 | 919 | break; |
916 | 920 | default: |
917 | SDL_RWseek(src, chunk_length, RW_SEEK_CUR); | |
921 | if (SDL_RWseek(src, chunk_length, RW_SEEK_CUR) < 0) | |
922 | return SDL_FALSE; | |
918 | 923 | break; |
919 | 924 | } |
920 | 925 | } |
1070 | 1075 | /* Unknown/unsupported chunk: we just skip over */ |
1071 | 1076 | break; |
1072 | 1077 | } |
1073 | } while (next_chunk < file_length && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != -1); | |
1078 | } while (next_chunk < file_length && SDL_RWseek(src, next_chunk, RW_SEEK_SET) >= 0); | |
1074 | 1079 | |
1075 | 1080 | if (!found_SSND) { |
1076 | 1081 | Mix_SetError("Bad AIFF/AIFF-C file (no SSND chunk)"); |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
55 | 55 | void (*xmp_free_context)(xmp_context); |
56 | 56 | } xmp_loader; |
57 | 57 | |
58 | static xmp_loader libxmp = { | |
59 | 0, NULL | |
60 | }; | |
58 | static xmp_loader libxmp; | |
61 | 59 | |
62 | 60 | #ifdef XMP_DYNAMIC |
63 | 61 | #define FUNCTION_LOADER(FUNC, SIG) \ |
220 | 218 | |
221 | 219 | meta_tags_init(&music->tags); |
222 | 220 | libxmp.xmp_get_module_info(music->ctx, &music->mi); |
221 | if (music->mi.mod->name[0]) { | |
222 | meta_tags_set(&music->tags, MIX_META_TITLE, music->mi.mod->name); | |
223 | } | |
223 | 224 | if (music->mi.comment) { |
224 | meta_tags_set(&music->tags, MIX_META_TITLE, music->mi.comment); | |
225 | meta_tags_set(&music->tags, MIX_META_COPYRIGHT, music->mi.comment); | |
225 | 226 | } |
226 | 227 | |
227 | 228 | if (freesrc) { |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
89 | 89 | newEvent->data[1] = b; |
90 | 90 | } |
91 | 91 | else |
92 | Mix_SetError("Out of memory"); | |
92 | Mix_OutOfMemory(); | |
93 | 93 | |
94 | 94 | return newEvent; |
95 | 95 | } |
317 | 317 | mididata->track = (MIDITrack*) SDL_calloc(1, sizeof(MIDITrack) * mididata->nTracks); |
318 | 318 | if (NULL == mididata->track) |
319 | 319 | { |
320 | Mix_SetError("Out of memory"); | |
320 | Mix_OutOfMemory(); | |
321 | 321 | goto bail; |
322 | 322 | } |
323 | 323 | |
335 | 335 | mididata->track[i].data = SDL_malloc(size); |
336 | 336 | if (NULL == mididata->track[i].data) |
337 | 337 | { |
338 | Mix_SetError("Out of memory"); | |
338 | Mix_OutOfMemory(); | |
339 | 339 | goto bail; |
340 | 340 | } |
341 | 341 | SDL_RWread(src, mididata->track[i].data, 1, size); |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
110 | 110 | |
111 | 111 | static void SDLCALL _Eff_position_u8(int chan, void *stream, int len, void *udata) |
112 | 112 | { |
113 | volatile position_args *args = (volatile position_args *) udata; | |
114 | 113 | Uint8 *ptr = (Uint8 *) stream; |
114 | const float dist_f = ((position_args *)udata)->distance_f; | |
115 | const float left_f = ((position_args *)udata)->left_f; | |
116 | const float right_f = ((position_args *)udata)->right_f; | |
115 | 117 | int i; |
116 | 118 | |
117 | 119 | (void)chan; |
122 | 124 | * 1.0, and are therefore throwaways. |
123 | 125 | */ |
124 | 126 | if (len % (int)sizeof(Uint16) != 0) { |
125 | *ptr = (Uint8) (((float) *ptr) * args->distance_f); | |
127 | *ptr = (Uint8) (((float) *ptr) * dist_f); | |
126 | 128 | ptr++; |
127 | 129 | len--; |
128 | 130 | } |
129 | 131 | |
130 | if (args->room_angle == 180) | |
132 | if (((position_args *)udata)->room_angle == 180) | |
131 | 133 | for (i = 0; i < len; i += sizeof (Uint8) * 2) { |
132 | 134 | /* must adjust the sample so that 0 is the center */ |
133 | 135 | *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) |
134 | * args->right_f) * args->distance_f) + 128); | |
135 | ptr++; | |
136 | *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) | |
137 | * args->left_f) * args->distance_f) + 128); | |
136 | * right_f) * dist_f) + 128); | |
137 | ptr++; | |
138 | *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) | |
139 | * left_f) * dist_f) + 128); | |
138 | 140 | ptr++; |
139 | 141 | } |
140 | 142 | else for (i = 0; i < len; i += sizeof (Uint8) * 2) { |
141 | 143 | /* must adjust the sample so that 0 is the center */ |
142 | 144 | *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) |
143 | * args->left_f) * args->distance_f) + 128); | |
144 | ptr++; | |
145 | *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) | |
146 | * args->right_f) * args->distance_f) + 128); | |
145 | * left_f) * dist_f) + 128); | |
146 | ptr++; | |
147 | *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128)) | |
148 | * right_f) * dist_f) + 128); | |
147 | 149 | ptr++; |
148 | 150 | } |
149 | 151 | } |
411 | 413 | |
412 | 414 | static void SDLCALL _Eff_position_s8(int chan, void *stream, int len, void *udata) |
413 | 415 | { |
414 | volatile position_args *args = (volatile position_args *) udata; | |
415 | 416 | Sint8 *ptr = (Sint8 *) stream; |
417 | const float dist_f = ((position_args *)udata)->distance_f; | |
418 | const float left_f = ((position_args *)udata)->left_f; | |
419 | const float right_f = ((position_args *)udata)->right_f; | |
416 | 420 | int i; |
417 | 421 | |
418 | 422 | (void)chan; |
423 | 427 | * 1.0, and are therefore throwaways. |
424 | 428 | */ |
425 | 429 | if (len % (int)sizeof(Sint16) != 0) { |
426 | *ptr = (Sint8) (((float) *ptr) * args->distance_f); | |
430 | *ptr = (Sint8) (((float) *ptr) * dist_f); | |
427 | 431 | ptr++; |
428 | 432 | len--; |
429 | 433 | } |
430 | 434 | |
431 | if (args->room_angle == 180) | |
435 | if (((position_args *)udata)->room_angle == 180) | |
432 | 436 | for (i = 0; i < len; i += sizeof (Sint8) * 2) { |
433 | *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); | |
434 | ptr++; | |
435 | *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); | |
437 | *ptr = (Sint8)((((float) *ptr) * right_f) * dist_f); | |
438 | ptr++; | |
439 | *ptr = (Sint8)((((float) *ptr) * left_f) * dist_f); | |
436 | 440 | ptr++; |
437 | 441 | } |
438 | 442 | else |
439 | 443 | for (i = 0; i < len; i += sizeof (Sint8) * 2) { |
440 | *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); | |
441 | ptr++; | |
442 | *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); | |
444 | *ptr = (Sint8)((((float) *ptr) * left_f) * dist_f); | |
445 | ptr++; | |
446 | *ptr = (Sint8)((((float) *ptr) * right_f) * dist_f); | |
443 | 447 | ptr++; |
444 | 448 | } |
445 | 449 | } |
611 | 615 | |
612 | 616 | static void SDLCALL _Eff_position_u16lsb(int chan, void *stream, int len, void *udata) |
613 | 617 | { |
614 | volatile position_args *args = (volatile position_args *) udata; | |
615 | 618 | Uint16 *ptr = (Uint16 *) stream; |
619 | const SDL_bool opp = ((position_args *)udata)->room_angle == 180 ? SDL_TRUE : SDL_FALSE; | |
620 | const float dist_f = ((position_args *)udata)->distance_f; | |
621 | const float left_f = ((position_args *)udata)->left_f; | |
622 | const float right_f = ((position_args *)udata)->right_f; | |
616 | 623 | int i; |
617 | 624 | |
618 | 625 | (void)chan; |
621 | 628 | Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768); |
622 | 629 | Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768); |
623 | 630 | |
624 | Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f) | |
625 | * args->distance_f) + 32768); | |
626 | Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f) | |
627 | * args->distance_f) + 32768); | |
628 | ||
629 | if (args->room_angle == 180) { | |
631 | Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * left_f) | |
632 | * dist_f) + 32768); | |
633 | Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * right_f) | |
634 | * dist_f) + 32768); | |
635 | ||
636 | if (opp) { | |
630 | 637 | *(ptr++) = (Uint16) SDL_SwapLE16(swapr); |
631 | 638 | *(ptr++) = (Uint16) SDL_SwapLE16(swapl); |
632 | 639 | } |
758 | 765 | static void SDLCALL _Eff_position_s16lsb(int chan, void *stream, int len, void *udata) |
759 | 766 | { |
760 | 767 | /* 16 signed bits (lsb) * 2 channels. */ |
761 | volatile position_args *args = (volatile position_args *) udata; | |
762 | 768 | Sint16 *ptr = (Sint16 *) stream; |
769 | const SDL_bool opp = ((position_args *)udata)->room_angle == 180 ? SDL_TRUE : SDL_FALSE; | |
770 | const float dist_f = ((position_args *)udata)->distance_f; | |
771 | const float left_f = ((position_args *)udata)->left_f; | |
772 | const float right_f = ((position_args *)udata)->right_f; | |
763 | 773 | int i; |
764 | 774 | |
765 | 775 | (void)chan; |
773 | 783 | |
774 | 784 | for (i = 0; i < len; i += sizeof (Sint16) * 2) { |
775 | 785 | Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) * |
776 | args->left_f) * args->distance_f); | |
786 | left_f) * dist_f); | |
777 | 787 | Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) * |
778 | args->right_f) * args->distance_f); | |
779 | if (args->room_angle == 180) { | |
788 | right_f) * dist_f); | |
789 | if (opp) { | |
780 | 790 | *(ptr++) = (Sint16) SDL_SwapLE16(swapr); |
781 | 791 | *(ptr++) = (Sint16) SDL_SwapLE16(swapl); |
782 | 792 | } |
895 | 905 | static void SDLCALL _Eff_position_u16msb(int chan, void *stream, int len, void *udata) |
896 | 906 | { |
897 | 907 | /* 16 signed bits (lsb) * 2 channels. */ |
898 | volatile position_args *args = (volatile position_args *) udata; | |
899 | 908 | Uint16 *ptr = (Uint16 *) stream; |
909 | const SDL_bool opp = ((position_args *)udata)->room_angle == 180 ? SDL_TRUE : SDL_FALSE; | |
910 | const float dist_f = ((position_args *)udata)->distance_f; | |
911 | const float left_f = ((position_args *)udata)->left_f; | |
912 | const float right_f = ((position_args *)udata)->right_f; | |
900 | 913 | int i; |
901 | 914 | |
902 | 915 | (void)chan; |
905 | 918 | Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768); |
906 | 919 | Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768); |
907 | 920 | |
908 | Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f) | |
909 | * args->distance_f) + 32768); | |
910 | Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f) | |
911 | * args->distance_f) + 32768); | |
912 | ||
913 | if (args->room_angle == 180) { | |
921 | Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * left_f) | |
922 | * dist_f) + 32768); | |
923 | Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * right_f) | |
924 | * dist_f) + 32768); | |
925 | ||
926 | if (opp) { | |
914 | 927 | *(ptr++) = (Uint16) SDL_SwapBE16(swapr); |
915 | 928 | *(ptr++) = (Uint16) SDL_SwapBE16(swapl); |
916 | 929 | } |
1044 | 1057 | static void SDLCALL _Eff_position_s16msb(int chan, void *stream, int len, void *udata) |
1045 | 1058 | { |
1046 | 1059 | /* 16 signed bits (lsb) * 2 channels. */ |
1047 | volatile position_args *args = (volatile position_args *) udata; | |
1048 | 1060 | Sint16 *ptr = (Sint16 *) stream; |
1061 | const float dist_f = ((position_args *)udata)->distance_f; | |
1062 | const float left_f = ((position_args *)udata)->left_f; | |
1063 | const float right_f = ((position_args *)udata)->right_f; | |
1049 | 1064 | int i; |
1050 | 1065 | |
1051 | 1066 | (void)chan; |
1052 | 1067 | |
1053 | 1068 | for (i = 0; i < len; i += sizeof (Sint16) * 2) { |
1054 | 1069 | Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) * |
1055 | args->left_f) * args->distance_f); | |
1070 | left_f) * dist_f); | |
1056 | 1071 | Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) * |
1057 | args->right_f) * args->distance_f); | |
1072 | right_f) * dist_f); | |
1058 | 1073 | *(ptr++) = (Sint16) SDL_SwapBE16(swapl); |
1059 | 1074 | *(ptr++) = (Sint16) SDL_SwapBE16(swapr); |
1060 | 1075 | } |
1170 | 1185 | static void SDLCALL _Eff_position_s32lsb(int chan, void *stream, int len, void *udata) |
1171 | 1186 | { |
1172 | 1187 | /* 32 signed bits (lsb) * 2 channels. */ |
1173 | volatile position_args *args = (volatile position_args *) udata; | |
1174 | 1188 | Sint32 *ptr = (Sint32 *) stream; |
1189 | const SDL_bool opp = ((position_args *)udata)->room_angle == 180 ? SDL_TRUE : SDL_FALSE; | |
1190 | const float dist_f = ((position_args *)udata)->distance_f; | |
1191 | const float left_f = ((position_args *)udata)->left_f; | |
1192 | const float right_f = ((position_args *)udata)->right_f; | |
1175 | 1193 | int i; |
1176 | 1194 | |
1177 | 1195 | (void)chan; |
1185 | 1203 | |
1186 | 1204 | for (i = 0; i < len; i += sizeof (Sint32) * 2) { |
1187 | 1205 | Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) * |
1188 | args->left_f) * args->distance_f); | |
1206 | left_f) * dist_f); | |
1189 | 1207 | Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) * |
1190 | args->right_f) * args->distance_f); | |
1191 | if (args->room_angle == 180) { | |
1208 | right_f) * dist_f); | |
1209 | if (opp) { | |
1192 | 1210 | *(ptr++) = (Sint32) SDL_SwapLE32(swapr); |
1193 | 1211 | *(ptr++) = (Sint32) SDL_SwapLE32(swapl); |
1194 | 1212 | } |
1308 | 1326 | static void SDLCALL _Eff_position_s32msb(int chan, void *stream, int len, void *udata) |
1309 | 1327 | { |
1310 | 1328 | /* 32 signed bits (lsb) * 2 channels. */ |
1311 | volatile position_args *args = (volatile position_args *) udata; | |
1312 | 1329 | Sint32 *ptr = (Sint32 *) stream; |
1330 | const float dist_f = ((position_args *)udata)->distance_f; | |
1331 | const float left_f = ((position_args *)udata)->left_f; | |
1332 | const float right_f = ((position_args *)udata)->right_f; | |
1313 | 1333 | int i; |
1314 | 1334 | |
1315 | 1335 | (void)chan; |
1316 | 1336 | |
1317 | 1337 | for (i = 0; i < len; i += sizeof (Sint32) * 2) { |
1318 | 1338 | Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) * |
1319 | args->left_f) * args->distance_f); | |
1339 | left_f) * dist_f); | |
1320 | 1340 | Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) * |
1321 | args->right_f) * args->distance_f); | |
1341 | right_f) * dist_f); | |
1322 | 1342 | *(ptr++) = (Sint32) SDL_SwapBE32(swapl); |
1323 | 1343 | *(ptr++) = (Sint32) SDL_SwapBE32(swapr); |
1324 | 1344 | } |
1434 | 1454 | static void SDLCALL _Eff_position_f32sys(int chan, void *stream, int len, void *udata) |
1435 | 1455 | { |
1436 | 1456 | /* float * 2 channels. */ |
1437 | volatile position_args *args = (volatile position_args *) udata; | |
1438 | 1457 | float *ptr = (float *) stream; |
1458 | const float dist_f = ((position_args *)udata)->distance_f; | |
1459 | const float left_f = ((position_args *)udata)->left_f; | |
1460 | const float right_f = ((position_args *)udata)->right_f; | |
1439 | 1461 | int i; |
1440 | 1462 | |
1441 | 1463 | (void)chan; |
1442 | 1464 | |
1443 | 1465 | for (i = 0; i < len; i += sizeof (float) * 2) { |
1444 | float swapl = ((*(ptr+0) * args->left_f) * args->distance_f); | |
1445 | float swapr = ((*(ptr+1) * args->right_f) * args->distance_f); | |
1466 | float swapl = ((*(ptr+0) * left_f) * dist_f); | |
1467 | float swapr = ((*(ptr+1) * right_f) * dist_f); | |
1446 | 1468 | *(ptr++) = swapl; |
1447 | 1469 | *(ptr++) = swapr; |
1448 | 1470 | } |
1566 | 1588 | if (pos_args_global == NULL) { |
1567 | 1589 | pos_args_global = SDL_malloc(sizeof (position_args)); |
1568 | 1590 | if (pos_args_global == NULL) { |
1569 | Mix_SetError("Out of memory"); | |
1591 | Mix_OutOfMemory(); | |
1570 | 1592 | return(NULL); |
1571 | 1593 | } |
1572 | 1594 | init_position_args(pos_args_global); |
1578 | 1600 | if (channel >= position_channels) { |
1579 | 1601 | rc = SDL_realloc(pos_args_array, (size_t)(channel + 1) * sizeof(position_args *)); |
1580 | 1602 | if (rc == NULL) { |
1581 | Mix_SetError("Out of memory"); | |
1603 | Mix_OutOfMemory(); | |
1582 | 1604 | return(NULL); |
1583 | 1605 | } |
1584 | 1606 | pos_args_array = (position_args **) rc; |
1591 | 1613 | if (pos_args_array[channel] == NULL) { |
1592 | 1614 | pos_args_array[channel] = (position_args *)SDL_malloc(sizeof(position_args)); |
1593 | 1615 | if (pos_args_array[channel] == NULL) { |
1594 | Mix_SetError("Out of memory"); | |
1616 | Mix_OutOfMemory(); | |
1595 | 1617 | return(NULL); |
1596 | 1618 | } |
1597 | 1619 | init_position_args(pos_args_array[channel]); |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
635 | 635 | Mix_UnlockAudio(); |
636 | 636 | |
637 | 637 | if (count > 0) { |
638 | *audio_len = (count - 1) * fragment_size + fragment->size; | |
638 | *audio_len = (count - 1) * fragment_size + last->size; | |
639 | 639 | *audio_buf = (Uint8 *)SDL_malloc(*audio_len); |
640 | 640 | if (*audio_buf) { |
641 | 641 | Uint8 *dst = *audio_buf; |
644 | 644 | dst += fragment->size; |
645 | 645 | } |
646 | 646 | } else { |
647 | SDL_OutOfMemory(); | |
647 | Mix_OutOfMemory(); | |
648 | 648 | spec = NULL; |
649 | 649 | } |
650 | 650 | } else { |
676 | 676 | |
677 | 677 | /* rcg06012001 Make sure src is valid */ |
678 | 678 | if (!src) { |
679 | SDL_SetError("Mix_LoadWAV_RW with NULL src"); | |
679 | Mix_SetError("Mix_LoadWAV_RW with NULL src"); | |
680 | 680 | return(NULL); |
681 | 681 | } |
682 | 682 | |
683 | 683 | /* Make sure audio has been opened */ |
684 | 684 | if (!audio_opened) { |
685 | SDL_SetError("Audio device hasn't been opened"); | |
685 | Mix_SetError("Audio device hasn't been opened"); | |
686 | 686 | if (freesrc) { |
687 | 687 | SDL_RWclose(src); |
688 | 688 | } |
692 | 692 | /* Allocate the chunk memory */ |
693 | 693 | chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk)); |
694 | 694 | if (chunk == NULL) { |
695 | SDL_SetError("Out of memory"); | |
695 | Mix_OutOfMemory(); | |
696 | 696 | if (freesrc) { |
697 | 697 | SDL_RWclose(src); |
698 | 698 | } |
746 | 746 | wavecvt.len = chunk->alen & ~(samplesize-1); |
747 | 747 | wavecvt.buf = (Uint8 *)SDL_calloc(1, wavecvt.len*wavecvt.len_mult); |
748 | 748 | if (wavecvt.buf == NULL) { |
749 | SDL_SetError("Out of memory"); | |
749 | Mix_OutOfMemory(); | |
750 | 750 | SDL_free(chunk->abuf); |
751 | 751 | SDL_free(chunk); |
752 | 752 | return(NULL); |
779 | 779 | |
780 | 780 | /* Make sure audio has been opened */ |
781 | 781 | if (! audio_opened) { |
782 | SDL_SetError("Audio device hasn't been opened"); | |
782 | Mix_SetError("Audio device hasn't been opened"); | |
783 | 783 | return(NULL); |
784 | 784 | } |
785 | 785 | |
786 | 786 | /* Allocate the chunk memory */ |
787 | 787 | chunk = (Mix_Chunk *)SDL_calloc(1,sizeof(Mix_Chunk)); |
788 | 788 | if (chunk == NULL) { |
789 | SDL_SetError("Out of memory"); | |
789 | Mix_OutOfMemory(); | |
790 | 790 | return(NULL); |
791 | 791 | } |
792 | 792 | |
813 | 813 | |
814 | 814 | /* Make sure audio has been opened */ |
815 | 815 | if (! audio_opened) { |
816 | SDL_SetError("Audio device hasn't been opened"); | |
816 | Mix_SetError("Audio device hasn't been opened"); | |
817 | 817 | return(NULL); |
818 | 818 | } |
819 | 819 | |
820 | 820 | /* Allocate the chunk memory */ |
821 | 821 | chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk)); |
822 | 822 | if (chunk == NULL) { |
823 | SDL_SetError("Out of memory"); | |
823 | Mix_OutOfMemory(); | |
824 | 824 | return(NULL); |
825 | 825 | } |
826 | 826 | |
831 | 831 | chunk->volume = MIX_MAX_VOLUME; |
832 | 832 | |
833 | 833 | return(chunk); |
834 | } | |
835 | ||
836 | /* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ | |
837 | static void Mix_HaltChannel_locked(int which) | |
838 | { | |
839 | if (Mix_Playing(which)) { | |
840 | _Mix_channel_done_playing(which); | |
841 | mix_channel[which].playing = 0; | |
842 | mix_channel[which].looping = 0; | |
843 | } | |
844 | mix_channel[which].expire = 0; | |
845 | if (mix_channel[which].fading != MIX_NO_FADING) /* Restore volume */ | |
846 | mix_channel[which].volume = mix_channel[which].fade_volume_reset; | |
847 | mix_channel[which].fading = MIX_NO_FADING; | |
834 | 848 | } |
835 | 849 | |
836 | 850 | /* Free an audio chunk previously loaded */ |
845 | 859 | if (mix_channel) { |
846 | 860 | for (i=0; i<num_channels; ++i) { |
847 | 861 | if (chunk == mix_channel[i].chunk) { |
848 | mix_channel[i].playing = 0; | |
849 | mix_channel[i].looping = 0; | |
862 | Mix_HaltChannel_locked(i); | |
850 | 863 | } |
851 | 864 | } |
852 | 865 | } |
1105 | 1118 | { |
1106 | 1119 | int i; |
1107 | 1120 | |
1121 | Mix_LockAudio(); | |
1108 | 1122 | if (which == -1) { |
1109 | 1123 | for (i=0; i<num_channels; ++i) { |
1110 | Mix_HaltChannel(i); | |
1124 | Mix_HaltChannel_locked(i); | |
1111 | 1125 | } |
1112 | 1126 | } else if (which < num_channels) { |
1113 | Mix_LockAudio(); | |
1114 | if (Mix_Playing(which)) { | |
1115 | _Mix_channel_done_playing(which); | |
1116 | mix_channel[which].playing = 0; | |
1117 | mix_channel[which].looping = 0; | |
1118 | } | |
1119 | mix_channel[which].expire = 0; | |
1120 | if (mix_channel[which].fading != MIX_NO_FADING) /* Restore volume */ | |
1121 | mix_channel[which].volume = mix_channel[which].fade_volume_reset; | |
1122 | mix_channel[which].fading = MIX_NO_FADING; | |
1123 | Mix_UnlockAudio(); | |
1124 | } | |
1127 | Mix_HaltChannel_locked(which); | |
1128 | } | |
1129 | Mix_UnlockAudio(); | |
1125 | 1130 | return(0); |
1126 | 1131 | } |
1127 | 1132 | |
1316 | 1321 | int status = 0; |
1317 | 1322 | int i; |
1318 | 1323 | for(i=0; i < num_channels; ++i) { |
1319 | if (mix_channel[i].paused) { | |
1324 | if (Mix_Playing(i) && mix_channel[i].paused) { | |
1320 | 1325 | ++ status; |
1321 | 1326 | } |
1322 | 1327 | } |
1323 | 1328 | return(status); |
1324 | 1329 | } else if (which < num_channels) { |
1325 | return(mix_channel[which].paused != 0); | |
1330 | return(Mix_Playing(which) && mix_channel[which].paused != 0); | |
1326 | 1331 | } else { |
1327 | 1332 | return(0); |
1328 | 1333 | } |
1431 | 1436 | |
1432 | 1437 | new_e = SDL_malloc(sizeof (effect_info)); |
1433 | 1438 | if (new_e == NULL) { |
1434 | Mix_SetError("Out of memory"); | |
1439 | Mix_OutOfMemory(); | |
1435 | 1440 | return(0); |
1436 | 1441 | } |
1437 | 1442 |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
17 | 17 | misrepresented as being the original software. |
18 | 18 | 3. This notice may not be removed or altered from any source distribution. |
19 | 19 | */ |
20 | #ifndef MIXER_H_ | |
21 | #define MIXER_H_ | |
20 | 22 | |
21 | 23 | /* Locking wrapper functions */ |
22 | 24 | extern void Mix_LockAudio(void); |
24 | 26 | |
25 | 27 | extern void add_chunk_decoder(const char *decoder); |
26 | 28 | |
29 | #endif /* MIXER_H_ */ | |
30 | ||
27 | 31 | /* vi: set ts=4 sw=4 expandtab: */ |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
576 | 576 | /* Allocate memory for the music structure */ |
577 | 577 | Mix_Music *music = (Mix_Music *)SDL_calloc(1, sizeof(Mix_Music)); |
578 | 578 | if (music == NULL) { |
579 | Mix_SetError("Out of memory"); | |
579 | Mix_OutOfMemory(); | |
580 | 580 | return NULL; |
581 | 581 | } |
582 | 582 | music->interface = interface; |
687 | 687 | Mix_Music *music = (Mix_Music *)SDL_calloc(1, sizeof(Mix_Music)); |
688 | 688 | if (music == NULL) { |
689 | 689 | interface->Delete(context); |
690 | Mix_SetError("Out of memory"); | |
690 | Mix_OutOfMemory(); | |
691 | 691 | return NULL; |
692 | 692 | } |
693 | 693 | music->interface = interface; |
865 | 865 | int retval; |
866 | 866 | |
867 | 867 | if (ms_per_step == 0) { |
868 | SDL_SetError("Audio device hasn't been opened"); | |
868 | Mix_SetError("Audio device hasn't been opened"); | |
869 | 869 | return(-1); |
870 | 870 | } |
871 | 871 | |
1173 | 1173 | int retval = 0; |
1174 | 1174 | |
1175 | 1175 | if (ms_per_step == 0) { |
1176 | SDL_SetError("Audio device hasn't been opened"); | |
1176 | Mix_SetError("Audio device hasn't been opened"); | |
1177 | 1177 | return 0; |
1178 | 1178 | } |
1179 | 1179 |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
17 | 17 | misrepresented as being the original software. |
18 | 18 | 3. This notice may not be removed or altered from any source distribution. |
19 | 19 | */ |
20 | #include "SDL_mixer.h" | |
21 | ||
22 | 20 | #ifndef MUSIC_H_ |
23 | 21 | #define MUSIC_H_ |
22 | ||
23 | #include "SDL_mixer.h" | |
24 | 24 | |
25 | 25 | /* Supported music APIs, in order of preference */ |
26 | 26 |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
0 | 0 | /* |
1 | 1 | SDL_mixer: An audio mixer library based on the SDL library |
2 | Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org> | |
2 | Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org> | |
3 | 3 | |
4 | 4 | This software is provided 'as-is', without any express or implied |
5 | 5 | warranty. In no event will the authors be held liable for any damages |
24 | 24 | VALUE "FileDescription", "SDL_mixer\0" |
25 | 25 | VALUE "FileVersion", "2, 0, 4, 0\0" |
26 | 26 | VALUE "InternalName", "SDL_mixer\0" |
27 | VALUE "LegalCopyright", "Copyright © 2021 Sam Lantinga\0" | |
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 | 30 | VALUE "ProductVersion", "2, 0, 4, 0\0" |