Reorganize files tree
authorVitaly Novichkov
Tue, 19 Nov 2019 12:36:40 +0300
changeset 9991a87fe70802d
parent 998 0f66f0542b10
child 1000 9d62fc52d0ad
Reorganize files tree
- Make the "src" directory for source files and private headers
- Make an "include" directory for the public header
- Make Autotools, Android CMake, and Android Make builds work with the new tree

TODO: VisualC, VisualC-WinRT, Xcode and Xcode-iOS needs an update: NOW THEY ARE BROKEN
Android.mk
CMakeLists.txt
Makefile.in
SDL_mixer.h
configure
configure.in
effect_position.c
effect_stereoreverse.c
effects_internal.c
effects_internal.h
include/SDL_mixer.h
load_aiff.c
load_aiff.h
load_voc.c
load_voc.h
mixer.c
mixer.h
music.c
music.h
music_cmd.c
music_cmd.h
music_flac.c
music_flac.h
music_fluidsynth.c
music_fluidsynth.h
music_mad.c
music_mad.h
music_mikmod.c
music_mikmod.h
music_modplug.c
music_modplug.h
music_mpg123.c
music_mpg123.h
music_nativemidi.c
music_nativemidi.h
music_ogg.c
music_ogg.h
music_opus.c
music_opus.h
music_timidity.c
music_timidity.h
music_wav.c
music_wav.h
native_midi/native_midi.h
native_midi/native_midi_common.c
native_midi/native_midi_common.h
native_midi/native_midi_haiku.cpp
native_midi/native_midi_mac.c
native_midi/native_midi_macosx.c
native_midi/native_midi_win32.c
src/codecs/load_aiff.c
src/codecs/load_aiff.h
src/codecs/load_voc.c
src/codecs/load_voc.h
src/codecs/music_cmd.c
src/codecs/music_cmd.h
src/codecs/music_flac.c
src/codecs/music_flac.h
src/codecs/music_fluidsynth.c
src/codecs/music_fluidsynth.h
src/codecs/music_mad.c
src/codecs/music_mad.h
src/codecs/music_mikmod.c
src/codecs/music_mikmod.h
src/codecs/music_modplug.c
src/codecs/music_modplug.h
src/codecs/music_mpg123.c
src/codecs/music_mpg123.h
src/codecs/music_nativemidi.c
src/codecs/music_nativemidi.h
src/codecs/music_ogg.c
src/codecs/music_ogg.h
src/codecs/music_opus.c
src/codecs/music_opus.h
src/codecs/music_timidity.c
src/codecs/music_timidity.h
src/codecs/music_wav.c
src/codecs/music_wav.h
src/codecs/native_midi/native_midi.h
src/codecs/native_midi/native_midi_common.c
src/codecs/native_midi/native_midi_common.h
src/codecs/native_midi/native_midi_haiku.cpp
src/codecs/native_midi/native_midi_mac.c
src/codecs/native_midi/native_midi_macosx.c
src/codecs/native_midi/native_midi_win32.c
src/codecs/timidity/Android.mk
src/codecs/timidity/CHANGES
src/codecs/timidity/CMakeLists.txt
src/codecs/timidity/COPYING
src/codecs/timidity/FAQ
src/codecs/timidity/README
src/codecs/timidity/TODO
src/codecs/timidity/common.c
src/codecs/timidity/common.h
src/codecs/timidity/instrum.c
src/codecs/timidity/instrum.h
src/codecs/timidity/mix.c
src/codecs/timidity/mix.h
src/codecs/timidity/options.h
src/codecs/timidity/output.c
src/codecs/timidity/output.h
src/codecs/timidity/playmidi.c
src/codecs/timidity/playmidi.h
src/codecs/timidity/readmidi.c
src/codecs/timidity/readmidi.h
src/codecs/timidity/resample.c
src/codecs/timidity/resample.h
src/codecs/timidity/tables.c
src/codecs/timidity/tables.h
src/codecs/timidity/timidity.c
src/codecs/timidity/timidity.h
src/effect_position.c
src/effect_stereoreverse.c
src/effects_internal.c
src/effects_internal.h
src/mixer.c
src/mixer.h
src/music.c
src/music.h
timidity/Android.mk
timidity/CHANGES
timidity/CMakeLists.txt
timidity/COPYING
timidity/FAQ
timidity/README
timidity/TODO
timidity/common.c
timidity/common.h
timidity/instrum.c
timidity/instrum.h
timidity/mix.c
timidity/mix.h
timidity/options.h
timidity/output.c
timidity/output.h
timidity/playmidi.c
timidity/playmidi.h
timidity/readmidi.c
timidity/readmidi.h
timidity/resample.c
timidity/resample.h
timidity/tables.c
timidity/tables.h
timidity/timidity.c
timidity/timidity.h
     1.1 --- a/Android.mk	Mon Nov 18 18:50:50 2019 +0300
     1.2 +++ b/Android.mk	Tue Nov 19 12:36:40 2019 +0300
     1.3 @@ -20,7 +20,7 @@
     1.4  
     1.5  # Enable this if you want to support TiMidity
     1.6  SUPPORT_MID_TIMIDITY ?= true
     1.7 -TIMIDITY_LIBRARY_PATH := timidity
     1.8 +TIMIDITY_LIBRARY_PATH := src/codecs/timidity
     1.9  
    1.10  
    1.11  # Build the library
    1.12 @@ -57,7 +57,7 @@
    1.13  
    1.14  LOCAL_MODULE := SDL2_mixer
    1.15  
    1.16 -LOCAL_SRC_FILES := $(notdir $(filter-out %/playmus.c %/playwave.c, $(wildcard $(LOCAL_PATH)/*.c))) \
    1.17 +LOCAL_SRC_FILES := $(notdir $(filter-out %/playmus.c %/playwave.c, $(wildcard $(LOCAL_PATH)/src/*.c), $(wildcard $(LOCAL_PATH)/src/codecs/*.c)) \
    1.18  
    1.19  LOCAL_CFLAGS :=
    1.20  LOCAL_LDLIBS :=
     2.1 --- a/CMakeLists.txt	Mon Nov 18 18:50:50 2019 +0300
     2.2 +++ b/CMakeLists.txt	Tue Nov 19 12:36:40 2019 +0300
     2.3 @@ -4,7 +4,6 @@
     2.4  
     2.5  if (ANDROID)
     2.6  
     2.7 -
     2.8      # FIXME: missing CMakeLists.txt for MPG123
     2.9      set(SUPPORT_MP3_MPG123 OFF CACHE BOOL "" FORCE)
    2.10  
    2.11 @@ -14,14 +13,20 @@
    2.12      option(SUPPORT_MOD_MODPLUG "Support loading MOD music via modplug" OFF)
    2.13      option(SUPPORT_MID_TIMIDITY "Support TiMidity" OFF)
    2.14  
    2.15 +    include_directories(include src src/codecs)
    2.16 +
    2.17      add_library(SDL2_mixer SHARED)
    2.18  
    2.19      target_sources(SDL2_mixer PRIVATE
    2.20 -            effect_position.c effects_internal.c
    2.21 -            effect_stereoreverse.c load_aiff.c load_voc.c mixer.c music.c
    2.22 -            music_cmd.c music_flac.c music_fluidsynth.c music_mad.c
    2.23 -            music_mikmod.c music_modplug.c music_mpg123.c music_nativemidi.c
    2.24 -            music_ogg.c music_opus.c music_timidity.c music_wav.c)
    2.25 +            src/effect_position.c src/effects_internal.c src/effect_stereoreverse.c
    2.26 +            src/mixer.c src/music.c
    2.27 +            src/codecs/load_aiff.c src/codecs/load_voc.c
    2.28 +            src/codecs/music_cmd.c src/codecs/music_flac.c
    2.29 +            src/codecs/music_fluidsynth.c src/codecs/music_mad.c
    2.30 +            src/codecs/music_mikmod.c src/codecs/music_modplug.c
    2.31 +            src/codecs/music_mpg123.c src/codecs/music_nativemidi.c
    2.32 +            src/codecs/music_ogg.c src/codecs/music_opus.c
    2.33 +            src/codecs/music_timidity.c src/codecs/music_wav.c)
    2.34  
    2.35      if (SUPPORT_FLAC)
    2.36          add_definitions(-DMUSIC_FLAC)
     3.1 --- a/Makefile.in	Mon Nov 18 18:50:50 2019 +0300
     3.2 +++ b/Makefile.in	Tue Nov 19 12:36:40 2019 +0300
     3.3 @@ -38,7 +38,7 @@
     3.4  PLAYWAVE_OBJECTS = @PLAYWAVE_OBJECTS@
     3.5  PLAYMUS_OBJECTS = @PLAYMUS_OBJECTS@
     3.6  
     3.7 -DIST = *.txt Android.mk Makefile.in SDL2_mixer.pc.in SDL2_mixer.spec.in SDL_mixer.h VisualC VisualC-WinRT Xcode Xcode-iOS acinclude aclocal.m4 autogen.sh build-scripts configure configure.in debian effect_position.c effect_stereoreverse.c effects_internal.c effects_internal.h external gcc-fat.sh load_aiff.c load_aiff.h load_voc.c load_voc.h mixer.c mixer.h music.c music.h music_cmd.c music_cmd.h music_flac.c music_flac.h music_fluidsynth.c music_fluidsynth.h music_mad.c music_mad.h music_mikmod.c music_mikmod.h music_modplug.c music_modplug.h music_mpg123.c music_mpg123.h music_nativemidi.c music_nativemidi.h music_ogg.c music_ogg.h music_opus.c music_opus.h music_timidity.c music_timidity.h music_wav.c music_wav.h native_midi playmus.c playwave.c timidity version.rc
     3.8 +DIST = *.txt Android.mk Makefile.in SDL2_mixer.pc.in SDL2_mixer.spec.in include/SDL_mixer.h VisualC VisualC-WinRT Xcode Xcode-iOS acinclude aclocal.m4 autogen.sh build-scripts configure configure.in debian effect_position.c effect_stereoreverse.c effects_internal.c effects_internal.h external gcc-fat.sh src/codecs/load_aiff.c src/codecs/load_aiff.h src/codecs/load_voc.c src/codecs/load_voc.h src/mixer.c src/mixer.h src/music.c src/music.h src/codecs/music_cmd.c src/codecs/music_cmd.h src/codecs/music_flac.c src/codecs/music_flac.h src/codecs/music_fluidsynth.c src/codecs/music_fluidsynth.h src/codecs/music_mad.c src/codecs/music_mad.h src/codecs/music_mikmod.c src/codecs/music_mikmod.h src/codecs/music_modplug.c src/codecs/music_modplug.h src/codecs/music_mpg123.c src/codecs/music_mpg123.h src/codecs/music_nativemidi.c src/codecs/music_nativemidi.h src/codecs/music_ogg.c src/codecs/music_ogg.h src/codecs/music_opus.c src/codecs/music_opus.h src/codecs/music_timidity.c src/codecs/music_timidity.h src/codecs/music_wav.c src/codecs/music_wav.h src/codecs/native_midi playmus.c playwave.c src/codecs/timidity version.rc
     3.9  
    3.10  LT_AGE      = @LT_AGE@
    3.11  LT_CURRENT  = @LT_CURRENT@
    3.12 @@ -71,7 +71,7 @@
    3.13  install: all install-hdrs install-lib #install-bin
    3.14  install-hdrs:
    3.15  	$(SHELL) $(auxdir)/mkinstalldirs $(includedir)/SDL2
    3.16 -	for src in $(srcdir)/SDL_mixer.h; do \
    3.17 +	for src in $(srcdir)/include/SDL_mixer.h; do \
    3.18  	    file=`echo $$src | sed -e 's|^.*/||'`; \
    3.19  	    $(INSTALL) -m 644 $$src $(includedir)/SDL2/$$file; \
    3.20  	done
    3.21 @@ -87,7 +87,7 @@
    3.22  
    3.23  uninstall: uninstall-hdrs uninstall-lib uninstall-bin
    3.24  uninstall-hdrs:
    3.25 -	for src in $(srcdir)/SDL_mixer.h; do \
    3.26 +	for src in $(srcdir)/include/SDL_mixer.h; do \
    3.27  	    file=`echo $$src | sed -e 's|^.*/||'`; \
    3.28  	    rm -f $(includedir)/SDL2/$$file; \
    3.29  	done
     4.1 --- a/SDL_mixer.h	Mon Nov 18 18:50:50 2019 +0300
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,651 +0,0 @@
     4.4 -/*
     4.5 -  SDL_mixer:  An audio mixer library based on the SDL library
     4.6 -  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
     4.7 -
     4.8 -  This software is provided 'as-is', without any express or implied
     4.9 -  warranty.  In no event will the authors be held liable for any damages
    4.10 -  arising from the use of this software.
    4.11 -
    4.12 -  Permission is granted to anyone to use this software for any purpose,
    4.13 -  including commercial applications, and to alter it and redistribute it
    4.14 -  freely, subject to the following restrictions:
    4.15 -
    4.16 -  1. The origin of this software must not be misrepresented; you must not
    4.17 -     claim that you wrote the original software. If you use this software
    4.18 -     in a product, an acknowledgment in the product documentation would be
    4.19 -     appreciated but is not required.
    4.20 -  2. Altered source versions must be plainly marked as such, and must not be
    4.21 -     misrepresented as being the original software.
    4.22 -  3. This notice may not be removed or altered from any source distribution.
    4.23 -*/
    4.24 -
    4.25 -#ifndef SDL_MIXER_H_
    4.26 -#define SDL_MIXER_H_
    4.27 -
    4.28 -#include "SDL_stdinc.h"
    4.29 -#include "SDL_rwops.h"
    4.30 -#include "SDL_audio.h"
    4.31 -#include "SDL_endian.h"
    4.32 -#include "SDL_version.h"
    4.33 -#include "begin_code.h"
    4.34 -
    4.35 -/* Set up for C function definitions, even when using C++ */
    4.36 -#ifdef __cplusplus
    4.37 -extern "C" {
    4.38 -#endif
    4.39 -
    4.40 -/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
    4.41 -*/
    4.42 -#define SDL_MIXER_MAJOR_VERSION 2
    4.43 -#define SDL_MIXER_MINOR_VERSION 0
    4.44 -#define SDL_MIXER_PATCHLEVEL    4
    4.45 -
    4.46 -/* This macro can be used to fill a version structure with the compile-time
    4.47 - * version of the SDL_mixer library.
    4.48 - */
    4.49 -#define SDL_MIXER_VERSION(X)                        \
    4.50 -{                                                   \
    4.51 -    (X)->major = SDL_MIXER_MAJOR_VERSION;           \
    4.52 -    (X)->minor = SDL_MIXER_MINOR_VERSION;           \
    4.53 -    (X)->patch = SDL_MIXER_PATCHLEVEL;              \
    4.54 -}
    4.55 -
    4.56 -/* Backwards compatibility */
    4.57 -#define MIX_MAJOR_VERSION   SDL_MIXER_MAJOR_VERSION
    4.58 -#define MIX_MINOR_VERSION   SDL_MIXER_MINOR_VERSION
    4.59 -#define MIX_PATCHLEVEL      SDL_MIXER_PATCHLEVEL
    4.60 -#define MIX_VERSION(X)      SDL_MIXER_VERSION(X)
    4.61 -
    4.62 -/**
    4.63 - *  This is the version number macro for the current SDL_mixer version.
    4.64 - */
    4.65 -#define SDL_MIXER_COMPILEDVERSION \
    4.66 -    SDL_VERSIONNUM(SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL)
    4.67 -
    4.68 -/**
    4.69 - *  This macro will evaluate to true if compiled with SDL_mixer at least X.Y.Z.
    4.70 - */
    4.71 -#define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \
    4.72 -    (SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
    4.73 -
    4.74 -/* This function gets the version of the dynamically linked SDL_mixer library.
    4.75 -   it should NOT be used to fill a version structure, instead you should
    4.76 -   use the SDL_MIXER_VERSION() macro.
    4.77 - */
    4.78 -extern DECLSPEC const SDL_version * SDLCALL Mix_Linked_Version(void);
    4.79 -
    4.80 -typedef enum
    4.81 -{
    4.82 -    MIX_INIT_FLAC   = 0x00000001,
    4.83 -    MIX_INIT_MOD    = 0x00000002,
    4.84 -    MIX_INIT_MP3    = 0x00000008,
    4.85 -    MIX_INIT_OGG    = 0x00000010,
    4.86 -    MIX_INIT_MID    = 0x00000020,
    4.87 -    MIX_INIT_OPUS   = 0x00000040
    4.88 -} MIX_InitFlags;
    4.89 -
    4.90 -/* Loads dynamic libraries and prepares them for use.  Flags should be
    4.91 -   one or more flags from MIX_InitFlags OR'd together.
    4.92 -   It returns the flags successfully initialized, or 0 on failure.
    4.93 - */
    4.94 -extern DECLSPEC int SDLCALL Mix_Init(int flags);
    4.95 -
    4.96 -/* Unloads libraries loaded with Mix_Init */
    4.97 -extern DECLSPEC void SDLCALL Mix_Quit(void);
    4.98 -
    4.99 -
   4.100 -/* The default mixer has 8 simultaneous mixing channels */
   4.101 -#ifndef MIX_CHANNELS
   4.102 -#define MIX_CHANNELS    8
   4.103 -#endif
   4.104 -
   4.105 -/* Good default values for a PC soundcard */
   4.106 -#define MIX_DEFAULT_FREQUENCY   22050
   4.107 -#if SDL_BYTEORDER == SDL_LIL_ENDIAN
   4.108 -#define MIX_DEFAULT_FORMAT  AUDIO_S16LSB
   4.109 -#else
   4.110 -#define MIX_DEFAULT_FORMAT  AUDIO_S16MSB
   4.111 -#endif
   4.112 -#define MIX_DEFAULT_CHANNELS    2
   4.113 -#define MIX_MAX_VOLUME          SDL_MIX_MAXVOLUME /* Volume of a chunk */
   4.114 -
   4.115 -/* The internal format for an audio chunk */
   4.116 -typedef struct Mix_Chunk {
   4.117 -    int allocated;
   4.118 -    Uint8 *abuf;
   4.119 -    Uint32 alen;
   4.120 -    Uint8 volume;       /* Per-sample volume, 0-128 */
   4.121 -} Mix_Chunk;
   4.122 -
   4.123 -/* The different fading types supported */
   4.124 -typedef enum {
   4.125 -    MIX_NO_FADING,
   4.126 -    MIX_FADING_OUT,
   4.127 -    MIX_FADING_IN
   4.128 -} Mix_Fading;
   4.129 -
   4.130 -/* These are types of music files (not libraries used to load them) */
   4.131 -typedef enum {
   4.132 -    MUS_NONE,
   4.133 -    MUS_CMD,
   4.134 -    MUS_WAV,
   4.135 -    MUS_MOD,
   4.136 -    MUS_MID,
   4.137 -    MUS_OGG,
   4.138 -    MUS_MP3,
   4.139 -    MUS_MP3_MAD_UNUSED,
   4.140 -    MUS_FLAC,
   4.141 -    MUS_MODPLUG_UNUSED,
   4.142 -    MUS_OPUS
   4.143 -} Mix_MusicType;
   4.144 -
   4.145 -/* The internal format for a music chunk interpreted via mikmod */
   4.146 -typedef struct _Mix_Music Mix_Music;
   4.147 -
   4.148 -/* Open the mixer with a certain audio format */
   4.149 -extern DECLSPEC int SDLCALL Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize);
   4.150 -
   4.151 -/* Open the mixer with specific device and certain audio format */
   4.152 -extern DECLSPEC int SDLCALL Mix_OpenAudioDevice(int frequency, Uint16 format, int channels, int chunksize, const char* device, int allowed_changes);
   4.153 -
   4.154 -/* Dynamically change the number of channels managed by the mixer.
   4.155 -   If decreasing the number of channels, the upper channels are
   4.156 -   stopped.
   4.157 -   This function returns the new number of allocated channels.
   4.158 - */
   4.159 -extern DECLSPEC int SDLCALL Mix_AllocateChannels(int numchans);
   4.160 -
   4.161 -/* Find out what the actual audio device parameters are.
   4.162 -   This function returns 1 if the audio has been opened, 0 otherwise.
   4.163 - */
   4.164 -extern DECLSPEC int SDLCALL Mix_QuerySpec(int *frequency,Uint16 *format,int *channels);
   4.165 -
   4.166 -/* Load a wave file or a music (.mod .s3m .it .xm) file */
   4.167 -extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV_RW(SDL_RWops *src, int freesrc);
   4.168 -#define Mix_LoadWAV(file)   Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1)
   4.169 -extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file);
   4.170 -
   4.171 -/* Load a music file from an SDL_RWop object (Ogg and MikMod specific currently)
   4.172 -   Matt Campbell (matt@campbellhome.dhs.org) April 2000 */
   4.173 -extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *src, int freesrc);
   4.174 -
   4.175 -/* Load a music file from an SDL_RWop object assuming a specific format */
   4.176 -extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc);
   4.177 -
   4.178 -/* Load a wave file of the mixer format from a memory buffer */
   4.179 -extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_WAV(Uint8 *mem);
   4.180 -
   4.181 -/* Load raw audio data of the mixer format from a memory buffer */
   4.182 -extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len);
   4.183 -
   4.184 -/* Free an audio chunk previously loaded */
   4.185 -extern DECLSPEC void SDLCALL Mix_FreeChunk(Mix_Chunk *chunk);
   4.186 -extern DECLSPEC void SDLCALL Mix_FreeMusic(Mix_Music *music);
   4.187 -
   4.188 -/* Get a list of chunk/music decoders that this build of SDL_mixer provides.
   4.189 -   This list can change between builds AND runs of the program, if external
   4.190 -   libraries that add functionality become available.
   4.191 -   You must successfully call Mix_OpenAudio() before calling these functions.
   4.192 -   This API is only available in SDL_mixer 1.2.9 and later.
   4.193 -
   4.194 -   // usage...
   4.195 -   int i;
   4.196 -   const int total = Mix_GetNumChunkDecoders();
   4.197 -   for (i = 0; i < total; i++)
   4.198 -       printf("Supported chunk decoder: [%s]\n", Mix_GetChunkDecoder(i));
   4.199 -
   4.200 -   Appearing in this list doesn't promise your specific audio file will
   4.201 -   decode...but it's handy to know if you have, say, a functioning Timidity
   4.202 -   install.
   4.203 -
   4.204 -   These return values are static, read-only data; do not modify or free it.
   4.205 -   The pointers remain valid until you call Mix_CloseAudio().
   4.206 -*/
   4.207 -extern DECLSPEC int SDLCALL Mix_GetNumChunkDecoders(void);
   4.208 -extern DECLSPEC const char * SDLCALL Mix_GetChunkDecoder(int index);
   4.209 -extern DECLSPEC SDL_bool SDLCALL Mix_HasChunkDecoder(const char *name);
   4.210 -extern DECLSPEC int SDLCALL Mix_GetNumMusicDecoders(void);
   4.211 -extern DECLSPEC const char * SDLCALL Mix_GetMusicDecoder(int index);
   4.212 -extern DECLSPEC SDL_bool SDLCALL Mix_HasMusicDecoder(const char *name);
   4.213 -
   4.214 -/* Find out the music format of a mixer music, or the currently playing
   4.215 -   music, if 'music' is NULL.
   4.216 -*/
   4.217 -extern DECLSPEC Mix_MusicType SDLCALL Mix_GetMusicType(const Mix_Music *music);
   4.218 -
   4.219 -/* Set a function that is called after all mixing is performed.
   4.220 -   This can be used to provide real-time visual display of the audio stream
   4.221 -   or add a custom mixer filter for the stream data.
   4.222 -*/
   4.223 -extern DECLSPEC void SDLCALL Mix_SetPostMix(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg);
   4.224 -
   4.225 -/* Add your own music player or additional mixer function.
   4.226 -   If 'mix_func' is NULL, the default music player is re-enabled.
   4.227 - */
   4.228 -extern DECLSPEC void SDLCALL Mix_HookMusic(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg);
   4.229 -
   4.230 -/* Add your own callback for when the music has finished playing or when it is
   4.231 - * stopped from a call to Mix_HaltMusic.
   4.232 - */
   4.233 -extern DECLSPEC void SDLCALL Mix_HookMusicFinished(void (SDLCALL *music_finished)(void));
   4.234 -
   4.235 -/* Get a pointer to the user data for the current music hook */
   4.236 -extern DECLSPEC void * SDLCALL Mix_GetMusicHookData(void);
   4.237 -
   4.238 -/*
   4.239 - * Add your own callback when a channel has finished playing. NULL
   4.240 - *  to disable callback. The callback may be called from the mixer's audio
   4.241 - *  callback or it could be called as a result of Mix_HaltChannel(), etc.
   4.242 - *  do not call SDL_LockAudio() from this callback; you will either be
   4.243 - *  inside the audio callback, or SDL_mixer will explicitly lock the audio
   4.244 - *  before calling your callback.
   4.245 - */
   4.246 -extern DECLSPEC void SDLCALL Mix_ChannelFinished(void (SDLCALL *channel_finished)(int channel));
   4.247 -
   4.248 -
   4.249 -/* Special Effects API by ryan c. gordon. (icculus@icculus.org) */
   4.250 -
   4.251 -#define MIX_CHANNEL_POST  -2
   4.252 -
   4.253 -/* This is the format of a special effect callback:
   4.254 - *
   4.255 - *   myeffect(int chan, void *stream, int len, void *udata);
   4.256 - *
   4.257 - * (chan) is the channel number that your effect is affecting. (stream) is
   4.258 - *  the buffer of data to work upon. (len) is the size of (stream), and
   4.259 - *  (udata) is a user-defined bit of data, which you pass as the last arg of
   4.260 - *  Mix_RegisterEffect(), and is passed back unmolested to your callback.
   4.261 - *  Your effect changes the contents of (stream) based on whatever parameters
   4.262 - *  are significant, or just leaves it be, if you prefer. You can do whatever
   4.263 - *  you like to the buffer, though, and it will continue in its changed state
   4.264 - *  down the mixing pipeline, through any other effect functions, then finally
   4.265 - *  to be mixed with the rest of the channels and music for the final output
   4.266 - *  stream.
   4.267 - *
   4.268 - * DO NOT EVER call SDL_LockAudio() from your callback function!
   4.269 - */
   4.270 -typedef void (SDLCALL *Mix_EffectFunc_t)(int chan, void *stream, int len, void *udata);
   4.271 -
   4.272 -/*
   4.273 - * This is a callback that signifies that a channel has finished all its
   4.274 - *  loops and has completed playback. This gets called if the buffer
   4.275 - *  plays out normally, or if you call Mix_HaltChannel(), implicitly stop
   4.276 - *  a channel via Mix_AllocateChannels(), or unregister a callback while
   4.277 - *  it's still playing.
   4.278 - *
   4.279 - * DO NOT EVER call SDL_LockAudio() from your callback function!
   4.280 - */
   4.281 -typedef void (SDLCALL *Mix_EffectDone_t)(int chan, void *udata);
   4.282 -
   4.283 -
   4.284 -/* Register a special effect function. At mixing time, the channel data is
   4.285 - *  copied into a buffer and passed through each registered effect function.
   4.286 - *  After it passes through all the functions, it is mixed into the final
   4.287 - *  output stream. The copy to buffer is performed once, then each effect
   4.288 - *  function performs on the output of the previous effect. Understand that
   4.289 - *  this extra copy to a buffer is not performed if there are no effects
   4.290 - *  registered for a given chunk, which saves CPU cycles, and any given
   4.291 - *  effect will be extra cycles, too, so it is crucial that your code run
   4.292 - *  fast. Also note that the data that your function is given is in the
   4.293 - *  format of the sound device, and not the format you gave to Mix_OpenAudio(),
   4.294 - *  although they may in reality be the same. This is an unfortunate but
   4.295 - *  necessary speed concern. Use Mix_QuerySpec() to determine if you can
   4.296 - *  handle the data before you register your effect, and take appropriate
   4.297 - *  actions.
   4.298 - * You may also specify a callback (Mix_EffectDone_t) that is called when
   4.299 - *  the channel finishes playing. This gives you a more fine-grained control
   4.300 - *  than Mix_ChannelFinished(), in case you need to free effect-specific
   4.301 - *  resources, etc. If you don't need this, you can specify NULL.
   4.302 - * You may set the callbacks before or after calling Mix_PlayChannel().
   4.303 - * Things like Mix_SetPanning() are just internal special effect functions,
   4.304 - *  so if you are using that, you've already incurred the overhead of a copy
   4.305 - *  to a separate buffer, and that these effects will be in the queue with
   4.306 - *  any functions you've registered. The list of registered effects for a
   4.307 - *  channel is reset when a chunk finishes playing, so you need to explicitly
   4.308 - *  set them with each call to Mix_PlayChannel*().
   4.309 - * You may also register a special effect function that is to be run after
   4.310 - *  final mixing occurs. The rules for these callbacks are identical to those
   4.311 - *  in Mix_RegisterEffect, but they are run after all the channels and the
   4.312 - *  music have been mixed into a single stream, whereas channel-specific
   4.313 - *  effects run on a given channel before any other mixing occurs. These
   4.314 - *  global effect callbacks are call "posteffects". Posteffects only have
   4.315 - *  their Mix_EffectDone_t function called when they are unregistered (since
   4.316 - *  the main output stream is never "done" in the same sense as a channel).
   4.317 - *  You must unregister them manually when you've had enough. Your callback
   4.318 - *  will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
   4.319 - *  processing is considered a posteffect.
   4.320 - *
   4.321 - * After all these effects have finished processing, the callback registered
   4.322 - *  through Mix_SetPostMix() runs, and then the stream goes to the audio
   4.323 - *  device.
   4.324 - *
   4.325 - * DO NOT EVER call SDL_LockAudio() from your callback function!
   4.326 - *
   4.327 - * returns zero if error (no such channel), nonzero if added.
   4.328 - *  Error messages can be retrieved from Mix_GetError().
   4.329 - */
   4.330 -extern DECLSPEC int SDLCALL Mix_RegisterEffect(int chan, Mix_EffectFunc_t f, Mix_EffectDone_t d, void *arg);
   4.331 -
   4.332 -
   4.333 -/* You may not need to call this explicitly, unless you need to stop an
   4.334 - *  effect from processing in the middle of a chunk's playback.
   4.335 - * Posteffects are never implicitly unregistered as they are for channels,
   4.336 - *  but they may be explicitly unregistered through this function by
   4.337 - *  specifying MIX_CHANNEL_POST for a channel.
   4.338 - * returns zero if error (no such channel or effect), nonzero if removed.
   4.339 - *  Error messages can be retrieved from Mix_GetError().
   4.340 - */
   4.341 -extern DECLSPEC int SDLCALL Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f);
   4.342 -
   4.343 -
   4.344 -/* You may not need to call this explicitly, unless you need to stop all
   4.345 - *  effects from processing in the middle of a chunk's playback. Note that
   4.346 - *  this will also shut off some internal effect processing, since
   4.347 - *  Mix_SetPanning() and others may use this API under the hood. This is
   4.348 - *  called internally when a channel completes playback.
   4.349 - * Posteffects are never implicitly unregistered as they are for channels,
   4.350 - *  but they may be explicitly unregistered through this function by
   4.351 - *  specifying MIX_CHANNEL_POST for a channel.
   4.352 - * returns zero if error (no such channel), nonzero if all effects removed.
   4.353 - *  Error messages can be retrieved from Mix_GetError().
   4.354 - */
   4.355 -extern DECLSPEC int SDLCALL Mix_UnregisterAllEffects(int channel);
   4.356 -
   4.357 -
   4.358 -#define MIX_EFFECTSMAXSPEED  "MIX_EFFECTSMAXSPEED"
   4.359 -
   4.360 -/*
   4.361 - * These are the internally-defined mixing effects. They use the same API that
   4.362 - *  effects defined in the application use, but are provided here as a
   4.363 - *  convenience. Some effects can reduce their quality or use more memory in
   4.364 - *  the name of speed; to enable this, make sure the environment variable
   4.365 - *  MIX_EFFECTSMAXSPEED (see above) is defined before you call
   4.366 - *  Mix_OpenAudio().
   4.367 - */
   4.368 -
   4.369 -
   4.370 -/* Set the panning of a channel. The left and right channels are specified
   4.371 - *  as integers between 0 and 255, quietest to loudest, respectively.
   4.372 - *
   4.373 - * Technically, this is just individual volume control for a sample with
   4.374 - *  two (stereo) channels, so it can be used for more than just panning.
   4.375 - *  If you want real panning, call it like this:
   4.376 - *
   4.377 - *   Mix_SetPanning(channel, left, 255 - left);
   4.378 - *
   4.379 - * ...which isn't so hard.
   4.380 - *
   4.381 - * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
   4.382 - *  the panning will be done to the final mixed stream before passing it on
   4.383 - *  to the audio device.
   4.384 - *
   4.385 - * This uses the Mix_RegisterEffect() API internally, and returns without
   4.386 - *  registering the effect function if the audio device is not configured
   4.387 - *  for stereo output. Setting both (left) and (right) to 255 causes this
   4.388 - *  effect to be unregistered, since that is the data's normal state.
   4.389 - *
   4.390 - * returns zero if error (no such channel or Mix_RegisterEffect() fails),
   4.391 - *  nonzero if panning effect enabled. Note that an audio device in mono
   4.392 - *  mode is a no-op, but this call will return successful in that case.
   4.393 - *  Error messages can be retrieved from Mix_GetError().
   4.394 - */
   4.395 -extern DECLSPEC int SDLCALL Mix_SetPanning(int channel, Uint8 left, Uint8 right);
   4.396 -
   4.397 -
   4.398 -/* Set the position of a channel. (angle) is an integer from 0 to 360, that
   4.399 - *  specifies the location of the sound in relation to the listener. (angle)
   4.400 - *  will be reduced as neccesary (540 becomes 180 degrees, -100 becomes 260).
   4.401 - *  Angle 0 is due north, and rotates clockwise as the value increases.
   4.402 - *  For efficiency, the precision of this effect may be limited (angles 1
   4.403 - *  through 7 might all produce the same effect, 8 through 15 are equal, etc).
   4.404 - *  (distance) is an integer between 0 and 255 that specifies the space
   4.405 - *  between the sound and the listener. The larger the number, the further
   4.406 - *  away the sound is. Using 255 does not guarantee that the channel will be
   4.407 - *  culled from the mixing process or be completely silent. For efficiency,
   4.408 - *  the precision of this effect may be limited (distance 0 through 5 might
   4.409 - *  all produce the same effect, 6 through 10 are equal, etc). Setting (angle)
   4.410 - *  and (distance) to 0 unregisters this effect, since the data would be
   4.411 - *  unchanged.
   4.412 - *
   4.413 - * If you need more precise positional audio, consider using OpenAL for
   4.414 - *  spatialized effects instead of SDL_mixer. This is only meant to be a
   4.415 - *  basic effect for simple "3D" games.
   4.416 - *
   4.417 - * If the audio device is configured for mono output, then you won't get
   4.418 - *  any effectiveness from the angle; however, distance attenuation on the
   4.419 - *  channel will still occur. While this effect will function with stereo
   4.420 - *  voices, it makes more sense to use voices with only one channel of sound,
   4.421 - *  so when they are mixed through this effect, the positioning will sound
   4.422 - *  correct. You can convert them to mono through SDL before giving them to
   4.423 - *  the mixer in the first place if you like.
   4.424 - *
   4.425 - * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
   4.426 - *  the positioning will be done to the final mixed stream before passing it
   4.427 - *  on to the audio device.
   4.428 - *
   4.429 - * This is a convenience wrapper over Mix_SetDistance() and Mix_SetPanning().
   4.430 - *
   4.431 - * returns zero if error (no such channel or Mix_RegisterEffect() fails),
   4.432 - *  nonzero if position effect is enabled.
   4.433 - *  Error messages can be retrieved from Mix_GetError().
   4.434 - */
   4.435 -extern DECLSPEC int SDLCALL Mix_SetPosition(int channel, Sint16 angle, Uint8 distance);
   4.436 -
   4.437 -
   4.438 -/* Set the "distance" of a channel. (distance) is an integer from 0 to 255
   4.439 - *  that specifies the location of the sound in relation to the listener.
   4.440 - *  Distance 0 is overlapping the listener, and 255 is as far away as possible
   4.441 - *  A distance of 255 does not guarantee silence; in such a case, you might
   4.442 - *  want to try changing the chunk's volume, or just cull the sample from the
   4.443 - *  mixing process with Mix_HaltChannel().
   4.444 - * For efficiency, the precision of this effect may be limited (distances 1
   4.445 - *  through 7 might all produce the same effect, 8 through 15 are equal, etc).
   4.446 - *  (distance) is an integer between 0 and 255 that specifies the space
   4.447 - *  between the sound and the listener. The larger the number, the further
   4.448 - *  away the sound is.
   4.449 - * Setting (distance) to 0 unregisters this effect, since the data would be
   4.450 - *  unchanged.
   4.451 - * If you need more precise positional audio, consider using OpenAL for
   4.452 - *  spatialized effects instead of SDL_mixer. This is only meant to be a
   4.453 - *  basic effect for simple "3D" games.
   4.454 - *
   4.455 - * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
   4.456 - *  the distance attenuation will be done to the final mixed stream before
   4.457 - *  passing it on to the audio device.
   4.458 - *
   4.459 - * This uses the Mix_RegisterEffect() API internally.
   4.460 - *
   4.461 - * returns zero if error (no such channel or Mix_RegisterEffect() fails),
   4.462 - *  nonzero if position effect is enabled.
   4.463 - *  Error messages can be retrieved from Mix_GetError().
   4.464 - */
   4.465 -extern DECLSPEC int SDLCALL Mix_SetDistance(int channel, Uint8 distance);
   4.466 -
   4.467 -
   4.468 -/*
   4.469 - * !!! FIXME : Haven't implemented, since the effect goes past the
   4.470 - *              end of the sound buffer. Will have to think about this.
   4.471 - *               --ryan.
   4.472 - */
   4.473 -#if 0
   4.474 -/* Causes an echo effect to be mixed into a sound. (echo) is the amount
   4.475 - *  of echo to mix. 0 is no echo, 255 is infinite (and probably not
   4.476 - *  what you want).
   4.477 - *
   4.478 - * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
   4.479 - *  the reverbing will be done to the final mixed stream before passing it on
   4.480 - *  to the audio device.
   4.481 - *
   4.482 - * This uses the Mix_RegisterEffect() API internally. If you specify an echo
   4.483 - *  of zero, the effect is unregistered, as the data is already in that state.
   4.484 - *
   4.485 - * returns zero if error (no such channel or Mix_RegisterEffect() fails),
   4.486 - *  nonzero if reversing effect is enabled.
   4.487 - *  Error messages can be retrieved from Mix_GetError().
   4.488 - */
   4.489 -extern no_parse_DECLSPEC int SDLCALL Mix_SetReverb(int channel, Uint8 echo);
   4.490 -#endif
   4.491 -
   4.492 -/* Causes a channel to reverse its stereo. This is handy if the user has his
   4.493 - *  speakers hooked up backwards, or you would like to have a minor bit of
   4.494 - *  psychedelia in your sound code.  :)  Calling this function with (flip)
   4.495 - *  set to non-zero reverses the chunks's usual channels. If (flip) is zero,
   4.496 - *  the effect is unregistered.
   4.497 - *
   4.498 - * This uses the Mix_RegisterEffect() API internally, and thus is probably
   4.499 - *  more CPU intensive than having the user just plug in his speakers
   4.500 - *  correctly. Mix_SetReverseStereo() returns without registering the effect
   4.501 - *  function if the audio device is not configured for stereo output.
   4.502 - *
   4.503 - * If you specify MIX_CHANNEL_POST for (channel), then this the effect is used
   4.504 - *  on the final mixed stream before sending it on to the audio device (a
   4.505 - *  posteffect).
   4.506 - *
   4.507 - * returns zero if error (no such channel or Mix_RegisterEffect() fails),
   4.508 - *  nonzero if reversing effect is enabled. Note that an audio device in mono
   4.509 - *  mode is a no-op, but this call will return successful in that case.
   4.510 - *  Error messages can be retrieved from Mix_GetError().
   4.511 - */
   4.512 -extern DECLSPEC int SDLCALL Mix_SetReverseStereo(int channel, int flip);
   4.513 -
   4.514 -/* end of effects API. --ryan. */
   4.515 -
   4.516 -
   4.517 -/* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
   4.518 -   them dynamically to the next sample if requested with a -1 value below.
   4.519 -   Returns the number of reserved channels.
   4.520 - */
   4.521 -extern DECLSPEC int SDLCALL Mix_ReserveChannels(int num);
   4.522 -
   4.523 -/* Channel grouping functions */
   4.524 -
   4.525 -/* Attach a tag to a channel. A tag can be assigned to several mixer
   4.526 -   channels, to form groups of channels.
   4.527 -   If 'tag' is -1, the tag is removed (actually -1 is the tag used to
   4.528 -   represent the group of all the channels).
   4.529 -   Returns true if everything was OK.
   4.530 - */
   4.531 -extern DECLSPEC int SDLCALL Mix_GroupChannel(int which, int tag);
   4.532 -/* Assign several consecutive channels to a group */
   4.533 -extern DECLSPEC int SDLCALL Mix_GroupChannels(int from, int to, int tag);
   4.534 -/* Finds the first available channel in a group of channels,
   4.535 -   returning -1 if none are available.
   4.536 - */
   4.537 -extern DECLSPEC int SDLCALL Mix_GroupAvailable(int tag);
   4.538 -/* Returns the number of channels in a group. This is also a subtle
   4.539 -   way to get the total number of channels when 'tag' is -1
   4.540 - */
   4.541 -extern DECLSPEC int SDLCALL Mix_GroupCount(int tag);
   4.542 -/* Finds the "oldest" sample playing in a group of channels */
   4.543 -extern DECLSPEC int SDLCALL Mix_GroupOldest(int tag);
   4.544 -/* Finds the "most recent" (i.e. last) sample playing in a group of channels */
   4.545 -extern DECLSPEC int SDLCALL Mix_GroupNewer(int tag);
   4.546 -
   4.547 -/* Play an audio chunk on a specific channel.
   4.548 -   If the specified channel is -1, play on the first free channel.
   4.549 -   If 'loops' is greater than zero, loop the sound that many times.
   4.550 -   If 'loops' is -1, loop inifinitely (~65000 times).
   4.551 -   Returns which channel was used to play the sound.
   4.552 -*/
   4.553 -#define Mix_PlayChannel(channel,chunk,loops) Mix_PlayChannelTimed(channel,chunk,loops,-1)
   4.554 -/* The same as above, but the sound is played at most 'ticks' milliseconds */
   4.555 -extern DECLSPEC int SDLCALL Mix_PlayChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ticks);
   4.556 -extern DECLSPEC int SDLCALL Mix_PlayMusic(Mix_Music *music, int loops);
   4.557 -
   4.558 -/* Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions */
   4.559 -extern DECLSPEC int SDLCALL Mix_FadeInMusic(Mix_Music *music, int loops, int ms);
   4.560 -extern DECLSPEC int SDLCALL Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position);
   4.561 -#define Mix_FadeInChannel(channel,chunk,loops,ms) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1)
   4.562 -extern DECLSPEC int SDLCALL Mix_FadeInChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ms, int ticks);
   4.563 -
   4.564 -/* Set the volume in the range of 0-128 of a specific channel or chunk.
   4.565 -   If the specified channel is -1, set volume for all channels.
   4.566 -   Returns the original volume.
   4.567 -   If the specified volume is -1, just return the current volume.
   4.568 -*/
   4.569 -extern DECLSPEC int SDLCALL Mix_Volume(int channel, int volume);
   4.570 -extern DECLSPEC int SDLCALL Mix_VolumeChunk(Mix_Chunk *chunk, int volume);
   4.571 -extern DECLSPEC int SDLCALL Mix_VolumeMusic(int volume);
   4.572 -
   4.573 -/* Halt playing of a particular channel */
   4.574 -extern DECLSPEC int SDLCALL Mix_HaltChannel(int channel);
   4.575 -extern DECLSPEC int SDLCALL Mix_HaltGroup(int tag);
   4.576 -extern DECLSPEC int SDLCALL Mix_HaltMusic(void);
   4.577 -
   4.578 -/* Change the expiration delay for a particular channel.
   4.579 -   The sample will stop playing after the 'ticks' milliseconds have elapsed,
   4.580 -   or remove the expiration if 'ticks' is -1
   4.581 -*/
   4.582 -extern DECLSPEC int SDLCALL Mix_ExpireChannel(int channel, int ticks);
   4.583 -
   4.584 -/* Halt a channel, fading it out progressively till it's silent
   4.585 -   The ms parameter indicates the number of milliseconds the fading
   4.586 -   will take.
   4.587 - */
   4.588 -extern DECLSPEC int SDLCALL Mix_FadeOutChannel(int which, int ms);
   4.589 -extern DECLSPEC int SDLCALL Mix_FadeOutGroup(int tag, int ms);
   4.590 -extern DECLSPEC int SDLCALL Mix_FadeOutMusic(int ms);
   4.591 -
   4.592 -/* Query the fading status of a channel */
   4.593 -extern DECLSPEC Mix_Fading SDLCALL Mix_FadingMusic(void);
   4.594 -extern DECLSPEC Mix_Fading SDLCALL Mix_FadingChannel(int which);
   4.595 -
   4.596 -/* Pause/Resume a particular channel */
   4.597 -extern DECLSPEC void SDLCALL Mix_Pause(int channel);
   4.598 -extern DECLSPEC void SDLCALL Mix_Resume(int channel);
   4.599 -extern DECLSPEC int SDLCALL Mix_Paused(int channel);
   4.600 -
   4.601 -/* Pause/Resume the music stream */
   4.602 -extern DECLSPEC void SDLCALL Mix_PauseMusic(void);
   4.603 -extern DECLSPEC void SDLCALL Mix_ResumeMusic(void);
   4.604 -extern DECLSPEC void SDLCALL Mix_RewindMusic(void);
   4.605 -extern DECLSPEC int SDLCALL Mix_PausedMusic(void);
   4.606 -
   4.607 -/* Set the current position in the music stream.
   4.608 -   This returns 0 if successful, or -1 if it failed or isn't implemented.
   4.609 -   This function is only implemented for MOD music formats (set pattern
   4.610 -   order number) and for OGG, FLAC, MP3_MAD, MP3_MPG and MODPLUG music
   4.611 -   (set position in seconds), at the moment.
   4.612 -*/
   4.613 -extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position);
   4.614 -
   4.615 -/* Check the status of a specific channel.
   4.616 -   If the specified channel is -1, check all channels.
   4.617 -*/
   4.618 -extern DECLSPEC int SDLCALL Mix_Playing(int channel);
   4.619 -extern DECLSPEC int SDLCALL Mix_PlayingMusic(void);
   4.620 -
   4.621 -/* Stop music and set external music playback command */
   4.622 -extern DECLSPEC int SDLCALL Mix_SetMusicCMD(const char *command);
   4.623 -
   4.624 -/* Synchro value is set by MikMod from modules while playing */
   4.625 -extern DECLSPEC int SDLCALL Mix_SetSynchroValue(int value);
   4.626 -extern DECLSPEC int SDLCALL Mix_GetSynchroValue(void);
   4.627 -
   4.628 -/* Set/Get/Iterate SoundFonts paths to use by supported MIDI backends */
   4.629 -extern DECLSPEC int SDLCALL Mix_SetSoundFonts(const char *paths);
   4.630 -extern DECLSPEC const char* SDLCALL Mix_GetSoundFonts(void);
   4.631 -extern DECLSPEC int SDLCALL Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data);
   4.632 -
   4.633 -/* Get the Mix_Chunk currently associated with a mixer channel
   4.634 -    Returns NULL if it's an invalid channel, or there's no chunk associated.
   4.635 -*/
   4.636 -extern DECLSPEC Mix_Chunk * SDLCALL Mix_GetChunk(int channel);
   4.637 -
   4.638 -/* Close the mixer, halting all playing audio */
   4.639 -extern DECLSPEC void SDLCALL Mix_CloseAudio(void);
   4.640 -
   4.641 -/* We'll use SDL for reporting errors */
   4.642 -#define Mix_SetError    SDL_SetError
   4.643 -#define Mix_GetError    SDL_GetError
   4.644 -#define Mix_ClearError  SDL_ClearError
   4.645 -
   4.646 -/* Ends C function definitions when using C++ */
   4.647 -#ifdef __cplusplus
   4.648 -}
   4.649 -#endif
   4.650 -#include "close_code.h"
   4.651 -
   4.652 -#endif /* SDL_MIXER_H_ */
   4.653 -
   4.654 -/* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/configure	Mon Nov 18 18:50:50 2019 +0300
     5.2 +++ b/configure	Tue Nov 19 12:36:40 2019 +0300
     5.3 @@ -862,6 +862,7 @@
     5.4  docdir
     5.5  oldincludedir
     5.6  includedir
     5.7 +runstatedir
     5.8  localstatedir
     5.9  sharedstatedir
    5.10  sysconfdir
    5.11 @@ -973,6 +974,7 @@
    5.12  sysconfdir='${prefix}/etc'
    5.13  sharedstatedir='${prefix}/com'
    5.14  localstatedir='${prefix}/var'
    5.15 +runstatedir='${localstatedir}/run'
    5.16  includedir='${prefix}/include'
    5.17  oldincludedir='/usr/include'
    5.18  docdir='${datarootdir}/doc/${PACKAGE}'
    5.19 @@ -1225,6 +1227,15 @@
    5.20    | -silent | --silent | --silen | --sile | --sil)
    5.21      silent=yes ;;
    5.22  
    5.23 +  -runstatedir | --runstatedir | --runstatedi | --runstated \
    5.24 +  | --runstate | --runstat | --runsta | --runst | --runs \
    5.25 +  | --run | --ru | --r)
    5.26 +    ac_prev=runstatedir ;;
    5.27 +  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
    5.28 +  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
    5.29 +  | --run=* | --ru=* | --r=*)
    5.30 +    runstatedir=$ac_optarg ;;
    5.31 +
    5.32    -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
    5.33      ac_prev=sbindir ;;
    5.34    -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
    5.35 @@ -1362,7 +1373,7 @@
    5.36  for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
    5.37  		datadir sysconfdir sharedstatedir localstatedir includedir \
    5.38  		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
    5.39 -		libdir localedir mandir
    5.40 +		libdir localedir mandir runstatedir
    5.41  do
    5.42    eval ac_val=\$$ac_var
    5.43    # Remove trailing slashes.
    5.44 @@ -1515,6 +1526,7 @@
    5.45    --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
    5.46    --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
    5.47    --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
    5.48 +  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
    5.49    --libdir=DIR            object code libraries [EPREFIX/lib]
    5.50    --includedir=DIR        C header files [PREFIX/include]
    5.51    --oldincludedir=DIR     C header files for non-gcc [/usr/include]
    5.52 @@ -3927,13 +3939,13 @@
    5.53  else
    5.54    lt_cv_nm_interface="BSD nm"
    5.55    echo "int some_variable = 0;" > conftest.$ac_ext
    5.56 -  (eval echo "\"\$as_me:3930: $ac_compile\"" >&5)
    5.57 +  (eval echo "\"\$as_me:3942: $ac_compile\"" >&5)
    5.58    (eval "$ac_compile" 2>conftest.err)
    5.59    cat conftest.err >&5
    5.60 -  (eval echo "\"\$as_me:3933: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
    5.61 +  (eval echo "\"\$as_me:3945: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
    5.62    (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
    5.63    cat conftest.err >&5
    5.64 -  (eval echo "\"\$as_me:3936: output\"" >&5)
    5.65 +  (eval echo "\"\$as_me:3948: output\"" >&5)
    5.66    cat conftest.out >&5
    5.67    if $GREP 'External.*some_variable' conftest.out > /dev/null; then
    5.68      lt_cv_nm_interface="MS dumpbin"
    5.69 @@ -5144,7 +5156,7 @@
    5.70    ;;
    5.71  *-*-irix6*)
    5.72    # Find out which ABI we are using.
    5.73 -  echo '#line 5147 "configure"' > conftest.$ac_ext
    5.74 +  echo '#line 5159 "configure"' > conftest.$ac_ext
    5.75    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
    5.76    (eval $ac_compile) 2>&5
    5.77    ac_status=$?
    5.78 @@ -6974,11 +6986,11 @@
    5.79     -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    5.80     -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    5.81     -e 's:$: $lt_compiler_flag:'`
    5.82 -   (eval echo "\"\$as_me:6977: $lt_compile\"" >&5)
    5.83 +   (eval echo "\"\$as_me:6989: $lt_compile\"" >&5)
    5.84     (eval "$lt_compile" 2>conftest.err)
    5.85     ac_status=$?
    5.86     cat conftest.err >&5
    5.87 -   echo "$as_me:6981: \$? = $ac_status" >&5
    5.88 +   echo "$as_me:6993: \$? = $ac_status" >&5
    5.89     if (exit $ac_status) && test -s "$ac_outfile"; then
    5.90       # The compiler can only warn and ignore the option if not recognized
    5.91       # So say no if there are warnings other than the usual output.
    5.92 @@ -7313,11 +7325,11 @@
    5.93     -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    5.94     -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    5.95     -e 's:$: $lt_compiler_flag:'`
    5.96 -   (eval echo "\"\$as_me:7316: $lt_compile\"" >&5)
    5.97 +   (eval echo "\"\$as_me:7328: $lt_compile\"" >&5)
    5.98     (eval "$lt_compile" 2>conftest.err)
    5.99     ac_status=$?
   5.100     cat conftest.err >&5
   5.101 -   echo "$as_me:7320: \$? = $ac_status" >&5
   5.102 +   echo "$as_me:7332: \$? = $ac_status" >&5
   5.103     if (exit $ac_status) && test -s "$ac_outfile"; then
   5.104       # The compiler can only warn and ignore the option if not recognized
   5.105       # So say no if there are warnings other than the usual output.
   5.106 @@ -7418,11 +7430,11 @@
   5.107     -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   5.108     -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   5.109     -e 's:$: $lt_compiler_flag:'`
   5.110 -   (eval echo "\"\$as_me:7421: $lt_compile\"" >&5)
   5.111 +   (eval echo "\"\$as_me:7433: $lt_compile\"" >&5)
   5.112     (eval "$lt_compile" 2>out/conftest.err)
   5.113     ac_status=$?
   5.114     cat out/conftest.err >&5
   5.115 -   echo "$as_me:7425: \$? = $ac_status" >&5
   5.116 +   echo "$as_me:7437: \$? = $ac_status" >&5
   5.117     if (exit $ac_status) && test -s out/conftest2.$ac_objext
   5.118     then
   5.119       # The compiler can only warn and ignore the option if not recognized
   5.120 @@ -7473,11 +7485,11 @@
   5.121     -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   5.122     -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   5.123     -e 's:$: $lt_compiler_flag:'`
   5.124 -   (eval echo "\"\$as_me:7476: $lt_compile\"" >&5)
   5.125 +   (eval echo "\"\$as_me:7488: $lt_compile\"" >&5)
   5.126     (eval "$lt_compile" 2>out/conftest.err)
   5.127     ac_status=$?
   5.128     cat out/conftest.err >&5
   5.129 -   echo "$as_me:7480: \$? = $ac_status" >&5
   5.130 +   echo "$as_me:7492: \$? = $ac_status" >&5
   5.131     if (exit $ac_status) && test -s out/conftest2.$ac_objext
   5.132     then
   5.133       # The compiler can only warn and ignore the option if not recognized
   5.134 @@ -9842,7 +9854,7 @@
   5.135    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   5.136    lt_status=$lt_dlunknown
   5.137    cat > conftest.$ac_ext <<_LT_EOF
   5.138 -#line 9845 "configure"
   5.139 +#line 9857 "configure"
   5.140  #include "confdefs.h"
   5.141  
   5.142  #if HAVE_DLFCN_H
   5.143 @@ -9938,7 +9950,7 @@
   5.144    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   5.145    lt_status=$lt_dlunknown
   5.146    cat > conftest.$ac_ext <<_LT_EOF
   5.147 -#line 9941 "configure"
   5.148 +#line 9953 "configure"
   5.149  #include "confdefs.h"
   5.150  
   5.151  #if HAVE_DLFCN_H
   5.152 @@ -10930,7 +10942,7 @@
   5.153          BASE_LDFLAGS=""
   5.154          ;;
   5.155  esac
   5.156 -BUILD_CFLAGS="$CFLAGS $CPPFLAGS"
   5.157 +BUILD_CFLAGS="$CFLAGS $CPPFLAGS -I$srcdir/include -I$srcdir/src -I$srcdir/src/codecs"
   5.158  EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
   5.159  BUILD_LDFLAGS="$LDFLAGS"
   5.160  EXTRA_LDFLAGS="$BASE_LDFLAGS"
   5.161 @@ -11094,7 +11106,7 @@
   5.162  esac
   5.163  
   5.164  # Standard C sources
   5.165 -SOURCES=`ls $srcdir/*.c | fgrep -v playwave.c | fgrep -v playmus.c`
   5.166 +SOURCES=`ls $srcdir/src/*.c $srcdir/src/codecs/*.c | fgrep -v playwave.c | fgrep -v playmus.c`
   5.167  
   5.168  base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
   5.169  
   5.170 @@ -12104,8 +12116,8 @@
   5.171  fi
   5.172  
   5.173      if test x$enable_music_midi_timidity = xyes; then
   5.174 -        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_TIMIDITY -I\$(srcdir)/timidity"
   5.175 -        SOURCES="$SOURCES $srcdir/timidity/*.c"
   5.176 +        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_TIMIDITY -I\$(srcdir)/src/codecs/timidity"
   5.177 +        SOURCES="$SOURCES $srcdir/src/codecs/timidity/*.c"
   5.178      fi
   5.179      # Check whether --enable-music-midi-native was given.
   5.180  if test "${enable_music_midi_native+set}" = set; then :
   5.181 @@ -12134,12 +12146,12 @@
   5.182                  ;;
   5.183          esac
   5.184          if test x$use_music_midi_native = xyes; then
   5.185 -            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi"
   5.186 -            SOURCES="$SOURCES $srcdir/native_midi/*.c"
   5.187 +            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/src/codecs/native_midi"
   5.188 +            SOURCES="$SOURCES $srcdir/src/codecs/native_midi/*.c"
   5.189          elif test x$use_music_midi_native = xyes_cpp; then
   5.190 -            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi"
   5.191 -            SOURCES="$SOURCES $srcdir/native_midi/*.c"
   5.192 -            SOURCES_CXX="$SOURCES_CXX $srcdir/native_midi/*.cpp"
   5.193 +            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/src/codecs/native_midi"
   5.194 +            SOURCES="$SOURCES $srcdir/src/codecs/native_midi/*.c"
   5.195 +            SOURCES_CXX="$SOURCES_CXX $srcdir/src/codecs/native_midi/*.cpp"
   5.196          fi
   5.197      fi
   5.198      # Check whether --enable-music-midi-fluidsynth was given.
     6.1 --- a/configure.in	Mon Nov 18 18:50:50 2019 +0300
     6.2 +++ b/configure.in	Tue Nov 19 12:36:40 2019 +0300
     6.3 @@ -68,7 +68,7 @@
     6.4          BASE_LDFLAGS=""
     6.5          ;;
     6.6  esac
     6.7 -BUILD_CFLAGS="$CFLAGS $CPPFLAGS"
     6.8 +BUILD_CFLAGS="$CFLAGS $CPPFLAGS -I$srcdir/include -I$srcdir/src -I$srcdir/src/codecs"
     6.9  EXTRA_CFLAGS="$INCLUDE $BASE_CFLAGS"
    6.10  BUILD_LDFLAGS="$LDFLAGS"
    6.11  EXTRA_LDFLAGS="$BASE_LDFLAGS"
    6.12 @@ -135,7 +135,7 @@
    6.13  esac
    6.14  
    6.15  # Standard C sources
    6.16 -SOURCES=`ls $srcdir/*.c | fgrep -v playwave.c | fgrep -v playmus.c`
    6.17 +SOURCES=`ls $srcdir/src/*.c $srcdir/src/codecs/*.c | fgrep -v playwave.c | fgrep -v playmus.c`
    6.18  
    6.19  dnl set this to use on systems that use lib64 instead of lib
    6.20  base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
    6.21 @@ -359,8 +359,8 @@
    6.22  AC_HELP_STRING([--enable-music-midi-timidity], [enable timidity MIDI output [[default=yes]]]),
    6.23                    [], [enable_music_midi_timidity=yes])
    6.24      if test x$enable_music_midi_timidity = xyes; then
    6.25 -        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_TIMIDITY -I\$(srcdir)/timidity"
    6.26 -        SOURCES="$SOURCES $srcdir/timidity/*.c"
    6.27 +        EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_TIMIDITY -I\$(srcdir)/src/codecs/timidity"
    6.28 +        SOURCES="$SOURCES $srcdir/src/codecs/timidity/*.c"
    6.29      fi
    6.30      AC_ARG_ENABLE([music-midi-native],
    6.31  AC_HELP_STRING([--enable-music-midi-native], [enable native MIDI music output [[default=yes]]]),
    6.32 @@ -381,16 +381,16 @@
    6.33                  ;;
    6.34              *-*-haiku*)
    6.35                  use_music_midi_native=yes_cpp
    6.36 -                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmidi" 
    6.37 +                EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmidi"
    6.38                  ;;
    6.39          esac
    6.40          if test x$use_music_midi_native = xyes; then
    6.41 -            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi"
    6.42 -            SOURCES="$SOURCES $srcdir/native_midi/*.c"
    6.43 +            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/src/codecs/native_midi"
    6.44 +            SOURCES="$SOURCES $srcdir/src/codecs/native_midi/*.c"
    6.45          elif test x$use_music_midi_native = xyes_cpp; then
    6.46 -            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi"
    6.47 -            SOURCES="$SOURCES $srcdir/native_midi/*.c"
    6.48 -            SOURCES_CXX="$SOURCES_CXX $srcdir/native_midi/*.cpp"
    6.49 +            EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/src/codecs/native_midi"
    6.50 +            SOURCES="$SOURCES $srcdir/src/codecs/native_midi/*.c"
    6.51 +            SOURCES_CXX="$SOURCES_CXX $srcdir/src/codecs/native_midi/*.cpp"
    6.52          fi
    6.53      fi
    6.54      AC_ARG_ENABLE([music-midi-fluidsynth],
    6.55 @@ -541,7 +541,7 @@
    6.56      if test x$have_flac_ver = xyes; then
    6.57          AC_CHECK_HEADER([FLAC/stream_decoder.h], [have_flac_hdr=yes])
    6.58          AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new], [have_flac_lib=yes])
    6.59 -        if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then    
    6.60 +        if test x$have_flac_hdr = xyes -a x$have_flac_lib = xyes; then
    6.61              case "$host" in
    6.62                  *-*-darwin*)
    6.63                      flac_lib=[`find_lib libFLAC.dylib`]
    6.64 @@ -768,7 +768,7 @@
    6.65  
    6.66  -include \$(PLAYMUS_OBJECTS:.lo=.d)
    6.67  $PLAYMUS_DEPENDS
    6.68 -__EOF__ 
    6.69 +__EOF__
    6.70  ], [
    6.71  DEPENDS="$DEPENDS"
    6.72  VERSION_DEPENDS="$VERSION_DEPENDS"
     7.1 --- a/effect_position.c	Mon Nov 18 18:50:50 2019 +0300
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,2109 +0,0 @@
     7.4 -/*
     7.5 -  SDL_mixer:  An audio mixer library based on the SDL library
     7.6 -  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
     7.7 -
     7.8 -  This software is provided 'as-is', without any express or implied
     7.9 -  warranty.  In no event will the authors be held liable for any damages
    7.10 -  arising from the use of this software.
    7.11 -
    7.12 -  Permission is granted to anyone to use this software for any purpose,
    7.13 -  including commercial applications, and to alter it and redistribute it
    7.14 -  freely, subject to the following restrictions:
    7.15 -
    7.16 -  1. The origin of this software must not be misrepresented; you must not
    7.17 -     claim that you wrote the original software. If you use this software
    7.18 -     in a product, an acknowledgment in the product documentation would be
    7.19 -     appreciated but is not required.
    7.20 -  2. Altered source versions must be plainly marked as such, and must not be
    7.21 -     misrepresented as being the original software.
    7.22 -  3. This notice may not be removed or altered from any source distribution.
    7.23 -
    7.24 -  This file by Ryan C. Gordon (icculus@icculus.org)
    7.25 -
    7.26 -  These are some internally supported special effects that use SDL_mixer's
    7.27 -  effect callback API. They are meant for speed over quality.  :)
    7.28 -*/
    7.29 -
    7.30 -#include <stdio.h>
    7.31 -#include <stdlib.h>
    7.32 -#include <string.h>
    7.33 -
    7.34 -#include "SDL.h"
    7.35 -#include "SDL_endian.h"
    7.36 -#include "SDL_mixer.h"
    7.37 -#include "mixer.h"
    7.38 -
    7.39 -#define __MIX_INTERNAL_EFFECT__
    7.40 -#include "effects_internal.h"
    7.41 -
    7.42 -/* profile code:
    7.43 -    #include <sys/time.h>
    7.44 -    #include <unistd.h>
    7.45 -    struct timeval tv1;
    7.46 -    struct timeval tv2;
    7.47 -
    7.48 -    gettimeofday(&tv1, NULL);
    7.49 -
    7.50 -        ... do your thing here ...
    7.51 -
    7.52 -    gettimeofday(&tv2, NULL);
    7.53 -    printf("%ld\n", tv2.tv_usec - tv1.tv_usec);
    7.54 -*/
    7.55 -
    7.56 -
    7.57 -/*
    7.58 - * Positional effects...panning, distance attenuation, etc.
    7.59 - */
    7.60 -
    7.61 -typedef struct _Eff_positionargs
    7.62 -{
    7.63 -    volatile float left_f;
    7.64 -    volatile float right_f;
    7.65 -    volatile Uint8 left_u8;
    7.66 -    volatile Uint8 right_u8;
    7.67 -    volatile float left_rear_f;
    7.68 -    volatile float right_rear_f;
    7.69 -    volatile float center_f;
    7.70 -    volatile float lfe_f;
    7.71 -    volatile Uint8 left_rear_u8;
    7.72 -    volatile Uint8 right_rear_u8;
    7.73 -    volatile Uint8 center_u8;
    7.74 -    volatile Uint8 lfe_u8;
    7.75 -    volatile float distance_f;
    7.76 -    volatile Uint8 distance_u8;
    7.77 -    volatile Sint16 room_angle;
    7.78 -    volatile int in_use;
    7.79 -    volatile int channels;
    7.80 -} position_args;
    7.81 -
    7.82 -static position_args **pos_args_array = NULL;
    7.83 -static position_args *pos_args_global = NULL;
    7.84 -static int position_channels = 0;
    7.85 -
    7.86 -void _Eff_PositionDeinit(void)
    7.87 -{
    7.88 -    int i;
    7.89 -    for (i = 0; i < position_channels; i++) {
    7.90 -        SDL_free(pos_args_array[i]);
    7.91 -    }
    7.92 -
    7.93 -    position_channels = 0;
    7.94 -
    7.95 -    SDL_free(pos_args_global);
    7.96 -    pos_args_global = NULL;
    7.97 -    SDL_free(pos_args_array);
    7.98 -    pos_args_array = NULL;
    7.99 -}
   7.100 -
   7.101 -
   7.102 -/* This just frees up the callback-specific data. */
   7.103 -static void SDLCALL _Eff_PositionDone(int channel, void *udata)
   7.104 -{
   7.105 -    (void)udata;
   7.106 -
   7.107 -    if (channel < 0) {
   7.108 -        if (pos_args_global != NULL) {
   7.109 -            SDL_free(pos_args_global);
   7.110 -            pos_args_global = NULL;
   7.111 -        }
   7.112 -    }
   7.113 -    else if (pos_args_array[channel] != NULL) {
   7.114 -        SDL_free(pos_args_array[channel]);
   7.115 -        pos_args_array[channel] = NULL;
   7.116 -    }
   7.117 -}
   7.118 -
   7.119 -static void SDLCALL _Eff_position_u8(int chan, void *stream, int len, void *udata)
   7.120 -{
   7.121 -    volatile position_args *args = (volatile position_args *) udata;
   7.122 -    Uint8 *ptr = (Uint8 *) stream;
   7.123 -    int i;
   7.124 -
   7.125 -    (void)chan;
   7.126 -
   7.127 -    /*
   7.128 -     * if there's only a mono channnel (the only way we wouldn't have
   7.129 -     *  a len divisible by 2 here), then left_f and right_f are always
   7.130 -     *  1.0, and are therefore throwaways.
   7.131 -     */
   7.132 -    if (len % (int)sizeof(Uint16) != 0) {
   7.133 -        *ptr = (Uint8) (((float) *ptr) * args->distance_f);
   7.134 -        ptr++;
   7.135 -        len--;
   7.136 -    }
   7.137 -
   7.138 -    if (args->room_angle == 180)
   7.139 -    for (i = 0; i < len; i += sizeof (Uint8) * 2) {
   7.140 -        /* must adjust the sample so that 0 is the center */
   7.141 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.142 -            * args->right_f) * args->distance_f) + 128);
   7.143 -        ptr++;
   7.144 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.145 -            * args->left_f) * args->distance_f) + 128);
   7.146 -        ptr++;
   7.147 -    }
   7.148 -    else for (i = 0; i < len; i += sizeof (Uint8) * 2) {
   7.149 -        /* must adjust the sample so that 0 is the center */
   7.150 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.151 -            * args->left_f) * args->distance_f) + 128);
   7.152 -        ptr++;
   7.153 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.154 -            * args->right_f) * args->distance_f) + 128);
   7.155 -        ptr++;
   7.156 -    }
   7.157 -}
   7.158 -
   7.159 -static void SDLCALL _Eff_position_u8_c4(int chan, void *stream, int len, void *udata)
   7.160 -{
   7.161 -    volatile position_args *args = (volatile position_args *) udata;
   7.162 -    Uint8 *ptr = (Uint8 *) stream;
   7.163 -    int i;
   7.164 -
   7.165 -    (void)chan;
   7.166 -
   7.167 -    /*
   7.168 -     * if there's only a mono channnel (the only way we wouldn't have
   7.169 -     *  a len divisible by 2 here), then left_f and right_f are always
   7.170 -     *  1.0, and are therefore throwaways.
   7.171 -     */
   7.172 -    if (len % (int)sizeof(Uint16) != 0) {
   7.173 -        *ptr = (Uint8) (((float) *ptr) * args->distance_f);
   7.174 -        ptr++;
   7.175 -        len--;
   7.176 -    }
   7.177 -
   7.178 -    if (args->room_angle == 0)
   7.179 -    for (i = 0; i < len; i += sizeof (Uint8) * 6) {
   7.180 -        /* must adjust the sample so that 0 is the center */
   7.181 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.182 -            * args->left_f) * args->distance_f) + 128);
   7.183 -        ptr++;
   7.184 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.185 -            * args->right_f) * args->distance_f) + 128);
   7.186 -        ptr++;
   7.187 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.188 -            * args->left_rear_f) * args->distance_f) + 128);
   7.189 -        ptr++;
   7.190 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.191 -            * args->right_rear_f) * args->distance_f) + 128);
   7.192 -        ptr++;
   7.193 -    }
   7.194 -    else if (args->room_angle == 90)
   7.195 -    for (i = 0; i < len; i += sizeof (Uint8) * 6) {
   7.196 -        /* must adjust the sample so that 0 is the center */
   7.197 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.198 -            * args->right_f) * args->distance_f) + 128);
   7.199 -        ptr++;
   7.200 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.201 -            * args->right_rear_f) * args->distance_f) + 128);
   7.202 -        ptr++;
   7.203 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.204 -            * args->left_f) * args->distance_f) + 128);
   7.205 -        ptr++;
   7.206 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.207 -            * args->left_rear_f) * args->distance_f) + 128);
   7.208 -        ptr++;
   7.209 -    }
   7.210 -    else if (args->room_angle == 180)
   7.211 -    for (i = 0; i < len; i += sizeof (Uint8) * 6) {
   7.212 -        /* must adjust the sample so that 0 is the center */
   7.213 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.214 -            * args->right_rear_f) * args->distance_f) + 128);
   7.215 -        ptr++;
   7.216 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.217 -            * args->left_rear_f) * args->distance_f) + 128);
   7.218 -        ptr++;
   7.219 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.220 -            * args->right_f) * args->distance_f) + 128);
   7.221 -        ptr++;
   7.222 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.223 -            * args->left_f) * args->distance_f) + 128);
   7.224 -        ptr++;
   7.225 -    }
   7.226 -    else if (args->room_angle == 270)
   7.227 -    for (i = 0; i < len; i += sizeof (Uint8) * 6) {
   7.228 -        /* must adjust the sample so that 0 is the center */
   7.229 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.230 -            * args->left_rear_f) * args->distance_f) + 128);
   7.231 -        ptr++;
   7.232 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.233 -            * args->left_f) * args->distance_f) + 128);
   7.234 -        ptr++;
   7.235 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.236 -            * args->right_rear_f) * args->distance_f) + 128);
   7.237 -        ptr++;
   7.238 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.239 -            * args->right_f) * args->distance_f) + 128);
   7.240 -        ptr++;
   7.241 -    }
   7.242 -}
   7.243 -
   7.244 -
   7.245 -static void SDLCALL _Eff_position_u8_c6(int chan, void *stream, int len, void *udata)
   7.246 -{
   7.247 -    volatile position_args *args = (volatile position_args *) udata;
   7.248 -    Uint8 *ptr = (Uint8 *) stream;
   7.249 -    int i;
   7.250 -
   7.251 -    (void)chan;
   7.252 -    (void)len;
   7.253 -
   7.254 -    /*
   7.255 -     * if there's only a mono channnel (the only way we wouldn't have
   7.256 -     *  a len divisible by 2 here), then left_f and right_f are always
   7.257 -     *  1.0, and are therefore throwaways.
   7.258 -     */
   7.259 -    if (len % (int)sizeof(Uint16) != 0) {
   7.260 -        *ptr = (Uint8) (((float) *ptr) * args->distance_f);
   7.261 -        ptr++;
   7.262 -        len--;
   7.263 -    }
   7.264 -
   7.265 -    if (args->room_angle == 0)
   7.266 -    for (i = 0; i < len; i += sizeof (Uint8) * 6) {
   7.267 -        /* must adjust the sample so that 0 is the center */
   7.268 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.269 -            * args->left_f) * args->distance_f) + 128);
   7.270 -        ptr++;
   7.271 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.272 -            * args->right_f) * args->distance_f) + 128);
   7.273 -        ptr++;
   7.274 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.275 -            * args->left_rear_f) * args->distance_f) + 128);
   7.276 -        ptr++;
   7.277 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.278 -            * args->right_rear_f) * args->distance_f) + 128);
   7.279 -        ptr++;
   7.280 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.281 -            * args->center_f) * args->distance_f) + 128);
   7.282 -        ptr++;
   7.283 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.284 -            * args->lfe_f) * args->distance_f) + 128);
   7.285 -        ptr++;
   7.286 -    }
   7.287 -    else if (args->room_angle == 90)
   7.288 -    for (i = 0; i < len; i += sizeof (Uint8) * 6) {
   7.289 -        /* must adjust the sample so that 0 is the center */
   7.290 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.291 -            * args->right_f) * args->distance_f) + 128);
   7.292 -        ptr++;
   7.293 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.294 -            * args->right_rear_f) * args->distance_f) + 128);
   7.295 -        ptr++;
   7.296 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.297 -            * args->left_f) * args->distance_f) + 128);
   7.298 -        ptr++;
   7.299 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.300 -            * args->left_rear_f) * args->distance_f) + 128);
   7.301 -        ptr++;
   7.302 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.303 -            * args->right_rear_f) * args->distance_f/2) + 128)
   7.304 -            + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.305 -            * args->right_f) * args->distance_f/2) + 128);
   7.306 -        ptr++;
   7.307 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.308 -            * args->lfe_f) * args->distance_f) + 128);
   7.309 -        ptr++;
   7.310 -    }
   7.311 -    else if (args->room_angle == 180)
   7.312 -    for (i = 0; i < len; i += sizeof (Uint8) * 6) {
   7.313 -        /* must adjust the sample so that 0 is the center */
   7.314 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.315 -            * args->right_rear_f) * args->distance_f) + 128);
   7.316 -        ptr++;
   7.317 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.318 -            * args->left_rear_f) * args->distance_f) + 128);
   7.319 -        ptr++;
   7.320 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.321 -            * args->right_f) * args->distance_f) + 128);
   7.322 -        ptr++;
   7.323 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.324 -            * args->left_f) * args->distance_f) + 128);
   7.325 -        ptr++;
   7.326 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.327 -            * args->right_rear_f) * args->distance_f/2) + 128)
   7.328 -            + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.329 -            * args->left_rear_f) * args->distance_f/2) + 128);
   7.330 -        ptr++;
   7.331 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.332 -            * args->lfe_f) * args->distance_f) + 128);
   7.333 -        ptr++;
   7.334 -    }
   7.335 -    else if (args->room_angle == 270)
   7.336 -    for (i = 0; i < len; i += sizeof (Uint8) * 6) {
   7.337 -        /* must adjust the sample so that 0 is the center */
   7.338 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.339 -            * args->left_rear_f) * args->distance_f) + 128);
   7.340 -        ptr++;
   7.341 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.342 -            * args->left_f) * args->distance_f) + 128);
   7.343 -        ptr++;
   7.344 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.345 -            * args->right_rear_f) * args->distance_f) + 128);
   7.346 -        ptr++;
   7.347 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.348 -            * args->right_f) * args->distance_f) + 128);
   7.349 -        ptr++;
   7.350 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.351 -            * args->left_f) * args->distance_f/2) + 128)
   7.352 -            + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.353 -            * args->left_rear_f) * args->distance_f/2) + 128);
   7.354 -        ptr++;
   7.355 -        *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
   7.356 -            * args->lfe_f) * args->distance_f) + 128);
   7.357 -        ptr++;
   7.358 -    }
   7.359 -}
   7.360 -
   7.361 -
   7.362 -/*
   7.363 - * This one runs about 10.1 times faster than the non-table version, with
   7.364 - *  no loss in quality. It does, however, require 64k of memory for the
   7.365 - *  lookup table. Also, this will only update position information once per
   7.366 - *  call; the non-table version always checks the arguments for each sample,
   7.367 - *  in case the user has called Mix_SetPanning() or whatnot again while this
   7.368 - *  callback is running.
   7.369 - */
   7.370 -static void SDLCALL _Eff_position_table_u8(int chan, void *stream, int len, void *udata)
   7.371 -{
   7.372 -    volatile position_args *args = (volatile position_args *) udata;
   7.373 -    Uint8 *ptr = (Uint8 *) stream;
   7.374 -    Uint32 *p;
   7.375 -    int i;
   7.376 -    Uint8 *l = ((Uint8 *) _Eff_volume_table) + (256 * args->left_u8);
   7.377 -    Uint8 *r = ((Uint8 *) _Eff_volume_table) + (256 * args->right_u8);
   7.378 -    Uint8 *d = ((Uint8 *) _Eff_volume_table) + (256 * args->distance_u8);
   7.379 -
   7.380 -    (void)chan;
   7.381 -
   7.382 -    if (args->room_angle == 180) {
   7.383 -        Uint8 *temp = l;
   7.384 -        l = r;
   7.385 -        r = temp;
   7.386 -    }
   7.387 -    /*
   7.388 -     * if there's only a mono channnel, then l[] and r[] are always
   7.389 -     *  volume 255, and are therefore throwaways. Still, we have to
   7.390 -     *  be sure not to overrun the audio buffer...
   7.391 -     */
   7.392 -    while (len % (int)sizeof(Uint32) != 0) {
   7.393 -        *ptr = d[l[*ptr]];
   7.394 -        ptr++;
   7.395 -        if (args->channels > 1) {
   7.396 -            *ptr = d[r[*ptr]];
   7.397 -            ptr++;
   7.398 -        }
   7.399 -        len -= args->channels;
   7.400 -    }
   7.401 -
   7.402 -    p = (Uint32 *) ptr;
   7.403 -
   7.404 -    for (i = 0; i < len; i += sizeof (Uint32)) {
   7.405 -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
   7.406 -        *p = (d[l[(*p & 0xFF000000) >> 24]] << 24) |
   7.407 -             (d[r[(*p & 0x00FF0000) >> 16]] << 16) |
   7.408 -             (d[l[(*p & 0x0000FF00) >>  8]] <<  8) |
   7.409 -             (d[r[(*p & 0x000000FF)      ]]     ) ;
   7.410 -#else
   7.411 -        *p = (d[r[(*p & 0xFF000000) >> 24]] << 24) |
   7.412 -             (d[l[(*p & 0x00FF0000) >> 16]] << 16) |
   7.413 -             (d[r[(*p & 0x0000FF00) >>  8]] <<  8) |
   7.414 -             (d[l[(*p & 0x000000FF)      ]]     ) ;
   7.415 -#endif
   7.416 -        ++p;
   7.417 -    }
   7.418 -}
   7.419 -
   7.420 -
   7.421 -static void SDLCALL _Eff_position_s8(int chan, void *stream, int len, void *udata)
   7.422 -{
   7.423 -    volatile position_args *args = (volatile position_args *) udata;
   7.424 -    Sint8 *ptr = (Sint8 *) stream;
   7.425 -    int i;
   7.426 -
   7.427 -    (void)chan;
   7.428 -
   7.429 -    /*
   7.430 -     * if there's only a mono channnel (the only way we wouldn't have
   7.431 -     *  a len divisible by 2 here), then left_f and right_f are always
   7.432 -     *  1.0, and are therefore throwaways.
   7.433 -     */
   7.434 -    if (len % (int)sizeof(Sint16) != 0) {
   7.435 -        *ptr = (Sint8) (((float) *ptr) * args->distance_f);
   7.436 -        ptr++;
   7.437 -        len--;
   7.438 -    }
   7.439 -
   7.440 -    if (args->room_angle == 180)
   7.441 -    for (i = 0; i < len; i += sizeof (Sint8) * 2) {
   7.442 -        *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f);
   7.443 -        ptr++;
   7.444 -        *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f);
   7.445 -        ptr++;
   7.446 -    }
   7.447 -    else
   7.448 -    for (i = 0; i < len; i += sizeof (Sint8) * 2) {
   7.449 -        *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f);
   7.450 -        ptr++;
   7.451 -        *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f);
   7.452 -        ptr++;
   7.453 -    }
   7.454 -}
   7.455 -static void SDLCALL _Eff_position_s8_c4(int chan, void *stream, int len, void *udata)
   7.456 -{
   7.457 -    volatile position_args *args = (volatile position_args *) udata;
   7.458 -    Sint8 *ptr = (Sint8 *) stream;
   7.459 -    int i;
   7.460 -
   7.461 -    (void)chan;
   7.462 -
   7.463 -    /*
   7.464 -     * if there's only a mono channnel (the only way we wouldn't have
   7.465 -     *  a len divisible by 2 here), then left_f and right_f are always
   7.466 -     *  1.0, and are therefore throwaways.
   7.467 -     */
   7.468 -    if (len % (int)sizeof(Sint16) != 0) {
   7.469 -        *ptr = (Sint8) (((float) *ptr) * args->distance_f);
   7.470 -        ptr++;
   7.471 -        len--;
   7.472 -    }
   7.473 -
   7.474 -    for (i = 0; i < len; i += sizeof (Sint8) * 4) {
   7.475 -      switch (args->room_angle) {
   7.476 -       case 0:
   7.477 -        *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
   7.478 -        *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
   7.479 -        *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
   7.480 -        *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
   7.481 -        break;
   7.482 -       case 90:
   7.483 -        *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
   7.484 -        *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
   7.485 -        *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
   7.486 -        *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
   7.487 -        break;
   7.488 -       case 180:
   7.489 -        *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
   7.490 -        *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
   7.491 -        *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
   7.492 -        *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
   7.493 -        break;
   7.494 -       case 270:
   7.495 -        *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
   7.496 -        *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
   7.497 -        *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
   7.498 -        *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
   7.499 -        break;
   7.500 -      }
   7.501 -    }
   7.502 -}
   7.503 -static void SDLCALL _Eff_position_s8_c6(int chan, void *stream, int len, void *udata)
   7.504 -{
   7.505 -    volatile position_args *args = (volatile position_args *) udata;
   7.506 -    Sint8 *ptr = (Sint8 *) stream;
   7.507 -    int i;
   7.508 -
   7.509 -    (void)chan;
   7.510 -
   7.511 -    /*
   7.512 -     * if there's only a mono channnel (the only way we wouldn't have
   7.513 -     *  a len divisible by 2 here), then left_f and right_f are always
   7.514 -     *  1.0, and are therefore throwaways.
   7.515 -     */
   7.516 -    if (len % (int)sizeof(Sint16) != 0) {
   7.517 -        *ptr = (Sint8) (((float) *ptr) * args->distance_f);
   7.518 -        ptr++;
   7.519 -        len--;
   7.520 -    }
   7.521 -
   7.522 -    for (i = 0; i < len; i += sizeof (Sint8) * 6) {
   7.523 -      switch (args->room_angle) {
   7.524 -       case 0:
   7.525 -        *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
   7.526 -        *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
   7.527 -        *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
   7.528 -        *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
   7.529 -        *ptr = (Sint8)((((float) *ptr) * args->center_f) * args->distance_f); ptr++;
   7.530 -        *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
   7.531 -        break;
   7.532 -       case 90:
   7.533 -        *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
   7.534 -        *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
   7.535 -        *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
   7.536 -        *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
   7.537 -        *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f / 2)
   7.538 -           + (Sint8)((((float) *ptr) * args->right_f) * args->distance_f / 2); ptr++;
   7.539 -        *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
   7.540 -        break;
   7.541 -       case 180:
   7.542 -        *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
   7.543 -        *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
   7.544 -        *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
   7.545 -        *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
   7.546 -        *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f / 2)
   7.547 -           + (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f / 2); ptr++;
   7.548 -        *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
   7.549 -        break;
   7.550 -       case 270:
   7.551 -        *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
   7.552 -        *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
   7.553 -        *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
   7.554 -        *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
   7.555 -        *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f / 2)
   7.556 -           + (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f / 2); ptr++;
   7.557 -        *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
   7.558 -        break;
   7.559 -      }
   7.560 -    }
   7.561 -}
   7.562 -
   7.563 -
   7.564 -/*
   7.565 - * This one runs about 10.1 times faster than the non-table version, with
   7.566 - *  no loss in quality. It does, however, require 64k of memory for the
   7.567 - *  lookup table. Also, this will only update position information once per
   7.568 - *  call; the non-table version always checks the arguments for each sample,
   7.569 - *  in case the user has called Mix_SetPanning() or whatnot again while this
   7.570 - *  callback is running.
   7.571 - */
   7.572 -static void SDLCALL _Eff_position_table_s8(int chan, void *stream, int len, void *udata)
   7.573 -{
   7.574 -    volatile position_args *args = (volatile position_args *) udata;
   7.575 -    Sint8 *ptr = (Sint8 *) stream;
   7.576 -    Uint32 *p;
   7.577 -    int i;
   7.578 -    Sint8 *l = ((Sint8 *) _Eff_volume_table) + (256 * args->left_u8);
   7.579 -    Sint8 *r = ((Sint8 *) _Eff_volume_table) + (256 * args->right_u8);
   7.580 -    Sint8 *d = ((Sint8 *) _Eff_volume_table) + (256 * args->distance_u8);
   7.581 -
   7.582 -    (void)chan;
   7.583 -
   7.584 -    if (args->room_angle == 180) {
   7.585 -        Sint8 *temp = l;
   7.586 -        l = r;
   7.587 -        r = temp;
   7.588 -    }
   7.589 -
   7.590 -    while (len % (int)sizeof(Uint32) != 0) {
   7.591 -        *ptr = d[l[*ptr]];
   7.592 -        ptr++;
   7.593 -        if (args->channels > 1) {
   7.594 -            *ptr = d[r[*ptr]];
   7.595 -            ptr++;
   7.596 -        }
   7.597 -        len -= args->channels;
   7.598 -    }
   7.599 -
   7.600 -    p = (Uint32 *) ptr;
   7.601 -
   7.602 -    for (i = 0; i < len; i += sizeof (Uint32)) {
   7.603 -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
   7.604 -        *p = (d[l[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) |
   7.605 -             (d[r[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) |
   7.606 -             (d[l[((Sint16)(Sint8)((*p & 0x0000FF00) >>  8))+128]] <<  8) |
   7.607 -             (d[r[((Sint16)(Sint8)((*p & 0x000000FF)     ))+128]]     ) ;
   7.608 -#else
   7.609 -        *p = (d[r[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) |
   7.610 -             (d[l[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) |
   7.611 -             (d[r[((Sint16)(Sint8)((*p & 0x0000FF00) >>  8))+128]] <<  8) |
   7.612 -             (d[l[((Sint16)(Sint8)((*p & 0x000000FF)     ))+128]]     ) ;
   7.613 -#endif
   7.614 -        ++p;
   7.615 -    }
   7.616 -}
   7.617 -
   7.618 -
   7.619 -/* !!! FIXME : Optimize the code for 16-bit samples? */
   7.620 -
   7.621 -static void SDLCALL _Eff_position_u16lsb(int chan, void *stream, int len, void *udata)
   7.622 -{
   7.623 -    volatile position_args *args = (volatile position_args *) udata;
   7.624 -    Uint16 *ptr = (Uint16 *) stream;
   7.625 -    int i;
   7.626 -
   7.627 -    (void)chan;
   7.628 -
   7.629 -    for (i = 0; i < len; i += sizeof (Uint16) * 2) {
   7.630 -        Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
   7.631 -        Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
   7.632 -
   7.633 -        Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
   7.634 -                                    * args->distance_f) + 32768);
   7.635 -        Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
   7.636 -                                    * args->distance_f) + 32768);
   7.637 -
   7.638 -        if (args->room_angle == 180) {
   7.639 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
   7.640 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
   7.641 -        }
   7.642 -        else {
   7.643 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
   7.644 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
   7.645 -        }
   7.646 -    }
   7.647 -}
   7.648 -static void SDLCALL _Eff_position_u16lsb_c4(int chan, void *stream, int len, void *udata)
   7.649 -{
   7.650 -    volatile position_args *args = (volatile position_args *) udata;
   7.651 -    Uint16 *ptr = (Uint16 *) stream;
   7.652 -    int i;
   7.653 -
   7.654 -    (void)chan;
   7.655 -
   7.656 -    for (i = 0; i < len; i += sizeof (Uint16) * 4) {
   7.657 -        Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
   7.658 -        Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
   7.659 -        Sint16 samplr = (Sint16) (SDL_SwapLE16(*(ptr+2)) - 32768);
   7.660 -        Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768);
   7.661 -
   7.662 -        Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
   7.663 -                                    * args->distance_f) + 32768);
   7.664 -        Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
   7.665 -                                    * args->distance_f) + 32768);
   7.666 -        Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
   7.667 -                                    * args->distance_f) + 32768);
   7.668 -        Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
   7.669 -                                    * args->distance_f) + 32768);
   7.670 -
   7.671 -        switch (args->room_angle) {
   7.672 -        case 0:
   7.673 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
   7.674 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
   7.675 -            *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
   7.676 -            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
   7.677 -            break;
   7.678 -        case 90:
   7.679 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
   7.680 -            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
   7.681 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
   7.682 -            *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
   7.683 -            break;
   7.684 -        case 180:
   7.685 -            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
   7.686 -            *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
   7.687 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
   7.688 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
   7.689 -            break;
   7.690 -        case 270:
   7.691 -            *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
   7.692 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
   7.693 -            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
   7.694 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
   7.695 -            break;
   7.696 -        }
   7.697 -    }
   7.698 -}
   7.699 -static void SDLCALL _Eff_position_u16lsb_c6(int chan, void *stream, int len, void *udata)
   7.700 -{
   7.701 -    volatile position_args *args = (volatile position_args *) udata;
   7.702 -    Uint16 *ptr = (Uint16 *) stream;
   7.703 -    int i;
   7.704 -
   7.705 -    (void)chan;
   7.706 -
   7.707 -    for (i = 0; i < len; i += sizeof (Uint16) * 6) {
   7.708 -        Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
   7.709 -        Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
   7.710 -        Sint16 samplr = (Sint16) (SDL_SwapLE16(*(ptr+2)) - 32768);
   7.711 -        Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768);
   7.712 -        Sint16 sampce = (Sint16) (SDL_SwapLE16(*(ptr+4)) - 32768);
   7.713 -        Sint16 sampwf = (Sint16) (SDL_SwapLE16(*(ptr+5)) - 32768);
   7.714 -
   7.715 -        Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
   7.716 -                                    * args->distance_f) + 32768);
   7.717 -        Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
   7.718 -                                    * args->distance_f) + 32768);
   7.719 -        Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
   7.720 -                                    * args->distance_f) + 32768);
   7.721 -        Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
   7.722 -                                    * args->distance_f) + 32768);
   7.723 -        Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f)
   7.724 -                                    * args->distance_f) + 32768);
   7.725 -        Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f)
   7.726 -                                    * args->distance_f) + 32768);
   7.727 -
   7.728 -        switch (args->room_angle) {
   7.729 -        case 0:
   7.730 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
   7.731 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
   7.732 -            *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
   7.733 -            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
   7.734 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapce);
   7.735 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
   7.736 -            break;
   7.737 -        case 90:
   7.738 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
   7.739 -            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
   7.740 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
   7.741 -            *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
   7.742 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapr)/2 + (Uint16) SDL_SwapLE16(swaprr)/2;
   7.743 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
   7.744 -            break;
   7.745 -        case 180:
   7.746 -            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
   7.747 -            *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
   7.748 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
   7.749 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
   7.750 -            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr)/2 + (Uint16) SDL_SwapLE16(swaplr)/2;
   7.751 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
   7.752 -            break;
   7.753 -        case 270:
   7.754 -            *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
   7.755 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
   7.756 -            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
   7.757 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
   7.758 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapl)/2 + (Uint16) SDL_SwapLE16(swaplr)/2;
   7.759 -            *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
   7.760 -            break;
   7.761 -        }
   7.762 -    }
   7.763 -}
   7.764 -
   7.765 -static void SDLCALL _Eff_position_s16lsb(int chan, void *stream, int len, void *udata)
   7.766 -{
   7.767 -    /* 16 signed bits (lsb) * 2 channels. */
   7.768 -    volatile position_args *args = (volatile position_args *) udata;
   7.769 -    Sint16 *ptr = (Sint16 *) stream;
   7.770 -    int i;
   7.771 -
   7.772 -    (void)chan;
   7.773 -
   7.774 -#if 0
   7.775 -    if (len % (int)(sizeof(Sint16) * 2)) {
   7.776 -        fprintf(stderr,"Not an even number of frames! len=%d\n", len);
   7.777 -        return;
   7.778 -    }
   7.779 -#endif
   7.780 -
   7.781 -    for (i = 0; i < len; i += sizeof (Sint16) * 2) {
   7.782 -        Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *
   7.783 -                                    args->left_f) * args->distance_f);
   7.784 -        Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
   7.785 -                                    args->right_f) * args->distance_f);
   7.786 -        if (args->room_angle == 180) {
   7.787 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
   7.788 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
   7.789 -        }
   7.790 -        else {
   7.791 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
   7.792 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
   7.793 -        }
   7.794 -    }
   7.795 -}
   7.796 -static void SDLCALL _Eff_position_s16lsb_c4(int chan, void *stream, int len, void *udata)
   7.797 -{
   7.798 -    /* 16 signed bits (lsb) * 4 channels. */
   7.799 -    volatile position_args *args = (volatile position_args *) udata;
   7.800 -    Sint16 *ptr = (Sint16 *) stream;
   7.801 -    int i;
   7.802 -
   7.803 -    (void)chan;
   7.804 -
   7.805 -    for (i = 0; i < len; i += sizeof (Sint16) * 4) {
   7.806 -        Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *
   7.807 -                                    args->left_f) * args->distance_f);
   7.808 -        Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
   7.809 -                                    args->right_f) * args->distance_f);
   7.810 -        Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
   7.811 -                                    args->left_rear_f) * args->distance_f);
   7.812 -        Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+2))) *
   7.813 -                                    args->right_rear_f) * args->distance_f);
   7.814 -        switch (args->room_angle) {
   7.815 -        case 0:
   7.816 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
   7.817 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
   7.818 -            *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
   7.819 -            *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
   7.820 -            break;
   7.821 -        case 90:
   7.822 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
   7.823 -            *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
   7.824 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
   7.825 -            *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
   7.826 -            break;
   7.827 -        case 180:
   7.828 -            *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
   7.829 -            *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
   7.830 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
   7.831 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
   7.832 -            break;
   7.833 -        case 270:
   7.834 -            *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
   7.835 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
   7.836 -            *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
   7.837 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
   7.838 -            break;
   7.839 -        }
   7.840 -    }
   7.841 -}
   7.842 -
   7.843 -static void SDLCALL _Eff_position_s16lsb_c6(int chan, void *stream, int len, void *udata)
   7.844 -{
   7.845 -    /* 16 signed bits (lsb) * 6 channels. */
   7.846 -    volatile position_args *args = (volatile position_args *) udata;
   7.847 -    Sint16 *ptr = (Sint16 *) stream;
   7.848 -    int i;
   7.849 -
   7.850 -    (void)chan;
   7.851 -
   7.852 -    for (i = 0; i < len; i += sizeof (Sint16) * 6) {
   7.853 -        Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *
   7.854 -                                    args->left_f) * args->distance_f);
   7.855 -        Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
   7.856 -                                    args->right_f) * args->distance_f);
   7.857 -        Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+2))) *
   7.858 -                                    args->left_rear_f) * args->distance_f);
   7.859 -        Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+3))) *
   7.860 -                                    args->right_rear_f) * args->distance_f);
   7.861 -        Sint16 swapce = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+4))) *
   7.862 -                                    args->center_f) * args->distance_f);
   7.863 -        Sint16 swapwf = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+5))) *
   7.864 -                                    args->lfe_f) * args->distance_f);
   7.865 -        switch (args->room_angle) {
   7.866 -        case 0:
   7.867 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
   7.868 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
   7.869 -            *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
   7.870 -            *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
   7.871 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapce);
   7.872 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
   7.873 -            break;
   7.874 -        case 90:
   7.875 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
   7.876 -            *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
   7.877 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
   7.878 -            *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
   7.879 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapr)/2 + (Sint16) SDL_SwapLE16(swaprr)/2;
   7.880 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
   7.881 -            break;
   7.882 -        case 180:
   7.883 -            *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
   7.884 -            *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
   7.885 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
   7.886 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
   7.887 -            *(ptr++) = (Sint16) SDL_SwapLE16(swaprr)/2 + (Sint16) SDL_SwapLE16(swaplr)/2;
   7.888 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
   7.889 -            break;
   7.890 -        case 270:
   7.891 -            *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
   7.892 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
   7.893 -            *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
   7.894 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
   7.895 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapl)/2 + (Sint16) SDL_SwapLE16(swaplr)/2;
   7.896 -            *(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
   7.897 -            break;
   7.898 -        }
   7.899 -    }
   7.900 -}
   7.901 -
   7.902 -static void SDLCALL _Eff_position_u16msb(int chan, void *stream, int len, void *udata)
   7.903 -{
   7.904 -    /* 16 signed bits (lsb) * 2 channels. */
   7.905 -    volatile position_args *args = (volatile position_args *) udata;
   7.906 -    Uint16 *ptr = (Uint16 *) stream;
   7.907 -    int i;
   7.908 -
   7.909 -    (void)chan;
   7.910 -
   7.911 -    for (i = 0; i < len; i += sizeof (Sint16) * 2) {
   7.912 -        Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
   7.913 -        Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
   7.914 -
   7.915 -        Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
   7.916 -                                    * args->distance_f) + 32768);
   7.917 -        Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
   7.918 -                                    * args->distance_f) + 32768);
   7.919 -
   7.920 -        if (args->room_angle == 180) {
   7.921 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
   7.922 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
   7.923 -        }
   7.924 -        else {
   7.925 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
   7.926 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
   7.927 -        }
   7.928 -    }
   7.929 -}
   7.930 -
   7.931 -static void SDLCALL _Eff_position_u16msb_c4(int chan, void *stream, int len, void *udata)
   7.932 -{
   7.933 -    /* 16 signed bits (lsb) * 4 channels. */
   7.934 -    volatile position_args *args = (volatile position_args *) udata;
   7.935 -    Uint16 *ptr = (Uint16 *) stream;
   7.936 -    int i;
   7.937 -
   7.938 -    (void)chan;
   7.939 -
   7.940 -    for (i = 0; i < len; i += sizeof (Sint16) * 4) {
   7.941 -        Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
   7.942 -        Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
   7.943 -        Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768);
   7.944 -        Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768);
   7.945 -
   7.946 -        Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
   7.947 -                                    * args->distance_f) + 32768);
   7.948 -        Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
   7.949 -                                    * args->distance_f) + 32768);
   7.950 -        Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
   7.951 -                                    * args->distance_f) + 32768);
   7.952 -        Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
   7.953 -                                    * args->distance_f) + 32768);
   7.954 -
   7.955 -        switch (args->room_angle) {
   7.956 -        case 0:
   7.957 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
   7.958 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
   7.959 -            *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
   7.960 -            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
   7.961 -            break;
   7.962 -        case 90:
   7.963 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
   7.964 -            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
   7.965 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
   7.966 -            *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
   7.967 -            break;
   7.968 -        case 180:
   7.969 -            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
   7.970 -            *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
   7.971 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
   7.972 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
   7.973 -            break;
   7.974 -        case 270:
   7.975 -            *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
   7.976 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
   7.977 -            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
   7.978 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
   7.979 -            break;
   7.980 -        }
   7.981 -    }
   7.982 -}
   7.983 -
   7.984 -static void SDLCALL _Eff_position_u16msb_c6(int chan, void *stream, int len, void *udata)
   7.985 -{
   7.986 -    /* 16 signed bits (lsb) * 6 channels. */
   7.987 -    volatile position_args *args = (volatile position_args *) udata;
   7.988 -    Uint16 *ptr = (Uint16 *) stream;
   7.989 -    int i;
   7.990 -
   7.991 -    (void)chan;
   7.992 -
   7.993 -    for (i = 0; i < len; i += sizeof (Sint16) * 6) {
   7.994 -        Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
   7.995 -        Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
   7.996 -        Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768);
   7.997 -        Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768);
   7.998 -        Sint16 sampce = (Sint16) (SDL_SwapBE16(*(ptr+4)) - 32768);
   7.999 -        Sint16 sampwf = (Sint16) (SDL_SwapBE16(*(ptr+5)) - 32768);
  7.1000 -
  7.1001 -        Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
  7.1002 -                                    * args->distance_f) + 32768);
  7.1003 -        Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
  7.1004 -                                    * args->distance_f) + 32768);
  7.1005 -        Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
  7.1006 -                                    * args->distance_f) + 32768);
  7.1007 -        Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
  7.1008 -                                    * args->distance_f) + 32768);
  7.1009 -        Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f)
  7.1010 -                                    * args->distance_f) + 32768);
  7.1011 -        Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f)
  7.1012 -                                    * args->distance_f) + 32768);
  7.1013 -
  7.1014 -        switch (args->room_angle) {
  7.1015 -        case 0:
  7.1016 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
  7.1017 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
  7.1018 -            *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
  7.1019 -            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
  7.1020 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapce);
  7.1021 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
  7.1022 -            break;
  7.1023 -        case 90:
  7.1024 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
  7.1025 -            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
  7.1026 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
  7.1027 -            *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
  7.1028 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapr)/2 + (Uint16) SDL_SwapBE16(swaprr)/2;
  7.1029 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
  7.1030 -            break;
  7.1031 -        case 180:
  7.1032 -            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
  7.1033 -            *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
  7.1034 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
  7.1035 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
  7.1036 -            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr)/2 + (Uint16) SDL_SwapBE16(swaplr)/2;
  7.1037 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
  7.1038 -            break;
  7.1039 -        case 270:
  7.1040 -            *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
  7.1041 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
  7.1042 -            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
  7.1043 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
  7.1044 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapl)/2 + (Uint16) SDL_SwapBE16(swaplr)/2;
  7.1045 -            *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
  7.1046 -            break;
  7.1047 -        }
  7.1048 -    }
  7.1049 -}
  7.1050 -
  7.1051 -static void SDLCALL _Eff_position_s16msb(int chan, void *stream, int len, void *udata)
  7.1052 -{
  7.1053 -    /* 16 signed bits (lsb) * 2 channels. */
  7.1054 -    volatile position_args *args = (volatile position_args *) udata;
  7.1055 -    Sint16 *ptr = (Sint16 *) stream;
  7.1056 -    int i;
  7.1057 -
  7.1058 -    (void)chan;
  7.1059 -
  7.1060 -    for (i = 0; i < len; i += sizeof (Sint16) * 2) {
  7.1061 -        Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) *
  7.1062 -                                    args->left_f) * args->distance_f);
  7.1063 -        Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) *
  7.1064 -                                    args->right_f) * args->distance_f);
  7.1065 -        *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
  7.1066 -        *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
  7.1067 -    }
  7.1068 -}
  7.1069 -static void SDLCALL _Eff_position_s16msb_c4(int chan, void *stream, int len, void *udata)
  7.1070 -{
  7.1071 -    /* 16 signed bits (lsb) * 4 channels. */
  7.1072 -    volatile position_args *args = (volatile position_args *) udata;
  7.1073 -    Sint16 *ptr = (Sint16 *) stream;
  7.1074 -    int i;
  7.1075 -
  7.1076 -    (void)chan;
  7.1077 -
  7.1078 -    for (i = 0; i < len; i += sizeof (Sint16) * 4) {
  7.1079 -        Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) *
  7.1080 -                                    args->left_f) * args->distance_f);
  7.1081 -        Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) *
  7.1082 -                                    args->right_f) * args->distance_f);
  7.1083 -        Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+2))) *
  7.1084 -                                    args->left_rear_f) * args->distance_f);
  7.1085 -        Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+3))) *
  7.1086 -                                    args->right_rear_f) * args->distance_f);
  7.1087 -        switch (args->room_angle) {
  7.1088 -        case 0:
  7.1089 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
  7.1090 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
  7.1091 -            *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
  7.1092 -            *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
  7.1093 -            break;
  7.1094 -        case 90:
  7.1095 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
  7.1096 -            *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
  7.1097 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
  7.1098 -            *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
  7.1099 -            break;
  7.1100 -        case 180:
  7.1101 -            *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
  7.1102 -            *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
  7.1103 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
  7.1104 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
  7.1105 -            break;
  7.1106 -        case 270:
  7.1107 -            *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
  7.1108 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
  7.1109 -            *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
  7.1110 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
  7.1111 -            break;
  7.1112 -        }
  7.1113 -    }
  7.1114 -}
  7.1115 -static void SDLCALL _Eff_position_s16msb_c6(int chan, void *stream, int len, void *udata)
  7.1116 -{
  7.1117 -    /* 16 signed bits (lsb) * 6 channels. */
  7.1118 -    volatile position_args *args = (volatile position_args *) udata;
  7.1119 -    Sint16 *ptr = (Sint16 *) stream;
  7.1120 -    int i;
  7.1121 -
  7.1122 -    (void)chan;
  7.1123 -
  7.1124 -    for (i = 0; i < len; i += sizeof (Sint16) * 6) {
  7.1125 -        Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) *
  7.1126 -                                    args->left_f) * args->distance_f);
  7.1127 -        Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) *
  7.1128 -                                    args->right_f) * args->distance_f);
  7.1129 -        Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+2))) *
  7.1130 -                                    args->left_rear_f) * args->distance_f);
  7.1131 -        Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+3))) *
  7.1132 -                                    args->right_rear_f) * args->distance_f);
  7.1133 -        Sint16 swapce = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+4))) *
  7.1134 -                                    args->center_f) * args->distance_f);
  7.1135 -        Sint16 swapwf = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+5))) *
  7.1136 -                                    args->lfe_f) * args->distance_f);
  7.1137 -
  7.1138 -        switch (args->room_angle) {
  7.1139 -        case 0:
  7.1140 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
  7.1141 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
  7.1142 -            *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
  7.1143 -            *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
  7.1144 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapce);
  7.1145 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapwf);
  7.1146 -            break;
  7.1147 -        case 90:
  7.1148 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
  7.1149 -            *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
  7.1150 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
  7.1151 -            *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
  7.1152 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapr)/2 + (Sint16) SDL_SwapBE16(swaprr)/2;
  7.1153 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapwf);
  7.1154 -            break;
  7.1155 -        case 180:
  7.1156 -            *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
  7.1157 -            *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
  7.1158 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
  7.1159 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
  7.1160 -            *(ptr++) = (Sint16) SDL_SwapBE16(swaprr)/2 + (Sint16) SDL_SwapBE16(swaplr)/2;
  7.1161 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapwf);
  7.1162 -            break;
  7.1163 -        case 270:
  7.1164 -            *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
  7.1165 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
  7.1166 -            *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
  7.1167 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
  7.1168 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapl)/2 + (Sint16) SDL_SwapBE16(swaplr)/2;
  7.1169 -            *(ptr++) = (Sint16) SDL_SwapBE16(swapwf);
  7.1170 -            break;
  7.1171 -        }
  7.1172 -    }
  7.1173 -}
  7.1174 -
  7.1175 -static void SDLCALL _Eff_position_s32lsb(int chan, void *stream, int len, void *udata)
  7.1176 -{
  7.1177 -    /* 32 signed bits (lsb) * 2 channels. */
  7.1178 -    volatile position_args *args = (volatile position_args *) udata;
  7.1179 -    Sint32 *ptr = (Sint32 *) stream;
  7.1180 -    int i;
  7.1181 -
  7.1182 -    (void)chan;
  7.1183 -
  7.1184 -#if 0
  7.1185 -    if (len % (int)(sizeof(Sint32) * 2)) {
  7.1186 -        fprintf(stderr,"Not an even number of frames! len=%d\n", len);
  7.1187 -        return;
  7.1188 -    }
  7.1189 -#endif
  7.1190 -
  7.1191 -    for (i = 0; i < len; i += sizeof (Sint32) * 2) {
  7.1192 -        Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) *
  7.1193 -                                    args->left_f) * args->distance_f);
  7.1194 -        Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) *
  7.1195 -                                    args->right_f) * args->distance_f);
  7.1196 -        if (args->room_angle == 180) {
  7.1197 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
  7.1198 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
  7.1199 -        }
  7.1200 -        else {
  7.1201 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
  7.1202 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
  7.1203 -        }
  7.1204 -    }
  7.1205 -}
  7.1206 -static void SDLCALL _Eff_position_s32lsb_c4(int chan, void *stream, int len, void *udata)
  7.1207 -{
  7.1208 -    /* 32 signed bits (lsb) * 4 channels. */
  7.1209 -    volatile position_args *args = (volatile position_args *) udata;
  7.1210 -    Sint32 *ptr = (Sint32 *) stream;
  7.1211 -    int i;
  7.1212 -
  7.1213 -    (void)chan;
  7.1214 -
  7.1215 -    for (i = 0; i < len; i += sizeof (Sint32) * 4) {
  7.1216 -        Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) *
  7.1217 -                                    args->left_f) * args->distance_f);
  7.1218 -        Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) *
  7.1219 -                                    args->right_f) * args->distance_f);
  7.1220 -        Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) *
  7.1221 -                                    args->left_rear_f) * args->distance_f);
  7.1222 -        Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+2))) *
  7.1223 -                                    args->right_rear_f) * args->distance_f);
  7.1224 -        switch (args->room_angle) {
  7.1225 -        case 0:
  7.1226 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
  7.1227 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
  7.1228 -            *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
  7.1229 -            *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
  7.1230 -            break;
  7.1231 -        case 90:
  7.1232 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
  7.1233 -            *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
  7.1234 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
  7.1235 -            *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
  7.1236 -            break;
  7.1237 -        case 180:
  7.1238 -            *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
  7.1239 -            *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
  7.1240 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
  7.1241 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
  7.1242 -            break;
  7.1243 -        case 270:
  7.1244 -            *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
  7.1245 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
  7.1246 -            *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
  7.1247 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
  7.1248 -            break;
  7.1249 -        }
  7.1250 -    }
  7.1251 -}
  7.1252 -
  7.1253 -static void SDLCALL _Eff_position_s32lsb_c6(int chan, void *stream, int len, void *udata)
  7.1254 -{
  7.1255 -    /* 32 signed bits (lsb) * 6 channels. */
  7.1256 -    volatile position_args *args = (volatile position_args *) udata;
  7.1257 -    Sint32 *ptr = (Sint32 *) stream;
  7.1258 -    int i;
  7.1259 -
  7.1260 -    (void)chan;
  7.1261 -
  7.1262 -    for (i = 0; i < len; i += sizeof (Sint32) * 6) {
  7.1263 -        Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) *
  7.1264 -                                    args->left_f) * args->distance_f);
  7.1265 -        Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) *
  7.1266 -                                    args->right_f) * args->distance_f);
  7.1267 -        Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+2))) *
  7.1268 -                                    args->left_rear_f) * args->distance_f);
  7.1269 -        Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+3))) *
  7.1270 -                                    args->right_rear_f) * args->distance_f);
  7.1271 -        Sint32 swapce = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+4))) *
  7.1272 -                                    args->center_f) * args->distance_f);
  7.1273 -        Sint32 swapwf = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+5))) *
  7.1274 -                                    args->lfe_f) * args->distance_f);
  7.1275 -        switch (args->room_angle) {
  7.1276 -        case 0:
  7.1277 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
  7.1278 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
  7.1279 -            *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
  7.1280 -            *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
  7.1281 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapce);
  7.1282 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapwf);
  7.1283 -            break;
  7.1284 -        case 90:
  7.1285 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
  7.1286 -            *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
  7.1287 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
  7.1288 -            *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
  7.1289 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapr)/2 + (Sint32) SDL_SwapLE32(swaprr)/2;
  7.1290 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapwf);
  7.1291 -            break;
  7.1292 -        case 180:
  7.1293 -            *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
  7.1294 -            *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
  7.1295 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
  7.1296 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
  7.1297 -            *(ptr++) = (Sint32) SDL_SwapLE32(swaprr)/2 + (Sint32) SDL_SwapLE32(swaplr)/2;
  7.1298 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapwf);
  7.1299 -            break;
  7.1300 -        case 270:
  7.1301 -            *(ptr++) = (Sint32) SDL_SwapLE32(swaplr);
  7.1302 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapl);
  7.1303 -            *(ptr++) = (Sint32) SDL_SwapLE32(swaprr);
  7.1304 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapr);
  7.1305 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapl)/2 + (Sint32) SDL_SwapLE32(swaplr)/2;
  7.1306 -            *(ptr++) = (Sint32) SDL_SwapLE32(swapwf);
  7.1307 -            break;
  7.1308 -        }
  7.1309 -    }
  7.1310 -}
  7.1311 -
  7.1312 -static void SDLCALL _Eff_position_s32msb(int chan, void *stream, int len, void *udata)
  7.1313 -{
  7.1314 -    /* 32 signed bits (lsb) * 2 channels. */
  7.1315 -    volatile position_args *args = (volatile position_args *) udata;
  7.1316 -    Sint32 *ptr = (Sint32 *) stream;
  7.1317 -    int i;
  7.1318 -
  7.1319 -    (void)chan;
  7.1320 -
  7.1321 -    for (i = 0; i < len; i += sizeof (Sint32) * 2) {
  7.1322 -        Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) *
  7.1323 -                                    args->left_f) * args->distance_f);
  7.1324 -        Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) *
  7.1325 -                                    args->right_f) * args->distance_f);
  7.1326 -        *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
  7.1327 -        *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
  7.1328 -    }
  7.1329 -}
  7.1330 -static void SDLCALL _Eff_position_s32msb_c4(int chan, void *stream, int len, void *udata)
  7.1331 -{
  7.1332 -    /* 32 signed bits (lsb) * 4 channels. */
  7.1333 -    volatile position_args *args = (volatile position_args *) udata;
  7.1334 -    Sint32 *ptr = (Sint32 *) stream;
  7.1335 -    int i;
  7.1336 -
  7.1337 -    (void)chan;
  7.1338 -
  7.1339 -    for (i = 0; i < len; i += sizeof (Sint32) * 4) {
  7.1340 -        Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) *
  7.1341 -                                    args->left_f) * args->distance_f);
  7.1342 -        Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) *
  7.1343 -                                    args->right_f) * args->distance_f);
  7.1344 -        Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+2))) *
  7.1345 -                                    args->left_rear_f) * args->distance_f);
  7.1346 -        Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+3))) *
  7.1347 -                                    args->right_rear_f) * args->distance_f);
  7.1348 -        switch (args->room_angle) {
  7.1349 -        case 0:
  7.1350 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
  7.1351 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
  7.1352 -            *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
  7.1353 -            *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
  7.1354 -            break;
  7.1355 -        case 90:
  7.1356 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
  7.1357 -            *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
  7.1358 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
  7.1359 -            *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
  7.1360 -            break;
  7.1361 -        case 180:
  7.1362 -            *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
  7.1363 -            *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
  7.1364 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
  7.1365 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
  7.1366 -            break;
  7.1367 -        case 270:
  7.1368 -            *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
  7.1369 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
  7.1370 -            *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
  7.1371 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
  7.1372 -            break;
  7.1373 -        }
  7.1374 -    }
  7.1375 -}
  7.1376 -static void SDLCALL _Eff_position_s32msb_c6(int chan, void *stream, int len, void *udata)
  7.1377 -{
  7.1378 -    /* 32 signed bits (lsb) * 6 channels. */
  7.1379 -    volatile position_args *args = (volatile position_args *) udata;
  7.1380 -    Sint32 *ptr = (Sint32 *) stream;
  7.1381 -    int i;
  7.1382 -
  7.1383 -    (void)chan;
  7.1384 -
  7.1385 -    for (i = 0; i < len; i += sizeof (Sint32) * 6) {
  7.1386 -        Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) *
  7.1387 -                                    args->left_f) * args->distance_f);
  7.1388 -        Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) *
  7.1389 -                                    args->right_f) * args->distance_f);
  7.1390 -        Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+2))) *
  7.1391 -                                    args->left_rear_f) * args->distance_f);
  7.1392 -        Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+3))) *
  7.1393 -                                    args->right_rear_f) * args->distance_f);
  7.1394 -        Sint32 swapce = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+4))) *
  7.1395 -                                    args->center_f) * args->distance_f);
  7.1396 -        Sint32 swapwf = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+5))) *
  7.1397 -                                    args->lfe_f) * args->distance_f);
  7.1398 -
  7.1399 -        switch (args->room_angle) {
  7.1400 -        case 0:
  7.1401 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
  7.1402 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
  7.1403 -            *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
  7.1404 -            *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
  7.1405 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapce);
  7.1406 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapwf);
  7.1407 -            break;
  7.1408 -        case 90:
  7.1409 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
  7.1410 -            *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
  7.1411 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
  7.1412 -            *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
  7.1413 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapr)/2 + (Sint32) SDL_SwapBE32(swaprr)/2;
  7.1414 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapwf);
  7.1415 -            break;
  7.1416 -        case 180:
  7.1417 -            *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
  7.1418 -            *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
  7.1419 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
  7.1420 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
  7.1421 -            *(ptr++) = (Sint32) SDL_SwapBE32(swaprr)/2 + (Sint32) SDL_SwapBE32(swaplr)/2;
  7.1422 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapwf);
  7.1423 -            break;
  7.1424 -        case 270:
  7.1425 -            *(ptr++) = (Sint32) SDL_SwapBE32(swaplr);
  7.1426 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapl);
  7.1427 -            *(ptr++) = (Sint32) SDL_SwapBE32(swaprr);
  7.1428 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapr);
  7.1429 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapl)/2 + (Sint32) SDL_SwapBE32(swaplr)/2;
  7.1430 -            *(ptr++) = (Sint32) SDL_SwapBE32(swapwf);
  7.1431 -            break;
  7.1432 -        }
  7.1433 -    }
  7.1434 -}
  7.1435 -
  7.1436 -static void SDLCALL _Eff_position_f32sys(int chan, void *stream, int len, void *udata)
  7.1437 -{
  7.1438 -    /* float * 2 channels. */
  7.1439 -    volatile position_args *args = (volatile position_args *) udata;
  7.1440 -    float *ptr = (float *) stream;
  7.1441 -    int i;
  7.1442 -
  7.1443 -    (void)chan;
  7.1444 -
  7.1445 -    for (i = 0; i < len; i += sizeof (float) * 2) {
  7.1446 -        float swapl = ((*(ptr+0) * args->left_f) * args->distance_f);
  7.1447 -        float swapr = ((*(ptr+1) * args->right_f) * args->distance_f);
  7.1448 -        *(ptr++) = swapl;
  7.1449 -        *(ptr++) = swapr;
  7.1450 -    }
  7.1451 -}
  7.1452 -static void SDLCALL _Eff_position_f32sys_c4(int chan, void *stream, int len, void *udata)
  7.1453 -{
  7.1454 -    /* float * 4 channels. */
  7.1455 -    volatile position_args *args = (volatile position_args *) udata;
  7.1456 -    float *ptr = (float *) stream;
  7.1457 -    int i;
  7.1458 -
  7.1459 -    (void)chan;
  7.1460 -
  7.1461 -    for (i = 0; i < len; i += sizeof (float) * 4) {
  7.1462 -        float swapl = ((*(ptr+0) * args->left_f) * args->distance_f);
  7.1463 -        float swapr = ((*(ptr+1) * args->right_f) * args->distance_f);
  7.1464 -        float swaplr = ((*(ptr+2) * args->left_rear_f) * args->distance_f);
  7.1465 -        float swaprr = ((*(ptr+3) * args->right_rear_f) * args->distance_f);
  7.1466 -        switch (args->room_angle) {
  7.1467 -        case 0:
  7.1468 -            *(ptr++) = swapl;
  7.1469 -            *(ptr++) = swapr;
  7.1470 -            *(ptr++) = swaplr;
  7.1471 -            *(ptr++) = swaprr;
  7.1472 -            break;
  7.1473 -        case 90:
  7.1474 -            *(ptr++) = swapr;
  7.1475 -            *(ptr++) = swaprr;
  7.1476 -            *(ptr++) = swapl;
  7.1477 -            *(ptr++) = swaplr;
  7.1478 -            break;
  7.1479 -        case 180:
  7.1480 -            *(ptr++) = swaprr;
  7.1481 -            *(ptr++) = swaplr;
  7.1482 -            *(ptr++) = swapr;
  7.1483 -            *(ptr++) = swapl;
  7.1484 -            break;
  7.1485 -        case 270:
  7.1486 -            *(ptr++) = swaplr;
  7.1487 -            *(ptr++) = swapl;
  7.1488 -            *(ptr++) = swaprr;
  7.1489 -            *(ptr++) = swapr;
  7.1490 -            break;
  7.1491 -        }
  7.1492 -    }
  7.1493 -}
  7.1494 -static void SDLCALL _Eff_position_f32sys_c6(int chan, void *stream, int len, void *udata)
  7.1495 -{
  7.1496 -    /* float * 6 channels. */
  7.1497 -    volatile position_args *args = (volatile position_args *) udata;
  7.1498 -    float *ptr = (float *) stream;
  7.1499 -    int i;
  7.1500 -
  7.1501 -    (void)chan;
  7.1502 -
  7.1503 -    for (i = 0; i < len; i += sizeof (float) * 6) {
  7.1504 -        float swapl = ((*(ptr+0) * args->left_f) * args->distance_f);
  7.1505 -        float swapr = ((*(ptr+1) * args->right_f) * args->distance_f);
  7.1506 -        float swaplr = ((*(ptr+2) * args->left_rear_f) * args->distance_f);
  7.1507 -        float swaprr = ((*(ptr+3) * args->right_rear_f) * args->distance_f);
  7.1508 -        float swapce = ((*(ptr+4) * args->center_f) * args->distance_f);
  7.1509 -        float swapwf = ((*(ptr+5) * args->lfe_f) * args->distance_f);
  7.1510 -
  7.1511 -        switch (args->room_angle) {
  7.1512 -        case 0:
  7.1513 -            *(ptr++) = swapl;
  7.1514 -            *(ptr++) = swapr;
  7.1515 -            *(ptr++) = swaplr;
  7.1516 -            *(ptr++) = swaprr;
  7.1517 -            *(ptr++) = swapce;
  7.1518 -            *(ptr++) = swapwf;
  7.1519 -            break;
  7.1520 -        case 90:
  7.1521 -            *(ptr++) = swapr;
  7.1522 -            *(ptr++) = swaprr;
  7.1523 -            *(ptr++) = swapl;
  7.1524 -            *(ptr++) = swaplr;
  7.1525 -            *(ptr++) = swapr/2.0f + swaprr/2.0f;
  7.1526 -            *(ptr++) = swapwf;
  7.1527 -            break;
  7.1528 -        case 180:
  7.1529 -            *(ptr++) = swaprr;
  7.1530 -            *(ptr++) = swaplr;
  7.1531 -            *(ptr++) = swapr;
  7.1532 -            *(ptr++) = swapl;
  7.1533 -            *(ptr++) = swaprr/2.0f + swaplr/2.0f;
  7.1534 -            *(ptr++) = swapwf;
  7.1535 -            break;
  7.1536 -        case 270:
  7.1537 -            *(ptr++) = swaplr;
  7.1538 -            *(ptr++) = swapl;
  7.1539 -            *(ptr++) = swaprr;
  7.1540 -            *(ptr++) = swapr;
  7.1541 -            *(ptr++) = swapl/2.0f + swaplr/2.0f;
  7.1542 -            *(ptr++) = swapwf;
  7.1543 -            break;
  7.1544 -        }
  7.1545 -    }
  7.1546 -}
  7.1547 -
  7.1548 -static void init_position_args(position_args *args)
  7.1549 -{
  7.1550 -    SDL_memset(args, '\0', sizeof (position_args));
  7.1551 -    args->in_use = 0;
  7.1552 -    args->room_angle = 0;
  7.1553 -    args->left_u8 = args->right_u8 = args->distance_u8 = 255;
  7.1554 -    args->left_f  = args->right_f  = args->distance_f  = 1.0f;
  7.1555 -    args->left_rear_u8 = args->right_rear_u8 = args->center_u8 = args->lfe_u8 = 255;
  7.1556 -    args->left_rear_f = args->right_rear_f = args->center_f = args->lfe_f = 1.0f;
  7.1557 -    Mix_QuerySpec(NULL, NULL, (int *) &args->channels);
  7.1558 -}
  7.1559 -
  7.1560 -
  7.1561 -static position_args *get_position_arg(int channel)
  7.1562 -{
  7.1563 -    void *rc;
  7.1564 -    int i;
  7.1565 -
  7.1566 -    if (channel < 0) {
  7.1567 -        if (pos_args_global == NULL) {
  7.1568 -            pos_args_global = SDL_malloc(sizeof (position_args));
  7.1569 -            if (pos_args_global == NULL) {
  7.1570 -                Mix_SetError("Out of memory");
  7.1571 -                return(NULL);
  7.1572 -            }
  7.1573 -            init_position_args(pos_args_global);
  7.1574 -        }
  7.1575 -
  7.1576 -        return(pos_args_global);
  7.1577 -    }
  7.1578 -
  7.1579 -    if (channel >= position_channels) {
  7.1580 -        rc = SDL_realloc(pos_args_array, (size_t)(channel + 1) * sizeof(position_args *));
  7.1581 -        if (rc == NULL) {
  7.1582 -            Mix_SetError("Out of memory");
  7.1583 -            return(NULL);
  7.1584 -        }
  7.1585 -        pos_args_array = (position_args **) rc;
  7.1586 -        for (i = position_channels; i <= channel; i++) {
  7.1587 -            pos_args_array[i] = NULL;
  7.1588 -        }
  7.1589 -        position_channels = channel + 1;
  7.1590 -    }
  7.1591 -
  7.1592 -    if (pos_args_array[channel] == NULL) {
  7.1593 -        pos_args_array[channel] = (position_args *)SDL_malloc(sizeof(position_args));
  7.1594 -        if (pos_args_array[channel] == NULL) {
  7.1595 -            Mix_SetError("Out of memory");
  7.1596 -            return(NULL);
  7.1597 -        }
  7.1598 -        init_position_args(pos_args_array[channel]);
  7.1599 -    }
  7.1600 -
  7.1601 -    return(pos_args_array[channel]);
  7.1602 -}
  7.1603 -
  7.1604 -
  7.1605 -static Mix_EffectFunc_t get_position_effect_func(Uint16 format, int channels)
  7.1606 -{
  7.1607 -    Mix_EffectFunc_t f = NULL;
  7.1608 -
  7.1609 -    switch (format) {
  7.1610 -        case AUDIO_U8:
  7.1611 -        switch (channels) {
  7.1612 -            case 1:
  7.1613 -            case 2:
  7.1614 -                f = (_Eff_build_volume_table_u8()) ? _Eff_position_table_u8 :
  7.1615 -                                                        _Eff_position_u8;
  7.1616 -                break;
  7.1617 -            case 4:
  7.1618 -                f = _Eff_position_u8_c4;
  7.1619 -                break;
  7.1620 -            case 6:
  7.1621 -                f = _Eff_position_u8_c6;
  7.1622 -                break;
  7.1623 -            default:
  7.1624 -                Mix_SetError("Unsupported audio channels");
  7.1625 -                break;
  7.1626 -        }
  7.1627 -        break;
  7.1628 -
  7.1629 -        case AUDIO_S8:
  7.1630 -        switch (channels) {
  7.1631 -            case 1:
  7.1632 -            case 2:
  7.1633 -                f = (_Eff_build_volume_table_s8()) ? _Eff_position_table_s8 :
  7.1634 -                                                        _Eff_position_s8;
  7.1635 -                break;
  7.1636 -            case 4:
  7.1637 -                f = _Eff_position_s8_c4;
  7.1638 -                break;
  7.1639 -            case 6:
  7.1640 -                f = _Eff_position_s8_c6;
  7.1641 -                break;
  7.1642 -            default:
  7.1643 -                Mix_SetError("Unsupported audio channels");
  7.1644 -                break;
  7.1645 -        }
  7.1646 -        break;
  7.1647 -
  7.1648 -        case AUDIO_U16LSB:
  7.1649 -        switch (channels) {
  7.1650 -            case 1:
  7.1651 -            case 2:
  7.1652 -                f = _Eff_position_u16lsb;
  7.1653 -                break;
  7.1654 -            case 4:
  7.1655 -                f = _Eff_position_u16lsb_c4;
  7.1656 -                break;
  7.1657 -            case 6:
  7.1658 -                f = _Eff_position_u16lsb_c6;
  7.1659 -                break;
  7.1660 -            default:
  7.1661 -                Mix_SetError("Unsupported audio channels");
  7.1662 -                break;
  7.1663 -        }
  7.1664 -        break;
  7.1665 -
  7.1666 -        case AUDIO_S16LSB:
  7.1667 -        switch (channels) {
  7.1668 -            case 1:
  7.1669 -            case 2:
  7.1670 -                f = _Eff_position_s16lsb;
  7.1671 -                break;
  7.1672 -            case 4:
  7.1673 -                f = _Eff_position_s16lsb_c4;
  7.1674 -                break;
  7.1675 -            case 6:
  7.1676 -                f = _Eff_position_s16lsb_c6;
  7.1677 -                break;
  7.1678 -            default:
  7.1679 -                Mix_SetError("Unsupported audio channels");
  7.1680 -                break;
  7.1681 -        }
  7.1682 -        break;
  7.1683 -
  7.1684 -        case AUDIO_U16MSB:
  7.1685 -        switch (channels) {
  7.1686 -            case 1:
  7.1687 -            case 2:
  7.1688 -                f = _Eff_position_u16msb;
  7.1689 -                break;
  7.1690 -            case 4:
  7.1691 -                f = _Eff_position_u16msb_c4;
  7.1692 -                break;
  7.1693 -            case 6:
  7.1694 -                f = _Eff_position_u16msb_c6;
  7.1695 -                break;
  7.1696 -            default:
  7.1697 -                Mix_SetError("Unsupported audio channels");
  7.1698 -                break;
  7.1699 -        }
  7.1700 -        break;
  7.1701 -
  7.1702 -        case AUDIO_S16MSB:
  7.1703 -        switch (channels) {
  7.1704 -            case 1:
  7.1705 -            case 2:
  7.1706 -                f = _Eff_position_s16msb;
  7.1707 -                break;
  7.1708 -            case 4:
  7.1709 -                f = _Eff_position_s16msb_c4;
  7.1710 -                break;
  7.1711 -            case 6:
  7.1712 -                f = _Eff_position_s16msb_c6;
  7.1713 -                break;
  7.1714 -            default:
  7.1715 -                Mix_SetError("Unsupported audio channels");
  7.1716 -                break;
  7.1717 -        }
  7.1718 -        break;
  7.1719 -
  7.1720 -        case AUDIO_S32MSB:
  7.1721 -        switch (channels) {
  7.1722 -            case 1:
  7.1723 -            case 2:
  7.1724 -                f = _Eff_position_s32msb;
  7.1725 -                break;
  7.1726 -            case 4:
  7.1727 -                f = _Eff_position_s32msb_c4;
  7.1728 -                break;
  7.1729 -            case 6:
  7.1730 -                f = _Eff_position_s32msb_c6;
  7.1731 -                break;
  7.1732 -            default:
  7.1733 -                Mix_SetError("Unsupported audio channels");
  7.1734 -                break;
  7.1735 -        }
  7.1736 -        break;
  7.1737 -
  7.1738 -        case AUDIO_S32LSB:
  7.1739 -        switch (channels) {
  7.1740 -            case 1:
  7.1741 -            case 2:
  7.1742 -                f = _Eff_position_s32lsb;
  7.1743 -                break;
  7.1744 -            case 4:
  7.1745 -                f = _Eff_position_s32lsb_c4;
  7.1746 -                break;
  7.1747 -            case 6:
  7.1748 -                f = _Eff_position_s32lsb_c6;
  7.1749 -                break;
  7.1750 -            default:
  7.1751 -                Mix_SetError("Unsupported audio channels");
  7.1752 -                break;
  7.1753 -        }
  7.1754 -        break;
  7.1755 -
  7.1756 -        case AUDIO_F32SYS:
  7.1757 -        switch (channels) {
  7.1758 -            case 1:
  7.1759 -            case 2:
  7.1760 -                f = _Eff_position_f32sys;
  7.1761 -                break;
  7.1762 -            case 4:
  7.1763 -                f = _Eff_position_f32sys_c4;
  7.1764 -                break;
  7.1765 -            case 6:
  7.1766 -                f = _Eff_position_f32sys_c6;
  7.1767 -                break;
  7.1768 -            default:
  7.1769 -                Mix_SetError("Unsupported audio channels");
  7.1770 -                break;
  7.1771 -        }
  7.1772 -        break;
  7.1773 -
  7.1774 -        default:
  7.1775 -            Mix_SetError("Unsupported audio format");
  7.1776 -            break;
  7.1777 -    }
  7.1778 -
  7.1779 -    return(f);
  7.1780 -}
  7.1781 -
  7.1782 -static Uint8 speaker_amplitude[6];
  7.1783 -
  7.1784 -static void set_amplitudes(int channels, int angle, int room_angle)
  7.1785 -{
  7.1786 -    int left = 255, right = 255;
  7.1787 -    int left_rear = 255, right_rear = 255, center = 255;
  7.1788 -
  7.1789 -    angle = SDL_abs(angle) % 360;  /* make angle between 0 and 359. */
  7.1790 -
  7.1791 -    if (channels == 2)
  7.1792 -    {
  7.1793 -        /*
  7.1794 -         * We only attenuate by position if the angle falls on the far side
  7.1795 -         *  of center; That is, an angle that's due north would not attenuate
  7.1796 -         *  either channel. Due west attenuates the right channel to 0.0, and
  7.1797 -         *  due east attenuates the left channel to 0.0. Slightly east of
  7.1798 -         *  center attenuates the left channel a little, and the right channel
  7.1799 -         *  not at all. I think of this as occlusion by one's own head.  :)
  7.1800 -         *
  7.1801 -         *   ...so, we split our angle circle into four quadrants...
  7.1802 -         */
  7.1803 -        if (angle < 90) {
  7.1804 -            left = 255 - ((int) (255.0f * (((float) angle) / 89.0f)));
  7.1805 -        } else if (angle < 180) {
  7.1806 -            left = (int) (255.0f * (((float) (angle - 90)) / 89.0f));
  7.1807 -        } else if (angle < 270) {
  7.1808 -            right = 255 - ((int) (255.0f * (((float) (angle - 180)) / 89.0f)));
  7.1809 -        } else {
  7.1810 -            right = (int) (255.0f * (((float) (angle - 270)) / 89.0f));
  7.1811 -        }
  7.1812 -    }
  7.1813 -
  7.1814 -    if (channels == 4 || channels == 6)
  7.1815 -    {
  7.1816 -        /*
  7.1817 -         *  An angle that's due north does not attenuate the center channel.
  7.1818 -         *  An angle in the first quadrant, 0-90, does not attenuate the RF.
  7.1819 -         *
  7.1820 -         *   ...so, we split our angle circle into 8 ...
  7.1821 -         *
  7.1822 -         *             CE
  7.1823 -         *             0
  7.1824 -         *     LF      |         RF
  7.1825 -         *             |
  7.1826 -         *  270<-------|----------->90
  7.1827 -         *             |
  7.1828 -         *     LR      |         RR
  7.1829 -         *            180
  7.1830 -         *
  7.1831 -         */
  7.1832 -        if (angle < 45) {
  7.1833 -            left = ((int) (255.0f * (((float) (180 - angle)) / 179.0f)));
  7.1834 -            left_rear = 255 - ((int) (255.0f * (((float) (angle + 45)) / 89.0f)));
  7.1835 -            right_rear = 255 - ((int) (255.0f * (((float) (90 - angle)) / 179.0f)));
  7.1836 -        } else if (angle < 90) {
  7.1837 -            center = ((int) (255.0f * (((float) (225 - angle)) / 179.0f)));
  7.1838 -            left = ((int) (255.0f * (((float) (180 - angle)) / 179.0f)));
  7.1839 -            left_rear = 255 - ((int) (255.0f * (((float) (135 - angle)) / 89.0f)));
  7.1840 -            right_rear = ((int) (255.0f * (((float) (90 + angle)) / 179.0f)));
  7.1841 -        } else if (angle < 135) {
  7.1842 -            center = ((int) (255.0f * (((float) (225 - angle)) / 179.0f)));
  7.1843 -            left = 255 - ((int) (255.0f * (((float) (angle - 45)) / 89.0f)));
  7.1844 -            right = ((int) (255.0f * (((float) (270 - angle)) / 179.0f)));
  7.1845 -            left_rear = ((int) (255.0f * (((float) (angle)) / 179.0f)));
  7.1846 -        } else if (angle < 180) {
  7.1847 -            center = 255 - ((int) (255.0f * (((float) (angle - 90)) / 89.0f)));
  7.1848 -            left = 255 - ((int) (255.0f * (((float) (225 - angle)) / 89.0f)));
  7.1849 -            right = ((int) (255.0f * (((float) (270 - angle)) / 179.0f)));
  7.1850 -            left_rear = ((int) (255.0f * (((float) (angle)) / 179.0f)));
  7.1851 -        } else if (angle < 225) {
  7.1852 -            center = 255 - ((int) (255.0f * (((float) (270 - angle)) / 89.0f)));
  7.1853 -            left = ((int) (255.0f * (((float) (angle - 90)) / 179.0f)));
  7.1854 -            right = 255 - ((int) (255.0f * (((float) (angle - 135)) / 89.0f)));
  7.1855 -            right_rear = ((int) (255.0f * (((float) (360 - angle)) / 179.0f)));
  7.1856 -        } else if (angle < 270) {
  7.1857 -            center = ((int) (255.0f * (((float) (angle - 135)) / 179.0f)));
  7.1858 -            left = ((int) (255.0f * (((float) (angle - 90)) / 179.0f)));
  7.1859 -            right = 255 - ((int) (255.0f * (((float) (315 - angle)) / 89.0f)));
  7.1860 -            right_rear = ((int) (255.0f * (((float) (360 - angle)) / 179.0f)));
  7.1861 -        } else if (angle < 315) {
  7.1862 -            center = ((int) (255.0f * (((float) (angle - 135)) / 179.0f)));
  7.1863 -            right = ((int) (255.0f * (((float) (angle - 180)) / 179.0f)));
  7.1864 -            left_rear = ((int) (255.0f * (((float) (450 - angle)) / 179.0f)));
  7.1865 -            right_rear = 255 - ((int) (255.0f * (((float) (angle - 225)) / 89.0f)));
  7.1866 -        } else {
  7.1867 -            right = ((int) (255.0f * (((float) (angle - 180)) / 179.0f)));
  7.1868 -            left_rear = ((int) (255.0f * (((float) (450 - angle)) / 179.0f)));
  7.1869 -            right_rear = 255 - ((int) (255.0f * (((float) (405 - angle)) / 89.0f)));
  7.1870 -        }
  7.1871 -    }
  7.1872 -
  7.1873 -    if (left < 0) left = 0;
  7.1874 -    if (left > 255) left = 255;
  7.1875 -    if (right < 0) right = 0;
  7.1876 -    if (right > 255) right = 255;
  7.1877 -    if (left_rear < 0) left_rear = 0;
  7.1878 -    if (left_rear > 255) left_rear = 255;
  7.1879 -    if (right_rear < 0) right_rear = 0;
  7.1880 -    if (right_rear > 255) right_rear = 255;
  7.1881 -    if (center < 0) center = 0;
  7.1882 -    if (center > 255) center = 255;
  7.1883 -
  7.1884 -    if (room_angle == 90) {
  7.1885 -        speaker_amplitude[0] = (Uint8)left_rear;
  7.1886 -        speaker_amplitude[1] = (Uint8)left;
  7.1887 -        speaker_amplitude[2] = (Uint8)right_rear;
  7.1888 -        speaker_amplitude[3] = (Uint8)right;
  7.1889 -    }
  7.1890 -    else if (room_angle == 180) {
  7.1891 -    if (channels == 2) {
  7.1892 -            speaker_amplitude[0] = (Uint8)right;
  7.1893 -            speaker_amplitude[1] = (Uint8)left;
  7.1894 -    }
  7.1895 -    else {
  7.1896 -            speaker_amplitude[0] = (Uint8)right_rear;
  7.1897 -            speaker_amplitude[1] = (Uint8)left_rear;
  7.1898 -            speaker_amplitude[2] = (Uint8)right;
  7.1899 -            speaker_amplitude[3] = (Uint8)left;
  7.1900 -    }
  7.1901 -    }
  7.1902 -    else if (room_angle == 270) {
  7.1903 -        speaker_amplitude[0] = (Uint8)right;
  7.1904 -        speaker_amplitude[1] = (Uint8)right_rear;
  7.1905 -        speaker_amplitude[2] = (Uint8)left;
  7.1906 -        speaker_amplitude[3] = (Uint8)left_rear;
  7.1907 -    }
  7.1908 -    else {
  7.1909 -        speaker_amplitude[0] = (Uint8)left;
  7.1910 -        speaker_amplitude[1] = (Uint8)right;
  7.1911 -        speaker_amplitude[2] = (Uint8)left_rear;
  7.1912 -        speaker_amplitude[3] = (Uint8)right_rear;
  7.1913 -    }
  7.1914 -    speaker_amplitude[4] = (Uint8)center;
  7.1915 -    speaker_amplitude[5] = 255;
  7.1916 -}
  7.1917 -
  7.1918 -int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance);
  7.1919 -
  7.1920 -int Mix_SetPanning(int channel, Uint8 left, Uint8 right)
  7.1921 -{
  7.1922 -    Mix_EffectFunc_t f = NULL;
  7.1923 -    int channels;
  7.1924 -    Uint16 format;
  7.1925 -    position_args *args = NULL;
  7.1926 -    int retval = 1;
  7.1927 -
  7.1928 -    Mix_QuerySpec(NULL, &format, &channels);
  7.1929 -
  7.1930 -    if (channels != 2 && channels != 4 && channels != 6)    /* it's a no-op; we call that successful. */
  7.1931 -        return(1);
  7.1932 -
  7.1933 -    if (channels > 2) {
  7.1934 -        /* left = right = 255 => angle = 0, to unregister effect as when channels = 2 */
  7.1935 -        /* left = 255 =>  angle = -90;  left = 0 => angle = +89 */
  7.1936 -        int angle = 0;
  7.1937 -        if ((left != 255) || (right != 255)) {
  7.1938 -        angle = (int)left;
  7.1939 -            angle = 127 - angle;
  7.1940 -        angle = -angle;
  7.1941 -            angle = angle * 90 / 128; /* Make it larger for more effect? */
  7.1942 -        }
  7.1943 -        return(Mix_SetPosition(channel, angle, 0));
  7.1944 -    }
  7.1945 -
  7.1946 -    f = get_position_effect_func(format, channels);
  7.1947 -    if (f == NULL)
  7.1948 -        return(0);
  7.1949 -
  7.1950 -    Mix_LockAudio();
  7.1951 -    args = get_position_arg(channel);
  7.1952 -    if (!args) {
  7.1953 -        Mix_UnlockAudio();
  7.1954 -        return(0);
  7.1955 -    }
  7.1956 -
  7.1957 -        /* it's a no-op; unregister the effect, if it's registered. */
  7.1958 -    if ((args->distance_u8 == 255) && (left == 255) && (right == 255)) {
  7.1959 -        if (args->in_use) {
  7.1960 -            retval = _Mix_UnregisterEffect_locked(channel, f);
  7.1961 -            Mix_UnlockAudio();
  7.1962 -            return(retval);
  7.1963 -        } else {
  7.1964 -            Mix_UnlockAudio();
  7.1965 -            return(1);
  7.1966 -        }
  7.1967 -    }
  7.1968 -
  7.1969 -    args->left_u8 = left;
  7.1970 -    args->left_f = ((float) left) / 255.0f;
  7.1971 -    args->right_u8 = right;
  7.1972 -    args->right_f = ((float) right) / 255.0f;
  7.1973 -    args->room_angle = 0;
  7.1974 -
  7.1975 -    if (!args->in_use) {
  7.1976 -        args->in_use = 1;
  7.1977 -        retval=_Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void*)args);
  7.1978 -    }
  7.1979 -
  7.1980 -    Mix_UnlockAudio();
  7.1981 -    return(retval);
  7.1982 -}
  7.1983 -
  7.1984 -
  7.1985 -int Mix_SetDistance(int channel, Uint8 distance)
  7.1986 -{
  7.1987 -    Mix_EffectFunc_t f = NULL;
  7.1988 -    Uint16 format;
  7.1989 -    position_args *args = NULL;
  7.1990 -    int channels;
  7.1991 -    int retval = 1;
  7.1992 -
  7.1993 -    Mix_QuerySpec(NULL, &format, &channels);
  7.1994 -    f = get_position_effect_func(format, channels);
  7.1995 -    if (f == NULL)
  7.1996 -        return(0);
  7.1997 -
  7.1998 -    Mix_LockAudio();
  7.1999 -    args = get_position_arg(channel);
  7.2000 -    if (!args) {
  7.2001 -        Mix_UnlockAudio();
  7.2002 -        return(0);
  7.2003 -    }
  7.2004 -
  7.2005 -    distance = 255 - distance;  /* flip it to our scale. */
  7.2006 -
  7.2007 -        /* it's a no-op; unregister the effect, if it's registered. */
  7.2008 -    if ((distance == 255) && (args->left_u8 == 255) && (args->right_u8 == 255)) {
  7.2009 -        if (args->in_use) {
  7.2010 -            retval = _Mix_UnregisterEffect_locked(channel, f);
  7.2011 -            Mix_UnlockAudio();
  7.2012 -            return(retval);
  7.2013 -        } else {
  7.2014 -            Mix_UnlockAudio();
  7.2015 -            return(1);
  7.2016 -        }
  7.2017 -    }
  7.2018 -
  7.2019 -    args->distance_u8 = distance;
  7.2020 -    args->distance_f = ((float) distance) / 255.0f;
  7.2021 -    if (!args->in_use) {
  7.2022 -        args->in_use = 1;
  7.2023 -        retval = _Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void *) args);
  7.2024 -    }
  7.2025 -
  7.2026 -    Mix_UnlockAudio();
  7.2027 -    return(retval);
  7.2028 -}
  7.2029 -
  7.2030 -
  7.2031 -int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance)
  7.2032 -{
  7.2033 -    Mix_EffectFunc_t f = NULL;
  7.2034 -    Uint16 format;
  7.2035 -    int channels;
  7.2036 -    position_args *args = NULL;
  7.2037 -    Sint16 room_angle = 0;
  7.2038 -    int retval = 1;
  7.2039 -
  7.2040 -    Mix_QuerySpec(NULL, &format, &channels);
  7.2041 -    f = get_position_effect_func(format, channels);
  7.2042 -    if (f == NULL)
  7.2043 -        return(0);
  7.2044 -
  7.2045 -    angle = SDL_abs(angle) % 360;  /* make angle between 0 and 359. */
  7.2046 -
  7.2047 -    Mix_LockAudio();
  7.2048 -    args = get_position_arg(channel);
  7.2049 -    if (!args) {
  7.2050 -        Mix_UnlockAudio();
  7.2051 -        return(0);
  7.2052 -    }
  7.2053 -
  7.2054 -    /* it's a no-op; unregister the effect, if it's registered. */
  7.2055 -    if ((!distance) && (!angle)) {
  7.2056 -        if (args->in_use) {
  7.2057 -            retval = _Mix_UnregisterEffect_locked(channel, f);
  7.2058 -            Mix_UnlockAudio();
  7.2059 -            return(retval);
  7.2060 -        } else {
  7.2061 -            Mix_UnlockAudio();
  7.2062 -            return(1);
  7.2063 -        }
  7.2064 -    }
  7.2065 -
  7.2066 -    if (channels == 2)
  7.2067 -    {
  7.2068 -      if (angle > 180)
  7.2069 -          room_angle = 180; /* exchange left and right channels */
  7.2070 -      else room_angle = 0;
  7.2071 -    }
  7.2072 -
  7.2073 -    if (channels == 4 || channels == 6)
  7.2074 -    {
  7.2075 -        if (angle > 315) room_angle = 0;
  7.2076 -        else if (angle > 225) room_angle = 270;
  7.2077 -        else if (angle > 135) room_angle = 180;
  7.2078 -        else if (angle > 45) room_angle = 90;
  7.2079 -        else room_angle = 0;
  7.2080 -    }
  7.2081 -
  7.2082 -    distance = 255 - distance;  /* flip it to scale Mix_SetDistance() uses. */
  7.2083 -
  7.2084 -    set_amplitudes(channels, angle, room_angle);
  7.2085 -
  7.2086 -    args->left_u8 = speaker_amplitude[0];
  7.2087 -    args->left_f = ((float) speaker_amplitude[0]) / 255.0f;
  7.2088 -    args->right_u8 = speaker_amplitude[1];
  7.2089 -    args->right_f = ((float) speaker_amplitude[1]) / 255.0f;
  7.2090 -    args->left_rear_u8 = speaker_amplitude[2];
  7.2091 -    args->left_rear_f = ((float) speaker_amplitude[2]) / 255.0f;
  7.2092 -    args->right_rear_u8 = speaker_amplitude[3];
  7.2093 -    args->right_rear_f = ((float) speaker_amplitude[3]) / 255.0f;
  7.2094 -    args->center_u8 = speaker_amplitude[4];
  7.2095 -    args->center_f = ((float) speaker_amplitude[4]) / 255.0f;
  7.2096 -    args->lfe_u8 = speaker_amplitude[5];
  7.2097 -    args->lfe_f = ((float) speaker_amplitude[5]) / 255.0f;
  7.2098 -    args->distance_u8 = distance;
  7.2099 -    args->distance_f = ((float) distance) / 255.0f;
  7.2100 -    args->room_angle = room_angle;
  7.2101 -    if (!args->in_use) {
  7.2102 -        args->in_use = 1;
  7.2103 -        retval = _Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void *) args);
  7.2104 -    }
  7.2105 -
  7.2106 -    Mix_UnlockAudio();
  7.2107 -    return(retval);
  7.2108 -}
  7.2109 -
  7.2110 -/* end of effects_position.c ... */
  7.2111 -
  7.2112 -/* vi: set ts=4 sw=4 expandtab: */
     8.1 --- a/effect_stereoreverse.c	Mon Nov 18 18:50:50 2019 +0300
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,143 +0,0 @@
     8.4 -/*
     8.5 -  SDL_mixer:  An audio mixer library based on the SDL library
     8.6 -  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
     8.7 -
     8.8 -  This software is provided 'as-is', without any express or implied
     8.9 -  warranty.  In no event will the authors be held liable for any damages
    8.10 -  arising from the use of this software.
    8.11 -
    8.12 -  Permission is granted to anyone to use this software for any purpose,
    8.13 -  including commercial applications, and to alter it and redistribute it
    8.14 -  freely, subject to the following restrictions:
    8.15 -
    8.16 -  1. The origin of this software must not be misrepresented; you must not
    8.17 -     claim that you wrote the original software. If you use this software
    8.18 -     in a product, an acknowledgment in the product documentation would be
    8.19 -     appreciated but is not required.
    8.20 -  2. Altered source versions must be plainly marked as such, and must not be
    8.21 -     misrepresented as being the original software.
    8.22 -  3. This notice may not be removed or altered from any source distribution.
    8.23 -
    8.24 -  This file by Ryan C. Gordon (icculus@icculus.org)
    8.25 -
    8.26 -  These are some internally supported special effects that use SDL_mixer's
    8.27 -  effect callback API. They are meant for speed over quality.  :)
    8.28 -*/
    8.29 -
    8.30 -#include <stdio.h>
    8.31 -#include <stdlib.h>
    8.32 -
    8.33 -#include "SDL.h"
    8.34 -#include "SDL_mixer.h"
    8.35 -
    8.36 -#define __MIX_INTERNAL_EFFECT__
    8.37 -#include "effects_internal.h"
    8.38 -
    8.39 -/* profile code:
    8.40 -    #include <sys/time.h>
    8.41 -    #include <unistd.h>
    8.42 -    struct timeval tv1;
    8.43 -    struct timeval tv2;
    8.44 -
    8.45 -    gettimeofday(&tv1, NULL);
    8.46 -
    8.47 -        ... do your thing here ...
    8.48 -
    8.49 -    gettimeofday(&tv2, NULL);
    8.50 -    printf("%ld\n", tv2.tv_usec - tv1.tv_usec);
    8.51 -*/
    8.52 -
    8.53 -
    8.54 -/*
    8.55 - * Stereo reversal effect...this one's pretty straightforward...
    8.56 - */
    8.57 -
    8.58 -static void SDLCALL _Eff_reversestereo32(int chan, void *stream, int len, void *udata)
    8.59 -{
    8.60 -    /* 16 bits * 2 channels. */
    8.61 -    Uint32 *ptr = (Uint32 *) stream;
    8.62 -    Uint32 tmp;
    8.63 -    int i;
    8.64 -
    8.65 -    (void)chan;
    8.66 -    (void)udata;
    8.67 -
    8.68 -    for (i = 0; i < len; i += 2 * sizeof (Uint32), ptr += 2) {
    8.69 -        tmp = ptr[0];
    8.70 -        ptr[0] = ptr[1];
    8.71 -        ptr[1] = tmp;
    8.72 -    }
    8.73 -}
    8.74 -
    8.75 -static void SDLCALL _Eff_reversestereo16(int chan, void *stream, int len, void *udata)
    8.76 -{
    8.77 -    /* 16 bits * 2 channels. */
    8.78 -    Uint32 *ptr = (Uint32 *) stream;
    8.79 -    int i;
    8.80 -
    8.81 -    (void)chan;
    8.82 -    (void)udata;
    8.83 -
    8.84 -    for (i = 0; i < len; i += sizeof (Uint32), ptr++) {
    8.85 -        *ptr = (((*ptr) & 0xFFFF0000) >> 16) | (((*ptr) & 0x0000FFFF) << 16);
    8.86 -    }
    8.87 -}
    8.88 -
    8.89 -static void SDLCALL _Eff_reversestereo8(int chan, void *stream, int len, void *udata)
    8.90 -{
    8.91 -    /* 8 bits * 2 channels. */
    8.92 -    Uint32 *ptr = (Uint32 *) stream;
    8.93 -    int i;
    8.94 -
    8.95 -    (void)chan;
    8.96 -    (void)udata;
    8.97 -
    8.98 -    /* get the last two bytes if len is not divisible by four... */
    8.99 -    if (len % (int)sizeof(Uint32) != 0) {
   8.100 -        Uint16 *p = (Uint16 *) (((Uint8 *) stream) + (len - 2));
   8.101 -        *p = (Uint16)((((*p) & 0xFF00) >> 8) | (((*ptr) & 0x00FF) << 8));
   8.102 -        len -= 2;
   8.103 -    }
   8.104 -
   8.105 -    for (i = 0; i < len; i += sizeof (Uint32), ptr++) {
   8.106 -        *ptr = (((*ptr) & 0x0000FF00) >> 8) | (((*ptr) & 0x000000FF) << 8) |
   8.107 -               (((*ptr) & 0xFF000000) >> 8) | (((*ptr) & 0x00FF0000) << 8);
   8.108 -    }
   8.109 -}
   8.110 -
   8.111 -
   8.112 -int Mix_SetReverseStereo(int channel, int flip)
   8.113 -{
   8.114 -    Mix_EffectFunc_t f = NULL;
   8.115 -    int channels;
   8.116 -    Uint16 format;
   8.117 -
   8.118 -    Mix_QuerySpec(NULL, &format, &channels);
   8.119 -
   8.120 -    if (channels == 2) {
   8.121 -        int bits = (format & 0xFF);
   8.122 -        switch (bits) {
   8.123 -        case 8:
   8.124 -            f = _Eff_reversestereo8;
   8.125 -            break;
   8.126 -        case 16:
   8.127 -            f = _Eff_reversestereo16;
   8.128 -            break;
   8.129 -        case 32:
   8.130 -            f = _Eff_reversestereo32;
   8.131 -            break;
   8.132 -        default:
   8.133 -            Mix_SetError("Unsupported audio format");
   8.134 -            return(0);
   8.135 -        }
   8.136 -        if (!flip) return Mix_UnregisterEffect(channel, f);
   8.137 -        return(Mix_RegisterEffect(channel, f, NULL, NULL));
   8.138 -    }
   8.139 -
   8.140 -    Mix_SetError("Trying to reverse stereo on a non-stereo stream");
   8.141 -    return(0);
   8.142 -}
   8.143 -
   8.144 -/* end of effect_stereoreverse.c ... */
   8.145 -
   8.146 -/* vi: set ts=4 sw=4 expandtab: */
     9.1 --- a/effects_internal.c	Mon Nov 18 18:50:50 2019 +0300
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,121 +0,0 @@
     9.4 -/*
     9.5 -  SDL_mixer:  An audio mixer library based on the SDL library
     9.6 -  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
     9.7 -
     9.8 -  This software is provided 'as-is', without any express or implied
     9.9 -  warranty.  In no event will the authors be held liable for any damages
    9.10 -  arising from the use of this software.
    9.11 -
    9.12 -  Permission is granted to anyone to use this software for any purpose,
    9.13 -  including commercial applications, and to alter it and redistribute it
    9.14 -  freely, subject to the following restrictions:
    9.15 -
    9.16 -  1. The origin of this software must not be misrepresented; you must not
    9.17 -     claim that you wrote the original software. If you use this software
    9.18 -     in a product, an acknowledgment in the product documentation would be
    9.19 -     appreciated but is not required.
    9.20 -  2. Altered source versions must be plainly marked as such, and must not be
    9.21 -     misrepresented as being the original software.
    9.22 -  3. This notice may not be removed or altered from any source distribution.
    9.23 -
    9.24 -  This file by Ryan C. Gordon (icculus@icculus.org)
    9.25 -
    9.26 -  These are some helper functions for the internal mixer special effects.
    9.27 -*/
    9.28 -
    9.29 -
    9.30 -/* ------ These are used internally only. Don't touch. ------ */
    9.31 -
    9.32 -#include <stdio.h>
    9.33 -#include <stdlib.h>
    9.34 -#include "SDL_mixer.h"
    9.35 -
    9.36 -#define __MIX_INTERNAL_EFFECT__
    9.37 -#include "effects_internal.h"
    9.38 -
    9.39 -/* Should we favor speed over memory usage and/or quality of output? */
    9.40 -int _Mix_effects_max_speed = 0;
    9.41 -
    9.42 -
    9.43 -void _Mix_InitEffects(void)
    9.44 -{
    9.45 -    _Mix_effects_max_speed = (SDL_getenv(MIX_EFFECTSMAXSPEED) != NULL);
    9.46 -}
    9.47 -
    9.48 -void _Mix_DeinitEffects(void)
    9.49 -{
    9.50 -    _Eff_PositionDeinit();
    9.51 -}
    9.52 -
    9.53 -
    9.54 -void *_Eff_volume_table = NULL;
    9.55 -
    9.56 -
    9.57 -/* Build the volume table for Uint8-format samples.
    9.58 - *
    9.59 - * Each column of the table is a possible sample, while each row of the
    9.60 - *  table is a volume. Volume is a Uint8, where 0 is silence and 255 is full
    9.61 - *  volume. So _Eff_volume_table[128][mysample] would be the value of
    9.62 - *  mysample, at half volume.
    9.63 - */
    9.64 -void *_Eff_build_volume_table_u8(void)
    9.65 -{
    9.66 -    int volume;
    9.67 -    int sample;
    9.68 -    Uint8 *rc;
    9.69 -
    9.70 -    if (!_Mix_effects_max_speed) {
    9.71 -        return(NULL);
    9.72 -    }
    9.73 -
    9.74 -    if (!_Eff_volume_table) {
    9.75 -        rc = SDL_malloc(256 * 256);
    9.76 -        if (rc) {
    9.77 -            _Eff_volume_table = (void *) rc;
    9.78 -            for (volume = 0; volume < 256; volume++) {
    9.79 -                for (sample = -128; sample < 128; sample ++) {
    9.80 -                    *rc = (Uint8)(((float) sample) * ((float) volume / 255.0))
    9.81 -                        + 128;
    9.82 -                    rc++;
    9.83 -                }
    9.84 -            }
    9.85 -        }
    9.86 -    }
    9.87 -
    9.88 -    return(_Eff_volume_table);
    9.89 -}
    9.90 -
    9.91 -
    9.92 -/* Build the volume table for Sint8-format samples.
    9.93 - *
    9.94 - * Each column of the table is a possible sample, while each row of the
    9.95 - *  table is a volume. Volume is a Uint8, where 0 is silence and 255 is full
    9.96 - *  volume. So _Eff_volume_table[128][mysample+128] would be the value of
    9.97 - *  mysample, at half volume.
    9.98 - */
    9.99 -void *_Eff_build_volume_table_s8(void)
   9.100 -{
   9.101 -    int volume;
   9.102 -    int sample;
   9.103 -    Sint8 *rc;
   9.104 -
   9.105 -    if (!_Eff_volume_table) {
   9.106 -        rc = SDL_malloc(256 * 256);
   9.107 -        if (rc) {
   9.108 -            _Eff_volume_table = (void *) rc;
   9.109 -            for (volume = 0; volume < 256; volume++) {
   9.110 -                for (sample = -128; sample < 128; sample ++) {
   9.111 -                    *rc = (Sint8)(((float) sample) * ((float) volume / 255.0));
   9.112 -                    rc++;
   9.113 -                }
   9.114 -            }
   9.115 -        }
   9.116 -    }
   9.117 -
   9.118 -    return(_Eff_volume_table);
   9.119 -}
   9.120 -
   9.121 -
   9.122 -/* end of effects.c ... */
   9.123 -
   9.124 -/* vi: set ts=4 sw=4 expandtab: */
    10.1 --- a/effects_internal.h	Mon Nov 18 18:50:50 2019 +0300
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,49 +0,0 @@
    10.4 -/*
    10.5 -  SDL_mixer:  An audio mixer library based on the SDL library
    10.6 -  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
    10.7 -
    10.8 -  This software is provided 'as-is', without any express or implied
    10.9 -  warranty.  In no event will the authors be held liable for any damages
   10.10 -  arising from the use of this software.
   10.11 -
   10.12 -  Permission is granted to anyone to use this software for any purpose,
   10.13 -  including commercial applications, and to alter it and redistribute it
   10.14 -  freely, subject to the following restrictions:
   10.15 -
   10.16 -  1. The origin of this software must not be misrepresented; you must not
   10.17 -     claim that you wrote the original software. If you use this software
   10.18 -     in a product, an acknowledgment in the product documentation would be
   10.19 -     appreciated but is not required.
   10.20 -  2. Altered source versions must be plainly marked as such, and must not be
   10.21 -     misrepresented as being the original software.
   10.22 -  3. This notice may not be removed or altered from any source distribution.
   10.23 -*/
   10.24 -
   10.25 -/* $Id$ */
   10.26 -
   10.27 -#ifndef _INCLUDE_EFFECTS_INTERNAL_H_
   10.28 -#define _INCLUDE_EFFECTS_INTERNAL_H_
   10.29 -
   10.30 -#ifndef __MIX_INTERNAL_EFFECT__
   10.31 -#error You should not include this file or use these functions.
   10.32 -#endif
   10.33 -
   10.34 -#include "SDL_mixer.h"
   10.35 -
   10.36 -extern int _Mix_effects_max_speed;
   10.37 -extern void *_Eff_volume_table;
   10.38 -void *_Eff_build_volume_table_u8(void);
   10.39 -void *_Eff_build_volume_table_s8(void);
   10.40 -
   10.41 -void _Mix_InitEffects(void);
   10.42 -void _Mix_DeinitEffects(void);
   10.43 -void _Eff_PositionDeinit(void);
   10.44 -
   10.45 -int _Mix_RegisterEffect_locked(int channel, Mix_EffectFunc_t f,
   10.46 -                               Mix_EffectDone_t d, void *arg);
   10.47 -int _Mix_UnregisterEffect_locked(int channel, Mix_EffectFunc_t f);
   10.48 -int _Mix_UnregisterAllEffects_locked(int channel);
   10.49 -
   10.50 -#endif /* _INCLUDE_EFFECTS_INTERNAL_H_ */
   10.51 -
   10.52 -/* vi: set ts=4 sw=4 expandtab: */
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/include/SDL_mixer.h	Tue Nov 19 12:36:40 2019 +0300
    11.3 @@ -0,0 +1,651 @@
    11.4 +/*
    11.5 +  SDL_mixer:  An audio mixer library based on the SDL library
    11.6 +  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
    11.7 +
    11.8 +  This software is provided 'as-is', without any express or implied
    11.9 +  warranty.  In no event will the authors be held liable for any damages
   11.10 +  arising from the use of this software.
   11.11 +
   11.12 +  Permission is granted to anyone to use this software for any purpose,
   11.13 +  including commercial applications, and to alter it and redistribute it
   11.14 +  freely, subject to the following restrictions:
   11.15 +
   11.16 +  1. The origin of this software must not be misrepresented; you must not
   11.17 +     claim that you wrote the original software. If you use this software
   11.18 +     in a product, an acknowledgment in the product documentation would be
   11.19 +     appreciated but is not required.
   11.20 +  2. Altered source versions must be plainly marked as such, and must not be
   11.21 +     misrepresented as being the original software.
   11.22 +  3. This notice may not be removed or altered from any source distribution.
   11.23 +*/
   11.24 +
   11.25 +#ifndef SDL_MIXER_H_
   11.26 +#define SDL_MIXER_H_
   11.27 +
   11.28 +#include "SDL_stdinc.h"
   11.29 +#include "SDL_rwops.h"
   11.30 +#include "SDL_audio.h"
   11.31 +#include "SDL_endian.h"
   11.32 +#include "SDL_version.h"
   11.33 +#include "begin_code.h"
   11.34 +
   11.35 +/* Set up for C function definitions, even when using C++ */
   11.36 +#ifdef __cplusplus
   11.37 +extern "C" {
   11.38 +#endif
   11.39 +
   11.40 +/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
   11.41 +*/
   11.42 +#define SDL_MIXER_MAJOR_VERSION 2
   11.43 +#define SDL_MIXER_MINOR_VERSION 0
   11.44 +#define SDL_MIXER_PATCHLEVEL    4
   11.45 +
   11.46 +/* This macro can be used to fill a version structure with the compile-time
   11.47 + * version of the SDL_mixer library.
   11.48 + */
   11.49 +#define SDL_MIXER_VERSION(X)                        \
   11.50 +{                                                   \
   11.51 +    (X)->major = SDL_MIXER_MAJOR_VERSION;           \
   11.52 +    (X)->minor = SDL_MIXER_MINOR_VERSION;           \
   11.53 +    (X)->patch = SDL_MIXER_PATCHLEVEL;              \
   11.54 +}
   11.55 +
   11.56 +/* Backwards compatibility */
   11.57 +#define MIX_MAJOR_VERSION   SDL_MIXER_MAJOR_VERSION
   11.58 +#define MIX_MINOR_VERSION   SDL_MIXER_MINOR_VERSION
   11.59 +#define MIX_PATCHLEVEL      SDL_MIXER_PATCHLEVEL
   11.60 +#define MIX_VERSION(X)      SDL_MIXER_VERSION(X)
   11.61 +
   11.62 +/**
   11.63 + *  This is the version number macro for the current SDL_mixer version.
   11.64 + */
   11.65 +#define SDL_MIXER_COMPILEDVERSION \
   11.66 +    SDL_VERSIONNUM(SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL)
   11.67 +
   11.68 +/**
   11.69 + *  This macro will evaluate to true if compiled with SDL_mixer at least X.Y.Z.
   11.70 + */
   11.71 +#define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \
   11.72 +    (SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
   11.73 +
   11.74 +/* This function gets the version of the dynamically linked SDL_mixer library.
   11.75 +   it should NOT be used to fill a version structure, instead you should
   11.76 +   use the SDL_MIXER_VERSION() macro.
   11.77 + */
   11.78 +extern DECLSPEC const SDL_version * SDLCALL Mix_Linked_Version(void);
   11.79 +
   11.80 +typedef enum
   11.81 +{
   11.82 +    MIX_INIT_FLAC   = 0x00000001,
   11.83 +    MIX_INIT_MOD    = 0x00000002,
   11.84 +    MIX_INIT_MP3    = 0x00000008,
   11.85 +    MIX_INIT_OGG    = 0x00000010,
   11.86 +    MIX_INIT_MID    = 0x00000020,
   11.87 +    MIX_INIT_OPUS   = 0x00000040
   11.88 +} MIX_InitFlags;
   11.89 +
   11.90 +/* Loads dynamic libraries and prepares them for use.  Flags should be
   11.91 +   one or more flags from MIX_InitFlags OR'd together.
   11.92 +   It returns the flags successfully initialized, or 0 on failure.
   11.93 + */
   11.94 +extern DECLSPEC int SDLCALL Mix_Init(int flags);
   11.95 +
   11.96 +/* Unloads libraries loaded with Mix_Init */
   11.97 +extern DECLSPEC void SDLCALL Mix_Quit(void);
   11.98 +
   11.99 +
  11.100 +/* The default mixer has 8 simultaneous mixing channels */
  11.101 +#ifndef MIX_CHANNELS
  11.102 +#define MIX_CHANNELS    8
  11.103 +#endif
  11.104 +
  11.105 +/* Good default values for a PC soundcard */
  11.106 +#define MIX_DEFAULT_FREQUENCY   22050
  11.107 +#if SDL_BYTEORDER == SDL_LIL_ENDIAN
  11.108 +#define MIX_DEFAULT_FORMAT  AUDIO_S16LSB
  11.109 +#else
  11.110 +#define MIX_DEFAULT_FORMAT  AUDIO_S16MSB
  11.111 +#endif
  11.112 +#define MIX_DEFAULT_CHANNELS    2
  11.113 +#define MIX_MAX_VOLUME          SDL_MIX_MAXVOLUME /* Volume of a chunk */
  11.114 +
  11.115 +/* The internal format for an audio chunk */
  11.116 +typedef struct Mix_Chunk {
  11.117 +    int allocated;
  11.118 +    Uint8 *abuf;
  11.119 +    Uint32 alen;
  11.120 +    Uint8 volume;       /* Per-sample volume, 0-128 */
  11.121 +} Mix_Chunk;
  11.122 +
  11.123 +/* The different fading types supported */
  11.124 +typedef enum {
  11.125 +    MIX_NO_FADING,
  11.126 +    MIX_FADING_OUT,
  11.127 +    MIX_FADING_IN
  11.128 +} Mix_Fading;
  11.129 +
  11.130 +/* These are types of music files (not libraries used to load them) */
  11.131 +typedef enum {
  11.132 +    MUS_NONE,
  11.133 +    MUS_CMD,
  11.134 +    MUS_WAV,
  11.135 +    MUS_MOD,
  11.136 +    MUS_MID,
  11.137 +    MUS_OGG,
  11.138 +    MUS_MP3,
  11.139 +    MUS_MP3_MAD_UNUSED,
  11.140 +    MUS_FLAC,
  11.141 +    MUS_MODPLUG_UNUSED,
  11.142 +    MUS_OPUS
  11.143 +} Mix_MusicType;
  11.144 +
  11.145 +/* The internal format for a music chunk interpreted via mikmod */
  11.146 +typedef struct _Mix_Music Mix_Music;
  11.147 +
  11.148 +/* Open the mixer with a certain audio format */
  11.149 +extern DECLSPEC int SDLCALL Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize);
  11.150 +
  11.151 +/* Open the mixer with specific device and certain audio format */
  11.152 +extern DECLSPEC int SDLCALL Mix_OpenAudioDevice(int frequency, Uint16 format, int channels, int chunksize, const char* device, int allowed_changes);
  11.153 +
  11.154 +/* Dynamically change the number of channels managed by the mixer.
  11.155 +   If decreasing the number of channels, the upper channels are
  11.156 +   stopped.
  11.157 +   This function returns the new number of allocated channels.
  11.158 + */
  11.159 +extern DECLSPEC int SDLCALL Mix_AllocateChannels(int numchans);
  11.160 +
  11.161 +/* Find out what the actual audio device parameters are.
  11.162 +   This function returns 1 if the audio has been opened, 0 otherwise.
  11.163 + */
  11.164 +extern DECLSPEC int SDLCALL Mix_QuerySpec(int *frequency,Uint16 *format,int *channels);
  11.165 +
  11.166 +/* Load a wave file or a music (.mod .s3m .it .xm) file */
  11.167 +extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV_RW(SDL_RWops *src, int freesrc);
  11.168 +#define Mix_LoadWAV(file)   Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1)
  11.169 +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file);
  11.170 +
  11.171 +/* Load a music file from an SDL_RWop object (Ogg and MikMod specific currently)
  11.172 +   Matt Campbell (matt@campbellhome.dhs.org) April 2000 */
  11.173 +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *src, int freesrc);
  11.174 +
  11.175 +/* Load a music file from an SDL_RWop object assuming a specific format */
  11.176 +extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc);
  11.177 +
  11.178 +/* Load a wave file of the mixer format from a memory buffer */
  11.179 +extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_WAV(Uint8 *mem);
  11.180 +
  11.181 +/* Load raw audio data of the mixer format from a memory buffer */
  11.182 +extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len);
  11.183 +
  11.184 +/* Free an audio chunk previously loaded */
  11.185 +extern DECLSPEC void SDLCALL Mix_FreeChunk(Mix_Chunk *chunk);
  11.186 +extern DECLSPEC void SDLCALL Mix_FreeMusic(Mix_Music *music);
  11.187 +
  11.188 +/* Get a list of chunk/music decoders that this build of SDL_mixer provides.
  11.189 +   This list can change between builds AND runs of the program, if external
  11.190 +   libraries that add functionality become available.
  11.191 +   You must successfully call Mix_OpenAudio() before calling these functions.
  11.192 +   This API is only available in SDL_mixer 1.2.9 and later.
  11.193 +
  11.194 +   // usage...
  11.195 +   int i;
  11.196 +   const int total = Mix_GetNumChunkDecoders();
  11.197 +   for (i = 0; i < total; i++)
  11.198 +       printf("Supported chunk decoder: [%s]\n", Mix_GetChunkDecoder(i));
  11.199 +
  11.200 +   Appearing in this list doesn't promise your specific audio file will
  11.201 +   decode...but it's handy to know if you have, say, a functioning Timidity
  11.202 +   install.
  11.203 +
  11.204 +   These return values are static, read-only data; do not modify or free it.
  11.205 +   The pointers remain valid until you call Mix_CloseAudio().
  11.206 +*/
  11.207 +extern DECLSPEC int SDLCALL Mix_GetNumChunkDecoders(void);
  11.208 +extern DECLSPEC const char * SDLCALL Mix_GetChunkDecoder(int index);
  11.209 +extern DECLSPEC SDL_bool SDLCALL Mix_HasChunkDecoder(const char *name);
  11.210 +extern DECLSPEC int SDLCALL Mix_GetNumMusicDecoders(void);
  11.211 +extern DECLSPEC const char * SDLCALL Mix_GetMusicDecoder(int index);
  11.212 +extern DECLSPEC SDL_bool SDLCALL Mix_HasMusicDecoder(const char *name);
  11.213 +
  11.214 +/* Find out the music format of a mixer music, or the currently playing
  11.215 +   music, if 'music' is NULL.
  11.216 +*/
  11.217 +extern DECLSPEC Mix_MusicType SDLCALL Mix_GetMusicType(const Mix_Music *music);
  11.218 +
  11.219 +/* Set a function that is called after all mixing is performed.
  11.220 +   This can be used to provide real-time visual display of the audio stream
  11.221 +   or add a custom mixer filter for the stream data.
  11.222 +*/
  11.223 +extern DECLSPEC void SDLCALL Mix_SetPostMix(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg);
  11.224 +
  11.225 +/* Add your own music player or additional mixer function.
  11.226 +   If 'mix_func' is NULL, the default music player is re-enabled.
  11.227 + */
  11.228 +extern DECLSPEC void SDLCALL Mix_HookMusic(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg);
  11.229 +
  11.230 +/* Add your own callback for when the music has finished playing or when it is
  11.231 + * stopped from a call to Mix_HaltMusic.
  11.232 + */
  11.233 +extern DECLSPEC void SDLCALL Mix_HookMusicFinished(void (SDLCALL *music_finished)(void));
  11.234 +
  11.235 +/* Get a pointer to the user data for the current music hook */
  11.236 +extern DECLSPEC void * SDLCALL Mix_GetMusicHookData(void);
  11.237 +
  11.238 +/*
  11.239 + * Add your own callback when a channel has finished playing. NULL
  11.240 + *  to disable callback. The callback may be called from the mixer's audio
  11.241 + *  callback or it could be called as a result of Mix_HaltChannel(), etc.
  11.242 + *  do not call SDL_LockAudio() from this callback; you will either be
  11.243 + *  inside the audio callback, or SDL_mixer will explicitly lock the audio
  11.244 + *  before calling your callback.
  11.245 + */
  11.246 +extern DECLSPEC void SDLCALL Mix_ChannelFinished(void (SDLCALL *channel_finished)(int channel));
  11.247 +
  11.248 +
  11.249 +/* Special Effects API by ryan c. gordon. (icculus@icculus.org) */
  11.250 +
  11.251 +#define MIX_CHANNEL_POST  -2
  11.252 +
  11.253 +/* This is the format of a special effect callback:
  11.254 + *
  11.255 + *   myeffect(int chan, void *stream, int len, void *udata);
  11.256 + *
  11.257 + * (chan) is the channel number that your effect is affecting. (stream) is
  11.258 + *  the buffer of data to work upon. (len) is the size of (stream), and
  11.259 + *  (udata) is a user-defined bit of data, which you pass as the last arg of
  11.260 + *  Mix_RegisterEffect(), and is passed back unmolested to your callback.
  11.261 + *  Your effect changes the contents of (stream) based on whatever parameters
  11.262 + *  are significant, or just leaves it be, if you prefer. You can do whatever
  11.263 + *  you like to the buffer, though, and it will continue in its changed state
  11.264 + *  down the mixing pipeline, through any other effect functions, then finally
  11.265 + *  to be mixed with the rest of the channels and music for the final output
  11.266 + *  stream.
  11.267 + *
  11.268 + * DO NOT EVER call SDL_LockAudio() from your callback function!
  11.269 + */
  11.270 +typedef void (SDLCALL *Mix_EffectFunc_t)(int chan, void *stream, int len, void *udata);
  11.271 +
  11.272 +/*
  11.273 + * This is a callback that signifies that a channel has finished all its
  11.274 + *  loops and has completed playback. This gets called if the buffer
  11.275 + *  plays out normally, or if you call Mix_HaltChannel(), implicitly stop
  11.276 + *  a channel via Mix_AllocateChannels(), or unregister a callback while
  11.277 + *  it's still playing.
  11.278 + *
  11.279 + * DO NOT EVER call SDL_LockAudio() from your callback function!
  11.280 + */
  11.281 +typedef void (SDLCALL *Mix_EffectDone_t)(int chan, void *udata);
  11.282 +
  11.283 +
  11.284 +/* Register a special effect function. At mixing time, the channel data is
  11.285 + *  copied into a buffer and passed through each registered effect function.
  11.286 + *  After it passes through all the functions, it is mixed into the final
  11.287 + *  output stream. The copy to buffer is performed once, then each effect
  11.288 + *  function performs on the output of the previous effect. Understand that
  11.289 + *  this extra copy to a buffer is not performed if there are no effects
  11.290 + *  registered for a given chunk, which saves CPU cycles, and any given
  11.291 + *  effect will be extra cycles, too, so it is crucial that your code run
  11.292 + *  fast. Also note that the data that your function is given is in the
  11.293 + *  format of the sound device, and not the format you gave to Mix_OpenAudio(),
  11.294 + *  although they may in reality be the same. This is an unfortunate but
  11.295 + *  necessary speed concern. Use Mix_QuerySpec() to determine if you can
  11.296 + *  handle the data before you register your effect, and take appropriate
  11.297 + *  actions.
  11.298 + * You may also specify a callback (Mix_EffectDone_t) that is called when
  11.299 + *  the channel finishes playing. This gives you a more fine-grained control
  11.300 + *  than Mix_ChannelFinished(), in case you need to free effect-specific
  11.301 + *  resources, etc. If you don't need this, you can specify NULL.
  11.302 + * You may set the callbacks before or after calling Mix_PlayChannel().
  11.303 + * Things like Mix_SetPanning() are just internal special effect functions,
  11.304 + *  so if you are using that, you've already incurred the overhead of a copy
  11.305 + *  to a separate buffer, and that these effects will be in the queue with
  11.306 + *  any functions you've registered. The list of registered effects for a
  11.307 + *  channel is reset when a chunk finishes playing, so you need to explicitly
  11.308 + *  set them with each call to Mix_PlayChannel*().
  11.309 + * You may also register a special effect function that is to be run after
  11.310 + *  final mixing occurs. The rules for these callbacks are identical to those
  11.311 + *  in Mix_RegisterEffect, but they are run after all the channels and the
  11.312 + *  music have been mixed into a single stream, whereas channel-specific
  11.313 + *  effects run on a given channel before any other mixing occurs. These
  11.314 + *  global effect callbacks are call "posteffects". Posteffects only have
  11.315 + *  their Mix_EffectDone_t function called when they are unregistered (since
  11.316 + *  the main output stream is never "done" in the same sense as a channel).
  11.317 + *  You must unregister them manually when you've had enough. Your callback
  11.318 + *  will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
  11.319 + *  processing is considered a posteffect.
  11.320 + *
  11.321 + * After all these effects have finished processing, the callback registered
  11.322 + *  through Mix_SetPostMix() runs, and then the stream goes to the audio
  11.323 + *  device.
  11.324 + *
  11.325 + * DO NOT EVER call SDL_LockAudio() from your callback function!
  11.326 + *
  11.327 + * returns zero if error (no such channel), nonzero if added.
  11.328 + *  Error messages can be retrieved from Mix_GetError().
  11.329 + */
  11.330 +extern DECLSPEC int SDLCALL Mix_RegisterEffect(int chan, Mix_EffectFunc_t f, Mix_EffectDone_t d, void *arg);
  11.331 +
  11.332 +
  11.333 +/* You may not need to call this explicitly, unless you need to stop an
  11.334 + *  effect from processing in the middle of a chunk's playback.
  11.335 + * Posteffects are never implicitly unregistered as they are for channels,
  11.336 + *  but they may be explicitly unregistered through this function by
  11.337 + *  specifying MIX_CHANNEL_POST for a channel.
  11.338 + * returns zero if error (no such channel or effect), nonzero if removed.
  11.339 + *  Error messages can be retrieved from Mix_GetError().
  11.340 + */
  11.341 +extern DECLSPEC int SDLCALL Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f);
  11.342 +
  11.343 +
  11.344 +/* You may not need to call this explicitly, unless you need to stop all
  11.345 + *  effects from processing in the middle of a chunk's playback. Note that
  11.346 + *  this will also shut off some internal effect processing, since
  11.347 + *  Mix_SetPanning() and others may use this API under the hood. This is
  11.348 + *  called internally when a channel completes playback.
  11.349 + * Posteffects are never implicitly unregistered as they are for channels,
  11.350 + *  but they may be explicitly unregistered through this function by
  11.351 + *  specifying MIX_CHANNEL_POST for a channel.
  11.352 + * returns zero if error (no such channel), nonzero if all effects removed.
  11.353 + *  Error messages can be retrieved from Mix_GetError().
  11.354 + */
  11.355 +extern DECLSPEC int SDLCALL Mix_UnregisterAllEffects(int channel);
  11.356 +
  11.357 +
  11.358 +#define MIX_EFFECTSMAXSPEED  "MIX_EFFECTSMAXSPEED"
  11.359 +
  11.360 +/*
  11.361 + * These are the internally-defined mixing effects. They use the same API that
  11.362 + *  effects defined in the application use, but are provided here as a
  11.363 + *  convenience. Some effects can reduce their quality or use more memory in
  11.364 + *  the name of speed; to enable this, make sure the environment variable
  11.365 + *  MIX_EFFECTSMAXSPEED (see above) is defined before you call
  11.366 + *  Mix_OpenAudio().
  11.367 + */
  11.368 +
  11.369 +
  11.370 +/* Set the panning of a channel. The left and right channels are specified
  11.371 + *  as integers between 0 and 255, quietest to loudest, respectively.
  11.372 + *
  11.373 + * Technically, this is just individual volume control for a sample with
  11.374 + *  two (stereo) channels, so it can be used for more than just panning.
  11.375 + *  If you want real panning, call it like this:
  11.376 + *
  11.377 + *   Mix_SetPanning(channel, left, 255 - left);
  11.378 + *
  11.379 + * ...which isn't so hard.
  11.380 + *
  11.381 + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
  11.382 + *  the panning will be done to the final mixed stream before passing it on
  11.383 + *  to the audio device.
  11.384 + *
  11.385 + * This uses the Mix_RegisterEffect() API internally, and returns without
  11.386 + *  registering the effect function if the audio device is not configured
  11.387 + *  for stereo output. Setting both (left) and (right) to 255 causes this
  11.388 + *  effect to be unregistered, since that is the data's normal state.
  11.389 + *
  11.390 + * returns zero if error (no such channel or Mix_RegisterEffect() fails),
  11.391 + *  nonzero if panning effect enabled. Note that an audio device in mono
  11.392 + *  mode is a no-op, but this call will return successful in that case.
  11.393 + *  Error messages can be retrieved from Mix_GetError().
  11.394 + */
  11.395 +extern DECLSPEC int SDLCALL Mix_SetPanning(int channel, Uint8 left, Uint8 right);
  11.396 +
  11.397 +
  11.398 +/* Set the position of a channel. (angle) is an integer from 0 to 360, that
  11.399 + *  specifies the location of the sound in relation to the listener. (angle)
  11.400 + *  will be reduced as neccesary (540 becomes 180 degrees, -100 becomes 260).
  11.401 + *  Angle 0 is due north, and rotates clockwise as the value increases.
  11.402 + *  For efficiency, the precision of this effect may be limited (angles 1
  11.403 + *  through 7 might all produce the same effect, 8 through 15 are equal, etc).
  11.404 + *  (distance) is an integer between 0 and 255 that specifies the space
  11.405 + *  between the sound and the listener. The larger the number, the further
  11.406 + *  away the sound is. Using 255 does not guarantee that the channel will be
  11.407 + *  culled from the mixing process or be completely silent. For efficiency,
  11.408 + *  the precision of this effect may be limited (distance 0 through 5 might
  11.409 + *  all produce the same effect, 6 through 10 are equal, etc). Setting (angle)
  11.410 + *  and (distance) to 0 unregisters this effect, since the data would be
  11.411 + *  unchanged.
  11.412 + *
  11.413 + * If you need more precise positional audio, consider using OpenAL for
  11.414 + *  spatialized effects instead of SDL_mixer. This is only meant to be a
  11.415 + *  basic effect for simple "3D" games.
  11.416 + *
  11.417 + * If the audio device is configured for mono output, then you won't get
  11.418 + *  any effectiveness from the angle; however, distance attenuation on the
  11.419 + *  channel will still occur. While this effect will function with stereo
  11.420 + *  voices, it makes more sense to use voices with only one channel of sound,
  11.421 + *  so when they are mixed through this effect, the positioning will sound
  11.422 + *  correct. You can convert them to mono through SDL before giving them to
  11.423 + *  the mixer in the first place if you like.
  11.424 + *
  11.425 + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
  11.426 + *  the positioning will be done to the final mixed stream before passing it
  11.427 + *  on to the audio device.
  11.428 + *
  11.429 + * This is a convenience wrapper over Mix_SetDistance() and Mix_SetPanning().
  11.430 + *
  11.431 + * returns zero if error (no such channel or Mix_RegisterEffect() fails),
  11.432 + *  nonzero if position effect is enabled.
  11.433 + *  Error messages can be retrieved from Mix_GetError().
  11.434 + */
  11.435 +extern DECLSPEC int SDLCALL Mix_SetPosition(int channel, Sint16 angle, Uint8 distance);
  11.436 +
  11.437 +
  11.438 +/* Set the "distance" of a channel. (distance) is an integer from 0 to 255
  11.439 + *  that specifies the location of the sound in relation to the listener.
  11.440 + *  Distance 0 is overlapping the listener, and 255 is as far away as possible
  11.441 + *  A distance of 255 does not guarantee silence; in such a case, you might
  11.442 + *  want to try changing the chunk's volume, or just cull the sample from the
  11.443 + *  mixing process with Mix_HaltChannel().
  11.444 + * For efficiency, the precision of this effect may be limited (distances 1
  11.445 + *  through 7 might all produce the same effect, 8 through 15 are equal, etc).
  11.446 + *  (distance) is an integer between 0 and 255 that specifies the space
  11.447 + *  between the sound and the listener. The larger the number, the further
  11.448 + *  away the sound is.
  11.449 + * Setting (distance) to 0 unregisters this effect, since the data would be
  11.450 + *  unchanged.
  11.451 + * If you need more precise positional audio, consider using OpenAL for
  11.452 + *  spatialized effects instead of SDL_mixer. This is only meant to be a
  11.453 + *  basic effect for simple "3D" games.
  11.454 + *
  11.455 + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
  11.456 + *  the distance attenuation will be done to the final mixed stream before
  11.457 + *  passing it on to the audio device.
  11.458 + *
  11.459 + * This uses the Mix_RegisterEffect() API internally.
  11.460 + *
  11.461 + * returns zero if error (no such channel or Mix_RegisterEffect() fails),
  11.462 + *  nonzero if position effect is enabled.
  11.463 + *  Error messages can be retrieved from Mix_GetError().
  11.464 + */
  11.465 +extern DECLSPEC int SDLCALL Mix_SetDistance(int channel, Uint8 distance);
  11.466 +
  11.467 +
  11.468 +/*
  11.469 + * !!! FIXME : Haven't implemented, since the effect goes past the
  11.470 + *              end of the sound buffer. Will have to think about this.
  11.471 + *               --ryan.
  11.472 + */
  11.473 +#if 0
  11.474 +/* Causes an echo effect to be mixed into a sound. (echo) is the amount
  11.475 + *  of echo to mix. 0 is no echo, 255 is infinite (and probably not
  11.476 + *  what you want).
  11.477 + *
  11.478 + * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
  11.479 + *  the reverbing will be done to the final mixed stream before passing it on
  11.480 + *  to the audio device.
  11.481 + *
  11.482 + * This uses the Mix_RegisterEffect() API internally. If you specify an echo
  11.483 + *  of zero, the effect is unregistered, as the data is already in that state.
  11.484 + *
  11.485 + * returns zero if error (no such channel or Mix_RegisterEffect() fails),
  11.486 + *  nonzero if reversing effect is enabled.
  11.487 + *  Error messages can be retrieved from Mix_GetError().
  11.488 + */
  11.489 +extern no_parse_DECLSPEC int SDLCALL Mix_SetReverb(int channel, Uint8 echo);
  11.490 +#endif
  11.491 +
  11.492 +/* Causes a channel to reverse its stereo. This is handy if the user has his
  11.493 + *  speakers hooked up backwards, or you would like to have a minor bit of
  11.494 + *  psychedelia in your sound code.  :)  Calling this function with (flip)
  11.495 + *  set to non-zero reverses the chunks's usual channels. If (flip) is zero,
  11.496 + *  the effect is unregistered.
  11.497 + *
  11.498 + * This uses the Mix_RegisterEffect() API internally, and thus is probably
  11.499 + *  more CPU intensive than having the user just plug in his speakers
  11.500 + *  correctly. Mix_SetReverseStereo() returns without registering the effect
  11.501 + *  function if the audio device is not configured for stereo output.
  11.502 + *
  11.503 + * If you specify MIX_CHANNEL_POST for (channel), then this the effect is used
  11.504 + *  on the final mixed stream before sending it on to the audio device (a
  11.505 + *  posteffect).
  11.506 + *
  11.507 + * returns zero if error (no such channel or Mix_RegisterEffect() fails),
  11.508 + *  nonzero if reversing effect is enabled. Note that an audio device in mono
  11.509 + *  mode is a no-op, but this call will return successful in that case.
  11.510 + *  Error messages can be retrieved from Mix_GetError().
  11.511 + */
  11.512 +extern DECLSPEC int SDLCALL Mix_SetReverseStereo(int channel, int flip);
  11.513 +
  11.514 +/* end of effects API. --ryan. */
  11.515 +
  11.516 +
  11.517 +/* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
  11.518 +   them dynamically to the next sample if requested with a -1 value below.
  11.519 +   Returns the number of reserved channels.
  11.520 + */
  11.521 +extern DECLSPEC int SDLCALL Mix_ReserveChannels(int num);
  11.522 +
  11.523 +/* Channel grouping functions */
  11.524 +
  11.525 +/* Attach a tag to a channel. A tag can be assigned to several mixer
  11.526 +   channels, to form groups of channels.
  11.527 +   If 'tag' is -1, the tag is removed (actually -1 is the tag used to
  11.528 +   represent the group of all the channels).
  11.529 +   Returns true if everything was OK.
  11.530 + */
  11.531 +extern DECLSPEC int SDLCALL Mix_GroupChannel(int which, int tag);
  11.532 +/* Assign several consecutive channels to a group */
  11.533 +extern DECLSPEC int SDLCALL Mix_GroupChannels(int from, int to, int tag);
  11.534 +/* Finds the first available channel in a group of channels,
  11.535 +   returning -1 if none are available.
  11.536 + */
  11.537 +extern DECLSPEC int SDLCALL Mix_GroupAvailable(int tag);
  11.538 +/* Returns the number of channels in a group. This is also a subtle
  11.539 +   way to get the total number of channels when 'tag' is -1
  11.540 + */
  11.541 +extern DECLSPEC int SDLCALL Mix_GroupCount(int tag);
  11.542 +/* Finds the "oldest" sample playing in a group of channels */
  11.543 +extern DECLSPEC int SDLCALL Mix_GroupOldest(int tag);
  11.544 +/* Finds the "most recent" (i.e. last) sample playing in a group of channels */
  11.545 +extern DECLSPEC int SDLCALL Mix_GroupNewer(int tag);
  11.546 +
  11.547 +/* Play an audio chunk on a specific channel.
  11.548 +   If the specified channel is -1, play on the first free channel.
  11.549 +   If 'loops' is greater than zero, loop the sound that many times.
  11.550 +   If 'loops' is -1, loop inifinitely (~65000 times).
  11.551 +   Returns which channel was used to play the sound.
  11.552 +*/
  11.553 +#define Mix_PlayChannel(channel,chunk,loops) Mix_PlayChannelTimed(channel,chunk,loops,-1)
  11.554 +/* The same as above, but the sound is played at most 'ticks' milliseconds */
  11.555 +extern DECLSPEC int SDLCALL Mix_PlayChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ticks);
  11.556 +extern DECLSPEC int SDLCALL Mix_PlayMusic(Mix_Music *music, int loops);
  11.557 +
  11.558 +/* Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions */
  11.559 +extern DECLSPEC int SDLCALL Mix_FadeInMusic(Mix_Music *music, int loops, int ms);
  11.560 +extern DECLSPEC int SDLCALL Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position);
  11.561 +#define Mix_FadeInChannel(channel,chunk,loops,ms) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1)
  11.562 +extern DECLSPEC int SDLCALL Mix_FadeInChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ms, int ticks);
  11.563 +
  11.564 +/* Set the volume in the range of 0-128 of a specific channel or chunk.
  11.565 +   If the specified channel is -1, set volume for all channels.
  11.566 +   Returns the original volume.
  11.567 +   If the specified volume is -1, just return the current volume.
  11.568 +*/
  11.569 +extern DECLSPEC int SDLCALL Mix_Volume(int channel, int volume);
  11.570 +extern DECLSPEC int SDLCALL Mix_VolumeChunk(Mix_Chunk *chunk, int volume);
  11.571 +extern DECLSPEC int SDLCALL Mix_VolumeMusic(int volume);
  11.572 +
  11.573 +/* Halt playing of a particular channel */
  11.574 +extern DECLSPEC int SDLCALL Mix_HaltChannel(int channel);
  11.575 +extern DECLSPEC int SDLCALL Mix_HaltGroup(int tag);
  11.576 +extern DECLSPEC int SDLCALL Mix_HaltMusic(void);
  11.577 +
  11.578 +/* Change the expiration delay for a particular channel.
  11.579 +   The sample will stop playing after the 'ticks' milliseconds have elapsed,
  11.580 +   or remove the expiration if 'ticks' is -1
  11.581 +*/
  11.582 +extern DECLSPEC int SDLCALL Mix_ExpireChannel(int channel, int ticks);
  11.583 +
  11.584 +/* Halt a channel, fading it out progressively till it's silent
  11.585 +   The ms parameter indicates the number of milliseconds the fading
  11.586 +   will take.
  11.587 + */
  11.588 +extern DECLSPEC int SDLCALL Mix_FadeOutChannel(int which, int ms);
  11.589 +extern DECLSPEC int SDLCALL Mix_FadeOutGroup(int tag, int ms);
  11.590 +extern DECLSPEC int SDLCALL Mix_FadeOutMusic(int ms);
  11.591 +
  11.592 +/* Query the fading status of a channel */
  11.593 +extern DECLSPEC Mix_Fading SDLCALL Mix_FadingMusic(void);
  11.594 +extern DECLSPEC Mix_Fading SDLCALL Mix_FadingChannel(int which);
  11.595 +
  11.596 +/* Pause/Resume a particular channel */
  11.597 +extern DECLSPEC void SDLCALL Mix_Pause(int channel);
  11.598 +extern DECLSPEC void SDLCALL Mix_Resume(int channel);
  11.599 +extern DECLSPEC int SDLCALL Mix_Paused(int channel);
  11.600 +
  11.601 +/* Pause/Resume the music stream */
  11.602 +extern DECLSPEC void SDLCALL Mix_PauseMusic(void);
  11.603 +extern DECLSPEC void SDLCALL Mix_ResumeMusic(void);
  11.604 +extern DECLSPEC void SDLCALL Mix_RewindMusic(void);
  11.605 +extern DECLSPEC int SDLCALL Mix_PausedMusic(void);
  11.606 +
  11.607 +/* Set the current position in the music stream.
  11.608 +   This returns 0 if successful, or -1 if it failed or isn't implemented.
  11.609 +   This function is only implemented for MOD music formats (set pattern
  11.610 +   order number) and for OGG, FLAC, MP3_MAD, MP3_MPG and MODPLUG music
  11.611 +   (set position in seconds), at the moment.
  11.612 +*/
  11.613 +extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position);
  11.614 +
  11.615 +/* Check the status of a specific channel.
  11.616 +   If the specified channel is -1, check all channels.
  11.617 +*/
  11.618 +extern DECLSPEC int SDLCALL Mix_Playing(int channel);
  11.619 +extern DECLSPEC int SDLCALL Mix_PlayingMusic(void);
  11.620 +
  11.621 +/* Stop music and set external music playback command */
  11.622 +extern DECLSPEC int SDLCALL Mix_SetMusicCMD(const char *command);
  11.623 +
  11.624 +/* Synchro value is set by MikMod from modules while playing */
  11.625 +extern DECLSPEC int SDLCALL Mix_SetSynchroValue(int value);
  11.626 +extern DECLSPEC int SDLCALL Mix_GetSynchroValue(void);
  11.627 +
  11.628 +/* Set/Get/Iterate SoundFonts paths to use by supported MIDI backends */
  11.629 +extern DECLSPEC int SDLCALL Mix_SetSoundFonts(const char *paths);
  11.630 +extern DECLSPEC const char* SDLCALL Mix_GetSoundFonts(void);
  11.631 +extern DECLSPEC int SDLCALL Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data);
  11.632 +
  11.633 +/* Get the Mix_Chunk currently associated with a mixer channel
  11.634 +    Returns NULL if it's an invalid channel, or there's no chunk associated.
  11.635 +*/
  11.636 +extern DECLSPEC Mix_Chunk * SDLCALL Mix_GetChunk(int channel);
  11.637 +
  11.638 +/* Close the mixer, halting all playing audio */
  11.639 +extern DECLSPEC void SDLCALL Mix_CloseAudio(void);
  11.640 +
  11.641 +/* We'll use SDL for reporting errors */
  11.642 +#define Mix_SetError    SDL_SetError
  11.643 +#define Mix_GetError    SDL_GetError
  11.644 +#define Mix_ClearError  SDL_ClearError
  11.645 +
  11.646 +/* Ends C function definitions when using C++ */
  11.647 +#ifdef __cplusplus
  11.648 +}
  11.649 +#endif
  11.650 +#include "close_code.h"
  11.651 +
  11.652 +#endif /* SDL_MIXER_H_ */
  11.653 +
  11.654 +/* vi: set ts=4 sw=4 expandtab: */
    12.1 --- a/load_aiff.c	Mon Nov 18 18:50:50 2019 +0300
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,247 +0,0 @@
    12.4 -/*
    12.5 -  SDL_mixer:  An audio mixer library based on the SDL library
    12.6 -  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
    12.7 -
    12.8 -  This software is provided 'as-is', without any express or implied
    12.9 -  warranty.  In no event will the authors be held liable for any damages
   12.10 -  arising from the use of this software.
   12.11 -
   12.12 -  Permission is granted to anyone to use this software for any purpose,
   12.13 -  including commercial applications, and to alter it and redistribute it
   12.14 -  freely, subject to the following restrictions:
   12.15 -
   12.16 -  1. The origin of this software must not be misrepresented; you must not
   12.17 -     claim that you wrote the original software. If you use this software
   12.18 -     in a product, an acknowledgment in the product documentation would be
   12.19 -     appreciated but is not required.
   12.20 -  2. Altered source versions must be plainly marked as such, and must not be
   12.21 -     misrepresented as being the original software.
   12.22 -  3. This notice may not be removed or altered from any source distribution.
   12.23 -
   12.24 -  This is the source needed to decode an AIFF file into a waveform.
   12.25 -  It's pretty straightforward once you get going. The only
   12.26 -  externally-callable function is Mix_LoadAIFF_RW(), which is meant to
   12.27 -  act as identically to SDL_LoadWAV_RW() as possible.
   12.28 -
   12.29 -  This file by Torbjörn Andersson (torbjorn.andersson@eurotime.se)
   12.30 -  8SVX file support added by Marc Le Douarain (mavati@club-internet.fr)
   12.31 -  in december 2002.
   12.32 -*/
   12.33 -
   12.34 -#include "SDL_endian.h"
   12.35 -#include "SDL_mixer.h"
   12.36 -#include "load_aiff.h"
   12.37 -
   12.38 -/*********************************************/
   12.39 -/* Define values for AIFF (IFF audio) format */
   12.40 -/*********************************************/
   12.41 -#define FORM        0x4d524f46      /* "FORM" */
   12.42 -
   12.43 -#define AIFF        0x46464941      /* "AIFF" */
   12.44 -#define SSND        0x444e5353      /* "SSND" */
   12.45 -#define COMM        0x4d4d4f43      /* "COMM" */
   12.46 -
   12.47 -#define _8SVX       0x58565338      /* "8SVX" */
   12.48 -#define VHDR        0x52444856      /* "VHDR" */
   12.49 -#define BODY        0x59444F42      /* "BODY" */
   12.50 -
   12.51 -/* This function was taken from libsndfile. I don't pretend to fully
   12.52 - * understand it.
   12.53 - */
   12.54 -
   12.55 -static Uint32 SANE_to_Uint32 (Uint8 *sanebuf)
   12.56 -{
   12.57 -    /* Is the frequency outside of what we can represent with Uint32? */
   12.58 -    if ((sanebuf[0] & 0x80) || (sanebuf[0] <= 0x3F) || (sanebuf[0] > 0x40)
   12.59 -        || (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C))
   12.60 -        return 0;
   12.61 -
   12.62 -    return ((sanebuf[2] << 23) | (sanebuf[3] << 15) | (sanebuf[4] << 7)
   12.63 -        | (sanebuf[5] >> 1)) >> (29 - sanebuf[1]);
   12.64 -}
   12.65 -
   12.66 -/* This function is based on SDL_LoadWAV_RW(). */
   12.67 -
   12.68 -SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc,
   12.69 -    SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
   12.70 -{
   12.71 -    int was_error;
   12.72 -    int found_SSND;
   12.73 -    int found_COMM;
   12.74 -    int found_VHDR;
   12.75 -    int found_BODY;
   12.76 -    Sint64 start = 0;
   12.77 -
   12.78 -    Uint32 chunk_type;
   12.79 -    Uint32 chunk_length;
   12.80 -    Sint64 next_chunk;
   12.81 -
   12.82 -    /* AIFF magic header */
   12.83 -    Uint32 FORMchunk;
   12.84 -    Uint32 AIFFmagic;
   12.85 -
   12.86 -    /* SSND chunk */
   12.87 -    Uint32 offset;
   12.88 -    Uint32 blocksize;
   12.89 -
   12.90 -    /* COMM format chunk */
   12.91 -    Uint16 channels = 0;
   12.92 -    Uint32 numsamples = 0;
   12.93 -    Uint16 samplesize = 0;
   12.94 -    Uint8 sane_freq[10];
   12.95 -    Uint32 frequency = 0;
   12.96 -
   12.97 -    /* Make sure we are passed a valid data source */
   12.98 -    was_error = 0;
   12.99 -    if (src == NULL) {
  12.100 -        was_error = 1;
  12.101 -        goto done;
  12.102 -    }
  12.103 -
  12.104 -    FORMchunk   = SDL_ReadLE32(src);
  12.105 -    chunk_length    = SDL_ReadBE32(src);
  12.106 -    if (chunk_length == AIFF) { /* The FORMchunk has already been read */
  12.107 -        AIFFmagic    = chunk_length;
  12.108 -        chunk_length = FORMchunk;
  12.109 -        FORMchunk    = FORM;
  12.110 -    } else {
  12.111 -        AIFFmagic    = SDL_ReadLE32(src);
  12.112 -    }
  12.113 -    if ((FORMchunk != FORM) || ((AIFFmagic != AIFF) && (AIFFmagic != _8SVX))) {
  12.114 -        SDL_SetError("Unrecognized file type (not AIFF nor 8SVX)");
  12.115 -        was_error = 1;
  12.116 -        goto done;
  12.117 -    }
  12.118 -
  12.119 -    /* TODO: Better santity-checking. */
  12.120 -
  12.121 -    found_SSND = 0;
  12.122 -    found_COMM = 0;
  12.123 -    found_VHDR = 0;
  12.124 -    found_BODY = 0;
  12.125 -
  12.126 -    do {
  12.127 -        chunk_type  = SDL_ReadLE32(src);
  12.128 -        chunk_length = SDL_ReadBE32(src);
  12.129 -        next_chunk  = SDL_RWtell(src) + chunk_length;
  12.130 -        /* Paranoia to avoid infinite loops */
  12.131 -        if (chunk_length == 0)
  12.132 -            break;
  12.133 -
  12.134 -        switch (chunk_type) {
  12.135 -            case SSND:
  12.136 -                found_SSND  = 1;
  12.137 -                offset      = SDL_ReadBE32(src);
  12.138 -                blocksize   = SDL_ReadBE32(src);
  12.139 -                start       = SDL_RWtell(src) + offset;
  12.140 -                (void)blocksize; /* unused. */
  12.141 -                break;
  12.142 -
  12.143 -            case COMM:
  12.144 -                found_COMM  = 1;
  12.145 -                channels    = SDL_ReadBE16(src);
  12.146 -                numsamples  = SDL_ReadBE32(src);
  12.147 -                samplesize  = SDL_ReadBE16(src);
  12.148 -                SDL_RWread(src, sane_freq, sizeof(sane_freq), 1);
  12.149 -                frequency   = SANE_to_Uint32(sane_freq);
  12.150 -                if (frequency == 0) {
  12.151 -                    SDL_SetError("Bad AIFF sample frequency");
  12.152 -                    was_error = 1;
  12.153 -                    goto done;
  12.154 -                }
  12.155 -                break;
  12.156 -
  12.157 -            case VHDR:
  12.158 -                found_VHDR  = 1;
  12.159 -                SDL_ReadBE32(src);
  12.160 -                SDL_ReadBE32(src);
  12.161 -                SDL_ReadBE32(src);
  12.162 -                frequency = SDL_ReadBE16(src);
  12.163 -                channels = 1;
  12.164 -                samplesize = 8;
  12.165 -                break;
  12.166 -
  12.167 -            case BODY:
  12.168 -                found_BODY  = 1;
  12.169 -                numsamples  = chunk_length;
  12.170 -                start       = SDL_RWtell(src);
  12.171 -                break;
  12.172 -
  12.173 -            default:
  12.174 -                break;
  12.175 -        }
  12.176 -        /* a 0 pad byte can be stored for any odd-length chunk */
  12.177 -        if (chunk_length&1)
  12.178 -            next_chunk++;
  12.179 -    } while ((((AIFFmagic == AIFF) && (!found_SSND || !found_COMM))
  12.180 -          || ((AIFFmagic == _8SVX) && (!found_VHDR || !found_BODY)))
  12.181 -          && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != 1);
  12.182 -
  12.183 -    if ((AIFFmagic == AIFF) && !found_SSND) {
  12.184 -        SDL_SetError("Bad AIFF (no SSND chunk)");
  12.185 -        was_error = 1;
  12.186 -        goto done;
  12.187 -    }
  12.188 -
  12.189 -    if ((AIFFmagic == AIFF) && !found_COMM) {
  12.190 -        SDL_SetError("Bad AIFF (no COMM chunk)");
  12.191 -        was_error = 1;
  12.192 -        goto done;
  12.193 -    }
  12.194 -
  12.195 -    if ((AIFFmagic == _8SVX) && !found_VHDR) {
  12.196 -        SDL_SetError("Bad 8SVX (no VHDR chunk)");
  12.197 -        was_error = 1;
  12.198 -        goto done;
  12.199 -    }
  12.200 -
  12.201 -    if ((AIFFmagic == _8SVX) && !found_BODY) {
  12.202 -        SDL_SetError("Bad 8SVX (no BODY chunk)");
  12.203 -        was_error = 1;
  12.204 -        goto done;
  12.205 -    }
  12.206 -
  12.207 -    /* Decode the audio data format */
  12.208 -    SDL_memset(spec, 0, sizeof(*spec));
  12.209 -    spec->freq = frequency;
  12.210 -    switch (samplesize) {
  12.211 -        case 8:
  12.212 -            spec->format = AUDIO_S8;
  12.213 -            break;
  12.214 -        case 16:
  12.215 -            spec->format = AUDIO_S16MSB;
  12.216 -            break;
  12.217 -        default:
  12.218 -            SDL_SetError("Unsupported AIFF samplesize");
  12.219 -            was_error = 1;
  12.220 -            goto done;
  12.221 -    }
  12.222 -    spec->channels = (Uint8) channels;
  12.223 -    spec->samples = 4096;       /* Good default buffer size */
  12.224 -
  12.225 -    *audio_len = channels * numsamples * (samplesize / 8);
  12.226 -    *audio_buf = (Uint8 *)SDL_malloc(*audio_len);
  12.227 -    if (*audio_buf == NULL) {
  12.228 -        SDL_SetError("Out of memory");
  12.229 -        return(NULL);
  12.230 -    }
  12.231 -    SDL_RWseek(src, start, RW_SEEK_SET);
  12.232 -    if (SDL_RWread(src, *audio_buf, *audio_len, 1) != 1) {
  12.233 -        SDL_SetError("Unable to read audio data");
  12.234 -        return(NULL);
  12.235 -    }
  12.236 -
  12.237 -    /* Don't return a buffer that isn't a multiple of samplesize */
  12.238 -    *audio_len &= ~((samplesize / 8) - 1);
  12.239 -
  12.240 -done:
  12.241 -    if (freesrc && src) {
  12.242 -        SDL_RWclose(src);
  12.243 -    }
  12.244 -    if (was_error) {
  12.245 -        spec = NULL;
  12.246 -    }
  12.247 -    return(spec);
  12.248 -}
  12.249 -
  12.250 -/* vi: set ts=4 sw=4 expandtab: */
    13.1 --- a/load_aiff.h	Mon Nov 18 18:50:50 2019 +0300
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,33 +0,0 @@
    13.4 -/*
    13.5 -  SDL_mixer:  An audio mixer library based on the SDL library
    13.6 -  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
    13.7 -
    13.8 -  This software is provided 'as-is', without any express or implied
    13.9 -  warranty.  In no event will the authors be held liable for any damages
   13.10 -  arising from the use of this software.
   13.11 -
   13.12 -  Permission is granted to anyone to use this software for any purpose,
   13.13 -  including commercial applications, and to alter it and redistribute it
   13.14 -  freely, subject to the following restrictions:
   13.15 -
   13.16 -  1. The origin of this software must not be misrepresented; you must not
   13.17 -     claim that you wrote the original software. If you use this software
   13.18 -     in a product, an acknowledgment in the product documentation would be
   13.19 -     appreciated but is not required.
   13.20 -  2. Altered source versions must be plainly marked as such, and must not be
   13.21 -     misrepresented as being the original software.
   13.22 -  3. This notice may not be removed or altered from any source distribution.
   13.23 -
   13.24 -    This is the source needed to decode an AIFF file into a waveform.
   13.25 -    It's pretty straightforward once you get going. The only
   13.26 -    externally-callable function is Mix_LoadAIFF_RW(), which is meant to
   13.27 -    act as identically to SDL_LoadWAV_RW() as possible.
   13.28 -
   13.29 -    This file by Torbjörn Andersson (torbjorn.andersson@eurotime.se)
   13.30 -*/
   13.31 -
   13.32 -/* Don't call this directly; use Mix_LoadWAV_RW() for now. */
   13.33 -SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc,
   13.34 -    SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
   13.35 -
   13.36 -/* vi: set ts=4 sw=4 expandtab: */
    14.1 --- a/load_voc.c	Mon Nov 18 18:50:50 2019 +0300
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,452 +0,0 @@
    14.4 -/*
    14.5 -  SDL_mixer:  An audio mixer library based on the SDL library
    14.6 -  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
    14.7 -
    14.8 -  This software is provided 'as-is', without any express or implied
    14.9 -  warranty.  In no event will the authors be held liable for any damages
   14.10 -  arising from the use of this software.
   14.11 -
   14.12 -  Permission is granted to anyone to use this software for any purpose,
   14.13 -  including commercial applications, and to alter it and redistribute it
   14.14 -  freely, subject to the following restrictions:
   14.15 -
   14.16 -  1. The origin of this software must not be misrepresented; you must not
   14.17 -     claim that you wrote the original software. If you use this software
   14.18 -     in a product, an acknowledgment in the product documentation would be
   14.19 -     appreciated but is not required.
   14.20 -  2. Altered source versions must be plainly marked as such, and must not be
   14.21 -     misrepresented as being the original software.
   14.22 -  3. This notice may not be removed or altered from any source distribution.
   14.23 -
   14.24 -  This is the source needed to decode a Creative Labs VOC file into a
   14.25 -  waveform. It's pretty straightforward once you get going. The only
   14.26 -  externally-callable function is Mix_LoadVOC_RW(), which is meant to
   14.27 -  act as identically to SDL_LoadWAV_RW() as possible.
   14.28 -
   14.29 -  This file by Ryan C. Gordon (icculus@icculus.org).
   14.30 -
   14.31 -  Heavily borrowed from sox v12.17.1's voc.c.
   14.32 -        (http://www.freshmeat.net/projects/sox/)
   14.33 -*/
   14.34 -
   14.35 -#include "SDL_mixer.h"
   14.36 -#include "load_voc.h"
   14.37 -
   14.38 -/* Private data for VOC file */
   14.39 -typedef struct vocstuff {
   14.40 -    Uint32  rest;           /* bytes remaining in current block */
   14.41 -    Uint32  rate;           /* rate code (byte) of this chunk */
   14.42 -    int     silent;         /* sound or silence? */
   14.43 -    Uint32  srate;          /* rate code (byte) of silence */
   14.44 -    Uint32  blockseek;      /* start of current output block */
   14.45 -    Uint32  samples;        /* number of samples output */
   14.46 -    Uint32  size;           /* word length of data */
   14.47 -    Uint8   channels;       /* number of sound channels */
   14.48 -    int     has_extended;   /* Has an extended block been read? */
   14.49 -} vs_t;
   14.50 -
   14.51 -/* Size field */
   14.52 -/* SJB: note that the 1st 3 are sometimes used as sizeof(type) */
   14.53 -#define ST_SIZE_BYTE    1
   14.54 -#define ST_SIZE_8BIT    1
   14.55 -#define ST_SIZE_WORD    2
   14.56 -#define ST_SIZE_16BIT   2
   14.57 -#define ST_SIZE_DWORD   4
   14.58 -#define ST_SIZE_32BIT   4
   14.59 -#define ST_SIZE_FLOAT   5
   14.60 -#define ST_SIZE_DOUBLE  6
   14.61 -#define ST_SIZE_IEEE    7   /* IEEE 80-bit floats. */
   14.62 -
   14.63 -/* Style field */
   14.64 -#define ST_ENCODING_UNSIGNED    1 /* unsigned linear: Sound Blaster */
   14.65 -#define ST_ENCODING_SIGN2       2 /* signed linear 2's comp: Mac */
   14.66 -#define ST_ENCODING_ULAW        3 /* U-law signed logs: US telephony, SPARC */
   14.67 -#define ST_ENCODING_ALAW        4 /* A-law signed logs: non-US telephony */
   14.68 -#define ST_ENCODING_ADPCM       5 /* Compressed PCM */
   14.69 -#define ST_ENCODING_IMA_ADPCM   6 /* Compressed PCM */
   14.70 -#define ST_ENCODING_GSM         7 /* GSM 6.10 33-byte frame lossy compression */
   14.71 -
   14.72 -#define VOC_TERM        0
   14.73 -#define VOC_DATA        1
   14.74 -#define VOC_CONT        2
   14.75 -#define VOC_SILENCE     3
   14.76 -#define VOC_MARKER      4
   14.77 -#define VOC_TEXT        5
   14.78 -#define VOC_LOOP        6
   14.79 -#define VOC_LOOPEND     7
   14.80 -#define VOC_EXTENDED    8
   14.81 -#define VOC_DATA_16     9
   14.82 -
   14.83 -#define VOC_BAD_RATE  ~((Uint32)0)
   14.84 -
   14.85 -
   14.86 -static int voc_check_header(SDL_RWops *src)
   14.87 -{
   14.88 -    /* VOC magic header */
   14.89 -    Uint8  signature[20];  /* "Creative Voice File\032" */
   14.90 -    Uint16 datablockofs;
   14.91 -
   14.92 -    SDL_RWseek(src, 0, RW_SEEK_SET);
   14.93 -
   14.94 -    if (SDL_RWread(src, signature, sizeof (signature), 1) != 1)
   14.95 -        return(0);
   14.96 -
   14.97 -    if (SDL_memcmp(signature, "Creative Voice File\032", sizeof (signature)) != 0) {
   14.98 -        SDL_SetError("Unrecognized file type (not VOC)");
   14.99 -        return(0);
  14.100 -    }
  14.101 -
  14.102 -        /* get the offset where the first datablock is located */
  14.103 -    if (SDL_RWread(src, &datablockofs, sizeof (Uint16), 1) != 1)
  14.104 -        return(0);
  14.105 -
  14.106 -    datablockofs = SDL_SwapLE16(datablockofs);
  14.107 -
  14.108 -    if (SDL_RWseek(src, datablockofs, RW_SEEK_SET) != datablockofs)
  14.109 -        return(0);
  14.110 -
  14.111 -    return(1);  /* success! */
  14.112 -} /* voc_check_header */
  14.113 -
  14.114 -
  14.115 -/* Read next block header, save info, leave position at start of data */
  14.116 -static int voc_get_block(SDL_RWops *src, vs_t *v, SDL_AudioSpec *spec)
  14.117 -{
  14.118 -    Uint8 bits24[3];
  14.119 -    Uint8 uc, block;
  14.120 -    Uint32 sblen;
  14.121 -    Uint16 new_rate_short;
  14.122 -    Uint32 new_rate_long;
  14.123 -    Uint8 trash[6];
  14.124 -    Uint16 period;
  14.125 -    unsigned int i;
  14.126 -
  14.127 -    v->silent = 0;
  14.128 -    while (v->rest == 0)
  14.129 -    {
  14.130 -        if (SDL_RWread(src, &block, sizeof (block), 1) != 1)
  14.131 -            return 1;  /* assume that's the end of the file. */
  14.132 -
  14.133 -        if (block == VOC_TERM)
  14.134 -            return 1;
  14.135 -
  14.136 -        if (SDL_RWread(src, bits24, sizeof (bits24), 1) != 1)
  14.137 -            return 1;  /* assume that's the end of the file. */
  14.138 -
  14.139 -        /* Size is an 24-bit value. Ugh. */
  14.140 -        sblen = (Uint32)((bits24[0]) | (bits24[1] << 8) | (bits24[2] << 16));
  14.141 -
  14.142 -        switch(block)
  14.143 -        {
  14.144 -            case VOC_DATA:
  14.145 -                if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
  14.146 -                    return 0;
  14.147 -
  14.148 -                /* When DATA block preceeded by an EXTENDED     */
  14.149 -                /* block, the DATA blocks rate value is invalid */
  14.150 -                if (!v->has_extended)
  14.151 -                {
  14.152 -                    if (uc == 0)
  14.153 -                    {
  14.154 -                        SDL_SetError("VOC Sample rate is zero?");
  14.155 -                        return 0;
  14.156 -                    }
  14.157 -
  14.158 -                    if ((v->rate != VOC_BAD_RATE) && (uc != v->rate))
  14.159 -                    {
  14.160 -                        SDL_SetError("VOC sample rate codes differ");
  14.161 -                        return 0;
  14.162 -                    }
  14.163 -
  14.164 -                    v->rate = uc;
  14.165 -                    spec->freq = (Uint16)(1000000.0/(256 - v->rate));
  14.166 -                    v->channels = 1;
  14.167 -                }
  14.168 -
  14.169 -                if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
  14.170 -                    return 0;
  14.171 -
  14.172 -                if (uc != 0)
  14.173 -                {
  14.174 -                    SDL_SetError("VOC decoder only interprets 8-bit data");
  14.175 -                    return 0;
  14.176 -                }
  14.177 -
  14.178 -                v->has_extended = 0;
  14.179 -                v->rest = sblen - 2;
  14.180 -                v->size = ST_SIZE_BYTE;
  14.181 -                return 1;
  14.182 -
  14.183 -            case VOC_DATA_16:
  14.184 -                if (SDL_RWread(src, &new_rate_long, sizeof (new_rate_long), 1) != 1)
  14.185 -                    return 0;
  14.186 -                new_rate_long = SDL_SwapLE32(new_rate_long);
  14.187 -                if (new_rate_long == 0)
  14.188 -                {
  14.189 -                    SDL_SetError("VOC Sample rate is zero?");
  14.190 -                    return 0;
  14.191 -                }
  14.192 -                if ((v->rate != VOC_BAD_RATE) && (new_rate_long != v->rate))
  14.193 -                {
  14.194 -                    SDL_SetError("VOC sample rate codes differ");
  14.195 -                    return 0;
  14.196 -                }
  14.197 -                v->rate = new_rate_long;
  14.198 -                spec->freq = (int)new_rate_long;
  14.199 -
  14.200 -                if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
  14.201 -                    return 0;
  14.202 -
  14.203 -                switch (uc)
  14.204 -                {
  14.205 -                    case 8:  v->size = ST_SIZE_BYTE; break;
  14.206 -                    case 16: v->size = ST_SIZE_WORD; break;
  14.207 -                    default:
  14.208 -                        SDL_SetError("VOC with unknown data size");
  14.209 -                        return 0;
  14.210 -                }
  14.211 -
  14.212 -                if (SDL_RWread(src, &v->channels, sizeof (Uint8), 1) != 1)
  14.213 -                    return 0;
  14.214 -
  14.215 -                if (SDL_RWread(src, trash, sizeof (Uint8), 6) != 6)
  14.216 -                    return 0;
  14.217 -
  14.218 -                v->rest = sblen - 12;
  14.219 -                return 1;
  14.220 -
  14.221 -            case VOC_CONT:
  14.222 -                v->rest = sblen;
  14.223 -                return 1;
  14.224 -
  14.225 -            case VOC_SILENCE:
  14.226 -                if (SDL_RWread(src, &period, sizeof (period), 1) != 1)
  14.227 -                    return 0;
  14.228 -                period = SDL_SwapLE16(period);
  14.229 -
  14.230 -                if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
  14.231 -                    return 0;
  14.232 -                if (uc == 0)
  14.233 -                {
  14.234 -                    SDL_SetError("VOC silence sample rate is zero");
  14.235 -                    return 0;
  14.236 -                }
  14.237 -
  14.238 -                /*
  14.239 -                 * Some silence-packed files have gratuitously
  14.240 -                 * different sample rate codes in silence.
  14.241 -                 * Adjust period.
  14.242 -                 */
  14.243 -                if ((v->rate != VOC_BAD_RATE) && (uc != v->rate))
  14.244 -                    period = (Uint16)((period * (256 - uc))/(256 - v->rate));
  14.245 -                else
  14.246 -                    v->rate = uc;
  14.247 -                v->rest = period;
  14.248 -                v->silent = 1;
  14.249 -                return 1;
  14.250 -
  14.251 -            case VOC_LOOP:
  14.252 -            case VOC_LOOPEND:
  14.253 -                for(i = 0; i < sblen; i++)   /* skip repeat loops. */
  14.254 -                {
  14.255 -                    if (SDL_RWread(src, trash, sizeof (Uint8), 1) != 1)
  14.256 -                        return 0;
  14.257 -                }
  14.258 -                break;
  14.259 -
  14.260 -            case VOC_EXTENDED:
  14.261 -                /* An Extended block is followed by a data block */
  14.262 -                /* Set this byte so we know to use the rate      */
  14.263 -                /* value from the extended block and not the     */
  14.264 -                /* data block.                     */
  14.265 -                v->has_extended = 1;
  14.266 -                if (SDL_RWread(src, &new_rate_short, sizeof (new_rate_short), 1) != 1)
  14.267 -                    return 0;
  14.268 -                new_rate_short = SDL_SwapLE16(new_rate_short);
  14.269 -                if (new_rate_short == 0)
  14.270 -                {
  14.271 -                   SDL_SetError("VOC sample rate is zero");
  14.272 -                   return 0;
  14.273 -                }
  14.274 -                if ((v->rate != VOC_BAD_RATE) && (new_rate_short != v->rate))
  14.275 -                {
  14.276 -                   SDL_SetError("VOC sample rate codes differ");
  14.277 -                   return 0;
  14.278 -                }
  14.279 -                v->rate = new_rate_short;
  14.280 -
  14.281 -                if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
  14.282 -                    return 0;
  14.283 -
  14.284 -                if (uc != 0)
  14.285 -                {
  14.286 -                    SDL_SetError("VOC decoder only interprets 8-bit data");
  14.287 -                    return 0;
  14.288 -                }
  14.289 -
  14.290 -                if (SDL_RWread(src, &uc, sizeof (uc), 1) != 1)
  14.291 -                    return 0;
  14.292 -
  14.293 -                if (uc)
  14.294 -                    spec->channels = 2;  /* Stereo */
  14.295 -                /* Needed number of channels before finishing
  14.296 -                   compute for rate */
  14.297 -                spec->freq = (256000000L/(65536L - v->rate))/spec->channels;
  14.298 -                /* An extended block must be followed by a data */
  14.299 -                /* block to be valid so loop back to top so it  */
  14.300 -                /* can be grabed.                */
  14.301 -                continue;
  14.302 -
  14.303 -            case VOC_MARKER:
  14.304 -                if (SDL_RWread(src, trash, sizeof (Uint8), 2) != 2)
  14.305 -                    return 0;
  14.306 -
  14.307 -                /* Falling! Falling! */
  14.308 -
  14.309 -            default:  /* text block or other krapola. */
  14.310 -                for(i = 0; i < sblen; i++)
  14.311 -                {
  14.312 -                    if (SDL_RWread(src, &trash, sizeof (Uint8), 1) != 1)
  14.313 -                        return 0;
  14.314 -                }
  14.315 -
  14.316 -                if (block == VOC_TEXT)
  14.317 -                    continue;    /* get next block */
  14.318 -        }
  14.319 -    }
  14.320 -
  14.321 -    return 1;
  14.322 -}
  14.323 -
  14.324 -
  14.325 -static Uint32 voc_read(SDL_RWops *src, vs_t *v, Uint8 *buf, SDL_AudioSpec *spec)
  14.326 -{
  14.327 -    Uint32 done = 0;
  14.328 -    Uint8 silence = 0x80;
  14.329 -
  14.330 -    if (v->rest == 0)
  14.331 -    {
  14.332 -        if (!voc_get_block(src, v, spec))
  14.333 -            return 0;
  14.334 -    }
  14.335 -
  14.336 -    if (v->rest == 0)
  14.337 -        return 0;
  14.338 -
  14.339 -    if (v->silent)
  14.340 -    {
  14.341 -        if (v->size == ST_SIZE_WORD)
  14.342 -            silence = 0x00;
  14.343 -
  14.344 -        /* Fill in silence */
  14.345 -        SDL_memset(buf, silence, v->rest);
  14.346 -        done = v->rest;
  14.347 -        v->rest = 0;
  14.348 -    }
  14.349 -
  14.350 -    else
  14.351 -    {
  14.352 -        done = (Uint32)SDL_RWread(src, buf, 1, v->rest);
  14.353 -        v->rest -= done;
  14.354 -        if (v->size == ST_SIZE_WORD)
  14.355 -        {
  14.356 -            #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
  14.357 -                Uint16 *samples = (Uint16 *)buf;
  14.358 -                for (; v->rest > 0; v->rest -= 2)
  14.359 -                {
  14.360 -                    *samples = SDL_SwapLE16(*samples);
  14.361 -                    samples++;
  14.362 -                }
  14.363 -            #endif
  14.364 -            done >>= 1;
  14.365 -        }
  14.366 -    }
  14.367 -
  14.368 -    return done;
  14.369 -} /* voc_read */
  14.370 -
  14.371 -
  14.372 -/* don't call this directly; use Mix_LoadWAV_RW() for now. */
  14.373 -SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc,
  14.374 -        SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
  14.375 -{
  14.376 -    vs_t v;
  14.377 -    int was_error = 1;
  14.378 -    int samplesize;
  14.379 -    Uint8 *fillptr;
  14.380 -    void *ptr;
  14.381 -
  14.382 -    if ((!src) || (!audio_buf) || (!audio_len))   /* sanity checks. */
  14.383 -        goto done;
  14.384 -
  14.385 -    if (!voc_check_header(src))
  14.386 -        goto done;
  14.387 -
  14.388 -    v.rate = VOC_BAD_RATE;
  14.389 -    v.rest = 0;
  14.390 -    v.has_extended = 0;
  14.391 -    *audio_buf = NULL;
  14.392 -    *audio_len = 0;
  14.393 -    SDL_memset(spec, '\0', sizeof (SDL_AudioSpec));
  14.394 -
  14.395 -    if (!voc_get_block(src, &v, spec))
  14.396 -        goto done;
  14.397 -
  14.398 -    if (v.rate == VOC_BAD_RATE) {
  14.399 -        SDL_SetError("VOC data had no sound!");
  14.400 -        goto done;
  14.401 -    }
  14.402 -
  14.403 -    spec->format = ((v.size == ST_SIZE_WORD) ? AUDIO_S16 : AUDIO_U8);
  14.404 -    if (spec->channels == 0)
  14.405 -        spec->channels = v.channels;
  14.406 -
  14.407 -    *audio_len = v.rest;
  14.408 -    *audio_buf = SDL_malloc(v.rest);
  14.409 -    if (*audio_buf == NULL)
  14.410 -        goto done;
  14.411 -
  14.412 -    fillptr = *audio_buf;
  14.413 -
  14.414 -    while (voc_read(src, &v, fillptr, spec))
  14.415 -    {
  14.416 -        if (!voc_get_block(src, &v, spec))
  14.417 -            goto done;
  14.418 -
  14.419 -        *audio_len += v.rest;
  14.420 -        ptr = SDL_realloc(*audio_buf, *audio_len);
  14.421 -        if (ptr == NULL)
  14.422 -        {
  14.423 -            SDL_free(*audio_buf);
  14.424 -            *audio_buf = NULL;
  14.425 -            *audio_len = 0;
  14.426 -            goto done;
  14.427 -        }
  14.428 -
  14.429 -        *audio_buf = ptr;
  14.430 -        fillptr = ((Uint8 *) ptr) + (*audio_len - v.rest);
  14.431 -    }
  14.432 -
  14.433 -    spec->samples = (Uint16)(*audio_len / v.size);
  14.434 -
  14.435 -    was_error = 0;  /* success, baby! */
  14.436 -
  14.437 -    /* Don't return a buffer that isn't a multiple of samplesize */
  14.438 -    samplesize = ((spec->format & 0xFF)/8)*spec->channels;
  14.439 -    *audio_len &= (Uint32) ~(samplesize-1);
  14.440 -
  14.441 -done:
  14.442 -    if (freesrc && src) {
  14.443 -        SDL_RWclose(src);
  14.444 -    }
  14.445 -
  14.446 -    if (was_error) {
  14.447 -        spec = NULL;
  14.448 -    }
  14.449 -
  14.450 -    return(spec);
  14.451 -} /* Mix_LoadVOC_RW */
  14.452 -
  14.453 -/* end of load_voc.c ... */
  14.454 -
  14.455 -/* vi: set ts=4 sw=4 expandtab: */
    15.1 --- a/load_voc.h	Mon Nov 18 18:50:50 2019 +0300
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,36 +0,0 @@
    15.4 -/*
    15.5 -  SDL_mixer:  An audio mixer library based on the SDL library
    15.6 -  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
    15.7 -
    15.8 -  This software is provided 'as-is', without any express or implied
    15.9 -  warranty.  In no event will the authors be held liable for any damages
   15.10 -  arising from the use of this software.
   15.11 -
   15.12 -  Permission is granted to anyone to use this software for any purpose,
   15.13 -  including commercial applications, and to alter it and redistribute it
   15.14 -  freely, subject to the following restrictions:
   15.15 -
   15.16 -  1. The origin of this software must not be misrepresented; you must not
   15.17 -     claim that you wrote the original software. If you use this software
   15.18 -     in a product, an acknowledgment in the product documentation would be
   15.19 -     appreciated but is not required.
   15.20 -  2. Altered source versions must be plainly marked as such, and must not be
   15.21 -     misrepresented as being the original software.
   15.22 -  3. This notice may not be removed or altered from any source distribution.
   15.23 -
   15.24 -  This is the source needed to decode a Creative Labs VOC file into a
   15.25 -  waveform. It's pretty straightforward once you get going. The only
   15.26 -  externally-callable function is Mix_LoadVOC_RW(), which is meant to
   15.27 -  act as identically to SDL_LoadWAV_RW() as possible.
   15.28 -
   15.29 -  This file by Ryan C. Gordon (icculus@icculus.org).
   15.30 -
   15.31 -  Heavily borrowed from sox v12.17.1's voc.c.
   15.32 -        (http://www.freshmeat.net/projects/sox/)
   15.33 -*/
   15.34 -
   15.35 -/* Don't call this directly; use Mix_LoadWAV_RW() for now. */
   15.36 -SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc,
   15.37 -        SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
   15.38 -
   15.39 -/* vi: set ts=4 sw=4 expandtab: */
    16.1 --- a/mixer.c	Mon Nov 18 18:50:50 2019 +0300
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,1617 +0,0 @@
    16.4 -/*
    16.5 -  SDL_mixer:  An audio mixer library based on the SDL library
    16.6 -  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
    16.7 -
    16.8 -  This software is provided 'as-is', without any express or implied
    16.9 -  warranty.  In no event will the authors be held liable for any damages
   16.10 -  arising from the use of this software.
   16.11 -
   16.12 -  Permission is granted to anyone to use this software for any purpose,
   16.13 -  including commercial applications, and to alter it and redistribute it
   16.14 -  freely, subject to the following restrictions:
   16.15 -
   16.16 -  1. The origin of this software must not be misrepresented; you must not
   16.17 -     claim that you wrote the original software. If you use this software
   16.18 -     in a product, an acknowledgment in the product documentation would be
   16.19 -     appreciated but is not required.
   16.20 -  2. Altered source versions must be plainly marked as such, and must not be
   16.21 -     misrepresented as being the original software.
   16.22 -  3. This notice may not be removed or altered from any source distribution.
   16.23 -*/
   16.24 -
   16.25 -/* $Id$ */
   16.26 -
   16.27 -#include <stdio.h>
   16.28 -#include <stdlib.h>
   16.29 -#include <string.h>
   16.30 -
   16.31 -#include "SDL.h"
   16.32 -
   16.33 -#include "SDL_mixer.h"
   16.34 -#include "mixer.h"
   16.35 -#include "music.h"
   16.36 -#include "load_aiff.h"
   16.37 -#include "load_voc.h"
   16.38 -
   16.39 -#define __MIX_INTERNAL_EFFECT__
   16.40 -#include "effects_internal.h"
   16.41 -
   16.42 -/* Magic numbers for various audio file formats */
   16.43 -#define RIFF        0x46464952      /* "RIFF" */
   16.44 -#define WAVE        0x45564157      /* "WAVE" */
   16.45 -#define FORM        0x4d524f46      /* "FORM" */
   16.46 -#define CREA        0x61657243      /* "Crea" */
   16.47 -
   16.48 -static int audio_opened = 0;
   16.49 -static SDL_AudioSpec mixer;
   16.50 -static SDL_AudioDeviceID audio_device;
   16.51 -
   16.52 -typedef struct _Mix_effectinfo
   16.53 -{
   16.54 -    Mix_EffectFunc_t callback;
   16.55 -    Mix_EffectDone_t done_callback;
   16.56 -    void *udata;
   16.57 -    struct _Mix_effectinfo *next;
   16.58 -} effect_info;
   16.59 -
   16.60 -static struct _Mix_Channel {
   16.61 -    Mix_Chunk *chunk;
   16.62 -    int playing;
   16.63 -    int paused;
   16.64 -    Uint8 *samples;
   16.65 -    int volume;
   16.66 -    int looping;
   16.67 -    int tag;
   16.68 -    Uint32 expire;
   16.69 -    Uint32 start_time;
   16.70 -    Mix_Fading fading;
   16.71 -    int fade_volume;
   16.72 -    int fade_volume_reset;
   16.73 -    Uint32 fade_length;
   16.74 -    Uint32 ticks_fade;
   16.75 -    effect_info *effects;
   16.76 -} *mix_channel = NULL;
   16.77 -
   16.78 -static effect_info *posteffects = NULL;
   16.79 -
   16.80 -static int num_channels;
   16.81 -static int reserved_channels = 0;
   16.82 -
   16.83 -
   16.84 -/* Support for hooking into the mixer callback system */
   16.85 -static void (SDLCALL *mix_postmix)(void *udata, Uint8 *stream, int len) = NULL;
   16.86 -static void *mix_postmix_data = NULL;
   16.87 -
   16.88 -/* rcg07062001 callback to alert when channels are done playing. */
   16.89 -static void (SDLCALL *channel_done_callback)(int channel) = NULL;
   16.90 -
   16.91 -/* Support for user defined music functions */
   16.92 -static void (SDLCALL *mix_music)(void *udata, Uint8 *stream, int len) = music_mixer;
   16.93 -static void *music_data = NULL;
   16.94 -
   16.95 -/* rcg06042009 report available decoders at runtime. */
   16.96 -static const char **chunk_decoders = NULL;
   16.97 -static int num_decoders = 0;
   16.98 -
   16.99 -
  16.100 -int Mix_GetNumChunkDecoders(void)
  16.101 -{
  16.102 -    return(num_decoders);
  16.103 -}
  16.104 -
  16.105 -const char *Mix_GetChunkDecoder(int index)
  16.106 -{
  16.107 -    if ((index < 0) || (index >= num_decoders)) {
  16.108 -        return NULL;
  16.109 -    }
  16.110 -    return(chunk_decoders[index]);
  16.111 -}
  16.112 -
  16.113 -SDL_bool Mix_HasChunkDecoder(const char *name)
  16.114 -{
  16.115 -    int index;
  16.116 -    for (index = 0; index < num_decoders; ++index) {
  16.117 -        if (SDL_strcasecmp(name, chunk_decoders[index]) == 0) {
  16.118 -            return SDL_TRUE;
  16.119 -        }
  16.120 -    }
  16.121 -    return SDL_FALSE;
  16.122 -}
  16.123 -
  16.124 -void add_chunk_decoder(const char *decoder)
  16.125 -{
  16.126 -    int i;
  16.127 -    void *ptr;
  16.128 -
  16.129 -    /* Check to see if we already have this decoder */
  16.130 -    for (i = 0; i < num_decoders; ++i) {
  16.131 -        if (SDL_strcmp(chunk_decoders[i], decoder) == 0) {
  16.132 -            return;
  16.133 -        }
  16.134 -    }
  16.135 -
  16.136 -    ptr = SDL_realloc((void *)chunk_decoders, (num_decoders + 1) * sizeof (const char *));
  16.137 -    if (ptr == NULL) {
  16.138 -        return;  /* oh well, go on without it. */
  16.139 -    }
  16.140 -    chunk_decoders = (const char **) ptr;
  16.141 -    chunk_decoders[num_decoders++] = decoder;
  16.142 -}
  16.143 -
  16.144 -/* rcg06192001 get linked library's version. */
  16.145 -const SDL_version *Mix_Linked_Version(void)
  16.146 -{
  16.147 -    static SDL_version linked_version;
  16.148 -    SDL_MIXER_VERSION(&linked_version);
  16.149 -    return(&linked_version);
  16.150 -}
  16.151 -
  16.152 -int Mix_Init(int flags)
  16.153 -{
  16.154 -    int result = 0;
  16.155 -
  16.156 -    if (flags & MIX_INIT_FLAC) {
  16.157 -        if (load_music_type(MUS_FLAC)) {
  16.158 -            open_music_type(MUS_FLAC);
  16.159 -            result |= MIX_INIT_FLAC;
  16.160 -        } else {
  16.161 -            Mix_SetError("FLAC support not available");
  16.162 -        }
  16.163 -    }
  16.164 -    if (flags & MIX_INIT_MOD) {
  16.165 -        if (load_music_type(MUS_MOD)) {
  16.166 -            open_music_type(MUS_MOD);
  16.167 -            result |= MIX_INIT_MOD;
  16.168 -        } else {
  16.169 -            Mix_SetError("MOD support not available");
  16.170 -        }
  16.171 -    }
  16.172 -    if (flags & MIX_INIT_MP3) {
  16.173 -        if (load_music_type(MUS_MP3)) {
  16.174 -            open_music_type(MUS_MP3);
  16.175 -            result |= MIX_INIT_MP3;
  16.176 -        } else {
  16.177 -            Mix_SetError("MP3 support not available");
  16.178 -        }
  16.179 -    }
  16.180 -    if (flags & MIX_INIT_OGG) {
  16.181 -        if (load_music_type(MUS_OGG)) {
  16.182 -            open_music_type(MUS_OGG);
  16.183 -            result |= MIX_INIT_OGG;
  16.184 -        } else {
  16.185 -            Mix_SetError("OGG support not available");
  16.186 -        }
  16.187 -    }
  16.188 -    if (flags & MIX_INIT_OPUS) {
  16.189 -        if (load_music_type(MUS_OPUS)) {
  16.190 -            open_music_type(MUS_OPUS);
  16.191 -            result |= MIX_INIT_OPUS;
  16.192 -        } else {
  16.193 -            Mix_SetError("OPUS support not available");
  16.194 -        }
  16.195 -    }
  16.196 -    if (flags & MIX_INIT_MID) {
  16.197 -        if (load_music_type(MUS_MID)) {
  16.198 -            open_music_type(MUS_MID);
  16.199 -            result |= MIX_INIT_MID;
  16.200 -        } else {
  16.201 -            Mix_SetError("MIDI support not available");
  16.202 -        }
  16.203 -    }
  16.204 -    return result;
  16.205 -}
  16.206 -
  16.207 -void Mix_Quit()
  16.208 -{
  16.209 -    unload_music();
  16.210 -}
  16.211 -
  16.212 -static int _Mix_remove_all_effects(int channel, effect_info **e);
  16.213 -
  16.214 -/*
  16.215 - * rcg06122001 Cleanup effect callbacks.
  16.216 - *  MAKE SURE Mix_LockAudio() is called before this (or you're in the
  16.217 - *   audio callback).
  16.218 - */
  16.219 -static void _Mix_channel_done_playing(int channel)
  16.220 -{
  16.221 -    if (channel_done_callback) {
  16.222 -        channel_done_callback(channel);
  16.223 -    }
  16.224 -
  16.225 -    /*
  16.226 -     * Call internal function directly, to avoid locking audio from
  16.227 -     *   inside audio callback.
  16.228 -     */
  16.229 -    _Mix_remove_all_effects(channel, &mix_channel[channel].effects);
  16.230 -}
  16.231 -
  16.232 -
  16.233 -static void *Mix_DoEffects(int chan, void *snd, int len)
  16.234 -{
  16.235 -    int posteffect = (chan == MIX_CHANNEL_POST);
  16.236 -    effect_info *e = ((posteffect) ? posteffects : mix_channel[chan].effects);
  16.237 -    void *buf = snd;
  16.238 -
  16.239 -    if (e != NULL) {    /* are there any registered effects? */
  16.240 -        /* if this is the postmix, we can just overwrite the original. */
  16.241 -        if (!posteffect) {
  16.242 -            buf = SDL_malloc(len);
  16.243 -            if (buf == NULL) {
  16.244 -                return(snd);
  16.245 -            }
  16.246 -            SDL_memcpy(buf, snd, len);
  16.247 -        }
  16.248 -
  16.249 -        for (; e != NULL; e = e->next) {
  16.250 -            if (e->callback != NULL) {
  16.251 -                e->callback(chan, buf, len, e->udata);
  16.252 -            }
  16.253 -        }
  16.254 -    }
  16.255 -
  16.256 -    /* be sure to SDL_free() the return value if != snd ... */
  16.257 -    return(buf);
  16.258 -}
  16.259 -
  16.260 -
  16.261 -/* Mixing function */
  16.262 -static void SDLCALL
  16.263 -mix_channels(void *udata, Uint8 *stream, int len)
  16.264 -{
  16.265 -    Uint8 *mix_input;
  16.266 -    int i, mixable, volume = MIX_MAX_VOLUME;
  16.267 -    Uint32 sdl_ticks;
  16.268 -
  16.269 -    (void)udata;
  16.270 -
  16.271 -#if SDL_VERSION_ATLEAST(1, 3, 0)
  16.272 -    /* Need to initialize the stream in SDL 1.3+ */
  16.273 -    SDL_memset(stream, mixer.silence, len);
  16.274 -#endif
  16.275 -
  16.276 -    /* Mix the music (must be done before the channels are added) */
  16.277 -    mix_music(music_data, stream, len);
  16.278 -
  16.279 -    /* Mix any playing channels... */
  16.280 -    sdl_ticks = SDL_GetTicks();
  16.281 -    for (i=0; i<num_channels; ++i) {
  16.282 -        if (!mix_channel[i].paused) {
  16.283 -            if (mix_channel[i].expire > 0 && mix_channel[i].expire < sdl_ticks) {
  16.284 -                /* Expiration delay for that channel is reached */
  16.285 -                mix_channel[i].playing = 0;
  16.286 -                mix_channel[i].looping = 0;
  16.287 -                mix_channel[i].fading = MIX_NO_FADING;
  16.288 -                mix_channel[i].expire = 0;
  16.289 -                _Mix_channel_done_playing(i);
  16.290 -            } else if (mix_channel[i].fading != MIX_NO_FADING) {
  16.291 -                Uint32 ticks = sdl_ticks - mix_channel[i].ticks_fade;
  16.292 -                if (ticks >= mix_channel[i].fade_length) {
  16.293 -                    Mix_Volume(i, mix_channel[i].fade_volume_reset); /* Restore the volume */
  16.294 -                    if(mix_channel[i].fading == MIX_FADING_OUT) {
  16.295 -                        mix_channel[i].playing = 0;
  16.296 -                        mix_channel[i].looping = 0;
  16.297 -                        mix_channel[i].expire = 0;
  16.298 -                        _Mix_channel_done_playing(i);
  16.299 -                    }
  16.300 -                    mix_channel[i].fading = MIX_NO_FADING;
  16.301 -                } else {
  16.302 -                    if (mix_channel[i].fading == MIX_FADING_OUT) {
  16.303 -                        Mix_Volume(i, (mix_channel[i].fade_volume * (mix_channel[i].fade_length-ticks))
  16.304 -                                   / mix_channel[i].fade_length);
  16.305 -                    } else {
  16.306 -                        Mix_Volume(i, (mix_channel[i].fade_volume * ticks) / mix_channel[i].fade_length);
  16.307 -                    }
  16.308 -                }
  16.309 -            }
  16.310 -            if (mix_channel[i].playing > 0) {
  16.311 -                int index = 0;
  16.312 -                int remaining = len;
  16.313 -                while (mix_channel[i].playing > 0 && index < len) {
  16.314 -                    remaining = len - index;
  16.315 -                    volume = (mix_channel[i].volume*mix_channel[i].chunk->volume) / MIX_MAX_VOLUME;
  16.316 -                    mixable = mix_channel[i].playing;
  16.317 -                    if (mixable > remaining) {
  16.318 -                        mixable = remaining;
  16.319 -                    }
  16.320 -
  16.321 -                    mix_input = Mix_DoEffects(i, mix_channel[i].samples, mixable);
  16.322 -                    SDL_MixAudioFormat(stream+index,mix_input,mixer.format,mixable,volume);
  16.323 -                    if (mix_input != mix_channel[i].samples)
  16.324 -                        SDL_free(mix_input);
  16.325 -
  16.326 -                    mix_channel[i].samples += mixable;
  16.327 -                    mix_channel[i].playing -= mixable;
  16.328 -                    index += mixable;
  16.329 -
  16.330 -                    /* rcg06072001 Alert app if channel is done playing. */
  16.331 -                    if (!mix_channel[i].playing && !mix_channel[i].looping) {
  16.332 -                        _Mix_channel_done_playing(i);
  16.333 -                    }
  16.334 -                }
  16.335 -
  16.336 -                /* If looping the sample and we are at its end, make sure
  16.337 -                   we will still return a full buffer */
  16.338 -                while (mix_channel[i].looping && index < len) {
  16.339 -                    int alen = mix_channel[i].chunk->alen;
  16.340 -                    remaining = len - index;
  16.341 -                    if (remaining > alen) {
  16.342 -                        remaining = alen;
  16.343 -                    }
  16.344 -
  16.345 -                    mix_input = Mix_DoEffects(i, mix_channel[i].chunk->abuf, remaining);
  16.346 -                    SDL_MixAudioFormat(stream+index, mix_input, mixer.format, remaining, volume);
  16.347 -                    if (mix_input != mix_channel[i].chunk->abuf)
  16.348 -                        SDL_free(mix_input);
  16.349 -
  16.350 -                    if (mix_channel[i].looping > 0) {
  16.351 -                        --mix_channel[i].looping;
  16.352 -                    }
  16.353 -                    mix_channel[i].samples = mix_channel[i].chunk->abuf + remaining;
  16.354 -                    mix_channel[i].playing = mix_channel[i].chunk->alen - remaining;
  16.355 -                    index += remaining;
  16.356 -                }
  16.357 -                if (! mix_channel[i].playing && mix_channel[i].looping) {
  16.358 -                    if (mix_channel[i].looping > 0) {
  16.359 -                        --mix_channel[i].looping;
  16.360 -                    }
  16.361 -                    mix_channel[i].samples = mix_channel[i].chunk->abuf;
  16.362 -                    mix_channel[i].playing = mix_channel[i].chunk->alen;
  16.363 -                }
  16.364 -            }
  16.365 -        }
  16.366 -    }
  16.367 -
  16.368 -    /* rcg06122001 run posteffects... */
  16.369 -    Mix_DoEffects(MIX_CHANNEL_POST, stream, len);
  16.370 -
  16.371 -    if (mix_postmix) {
  16.372 -        mix_postmix(mix_postmix_data, stream, len);
  16.373 -    }
  16.374 -}
  16.375 -
  16.376 -#if 0
  16.377 -static void PrintFormat(char *title, SDL_AudioSpec *fmt)
  16.378 -{
  16.379 -    printf("%s: %d bit %s audio (%s) at %u Hz\n", title, (fmt->format&0xFF),
  16.380 -            (fmt->format&0x8000) ? "signed" : "unsigned",
  16.381 -            (fmt->channels > 2) ? "surround" :
  16.382 -            (fmt->channels > 1) ? "stereo" : "mono", fmt->freq);
  16.383 -}
  16.384 -#endif
  16.385 -
  16.386 -/* Open the mixer with a certain desired audio format */
  16.387 -int Mix_OpenAudioDevice(int frequency, Uint16 format, int nchannels, int chunksize,
  16.388 -                        const char* device, int allowed_changes)
  16.389 -{
  16.390 -    int i;
  16.391 -    SDL_AudioSpec desired;
  16.392 -
  16.393 -    /* This used to call SDL_OpenAudio(), which initializes the audio
  16.394 -       subsystem if necessary. Since SDL_OpenAudioDevice() doesn't,
  16.395 -       we have to handle this case here. */
  16.396 -    if (!SDL_WasInit(SDL_INIT_AUDIO)) {
  16.397 -        if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
  16.398 -            return -1;
  16.399 -        }
  16.400 -    }
  16.401 -
  16.402 -    /* If the mixer is already opened, increment open count */
  16.403 -    if (audio_opened) {
  16.404 -        if (format == mixer.format && nchannels == mixer.channels) {
  16.405 -            ++audio_opened;
  16.406 -            return(0);
  16.407 -        }
  16.408 -        while (audio_opened) {
  16.409 -            Mix_CloseAudio();
  16.410 -        }
  16.411 -    }
  16.412 -
  16.413 -    /* Set the desired format and frequency */
  16.414 -    desired.freq = frequency;
  16.415 -    desired.format = format;
  16.416 -    desired.channels = nchannels;
  16.417 -    desired.samples = chunksize;
  16.418 -    desired.callback = mix_channels;
  16.419 -    desired.userdata = NULL;
  16.420 -
  16.421 -    /* Accept nearly any audio format */
  16.422 -    if ((audio_device = SDL_OpenAudioDevice(device, 0, &desired, &mixer, allowed_changes)) == 0) {
  16.423 -        return(-1);
  16.424 -    }
  16.425 -#if 0
  16.426 -    PrintFormat("Audio device", &mixer);
  16.427 -#endif
  16.428 -
  16.429 -    num_channels = MIX_CHANNELS;
  16.430 -    mix_channel = (struct _Mix_Channel *) SDL_malloc(num_channels * sizeof(struct _Mix_Channel));
  16.431 -
  16.432 -    /* Clear out the audio channels */
  16.433 -    for (i=0; i<num_channels; ++i) {
  16.434 -        mix_channel[i].chunk = NULL;
  16.435 -        mix_channel[i].playing = 0;
  16.436 -        mix_channel[i].looping = 0;
  16.437 -        mix_channel[i].volume = SDL_MIX_MAXVOLUME;
  16.438 -        mix_channel[i].fade_volume = SDL_MIX_MAXVOLUME;
  16.439 -        mix_channel[i].fade_volume_reset = SDL_MIX_MAXVOLUME;
  16.440 -        mix_channel[i].fading = MIX_NO_FADING;
  16.441 -        mix_channel[i].tag = -1;
  16.442 -        mix_channel[i].expire = 0;
  16.443 -        mix_channel[i].effects = NULL;
  16.444 -        mix_channel[i].paused = 0;
  16.445 -    }
  16.446 -    Mix_VolumeMusic(SDL_MIX_MAXVOLUME);
  16.447 -
  16.448 -    _Mix_InitEffects();
  16.449 -
  16.450 -    add_chunk_decoder("WAVE");
  16.451 -    add_chunk_decoder("AIFF");
  16.452 -    add_chunk_decoder("VOC");
  16.453 -
  16.454 -    /* Initialize the music players */
  16.455 -    open_music(&mixer);
  16.456 -
  16.457 -    audio_opened = 1;
  16.458 -    SDL_PauseAudioDevice(audio_device, 0);
  16.459 -    return(0);
  16.460 -}
  16.461 -
  16.462 -/* Open the mixer with a certain desired audio format */
  16.463 -int Mix_OpenAudio(int frequency, Uint16 format, int nchannels, int chunksize)
  16.464 -{
  16.465 -    return Mix_OpenAudioDevice(frequency, format, nchannels, chunksize, NULL,
  16.466 -                                SDL_AUDIO_ALLOW_FREQUENCY_CHANGE |
  16.467 -                                SDL_AUDIO_ALLOW_CHANNELS_CHANGE);
  16.468 -}
  16.469 -
  16.470 -/* Dynamically change the number of channels managed by the mixer.
  16.471 -   If decreasing the number of channels, the upper channels are
  16.472 -   stopped.
  16.473 - */
  16.474 -int Mix_AllocateChannels(int numchans)
  16.475 -{
  16.476 -    if (numchans<0 || numchans==num_channels)
  16.477 -        return(num_channels);
  16.478 -
  16.479 -    if (numchans < num_channels) {
  16.480 -        /* Stop the affected channels */
  16.481 -        int i;
  16.482 -        for(i=numchans; i < num_channels; i++) {
  16.483 -            Mix_UnregisterAllEffects(i);
  16.484 -            Mix_HaltChannel(i);
  16.485 -        }
  16.486 -    }
  16.487 -    Mix_LockAudio();
  16.488 -    mix_channel = (struct _Mix_Channel *) SDL_realloc(mix_channel, numchans * sizeof(struct _Mix_Channel));
  16.489 -    if (numchans > num_channels) {
  16.490 -        /* Initialize the new channels */
  16.491 -        int i;
  16.492 -        for(i=num_channels; i < numchans; i++) {
  16.493 -            mix_channel[i].chunk = NULL;
  16.494 -            mix_channel[i].playing = 0;
  16.495 -            mix_channel[i].looping = 0;
  16.496 -            mix_channel[i].volume = MIX_MAX_VOLUME;
  16.497 -            mix_channel[i].fade_volume = MIX_MAX_VOLUME;
  16.498 -            mix_channel[i].fade_volume_reset = MIX_MAX_VOLUME;
  16.499 -            mix_channel[i].fading = MIX_NO_FADING;
  16.500 -            mix_channel[i].tag = -1;
  16.501 -            mix_channel[i].expire = 0;
  16.502 -            mix_channel[i].effects = NULL;
  16.503 -            mix_channel[i].paused = 0;
  16.504 -        }
  16.505 -    }
  16.506 -    num_channels = numchans;
  16.507 -    Mix_UnlockAudio();
  16.508 -    return(num_channels);
  16.509 -}
  16.510 -
  16.511 -/* Return the actual mixer parameters */
  16.512 -int Mix_QuerySpec(int *frequency, Uint16 *format, int *channels)
  16.513 -{
  16.514 -    if (audio_opened) {
  16.515 -        if (frequency) {
  16.516 -            *frequency = mixer.freq;
  16.517 -        }
  16.518 -        if (format) {
  16.519 -            *format = mixer.format;
  16.520 -        }
  16.521 -        if (channels) {
  16.522 -            *channels = mixer.channels;
  16.523 -        }
  16.524 -    }
  16.525 -    return(audio_opened);
  16.526 -}
  16.527 -
  16.528 -typedef struct _MusicFragment
  16.529 -{
  16.530 -    Uint8 *data;
  16.531 -    int size;
  16.532 -    struct _MusicFragment *next;
  16.533 -} MusicFragment;
  16.534 -
  16.535 -static SDL_AudioSpec *Mix_LoadMusic_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
  16.536 -{
  16.537 -    int i;
  16.538 -	Mix_MusicType music_type;
  16.539 -    Mix_MusicInterface *interface = NULL;
  16.540 -    void *music = NULL;
  16.541 -    Sint64 start;
  16.542 -    SDL_bool playing;
  16.543 -    MusicFragment *first = NULL, *last = NULL, *fragment = NULL;
  16.544 -    int count = 0;
  16.545 -    int fragment_size;
  16.546 -
  16.547 -	music_type = detect_music_type(src);
  16.548 -    if (!load_music_type(music_type) || !open_music_type(music_type)) {
  16.549 -        return NULL;
  16.550 -    }
  16.551 -
  16.552 -    *spec = mixer;
  16.553 -
  16.554 -    /* Use fragments sized on full audio frame boundaries - this'll do */
  16.555 -    fragment_size = spec->size;
  16.556 -
  16.557 -    start = SDL_RWtell(src);
  16.558 -    for (i = 0; i < get_num_music_interfaces(); ++i) {
  16.559 -        interface = get_music_interface(i);
  16.560 -        if (!interface->opened) {
  16.561 -            continue;
  16.562 -        }
  16.563 -        if (interface->type != music_type) {
  16.564 -            continue;
  16.565 -        }
  16.566 -        if (!interface->CreateFromRW || !interface->GetAudio) {
  16.567 -            continue;
  16.568 -        }
  16.569 -
  16.570 -        /* These music interfaces are not safe to use while music is playing */
  16.571 -        if (interface->api == MIX_MUSIC_CMD ||
  16.572 -             interface->api == MIX_MUSIC_MIKMOD ||
  16.573 -             interface->api == MIX_MUSIC_NATIVEMIDI) {
  16.574 -            continue;
  16.575 -        }
  16.576 -
  16.577 -        music = interface->CreateFromRW(src, freesrc);
  16.578 -        if (music) {
  16.579 -            /* The interface owns the data source now */
  16.580 -            freesrc = SDL_FALSE;
  16.581 -            break;
  16.582 -        }
  16.583 -
  16.584 -        /* Reset the stream for the next decoder */
  16.585 -        SDL_RWseek(src, start, RW_SEEK_SET);
  16.586 -    }
  16.587 -
  16.588 -    if (!music) {
  16.589 -        if (freesrc) {
  16.590 -            SDL_RWclose(src);
  16.591 -        }
  16.592 -        Mix_SetError("Unrecognized audio format");
  16.593 -        return NULL;
  16.594 -    }
  16.595 -
  16.596 -    Mix_LockAudio();
  16.597 -
  16.598 -    if (interface->Play) {
  16.599 -        interface->Play(music, 1);
  16.600 -    }
  16.601 -    playing = SDL_TRUE;
  16.602 -
  16.603 -    while (playing) {
  16.604 -        int left;
  16.605 -
  16.606 -        fragment = (MusicFragment *)SDL_malloc(sizeof(*fragment));
  16.607 -        if (!fragment) {
  16.608 -            /* Uh oh, out of memory, let's return what we have */
  16.609 -            break;
  16.610 -        }
  16.611 -        fragment->data = (Uint8 *)SDL_malloc(fragment_size);
  16.612 -        if (!fragment->data) {
  16.613 -            /* Uh oh, out of memory, let's return what we have */
  16.614 -            SDL_free(fragment);
  16.615 -            break;
  16.616 -        }
  16.617 -        fragment->next = NULL;
  16.618 -
  16.619 -        left = interface->GetAudio(music, fragment->data, fragment_size);
  16.620 -        if (left > 0) {
  16.621 -            playing = SDL_FALSE;
  16.622 -        } else if (interface->IsPlaying) {
  16.623 -            playing = interface->IsPlaying(music);
  16.624 -        }
  16.625 -        fragment->size = (fragment_size - left);
  16.626 -
  16.627 -        if (!first) {
  16.628 -            first = fragment;
  16.629 -        }
  16.630 -        if (last) {
  16.631 -            last->next = fragment;
  16.632 -        }
  16.633 -        last = fragment;
  16.634 -        ++count;
  16.635 -    }
  16.636 -
  16.637 -    if (interface->Stop) {
  16.638 -        interface->Stop(music);
  16.639 -    }
  16.640 -
  16.641 -    if (music) {
  16.642 -        interface->Delete(music);
  16.643 -    }
  16.644 -
  16.645 -    Mix_UnlockAudio();
  16.646 -
  16.647 -    if (count > 0) {
  16.648 -        *audio_len = (count - 1) * fragment_size + fragment->size;
  16.649 -        *audio_buf = (Uint8 *)SDL_malloc(*audio_len);
  16.650 -        if (*audio_buf) {
  16.651 -            Uint8 *dst = *audio_buf;
  16.652 -            for (fragment = first; fragment; fragment = fragment->next) {
  16.653 -                SDL_memcpy(dst, fragment->data, fragment->size);
  16.654 -                dst += fragment->size;
  16.655 -            }
  16.656 -        } else {
  16.657 -            SDL_OutOfMemory();
  16.658 -            spec = NULL;
  16.659 -        }
  16.660 -    } else {
  16.661 -        Mix_SetError("No audio data");
  16.662 -        spec = NULL;
  16.663 -    }
  16.664 -
  16.665 -    while (first) {
  16.666 -        fragment = first;
  16.667 -        first = first->next;
  16.668 -        SDL_free(fragment->data);
  16.669 -        SDL_free(fragment);
  16.670 -    }
  16.671 -
  16.672 -    if (freesrc) {
  16.673 -        SDL_RWclose(src);
  16.674 -    }
  16.675 -    return spec;
  16.676 -}
  16.677 -
  16.678 -/* Load a wave file */
  16.679 -Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc)
  16.680 -{
  16.681 -    Uint8 magic[4];
  16.682 -    Mix_Chunk *chunk;
  16.683 -    SDL_AudioSpec wavespec, *loaded;
  16.684 -    SDL_AudioCVT wavecvt;
  16.685 -    int samplesize;
  16.686 -
  16.687 -    /* rcg06012001 Make sure src is valid */
  16.688 -    if (!src) {
  16.689 -        SDL_SetError("Mix_LoadWAV_RW with NULL src");
  16.690 -        return(NULL);
  16.691 -    }
  16.692 -
  16.693 -    /* Make sure audio has been opened */
  16.694 -    if (!audio_opened) {
  16.695 -        SDL_SetError("Audio device hasn't been opened");
  16.696 -        if (freesrc) {
  16.697 -            SDL_RWclose(src);
  16.698 -        }
  16.699 -        return(NULL);
  16.700 -    }
  16.701 -
  16.702 -    /* Allocate the chunk memory */
  16.703 -    chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk));
  16.704 -    if (chunk == NULL) {
  16.705 -        SDL_SetError("Out of memory");
  16.706 -        if (freesrc) {
  16.707 -            SDL_RWclose(src);
  16.708 -        }
  16.709 -        return(NULL);
  16.710 -    }
  16.711 -
  16.712 -    /* Find out what kind of audio file this is */
  16.713 -    if (SDL_RWread(src, magic, 1, 4) != 4) {
  16.714 -        if (freesrc) {
  16.715 -            SDL_RWclose(src);
  16.716 -        }
  16.717 -        Mix_SetError("Couldn't read first 4 bytes of audio data");
  16.718 -        return NULL;
  16.719 -    }
  16.720 -    /* Seek backwards for compatibility with older loaders */
  16.721 -    SDL_RWseek(src, -4, RW_SEEK_CUR);
  16.722 -
  16.723 -    if (SDL_memcmp(magic, "WAVE", 4) == 0 || SDL_memcmp(magic, "RIFF", 4) == 0) {
  16.724 -        loaded = SDL_LoadWAV_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen);
  16.725 -    } else if (SDL_memcmp(magic, "FORM", 4) == 0) {
  16.726 -        loaded = Mix_LoadAIFF_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen);
  16.727 -    } else if (SDL_memcmp(magic, "Crea", 4) == 0) {
  16.728 -        loaded = Mix_LoadVOC_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen);
  16.729 -    } else {
  16.730 -        loaded = Mix_LoadMusic_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen);
  16.731 -    }
  16.732 -    if (!loaded) {
  16.733 -        /* The individual loaders have closed src if needed */
  16.734 -        SDL_free(chunk);
  16.735 -        return(NULL);
  16.736 -    }
  16.737 -
  16.738 -#if 0
  16.739 -    PrintFormat("Audio device", &mixer);
  16.740 -    PrintFormat("-- Wave file", &wavespec);
  16.741 -#endif
  16.742 -
  16.743 -    /* Build the audio converter and create conversion buffers */
  16.744 -    if (wavespec.format != mixer.format ||
  16.745 -         wavespec.channels != mixer.channels ||
  16.746 -         wavespec.freq != mixer.freq) {
  16.747 -        if (SDL_BuildAudioCVT(&wavecvt,
  16.748 -                wavespec.format, wavespec.channels, wavespec.freq,
  16.749 -                mixer.format, mixer.channels, mixer.freq) < 0) {
  16.750 -            SDL_free(chunk->abuf);
  16.751 -            SDL_free(chunk);
  16.752 -            return(NULL);
  16.753 -        }
  16.754 -        samplesize = ((wavespec.format & 0xFF)/8)*wavespec.channels;
  16.755 -        wavecvt.len = chunk->alen & ~(samplesize-1);
  16.756 -        wavecvt.buf = (Uint8 *)SDL_calloc(1, wavecvt.len*wavecvt.len_mult);
  16.757 -        if (wavecvt.buf == NULL) {
  16.758 -            SDL_SetError("Out of memory");
  16.759 -            SDL_free(chunk->abuf);
  16.760 -            SDL_free(chunk);
  16.761 -            return(NULL);
  16.762 -        }
  16.763 -        SDL_memcpy(wavecvt.buf, chunk->abuf, wavecvt.len);
  16.764 -        SDL_free(chunk->abuf);
  16.765 -
  16.766 -        /* Run the audio converter */
  16.767 -        if (SDL_ConvertAudio(&wavecvt) < 0) {
  16.768 -            SDL_free(wavecvt.buf);
  16.769 -            SDL_free(chunk);
  16.770 -            return(NULL);
  16.771 -        }
  16.772 -
  16.773 -        chunk->abuf = wavecvt.buf;
  16.774 -        chunk->alen = wavecvt.len_cvt;
  16.775 -    }
  16.776 -
  16.777 -    chunk->allocated = 1;
  16.778 -    chunk->volume = MIX_MAX_VOLUME;
  16.779 -
  16.780 -    return(chunk);
  16.781 -}
  16.782 -
  16.783 -/* Load a wave file of the mixer format from a memory buffer */
  16.784 -Mix_Chunk *Mix_QuickLoad_WAV(Uint8 *mem)
  16.785 -{
  16.786 -    Mix_Chunk *chunk;
  16.787 -    Uint8 magic[4];
  16.788 -
  16.789 -    /* Make sure audio has been opened */
  16.790 -    if (! audio_opened) {
  16.791 -        SDL_SetError("Audio device hasn't been opened");
  16.792 -        return(NULL);
  16.793 -    }
  16.794 -
  16.795 -    /* Allocate the chunk memory */
  16.796 -    chunk = (Mix_Chunk *)SDL_calloc(1,sizeof(Mix_Chunk));
  16.797 -    if (chunk == NULL) {
  16.798 -        SDL_SetError("Out of memory");
  16.799 -        return(NULL);
  16.800 -    }
  16.801 -
  16.802 -    /* Essentially just skip to the audio data (no error checking - fast) */
  16.803 -    chunk->allocated = 0;
  16.804 -    mem += 12; /* WAV header */
  16.805 -    do {
  16.806 -        SDL_memcpy(magic, mem, 4);
  16.807 -        mem += 4;
  16.808 -        chunk->alen = ((mem[3]<<24)|(mem[2]<<16)|(mem[1]<<8)|(mem[0]));
  16.809 -        mem += 4;
  16.810 -        chunk->abuf = mem;
  16.811 -        mem += chunk->alen;
  16.812 -    } while (memcmp(magic, "data", 4) != 0);
  16.813 -    chunk->volume = MIX_MAX_VOLUME;
  16.814 -
  16.815 -    return(chunk);
  16.816 -}
  16.817 -
  16.818 -/* Load raw audio data of the mixer format from a memory buffer */
  16.819 -Mix_Chunk *Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len)
  16.820 -{
  16.821 -    Mix_Chunk *chunk;
  16.822 -
  16.823 -    /* Make sure audio has been opened */
  16.824 -    if (! audio_opened) {
  16.825 -        SDL_SetError("Audio device hasn't been opened");
  16.826 -        return(NULL);
  16.827 -    }
  16.828 -
  16.829 -    /* Allocate the chunk memory */
  16.830 -    chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk));
  16.831 -    if (chunk == NULL) {
  16.832 -        SDL_SetError("Out of memory");
  16.833 -        return(NULL);
  16.834 -    }
  16.835 -
  16.836 -    /* Essentially just point at the audio data (no error checking - fast) */
  16.837 -    chunk->allocated = 0;
  16.838 -    chunk->alen = len;
  16.839 -    chunk->abuf = mem;
  16.840 -    chunk->volume = MIX_MAX_VOLUME;
  16.841 -
  16.842 -    return(chunk);
  16.843 -}
  16.844 -
  16.845 -/* Free an audio chunk previously loaded */
  16.846 -void Mix_FreeChunk(Mix_Chunk *chunk)
  16.847 -{
  16.848 -    int i;
  16.849 -
  16.850 -    /* Caution -- if the chunk is playing, the mixer will crash */
  16.851 -    if (chunk) {
  16.852 -        /* Guarantee that this chunk isn't playing */
  16.853 -        Mix_LockAudio();
  16.854 -        if (mix_channel) {
  16.855 -            for (i=0; i<num_channels; ++i) {
  16.856 -                if (chunk == mix_channel[i].chunk) {
  16.857 -                    mix_channel[i].playing = 0;
  16.858 -                    mix_channel[i].looping = 0;
  16.859 -                }
  16.860 -            }
  16.861 -        }
  16.862 -        Mix_UnlockAudio();
  16.863 -        /* Actually free the chunk */
  16.864 -        if (chunk->allocated) {
  16.865 -            SDL_free(chunk->abuf);
  16.866 -        }
  16.867 -        SDL_free(chunk);
  16.868 -    }
  16.869 -}
  16.870 -
  16.871 -/* Set a function that is called after all mixing is performed.
  16.872 -   This can be used to provide real-time visual display of the audio stream
  16.873 -   or add a custom mixer filter for the stream data.
  16.874 -*/
  16.875 -void Mix_SetPostMix(void (SDLCALL *mix_func)
  16.876 -                    (void *udata, Uint8 *stream, int len), void *arg)
  16.877 -{
  16.878 -    Mix_LockAudio();
  16.879 -    mix_postmix_data = arg;
  16.880 -    mix_postmix = mix_func;
  16.881 -    Mix_UnlockAudio();
  16.882 -}
  16.883 -
  16.884 -/* Add your own music player or mixer function.
  16.885 -   If 'mix_func' is NULL, the default music player is re-enabled.
  16.886 - */
  16.887 -void Mix_HookMusic(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len),
  16.888 -                                                                void *arg)
  16.889 -{
  16.890 -    Mix_LockAudio();
  16.891 -    if (mix_func != NULL) {
  16.892 -        music_data = arg;
  16.893 -        mix_music = mix_func;
  16.894 -    } else {
  16.895 -        music_data = NULL;
  16.896 -        mix_music = music_mixer;
  16.897 -    }
  16.898 -    Mix_UnlockAudio();
  16.899 -}
  16.900 -
  16.901 -void *Mix_GetMusicHookData(void)
  16.902 -{
  16.903 -    return(music_data);
  16.904 -}
  16.905 -
  16.906 -void Mix_ChannelFinished(void (SDLCALL *channel_finished)(int channel))
  16.907 -{
  16.908 -    Mix_LockAudio();
  16.909 -    channel_done_callback = channel_finished;
  16.910 -    Mix_UnlockAudio();
  16.911 -}
  16.912 -
  16.913 -
  16.914 -/* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
  16.915 -   them dynamically to the next sample if requested with a -1 value below.
  16.916 -   Returns the number of reserved channels.
  16.917 - */
  16.918 -int Mix_ReserveChannels(int num)
  16.919 -{
  16.920 -    if (num > num_channels)
  16.921 -        num = num_channels;
  16.922 -    reserved_channels = num;
  16.923 -    return num;
  16.924 -}
  16.925 -
  16.926 -static int checkchunkintegral(Mix_Chunk *chunk)
  16.927 -{
  16.928 -    int frame_width = 1;
  16.929 -
  16.930 -    if ((mixer.format & 0xFF) == 16) frame_width = 2;
  16.931 -    frame_width *= mixer.channels;
  16.932 -    while (chunk->alen % frame_width) chunk->alen--;
  16.933 -    return chunk->alen;
  16.934 -}
  16.935 -
  16.936 -/* Play an audio chunk on a specific channel.
  16.937 -   If the specified channel is -1, play on the first free channel.
  16.938 -   'ticks' is the number of milliseconds at most to play the sample, or -1
  16.939 -   if there is no limit.
  16.940 -   Returns which channel was used to play the sound.
  16.941 -*/
  16.942 -int Mix_PlayChannelTimed(int which, Mix_Chunk *chunk, int loops, int ticks)
  16.943 -{
  16.944 -    int i;
  16.945 -
  16.946 -    /* Don't play null pointers :-) */
  16.947 -    if (chunk == NULL) {
  16.948 -        Mix_SetError("Tried to play a NULL chunk");
  16.949 -        return(-1);
  16.950 -    }
  16.951 -    if (!checkchunkintegral(chunk)) {
  16.952 -        Mix_SetError("Tried to play a chunk with a bad frame");
  16.953 -        return(-1);
  16.954 -    }
  16.955 -
  16.956 -    /* Lock the mixer while modifying the playing channels */
  16.957 -    Mix_LockAudio();
  16.958 -    {
  16.959 -        /* If which is -1, play on the first free channel */
  16.960 -        if (which == -1) {
  16.961 -            for (i=reserved_channels; i<num_channels; ++i) {
  16.962 -                if (mix_channel[i].playing <= 0)
  16.963 -                    break;
  16.964 -            }
  16.965 -            if (i == num_channels) {
  16.966 -                Mix_SetError("No free channels available");
  16.967 -                which = -1;
  16.968 -            } else {
  16.969 -                which = i;
  16.970 -            }
  16.971 -        }
  16.972 -
  16.973 -        /* Queue up the audio data for this channel */
  16.974 -        if (which >= 0 && which < num_channels) {
  16.975 -            Uint32 sdl_ticks = SDL_GetTicks();
  16.976 -            if (Mix_Playing(which))
  16.977 -                _Mix_channel_done_playing(which);
  16.978 -            mix_channel[which].samples = chunk->abuf;
  16.979 -            mix_channel[which].playing = (int)chunk->alen;
  16.980 -            mix_channel[which].looping = loops;
  16.981 -            mix_channel[which].chunk = chunk;
  16.982 -            mix_channel[which].paused = 0;
  16.983 -            mix_channel[which].fading = MIX_NO_FADING;
  16.984 -            mix_channel[which].start_time = sdl_ticks;
  16.985 -            mix_channel[which].expire = (ticks > 0) ? (sdl_ticks + (Uint32)ticks) : 0;
  16.986 -        }
  16.987 -    }
  16.988 -    Mix_UnlockAudio();
  16.989 -
  16.990 -    /* Return the channel on which the sound is being played */
  16.991 -    return(which);
  16.992 -}
  16.993 -
  16.994 -/* Change the expiration delay for a channel */
  16.995 -int Mix_ExpireChannel(int which, int ticks)
  16.996 -{
  16.997 -    int status = 0;
  16.998 -
  16.999 -    if (which == -1) {
 16.1000 -        int i;
 16.1001 -        for (i=0; i < num_channels; ++ i) {
 16.1002 -            status += Mix_ExpireChannel(i, ticks);
 16.1003 -        }
 16.1004 -    } else if (which < num_channels) {
 16.1005 -        Mix_LockAudio();
 16.1006 -        mix_channel[which].expire = (ticks>0) ? (SDL_GetTicks() + (Uint32)ticks) : 0;
 16.1007 -        Mix_UnlockAudio();
 16.1008 -        ++ status;
 16.1009 -    }
 16.1010 -    return(status);
 16.1011 -}
 16.1012 -
 16.1013 -/* Fade in a sound on a channel, over ms milliseconds */
 16.1014 -int Mix_FadeInChannelTimed(int which, Mix_Chunk *chunk, int loops, int ms, int ticks)
 16.1015 -{
 16.1016 -    int i;
 16.1017 -
 16.1018 -    /* Don't play null pointers :-) */
 16.1019 -    if (chunk == NULL) {
 16.1020 -        return(-1);
 16.1021 -    }
 16.1022 -    if (!checkchunkintegral(chunk)) {
 16.1023 -        Mix_SetError("Tried to play a chunk with a bad frame");
 16.1024 -        return(-1);
 16.1025 -    }
 16.1026 -
 16.1027 -    /* Lock the mixer while modifying the playing channels */
 16.1028 -    Mix_LockAudio();
 16.1029 -    {
 16.1030 -        /* If which is -1, play on the first free channel */
 16.1031 -        if (which == -1) {
 16.1032 -            for (i=reserved_channels; i<num_channels; ++i) {
 16.1033 -                if (mix_channel[i].playing <= 0)
 16.1034 -                    break;
 16.1035 -            }
 16.1036 -            if (i == num_channels) {
 16.1037 -                which = -1;
 16.1038 -            } else {
 16.1039 -                which = i;
 16.1040 -            }
 16.1041 -        }
 16.1042 -
 16.1043 -        /* Queue up the audio data for this channel */
 16.1044 -        if (which >= 0 && which < num_channels) {
 16.1045 -            Uint32 sdl_ticks = SDL_GetTicks();
 16.1046 -            if (Mix_Playing(which))
 16.1047 -                _Mix_channel_done_playing(which);
 16.1048 -            mix_channel[which].samples = chunk->abuf;
 16.1049 -            mix_channel[which].playing = (int)chunk->alen;
 16.1050 -            mix_channel[which].looping = loops;
 16.1051 -            mix_channel[which].chunk = chunk;
 16.1052 -            mix_channel[which].paused = 0;
 16.1053 -            if (mix_channel[which].fading == MIX_NO_FADING) {
 16.1054 -                mix_channel[which].fade_volume_reset = mix_channel[which].volume;
 16.1055 -            }
 16.1056 -            mix_channel[which].fading = MIX_FADING_IN;
 16.1057 -            mix_channel[which].fade_volume = mix_channel[which].volume;
 16.1058 -            mix_channel[which].volume = 0;
 16.1059 -            mix_channel[which].fade_length = (Uint32)ms;
 16.1060 -            mix_channel[which].start_time = mix_channel[which].ticks_fade = sdl_ticks;
 16.1061 -            mix_channel[which].expire = (ticks > 0) ? (sdl_ticks+(Uint32)ticks) : 0;
 16.1062 -        }
 16.1063 -    }
 16.1064 -    Mix_UnlockAudio();
 16.1065 -
 16.1066 -    /* Return the channel on which the sound is being played */
 16.1067 -    return(which);
 16.1068 -}
 16.1069 -
 16.1070 -/* Set volume of a particular channel */
 16.1071 -int Mix_Volume(int which, int volume)
 16.1072 -{
 16.1073 -    int i;
 16.1074 -    int prev_volume = 0;
 16.1075 -
 16.1076 -    if (which == -1) {
 16.1077 -        for (i=0; i<num_channels; ++i) {
 16.1078 -            prev_volume += Mix_Volume(i, volume);
 16.1079 -        }
 16.1080 -        prev_volume /= num_channels;
 16.1081 -    } else if (which < num_channels) {
 16.1082 -        prev_volume = mix_channel[which].volume;
 16.1083 -        if (volume >= 0) {
 16.1084 -            if (volume > MIX_MAX_VOLUME) {
 16.1085 -                volume = MIX_MAX_VOLUME;
 16.1086 -            }
 16.1087 -            mix_channel[which].volume = volume;
 16.1088 -        }
 16.1089 -    }
 16.1090 -    return(prev_volume);
 16.1091 -}
 16.1092 -/* Set volume of a particular chunk */
 16.1093 -int Mix_VolumeChunk(Mix_Chunk *chunk, int volume)
 16.1094 -{
 16.1095 -    int prev_volume;
 16.1096 -
 16.1097 -    prev_volume = chunk->volume;
 16.1098 -    if (volume >= 0) {
 16.1099 -        if (volume > MIX_MAX_VOLUME) {
 16.1100 -            volume = MIX_MAX_VOLUME;
 16.1101 -        }
 16.1102 -        chunk->volume = volume;
 16.1103 -    }
 16.1104 -    return(prev_volume);
 16.1105 -}
 16.1106 -
 16.1107 -/* Halt playing of a particular channel */
 16.1108 -int Mix_HaltChannel(int which)
 16.1109 -{
 16.1110 -    int i;
 16.1111 -
 16.1112 -    if (which == -1) {
 16.1113 -        for (i=0; i<num_channels; ++i) {
 16.1114 -            Mix_HaltChannel(i);
 16.1115 -        }
 16.1116 -    } else if (which < num_channels) {
 16.1117 -        Mix_LockAudio();
 16.1118 -        if (mix_channel[which].playing) {
 16.1119 -            _Mix_channel_done_playing(which);
 16.1120 -            mix_channel[which].playing = 0;
 16.1121 -            mix_channel[which].looping = 0;
 16.1122 -        }
 16.1123 -        mix_channel[which].expire = 0;
 16.1124 -        if(mix_channel[which].fading != MIX_NO_FADING) /* Restore volume */
 16.1125 -            mix_channel[which].volume = mix_channel[which].fade_volume_reset;
 16.1126 -        mix_channel[which].fading = MIX_NO_FADING;
 16.1127 -        Mix_UnlockAudio();
 16.1128 -    }
 16.1129 -    return(0);
 16.1130 -}
 16.1131 -
 16.1132 -/* Halt playing of a particular group of channels */
 16.1133 -int Mix_HaltGroup(int tag)
 16.1134 -{
 16.1135 -    int i;
 16.1136 -
 16.1137 -    for (i=0; i<num_channels; ++i) {
 16.1138 -        if(mix_channel[i].tag == tag) {
 16.1139 -            Mix_HaltChannel(i);
 16.1140 -        }
 16.1141 -    }
 16.1142 -    return(0);
 16.1143 -}
 16.1144 -
 16.1145 -/* Fade out a channel and then stop it automatically */
 16.1146 -int Mix_FadeOutChannel(int which, int ms)
 16.1147 -{
 16.1148 -    int status;
 16.1149 -
 16.1150 -    status = 0;
 16.1151 -    if (audio_opened) {
 16.1152 -        if (which == -1) {
 16.1153 -            int i;
 16.1154 -
 16.1155 -            for (i=0; i<num_channels; ++i) {
 16.1156 -                status += Mix_FadeOutChannel(i, ms);
 16.1157 -            }
 16.1158 -        } else if (which < num_channels) {
 16.1159 -            Mix_LockAudio();
 16.1160 -            if (mix_channel[which].playing &&
 16.1161 -                (mix_channel[which].volume > 0) &&
 16.1162 -                (mix_channel[which].fading != MIX_FADING_OUT)) {
 16.1163 -                mix_channel[which].fade_volume = mix_channel[which].volume;
 16.1164 -                mix_channel[which].fade_length = (Uint32)ms;
 16.1165 -                mix_channel[which].ticks_fade = SDL_GetTicks();
 16.1166 -
 16.1167 -                /* only change fade_volume_reset if we're not fading. */
 16.1168 -                if (mix_channel[which].fading == MIX_NO_FADING) {
 16.1169 -                    mix_channel[which].fade_volume_reset = mix_channel[which].volume;
 16.1170 -                }
 16.1171 -
 16.1172 -                mix_channel[which].fading = MIX_FADING_OUT;
 16.1173 -
 16.1174 -                ++status;
 16.1175 -            }
 16.1176 -            Mix_UnlockAudio();
 16.1177 -        }
 16.1178 -    }
 16.1179 -    return(status);
 16.1180 -}
 16.1181 -
 16.1182 -/* Halt playing of a particular group of channels */
 16.1183 -int Mix_FadeOutGroup(int tag, int ms)
 16.1184 -{
 16.1185 -    int i;
 16.1186 -    int status = 0;
 16.1187 -    for (i=0; i<num_channels; ++i) {
 16.1188 -        if(mix_channel[i].tag == tag) {
 16.1189 -            status += Mix_FadeOutChannel(i,ms);
 16.1190 -        }
 16.1191 -    }
 16.1192 -    return(status);
 16.1193 -}
 16.1194 -
 16.1195 -Mix_Fading Mix_FadingChannel(int which)
 16.1196 -{
 16.1197 -    if (which < 0 || which >= num_channels) {
 16.1198 -        return MIX_NO_FADING;
 16.1199 -    }
 16.1200 -    return mix_channel[which].fading;
 16.1201 -}
 16.1202 -
 16.1203 -/* Check the status of a specific channel.
 16.1204 -   If the specified mix_channel is -1, check all mix channels.
 16.1205 -*/
 16.1206 -int Mix_Playing(int which)
 16.1207 -{
 16.1208 -    int status;
 16.1209 -
 16.1210 -    status = 0;
 16.1211 -    if (which == -1) {
 16.1212 -        int i;
 16.1213 -
 16.1214 -        for (i=0; i<num_channels; ++i) {
 16.1215 -            if ((mix_channel[i].playing > 0) ||
 16.1216 -                mix_channel[i].looping)
 16.1217 -            {
 16.1218 -                ++status;
 16.1219 -            }
 16.1220 -        }
 16.1221 -    } else if (which < num_channels) {
 16.1222 -        if ((mix_channel[which].playing > 0) ||
 16.1223 -             mix_channel[which].looping)
 16.1224 -        {
 16.1225 -            ++status;
 16.1226 -        }
 16.1227 -    }
 16.1228 -    return(status);
 16.1229 -}
 16.1230 -
 16.1231 -/* rcg06072001 Get the chunk associated with a channel. */
 16.1232 -Mix_Chunk *Mix_GetChunk(int channel)
 16.1233 -{
 16.1234 -    Mix_Chunk *retval = NULL;
 16.1235 -
 16.1236 -    if ((channel >= 0) && (channel < num_channels)) {
 16.1237 -        retval = mix_channel[channel].chunk;
 16.1238 -    }
 16.1239 -
 16.1240 -    return(retval);
 16.1241 -}
 16.1242 -
 16.1243 -/* Close the mixer, halting all playing audio */
 16.1244 -void Mix_CloseAudio(void)
 16.1245 -{
 16.1246 -    int i;
 16.1247 -
 16.1248 -    if (audio_opened) {
 16.1249 -        if (audio_opened == 1) {
 16.1250 -            for (i = 0; i < num_channels; i++) {
 16.1251 -                Mix_UnregisterAllEffects(i);
 16.1252 -            }
 16.1253 -            Mix_UnregisterAllEffects(MIX_CHANNEL_POST);
 16.1254 -            close_music();
 16.1255 -            Mix_SetMusicCMD(NULL);
 16.1256 -            Mix_HaltChannel(-1);
 16.1257 -            _Mix_DeinitEffects();
 16.1258 -            SDL_CloseAudioDevice(audio_device);
 16.1259 -            audio_device = 0;
 16.1260 -            SDL_free(mix_channel);
 16.1261 -            mix_channel = NULL;
 16.1262 -
 16.1263 -            /* rcg06042009 report available decoders at runtime. */
 16.1264 -            SDL_free((void *)chunk_decoders);
 16.1265 -            chunk_decoders = NULL;
 16.1266 -            num_decoders = 0;
 16.1267 -        }
 16.1268 -        --audio_opened;
 16.1269 -    }
 16.1270 -}
 16.1271 -
 16.1272 -/* Pause a particular channel (or all) */
 16.1273 -void Mix_Pause(int which)
 16.1274 -{
 16.1275 -    Uint32 sdl_ticks = SDL_GetTicks();
 16.1276 -    if (which == -1) {
 16.1277 -        int i;
 16.1278 -
 16.1279 -        for (i=0; i<num_channels; ++i) {
 16.1280 -            if (mix_channel[i].playing > 0) {
 16.1281 -                mix_channel[i].paused = sdl_ticks;
 16.1282 -            }
 16.1283 -        }
 16.1284 -    } else if (which < num_channels) {
 16.1285 -        if (mix_channel[which].playing > 0) {
 16.1286 -            mix_channel[which].paused = sdl_ticks;
 16.1287 -        }
 16.1288 -    }
 16.1289 -}
 16.1290 -
 16.1291 -/* Resume a paused channel */
 16.1292 -void Mix_Resume(int which)
 16.1293 -{
 16.1294 -    Uint32 sdl_ticks = SDL_GetTicks();
 16.1295 -
 16.1296 -    Mix_LockAudio();
 16.1297 -    if (which == -1) {
 16.1298 -        int i;
 16.1299 -
 16.1300 -        for (i=0; i<num_channels; ++i) {
 16.1301 -            if (mix_channel[i].playing > 0) {
 16.1302 -                if(mix_channel[i].expire > 0)
 16.1303 -                    mix_channel[i].expire += sdl_ticks - mix_channel[i].paused;
 16.1304 -                mix_channel[i].paused = 0;
 16.1305 -            }
 16.1306 -        }
 16.1307 -    } else if (which < num_channels) {
 16.1308 -        if (mix_channel[which].playing > 0) {
 16.1309 -            if(mix_channel[which].expire > 0)
 16.1310 -                mix_channel[which].expire += sdl_ticks - mix_channel[which].paused;
 16.1311 -            mix_channel[which].paused = 0;
 16.1312 -        }
 16.1313 -    }
 16.1314 -    Mix_UnlockAudio();
 16.1315 -}
 16.1316 -
 16.1317 -int Mix_Paused(int which)
 16.1318 -{
 16.1319 -    if (which < 0) {
 16.1320 -        int status = 0;
 16.1321 -        int i;
 16.1322 -        for(i=0; i < num_channels; ++i) {
 16.1323 -            if (mix_channel[i].paused) {
 16.1324 -                ++ status;
 16.1325 -            }
 16.1326 -        }
 16.1327 -        return(status);
 16.1328 -    } else if (which < num_channels) {
 16.1329 -        return(mix_channel[which].paused != 0);
 16.1330 -    } else {
 16.1331 -        return(0);
 16.1332 -    }
 16.1333 -}
 16.1334 -
 16.1335 -/* Change the group of a channel */
 16.1336 -int Mix_GroupChannel(int which, int tag)
 16.1337 -{
 16.1338 -    if (which < 0 || which > num_channels)
 16.1339 -        return(0);
 16.1340 -
 16.1341 -    Mix_LockAudio();
 16.1342 -    mix_channel[which].tag = tag;
 16.1343 -    Mix_UnlockAudio();
 16.1344 -    return(1);
 16.1345 -}
 16.1346 -
 16.1347 -/* Assign several consecutive channels to a group */
 16.1348 -int Mix_GroupChannels(int from, int to, int tag)
 16.1349 -{
 16.1350 -    int status = 0;
 16.1351 -    for(; from <= to; ++ from) {
 16.1352 -        status += Mix_GroupChannel(from, tag);
 16.1353 -    }
 16.1354 -    return(status);
 16.1355 -}
 16.1356 -
 16.1357 -/* Finds the first available channel in a group of channels */
 16.1358 -int Mix_GroupAvailable(int tag)
 16.1359 -{
 16.1360 -    int i;
 16.1361 -    for(i=0; i < num_channels; i ++) {
 16.1362 -        if (((tag == -1) || (tag == mix_channel[i].tag)) &&
 16.1363 -                            (mix_channel[i].playing <= 0))
 16.1364 -            return i;
 16.1365 -    }
 16.1366 -    return(-1);
 16.1367 -}
 16.1368 -
 16.1369 -int Mix_GroupCount(int tag)
 16.1370 -{
 16.1371 -    int count = 0;
 16.1372 -    int i;
 16.1373 -    for(i=0; i < num_channels; i ++) {
 16.1374 -        if (mix_channel[i].tag==tag || tag==-1)
 16.1375 -            ++ count;
 16.1376 -    }
 16.1377 -    return(count);
 16.1378 -}
 16.1379 -
 16.1380 -/* Finds the "oldest" sample playing in a group of channels */
 16.1381 -int Mix_GroupOldest(int tag)
 16.1382 -{
 16.1383 -    int chan = -1;
 16.1384 -    Uint32 mintime = SDL_GetTicks();
 16.1385 -    int i;
 16.1386 -    for(i=0; i < num_channels; i ++) {
 16.1387 -        if ((mix_channel[i].tag==tag || tag==-1) && mix_channel[i].playing > 0
 16.1388 -             && mix_channel[i].start_time <= mintime) {
 16.1389 -            mintime = mix_channel[i].start_time;
 16.1390 -            chan = i;
 16.1391 -        }
 16.1392 -    }
 16.1393 -    return(chan);
 16.1394 -}
 16.1395 -
 16.1396 -/* Finds the "most recent" (i.e. last) sample playing in a group of channels */
 16.1397 -int Mix_GroupNewer(int tag)
 16.1398 -{
 16.1399 -    int chan = -1;
 16.1400 -    Uint32 maxtime = 0;
 16.1401 -    int i;
 16.1402 -    for(i=0; i < num_channels; i ++) {
 16.1403 -        if ((mix_channel[i].tag==tag || tag==-1) && mix_channel[i].playing > 0
 16.1404 -             && mix_channel[i].start_time >= maxtime) {
 16.1405 -            maxtime = mix_channel[i].start_time;
 16.1406 -            chan = i;
 16.1407 -        }
 16.1408 -    }
 16.1409 -    return(chan);
 16.1410 -}
 16.1411 -
 16.1412 -
 16.1413 -
 16.1414 -/*
 16.1415 - * rcg06122001 The special effects exportable API.
 16.1416 - *  Please see effect_*.c for internally-implemented effects, such
 16.1417 - *  as Mix_SetPanning().
 16.1418 - */
 16.1419 -
 16.1420 -/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
 16.1421 -static int _Mix_register_effect(effect_info **e, Mix_EffectFunc_t f,
 16.1422 -                Mix_EffectDone_t d, void *arg)
 16.1423 -{
 16.1424 -    effect_info *new_e;
 16.1425 -
 16.1426 -    if (!e) {
 16.1427 -        Mix_SetError("Internal error");
 16.1428 -        return(0);
 16.1429 -    }
 16.1430 -
 16.1431 -    if (f == NULL) {
 16.1432 -        Mix_SetError("NULL effect callback");
 16.1433 -        return(0);
 16.1434 -    }
 16.1435 -
 16.1436 -    new_e = SDL_malloc(sizeof (effect_info));
 16.1437 -    if (new_e == NULL) {
 16.1438 -        Mix_SetError("Out of memory");
 16.1439 -        return(0);
 16.1440 -    }
 16.1441 -
 16.1442 -    new_e->callback = f;
 16.1443 -    new_e->done_callback = d;
 16.1444 -    new_e->udata = arg;
 16.1445 -    new_e->next = NULL;
 16.1446 -
 16.1447 -    /* add new effect to end of linked list... */
 16.1448 -    if (*e == NULL) {
 16.1449 -        *e = new_e;
 16.1450 -    } else {
 16.1451 -        effect_info *cur = *e;
 16.1452 -        while (1) {
 16.1453 -            if (cur->next == NULL) {
 16.1454 -                cur->next = new_e;
 16.1455 -                break;
 16.1456 -            }
 16.1457 -            cur = cur->next;
 16.1458 -        }
 16.1459 -    }
 16.1460 -
 16.1461 -    return(1);
 16.1462 -}
 16.1463 -
 16.1464 -
 16.1465 -/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
 16.1466 -static int _Mix_remove_effect(int channel, effect_info **e, Mix_EffectFunc_t f)
 16.1467 -{
 16.1468 -    effect_info *cur;
 16.1469 -    effect_info *prev = NULL;
 16.1470 -    effect_info *next = NULL;
 16.1471 -
 16.1472 -    if (!e) {
 16.1473 -        Mix_SetError("Internal error");
 16.1474 -        return(0);
 16.1475 -    }
 16.1476 -
 16.1477 -    for (cur = *e; cur != NULL; cur = cur->next) {
 16.1478 -        if (cur->callback == f) {
 16.1479 -            next = cur->next;
 16.1480 -            if (cur->done_callback != NULL) {
 16.1481 -                cur->done_callback(channel, cur->udata);
 16.1482 -            }
 16.1483 -            SDL_free(cur);
 16.1484 -
 16.1485 -            if (prev == NULL) {   /* removing first item of list? */
 16.1486 -                *e = next;
 16.1487 -            } else {
 16.1488 -                prev->next = next;
 16.1489 -            }
 16.1490 -            return(1);
 16.1491 -        }
 16.1492 -        prev = cur;
 16.1493 -    }
 16.1494 -
 16.1495 -    Mix_SetError("No such effect registered");
 16.1496 -    return(0);
 16.1497 -}
 16.1498 -
 16.1499 -
 16.1500 -/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
 16.1501 -static int _Mix_remove_all_effects(int channel, effect_info **e)
 16.1502 -{
 16.1503 -    effect_info *cur;
 16.1504 -    effect_info *next;
 16.1505 -
 16.1506 -    if (!e) {
 16.1507 -        Mix_SetError("Internal error");
 16.1508 -        return(0);
 16.1509 -    }
 16.1510 -
 16.1511 -    for (cur = *e; cur != NULL; cur = next) {
 16.1512 -        next = cur->next;
 16.1513 -        if (cur->done_callback != NULL) {
 16.1514 -            cur->done_callback(channel, cur->udata);
 16.1515 -        }
 16.1516 -        SDL_free(cur);
 16.1517 -    }
 16.1518 -    *e = NULL;
 16.1519 -
 16.1520 -    return(1);
 16.1521 -}
 16.1522 -
 16.1523 -
 16.1524 -/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
 16.1525 -int _Mix_RegisterEffect_locked(int channel, Mix_EffectFunc_t f,
 16.1526 -            Mix_EffectDone_t d, void *arg)
 16.1527 -{
 16.1528 -    effect_info **e = NULL;
 16.1529 -
 16.1530 -    if (channel == MIX_CHANNEL_POST) {
 16.1531 -        e = &posteffects;
 16.1532 -    } else {
 16.1533 -        if ((channel < 0) || (channel >= num_channels)) {
 16.1534 -            Mix_SetError("Invalid channel number");
 16.1535 -            return(0);
 16.1536 -        }
 16.1537 -        e = &mix_channel[channel].effects;
 16.1538 -    }
 16.1539 -
 16.1540 -    return _Mix_register_effect(e, f, d, arg);
 16.1541 -}
 16.1542 -
 16.1543 -int Mix_RegisterEffect(int channel, Mix_EffectFunc_t f,
 16.1544 -            Mix_EffectDone_t d, void *arg)
 16.1545 -{
 16.1546 -    int retval;
 16.1547 -    Mix_LockAudio();
 16.1548 -    retval = _Mix_RegisterEffect_locked(channel, f, d, arg);
 16.1549 -    Mix_UnlockAudio();
 16.1550 -    return retval;
 16.1551 -}
 16.1552 -
 16.1553 -
 16.1554 -/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
 16.1555 -int _Mix_UnregisterEffect_locked(int channel, Mix_EffectFunc_t f)
 16.1556 -{
 16.1557 -    effect_info **e = NULL;
 16.1558 -
 16.1559 -    if (channel == MIX_CHANNEL_POST) {
 16.1560 -        e = &posteffects;
 16.1561 -    } else {
 16.1562 -        if ((channel < 0) || (channel >= num_channels)) {
 16.1563 -            Mix_SetError("Invalid channel number");
 16.1564 -            return(0);
 16.1565 -        }
 16.1566 -        e = &mix_channel[channel].effects;
 16.1567 -    }
 16.1568 -
 16.1569 -    return _Mix_remove_effect(channel, e, f);
 16.1570 -}
 16.1571 -
 16.1572 -int Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f)
 16.1573 -{
 16.1574 -    int retval;
 16.1575 -    Mix_LockAudio();
 16.1576 -    retval = _Mix_UnregisterEffect_locked(channel, f);
 16.1577 -    Mix_UnlockAudio();
 16.1578 -    return(retval);
 16.1579 -}
 16.1580 -
 16.1581 -/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */
 16.1582 -int _Mix_UnregisterAllEffects_locked(int channel)
 16.1583 -{
 16.1584 -    effect_info **e = NULL;
 16.1585 -
 16.1586 -    if (channel == MIX_CHANNEL_POST) {
 16.1587 -        e = &posteffects;
 16.1588 -    } else {
 16.1589 -        if ((channel < 0) || (channel >= num_channels)) {
 16.1590 -            Mix_SetError("Invalid channel number");
 16.1591 -            return(0);
 16.1592 -        }
 16.1593 -        e = &mix_channel[channel].effects;
 16.1594 -    }
 16.1595 -
 16.1596 -    return _Mix_remove_all_effects(channel, e);
 16.1597 -}
 16.1598 -
 16.1599 -int Mix_UnregisterAllEffects(int channel)
 16.1600 -{
 16.1601 -    int retval;
 16.1602 -    Mix_LockAudio();
 16.1603 -    retval = _Mix_UnregisterAllEffects_locked(channel);
 16.1604 -    Mix_UnlockAudio();
 16.1605 -    return(retval);
 16.1606 -}
 16.1607 -
 16.1608 -void Mix_LockAudio(void)
 16.1609 -{
 16.1610 -    SDL_LockAudioDevice(audio_device);
 16.1611 -}
 16.1612 -
 16.1613 -void Mix_UnlockAudio(void)
 16.1614 -{
 16.1615 -    SDL_UnlockAudioDevice(audio_device);
 16.1616 -}
 16.1617 -
 16.1618 -/* end of mixer.c ... */
 16.1619 -
 16.1620 -/* vi: set ts=4 sw=4 expandtab: */
    17.1 --- a/mixer.h	Mon Nov 18 18:50:50 2019 +0300
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,28 +0,0 @@
    17.4 -/*
    17.5 -  SDL_mixer:  An audio mixer library based on the SDL library
    17.6 -  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
    17.7 -
    17.8 -  This software is provided 'as-is', without any express or implied
    17.9 -  warranty.  In no event will the authors be held liable for any damages
   17.10 -  arising from the use of this software.
   17.11 -
   17.12 -  Permission is granted to anyone to use this software for any purpose,
   17.13 -  including commercial applications, and to alter it and redistribute it
   17.14 -  freely, subject to the following restrictions:
   17.15 -
   17.16 -  1. The origin of this software must not be misrepresented; you must not
   17.17 -     claim that you wrote the original software. If you use this software
   17.18 -     in a product, an acknowledgment in the product documentation would be
   17.19 -     appreciated but is not required.
   17.20 -  2. Altered source versions must be plainly marked as such, and must not be
   17.21 -     misrepresented as being the original software.
   17.22 -  3. This notice may not be removed or altered from any source distribution.
   17.23 -*/
   17.24 -
   17.25 -/* Locking wrapper functions */
   17.26 -extern void Mix_LockAudio(void);
   17.27 -extern void Mix_UnlockAudio(void);
   17.28 -
   17.29 -extern void add_chunk_decoder(const char *decoder);
   17.30 -
   17.31 -/* vi: set ts=4 sw=4 expandtab: */
    18.1 --- a/music.c	Mon Nov 18 18:50:50 2019 +0300
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,1171 +0,0 @@
    18.4 -/*
    18.5 -  SDL_mixer:  An audio mixer library based on the SDL library
    18.6 -  Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
    18.7 -
    18.8 -  This software is provided 'as-is', without any express or implied
    18.9 -  warranty.  In no event will the authors be held liable for any damages
   18.10 -  arising from the use of this software.
   18.11 -
   18.12 -  Permission is granted to anyone to use this software for any purpose,
   18.13 -  including commercial applications, and to alter it and redistribute it
   18.14 -  freely, subject to the following restrictions:
   18.15 -
   18.16 -  1. The origin of this software must not be misrepresented; you must not
   18.17 -     claim that you wrote the original software. If you use this software
   18.18 -     in a product, an acknowledgment in the product documentation would be
   18.19 -     appreciated but is not required.
   18.20 -  2. Altered source versions must be plainly marked as such, and must not be
   18.21 -     misrepresented as being the original software.
   18.22 -  3. This notice may not be removed or altered from any source distribution.
   18.23 -*/
   18.24 -#include <string.h> /* for strtok() and strtok_s() */
   18.25 -
   18.26 -#include "SDL_hints.h"
   18.27 -#include "SDL_log.h"
   18.28 -#include "SDL_timer.h"
   18.29 -
   18.30 -#include "SDL_mixer.h"
   18.31 -#include "mixer.h"
   18.32 -#include "music.h"
   18.33 -
   18.34 -#include "music_cmd.h"
   18.35 -#include "music_wav.h"
   18.36 -#include "music_mikmod.h"
   18.37 -#include "music_modplug.h"
   18.38 -#include "music_nativemidi.h"
   18.39 -#include "music_fluidsynth.h"
   18.40 -#include "music_timidity.h"
   18.41 -#include "music_ogg.h"
   18.42 -#include "music_opus.h"
   18.43 -#include "music_mpg123.h"
   18.44 -#include "music_mad.h"
   18.45 -#include "music_flac.h"
   18.46 -#include "native_midi/native_midi.h"
   18.47 -
   18.48 -/* Check to make sure we are building with a new enough SDL */
   18.49 -#if SDL_COMPILEDVERSION < SDL_VERSIONNUM(2, 0, 7)
   18.50 -#error You need SDL 2.0.7 or newer from http://www.libsdl.org
   18.51 -#endif
   18.52 -
   18.53 -/* Set this hint to true if you want verbose logging of music interfaces */
   18.54 -#define SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES \
   18.55 -    "SDL_MIXER_DEBUG_MUSIC_INTERFACES"
   18.56 -
   18.57 -char *music_cmd = NULL;
   18.58 -static SDL_bool music_active = SDL_TRUE;
   18.59 -static int music_volume = MIX_MAX_VOLUME;
   18.60 -static Mix_Music * volatile music_playing = NULL;
   18.61 -SDL_AudioSpec music_spec;
   18.62 -
   18.63 -struct _Mix_Music {
   18.64 -    Mix_MusicInterface *interface;
   18.65 -    void *context;
   18.66 -
   18.67 -    SDL_bool playing;
   18.68 -    Mix_Fading fading;
   18.69 -    int fade_step;
   18.70 -    int fade_steps;
   18.71 -};
   18.72 -
   18.73 -/* Used to calculate fading steps */
   18.74 -static int ms_per_step;
   18.75 -
   18.76 -/* rcg06042009 report available decoders at runtime. */
   18.77 -static const char **music_decoders = NULL;
   18.78 -static int num_decoders = 0;
   18.79 -
   18.80 -/* Semicolon-separated SoundFont paths */
   18.81 -static char* soundfont_paths = NULL;
   18.82 -
   18.83 -/* Interfaces for the various music interfaces, ordered by priority */
   18.84 -static Mix_MusicInterface *s_music_interfaces[] =
   18.85 -{
   18.86 -#ifdef MUSIC_CMD
   18.87 -    &Mix_MusicInterface_CMD,
   18.88 -#endif
   18.89 -#ifdef MUSIC_WAV
   18.90 -    &Mix_MusicInterface_WAV,
   18.91 -#endif
   18.92 -#ifdef MUSIC_FLAC
   18.93 -    &Mix_MusicInterface_FLAC,
   18.94 -#endif
   18.95 -#ifdef MUSIC_OGG
   18.96 -    &Mix_MusicInterface_OGG,
   18.97 -#endif
   18.98 -#ifdef MUSIC_OPUS
   18.99 -    &Mix_MusicInterface_Opus,
  18.100 -#endif
  18.101 -#ifdef MUSIC_MP3_MPG123
  18.102 -    &Mix_MusicInterface_MPG123,
  18.103 -#endif
  18.104 -#ifdef MUSIC_MP3_MAD
  18.105 -    &Mix_MusicInterface_MAD,
  18.106 -#endif
  18.107 -#ifdef MUSIC_MOD_MODPLUG
  18.108 -    &Mix_MusicInterface_MODPLUG,
  18.109 -#endif
  18.110 -#ifdef MUSIC_MOD_MIKMOD
  18.111 -    &Mix_MusicInterface_MIKMOD,
  18.112 -#endif
  18.113 -#ifdef MUSIC_MID_FLUIDSYNTH
  18.114 -    &Mix_MusicInterface_FLUIDSYNTH,
  18.115 -#endif
  18.116 -#ifdef MUSIC_MID_TIMIDITY
  18.117 -    &Mix_MusicInterface_TIMIDITY,
  18.118 -#endif
  18.119 -#ifdef MUSIC_MID_NATIVE
  18.120 -    &Mix_MusicInterface_NATIVEMIDI,
  18.121 -#endif
  18.122 -};
  18.123 -
  18.124 -int get_num_music_interfaces(void)
  18.125 -{
  18.126 -    return SDL_arraysize(s_music_interfaces);
  18.127 -}
  18.128 -
  18.129 -Mix_MusicInterface *get_music_interface(int index)
  18.130 -{
  18.131 -    return s_music_interfaces[index];
  18.132 -}
  18.133 -
  18.134 -int Mix_GetNumMusicDecoders(void)
  18.135 -{
  18.136 -    return(num_decoders);
  18.137 -}
  18.138 -
  18.139 -const char *Mix_GetMusicDecoder(int index)
  18.140 -{
  18.141 -    if ((index < 0) || (index >= num_decoders)) {
  18.142 -        return NULL;
  18.143 -    }
  18.144 -    return(music_decoders[index]);
  18.145 -}
  18.146 -
  18.147 -static void add_music_decoder(const char *decoder)
  18.148 -{
  18.149 -    void *ptr;
  18.150 -    int i;
  18.151 -
  18.152 -    /* Check to see if we already have this decoder */
  18.153 -    for (i = 0; i < num_decoders; ++i) {
  18.154 -        if (SDL_strcmp(music_decoders[i], decoder) == 0) {
  18.155 -            return;
  18.156 -        }
  18.157 -    }
  18.158 -
  18.159 -    ptr = SDL_realloc((void *)music_decoders, (num_decoders + 1) * sizeof (const char *));
  18.160 -    if (ptr == NULL) {
  18.161 -        return;  /* oh well, go on without it. */
  18.162 -    }
  18.163 -    music_decoders = (const char **) ptr;
  18.164 -    music_decoders[num_decoders++] = decoder;
  18.165 -}
  18.166 -
  18.167 -/* Local low-level functions prototypes */
  18.168 -static void music_internal_initialize_volume(void);
  18.169 -static void music_internal_volume(int volume);
  18.170 -static int  music_internal_play(Mix_Music *music, int play_count, double position);
  18.171 -static int  music_internal_position(double position);
  18.172 -static SDL_bool music_internal_playing(void);
  18.173 -static void music_internal_halt(void);
  18.174 -
  18.175 -
  18.176 -/* Support for hooking when the music has finished */
  18.177 -static void (SDLCALL *music_finished_hook)(void) = NULL;
  18.178 -
  18.179 -void Mix_HookMusicFinished(void (SDLCALL *music_finished)(void))
  18.180 -{
  18.181 -    Mix_LockAudio();
  18.182 -    music_finished_hook = music_finished;
  18.183 -    Mix_UnlockAudio();
  18.184 -}
  18.185 -
  18.186 -/* Convenience function to fill audio and mix at the specified volume
  18.187 -   This is called from many music player's GetAudio callback.
  18.188 - */
  18.189 -int music_pcm_getaudio(void *context, void *data, int bytes, int volume,
  18.190 -                       int (*GetSome)(void *context, void *data, int bytes, SDL_bool *done))
  18.191 -{
  18.192 -    Uint8 *snd = (Uint8 *)data;
  18.193 -    Uint8 *dst;
  18.194 -    int len = bytes;
  18.195 -    SDL_bool done = SDL_FALSE;
  18.196 -
  18.197 -    if (volume == MIX_MAX_VOLUME) {
  18.198 -        dst = snd;
  18.199 -    } else {
  18.200 -        dst = SDL_stack_alloc(Uint8, bytes);
  18.201 -    }
  18.202 -    while (len > 0 && !done) {
  18.203 -        int consumed = GetSome(context, dst, len, &done);
  18.204 -        if (consumed < 0) {
  18.205 -            break;
  18.206 -        }
  18.207 -
  18.208 -        if (volume == MIX_MAX_VOLUME) {
  18.209 -            dst += consumed;
  18.210 -        } else {
  18.211 -            SDL_MixAudioFormat(snd, dst, music_spec.format, (Uint32)consumed, volume);
  18.212 -            snd += consumed;
  18.213 -        }
  18.214 -        len -= consumed;
  18.215 -    }
  18.216 -    if (volume != MIX_MAX_VOLUME) {
  18.217 -        SDL_stack_free(dst);
  18.218 -    }
  18.219 -    return len;
  18.220 -}
  18.221 -
  18.222 -/* Mixing function */
  18.223 -void SDLCALL music_mixer(void *udata, Uint8 *stream, int len)
  18.224 -{
  18.225 -    (void)udata;
  18.226 -
  18.227 -    while (music_playing && music_active && len > 0) {
  18.228 -        /* Handle fading */
  18.229 -        if (music_playing->fading != MIX_NO_FADING) {
  18.230 -            if (music_playing->fade_step++ < music_playing->fade_steps) {
  18.231 -                int volume;
  18.232 -                int fade_step = music_playing->fade_step;
  18.233 -                int fade_steps = music_playing->fade_steps;
  18.234 -
  18.235 -                if (music_playing->fading == MIX_FADING_OUT) {
  18.236 -                    volume = (music_volume * (fade_steps-fade_step)) / fade_steps;
  18.237 -                } else { /* Fading in */
  18.238 -                    volume = (music_volume * fade_step) / fade_steps;
  18.239 -                }
  18.240 -                music_internal_volume(volume);
  18.241 -            } else {
  18.242 -                if (music_playing->fading == MIX_FADING_OUT) {
  18.243 -                    music_internal_halt();
  18.244 -                    if (music_finished_hook) {
  18.245 -                        music_finished_hook();
  18.246 -                    }
  18.247 -                    return;
  18.248 -                }
  18.249 -                music_playing->fading = MIX_NO_FADING;
  18.250 -            }
  18.251 -        }
  18.252 -
  18.253 -        if (music_playing->interface->GetAudio) {
  18.254 -            int left = music_playing->interface->GetAudio(music_playing->context, stream, len);
  18.255 -            if (left != 0) {
  18.256 -                /* Either an error or finished playing with data left */
  18.257 -                music_playing->playing = SDL_FALSE;
  18.258 -            }
  18.259 -            if (left > 0) {
  18.260 -                stream += (len - left);
  18.261 -                len = left;
  18.262 -            } else {
  18.263 -                len = 0;
  18.264 -            }
  18.265 -        } else {
  18.266 -            len = 0;
  18.267 -        }
  18.268 -
  18.269 -        if (!music_internal_playing()) {
  18.270 -            music_internal_halt();
  18.271 -            if (music_finished_hook) {
  18.272 -                music_finished_hook();
  18.273 -            }
  18.274 -        }
  18.275 -    }
  18.276 -}
  18.277 -
  18.278 -/* Load the music interface libraries for a given music type */
  18.279 -SDL_bool load_music_type(Mix_MusicType type)
  18.280 -{
  18.281 -    size_t i;
  18.282 -    int loaded = 0;
  18.283 -    for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
  18.284 -        Mix_MusicInterface *interface = s_music_interfaces[i];
  18.285 -        if (interface->type != type) {
  18.286 -            continue;
  18.287 -        }
  18.288 -        if (!interface->loaded) {
  18.289 -            char hint[64];
  18.290 -            SDL_snprintf(hint, sizeof(hint), "SDL_MIXER_DISABLE_%s", interface->tag);
  18.291 -            if (SDL_GetHintBoolean(hint, SDL_FALSE)) {
  18.292 -                continue;
  18.293 -            }
  18.294 -
  18.295 -            if (interface->Load && interface->Load() < 0) {
  18.296 -                if (SDL_GetHintBoolean(SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES, SDL_FALSE)) {
  18.297 -                    SDL_Log("Couldn't load %s: %s\n", interface->tag, Mix_GetError());
  18.298 -                }
  18.299 -                continue;
  18.300 -            }
  18.301 -            interface->loaded = SDL_TRUE;
  18.302 -        }
  18.303 -        ++loaded;
  18.304 -    }
  18.305 -    return (loaded > 0) ? SDL_TRUE : SDL_FALSE;
  18.306 -}
  18.307 -
  18.308 -/* Open the music interfaces for a given music type */
  18.309 -SDL_bool open_music_type(Mix_MusicType type)
  18.310 -{
  18.311 -    size_t i;
  18.312 -    int opened = 0;
  18.313 -    SDL_bool use_native_midi = SDL_FALSE;
  18.314 -
  18.315 -    if (!music_spec.format) {
  18.316 -        /* Music isn't opened yet */
  18.317 -        return SDL_FALSE;
  18.318 -    }
  18.319 -
  18.320 -#ifdef MUSIC_MID_NATIVE
  18.321 -    if (type == MUS_MID && SDL_GetHintBoolean("SDL_NATIVE_MUSIC", SDL_FALSE) && native_midi_detect()) {
  18.322 -        use_native_midi = SDL_TRUE;
  18.323 -    }
  18.324 -#endif
  18.325 -
  18.326 -    for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
  18.327 -        Mix_MusicInterface *interface = s_music_interfaces[i];
  18.328 -        if (!interface->loaded) {
  18.329 -            continue;
  18.330 -        }
  18.331 -        if (type != MUS_NONE && interface->type != type) {
  18.332 -            continue;
  18.333 -        }
  18.334 -
  18.335 -        if (interface->type == MUS_MID && use_native_midi && interface->api != MIX_MUSIC_NATIVEMIDI) {
  18.336 -            continue;
  18.337 -        }
  18.338 -
  18.339 -        if (!interface->opened) {
  18.340 -            if (interface->Open && interface->Open(&music_spec) < 0) {
  18.341 -                if (SDL_GetHintBoolean(SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES, SDL_FALSE)) {
  18.342 -                    SDL_Log("Couldn't open %s: %s\n", interface->tag, Mix_GetError());
  18.343 -                }
  18.344 -                continue;
  18.345 -            }
  18.346 -            interface->opened = SDL_TRUE;
  18.347 -            add_music_decoder(interface->tag);
  18.348 -        }
  18.349 -        ++opened;
  18.350 -    }
  18.351 -
  18.352 -    if (has_music(MUS_MOD)) {
  18.353 -        add_music_decoder("MOD");
  18.354 -        add_chunk_decoder("MOD");
  18.355 -    }
  18.356 -    if (has_music(MUS_MID)) {
  18.357 -        add_music_decoder("MIDI");
  18.358 -        add_chunk_decoder("MID");
  18.359 -    }
  18.360 -    if (has_music(MUS_OGG)) {
  18.361 -        add_music_decoder("OGG");
  18.362 -        add_chunk_decoder("OGG");
  18.363 -    }
  18.364 -    if (has_music(MUS_OPUS)) {
  18.365 -        add_music_decoder("OPUS");
  18.366 -        add_chunk_decoder("OPUS");
  18.367 -    }
  18.368 -    if (has_music(MUS_MP3)) {
  18.369 -        add_music_decoder("MP3");
  18.370 -        add_chunk_decoder("MP3");
  18.371 -    }
  18.372 -    if (has_music(MUS_FLAC)) {
  18.373 -        add_music_decoder("FLAC");
  18.374 -        add_chunk_decoder("FLAC");
  18.375 -    }
  18.376 -
  18.377 -    return (opened > 0) ? SDL_TRUE : SDL_FALSE;
  18.378 -}
  18.379 -
  18.380 -/* Initialize the music interfaces with a certain desired audio format */
  18.381 -void open_music(const SDL_AudioSpec *spec)
  18.382 -{
  18.383 -#ifdef MIX_INIT_SOUNDFONT_PATHS
  18.384 -    if (!soundfont_paths) {
  18.385 -        soundfont_paths = SDL_strdup(MIX_INIT_SOUNDFONT_PATHS);
  18.386 -    }
  18.387 -#endif
  18.388 -
  18.389 -    /* Load the music interfaces that don't have explicit initialization */
  18.390 -    load_music_type(MUS_CMD);
  18.391 -    load_music_type(MUS_WAV);
  18.392 -
  18.393 -    /* Open all the interfaces that are loaded */
  18.394 -    music_spec = *spec;
  18.395 -    open_music_type(MUS_NONE);
  18.396 -
  18.397 -    Mix_VolumeMusic(MIX_MAX_VOLUME);
  18.398 -
  18.399 -    /* Calculate the number of ms for each callback */
  18.400 -    ms_per_step = (int) (((float)spec->samples * 1000.0) / spec->freq);
  18.401 -}
  18.402 -
  18.403 -/* Return SDL_TRUE if the music type is available */
  18.404 -SDL_bool has_music(Mix_MusicType type)
  18.405 -{
  18.406 -    size_t i;
  18.407 -    for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
  18.408 -        Mix_MusicInterface *interface = s_music_interfaces[i];
  18.409 -        if (interface->type != type) {
  18.410 -            continue;
  18.411 -        }
  18.412 -        if (interface->opened) {
  18.413 -            return SDL_TRUE;
  18.414 -        }
  18.415 -    }
  18.416 -    return SDL_FALSE;
  18.417 -}
  18.418 -
  18.419 -Mix_MusicType detect_music_type(SDL_RWops *src)
  18.420 -{
  18.421 -    Uint8 magic[12];
  18.422 -
  18.423 -    if (SDL_RWread(src, magic, 1, 12) != 12) {
  18.424 -        Mix_SetError("Couldn't read first 12 bytes of audio data");
  18.425 -        return MUS_NONE;
  18.426 -    }
  18.427 -    SDL_RWseek(src, -12, RW_SEEK_CUR);
  18.428 -
  18.429 -    /* WAVE files have the magic four bytes "RIFF"
  18.430 -       AIFF files have the magic 12 bytes "FORM" XXXX "AIFF" */
  18.431 -    if (((SDL_memcmp(magic, "RIFF", 4) == 0) && (SDL_memcmp((magic+8), "WAVE", 4) == 0)) ||
  18.432 -        (SDL_memcmp(magic, "FORM", 4) == 0)) {
  18.433 -        return MUS_WAV;
  18.434 -    }
  18.435 -
  18.436 -    /* Ogg Vorbis files have the magic four bytes "OggS" */
  18.437 -    if (SDL_memcmp(magic, "OggS", 4) == 0) {
  18.438 -        SDL_RWseek(src, 28, RW_SEEK_CUR);
  18.439 -        SDL_RWread(src, magic, 1, 8);
  18.440 -        SDL_RWseek(src,-36, RW_SEEK_CUR);
  18.441 -        if (SDL_memcmp(magic, "OpusHead", 8) == 0) {
  18.442 -            return MUS_OPUS;
  18.443 -        }
  18.444 -        return MUS_OGG;
  18.445 -    }
  18.446 -
  18.447 -    /* FLAC files have the magic four bytes "fLaC" */
  18.448 -    if (SDL_memcmp(magic, "fLaC", 4) == 0) {
  18.449 -        return MUS_FLAC;
  18.450 -    }
  18.451 -
  18.452 -    /* MIDI files have the magic four bytes "MThd" */
  18.453 -    if (SDL_memcmp(magic, "MThd", 4) == 0) {
  18.454 -        return MUS_MID;
  18.455 -    }
  18.456 -
  18.457 -    if (SDL_memcmp(magic, "ID3", 3) == 0 ||
  18.458 -        (magic[0] == 0xFF && (magic[1] & 0xFE) == 0xFA)) {
  18.459 -        return MUS_MP3;
  18.460 -    }
  18.461 -
  18.462 -    /* Assume MOD format.
  18.463 -     *
  18.464 -     * Apparently there is no way to check if the file is really a MOD,
  18.465 -     * or there are too many formats supported by MikMod/ModPlug, or
  18.466 -     * MikMod/ModPlug does this check by itself. */
  18.467 -    return MUS_MOD;
  18.468 -}
  18.469 -
  18.470 -/* Load a music file */
  18.471 -Mix_Music *Mix_LoadMUS(const char *file)
  18.472 -{
  18.473 -    size_t i;
  18.474 -    void *context;
  18.475 -    char *ext;
  18.476 -    Mix_MusicType type;
  18.477 -    SDL_RWops *src;
  18.478 -
  18.479 -    for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
  18.480 -        Mix_MusicInterface *interface = s_music_interfaces[i];
  18.481 -        if (!interface->opened || !interface->CreateFromFile) {
  18.482 -            continue;
  18.483 -        }
  18.484 -
  18.485 -        context = interface->CreateFromFile(file);
  18.486 -        if (context) {
  18.487 -            /* Allocate memory for the music structure */
  18.488 -            Mix_Music *music = (Mix_Music *)SDL_calloc(1, sizeof(Mix_Music));
  18.489 -            if (music == NULL) {
  18.490 -                Mix_SetError("Out of memory");
  18.491 -                return NULL;
  18.492 -            }
  18.493 -            music->interface = interface;
  18.494 -            music->context = context;
  18.495 -            return music;
  18.496 -        }
  18.497 -    }
  18.498 -
  18.499 -    src = SDL_RWFromFile(file, "rb");
  18.500 -    if (src == NULL) {
  18.501 -        Mix_SetError("Couldn't open '%s'", file);
  18.502 -        return NULL;
  18.503 -    }
  18.504 -
  18.505 -    /* Use the extension as a first guess on the file type */
  18.506 -    type = MUS_NONE;
  18.507 -    ext = strrchr(file, '.');
  18.508 -    if (ext) {
  18.509 -        ++ext; /* skip the dot in the extension */
  18.510 -        if (SDL_strcasecmp(ext, "WAV") == 0) {
  18.511 -            type = MUS_WAV;
  18.512 -        } else if (SDL_strcasecmp(ext, "MID") == 0 ||
  18.513 -                    SDL_strcasecmp(ext, "MIDI") == 0 ||
  18.514 -                    SDL_strcasecmp(ext, "KAR") == 0) {
  18.515 -            type = MUS_MID;
  18.516 -        } else if (SDL_strcasecmp(ext, "OGG") == 0) {
  18.517 -            type = MUS_OGG;
  18.518 -        } else if (SDL_strcasecmp(ext, "OPUS") == 0) {
  18.519 -            type = MUS_OPUS;
  18.520 -        } else if (SDL_strcasecmp(ext, "FLAC") == 0) {
  18.521 -            type = MUS_FLAC;
  18.522 -        } else  if (SDL_strcasecmp(ext, "MPG") == 0 ||
  18.523 -                     SDL_strcasecmp(ext, "MPEG") == 0 ||
  18.524 -                     SDL_strcasecmp(ext, "MP3") == 0 ||
  18.525 -                     SDL_strcasecmp(ext, "MAD") == 0) {
  18.526 -            type = MUS_MP3;
  18.527 -        } else if (SDL_strcasecmp(ext, "669") == 0 ||
  18.528 -                    SDL_strcasecmp(ext, "AMF") == 0 ||
  18.529 -                    SDL_strcasecmp(ext, "AMS") == 0 ||
  18.530 -                    SDL_strcasecmp(ext, "DBM") == 0 ||
  18.531 -                    SDL_strcasecmp(ext, "DSM") == 0 ||
  18.532 -                    SDL_strcasecmp(ext, "FAR") == 0 ||
  18.533 -                    SDL_strcasecmp(ext, "IT") == 0 ||
  18.534 -                    SDL_strcasecmp(ext, "MED") == 0 ||
  18.535 -                    SDL_strcasecmp(ext, "MDL") == 0 ||
  18.536 -                    SDL_strcasecmp(ext, "MOD") == 0 ||
  18.537 -                    SDL_strcasecmp(ext, "MOL") == 0 ||
  18.538 -                    SDL_strcasecmp(ext, "MTM") == 0 ||
  18.539 -                    SDL_strcasecmp(ext, "NST") == 0 ||
  18.540 -                    SDL_strcasecmp(ext, "OKT") == 0 ||
  18.541 -                    SDL_strcasecmp(ext, "PTM") == 0 ||
  18.542 -                    SDL_strcasecmp(ext, "S3M") == 0 ||
  18.543 -                    SDL_strcasecmp(ext, "STM") == 0 ||
  18.544 -                    SDL_strcasecmp(ext, "ULT") == 0 ||
  18.545 -                    SDL_strcasecmp(ext, "UMX") == 0 ||
  18.546 -                    SDL_strcasecmp(ext, "WOW") == 0 ||
  18.547 -                    SDL_strcasecmp(ext, "XM") == 0) {
  18.548 -            type = MUS_MOD;
  18.549 -        }
  18.550 -    }
  18.551 -    return Mix_LoadMUSType_RW(src, type, SDL_TRUE);
  18.552 -}
  18.553 -
  18.554 -Mix_Music *Mix_LoadMUS_RW(SDL_RWops *src, int freesrc)
  18.555 -{
  18.556 -    return Mix_LoadMUSType_RW(src, MUS_NONE, freesrc);
  18.557 -}
  18.558 -
  18.559 -Mix_Music *Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc)
  18.560 -{
  18.561 -    size_t i;
  18.562 -    void *context;
  18.563 -    Sint64 start;
  18.564 -
  18.565 -    if (!src) {
  18.566 -        Mix_SetError("RWops pointer is NULL");
  18.567 -        return NULL;
  18.568 -    }
  18.569 -    start = SDL_RWtell(src);
  18.570 -
  18.571 -    /* If the caller wants auto-detection, figure out what kind of file
  18.572 -     * this is. */
  18.573 -    if (type == MUS_NONE) {
  18.574 -        if ((type = detect_music_type(src)) == MUS_NONE) {
  18.575 -            /* Don't call Mix_SetError() since detect_music_type() does that. */
  18.576 -            if (freesrc) {
  18.577 -                SDL_RWclose(src);
  18.578 -            }
  18.579 -            return NULL;
  18.580 -        }
  18.581 -    }
  18.582 -
  18.583 -    Mix_ClearError();
  18.584 -
  18.585 -    if (load_music_type(type) && open_music_type(type)) {
  18.586 -        for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) {
  18.587 -            Mix_MusicInterface *interface = s_music_interfaces[i];
  18.588 -            if (!interface->opened || type != interface->type || !interface->CreateFromRW) {
  18.589 -                continue;
  18.590 -            }
  18.591 -
  18.592 -            context = interface->CreateFromRW(src, freesrc);
  18.593 -            if (context) {
  18.594 -                /* Allocate memory for the music structure */
  18.595 -                Mix_Music *music = (Mix_Music *)SDL_calloc(1, sizeof(Mix_Music));
  18.596 -                if (music == NULL) {
  18.597 -                    interface->Delete(context);
  18.598 -                    Mix_SetError("Out of memory");
  18.599 -                    return NULL;
  18.600 -                }
  18.601 -                music->interface = interface;
  18.602 -                music->context = context;
  18.603 -
  18.604 -                if (SDL_GetHintBoolean(SDL_MIXER_HINT_DEBUG_MUSIC_INTERFACES, SDL_FALSE)) {
  18.605 -                    SDL_Log("Loaded music with %s\n", interface->tag);
  18.606 -                }
  18.607 -                return music;
  18.608 -            }
  18.609 -
  18.610 -            /* Reset the stream for the next decoder */
  18.611 -            SDL_RWseek(src, start, RW_SEEK_SET);
  18.612 -        }
  18.613 -    }
  18.614 -
  18.615 -    if (!*Mix_GetError()) {
  18.616 -        Mix_SetError("Unrecognized audio format");
  18.617 -    }
  18.618 -    if (freesrc) {
  18.619 -        SDL_RWclose(src);
  18.620 -    } else {
  18.621 -        SDL_RWseek(src, start, RW_SEEK_SET);
  18.622 -    }
  18.623 -    return NULL;
  18.624 -}
  18.625 -
  18.626 -/* Free a music chunk previously loaded */
  18.627 -void Mix_FreeMusic(Mix_Music *music)
  18.628 -{
  18.629 -    if (music) {
  18.630 -        /* Stop the music if it's currently playing */
  18.631 -        Mix_LockAudio();
  18.632 -        if (music == music_playing) {
  18.633 -            /* Wait for any fade out to finish */
  18.634 -            while (music->fading == MIX_FADING_OUT) {
  18.635 -                Mix_UnlockAudio();
  18.636 -                SDL_Delay(100);
  18.637 -                Mix_LockAudio();
  18.638 -            }
  18.639 -            if (music == music_playing) {
  18.640 -                music_internal_halt();
  18.641 -            }
  18.642 -        }
  18.643 -        Mix_UnlockAudio();
  18.644 -
  18.645 -        music->interface->Delete(music->context);
  18.646 -        SDL_free(music);
  18.647 -    }
  18.648 -}
  18.649 -
  18.650 -/* Find out the music format of a mixer music, or the currently playing
  18.651 -   music, if 'music' is NULL.
  18.652 -*/
  18.653 -Mix_MusicType Mix_GetMusicType(const Mix_Music *music)
  18.654 -{
  18.655 -    Mix_MusicType type = MUS_NONE;
  18.656 -
  18.657 -    if (music) {
  18.658 -        type = music->interface->type;
  18.659 -    } else {
  18.660 -        Mix_LockAudio();
  18.661 -        if (music_playing) {
  18.662 -            type = music_playing->interface->type;
  18.663 -        }
  18.664 -        Mix_UnlockAudio();
  18.665 -    }
  18.666 -    return(type);
  18.667 -}
  18.668 -
  18.669 -/* Play a music chunk.  Returns 0, or -1 if there was an error.
  18.670 - */
  18.671 -static int music_internal_play(Mix_Music *music, int play_count, double position)
  18.672 -{
  18.673 -    int retval = 0;
  18.674 -
  18.675 -#if defined(__MACOSX__) && defined(MID_MUSIC_NATIVE)
  18.676 -    /* This fixes a bug with native MIDI on Mac OS X, where you
  18.677 -       can't really stop and restart MIDI from the audio callback.
  18.678 -    */
  18.679 -    if (music == music_playing && music->api == MIX_MUSIC_NATIVEMIDI) {
  18.680 -        /* Just a seek suffices to restart playing */
  18.681 -        music_internal_position(position);
  18.682 -        return 0;
  18.683 -    }
  18.684 -#endif
  18.685 -
  18.686 -    /* Note the music we're playing */
  18.687 -    if (music_playing) {
  18.688 -        music_internal_halt();
  18.689 -    }
  18.690 -    music_playing = music;
  18.691 -    music_playing->playing = SDL_TRUE;
  18.692 -
  18.693 -    /* Set the initial volume */
  18.694 -    music_internal_initialize_volume();
  18.695 -
  18.696 -    /* Set up for playback */
  18.697 -    retval = music->interface->Play(music->context, play_count);
  18.698 -
  18.699 -    /* Set the playback position, note any errors if an offset is used */
  18.700 -    if (retval == 0) {
  18.701 -        if (position > 0.0) {
  18.702 -            if (music_internal_position(position) < 0) {
  18.703 -                Mix_SetError("Position not implemented for music type");
  18.704 -                retval = -1;
  18.705 -            }
  18.706 -        } else {
  18.707 -            music_internal_position(0.0);
  18.708 -        }
  18.709 -    }
  18.710 -
  18.711 -    /* If the setup failed, we're not playing any music anymore */
  18.712 -    if (retval < 0) {
  18.713 -        music->playing = SDL_FALSE;
  18.714 -        music_playing = NULL;
  18.715 -    }
  18.716 -    return(retval);
  18.717 -}
  18.718 -
  18.719 -int Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position)
  18.720 -{
  18.721 -    int retval;
  18.722 -
  18.723 -    if (ms_per_step == 0) {
  18.724 -        SDL_SetError("Audio device hasn't been opened");
  18.725 -        return(-1);
  18.726 -    }
  18.727 -
  18.728 -    /* Don't play null pointers :-) */
  18.729 -    if (music == NULL) {
  18.730 -        Mix_SetError("music parameter was NULL");
  18.731 -        return(-1);
  18.732 -    }
  18.733 -
  18.734 -    /* Setup the data */
  18.735 -    if (ms) {
  18.736 -        music->fading = MIX_FADING_IN;
  18.737 -    } else {
  18.738 -        music->fading = MIX_NO_FADING;
  18.739 -    }
  18.740 -    music->fade_step = 0;
  18.741 -    music->fade_steps = ms/ms_per_step;
  18.742 -
  18.743 -    /* Play the puppy */
  18.744 -    Mix_LockAudio();
  18.745 -    /* If the current music is fading out, wait for the fade to complete */
  18.746 -    while (music_playing && (music_playing->fading == MIX_FADING_OUT)) {
  18.747 -        Mix_UnlockAudio();
  18.748 -        SDL_Delay(100);
  18.749 -        Mix_LockAudio();
  18.750 -    }
  18.751 -    if (loops == 0) {
  18.752 -        /* Loop is the number of times to play the audio */
  18.753 -        loops = 1;
  18.754 -    }
  18.755 -    retval = music_internal_play(music, loops, position);
  18.756 -    /* Set music as active */
  18.757 -    music_active = (retval == 0);
  18.758 -    Mix_UnlockAudio();
  18.759 -
  18.760 -    return(retval);
  18.761 -}
  18.762 -int Mix_FadeInMusic(Mix_Music *music, int loops, int ms)
  18.763 -{
  18.764 -    return Mix_FadeInMusicPos(music, loops, ms, 0.0);
  18.765 -}
  18.766 -int Mix_PlayMusic(Mix_Music *music, int loops)
  18.767 -{
  18.768 -    return Mix_FadeInMusicPos(music, loops, 0, 0.0);
  18.769 -}
  18.770 -
  18.771 -/* Set the playing music position */
  18.772 -int music_internal_position(double position)
  18.773 -{
  18.774 -    if (music_playing->interface->Seek) {
  18.775 -        return music_playing->interface->Seek(music_playing->context, position);
  18.776 -    }
  18.777 -    return -1;
  18.778 -}
  18.779 -int Mix_SetMusicPosition(double position)
  18.780 -{
  18.781 -    int retval;
  18.782 -
  18.783 -    Mix_LockAudio();
  18.784 -    if (music_playing) {
  18.785 -        retval = music_internal_position(position);
  18.786 -        if (retval < 0) {
  18.787 -            Mix_SetError("Position not implemented for music type");
  18.788 -        }
  18.789 -    } else {
  18.790 -        Mix_SetError("Music isn't playing");
  18.791 -        retval = -1;
  18.792 -    }
  18.793 -    Mix_UnlockAudio();
  18.794 -
  18.795 -    return(retval);
  18.796 -}
  18.797 -
  18.798 -/* Set the music's initial volume */
  18.799 -static void music_internal_initialize_volume(void)
  18.800 -{
  18.801 -    if (music_playing->fading == MIX_FADING_IN) {
  18.802 -        music_internal_volume(0);
  18.803 -    } else {
  18.804 -        music_internal_volume(music_volume);
  18.805 -    }
  18.806 -}
  18.807 -
  18.808 -/* Set the music volume */
  18.809 -static void music_internal_volume(int volume)
  18.810 -{
  18.811 -    if (music_playing->interface->SetVolume) {
  18.812 -        music_playing->interface->SetVolume(music_playing->context, volume);
  18.813 -    }
  18.814 -}
  18.815 -int Mix_VolumeMusic(int volume)
  18.816 -{
  18.817 -    int prev_volume;
  18.818 -
  18.819 -    prev_volume = music_volume;
  18.820 -    if (volume < 0) {
  18.821 -        return prev_volume;
  18.822 -    }
  18.823 -    if (volume > SDL_MIX_MAXVOLUME) {
  18.824 -        volume = SDL_MIX_MAXVOLUME;
  18.825 -    }
  18.826 -    music_volume = volume;
  18.827 -    Mix_LockAudio();
  18.828 -    if (music_playing) {
  18.829 -        music_internal_volume(music_volume);
  18.830 -    }
  18.831 -    Mix_UnlockAudio();
  18.832 -    return(prev_volume);
  18.833 -}
  18.834 -
  18.835 -/* Halt playing of music */
  18.836 -static void music_internal_halt(void)
  18.837 -{
  18.838 -    if (music_playing->interface->Stop) {
  18.839 -        music_playing->interface->Stop(music_playing->context);
  18.840 -    }
  18.841 -
  18.842 -    music_playing->playing = SDL_FALSE;
  18.843 -    music_playing->fading = MIX_NO_FADING;
  18.844 -    music_playing = NULL;
  18.845 -}
  18.846 -int Mix_HaltMusic(void)
  18.847 -{
  18.848 -    Mix_LockAudio();
  18.849 -    if (music_playing) {
  18.850 -        music_internal_halt();
  18.851 -        if (music_finished_hook) {
  18.852 -            music_finished_hook();
  18.853 -        }
  18.854 -    }
  18.855 -    Mix_UnlockAudio();
  18.856 -
  18.857 -    return(0);
  18.858 -}
  18.859 -