Codebase list libsdl2-mixer / upstream/2.0.5_20220103.g3f5a050+dfsg
New upstream version 2.0.5~20220103.g3f5a050+dfsg Simon McVittie 2 years ago
50 changed file(s) with 251 addition(s) and 221 deletion(s). Raw diff Collapse all Expand all
0 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
0 Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
11
22 This software is provided 'as-is', without any express or implied
33 warranty. In no event will the authors be held liable for any damages
2323 USE_FLAC=yes
2424 # opus music support
2525 USE_OPUS=yes
26 # mp3 music support (using libmad)
26 # mp3 music support (using libmad - Note: GPL license!)
2727 USE_LIBMAD=no
2828 # mp3 music support (using mpg123)
2929 USE_MPG123=yes
6161 CFLAGS_BASE = -bt=os2 -d0 -q -bm -5s -fp5 -fpi87 -sg -oteanbmier -ei -j
6262 # warnings:
6363 CFLAGS_BASE+= -wx
64 # newer OpenWatcom versions enable W303 by default
65 CFLAGS_BASE+= -wcd=303
6466 # include paths:
6567 CFLAGS_BASE+= -Iinclude -Isrc -I"src/codecs" -I"src/codecs/timidity" $(DEPS_INC)
6668 CFLAGS_BASE+= -I"$(%WATCOM)/h/os2" -I"$(%WATCOM)/h"
148150 @%append $@ NAME $(LIBNAME)
149151 @for %i in ($(OBJS)) do @%append $@ FILE %i
150152 @%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'
152154 @%append $@ LIBPATH $(DEPS_LIB)
153155 @for %i in ($(LIBS)) do @%append $@ LIB %i
154156 @%append $@ OPTION MAP=$*
152152 base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
153153
154154 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
156155 CheckVisibilityHidden()
157156 {
158157 AC_MSG_CHECKING(for GCC -fvisibility=hidden option)
159158 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
160165
161166 visibility_CFLAGS="-fvisibility=hidden"
162167 save_CFLAGS="$CFLAGS"
174179 fi
175180 }
176181
177
178182 dnl Function to find a library in the compiler search path
179183 find_lib()
180184 {
204208 EXTRA_CFLAGS="$EXTRA_CFLAGS $SDL_CFLAGS"
205209 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SDL_LIBS"
206210
211 dnl check for GCC visibility attributes
212 CheckVisibilityHidden
213
207214 dnl Check for math library
208215 AC_CHECK_LIB(m, pow, [LIBM="-lm"])
209216
211218 AC_CHECK_FUNCS(setbuf, [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SETBUF"])
212219
213220 dnl Check command-line options
214
215 CheckVisibilityHidden
216221
217222 AC_ARG_ENABLE([music-cmd],
218223 [AS_HELP_STRING([--enable-music-cmd], [support an external music player [default=yes]])],
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
689689 #define Mix_SetError SDL_SetError
690690 #define Mix_GetError SDL_GetError
691691 #define Mix_ClearError SDL_ClearError
692 #define Mix_OutOfMemory SDL_OutOfMemory
692693
693694 /* Ends C function definitions when using C++ */
694695 #ifdef __cplusplus
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
107107 AIFFmagic = SDL_ReadLE32(src);
108108 }
109109 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)");
111111 was_error = 1;
112112 goto done;
113113 }
144144 SDL_RWread(src, sane_freq, sizeof(sane_freq), 1);
145145 frequency = SANE_to_Uint32(sane_freq);
146146 if (frequency == 0) {
147 SDL_SetError("Bad AIFF sample frequency");
147 Mix_SetError("Bad AIFF sample frequency");
148148 was_error = 1;
149149 goto done;
150150 }
177177 && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != 1);
178178
179179 if ((AIFFmagic == AIFF) && !found_SSND) {
180 SDL_SetError("Bad AIFF (no SSND chunk)");
180 Mix_SetError("Bad AIFF (no SSND chunk)");
181181 was_error = 1;
182182 goto done;
183183 }
184184
185185 if ((AIFFmagic == AIFF) && !found_COMM) {
186 SDL_SetError("Bad AIFF (no COMM chunk)");
186 Mix_SetError("Bad AIFF (no COMM chunk)");
187187 was_error = 1;
188188 goto done;
189189 }
190190
191191 if ((AIFFmagic == _8SVX) && !found_VHDR) {
192 SDL_SetError("Bad 8SVX (no VHDR chunk)");
192 Mix_SetError("Bad 8SVX (no VHDR chunk)");
193193 was_error = 1;
194194 goto done;
195195 }
196196
197197 if ((AIFFmagic == _8SVX) && !found_BODY) {
198 SDL_SetError("Bad 8SVX (no BODY chunk)");
198 Mix_SetError("Bad 8SVX (no BODY chunk)");
199199 was_error = 1;
200200 goto done;
201201 }
211211 spec->format = AUDIO_S16MSB;
212212 break;
213213 default:
214 SDL_SetError("Unsupported AIFF samplesize");
214 Mix_SetError("Unsupported AIFF samplesize");
215215 was_error = 1;
216216 goto done;
217217 }
221221 *audio_len = channels * numsamples * (samplesize / 8);
222222 *audio_buf = (Uint8 *)SDL_malloc(*audio_len);
223223 if (*audio_buf == NULL) {
224 SDL_SetError("Out of memory");
224 Mix_OutOfMemory();
225225 return(NULL);
226226 }
227227 SDL_RWseek(src, start, RW_SEEK_SET);
228228 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");
230230 return(NULL);
231231 }
232232
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
6464 /* Allocate and fill the music structure */
6565 music = (MusicCMD *)SDL_calloc(1, sizeof *music);
6666 if (music == NULL) {
67 Mix_SetError("Out of memory");
67 Mix_OutOfMemory();
6868 return NULL;
6969 }
7070 music->file = SDL_strdup(file);
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
6868 FLAC__MetadataType type);
6969 } flac_loader;
7070
71 static flac_loader flac = {
72 0, NULL
73 };
71 static flac_loader flac;
7472
7573 #ifdef FLAC_DYNAMIC
7674 #define FUNCTION_LOADER(FUNC, SIG) \
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
6161 fluid_synth_t* (*new_fluid_synth)(fluid_settings_t*);
6262 } fluidsynth_loader;
6363
64 static fluidsynth_loader fluidsynth = {
65 0, NULL
66 };
64 static fluidsynth_loader fluidsynth;
6765
6866 #ifdef FLUIDSYNTH_DYNAMIC
6967 #define FUNCTION_LOADER(FUNC, SIG) \
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
6868 UBYTE* md_volume;
6969 } mikmod_loader;
7070
71 static mikmod_loader mikmod = {
72 0, NULL
73 };
71 static mikmod_loader mikmod;
7472
7573 #ifdef MIKMOD_DYNAMIC
7674 #define FUNCTION_LOADER(FUNC, SIG) \
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
4646 const char* (*ModPlug_GetName)(ModPlugFile* file);
4747 } modplug_loader;
4848
49 static modplug_loader modplug = {
50 0, NULL
51 };
52
49 static modplug_loader modplug;
5350
5451 static ModPlug_Settings settings;
5552
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
6060 const char* (*mpg123_strerror)(mpg123_handle *mh);
6161 } mpg123_loader;
6262
63 static mpg123_loader mpg123 = {
64 0, NULL
65 };
63 static mpg123_loader mpg123;
6664
6765 #ifdef MPG123_DYNAMIC
6866 #define FUNCTION_LOADER(FUNC, SIG) \
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
6060 ogg_int64_t (*ov_pcm_tell)(OggVorbis_File *vf);
6161 } vorbis_loader;
6262
63 static vorbis_loader vorbis = {
64 0, NULL
65 };
63 static vorbis_loader vorbis;
6664
6765 #ifdef OGG_DYNAMIC
6866 #define FUNCTION_LOADER(FUNC, SIG) \
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
4747 ogg_int64_t (*op_pcm_total)(const OggOpusFile *, int);
4848 } opus_loader;
4949
50 static opus_loader opus = {
51 0, NULL
52 };
50 static opus_loader opus;
5351
5452 #ifdef OPUS_DYNAMIC
5553 #define FUNCTION_LOADER(FUNC, SIG) \
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
7878 #define WAVE_MONO 1
7979 #define WAVE_STEREO 2
8080
81 #pragma pack(push, 1)
8182 typedef struct {
8283 /* Not saved in the chunk we read:
8384 Uint32 chunkID;
9293 } WaveFMT;
9394
9495 typedef struct {
96 WaveFMT format;
9597 Uint16 cbSize;
9698 union {
9799 Uint16 validbitspersample; /* bits of precision */
104106 Uint16 sub_data2;
105107 Uint16 sub_data3;
106108 Uint8 sub_data[8];
107 } WaveFMTex;
109 } WaveFMTEx;
108110
109111 typedef struct {
110112 Uint32 identifier;
131133 Uint32 sampler_data;
132134 SampleLoop loops[1];
133135 } SamplerChunk;
136 #pragma pack(pop)
134137
135138 /*********************************************/
136139 /* Define values for AIFF (IFF audio) format */
177180
178181 music = (WAV_Music *)SDL_calloc(1, sizeof(*music));
179182 if (!music) {
180 SDL_OutOfMemory();
183 Mix_OutOfMemory();
181184 return NULL;
182185 }
183186 music->src = src;
200203 }
201204 music->buffer = (Uint8*)SDL_malloc(music->spec.size);
202205 if (!music->buffer) {
206 Mix_OutOfMemory();
203207 WAV_Delete(music);
204208 return NULL;
205209 }
542546 if (loop->current_play_count > 0) {
543547 --loop->current_play_count;
544548 }
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;
546551 looped = SDL_TRUE;
547552 }
548553 }
581586 destpos -= dest_offset % sample_size;
582587 if (destpos > music->stop)
583588 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;
585591 return 0;
586592 }
587593
631637 static SDL_bool ParseFMT(WAV_Music *wave, Uint32 chunk_length)
632638 {
633639 SDL_AudioSpec *spec = &wave->spec;
634 WaveFMT *format;
635 WaveFMTex *formatEx = NULL;
636 Uint8 *data;
640 WaveFMTEx fmt;
641 size_t size;
637642 int bits;
638 SDL_bool loaded = SDL_FALSE;
639
640 if (chunk_length < sizeof(*format)) {
643
644 if (chunk_length < sizeof(fmt.format)) {
641645 Mix_SetError("Wave format chunk too small");
642646 return SDL_FALSE;
643647 }
644648
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)) {
651651 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);
657661
658662 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);
661668 }
662669
663670 /* Decode the audio data format */
678685 default:
679686 /* but NOT this */
680687 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);
685692 switch (bits) {
686693 case 8:
687694 switch(wave->encoding) {
725732 default:
726733 unknown_bits:
727734 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);
731738 spec->samples = 4096; /* Good default buffer size */
732739 wave->samplesize = spec->channels * (bits / 8);
733740 /* SDL_CalculateAudioSpec */
735742 spec->size *= spec->channels;
736743 spec->size *= spec->samples;
737744
738 loaded = SDL_TRUE;
739
740 done:
741 SDL_free(data);
742 return loaded;
745 return SDL_TRUE;
743746 }
744747
745748 static SDL_bool ParseDATA(WAV_Music *wave, Uint32 chunk_length)
746749 {
747750 wave->start = SDL_RWtell(wave->src);
748751 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;
750754 return SDL_TRUE;
751755 }
752756
755759 WAVLoopPoint *loop;
756760 WAVLoopPoint *loops = SDL_realloc(wave->loops, (wave->numloops + 1) * sizeof(*wave->loops));
757761 if (!loops) {
758 Mix_SetError("Out of memory");
762 Mix_OutOfMemory();
759763 return SDL_FALSE;
760764 }
761765
779783
780784 data = (Uint8 *)SDL_malloc(chunk_length);
781785 if (!data) {
782 Mix_SetError("Out of memory");
786 Mix_OutOfMemory();
783787 return SDL_FALSE;
784788 }
785789 if (!SDL_RWread(wave->src, data, chunk_length, 1)) {
829833
830834 data = (Uint8 *)SDL_malloc(chunk_length);
831835 if (!data) {
832 Mix_SetError("Out of memory");
836 Mix_OutOfMemory();
833837 return SDL_FALSE;
834838 }
835839
914918 return SDL_FALSE;
915919 break;
916920 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;
918923 break;
919924 }
920925 }
10701075 /* Unknown/unsupported chunk: we just skip over */
10711076 break;
10721077 }
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);
10741079
10751080 if (!found_SSND) {
10761081 Mix_SetError("Bad AIFF/AIFF-C file (no SSND chunk)");
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
5555 void (*xmp_free_context)(xmp_context);
5656 } xmp_loader;
5757
58 static xmp_loader libxmp = {
59 0, NULL
60 };
58 static xmp_loader libxmp;
6159
6260 #ifdef XMP_DYNAMIC
6361 #define FUNCTION_LOADER(FUNC, SIG) \
220218
221219 meta_tags_init(&music->tags);
222220 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 }
223224 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);
225226 }
226227
227228 if (freesrc) {
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
8989 newEvent->data[1] = b;
9090 }
9191 else
92 Mix_SetError("Out of memory");
92 Mix_OutOfMemory();
9393
9494 return newEvent;
9595 }
317317 mididata->track = (MIDITrack*) SDL_calloc(1, sizeof(MIDITrack) * mididata->nTracks);
318318 if (NULL == mididata->track)
319319 {
320 Mix_SetError("Out of memory");
320 Mix_OutOfMemory();
321321 goto bail;
322322 }
323323
335335 mididata->track[i].data = SDL_malloc(size);
336336 if (NULL == mididata->track[i].data)
337337 {
338 Mix_SetError("Out of memory");
338 Mix_OutOfMemory();
339339 goto bail;
340340 }
341341 SDL_RWread(src, mididata->track[i].data, 1, size);
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
110110
111111 static void SDLCALL _Eff_position_u8(int chan, void *stream, int len, void *udata)
112112 {
113 volatile position_args *args = (volatile position_args *) udata;
114113 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;
115117 int i;
116118
117119 (void)chan;
122124 * 1.0, and are therefore throwaways.
123125 */
124126 if (len % (int)sizeof(Uint16) != 0) {
125 *ptr = (Uint8) (((float) *ptr) * args->distance_f);
127 *ptr = (Uint8) (((float) *ptr) * dist_f);
126128 ptr++;
127129 len--;
128130 }
129131
130 if (args->room_angle == 180)
132 if (((position_args *)udata)->room_angle == 180)
131133 for (i = 0; i < len; i += sizeof (Uint8) * 2) {
132134 /* must adjust the sample so that 0 is the center */
133135 *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);
138140 ptr++;
139141 }
140142 else for (i = 0; i < len; i += sizeof (Uint8) * 2) {
141143 /* must adjust the sample so that 0 is the center */
142144 *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);
147149 ptr++;
148150 }
149151 }
411413
412414 static void SDLCALL _Eff_position_s8(int chan, void *stream, int len, void *udata)
413415 {
414 volatile position_args *args = (volatile position_args *) udata;
415416 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;
416420 int i;
417421
418422 (void)chan;
423427 * 1.0, and are therefore throwaways.
424428 */
425429 if (len % (int)sizeof(Sint16) != 0) {
426 *ptr = (Sint8) (((float) *ptr) * args->distance_f);
430 *ptr = (Sint8) (((float) *ptr) * dist_f);
427431 ptr++;
428432 len--;
429433 }
430434
431 if (args->room_angle == 180)
435 if (((position_args *)udata)->room_angle == 180)
432436 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);
436440 ptr++;
437441 }
438442 else
439443 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);
443447 ptr++;
444448 }
445449 }
611615
612616 static void SDLCALL _Eff_position_u16lsb(int chan, void *stream, int len, void *udata)
613617 {
614 volatile position_args *args = (volatile position_args *) udata;
615618 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;
616623 int i;
617624
618625 (void)chan;
621628 Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
622629 Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
623630
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) {
630637 *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
631638 *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
632639 }
758765 static void SDLCALL _Eff_position_s16lsb(int chan, void *stream, int len, void *udata)
759766 {
760767 /* 16 signed bits (lsb) * 2 channels. */
761 volatile position_args *args = (volatile position_args *) udata;
762768 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;
763773 int i;
764774
765775 (void)chan;
773783
774784 for (i = 0; i < len; i += sizeof (Sint16) * 2) {
775785 Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *
776 args->left_f) * args->distance_f);
786 left_f) * dist_f);
777787 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) {
780790 *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
781791 *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
782792 }
895905 static void SDLCALL _Eff_position_u16msb(int chan, void *stream, int len, void *udata)
896906 {
897907 /* 16 signed bits (lsb) * 2 channels. */
898 volatile position_args *args = (volatile position_args *) udata;
899908 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;
900913 int i;
901914
902915 (void)chan;
905918 Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
906919 Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
907920
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) {
914927 *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
915928 *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
916929 }
10441057 static void SDLCALL _Eff_position_s16msb(int chan, void *stream, int len, void *udata)
10451058 {
10461059 /* 16 signed bits (lsb) * 2 channels. */
1047 volatile position_args *args = (volatile position_args *) udata;
10481060 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;
10491064 int i;
10501065
10511066 (void)chan;
10521067
10531068 for (i = 0; i < len; i += sizeof (Sint16) * 2) {
10541069 Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) *
1055 args->left_f) * args->distance_f);
1070 left_f) * dist_f);
10561071 Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) *
1057 args->right_f) * args->distance_f);
1072 right_f) * dist_f);
10581073 *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
10591074 *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
10601075 }
11701185 static void SDLCALL _Eff_position_s32lsb(int chan, void *stream, int len, void *udata)
11711186 {
11721187 /* 32 signed bits (lsb) * 2 channels. */
1173 volatile position_args *args = (volatile position_args *) udata;
11741188 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;
11751193 int i;
11761194
11771195 (void)chan;
11851203
11861204 for (i = 0; i < len; i += sizeof (Sint32) * 2) {
11871205 Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) *
1188 args->left_f) * args->distance_f);
1206 left_f) * dist_f);
11891207 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) {
11921210 *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
11931211 *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
11941212 }
13081326 static void SDLCALL _Eff_position_s32msb(int chan, void *stream, int len, void *udata)
13091327 {
13101328 /* 32 signed bits (lsb) * 2 channels. */
1311 volatile position_args *args = (volatile position_args *) udata;
13121329 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;
13131333 int i;
13141334
13151335 (void)chan;
13161336
13171337 for (i = 0; i < len; i += sizeof (Sint32) * 2) {
13181338 Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) *
1319 args->left_f) * args->distance_f);
1339 left_f) * dist_f);
13201340 Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) *
1321 args->right_f) * args->distance_f);
1341 right_f) * dist_f);
13221342 *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
13231343 *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
13241344 }
14341454 static void SDLCALL _Eff_position_f32sys(int chan, void *stream, int len, void *udata)
14351455 {
14361456 /* float * 2 channels. */
1437 volatile position_args *args = (volatile position_args *) udata;
14381457 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;
14391461 int i;
14401462
14411463 (void)chan;
14421464
14431465 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);
14461468 *(ptr++) = swapl;
14471469 *(ptr++) = swapr;
14481470 }
15661588 if (pos_args_global == NULL) {
15671589 pos_args_global = SDL_malloc(sizeof (position_args));
15681590 if (pos_args_global == NULL) {
1569 Mix_SetError("Out of memory");
1591 Mix_OutOfMemory();
15701592 return(NULL);
15711593 }
15721594 init_position_args(pos_args_global);
15781600 if (channel >= position_channels) {
15791601 rc = SDL_realloc(pos_args_array, (size_t)(channel + 1) * sizeof(position_args *));
15801602 if (rc == NULL) {
1581 Mix_SetError("Out of memory");
1603 Mix_OutOfMemory();
15821604 return(NULL);
15831605 }
15841606 pos_args_array = (position_args **) rc;
15911613 if (pos_args_array[channel] == NULL) {
15921614 pos_args_array[channel] = (position_args *)SDL_malloc(sizeof(position_args));
15931615 if (pos_args_array[channel] == NULL) {
1594 Mix_SetError("Out of memory");
1616 Mix_OutOfMemory();
15951617 return(NULL);
15961618 }
15971619 init_position_args(pos_args_array[channel]);
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
635635 Mix_UnlockAudio();
636636
637637 if (count > 0) {
638 *audio_len = (count - 1) * fragment_size + fragment->size;
638 *audio_len = (count - 1) * fragment_size + last->size;
639639 *audio_buf = (Uint8 *)SDL_malloc(*audio_len);
640640 if (*audio_buf) {
641641 Uint8 *dst = *audio_buf;
644644 dst += fragment->size;
645645 }
646646 } else {
647 SDL_OutOfMemory();
647 Mix_OutOfMemory();
648648 spec = NULL;
649649 }
650650 } else {
676676
677677 /* rcg06012001 Make sure src is valid */
678678 if (!src) {
679 SDL_SetError("Mix_LoadWAV_RW with NULL src");
679 Mix_SetError("Mix_LoadWAV_RW with NULL src");
680680 return(NULL);
681681 }
682682
683683 /* Make sure audio has been opened */
684684 if (!audio_opened) {
685 SDL_SetError("Audio device hasn't been opened");
685 Mix_SetError("Audio device hasn't been opened");
686686 if (freesrc) {
687687 SDL_RWclose(src);
688688 }
692692 /* Allocate the chunk memory */
693693 chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk));
694694 if (chunk == NULL) {
695 SDL_SetError("Out of memory");
695 Mix_OutOfMemory();
696696 if (freesrc) {
697697 SDL_RWclose(src);
698698 }
746746 wavecvt.len = chunk->alen & ~(samplesize-1);
747747 wavecvt.buf = (Uint8 *)SDL_calloc(1, wavecvt.len*wavecvt.len_mult);
748748 if (wavecvt.buf == NULL) {
749 SDL_SetError("Out of memory");
749 Mix_OutOfMemory();
750750 SDL_free(chunk->abuf);
751751 SDL_free(chunk);
752752 return(NULL);
779779
780780 /* Make sure audio has been opened */
781781 if (! audio_opened) {
782 SDL_SetError("Audio device hasn't been opened");
782 Mix_SetError("Audio device hasn't been opened");
783783 return(NULL);
784784 }
785785
786786 /* Allocate the chunk memory */
787787 chunk = (Mix_Chunk *)SDL_calloc(1,sizeof(Mix_Chunk));
788788 if (chunk == NULL) {
789 SDL_SetError("Out of memory");
789 Mix_OutOfMemory();
790790 return(NULL);
791791 }
792792
813813
814814 /* Make sure audio has been opened */
815815 if (! audio_opened) {
816 SDL_SetError("Audio device hasn't been opened");
816 Mix_SetError("Audio device hasn't been opened");
817817 return(NULL);
818818 }
819819
820820 /* Allocate the chunk memory */
821821 chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk));
822822 if (chunk == NULL) {
823 SDL_SetError("Out of memory");
823 Mix_OutOfMemory();
824824 return(NULL);
825825 }
826826
831831 chunk->volume = MIX_MAX_VOLUME;
832832
833833 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;
834848 }
835849
836850 /* Free an audio chunk previously loaded */
845859 if (mix_channel) {
846860 for (i=0; i<num_channels; ++i) {
847861 if (chunk == mix_channel[i].chunk) {
848 mix_channel[i].playing = 0;
849 mix_channel[i].looping = 0;
862 Mix_HaltChannel_locked(i);
850863 }
851864 }
852865 }
11051118 {
11061119 int i;
11071120
1121 Mix_LockAudio();
11081122 if (which == -1) {
11091123 for (i=0; i<num_channels; ++i) {
1110 Mix_HaltChannel(i);
1124 Mix_HaltChannel_locked(i);
11111125 }
11121126 } 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();
11251130 return(0);
11261131 }
11271132
13161321 int status = 0;
13171322 int i;
13181323 for(i=0; i < num_channels; ++i) {
1319 if (mix_channel[i].paused) {
1324 if (Mix_Playing(i) && mix_channel[i].paused) {
13201325 ++ status;
13211326 }
13221327 }
13231328 return(status);
13241329 } else if (which < num_channels) {
1325 return(mix_channel[which].paused != 0);
1330 return(Mix_Playing(which) && mix_channel[which].paused != 0);
13261331 } else {
13271332 return(0);
13281333 }
14311436
14321437 new_e = SDL_malloc(sizeof (effect_info));
14331438 if (new_e == NULL) {
1434 Mix_SetError("Out of memory");
1439 Mix_OutOfMemory();
14351440 return(0);
14361441 }
14371442
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
1717 misrepresented as being the original software.
1818 3. This notice may not be removed or altered from any source distribution.
1919 */
20 #ifndef MIXER_H_
21 #define MIXER_H_
2022
2123 /* Locking wrapper functions */
2224 extern void Mix_LockAudio(void);
2426
2527 extern void add_chunk_decoder(const char *decoder);
2628
29 #endif /* MIXER_H_ */
30
2731 /* vi: set ts=4 sw=4 expandtab: */
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
576576 /* Allocate memory for the music structure */
577577 Mix_Music *music = (Mix_Music *)SDL_calloc(1, sizeof(Mix_Music));
578578 if (music == NULL) {
579 Mix_SetError("Out of memory");
579 Mix_OutOfMemory();
580580 return NULL;
581581 }
582582 music->interface = interface;
687687 Mix_Music *music = (Mix_Music *)SDL_calloc(1, sizeof(Mix_Music));
688688 if (music == NULL) {
689689 interface->Delete(context);
690 Mix_SetError("Out of memory");
690 Mix_OutOfMemory();
691691 return NULL;
692692 }
693693 music->interface = interface;
865865 int retval;
866866
867867 if (ms_per_step == 0) {
868 SDL_SetError("Audio device hasn't been opened");
868 Mix_SetError("Audio device hasn't been opened");
869869 return(-1);
870870 }
871871
11731173 int retval = 0;
11741174
11751175 if (ms_per_step == 0) {
1176 SDL_SetError("Audio device hasn't been opened");
1176 Mix_SetError("Audio device hasn't been opened");
11771177 return 0;
11781178 }
11791179
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
1717 misrepresented as being the original software.
1818 3. This notice may not be removed or altered from any source distribution.
1919 */
20 #include "SDL_mixer.h"
21
2220 #ifndef MUSIC_H_
2321 #define MUSIC_H_
22
23 #include "SDL_mixer.h"
2424
2525 /* Supported music APIs, in order of preference */
2626
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 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>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
2424 VALUE "FileDescription", "SDL_mixer\0"
2525 VALUE "FileVersion", "2, 0, 4, 0\0"
2626 VALUE "InternalName", "SDL_mixer\0"
27 VALUE "LegalCopyright", "Copyright © 2021 Sam Lantinga\0"
27 VALUE "LegalCopyright", "Copyright © 2022 Sam Lantinga\0"
2828 VALUE "OriginalFilename", "SDL_mixer.dll\0"
2929 VALUE "ProductName", "Simple DirectMedia Layer\0"
3030 VALUE "ProductVersion", "2, 0, 4, 0\0"