diff --git a/Android.mk b/Android.mk index a5b7100..a00d5c6 100644 --- a/Android.mk +++ b/Android.mk @@ -1,131 +1,103 @@ -LOCAL_PATH := $(call my-dir) +# Save the local path +MY_LOCAL_PATH := $(call my-dir) + + +# Enable this if you want to support loading FLAC music with libFLAC +SUPPORT_FLAC ?= true +FLAC_LIBRARY_PATH := external/flac-1.3.2 + +# Enable this if you want to support loading OGG Vorbis music via Tremor +SUPPORT_OGG ?= true +OGG_LIBRARY_PATH := external/libogg-1.3.2 +VORBIS_LIBRARY_PATH := external/libvorbisidec-1.2.1 + +# Enable this if you want to support loading MP3 music via MPG123 +SUPPORT_MP3_MPG123 ?= true +MPG123_LIBRARY_PATH := external/mpg123-1.25.6 + +# Enable this if you want to support loading MOD music via modplug +SUPPORT_MOD_MODPLUG ?= true +MODPLUG_LIBRARY_PATH := external/libmodplug-0.8.9.0 + +# Enable this if you want to support TiMidity +SUPPORT_TIMIDITY ?= true +TIMIDITY_LIBRARY_PATH := timidity + + +# Build the library +ifeq ($(SUPPORT_FLAC),true) + include $(MY_LOCAL_PATH)/$(FLAC_LIBRARY_PATH)/Android.mk +endif + +# Build the library +ifeq ($(SUPPORT_OGG),true) + include $(MY_LOCAL_PATH)/$(OGG_LIBRARY_PATH)/Android.mk + include $(MY_LOCAL_PATH)/$(VORBIS_LIBRARY_PATH)/Android.mk +endif + +# Build the library +ifeq ($(SUPPORT_MP3_MPG123),true) + include $(MY_LOCAL_PATH)/$(MPG123_LIBRARY_PATH)/Android.mk +endif + +# Build the library +ifeq ($(SUPPORT_MOD_MODPLUG),true) + include $(MY_LOCAL_PATH)/$(MODPLUG_LIBRARY_PATH)/Android.mk +endif + +# Build the library +ifeq ($(SUPPORT_TIMIDITY),true) + include $(MY_LOCAL_PATH)/$(TIMIDITY_LIBRARY_PATH)/Android.mk +endif + + +# Restore local path +LOCAL_PATH := $(MY_LOCAL_PATH) include $(CLEAR_VARS) LOCAL_MODULE := SDL2_mixer -# Enable this if you want to support loading MOD music via modplug -# The library path should be a relative path to this directory. -SUPPORT_MOD_MODPLUG ?= true -MODPLUG_LIBRARY_PATH := external/libmodplug-0.8.8.4 - -# Enable this if you want to support loading MOD music via mikmod -# The library path should be a relative path to this directory. -SUPPORT_MOD_MIKMOD ?= true -MIKMOD_LIBRARY_PATH := external/libmikmod-3.1.12 - -# Enable this if you want to support loading MP3 music via SMPEG -# The library path should be a relative path to this directory. -SUPPORT_MP3_SMPEG ?= true -SMPEG_LIBRARY_PATH := external/smpeg2-2.0.0 - -# Enable this if you want to support loading OGG Vorbis music via Tremor -# The library path should be a relative path to this directory. -SUPPORT_OGG ?= true -OGG_LIBRARY_PATH := external/libogg-1.3.1 -VORBIS_LIBRARY_PATH := external/libvorbisidec-1.2.1 - - -# Enable this if you want to support TiMidity -SUPPORT_TIMIDITY ?= true - -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_CFLAGS := -DWAV_MUSIC - LOCAL_SRC_FILES := $(notdir $(filter-out %/playmus.c %/playwave.c, $(wildcard $(LOCAL_PATH)/*.c))) \ - +LOCAL_CFLAGS := LOCAL_LDLIBS := LOCAL_STATIC_LIBRARIES := LOCAL_SHARED_LIBRARIES := SDL2 -ifeq ($(SUPPORT_TIMIDITY),true) - LOCAL_C_INCLUDES += $(LOCAL_PATH)/timidity - LOCAL_CFLAGS += -DMID_MUSIC -DUSE_TIMIDITY_MIDI - LOCAL_SRC_FILES += $(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/timidity/*.c)) +ifeq ($(SUPPORT_FLAC),true) + LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(FLAC_LIBRARY_PATH)/include + LOCAL_CFLAGS += -DMUSIC_FLAC + LOCAL_STATIC_LIBRARIES += libFLAC +endif + +ifeq ($(SUPPORT_OGG),true) + LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(OGG_LIBRARY_PATH)/include + LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(VORBIS_LIBRARY_PATH) + LOCAL_CFLAGS += -DMUSIC_OGG -DOGG_USE_TREMOR -DOGG_HEADER="" + LOCAL_STATIC_LIBRARIES += ogg vorbisidec +endif + +# This needs to be a shared library to comply with the LGPL license +ifeq ($(SUPPORT_MP3_MPG123),true) + LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(MPG123_LIBRARY_PATH) + LOCAL_CFLAGS += -DMUSIC_MP3_MPG123 + LOCAL_SHARED_LIBRARIES += mpg123 endif ifeq ($(SUPPORT_MOD_MODPLUG),true) - LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(MODPLUG_LIBRARY_PATH)/src $(LOCAL_PATH)/$(MODPLUG_LIBRARY_PATH)/src/libmodplug - LOCAL_CFLAGS += -DMODPLUG_MUSIC -DMODPLUG_HEADER="" -DHAVE_SETENV -DHAVE_SINF - LOCAL_SRC_FILES += \ - $(MODPLUG_LIBRARY_PATH)/src/fastmix.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_669.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_abc.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_amf.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_ams.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_dbm.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_dmf.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_dsm.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_far.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_it.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_j2b.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_mdl.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_med.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_mid.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_mod.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_mt2.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_mtm.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_okt.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_pat.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_psm.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_ptm.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_s3m.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_stm.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_ult.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_umx.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_wav.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/load_xm.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/mmcmp.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/modplug.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/snd_dsp.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/snd_flt.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/snd_fx.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/sndfile.cpp \ - $(MODPLUG_LIBRARY_PATH)/src/sndmix.cpp + LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(MODPLUG_LIBRARY_PATH)/src + LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(MODPLUG_LIBRARY_PATH)/src/libmodplug + LOCAL_CFLAGS += -DMUSIC_MOD_MODPLUG -DMODPLUG_HEADER="" + LOCAL_STATIC_LIBRARIES += modplug endif -ifeq ($(SUPPORT_MOD_MIKMOD),true) - LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(MIKMOD_LIBRARY_PATH)/include - LOCAL_CFLAGS += -DMOD_MUSIC - LOCAL_SHARED_LIBRARIES += mikmod +ifeq ($(SUPPORT_TIMIDITY),true) + LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(TIMIDITY_LIBRARY_PATH) + LOCAL_CFLAGS += -DMUSIC_MID_TIMIDITY + LOCAL_STATIC_LIBRARIES += timidity endif -ifeq ($(SUPPORT_MP3_SMPEG),true) - LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(SMPEG_LIBRARY_PATH) - LOCAL_CFLAGS += -DMP3_MUSIC - LOCAL_SHARED_LIBRARIES += smpeg2 -endif - -ifeq ($(SUPPORT_OGG),true) - LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(OGG_LIBRARY_PATH)/include $(LOCAL_PATH)/$(VORBIS_LIBRARY_PATH) - LOCAL_CFLAGS += -DOGG_MUSIC -DOGG_USE_TREMOR -DOGG_HEADER="" - ifeq ($(TARGET_ARCH_ABI),armeabi) - LOCAL_CFLAGS += -D_ARM_ASSEM_ - endif - ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) - LOCAL_CFLAGS += -D_ARM_ASSEM_ - endif - LOCAL_SRC_FILES += \ - $(VORBIS_LIBRARY_PATH)/mdct.c \ - $(VORBIS_LIBRARY_PATH)/block.c \ - $(VORBIS_LIBRARY_PATH)/window.c \ - $(VORBIS_LIBRARY_PATH)/synthesis.c \ - $(VORBIS_LIBRARY_PATH)/info.c \ - $(VORBIS_LIBRARY_PATH)/floor1.c \ - $(VORBIS_LIBRARY_PATH)/floor0.c \ - $(VORBIS_LIBRARY_PATH)/vorbisfile.c \ - $(VORBIS_LIBRARY_PATH)/res012.c \ - $(VORBIS_LIBRARY_PATH)/mapping0.c \ - $(VORBIS_LIBRARY_PATH)/registry.c \ - $(VORBIS_LIBRARY_PATH)/codebook.c \ - $(VORBIS_LIBRARY_PATH)/sharedbook.c \ - $(OGG_LIBRARY_PATH)/src/framing.c \ - $(OGG_LIBRARY_PATH)/src/bitwise.c -endif - -LOCAL_EXPORT_C_INCLUDES += $(LOCAL_C_INCLUDES) - -LOCAL_ARM_MODE := arm +LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH) include $(BUILD_SHARED_LIBRARY) diff --git a/CHANGES.txt b/CHANGES.txt index 1eb0834..bdd4a88 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,17 @@ +2.0.2: +Sam Lantinga - Fri Oct 20 22:04:50 PDT 2017 + * Implemented 24-bit and surround sound support for FLAC audio files +Sam Lantinga - Thu Oct 12 21:32:44 PDT 2017 + * Updated external libraries flac-1.3.2, libmodplug-0.8.9.0, libogg-1.3.2 and libvorbis-1.3.5 +Ryan Gordon - Thu Oct 12 21:29:59 PDT 2017 + * Updated for SDL 2.0.6 and newer +Franc[e]sco - Thu Jul 20 22:03:19 2017 +0200 + * Added support for MP3 playback using mpg123 +David Ludwig - Sun Apr 10 22:35:38 2016 + * Added support for UWP / Windows 10 apps +Juha Kuikka - Fri Jan 29 12:44:01 PST 2016 + * Added Mix_OpenAudioDevice() so you can specify the audio device to open + 2.0.1: Sam Lantinga - Tue Jul 7 11:40:33 PDT 2015 * Added support for 'smpl' format loop points in music WAV files diff --git a/COPYING.txt b/COPYING.txt index b7bd3d9..79c8276 100644 --- a/COPYING.txt +++ b/COPYING.txt @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/Makefile.in b/Makefile.in index d5e76a2..fe85165 100644 --- a/Makefile.in +++ b/Makefile.in @@ -20,7 +20,6 @@ EXE = @EXE@ SHELL = @SHELL@ CC = @CC@ -CXX = g++ CFLAGS = @BUILD_CFLAGS@ EXTRA_CFLAGS = @EXTRA_CFLAGS@ LDFLAGS = @BUILD_LDFLAGS@ @@ -39,7 +38,7 @@ PLAYWAVE_OBJECTS = @PLAYWAVE_OBJECTS@ PLAYMUS_OBJECTS = @PLAYMUS_OBJECTS@ -DIST = *.txt Android.mk Makefile.in SDL2_mixer.pc.in SDL_mixer.h SDL2_mixer.spec SDL2_mixer.spec.in debian VisualC Xcode Xcode-iOS acinclude autogen.sh build-scripts configure configure.in dynamic_flac.c dynamic_flac.h dynamic_fluidsynth.c dynamic_fluidsynth.h dynamic_modplug.c dynamic_modplug.h dynamic_mod.c dynamic_mod.h dynamic_mp3.c dynamic_mp3.h dynamic_ogg.c dynamic_ogg.h effect_position.c effect_stereoreverse.c effects_internal.c effects_internal.h fluidsynth.c fluidsynth.h external gcc-fat.sh libmikmod-3.1.12.zip load_aiff.c load_aiff.h load_flac.c load_flac.h load_mp3.c load_mp3.h load_ogg.c load_ogg.h load_voc.c load_voc.h mixer.c music.c music_cmd.c music_cmd.h music_flac.c music_flac.h music_mad.c music_mad.h music_mod.c music_mod.h music_modplug.c music_modplug.h music_ogg.c music_ogg.h native_midi playmus.c playwave.c timidity wavestream.c wavestream.h version.rc +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_smpeg.c music_smpeg.h music_timidity.c music_timidity.h music_wav.c music_wav.h native_midi playmus.c playwave.c timidity version.rc LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ @@ -66,10 +65,10 @@ $(LIBTOOL) --mode=link $(CC) -o $@ $(OBJECTS) $(VERSION_OBJECTS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LT_LDFLAGS) $(objects)/playwave$(EXE): $(objects)/playwave.lo $(objects)/$(TARGET) - $(LIBTOOL) --mode=link $(CC) -o $@ $(objects)/playwave.lo $(SDL_CFLAGS) $(SDL_LIBS) $(LDFLAGS) $(objects)/$(TARGET) + $(LIBTOOL) --mode=link $(CC) -o $@ $(objects)/playwave.lo $(SDL_CFLAGS) $(objects)/$(TARGET) $(SDL_LIBS) $(LDFLAGS) $(objects)/playmus$(EXE): $(objects)/playmus.lo $(objects)/$(TARGET) - $(LIBTOOL) --mode=link $(CC) -o $@ $(objects)/playmus.lo $(SDL_CFLAGS) $(SDL_LIBS) $(LDFLAGS) $(objects)/$(TARGET) + $(LIBTOOL) --mode=link $(CC) -o $@ $(objects)/playmus.lo $(SDL_CFLAGS) $(objects)/$(TARGET) $(SDL_LIBS) $(LDFLAGS) install: all install-hdrs install-lib #install-bin install-hdrs: diff --git a/README.txt b/README.txt index 9f2f306..523fcf1 100644 --- a/README.txt +++ b/README.txt @@ -6,25 +6,25 @@ Due to popular demand, here is a simple multi-channel audio mixer. It supports 8 channels of 16 bit stereo audio, plus a single channel -of music, mixed by the popular MikMod MOD, Timidity MIDI and SMPEG MP3 -libraries. +of music. See the header file SDL_mixer.h and the examples playwave.c and playmus.c for documentation on this mixer library. The mixer can currently load Microsoft WAVE files and Creative Labs VOC -files as audio samples, and can load MIDI files via Timidity and the -following music formats via MikMod: .MOD .S3M .IT .XM. It can load -Ogg Vorbis streams as music if built with Ogg Vorbis or Tremor libraries, -and finally it can load MP3 music using the SMPEG or libmad libraries. +files as audio samples, it can load FLAC files with libFLAC, it can load +Ogg Vorbis files with Ogg Vorbis or Tremor libraries, it can load MP3 files +using mpg123, SMPEG or libmad, and it can load MIDI files with Timidity, +FluidSynth, and natively on Windows, Mac OSX, and Linux, and finally it can +load the following file formats via ModPlug or MikMod: .MOD .S3M .IT .XM. Tremor decoding is disabled by default; you can enable it by passing --enable-music-ogg-tremor -to configure, or by defining OGG_MUSIC and OGG_USE_TREMOR. +to configure, or by defining MUSIC_OGG and OGG_USE_TREMOR. libmad decoding is disabled by default; you can enable it by passing --enable-music-mp3-mad -to configure, or by defining MP3_MAD_MUSIC +to configure, or by defining MUSIC_MP3_MAD vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv WARNING: The license for libmad is GPL, which means that in order to use it your application must also be GPL! @@ -34,10 +34,21 @@ so if playing regular WAVE files sound great, but playing MIDI files sound choppy, try using 8-bit audio, mono audio, or lower frequencies. -To play MIDI files, you'll need to get a complete set of GUS patches -from: +To play MIDI files using FluidSynth, you'll need to set the SDL_SOUNDFONTS +environment variable to a Sound Font 2 (.sf2) file containing the musical +instruments you want to use for MIDI playback. +(On some Linux distributions you can install the fluid-soundfont-gm package) + +To play MIDI files using Timidity, you'll need to get a complete set of +GUS patches from: http://www.libsdl.org/projects/mixer/timidity/timidity.tar.gz and unpack them in /usr/local/lib under UNIX, and C:\ under Win32. +iOS: +In order to use this library on iOS, you should include the SDL.xcodeproj +and Xcode-iOS/SDL_mixer.xcodeproj in your application, add the SDL/include +and SDL_mixer directories to your "Header Search Paths" setting, then add the +libSDL2.a and libSDL2_mixer.a to your "Link Binary with Libraries" setting. + This library is under the zlib license, see the file "COPYING.txt" for details. diff --git a/SDL2_mixer.spec b/SDL2_mixer.spec deleted file mode 100644 index dfa45e7..0000000 --- a/SDL2_mixer.spec +++ /dev/null @@ -1,64 +0,0 @@ -%define name SDL2_mixer -%define version 2.0.1 -%define release 1 - -Summary: Simple DirectMedia Layer - Sample Mixer Library -Name: %{name} -Version: %{version} -Release: %{release} -Source0: %{name}-%{version}.tar.gz -License: LGPL -Group: System Environment/Libraries -BuildRoot: /var/tmp/%{name}-buildroot -Prefix: %{_prefix} - -%description -Due to popular demand, here is a simple multi-channel audio mixer. -It supports 4 channels of 16 bit stereo audio, plus a single channel -of music, mixed by the popular MikMod MOD, Timidity MIDI, Ogg Vorbis, -Tremor, SMPEG MP3, and libmad MP3 libraries. - -%package devel -Summary: Libraries, includes and more to develop SDL applications. -Group: Development/Libraries -Requires: %{name} - -%description devel -Due to popular demand, here is a simple multi-channel audio mixer. -It supports 4 channels of 16 bit stereo audio, plus a single channel -of music, mixed by the popular MikMod MOD, Timidity MIDI, Ogg Vorbis, -Tremor, SMPEG MP3, and libmad MP3 libraries. - -%prep -%setup - -%build -CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{prefix} -make - -%install -rm -rf $RPM_BUILD_ROOT -make install prefix=$RPM_BUILD_ROOT/%{prefix} - -%clean -rm -rf $RPM_BUILD_ROOT - -%files -%defattr(-,root,root) -%doc README.txt CHANGES.txt COPYING.txt -%{prefix}/lib/lib*.so.* - -%files devel -%defattr(-,root,root) -%{prefix}/lib/lib*.a -%{prefix}/lib/lib*.la -%{prefix}/lib/lib*.so -%{prefix}/include/*/ -%{prefix}/lib/pkgconfig/*.pc - -%changelog -* Wed Jan 19 2000 Sam Lantinga -- converted to get package information from configure -* Sun Jan 16 2000 Hakan Tandogan -- initial spec file - diff --git a/SDL_mixer.h b/SDL_mixer.h index 71c1f5c..cbb8ae6 100644 --- a/SDL_mixer.h +++ b/SDL_mixer.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -19,10 +19,8 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* $Id$ */ - -#ifndef _SDL_MIXER_H -#define _SDL_MIXER_H +#ifndef SDL_MIXER_H_ +#define SDL_MIXER_H_ #include "SDL_stdinc.h" #include "SDL_rwops.h" @@ -40,7 +38,7 @@ */ #define SDL_MIXER_MAJOR_VERSION 2 #define SDL_MIXER_MINOR_VERSION 0 -#define SDL_MIXER_PATCHLEVEL 1 +#define SDL_MIXER_PATCHLEVEL 2 /* This macro can be used to fill a version structure with the compile-time * version of the SDL_mixer library. @@ -58,6 +56,18 @@ #define MIX_PATCHLEVEL SDL_MIXER_PATCHLEVEL #define MIX_VERSION(X) SDL_MIXER_VERSION(X) +/** + * This is the version number macro for the current SDL_mixer version. + */ +#define SDL_MIXER_COMPILEDVERSION \ + SDL_VERSIONNUM(SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL) + +/** + * This macro will evaluate to true if compiled with SDL_mixer at least X.Y.Z. + */ +#define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \ + (SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) + /* This function gets the version of the dynamically linked SDL_mixer library. it should NOT be used to fill a version structure, instead you should use the SDL_MIXER_VERSION() macro. @@ -66,12 +76,11 @@ typedef enum { - MIX_INIT_FLAC = 0x00000001, - MIX_INIT_MOD = 0x00000002, - MIX_INIT_MODPLUG = 0x00000004, - MIX_INIT_MP3 = 0x00000008, - MIX_INIT_OGG = 0x00000010, - MIX_INIT_FLUIDSYNTH = 0x00000020 + MIX_INIT_FLAC = 0x00000001, + MIX_INIT_MOD = 0x00000002, + MIX_INIT_MP3 = 0x00000008, + MIX_INIT_OGG = 0x00000010, + MIX_INIT_MID = 0x00000020 } MIX_InitFlags; /* Loads dynamic libraries and prepares them for use. Flags should be @@ -97,7 +106,7 @@ #define MIX_DEFAULT_FORMAT AUDIO_S16MSB #endif #define MIX_DEFAULT_CHANNELS 2 -#define MIX_MAX_VOLUME 128 /* Volume of a chunk */ +#define MIX_MAX_VOLUME SDL_MIX_MAXVOLUME /* Volume of a chunk */ /* The internal format for an audio chunk */ typedef struct Mix_Chunk { @@ -114,6 +123,7 @@ MIX_FADING_IN } Mix_Fading; +/* These are types of music files (not libraries used to load them) */ typedef enum { MUS_NONE, MUS_CMD, @@ -122,9 +132,9 @@ MUS_MID, MUS_OGG, MUS_MP3, - MUS_MP3_MAD, + MUS_MP3_MAD_UNUSED, MUS_FLAC, - MUS_MODPLUG + MUS_MODPLUG_UNUSED } Mix_MusicType; /* The internal format for a music chunk interpreted via mikmod */ @@ -132,6 +142,9 @@ /* Open the mixer with a certain audio format */ extern DECLSPEC int SDLCALL Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize); + +/* Open the mixer with specific device and certain audio format */ +extern DECLSPEC int SDLCALL Mix_OpenAudioDevice(int frequency, Uint16 format, int channels, int chunksize, const char* device, int allowed_changes); /* Dynamically change the number of channels managed by the mixer. If decreasing the number of channels, the upper channels are @@ -188,8 +201,10 @@ */ extern DECLSPEC int SDLCALL Mix_GetNumChunkDecoders(void); extern DECLSPEC const char * SDLCALL Mix_GetChunkDecoder(int index); +extern DECLSPEC SDL_bool SDLCALL Mix_HasChunkDecoder(const char *name); extern DECLSPEC int SDLCALL Mix_GetNumMusicDecoders(void); extern DECLSPEC const char * SDLCALL Mix_GetMusicDecoder(int index); +extern DECLSPEC SDL_bool SDLCALL Mix_HasMusicDecoder(const char *name); /* Find out the music format of a mixer music, or the currently playing music, if 'music' is NULL. @@ -200,17 +215,17 @@ This can be used to provide real-time visual display of the audio stream or add a custom mixer filter for the stream data. */ -extern DECLSPEC void SDLCALL Mix_SetPostMix(void (*mix_func)(void *udata, Uint8 *stream, int len), void *arg); +extern DECLSPEC void SDLCALL Mix_SetPostMix(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg); /* Add your own music player or additional mixer function. If 'mix_func' is NULL, the default music player is re-enabled. */ -extern DECLSPEC void SDLCALL Mix_HookMusic(void (*mix_func)(void *udata, Uint8 *stream, int len), void *arg); +extern DECLSPEC void SDLCALL Mix_HookMusic(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg); /* Add your own callback for when the music has finished playing or when it is * stopped from a call to Mix_HaltMusic. */ -extern DECLSPEC void SDLCALL Mix_HookMusicFinished(void (*music_finished)(void)); +extern DECLSPEC void SDLCALL Mix_HookMusicFinished(void (SDLCALL *music_finished)(void)); /* Get a pointer to the user data for the current music hook */ extern DECLSPEC void * SDLCALL Mix_GetMusicHookData(void); @@ -223,7 +238,7 @@ * inside the audio callback, or SDL_mixer will explicitly lock the audio * before calling your callback. */ -extern DECLSPEC void SDLCALL Mix_ChannelFinished(void (*channel_finished)(int channel)); +extern DECLSPEC void SDLCALL Mix_ChannelFinished(void (SDLCALL *channel_finished)(int channel)); /* Special Effects API by ryan c. gordon. (icculus@icculus.org) */ @@ -247,7 +262,7 @@ * * DO NOT EVER call SDL_LockAudio() from your callback function! */ -typedef void (*Mix_EffectFunc_t)(int chan, void *stream, int len, void *udata); +typedef void (SDLCALL *Mix_EffectFunc_t)(int chan, void *stream, int len, void *udata); /* * This is a callback that signifies that a channel has finished all its @@ -258,7 +273,7 @@ * * DO NOT EVER call SDL_LockAudio() from your callback function! */ -typedef void (*Mix_EffectDone_t)(int chan, void *udata); +typedef void (SDLCALL *Mix_EffectDone_t)(int chan, void *udata); /* Register a special effect function. At mixing time, the channel data is @@ -587,8 +602,8 @@ /* Set the current position in the music stream. This returns 0 if successful, or -1 if it failed or isn't implemented. This function is only implemented for MOD music formats (set pattern - order number) and for OGG, FLAC, MP3_MAD, and MODPLUG music (set - position in seconds), at the moment. + order number) and for OGG, FLAC, MP3_MAD, MP3_MPG and MODPLUG music + (set position in seconds), at the moment. */ extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position); @@ -608,7 +623,7 @@ /* Set/Get/Iterate SoundFonts paths to use by supported MIDI backends */ extern DECLSPEC int SDLCALL Mix_SetSoundFonts(const char *paths); extern DECLSPEC const char* SDLCALL Mix_GetSoundFonts(void); -extern DECLSPEC int SDLCALL Mix_EachSoundFont(int (*function)(const char*, void*), void *data); +extern DECLSPEC int SDLCALL Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data); /* Get the Mix_Chunk currently associated with a mixer channel Returns NULL if it's an invalid channel, or there's no chunk associated. @@ -621,6 +636,7 @@ /* We'll use SDL for reporting errors */ #define Mix_SetError SDL_SetError #define Mix_GetError SDL_GetError +#define Mix_ClearError SDL_ClearError /* Ends C function definitions when using C++ */ #ifdef __cplusplus @@ -628,4 +644,6 @@ #endif #include "close_code.h" -#endif /* _SDL_MIXER_H */ +#endif /* SDL_MIXER_H_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/VisualC-WinRT/UWP_VS2015/SDL_mixer-UWP.sln b/VisualC-WinRT/UWP_VS2015/SDL_mixer-UWP.sln new file mode 100644 index 0000000..a469b26 --- /dev/null +++ b/VisualC-WinRT/UWP_VS2015/SDL_mixer-UWP.sln @@ -0,0 +1,76 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2_mixer-UWP", "SDL_mixer-UWP.vcxproj", "{18665277-E558-4484-93F4-E4DC7BB614CB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libogg_dynamic-UWP", "libogg_dynamic-UWP.vcxproj", "{B14F8B7F-C9FF-4FD3-B328-7C68AB801E85}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libvorbis_dynamic-UWP", "libvorbis_dynamic-UWP.vcxproj", "{6B6C1F59-6A82-4097-8907-04DF5C95D014}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libvorbisfile_dynamic-UWP", "libvorbisfile_dynamic-UWP.vcxproj", "{70EF3B8F-6AAF-401B-9818-3371E950E73C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {18665277-E558-4484-93F4-E4DC7BB614CB}.Debug|ARM.ActiveCfg = Debug|ARM + {18665277-E558-4484-93F4-E4DC7BB614CB}.Debug|ARM.Build.0 = Debug|ARM + {18665277-E558-4484-93F4-E4DC7BB614CB}.Debug|x64.ActiveCfg = Debug|x64 + {18665277-E558-4484-93F4-E4DC7BB614CB}.Debug|x64.Build.0 = Debug|x64 + {18665277-E558-4484-93F4-E4DC7BB614CB}.Debug|x86.ActiveCfg = Debug|Win32 + {18665277-E558-4484-93F4-E4DC7BB614CB}.Debug|x86.Build.0 = Debug|Win32 + {18665277-E558-4484-93F4-E4DC7BB614CB}.Release|ARM.ActiveCfg = Release|ARM + {18665277-E558-4484-93F4-E4DC7BB614CB}.Release|ARM.Build.0 = Release|ARM + {18665277-E558-4484-93F4-E4DC7BB614CB}.Release|x64.ActiveCfg = Release|x64 + {18665277-E558-4484-93F4-E4DC7BB614CB}.Release|x64.Build.0 = Release|x64 + {18665277-E558-4484-93F4-E4DC7BB614CB}.Release|x86.ActiveCfg = Release|Win32 + {18665277-E558-4484-93F4-E4DC7BB614CB}.Release|x86.Build.0 = Release|Win32 + {B14F8B7F-C9FF-4FD3-B328-7C68AB801E85}.Debug|ARM.ActiveCfg = Debug|ARM + {B14F8B7F-C9FF-4FD3-B328-7C68AB801E85}.Debug|ARM.Build.0 = Debug|ARM + {B14F8B7F-C9FF-4FD3-B328-7C68AB801E85}.Debug|x64.ActiveCfg = Debug|x64 + {B14F8B7F-C9FF-4FD3-B328-7C68AB801E85}.Debug|x64.Build.0 = Debug|x64 + {B14F8B7F-C9FF-4FD3-B328-7C68AB801E85}.Debug|x86.ActiveCfg = Debug|Win32 + {B14F8B7F-C9FF-4FD3-B328-7C68AB801E85}.Debug|x86.Build.0 = Debug|Win32 + {B14F8B7F-C9FF-4FD3-B328-7C68AB801E85}.Release|ARM.ActiveCfg = Release|ARM + {B14F8B7F-C9FF-4FD3-B328-7C68AB801E85}.Release|ARM.Build.0 = Release|ARM + {B14F8B7F-C9FF-4FD3-B328-7C68AB801E85}.Release|x64.ActiveCfg = Release|x64 + {B14F8B7F-C9FF-4FD3-B328-7C68AB801E85}.Release|x64.Build.0 = Release|x64 + {B14F8B7F-C9FF-4FD3-B328-7C68AB801E85}.Release|x86.ActiveCfg = Release|Win32 + {B14F8B7F-C9FF-4FD3-B328-7C68AB801E85}.Release|x86.Build.0 = Release|Win32 + {6B6C1F59-6A82-4097-8907-04DF5C95D014}.Debug|ARM.ActiveCfg = Debug|ARM + {6B6C1F59-6A82-4097-8907-04DF5C95D014}.Debug|ARM.Build.0 = Debug|ARM + {6B6C1F59-6A82-4097-8907-04DF5C95D014}.Debug|x64.ActiveCfg = Debug|x64 + {6B6C1F59-6A82-4097-8907-04DF5C95D014}.Debug|x64.Build.0 = Debug|x64 + {6B6C1F59-6A82-4097-8907-04DF5C95D014}.Debug|x86.ActiveCfg = Debug|Win32 + {6B6C1F59-6A82-4097-8907-04DF5C95D014}.Debug|x86.Build.0 = Debug|Win32 + {6B6C1F59-6A82-4097-8907-04DF5C95D014}.Release|ARM.ActiveCfg = Release|ARM + {6B6C1F59-6A82-4097-8907-04DF5C95D014}.Release|ARM.Build.0 = Release|ARM + {6B6C1F59-6A82-4097-8907-04DF5C95D014}.Release|x64.ActiveCfg = Release|x64 + {6B6C1F59-6A82-4097-8907-04DF5C95D014}.Release|x64.Build.0 = Release|x64 + {6B6C1F59-6A82-4097-8907-04DF5C95D014}.Release|x86.ActiveCfg = Release|Win32 + {6B6C1F59-6A82-4097-8907-04DF5C95D014}.Release|x86.Build.0 = Release|Win32 + {70EF3B8F-6AAF-401B-9818-3371E950E73C}.Debug|ARM.ActiveCfg = Debug|ARM + {70EF3B8F-6AAF-401B-9818-3371E950E73C}.Debug|ARM.Build.0 = Debug|ARM + {70EF3B8F-6AAF-401B-9818-3371E950E73C}.Debug|x64.ActiveCfg = Debug|x64 + {70EF3B8F-6AAF-401B-9818-3371E950E73C}.Debug|x64.Build.0 = Debug|x64 + {70EF3B8F-6AAF-401B-9818-3371E950E73C}.Debug|x86.ActiveCfg = Debug|Win32 + {70EF3B8F-6AAF-401B-9818-3371E950E73C}.Debug|x86.Build.0 = Debug|Win32 + {70EF3B8F-6AAF-401B-9818-3371E950E73C}.Release|ARM.ActiveCfg = Release|ARM + {70EF3B8F-6AAF-401B-9818-3371E950E73C}.Release|ARM.Build.0 = Release|ARM + {70EF3B8F-6AAF-401B-9818-3371E950E73C}.Release|x64.ActiveCfg = Release|x64 + {70EF3B8F-6AAF-401B-9818-3371E950E73C}.Release|x64.Build.0 = Release|x64 + {70EF3B8F-6AAF-401B-9818-3371E950E73C}.Release|x86.ActiveCfg = Release|Win32 + {70EF3B8F-6AAF-401B-9818-3371E950E73C}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/VisualC-WinRT/UWP_VS2015/SDL_mixer-UWP.vcxproj b/VisualC-WinRT/UWP_VS2015/SDL_mixer-UWP.vcxproj new file mode 100644 index 0000000..a2384d1 --- /dev/null +++ b/VisualC-WinRT/UWP_VS2015/SDL_mixer-UWP.vcxproj @@ -0,0 +1,273 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {89e9b32e-a86a-47c3-a948-d2b1622925ce} + + + {b14f8b7f-c9ff-4fd3-b328-7c68ab801e85} + + + {70ef3b8f-6aaf-401b-9818-3371e950e73c} + + + {6b6c1f59-6a82-4097-8907-04df5c95d014} + + + + {18665277-e558-4484-93f4-e4dc7bb614cb} + DynamicLibrary + SDL2_mixer-UWP + SDL2_mixer_UWP + en-US + 14.0 + true + Windows Store + 8.2 + 10.0.10240.0 + 10.0.10240.0 + 10.0.10240.0 + 10.0.10240.0 + + + + DynamicLibrary + true + v140 + + + DynamicLibrary + true + v140 + + + DynamicLibrary + true + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + true + v140 + + + + + + + + + + + + + + + + + + + + + + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + + NotUsing + false + ..\..\timidity;..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + ..\..\timidity;..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;NDEBUG;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + ..\..\timidity;..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + ..\..\timidity;..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;NDEBUG;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + ..\..\timidity;..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + ..\..\timidity;..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;NDEBUG;%(PreprocessorDefinitions) + + + Console + false + false + + + + + + \ No newline at end of file diff --git a/VisualC-WinRT/UWP_VS2015/SDL_mixer-UWP.vcxproj.filters b/VisualC-WinRT/UWP_VS2015/SDL_mixer-UWP.vcxproj.filters new file mode 100644 index 0000000..344db2d --- /dev/null +++ b/VisualC-WinRT/UWP_VS2015/SDL_mixer-UWP.vcxproj.filters @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + + + {660dbe57-4c07-417e-9609-12b312726942} + + + \ No newline at end of file diff --git a/VisualC-WinRT/UWP_VS2015/libogg_dynamic-UWP.vcxproj b/VisualC-WinRT/UWP_VS2015/libogg_dynamic-UWP.vcxproj new file mode 100644 index 0000000..5677b18 --- /dev/null +++ b/VisualC-WinRT/UWP_VS2015/libogg_dynamic-UWP.vcxproj @@ -0,0 +1,239 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + {b14f8b7f-c9ff-4fd3-b328-7c68ab801e85} + DynamicLibrary + libogg_dynamic-UWP + libogg_dynamic_UWP + en-US + 14.0 + true + Windows Store + 8.2 + 10.0.10240.0 + 10.0.10240.0 + 10.0.10240.0 + 10.0.10240.0 + + + + DynamicLibrary + true + v140 + + + DynamicLibrary + true + v140 + + + DynamicLibrary + true + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + true + v140 + + + + + + + + + + + + + + + + + + + + + + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libogg + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libogg + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libogg + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libogg + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libogg + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libogg + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + 4244 + + + Console + false + false + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + 4244 + + + Console + false + false + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + 4244 + + + Console + false + false + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + 4244 + + + Console + false + false + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + 4244 + + + Console + false + false + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + 4244 + + + Console + false + false + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + + diff --git a/VisualC-WinRT/UWP_VS2015/libogg_dynamic-UWP.vcxproj.filters b/VisualC-WinRT/UWP_VS2015/libogg_dynamic-UWP.vcxproj.filters new file mode 100644 index 0000000..edaf205 --- /dev/null +++ b/VisualC-WinRT/UWP_VS2015/libogg_dynamic-UWP.vcxproj.filters @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisualC-WinRT/UWP_VS2015/libvorbis_dynamic-UWP.vcxproj b/VisualC-WinRT/UWP_VS2015/libvorbis_dynamic-UWP.vcxproj new file mode 100644 index 0000000..6ae3555 --- /dev/null +++ b/VisualC-WinRT/UWP_VS2015/libvorbis_dynamic-UWP.vcxproj @@ -0,0 +1,303 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {b14f8b7f-c9ff-4fd3-b328-7c68ab801e85} + + + + {6b6c1f59-6a82-4097-8907-04df5c95d014} + Win32Proj + libvorbis_dynamic-UWP + libvorbis_dynamic_UWP + en-US + 12.0 + true + Windows Store + 8.1 + 10.0.10240.0 + 10.0.10240.0 + 10.0.10240.0 + 10.0.10240.0 + + + + DynamicLibrary + true + v140 + + + DynamicLibrary + true + v140 + + + DynamicLibrary + true + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + true + v140 + + + + + + + + + + + + + + + + + + + + + + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbis + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbis + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbis + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbis + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbis + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbis + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + 4244;4100;4267;4189;4305;4127;4706 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + 4244;4100;4267;4189;4305;4127;4706 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;_WIN32_WCE;%(PreprocessorDefinitions) + 4244;4100;4267;4189;4305;4127;4706 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;_WIN32_WCE;%(PreprocessorDefinitions) + 4244;4100;4267;4189;4305;4127;4706 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + 4244;4100;4267;4189;4305;4127;4706 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + 4244;4100;4267;4189;4305;4127;4706 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + + diff --git a/VisualC-WinRT/UWP_VS2015/libvorbis_dynamic-UWP.vcxproj.filters b/VisualC-WinRT/UWP_VS2015/libvorbis_dynamic-UWP.vcxproj.filters new file mode 100644 index 0000000..2101a47 --- /dev/null +++ b/VisualC-WinRT/UWP_VS2015/libvorbis_dynamic-UWP.vcxproj.filters @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisualC-WinRT/UWP_VS2015/libvorbisfile_dynamic-UWP.vcxproj b/VisualC-WinRT/UWP_VS2015/libvorbisfile_dynamic-UWP.vcxproj new file mode 100644 index 0000000..8b4ef73 --- /dev/null +++ b/VisualC-WinRT/UWP_VS2015/libvorbisfile_dynamic-UWP.vcxproj @@ -0,0 +1,242 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + {b14f8b7f-c9ff-4fd3-b328-7c68ab801e85} + + + {6b6c1f59-6a82-4097-8907-04df5c95d014} + + + + {70ef3b8f-6aaf-401b-9818-3371e950e73c} + DynamicLibrary + libvorbisfile_dynamic-UWP + libvorbisfile_dynamic_UWP + en-US + 14.0 + true + Windows Store + 8.2 + 10.0.10240.0 + 10.0.10240.0 + 10.0.10240.0 + 10.0.10240.0 + + + + DynamicLibrary + true + v140 + + + DynamicLibrary + true + v140 + + + DynamicLibrary + true + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + true + v140 + + + DynamicLibrary + false + true + v140 + + + + + + + + + + + + + + + + + + + + + + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbisfile + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbisfile + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbisfile + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbisfile + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbisfile + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbisfile + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;_WINDLL;%(PreprocessorDefinitions) + 4244;4101 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions) + 4244;4101 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;_WIN32_WCE;_WINDLL;%(PreprocessorDefinitions) + 4244;4101 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;_WIN32_WCE;NDEBUG;%(PreprocessorDefinitions) + 4244;4101 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;_WINDLL;%(PreprocessorDefinitions) + 4244;4101 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions) + 4244;4101 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + + diff --git a/VisualC-WinRT/UWP_VS2015/libvorbisfile_dynamic-UWP.vcxproj.filters b/VisualC-WinRT/UWP_VS2015/libvorbisfile_dynamic-UWP.vcxproj.filters new file mode 100644 index 0000000..74d0fac --- /dev/null +++ b/VisualC-WinRT/UWP_VS2015/libvorbisfile_dynamic-UWP.vcxproj.filters @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/VisualC-WinRT/WinPhone80_VS2012/SDL_mixer-WinPhone80.sln b/VisualC-WinRT/WinPhone80_VS2012/SDL_mixer-WinPhone80.sln new file mode 100644 index 0000000..2cfb685 --- /dev/null +++ b/VisualC-WinRT/WinPhone80_VS2012/SDL_mixer-WinPhone80.sln @@ -0,0 +1,56 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2_mixer-WinPhone80", "SDL_mixer-WinPhone80.vcxproj", "{1F710837-D5C0-4E7F-ABEA-FBFF64722E7E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libogg_dynamic-WinPhone80", "libogg_dynamic-WinPhone80.vcxproj", "{DDB6F9C3-25D1-43C1-B439-20F2016D2F2E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libvorbis_dynamic-WinPhone80", "libvorbis_dynamic-WinPhone80.vcxproj", "{8859E555-5684-436D-AD14-4E8CEB11EAD1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libvorbisfile_dynamic-WinPhone80", "libvorbisfile_dynamic-WinPhone80.vcxproj", "{E1553EFC-2C62-41AE-ABA3-D933D66D435D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|Win32 = Debug|Win32 + Release|ARM = Release|ARM + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1F710837-D5C0-4E7F-ABEA-FBFF64722E7E}.Debug|ARM.ActiveCfg = Debug|ARM + {1F710837-D5C0-4E7F-ABEA-FBFF64722E7E}.Debug|ARM.Build.0 = Debug|ARM + {1F710837-D5C0-4E7F-ABEA-FBFF64722E7E}.Debug|Win32.ActiveCfg = Debug|Win32 + {1F710837-D5C0-4E7F-ABEA-FBFF64722E7E}.Debug|Win32.Build.0 = Debug|Win32 + {1F710837-D5C0-4E7F-ABEA-FBFF64722E7E}.Release|ARM.ActiveCfg = Release|ARM + {1F710837-D5C0-4E7F-ABEA-FBFF64722E7E}.Release|ARM.Build.0 = Release|ARM + {1F710837-D5C0-4E7F-ABEA-FBFF64722E7E}.Release|Win32.ActiveCfg = Release|Win32 + {1F710837-D5C0-4E7F-ABEA-FBFF64722E7E}.Release|Win32.Build.0 = Release|Win32 + {DDB6F9C3-25D1-43C1-B439-20F2016D2F2E}.Debug|ARM.ActiveCfg = Debug|ARM + {DDB6F9C3-25D1-43C1-B439-20F2016D2F2E}.Debug|ARM.Build.0 = Debug|ARM + {DDB6F9C3-25D1-43C1-B439-20F2016D2F2E}.Debug|Win32.ActiveCfg = Debug|Win32 + {DDB6F9C3-25D1-43C1-B439-20F2016D2F2E}.Debug|Win32.Build.0 = Debug|Win32 + {DDB6F9C3-25D1-43C1-B439-20F2016D2F2E}.Release|ARM.ActiveCfg = Release|ARM + {DDB6F9C3-25D1-43C1-B439-20F2016D2F2E}.Release|ARM.Build.0 = Release|ARM + {DDB6F9C3-25D1-43C1-B439-20F2016D2F2E}.Release|Win32.ActiveCfg = Release|Win32 + {DDB6F9C3-25D1-43C1-B439-20F2016D2F2E}.Release|Win32.Build.0 = Release|Win32 + {8859E555-5684-436D-AD14-4E8CEB11EAD1}.Debug|ARM.ActiveCfg = Debug|ARM + {8859E555-5684-436D-AD14-4E8CEB11EAD1}.Debug|ARM.Build.0 = Debug|ARM + {8859E555-5684-436D-AD14-4E8CEB11EAD1}.Debug|Win32.ActiveCfg = Debug|Win32 + {8859E555-5684-436D-AD14-4E8CEB11EAD1}.Debug|Win32.Build.0 = Debug|Win32 + {8859E555-5684-436D-AD14-4E8CEB11EAD1}.Release|ARM.ActiveCfg = Release|ARM + {8859E555-5684-436D-AD14-4E8CEB11EAD1}.Release|ARM.Build.0 = Release|ARM + {8859E555-5684-436D-AD14-4E8CEB11EAD1}.Release|Win32.ActiveCfg = Release|Win32 + {8859E555-5684-436D-AD14-4E8CEB11EAD1}.Release|Win32.Build.0 = Release|Win32 + {E1553EFC-2C62-41AE-ABA3-D933D66D435D}.Debug|ARM.ActiveCfg = Debug|ARM + {E1553EFC-2C62-41AE-ABA3-D933D66D435D}.Debug|ARM.Build.0 = Debug|ARM + {E1553EFC-2C62-41AE-ABA3-D933D66D435D}.Debug|Win32.ActiveCfg = Debug|Win32 + {E1553EFC-2C62-41AE-ABA3-D933D66D435D}.Debug|Win32.Build.0 = Debug|Win32 + {E1553EFC-2C62-41AE-ABA3-D933D66D435D}.Release|ARM.ActiveCfg = Release|ARM + {E1553EFC-2C62-41AE-ABA3-D933D66D435D}.Release|ARM.Build.0 = Release|ARM + {E1553EFC-2C62-41AE-ABA3-D933D66D435D}.Release|Win32.ActiveCfg = Release|Win32 + {E1553EFC-2C62-41AE-ABA3-D933D66D435D}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/VisualC-WinRT/WinPhone80_VS2012/SDL_mixer-WinPhone80.vcxproj b/VisualC-WinRT/WinPhone80_VS2012/SDL_mixer-WinPhone80.vcxproj new file mode 100644 index 0000000..ecbb249 --- /dev/null +++ b/VisualC-WinRT/WinPhone80_VS2012/SDL_mixer-WinPhone80.vcxproj @@ -0,0 +1,230 @@ + + + + + Debug + Win32 + + + Debug + ARM + + + Release + Win32 + + + Release + ARM + + + + {1f710837-d5c0-4e7f-abea-fbff64722e7e} + SDL2_mixer_WinPhone + en-US + 11.0 + SDL2_mixer-WinPhone80 + + + + DynamicLibrary + true + v110_wp80 + false + + + DynamicLibrary + true + v110_wp80 + false + + + DynamicLibrary + false + true + v110_wp80 + false + + + DynamicLibrary + false + true + v110_wp80 + false + + + + + + + + false + + + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + + _USRDLL;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include + + + Console + false + false + true + + + + + _USRDLL;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;NDEBUG;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include + + + Console + false + false + true + + + + + _USRDLL;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include + + + Console + false + false + true + + + + + _USRDLL;_CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;NDEBUG;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include + + + Console + false + false + true + + + + + true + + + true + false + + + + + {33048af1-031a-4ce6-b61e-fad2db832e9e} + + + {ddb6f9c3-25d1-43c1-b439-20f2016d2f2e} + + + {e1553efc-2c62-41ae-aba3-d933d66d435d} + + + {8859e555-5684-436d-ad14-4e8ceb11ead1} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisualC-WinRT/WinPhone80_VS2012/SDL_mixer-WinPhone80.vcxproj.filters b/VisualC-WinRT/WinPhone80_VS2012/SDL_mixer-WinPhone80.vcxproj.filters new file mode 100644 index 0000000..e998b91 --- /dev/null +++ b/VisualC-WinRT/WinPhone80_VS2012/SDL_mixer-WinPhone80.vcxproj.filters @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + + + + + + + + + + + + + + + + + + + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + + + {ba754ab5-5a7c-4e3c-9a2f-a1a8cf93fa90} + + + \ No newline at end of file diff --git a/VisualC-WinRT/WinPhone80_VS2012/libogg_dynamic-WinPhone80.vcxproj b/VisualC-WinRT/WinPhone80_VS2012/libogg_dynamic-WinPhone80.vcxproj new file mode 100644 index 0000000..fba1ad8 --- /dev/null +++ b/VisualC-WinRT/WinPhone80_VS2012/libogg_dynamic-WinPhone80.vcxproj @@ -0,0 +1,175 @@ + + + + + Debug + Win32 + + + Debug + ARM + + + Release + Win32 + + + Release + ARM + + + + {ddb6f9c3-25d1-43c1-b439-20f2016d2f2e} + libogg_WinPhone + en-US + 11.0 + libogg_dynamic-WinPhone80 + + + + DynamicLibrary + true + v110_wp80 + false + + + DynamicLibrary + true + v110_wp80 + false + + + DynamicLibrary + false + true + v110_wp80 + false + + + DynamicLibrary + false + true + v110_wp80 + false + + + + + + + + false + + + libogg + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + + + libogg + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + + + libogg + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + + + libogg + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + + + + _USRDLL;WIN32;_DEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + ..\..\external\libogg-1.3.2\include + 4244 + + + Console + false + false + true + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + _USRDLL;WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;NDEBUG;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + ..\..\external\libogg-1.3.2\include + 4244 + + + Console + false + false + true + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + _USRDLL;WIN32;_DEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + ..\..\external\libogg-1.3.2\include + 4244 + + + Console + false + false + true + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + _USRDLL;WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;NDEBUG;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + ..\..\external\libogg-1.3.2\include + 4244 + + + Console + false + false + true + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + true + + + true + false + + + + + + + + + + + + + + + + + + diff --git a/VisualC-WinRT/WinPhone80_VS2012/libogg_dynamic-WinPhone80.vcxproj.filters b/VisualC-WinRT/WinPhone80_VS2012/libogg_dynamic-WinPhone80.vcxproj.filters new file mode 100644 index 0000000..79d181b --- /dev/null +++ b/VisualC-WinRT/WinPhone80_VS2012/libogg_dynamic-WinPhone80.vcxproj.filters @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisualC-WinRT/WinPhone80_VS2012/libvorbis_dynamic-WinPhone80.vcxproj b/VisualC-WinRT/WinPhone80_VS2012/libvorbis_dynamic-WinPhone80.vcxproj new file mode 100644 index 0000000..6439efd --- /dev/null +++ b/VisualC-WinRT/WinPhone80_VS2012/libvorbis_dynamic-WinPhone80.vcxproj @@ -0,0 +1,238 @@ + + + + + Debug + Win32 + + + Debug + ARM + + + Release + Win32 + + + Release + ARM + + + + {8859e555-5684-436d-ad14-4e8ceb11ead1} + libvorbis_dynamic_WinPhone + en-US + 11.0 + + + + DynamicLibrary + true + v110_wp80 + false + + + DynamicLibrary + true + v110_wp80 + false + + + DynamicLibrary + false + true + v110_wp80 + false + + + DynamicLibrary + false + true + v110_wp80 + false + + + + + + + + false + + + libvorbis + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + + + libvorbis + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + + + libvorbis + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + + + libvorbis + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + + + + _USRDLL;_DEBUG;_WINDOWS;_USRDLL;LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + 4244;4100;4267;4189;4305;4127;4706 + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include + + + Console + false + false + true + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + _USRDLL;NDEBUG;_WINDOWS;_USRDLL;LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + 4244;4100;4267;4189;4305;4127;4706 + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include + + + Console + false + false + true + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + _USRDLL;_WIN32_WCE;_DEBUG;_WINDOWS;_USRDLL;LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + 4244;4100;4267;4189;4305;4127;4706 + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include + + + Console + false + false + true + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + _USRDLL;_WIN32_WCE;NDEBUG;_WINDOWS;_USRDLL;LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + 4244;4100;4267;4189;4305;4127;4706 + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include + + + Console + false + false + true + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + true + + + true + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {ddb6f9c3-25d1-43c1-b439-20f2016d2f2e} + + + + + + + diff --git a/VisualC-WinRT/WinPhone80_VS2012/libvorbis_dynamic-WinPhone80.vcxproj.filters b/VisualC-WinRT/WinPhone80_VS2012/libvorbis_dynamic-WinPhone80.vcxproj.filters new file mode 100644 index 0000000..e39da2b --- /dev/null +++ b/VisualC-WinRT/WinPhone80_VS2012/libvorbis_dynamic-WinPhone80.vcxproj.filters @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisualC-WinRT/WinPhone80_VS2012/libvorbisfile_dynamic-WinPhone80.vcxproj b/VisualC-WinRT/WinPhone80_VS2012/libvorbisfile_dynamic-WinPhone80.vcxproj new file mode 100644 index 0000000..75f2939 --- /dev/null +++ b/VisualC-WinRT/WinPhone80_VS2012/libvorbisfile_dynamic-WinPhone80.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Debug + ARM + + + Release + Win32 + + + Release + ARM + + + + {e1553efc-2c62-41ae-aba3-d933d66d435d} + libvorbisfile_dynamic_WinPhone + en-US + 11.0 + + + + DynamicLibrary + true + v110_wp80 + false + + + DynamicLibrary + true + v110_wp80 + false + + + DynamicLibrary + false + true + v110_wp80 + false + + + DynamicLibrary + false + true + v110_wp80 + false + + + + + + + + false + + + libvorbisfile + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + + + libvorbisfile + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + + + libvorbisfile + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + + + libvorbisfile + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + + + + _USRDLL;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include + + + Console + false + false + true + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + _USRDLL;NDEBUG;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include + + + Console + false + false + true + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + _USRDLL;_WIN32_WCE;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include + + + Console + false + false + true + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + _USRDLL;_WIN32_WCE;NDEBUG;%(PreprocessorDefinitions) + NotUsing + pch.h + false + $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include + + + Console + false + false + true + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + true + + + true + false + + + + + + + + + + + {ddb6f9c3-25d1-43c1-b439-20f2016d2f2e} + + + {8859e555-5684-436d-ad14-4e8ceb11ead1} + + + + + + + diff --git a/VisualC-WinRT/WinPhone80_VS2012/libvorbisfile_dynamic-WinPhone80.vcxproj.filters b/VisualC-WinRT/WinPhone80_VS2012/libvorbisfile_dynamic-WinPhone80.vcxproj.filters new file mode 100644 index 0000000..f70e45d --- /dev/null +++ b/VisualC-WinRT/WinPhone80_VS2012/libvorbisfile_dynamic-WinPhone80.vcxproj.filters @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/VisualC-WinRT/WinPhone81_VS2013/SDL_mixer-WinPhone81.sln b/VisualC-WinRT/WinPhone81_VS2013/SDL_mixer-WinPhone81.sln new file mode 100644 index 0000000..b507712 --- /dev/null +++ b/VisualC-WinRT/WinPhone81_VS2013/SDL_mixer-WinPhone81.sln @@ -0,0 +1,58 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.40629.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2_mixer-WinPhone81", "SDL_mixer-WinPhone81.vcxproj", "{FB75C3D3-D261-4575-9D17-9E88E09568BA}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libogg_dynamic-WinPhone81", "libogg_dynamic-WinPhone81.vcxproj", "{0CCC2E56-E3A4-4CD7-92BA-0C6F99440753}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libvorbis_dynamic-WinPhone81", "libvorbis_dynamic-WinPhone81.vcxproj", "{C943DBC9-4EB0-4684-BE3E-334342A7EE2C}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libvorbisfile_dynamic-WinPhone81", "libvorbisfile_dynamic-WinPhone81.vcxproj", "{203EFCC5-CE11-4A75-92F4-C3DBF7609376}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|Win32 = Debug|Win32 + Release|ARM = Release|ARM + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FB75C3D3-D261-4575-9D17-9E88E09568BA}.Debug|ARM.ActiveCfg = Debug|ARM + {FB75C3D3-D261-4575-9D17-9E88E09568BA}.Debug|ARM.Build.0 = Debug|ARM + {FB75C3D3-D261-4575-9D17-9E88E09568BA}.Debug|Win32.ActiveCfg = Debug|Win32 + {FB75C3D3-D261-4575-9D17-9E88E09568BA}.Debug|Win32.Build.0 = Debug|Win32 + {FB75C3D3-D261-4575-9D17-9E88E09568BA}.Release|ARM.ActiveCfg = Release|ARM + {FB75C3D3-D261-4575-9D17-9E88E09568BA}.Release|ARM.Build.0 = Release|ARM + {FB75C3D3-D261-4575-9D17-9E88E09568BA}.Release|Win32.ActiveCfg = Release|Win32 + {FB75C3D3-D261-4575-9D17-9E88E09568BA}.Release|Win32.Build.0 = Release|Win32 + {0CCC2E56-E3A4-4CD7-92BA-0C6F99440753}.Debug|ARM.ActiveCfg = Debug|ARM + {0CCC2E56-E3A4-4CD7-92BA-0C6F99440753}.Debug|ARM.Build.0 = Debug|ARM + {0CCC2E56-E3A4-4CD7-92BA-0C6F99440753}.Debug|Win32.ActiveCfg = Debug|Win32 + {0CCC2E56-E3A4-4CD7-92BA-0C6F99440753}.Debug|Win32.Build.0 = Debug|Win32 + {0CCC2E56-E3A4-4CD7-92BA-0C6F99440753}.Release|ARM.ActiveCfg = Release|ARM + {0CCC2E56-E3A4-4CD7-92BA-0C6F99440753}.Release|ARM.Build.0 = Release|ARM + {0CCC2E56-E3A4-4CD7-92BA-0C6F99440753}.Release|Win32.ActiveCfg = Release|Win32 + {0CCC2E56-E3A4-4CD7-92BA-0C6F99440753}.Release|Win32.Build.0 = Release|Win32 + {C943DBC9-4EB0-4684-BE3E-334342A7EE2C}.Debug|ARM.ActiveCfg = Debug|ARM + {C943DBC9-4EB0-4684-BE3E-334342A7EE2C}.Debug|ARM.Build.0 = Debug|ARM + {C943DBC9-4EB0-4684-BE3E-334342A7EE2C}.Debug|Win32.ActiveCfg = Debug|Win32 + {C943DBC9-4EB0-4684-BE3E-334342A7EE2C}.Debug|Win32.Build.0 = Debug|Win32 + {C943DBC9-4EB0-4684-BE3E-334342A7EE2C}.Release|ARM.ActiveCfg = Release|ARM + {C943DBC9-4EB0-4684-BE3E-334342A7EE2C}.Release|ARM.Build.0 = Release|ARM + {C943DBC9-4EB0-4684-BE3E-334342A7EE2C}.Release|Win32.ActiveCfg = Release|Win32 + {C943DBC9-4EB0-4684-BE3E-334342A7EE2C}.Release|Win32.Build.0 = Release|Win32 + {203EFCC5-CE11-4A75-92F4-C3DBF7609376}.Debug|ARM.ActiveCfg = Debug|ARM + {203EFCC5-CE11-4A75-92F4-C3DBF7609376}.Debug|ARM.Build.0 = Debug|ARM + {203EFCC5-CE11-4A75-92F4-C3DBF7609376}.Debug|Win32.ActiveCfg = Debug|Win32 + {203EFCC5-CE11-4A75-92F4-C3DBF7609376}.Debug|Win32.Build.0 = Debug|Win32 + {203EFCC5-CE11-4A75-92F4-C3DBF7609376}.Release|ARM.ActiveCfg = Release|ARM + {203EFCC5-CE11-4A75-92F4-C3DBF7609376}.Release|ARM.Build.0 = Release|ARM + {203EFCC5-CE11-4A75-92F4-C3DBF7609376}.Release|Win32.ActiveCfg = Release|Win32 + {203EFCC5-CE11-4A75-92F4-C3DBF7609376}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/VisualC-WinRT/WinPhone81_VS2013/SDL_mixer-WinPhone81.vcxproj b/VisualC-WinRT/WinPhone81_VS2013/SDL_mixer-WinPhone81.vcxproj new file mode 100644 index 0000000..9432524 --- /dev/null +++ b/VisualC-WinRT/WinPhone81_VS2013/SDL_mixer-WinPhone81.vcxproj @@ -0,0 +1,223 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + ARM + + + Release + ARM + + + + + {48fadc0e-964d-4dab-bced-372e0ad19577} + + + {0ccc2e56-e3a4-4cd7-92ba-0c6f99440753} + + + {203efcc5-ce11-4a75-92f4-c3dbf7609376} + + + {c943dbc9-4eb0-4684-be3e-334342a7ee2c} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {fb75c3d3-d261-4575-9d17-9e88e09568ba} + Win32Proj + SDL2_mixer-WinPhone81 + SDL2_mixer_WinPhone81 + en-US + 12.0 + true + Windows Phone + 8.1 + + + + DynamicLibrary + true + v120_wp81 + + + DynamicLibrary + false + true + v120_wp81 + + + DynamicLibrary + true + v120_wp81 + + + DynamicLibrary + false + true + v120_wp81 + + + + + + + + + + + + + + + + + + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + + NotUsing + false + true + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + true + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;NDEBUG;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + true + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + true + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;NDEBUG;%(PreprocessorDefinitions) + + + Console + false + false + + + + + + diff --git a/VisualC-WinRT/WinPhone81_VS2013/SDL_mixer-WinPhone81.vcxproj.filters b/VisualC-WinRT/WinPhone81_VS2013/SDL_mixer-WinPhone81.vcxproj.filters new file mode 100644 index 0000000..814b8f7 --- /dev/null +++ b/VisualC-WinRT/WinPhone81_VS2013/SDL_mixer-WinPhone81.vcxproj.filters @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + + + + + + + + + + + + + + + + + + + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + + + {3f55d8a7-802e-40cd-8b4e-b87e9fe24589} + + + \ No newline at end of file diff --git a/VisualC-WinRT/WinPhone81_VS2013/libogg_dynamic-WinPhone81.vcxproj b/VisualC-WinRT/WinPhone81_VS2013/libogg_dynamic-WinPhone81.vcxproj new file mode 100644 index 0000000..afbbdff --- /dev/null +++ b/VisualC-WinRT/WinPhone81_VS2013/libogg_dynamic-WinPhone81.vcxproj @@ -0,0 +1,168 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + ARM + + + Release + ARM + + + + + + + + + + + + + + + {0ccc2e56-e3a4-4cd7-92ba-0c6f99440753} + Win32Proj + libogg_dynamic-WinPhone81 + libogg_dynamic_WinPhone81 + en-US + 12.0 + true + Windows Phone + 8.1 + + + + DynamicLibrary + true + v120_wp81 + + + DynamicLibrary + false + true + v120_wp81 + + + DynamicLibrary + true + v120_wp81 + + + DynamicLibrary + false + true + v120_wp81 + + + + + + + + + + + + + + + + + + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libogg + + + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libogg + + + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libogg + + + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libogg + + + + NotUsing + false + true + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + 4244 + + + Console + false + false + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + NotUsing + false + true + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + 4244 + + + Console + false + false + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + NotUsing + false + true + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + 4244 + + + Console + false + false + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + NotUsing + false + true + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + 4244 + + + Console + false + false + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + + diff --git a/VisualC-WinRT/WinPhone81_VS2013/libogg_dynamic-WinPhone81.vcxproj.filters b/VisualC-WinRT/WinPhone81_VS2013/libogg_dynamic-WinPhone81.vcxproj.filters new file mode 100644 index 0000000..edaf205 --- /dev/null +++ b/VisualC-WinRT/WinPhone81_VS2013/libogg_dynamic-WinPhone81.vcxproj.filters @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisualC-WinRT/WinPhone81_VS2013/libvorbis_dynamic-WinPhone81.vcxproj b/VisualC-WinRT/WinPhone81_VS2013/libvorbis_dynamic-WinPhone81.vcxproj new file mode 100644 index 0000000..c41e3be --- /dev/null +++ b/VisualC-WinRT/WinPhone81_VS2013/libvorbis_dynamic-WinPhone81.vcxproj @@ -0,0 +1,232 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + ARM + + + Release + ARM + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {0ccc2e56-e3a4-4cd7-92ba-0c6f99440753} + + + + {c943dbc9-4eb0-4684-be3e-334342a7ee2c} + Win32Proj + libvorbis_dynamic-WinPhone81 + libvorbis_dynamic_WinPhone81 + en-US + 12.0 + true + Windows Phone + 8.1 + + + + DynamicLibrary + true + v120_wp81 + + + DynamicLibrary + false + true + v120_wp81 + + + DynamicLibrary + true + v120_wp81 + + + DynamicLibrary + false + true + v120_wp81 + + + + + + + + + + + + + + + + + + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbis + + + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbis + + + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbis + + + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbis + + + + NotUsing + false + true + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + 4244;4100;4267;4189;4305;4127;4706 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + NotUsing + false + true + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + 4244;4100;4267;4189;4305;4127;4706 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + NotUsing + false + true + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;_WIN32_WCE;%(PreprocessorDefinitions) + 4244;4100;4267;4189;4305;4127;4706 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + NotUsing + false + true + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;_WIN32_WCE;%(PreprocessorDefinitions) + 4244;4100;4267;4189;4305;4127;4706 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + + diff --git a/VisualC-WinRT/WinPhone81_VS2013/libvorbis_dynamic-WinPhone81.vcxproj.filters b/VisualC-WinRT/WinPhone81_VS2013/libvorbis_dynamic-WinPhone81.vcxproj.filters new file mode 100644 index 0000000..2101a47 --- /dev/null +++ b/VisualC-WinRT/WinPhone81_VS2013/libvorbis_dynamic-WinPhone81.vcxproj.filters @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisualC-WinRT/WinPhone81_VS2013/libvorbisfile_dynamic-WinPhone81.vcxproj b/VisualC-WinRT/WinPhone81_VS2013/libvorbisfile_dynamic-WinPhone81.vcxproj new file mode 100644 index 0000000..35b9a30 --- /dev/null +++ b/VisualC-WinRT/WinPhone81_VS2013/libvorbisfile_dynamic-WinPhone81.vcxproj @@ -0,0 +1,171 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + ARM + + + Release + ARM + + + + + + + + + + + {0ccc2e56-e3a4-4cd7-92ba-0c6f99440753} + + + {c943dbc9-4eb0-4684-be3e-334342a7ee2c} + + + + {203efcc5-ce11-4a75-92f4-c3dbf7609376} + Win32Proj + libvorbisfile_dynamic-WinPhone81 + libvorbisfile_dynamic_WinPhone81 + en-US + 12.0 + true + Windows Phone + 8.1 + + + + DynamicLibrary + true + v120_wp81 + + + DynamicLibrary + false + true + v120_wp81 + + + DynamicLibrary + true + v120_wp81 + + + DynamicLibrary + false + true + v120_wp81 + + + + + + + + + + + + + + + + + + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbisfile + + + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbisfile + + + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbisfile + + + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbisfile + + + + NotUsing + false + true + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;PSAPI_VERSION=2;WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP;_UITHREADCTXT_SUPPORT=0;%(PreprocessorDefinitions) + 4244;4101 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + NotUsing + false + true + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions) + 4244;4101 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + NotUsing + false + true + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;_WIN32_WCE;PSAPI_VERSION=2;WINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP;_UITHREADCTXT_SUPPORT=0;%(PreprocessorDefinitions) + 4244;4101 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + NotUsing + false + true + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;_WIN32_WCE;NDEBUG;%(PreprocessorDefinitions) + 4244;4101 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + + diff --git a/VisualC-WinRT/WinPhone81_VS2013/libvorbisfile_dynamic-WinPhone81.vcxproj.filters b/VisualC-WinRT/WinPhone81_VS2013/libvorbisfile_dynamic-WinPhone81.vcxproj.filters new file mode 100644 index 0000000..74d0fac --- /dev/null +++ b/VisualC-WinRT/WinPhone81_VS2013/libvorbisfile_dynamic-WinPhone81.vcxproj.filters @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/VisualC-WinRT/WinRT80_VS2012/SDL_mixer-WinRT80.sln b/VisualC-WinRT/WinRT80_VS2012/SDL_mixer-WinRT80.sln new file mode 100644 index 0000000..03f7674 --- /dev/null +++ b/VisualC-WinRT/WinRT80_VS2012/SDL_mixer-WinRT80.sln @@ -0,0 +1,74 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2_mixer-WinRT80", "SDL_mixer-WinRT80.vcxproj", "{06925935-B340-44E8-BDDD-7C1B8D64FF76}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libogg_dynamic-WinRT80", "libogg_dynamic-WinRT80.vcxproj", "{15CBFEFF-7965-41F5-B4E2-21E8795C9159}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libvorbis_dynamic-WinRT80", "libvorbis_dynamic-WinRT80.vcxproj", "{3A214E06-B95E-4D61-A291-1F8DF2EC10FD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libvorbisfile_dynamic-WinRT80", "libvorbisfile_dynamic-WinRT80.vcxproj", "{CEBDE98B-A6AA-46E6-BC79-FAAF823DB9EC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|ARM = Release|ARM + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {06925935-B340-44E8-BDDD-7C1B8D64FF76}.Debug|ARM.ActiveCfg = Debug|ARM + {06925935-B340-44E8-BDDD-7C1B8D64FF76}.Debug|ARM.Build.0 = Debug|ARM + {06925935-B340-44E8-BDDD-7C1B8D64FF76}.Debug|Win32.ActiveCfg = Debug|Win32 + {06925935-B340-44E8-BDDD-7C1B8D64FF76}.Debug|Win32.Build.0 = Debug|Win32 + {06925935-B340-44E8-BDDD-7C1B8D64FF76}.Debug|x64.ActiveCfg = Debug|x64 + {06925935-B340-44E8-BDDD-7C1B8D64FF76}.Debug|x64.Build.0 = Debug|x64 + {06925935-B340-44E8-BDDD-7C1B8D64FF76}.Release|ARM.ActiveCfg = Release|ARM + {06925935-B340-44E8-BDDD-7C1B8D64FF76}.Release|ARM.Build.0 = Release|ARM + {06925935-B340-44E8-BDDD-7C1B8D64FF76}.Release|Win32.ActiveCfg = Release|Win32 + {06925935-B340-44E8-BDDD-7C1B8D64FF76}.Release|Win32.Build.0 = Release|Win32 + {06925935-B340-44E8-BDDD-7C1B8D64FF76}.Release|x64.ActiveCfg = Release|x64 + {06925935-B340-44E8-BDDD-7C1B8D64FF76}.Release|x64.Build.0 = Release|x64 + {15CBFEFF-7965-41F5-B4E2-21E8795C9159}.Debug|ARM.ActiveCfg = Debug|ARM + {15CBFEFF-7965-41F5-B4E2-21E8795C9159}.Debug|ARM.Build.0 = Debug|ARM + {15CBFEFF-7965-41F5-B4E2-21E8795C9159}.Debug|Win32.ActiveCfg = Debug|Win32 + {15CBFEFF-7965-41F5-B4E2-21E8795C9159}.Debug|Win32.Build.0 = Debug|Win32 + {15CBFEFF-7965-41F5-B4E2-21E8795C9159}.Debug|x64.ActiveCfg = Debug|x64 + {15CBFEFF-7965-41F5-B4E2-21E8795C9159}.Debug|x64.Build.0 = Debug|x64 + {15CBFEFF-7965-41F5-B4E2-21E8795C9159}.Release|ARM.ActiveCfg = Release|ARM + {15CBFEFF-7965-41F5-B4E2-21E8795C9159}.Release|ARM.Build.0 = Release|ARM + {15CBFEFF-7965-41F5-B4E2-21E8795C9159}.Release|Win32.ActiveCfg = Release|Win32 + {15CBFEFF-7965-41F5-B4E2-21E8795C9159}.Release|Win32.Build.0 = Release|Win32 + {15CBFEFF-7965-41F5-B4E2-21E8795C9159}.Release|x64.ActiveCfg = Release|x64 + {15CBFEFF-7965-41F5-B4E2-21E8795C9159}.Release|x64.Build.0 = Release|x64 + {3A214E06-B95E-4D61-A291-1F8DF2EC10FD}.Debug|ARM.ActiveCfg = Debug|ARM + {3A214E06-B95E-4D61-A291-1F8DF2EC10FD}.Debug|ARM.Build.0 = Debug|ARM + {3A214E06-B95E-4D61-A291-1F8DF2EC10FD}.Debug|Win32.ActiveCfg = Debug|Win32 + {3A214E06-B95E-4D61-A291-1F8DF2EC10FD}.Debug|Win32.Build.0 = Debug|Win32 + {3A214E06-B95E-4D61-A291-1F8DF2EC10FD}.Debug|x64.ActiveCfg = Debug|x64 + {3A214E06-B95E-4D61-A291-1F8DF2EC10FD}.Debug|x64.Build.0 = Debug|x64 + {3A214E06-B95E-4D61-A291-1F8DF2EC10FD}.Release|ARM.ActiveCfg = Release|ARM + {3A214E06-B95E-4D61-A291-1F8DF2EC10FD}.Release|ARM.Build.0 = Release|ARM + {3A214E06-B95E-4D61-A291-1F8DF2EC10FD}.Release|Win32.ActiveCfg = Release|Win32 + {3A214E06-B95E-4D61-A291-1F8DF2EC10FD}.Release|Win32.Build.0 = Release|Win32 + {3A214E06-B95E-4D61-A291-1F8DF2EC10FD}.Release|x64.ActiveCfg = Release|x64 + {3A214E06-B95E-4D61-A291-1F8DF2EC10FD}.Release|x64.Build.0 = Release|x64 + {CEBDE98B-A6AA-46E6-BC79-FAAF823DB9EC}.Debug|ARM.ActiveCfg = Debug|ARM + {CEBDE98B-A6AA-46E6-BC79-FAAF823DB9EC}.Debug|ARM.Build.0 = Debug|ARM + {CEBDE98B-A6AA-46E6-BC79-FAAF823DB9EC}.Debug|Win32.ActiveCfg = Debug|Win32 + {CEBDE98B-A6AA-46E6-BC79-FAAF823DB9EC}.Debug|Win32.Build.0 = Debug|Win32 + {CEBDE98B-A6AA-46E6-BC79-FAAF823DB9EC}.Debug|x64.ActiveCfg = Debug|x64 + {CEBDE98B-A6AA-46E6-BC79-FAAF823DB9EC}.Debug|x64.Build.0 = Debug|x64 + {CEBDE98B-A6AA-46E6-BC79-FAAF823DB9EC}.Release|ARM.ActiveCfg = Release|ARM + {CEBDE98B-A6AA-46E6-BC79-FAAF823DB9EC}.Release|ARM.Build.0 = Release|ARM + {CEBDE98B-A6AA-46E6-BC79-FAAF823DB9EC}.Release|Win32.ActiveCfg = Release|Win32 + {CEBDE98B-A6AA-46E6-BC79-FAAF823DB9EC}.Release|Win32.Build.0 = Release|Win32 + {CEBDE98B-A6AA-46E6-BC79-FAAF823DB9EC}.Release|x64.ActiveCfg = Release|x64 + {CEBDE98B-A6AA-46E6-BC79-FAAF823DB9EC}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/VisualC-WinRT/WinRT80_VS2012/SDL_mixer-WinRT80.vcxproj b/VisualC-WinRT/WinRT80_VS2012/SDL_mixer-WinRT80.vcxproj new file mode 100644 index 0000000..6201615 --- /dev/null +++ b/VisualC-WinRT/WinRT80_VS2012/SDL_mixer-WinRT80.vcxproj @@ -0,0 +1,284 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + + {aeaea3a2-d4e6-45b1-8ec6-53d84287fc14} + + + {15cbfeff-7965-41f5-b4e2-21e8795c9159} + + + {cebde98b-a6aa-46e6-bc79-faaf823db9ec} + + + {3a214e06-b95e-4d61-a291-1f8df2ec10fd} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {06925935-b340-44e8-bddd-7c1b8d64ff76} + Win32Proj + SDL2_mixer-WinRT80 + SDL_mixer_VS2012_WinRT + en-US + 11.0 + true + + + + DynamicLibrary + true + v110 + + + DynamicLibrary + true + v110 + + + DynamicLibrary + true + v110 + + + DynamicLibrary + false + true + v110 + + + DynamicLibrary + false + true + v110 + + + DynamicLibrary + false + true + v110 + + + + + + + + + + + + + + + + + + + + + + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + + + Console + false + false + + + + + + \ No newline at end of file diff --git a/VisualC-WinRT/WinRT80_VS2012/SDL_mixer-WinRT80.vcxproj.filters b/VisualC-WinRT/WinRT80_VS2012/SDL_mixer-WinRT80.vcxproj.filters new file mode 100644 index 0000000..463712c --- /dev/null +++ b/VisualC-WinRT/WinRT80_VS2012/SDL_mixer-WinRT80.vcxproj.filters @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + + + + + + + + + + + + + + + + + + + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + + + {76edff39-58d9-4391-b729-e34269a68b5a} + + + \ No newline at end of file diff --git a/VisualC-WinRT/WinRT80_VS2012/libogg_dynamic-WinRT80.vcxproj b/VisualC-WinRT/WinRT80_VS2012/libogg_dynamic-WinRT80.vcxproj new file mode 100644 index 0000000..a763d54 --- /dev/null +++ b/VisualC-WinRT/WinRT80_VS2012/libogg_dynamic-WinRT80.vcxproj @@ -0,0 +1,279 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + libogg_dynamic-WinRT80 + {15CBFEFF-7965-41F5-B4E2-21E8795C9159} + libogg + Win32Proj + + + + DynamicLibrary + Unicode + true + v110 + true + + + DynamicLibrary + Unicode + true + v110 + true + + + DynamicLibrary + Unicode + v110 + true + + + DynamicLibrary + Unicode + v110 + true + + + DynamicLibrary + Unicode + true + v110 + true + + + DynamicLibrary + Unicode + v110 + true + + + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + + + libogg + + + libogg + + + libogg + + + libogg + + + libogg + + + libogg + + + + Disabled + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + EditAndContinue + CompileAsC + Cdecl + + + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + Disabled + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + EditAndContinue + CompileAsC + Cdecl + + + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + X64 + + + Disabled + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + ProgramDatabase + CompileAsC + Cdecl + + + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + MaxSpeed + AnySuitable + true + Speed + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + + + Level4 + + + CompileAsC + 4244;%(DisableSpecificWarnings) + Cdecl + + + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + MaxSpeed + AnySuitable + true + Speed + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + + + Level4 + + + CompileAsC + 4244;%(DisableSpecificWarnings) + Cdecl + + + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + X64 + + + MaxSpeed + AnySuitable + true + Speed + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + + + Level4 + + + CompileAsC + 4244;%(DisableSpecificWarnings) + Cdecl + + + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + + + + + + + + + + + + + diff --git a/VisualC-WinRT/WinRT80_VS2012/libvorbis_dynamic-WinRT80.vcxproj b/VisualC-WinRT/WinRT80_VS2012/libvorbis_dynamic-WinRT80.vcxproj new file mode 100644 index 0000000..642a853 --- /dev/null +++ b/VisualC-WinRT/WinRT80_VS2012/libvorbis_dynamic-WinRT80.vcxproj @@ -0,0 +1,359 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + libvorbis_dynamic-WinRT80 + {3A214E06-B95E-4D61-A291-1F8DF2EC10FD} + libvorbis + Win32Proj + + + + DynamicLibrary + Unicode + true + v110 + true + + + DynamicLibrary + Unicode + true + v110 + true + + + DynamicLibrary + Unicode + v110 + true + + + DynamicLibrary + Unicode + v110 + true + + + DynamicLibrary + Unicode + true + v110 + true + + + DynamicLibrary + Unicode + v110 + true + + + + + + + <_ProjectFileVersion>10.0.30319.1 + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + true + true + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + true + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + false + + + libvorbis + + + libvorbis + + + libvorbis + + + libvorbis + + + libvorbis + + + libvorbis + + + + Disabled + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + EditAndContinue + CompileAsC + Cdecl + + + %(AdditionalDependencies) + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + true + $(OutDir)libvorbis.pdb + Windows + MachineX86 + + + + + Disabled + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;_WIN32_WCE;_DEBUG;_WINDOWS;_USRDLL;LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + EditAndContinue + CompileAsC + Cdecl + + + %(AdditionalDependencies) + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + true + $(OutDir)libvorbis.pdb + Windows + + + + + X64 + + + Disabled + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level4 + ProgramDatabase + CompileAsC + Cdecl + + + %(AdditionalDependencies) + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + true + $(OutDir)libvorbis.pdb + Windows + MachineX64 + + + + + Full + AnySuitable + true + Speed + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + + + Level4 + ProgramDatabase + CompileAsC + 4244;4100;4267;4189;4305;4127;4706;%(DisableSpecificWarnings) + Cdecl + + + %(AdditionalDependencies) + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + false + Windows + true + true + MachineX86 + + + + + Full + AnySuitable + true + Speed + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;_WIN32_WCE;NDEBUG;_WINDOWS;_USRDLL;LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + + + Level4 + ProgramDatabase + CompileAsC + 4244;4100;4267;4189;4305;4127;4706;%(DisableSpecificWarnings) + Cdecl + + + %(AdditionalDependencies) + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + false + Windows + true + true + + + + + X64 + + + Full + AnySuitable + true + Speed + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + MultiThreadedDLL + false + + + Level4 + ProgramDatabase + CompileAsC + 4244;4100;4267;4189;4305;4127;4706;%(DisableSpecificWarnings) + Cdecl + + + %(AdditionalDependencies) + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + false + Windows + true + true + MachineX64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {15cbfeff-7965-41f5-b4e2-21e8795c9159} + + + + + + diff --git a/VisualC-WinRT/WinRT80_VS2012/libvorbisfile_dynamic-WinRT80.vcxproj b/VisualC-WinRT/WinRT80_VS2012/libvorbisfile_dynamic-WinRT80.vcxproj new file mode 100644 index 0000000..8579be7 --- /dev/null +++ b/VisualC-WinRT/WinRT80_VS2012/libvorbisfile_dynamic-WinRT80.vcxproj @@ -0,0 +1,266 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + libvorbisfile_dynamic-WinRT80 + {CEBDE98B-A6AA-46E6-BC79-FAAF823DB9EC} + libvorbisfile + Win32Proj + + + + DynamicLibrary + Unicode + v110 + true + + + DynamicLibrary + Unicode + v110 + true + + + DynamicLibrary + Unicode + v110 + true + + + DynamicLibrary + Unicode + v110 + true + + + DynamicLibrary + Unicode + v110 + true + + + DynamicLibrary + Unicode + v110 + true + + + + + + + <_ProjectFileVersion>10.0.30319.1 + $(SolutionDir)$(Configuration)\$(MSBuildProjectName)\ + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + true + true + $(SolutionDir)$(Configuration)\$(MSBuildProjectName)\ + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + true + $(SolutionDir)$(Configuration)\$(MSBuildProjectName)\ + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + false + false + $(SolutionDir)$(Configuration)\$(MSBuildProjectName)\ + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + false + + + libvorbisfile + + + libvorbisfile + + + libvorbisfile + + + libvorbisfile + + + libvorbisfile + + + libvorbisfile + + + + Disabled + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBVORBISFILE_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + EditAndContinue + Cdecl + + + %(AdditionalDependencies) + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + true + $(OutDir)libvorbisfile.pdb + Windows + MachineX86 + + + + + Disabled + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;%(AdditionalIncludeDirectories) + WIN32;_WIN32_WCE;_DEBUG;_WINDOWS;_USRDLL;LIBVORBISFILE_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + EditAndContinue + Cdecl + + + %(AdditionalDependencies) + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + true + $(OutDir)libvorbisfile.pdb + Windows + + + + + X64 + + + Disabled + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBVORBISFILE_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + ProgramDatabase + Cdecl + + + %(AdditionalDependencies) + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + true + $(OutDir)libvorbisfile.pdb + Windows + MachineX64 + + + + + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBVORBISFILE_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level3 + ProgramDatabase + Cdecl + + + %(AdditionalDependencies) + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + false + Windows + true + true + MachineX86 + + + + + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;%(AdditionalIncludeDirectories) + WIN32;_WIN32_WCE;NDEBUG;_WINDOWS;_USRDLL;LIBVORBISFILE_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level3 + ProgramDatabase + Cdecl + + + %(AdditionalDependencies) + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + false + Windows + true + true + + + + + X64 + + + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBVORBISFILE_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + MultiThreadedDLL + + + Level3 + ProgramDatabase + Cdecl + + + %(AdditionalDependencies) + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + false + Windows + true + true + MachineX64 + + + + + + + + + + + {15cbfeff-7965-41f5-b4e2-21e8795c9159} + + + {3a214e06-b95e-4d61-a291-1f8df2ec10fd} + + + + + + diff --git a/VisualC-WinRT/WinRT81_VS2013/SDL_mixer-WinRT81.sln b/VisualC-WinRT/WinRT81_VS2013/SDL_mixer-WinRT81.sln new file mode 100644 index 0000000..9d0bb93 --- /dev/null +++ b/VisualC-WinRT/WinRT81_VS2013/SDL_mixer-WinRT81.sln @@ -0,0 +1,76 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.40629.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2_mixer-WinRT81", "SDL_mixer-WinRT81.vcxproj", "{3A833C7A-C776-4202-9DBD-BC879B23C605}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libogg_dynamic-WinRT81", "libogg_dynamic-WinRT81.vcxproj", "{6BC6349C-E355-4F1C-9290-FF755114A84B}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libvorbis_dynamic-WinRT81", "libvorbis_dynamic-WinRT81.vcxproj", "{E3AB27F1-EB89-4C65-85DF-CB6A4F805753}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libvorbisfile_dynamic-WinRT81", "libvorbisfile_dynamic-WinRT81.vcxproj", "{936B2819-2364-45D9-901D-52878914FAFA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|ARM = Release|ARM + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3A833C7A-C776-4202-9DBD-BC879B23C605}.Debug|ARM.ActiveCfg = Debug|ARM + {3A833C7A-C776-4202-9DBD-BC879B23C605}.Debug|ARM.Build.0 = Debug|ARM + {3A833C7A-C776-4202-9DBD-BC879B23C605}.Debug|Win32.ActiveCfg = Debug|Win32 + {3A833C7A-C776-4202-9DBD-BC879B23C605}.Debug|Win32.Build.0 = Debug|Win32 + {3A833C7A-C776-4202-9DBD-BC879B23C605}.Debug|x64.ActiveCfg = Debug|x64 + {3A833C7A-C776-4202-9DBD-BC879B23C605}.Debug|x64.Build.0 = Debug|x64 + {3A833C7A-C776-4202-9DBD-BC879B23C605}.Release|ARM.ActiveCfg = Release|ARM + {3A833C7A-C776-4202-9DBD-BC879B23C605}.Release|ARM.Build.0 = Release|ARM + {3A833C7A-C776-4202-9DBD-BC879B23C605}.Release|Win32.ActiveCfg = Release|Win32 + {3A833C7A-C776-4202-9DBD-BC879B23C605}.Release|Win32.Build.0 = Release|Win32 + {3A833C7A-C776-4202-9DBD-BC879B23C605}.Release|x64.ActiveCfg = Release|x64 + {3A833C7A-C776-4202-9DBD-BC879B23C605}.Release|x64.Build.0 = Release|x64 + {6BC6349C-E355-4F1C-9290-FF755114A84B}.Debug|ARM.ActiveCfg = Debug|ARM + {6BC6349C-E355-4F1C-9290-FF755114A84B}.Debug|ARM.Build.0 = Debug|ARM + {6BC6349C-E355-4F1C-9290-FF755114A84B}.Debug|Win32.ActiveCfg = Debug|Win32 + {6BC6349C-E355-4F1C-9290-FF755114A84B}.Debug|Win32.Build.0 = Debug|Win32 + {6BC6349C-E355-4F1C-9290-FF755114A84B}.Debug|x64.ActiveCfg = Debug|x64 + {6BC6349C-E355-4F1C-9290-FF755114A84B}.Debug|x64.Build.0 = Debug|x64 + {6BC6349C-E355-4F1C-9290-FF755114A84B}.Release|ARM.ActiveCfg = Release|ARM + {6BC6349C-E355-4F1C-9290-FF755114A84B}.Release|ARM.Build.0 = Release|ARM + {6BC6349C-E355-4F1C-9290-FF755114A84B}.Release|Win32.ActiveCfg = Release|Win32 + {6BC6349C-E355-4F1C-9290-FF755114A84B}.Release|Win32.Build.0 = Release|Win32 + {6BC6349C-E355-4F1C-9290-FF755114A84B}.Release|x64.ActiveCfg = Release|x64 + {6BC6349C-E355-4F1C-9290-FF755114A84B}.Release|x64.Build.0 = Release|x64 + {E3AB27F1-EB89-4C65-85DF-CB6A4F805753}.Debug|ARM.ActiveCfg = Debug|ARM + {E3AB27F1-EB89-4C65-85DF-CB6A4F805753}.Debug|ARM.Build.0 = Debug|ARM + {E3AB27F1-EB89-4C65-85DF-CB6A4F805753}.Debug|Win32.ActiveCfg = Debug|Win32 + {E3AB27F1-EB89-4C65-85DF-CB6A4F805753}.Debug|Win32.Build.0 = Debug|Win32 + {E3AB27F1-EB89-4C65-85DF-CB6A4F805753}.Debug|x64.ActiveCfg = Debug|x64 + {E3AB27F1-EB89-4C65-85DF-CB6A4F805753}.Debug|x64.Build.0 = Debug|x64 + {E3AB27F1-EB89-4C65-85DF-CB6A4F805753}.Release|ARM.ActiveCfg = Release|ARM + {E3AB27F1-EB89-4C65-85DF-CB6A4F805753}.Release|ARM.Build.0 = Release|ARM + {E3AB27F1-EB89-4C65-85DF-CB6A4F805753}.Release|Win32.ActiveCfg = Release|Win32 + {E3AB27F1-EB89-4C65-85DF-CB6A4F805753}.Release|Win32.Build.0 = Release|Win32 + {E3AB27F1-EB89-4C65-85DF-CB6A4F805753}.Release|x64.ActiveCfg = Release|x64 + {E3AB27F1-EB89-4C65-85DF-CB6A4F805753}.Release|x64.Build.0 = Release|x64 + {936B2819-2364-45D9-901D-52878914FAFA}.Debug|ARM.ActiveCfg = Debug|ARM + {936B2819-2364-45D9-901D-52878914FAFA}.Debug|ARM.Build.0 = Debug|ARM + {936B2819-2364-45D9-901D-52878914FAFA}.Debug|Win32.ActiveCfg = Debug|Win32 + {936B2819-2364-45D9-901D-52878914FAFA}.Debug|Win32.Build.0 = Debug|Win32 + {936B2819-2364-45D9-901D-52878914FAFA}.Debug|x64.ActiveCfg = Debug|x64 + {936B2819-2364-45D9-901D-52878914FAFA}.Debug|x64.Build.0 = Debug|x64 + {936B2819-2364-45D9-901D-52878914FAFA}.Release|ARM.ActiveCfg = Release|ARM + {936B2819-2364-45D9-901D-52878914FAFA}.Release|ARM.Build.0 = Release|ARM + {936B2819-2364-45D9-901D-52878914FAFA}.Release|Win32.ActiveCfg = Release|Win32 + {936B2819-2364-45D9-901D-52878914FAFA}.Release|Win32.Build.0 = Release|Win32 + {936B2819-2364-45D9-901D-52878914FAFA}.Release|x64.ActiveCfg = Release|x64 + {936B2819-2364-45D9-901D-52878914FAFA}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/VisualC-WinRT/WinRT81_VS2013/SDL_mixer-WinRT81.vcxproj b/VisualC-WinRT/WinRT81_VS2013/SDL_mixer-WinRT81.vcxproj new file mode 100644 index 0000000..8524c12 --- /dev/null +++ b/VisualC-WinRT/WinRT81_VS2013/SDL_mixer-WinRT81.vcxproj @@ -0,0 +1,286 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + + {c8df6173-06a1-4f56-a9bc-2002596b30e9} + + + {6bc6349c-e355-4f1c-9290-ff755114a84b} + + + {936b2819-2364-45d9-901d-52878914fafa} + + + {e3ab27f1-eb89-4c65-85df-cb6a4f805753} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {3a833c7a-c776-4202-9dbd-bc879b23c605} + Win32Proj + SDL2_mixer-WinRT81 + SDL2_mixer_WinRT81 + en-US + 12.0 + true + Windows Store + 8.1 + + + + DynamicLibrary + true + v120 + + + DynamicLibrary + true + v120 + + + DynamicLibrary + true + v120 + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + true + v120 + + + + + + + + + + + + + + + + + + + + + + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + SDL2_mixer + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;NDEBUG;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;NDEBUG;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;%(PreprocessorDefinitions) + + + Console + false + false + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;..\..\external\libvorbis-1.3.5\include;..\..\..\SDL\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;MUSIC_WAV;MUSIC_OGG;OGG_DYNAMIC="libvorbisfile.dll";MUSIC_MID_TIMIDITY;NDEBUG;%(PreprocessorDefinitions) + + + Console + false + false + + + + + + \ No newline at end of file diff --git a/VisualC-WinRT/WinRT81_VS2013/SDL_mixer-WinRT81.vcxproj.filters b/VisualC-WinRT/WinRT81_VS2013/SDL_mixer-WinRT81.vcxproj.filters new file mode 100644 index 0000000..3b9c3e8 --- /dev/null +++ b/VisualC-WinRT/WinRT81_VS2013/SDL_mixer-WinRT81.vcxproj.filters @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + + + + + + + + + + + + + + + + + + + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + Timidity + + + + + {1a42c048-3a89-4691-8289-2eb5b280596f} + + + \ No newline at end of file diff --git a/VisualC-WinRT/WinRT81_VS2013/libogg_dynamic-WinRT81.vcxproj b/VisualC-WinRT/WinRT81_VS2013/libogg_dynamic-WinRT81.vcxproj new file mode 100644 index 0000000..cd228a9 --- /dev/null +++ b/VisualC-WinRT/WinRT81_VS2013/libogg_dynamic-WinRT81.vcxproj @@ -0,0 +1,235 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + {6bc6349c-e355-4f1c-9290-ff755114a84b} + Win32Proj + libogg_dynamic-WinRT81 + libogg_dynamic_WinRT81 + en-US + 12.0 + true + Windows Store + 8.1 + + + + DynamicLibrary + true + v120 + + + DynamicLibrary + true + v120 + + + DynamicLibrary + true + v120 + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + true + v120 + + + + + + + + + + + + + + + + + + + + + + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libogg + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libogg + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libogg + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libogg + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libogg + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libogg + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + 4244 + + + Console + false + false + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + 4244 + + + Console + false + false + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + 4244 + + + Console + false + false + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + 4244 + + + Console + false + false + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + 4244 + + + Console + false + false + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + NotUsing + false + ..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;LIBOGG_EXPORTS;%(PreprocessorDefinitions) + 4244 + + + Console + false + false + ..\..\external\libogg-1.3.2\win32\ogg.def + + + + + + diff --git a/VisualC-WinRT/WinRT81_VS2013/libogg_dynamic-WinRT81.vcxproj.filters b/VisualC-WinRT/WinRT81_VS2013/libogg_dynamic-WinRT81.vcxproj.filters new file mode 100644 index 0000000..edaf205 --- /dev/null +++ b/VisualC-WinRT/WinRT81_VS2013/libogg_dynamic-WinRT81.vcxproj.filters @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisualC-WinRT/WinRT81_VS2013/libvorbis_dynamic-WinRT81.vcxproj b/VisualC-WinRT/WinRT81_VS2013/libvorbis_dynamic-WinRT81.vcxproj new file mode 100644 index 0000000..f6fe398 --- /dev/null +++ b/VisualC-WinRT/WinRT81_VS2013/libvorbis_dynamic-WinRT81.vcxproj @@ -0,0 +1,299 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {6bc6349c-e355-4f1c-9290-ff755114a84b} + + + + {e3ab27f1-eb89-4c65-85df-cb6a4f805753} + Win32Proj + libvorbis_dynamic-WinRT81 + libvorbis_dynamic_WinRT81 + en-US + 12.0 + true + Windows Store + 8.1 + + + + DynamicLibrary + true + v120 + + + DynamicLibrary + true + v120 + + + DynamicLibrary + true + v120 + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + true + v120 + + + + + + + + + + + + + + + + + + + + + + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbis + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbis + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbis + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbis + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbis + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbis + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + 4244;4100;4267;4189;4305;4127;4706 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + 4244;4100;4267;4189;4305;4127;4706 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;_WIN32_WCE;%(PreprocessorDefinitions) + 4244;4100;4267;4189;4305;4127;4706 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;_WIN32_WCE;%(PreprocessorDefinitions) + 4244;4100;4267;4189;4305;4127;4706 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + 4244;4100;4267;4189;4305;4127;4706 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + LIBVORBIS_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + 4244;4100;4267;4189;4305;4127;4706 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbis.def + + + + + + diff --git a/VisualC-WinRT/WinRT81_VS2013/libvorbis_dynamic-WinRT81.vcxproj.filters b/VisualC-WinRT/WinRT81_VS2013/libvorbis_dynamic-WinRT81.vcxproj.filters new file mode 100644 index 0000000..2101a47 --- /dev/null +++ b/VisualC-WinRT/WinRT81_VS2013/libvorbis_dynamic-WinRT81.vcxproj.filters @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/VisualC-WinRT/WinRT81_VS2013/libvorbisfile_dynamic-WinRT81.vcxproj b/VisualC-WinRT/WinRT81_VS2013/libvorbisfile_dynamic-WinRT81.vcxproj new file mode 100644 index 0000000..4286de3 --- /dev/null +++ b/VisualC-WinRT/WinRT81_VS2013/libvorbisfile_dynamic-WinRT81.vcxproj @@ -0,0 +1,238 @@ + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + {6bc6349c-e355-4f1c-9290-ff755114a84b} + + + {e3ab27f1-eb89-4c65-85df-cb6a4f805753} + + + + {936b2819-2364-45d9-901d-52878914fafa} + Win32Proj + libvorbisfile_dynamic-WinRT81 + libvorbisfile_dynamic_WinRT81 + en-US + 12.0 + true + Windows Store + 8.1 + + + + DynamicLibrary + true + v120 + + + DynamicLibrary + true + v120 + + + DynamicLibrary + true + v120 + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + true + v120 + + + DynamicLibrary + false + true + v120 + + + + + + + + + + + + + + + + + + + + + + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbisfile + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbisfile + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbisfile + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbisfile + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbisfile + + + false + false + Objs\$(Platform)\$(Configuration)\$(MSBuildProjectName)\ + libvorbisfile + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;_WINDLL;%(PreprocessorDefinitions) + 4244;4101 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions) + 4244;4101 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;_WIN32_WCE;_WINDLL;%(PreprocessorDefinitions) + 4244;4101 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;_WIN32_WCE;NDEBUG;%(PreprocessorDefinitions) + 4244;4101 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;_WINDLL;%(PreprocessorDefinitions) + 4244;4101 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + NotUsing + false + ..\..\external\libvorbis-1.3.5\include;..\..\external\libogg-1.3.2\include;%(AdditionalIncludeDirectories) + _CRT_SECURE_NO_WARNINGS;NDEBUG;%(PreprocessorDefinitions) + 4244;4101 + + + Console + false + false + ..\..\external\libvorbis-1.3.5\win32\vorbisfile.def + + + + + + diff --git a/VisualC-WinRT/WinRT81_VS2013/libvorbisfile_dynamic-WinRT81.vcxproj.filters b/VisualC-WinRT/WinRT81_VS2013/libvorbisfile_dynamic-WinRT81.vcxproj.filters new file mode 100644 index 0000000..74d0fac --- /dev/null +++ b/VisualC-WinRT/WinRT81_VS2013/libvorbisfile_dynamic-WinRT81.vcxproj.filters @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/acinclude/libtool.m4 b/acinclude/libtool.m4 index b64223e..03771a7 100644 --- a/acinclude/libtool.m4 +++ b/acinclude/libtool.m4 @@ -1302,7 +1302,10 @@ x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; - ppc*-*linux*|powerpc*-*linux*) + powerpc64le-*linux*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc64-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..da031aa --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,9327 @@ +############################################################################## +# Based on libtool-2.2.6a +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +m4_define([_LT_COPYING], [dnl +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, +# 2006, 2007, 2008 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is part of GNU Libtool. +# +# GNU Libtool is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# As a special exception to the GNU General Public License, +# if you distribute this file as part of a program or library that +# is built using GNU Libtool, you may include this file under the +# same distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Libtool; see the file COPYING. If not, a copy +# can be downloaded from http://www.gnu.org/licenses/gpl.html, or +# obtained by writing to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +]) + +# serial 56 LT_INIT + + +# LT_PREREQ(VERSION) +# ------------------ +# Complain and exit if this libtool version is less that VERSION. +m4_defun([LT_PREREQ], +[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, + [m4_default([$3], + [m4_fatal([Libtool version $1 or higher is required], + 63)])], + [$2])]) + + +# _LT_CHECK_BUILDDIR +# ------------------ +# Complain if the absolute build directory name contains unusual characters +m4_defun([_LT_CHECK_BUILDDIR], +[case `pwd` in + *\ * | *\ *) + AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; +esac +]) + + +# LT_INIT([OPTIONS]) +# ------------------ +AC_DEFUN([LT_INIT], +[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT +AC_BEFORE([$0], [LT_LANG])dnl +AC_BEFORE([$0], [LT_OUTPUT])dnl +AC_BEFORE([$0], [LTDL_INIT])dnl +m4_require([_LT_CHECK_BUILDDIR])dnl + +dnl Autoconf doesn't catch unexpanded LT_ macros by default: +m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl +m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl +dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 +dnl unless we require an AC_DEFUNed macro: +AC_REQUIRE([LTOPTIONS_VERSION])dnl +AC_REQUIRE([LTSUGAR_VERSION])dnl +AC_REQUIRE([LTVERSION_VERSION])dnl +AC_REQUIRE([LTOBSOLETE_VERSION])dnl +m4_require([_LT_PROG_LTMAIN])dnl + +dnl Parse OPTIONS +_LT_SET_OPTIONS([$0], [$1]) + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ltmain" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +_LT_SETUP + +# Only expand once: +m4_define([LT_INIT]) +])# LT_INIT + +# Old names: +AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) +AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PROG_LIBTOOL], []) +dnl AC_DEFUN([AM_PROG_LIBTOOL], []) + + +# _LT_CC_BASENAME(CC) +# ------------------- +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +m4_defun([_LT_CC_BASENAME], +[for cc_temp in $1""; do + case $cc_temp in + compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; + distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"` +]) + + +# _LT_FILEUTILS_DEFAULTS +# ---------------------- +# It is okay to use these file commands and assume they have been set +# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. +m4_defun([_LT_FILEUTILS_DEFAULTS], +[: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} +])# _LT_FILEUTILS_DEFAULTS + + +# _LT_SETUP +# --------- +m4_defun([_LT_SETUP], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +_LT_DECL([], [host_alias], [0], [The host system])dnl +_LT_DECL([], [host], [0])dnl +_LT_DECL([], [host_os], [0])dnl +dnl +_LT_DECL([], [build_alias], [0], [The build system])dnl +_LT_DECL([], [build], [0])dnl +_LT_DECL([], [build_os], [0])dnl +dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +test -z "$LN_S" && LN_S="ln -s" +_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl +dnl +AC_REQUIRE([LT_CMD_MAX_LEN])dnl +_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl +_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl +dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_CHECK_SHELL_FEATURES])dnl +m4_require([_LT_CMD_RELOAD])dnl +m4_require([_LT_CHECK_MAGIC_METHOD])dnl +m4_require([_LT_CMD_OLD_ARCHIVE])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl + +_LT_CONFIG_LIBTOOL_INIT([ +# See if we are running on zsh, and set the options which allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi +]) +if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi + +_LT_CHECK_OBJDIR + +m4_require([_LT_TAG_COMPILER])dnl +_LT_PROG_ECHO_BACKSLASH + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([["`\\]]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld="$lt_cv_prog_gnu_ld" + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +_LT_CC_BASENAME([$compiler]) + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + _LT_PATH_MAGIC + fi + ;; +esac + +# Use C for the default configuration in the libtool script +LT_SUPPORTED_TAG([CC]) +_LT_LANG_C_CONFIG +_LT_LANG_DEFAULT_CONFIG +_LT_CONFIG_COMMANDS +])# _LT_SETUP + + +# _LT_PROG_LTMAIN +# --------------- +# Note that this code is called both from `configure', and `config.status' +# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, +# `config.status' has no value for ac_aux_dir unless we are using Automake, +# so we pass a copy along to make sure it has a sensible value anyway. +m4_defun([_LT_PROG_LTMAIN], +[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl +_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) +ltmain="$ac_aux_dir/ltmain.sh" +])# _LT_PROG_LTMAIN + + +## ------------------------------------- ## +## Accumulate code for creating libtool. ## +## ------------------------------------- ## + +# So that we can recreate a full libtool script including additional +# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS +# in macros and then make a single call at the end using the `libtool' +# label. + + +# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) +# ---------------------------------------- +# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL_INIT], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_INIT], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_INIT]) + + +# _LT_CONFIG_LIBTOOL([COMMANDS]) +# ------------------------------ +# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) + + +# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) +# ----------------------------------------------------- +m4_defun([_LT_CONFIG_SAVE_COMMANDS], +[_LT_CONFIG_LIBTOOL([$1]) +_LT_CONFIG_LIBTOOL_INIT([$2]) +]) + + +# _LT_FORMAT_COMMENT([COMMENT]) +# ----------------------------- +# Add leading comment marks to the start of each line, and a trailing +# full-stop to the whole comment if one is not present already. +m4_define([_LT_FORMAT_COMMENT], +[m4_ifval([$1], [ +m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], + [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) +)]) + + + +## ------------------------ ## +## FIXME: Eliminate VARNAME ## +## ------------------------ ## + + +# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) +# ------------------------------------------------------------------- +# CONFIGNAME is the name given to the value in the libtool script. +# VARNAME is the (base) name used in the configure script. +# VALUE may be 0, 1 or 2 for a computed quote escaped value based on +# VARNAME. Any other value will be used directly. +m4_define([_LT_DECL], +[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], + [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], + [m4_ifval([$1], [$1], [$2])]) + lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) + m4_ifval([$4], + [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) + lt_dict_add_subkey([lt_decl_dict], [$2], + [tagged?], [m4_ifval([$5], [yes], [no])])]) +]) + + +# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) +# -------------------------------------------------------- +m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) + + +# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_tag_varnames], +[_lt_decl_filter([tagged?], [yes], $@)]) + + +# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) +# --------------------------------------------------------- +m4_define([_lt_decl_filter], +[m4_case([$#], + [0], [m4_fatal([$0: too few arguments: $#])], + [1], [m4_fatal([$0: too few arguments: $#: $1])], + [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], + [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], + [lt_dict_filter([lt_decl_dict], $@)])[]dnl +]) + + +# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) +# -------------------------------------------------- +m4_define([lt_decl_quote_varnames], +[_lt_decl_filter([value], [1], $@)]) + + +# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_dquote_varnames], +[_lt_decl_filter([value], [2], $@)]) + + +# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_varnames_tagged], +[m4_assert([$# <= 2])dnl +_$0(m4_quote(m4_default([$1], [[, ]])), + m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), + m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) +m4_define([_lt_decl_varnames_tagged], +[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) + + +# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_all_varnames], +[_$0(m4_quote(m4_default([$1], [[, ]])), + m4_if([$2], [], + m4_quote(lt_decl_varnames), + m4_quote(m4_shift($@))))[]dnl +]) +m4_define([_lt_decl_all_varnames], +[lt_join($@, lt_decl_varnames_tagged([$1], + lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl +]) + + +# _LT_CONFIG_STATUS_DECLARE([VARNAME]) +# ------------------------------------ +# Quote a variable value, and forward it to `config.status' so that its +# declaration there will have the same value as in `configure'. VARNAME +# must have a single quote delimited value for this to work. +m4_define([_LT_CONFIG_STATUS_DECLARE], +[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`']) + + +# _LT_CONFIG_STATUS_DECLARATIONS +# ------------------------------ +# We delimit libtool config variables with single quotes, so when +# we write them to config.status, we have to be sure to quote all +# embedded single quotes properly. In configure, this macro expands +# each variable declared with _LT_DECL (and _LT_TAGDECL) into: +# +# ='`$ECHO "X$" | $Xsed -e "$delay_single_quote_subst"`' +m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], +[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), + [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAGS +# ---------------- +# Output comment and list of tags supported by the script +m4_defun([_LT_LIBTOOL_TAGS], +[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl +available_tags="_LT_TAGS"dnl +]) + + +# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) +# ----------------------------------- +# Extract the dictionary values for VARNAME (optionally with TAG) and +# expand to a commented shell variable setting: +# +# # Some comment about what VAR is for. +# visible_name=$lt_internal_name +m4_define([_LT_LIBTOOL_DECLARE], +[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], + [description])))[]dnl +m4_pushdef([_libtool_name], + m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl +m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), + [0], [_libtool_name=[$]$1], + [1], [_libtool_name=$lt_[]$1], + [2], [_libtool_name=$lt_[]$1], + [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl +m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl +]) + + +# _LT_LIBTOOL_CONFIG_VARS +# ----------------------- +# Produce commented declarations of non-tagged libtool config variables +# suitable for insertion in the LIBTOOL CONFIG section of the `libtool' +# script. Tagged libtool config variables (even for the LIBTOOL CONFIG +# section) are produced by _LT_LIBTOOL_TAG_VARS. +m4_defun([_LT_LIBTOOL_CONFIG_VARS], +[m4_foreach([_lt_var], + m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAG_VARS(TAG) +# ------------------------- +m4_define([_LT_LIBTOOL_TAG_VARS], +[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) + + +# _LT_TAGVAR(VARNAME, [TAGNAME]) +# ------------------------------ +m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) + + +# _LT_CONFIG_COMMANDS +# ------------------- +# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of +# variables for single and double quote escaping we saved from calls +# to _LT_DECL, we can put quote escaped variables declarations +# into `config.status', and then the shell code to quote escape them in +# for loops in `config.status'. Finally, any additional code accumulated +# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. +m4_defun([_LT_CONFIG_COMMANDS], +[AC_PROVIDE_IFELSE([LT_OUTPUT], + dnl If the libtool generation code has been placed in $CONFIG_LT, + dnl instead of duplicating it all over again into config.status, + dnl then we will have config.status run $CONFIG_LT later, so it + dnl needs to know what name is stored there: + [AC_CONFIG_COMMANDS([libtool], + [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], + dnl If the libtool generation code is destined for config.status, + dnl expand the accumulated commands and init code now: + [AC_CONFIG_COMMANDS([libtool], + [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) +])#_LT_CONFIG_COMMANDS + + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], +[ + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +_LT_CONFIG_STATUS_DECLARATIONS +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# Quote evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_quote_varnames); do + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_dquote_varnames); do + case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Fix-up fallback echo if it was mangled by the above quoting rules. +case \$lt_ECHO in +*'\\\[$]0 --fallback-echo"')dnl " + lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\` + ;; +esac + +_LT_OUTPUT_LIBTOOL_INIT +]) + + +# LT_OUTPUT +# --------- +# This macro allows early generation of the libtool script (before +# AC_OUTPUT is called), incase it is used in configure for compilation +# tests. +AC_DEFUN([LT_OUTPUT], +[: ${CONFIG_LT=./config.lt} +AC_MSG_NOTICE([creating $CONFIG_LT]) +cat >"$CONFIG_LT" <<_LTEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate a libtool stub with the current configuration. + +lt_cl_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_LTEOF + +cat >>"$CONFIG_LT" <<\_LTEOF +AS_SHELL_SANITIZE +_AS_PREPARE + +exec AS_MESSAGE_FD>&1 +exec AS_MESSAGE_LOG_FD>>config.log +{ + echo + AS_BOX([Running $as_me.]) +} >&AS_MESSAGE_LOG_FD + +lt_cl_help="\ +\`$as_me' creates a local libtool stub from the current configuration, +for use in further configure time tests before the real libtool is +generated. + +Usage: $[0] [[OPTIONS]] + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + +Report bugs to ." + +lt_cl_version="\ +m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl +m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) +configured by $[0], generated by m4_PACKAGE_STRING. + +Copyright (C) 2008 Free Software Foundation, Inc. +This config.lt script is free software; the Free Software Foundation +gives unlimited permision to copy, distribute and modify it." + +while test $[#] != 0 +do + case $[1] in + --version | --v* | -V ) + echo "$lt_cl_version"; exit 0 ;; + --help | --h* | -h ) + echo "$lt_cl_help"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --quiet | --q* | --silent | --s* | -q ) + lt_cl_silent=: ;; + + -*) AC_MSG_ERROR([unrecognized option: $[1] +Try \`$[0] --help' for more information.]) ;; + + *) AC_MSG_ERROR([unrecognized argument: $[1] +Try \`$[0] --help' for more information.]) ;; + esac + shift +done + +if $lt_cl_silent; then + exec AS_MESSAGE_FD>/dev/null +fi +_LTEOF + +cat >>"$CONFIG_LT" <<_LTEOF +_LT_OUTPUT_LIBTOOL_COMMANDS_INIT +_LTEOF + +cat >>"$CONFIG_LT" <<\_LTEOF +AC_MSG_NOTICE([creating $ofile]) +_LT_OUTPUT_LIBTOOL_COMMANDS +AS_EXIT(0) +_LTEOF +chmod +x "$CONFIG_LT" + +# configure is writing to config.log, but config.lt does its own redirection, +# appending to config.log, which fails on DOS, as config.log is still kept +# open by configure. Here we exec the FD to /dev/null, effectively closing +# config.log, so it can be properly (re)opened and appended to by config.lt. +if test "$no_create" != yes; then + lt_cl_success=: + test "$silent" = yes && + lt_config_lt_args="$lt_config_lt_args --quiet" + exec AS_MESSAGE_LOG_FD>/dev/null + $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false + exec AS_MESSAGE_LOG_FD>>config.log + $lt_cl_success || AS_EXIT(1) +fi +])# LT_OUTPUT + + +# _LT_CONFIG(TAG) +# --------------- +# If TAG is the built-in tag, create an initial libtool script with a +# default configuration from the untagged config vars. Otherwise add code +# to config.status for appending the configuration named by TAG from the +# matching tagged config vars. +m4_defun([_LT_CONFIG], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_CONFIG_SAVE_COMMANDS([ + m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl + m4_if(_LT_TAG, [C], [ + # See if we are running on zsh, and set the options which allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + + cfgfile="${ofile}T" + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL + +# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +_LT_COPYING +_LT_LIBTOOL_TAGS + +# ### BEGIN LIBTOOL CONFIG +_LT_LIBTOOL_CONFIG_VARS +_LT_LIBTOOL_TAG_VARS +# ### END LIBTOOL CONFIG + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + _LT_PROG_LTMAIN + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + _LT_PROG_XSI_SHELLFNS + + sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" +], +[cat <<_LT_EOF >> "$ofile" + +dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded +dnl in a comment (ie after a #). +# ### BEGIN LIBTOOL TAG CONFIG: $1 +_LT_LIBTOOL_TAG_VARS(_LT_TAG) +# ### END LIBTOOL TAG CONFIG: $1 +_LT_EOF +])dnl /m4_if +], +[m4_if([$1], [], [ + PACKAGE='$PACKAGE' + VERSION='$VERSION' + TIMESTAMP='$TIMESTAMP' + RM='$RM' + ofile='$ofile'], []) +])dnl /_LT_CONFIG_SAVE_COMMANDS +])# _LT_CONFIG + + +# LT_SUPPORTED_TAG(TAG) +# --------------------- +# Trace this macro to discover what tags are supported by the libtool +# --tag option, using: +# autoconf --trace 'LT_SUPPORTED_TAG:$1' +AC_DEFUN([LT_SUPPORTED_TAG], []) + + +# C support is built-in for now +m4_define([_LT_LANG_C_enabled], []) +m4_define([_LT_TAGS], []) + + +# LT_LANG(LANG) +# ------------- +# Enable libtool support for the given language if not already enabled. +AC_DEFUN([LT_LANG], +[AC_BEFORE([$0], [LT_OUTPUT])dnl +m4_case([$1], + [C], [_LT_LANG(C)], + [C++], [_LT_LANG(CXX)], + [Java], [_LT_LANG(GCJ)], + [Fortran 77], [_LT_LANG(F77)], + [Fortran], [_LT_LANG(FC)], + [Windows Resource], [_LT_LANG(RC)], + [m4_ifdef([_LT_LANG_]$1[_CONFIG], + [_LT_LANG($1)], + [m4_fatal([$0: unsupported language: "$1"])])])dnl +])# LT_LANG + + +# _LT_LANG(LANGNAME) +# ------------------ +m4_defun([_LT_LANG], +[m4_ifdef([_LT_LANG_]$1[_enabled], [], + [LT_SUPPORTED_TAG([$1])dnl + m4_append([_LT_TAGS], [$1 ])dnl + m4_define([_LT_LANG_]$1[_enabled], [])dnl + _LT_LANG_$1_CONFIG($1)])dnl +])# _LT_LANG + + +# _LT_LANG_DEFAULT_CONFIG +# ----------------------- +m4_defun([_LT_LANG_DEFAULT_CONFIG], +[AC_PROVIDE_IFELSE([AC_PROG_CXX], + [LT_LANG(CXX)], + [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) + +AC_PROVIDE_IFELSE([AC_PROG_F77], + [LT_LANG(F77)], + [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) + +AC_PROVIDE_IFELSE([AC_PROG_FC], + [LT_LANG(FC)], + [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) + +dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal +dnl pulling things in needlessly. +AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([LT_PROG_GCJ], + [LT_LANG(GCJ)], + [m4_ifdef([AC_PROG_GCJ], + [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([A][M_PROG_GCJ], + [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([LT_PROG_GCJ], + [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) + +AC_PROVIDE_IFELSE([LT_PROG_RC], + [LT_LANG(RC)], + [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) +])# _LT_LANG_DEFAULT_CONFIG + +# Obsolete macros: +AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) +AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) +AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) +AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_CXX], []) +dnl AC_DEFUN([AC_LIBTOOL_F77], []) +dnl AC_DEFUN([AC_LIBTOOL_FC], []) +dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) + + +# _LT_TAG_COMPILER +# ---------------- +m4_defun([_LT_TAG_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl +_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl +_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl +_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC +])# _LT_TAG_COMPILER + + +# _LT_COMPILER_BOILERPLATE +# ------------------------ +# Check for compiler boilerplate output or warnings with +# the simple compiler test code. +m4_defun([_LT_COMPILER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* +])# _LT_COMPILER_BOILERPLATE + + +# _LT_LINKER_BOILERPLATE +# ---------------------- +# Check for linker boilerplate output or warnings with +# the simple link test code. +m4_defun([_LT_LINKER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* +])# _LT_LINKER_BOILERPLATE + +# _LT_REQUIRED_DARWIN_CHECKS +# ------------------------- +m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ + case $host_os in + rhapsody* | darwin*) + AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) + AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) + AC_CHECK_TOOL([LIPO], [lipo], [:]) + AC_CHECK_TOOL([OTOOL], [otool], [:]) + AC_CHECK_TOOL([OTOOL64], [otool64], [:]) + _LT_DECL([], [DSYMUTIL], [1], + [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) + _LT_DECL([], [NMEDIT], [1], + [Tool to change global to local symbols on Mac OS X]) + _LT_DECL([], [LIPO], [1], + [Tool to manipulate fat objects and archives on Mac OS X]) + _LT_DECL([], [OTOOL], [1], + [ldd/readelf like tool for Mach-O binaries on Mac OS X]) + _LT_DECL([], [OTOOL64], [1], + [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) + + AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], + [lt_cv_apple_cc_single_mod=no + if test -z "${LT_MULTI_MODULE}"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&AS_MESSAGE_LOG_FD + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi]) + AC_CACHE_CHECK([for -exported_symbols_list linker flag], + [lt_cv_ld_exported_symbols_list], + [lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [lt_cv_ld_exported_symbols_list=yes], + [lt_cv_ld_exported_symbols_list=no]) + LDFLAGS="$save_LDFLAGS" + ]) + case $host_os in + rhapsody* | darwin1.[[012]]) + _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + 10.[[012]]*) + _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test "$lt_cv_apple_cc_single_mod" = "yes"; then + _lt_dar_single_mod='$single_module' + fi + if test "$lt_cv_ld_exported_symbols_list" = "yes"; then + _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + if test "$DSYMUTIL" != ":"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac +]) + + +# _LT_DARWIN_LINKER_FEATURES +# -------------------------- +# Checks for linker and compiler features on darwin +m4_defun([_LT_DARWIN_LINKER_FEATURES], +[ + m4_require([_LT_REQUIRED_DARWIN_CHECKS]) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_automatic, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_TAGVAR(whole_archive_flag_spec, $1)='' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" + case $cc_basename in + ifort*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test "$_lt_dar_can_shared" = "yes"; then + output_verbose_link_cmd=echo + _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" + _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" + _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" + m4_if([$1], [CXX], +[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then + _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" + fi +],[]) + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi +]) + +# _LT_SYS_MODULE_PATH_AIX +# ----------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +m4_defun([_LT_SYS_MODULE_PATH_AIX], +[m4_require([_LT_DECL_SED])dnl +AC_LINK_IFELSE(AC_LANG_PROGRAM,[ +lt_aix_libpath_sed=' + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\(.*\)$/\1/ + p + } + }' +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` +fi],[]) +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +])# _LT_SYS_MODULE_PATH_AIX + + +# _LT_SHELL_INIT(ARG) +# ------------------- +m4_define([_LT_SHELL_INIT], +[ifdef([AC_DIVERSION_NOTICE], + [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], + [AC_DIVERT_PUSH(NOTICE)]) +$1 +AC_DIVERT_POP +])# _LT_SHELL_INIT + + +# _LT_PROG_ECHO_BACKSLASH +# ----------------------- +# Add some code to the start of the generated configure script which +# will find an echo command which doesn't interpret backslashes. +m4_defun([_LT_PROG_ECHO_BACKSLASH], +[_LT_SHELL_INIT([ +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$lt_ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` + ;; +esac + +ECHO=${lt_ECHO-echo} +if test "X[$]1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X[$]1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then + # Yippee, $ECHO works! + : +else + # Restart under the correct shell. + exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} +fi + +if test "X[$]1" = X--fallback-echo; then + # used as fallback echo + shift + cat <<_LT_EOF +[$]* +_LT_EOF + exit 0 +fi + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test -z "$lt_ECHO"; then + if test "X${echo_test_string+set}" != Xset; then + # find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if { echo_test_string=`eval $cmd`; } 2>/dev/null && + { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null + then + break + fi + done + fi + + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : + else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$ECHO" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + ECHO='print -r' + elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} + else + # Try using printf. + ECHO='printf %s\n' + if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' && + echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + ECHO="$CONFIG_SHELL [$]0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + ECHO="$CONFIG_SHELL [$]0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do + if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "[$]0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} + else + # Oops. We lost completely, so just stick with echo. + ECHO=echo + fi + fi + fi + fi + fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +lt_ECHO=$ECHO +if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then + lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" +fi + +AC_SUBST(lt_ECHO) +]) +_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) +_LT_DECL([], [ECHO], [1], + [An echo program that does not interpret backslashes]) +])# _LT_PROG_ECHO_BACKSLASH + + +# _LT_ENABLE_LOCK +# --------------- +m4_defun([_LT_ENABLE_LOCK], +[AC_ARG_ENABLE([libtool-lock], + [AS_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + powerpc64le-*linux*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc64-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_PUSH(C) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_POP]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +sparc*-*solaris*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) LD="${LD-ld} -m elf64_sparc" ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; +esac + +need_locks="$enable_libtool_lock" +])# _LT_ENABLE_LOCK + + +# _LT_CMD_OLD_ARCHIVE +# ------------------- +m4_defun([_LT_CMD_OLD_ARCHIVE], +[AC_CHECK_TOOL(AR, ar, false) +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +_LT_DECL([], [AR], [1], [The archiver]) +_LT_DECL([], [AR_FLAGS], [1]) + +AC_CHECK_TOOL(STRIP, strip, :) +test -z "$STRIP" && STRIP=: +_LT_DECL([], [STRIP], [1], [A symbol stripping program]) + +AC_CHECK_TOOL(RANLIB, ranlib, :) +test -z "$RANLIB" && RANLIB=: +_LT_DECL([], [RANLIB], [1], + [Commands used to install an old-style archive]) + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi +_LT_DECL([], [old_postinstall_cmds], [2]) +_LT_DECL([], [old_postuninstall_cmds], [2]) +_LT_TAGDECL([], [old_archive_cmds], [2], + [Commands used to build an old-style archive]) +])# _LT_CMD_OLD_ARCHIVE + + +# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------------------- +# Check whether the given compiler option works +AC_DEFUN([_LT_COMPILER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$3" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + fi + $RM conftest* +]) + +if test x"[$]$2" = xyes; then + m4_if([$5], , :, [$5]) +else + m4_if([$6], , :, [$6]) +fi +])# _LT_COMPILER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) + + +# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------- +# Check whether the given linker option works +AC_DEFUN([_LT_LINKER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $3" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&AS_MESSAGE_LOG_FD + $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + else + $2=yes + fi + fi + $RM -r conftest* + LDFLAGS="$save_LDFLAGS" +]) + +if test x"[$]$2" = xyes; then + m4_if([$4], , :, [$4]) +else + m4_if([$5], , :, [$5]) +fi +])# _LT_LINKER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) + + +# LT_CMD_MAX_LEN +#--------------- +AC_DEFUN([LT_CMD_MAX_LEN], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +# find the maximum length of command line arguments +AC_MSG_CHECKING([the maximum length of command line arguments]) +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + beos*) + # On BeOS, this test takes a really really long time. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8 ; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \ + = "XX$teststring$teststring"; } >/dev/null 2>&1 && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac +]) +if test -n $lt_cv_sys_max_cmd_len ; then + AC_MSG_RESULT($lt_cv_sys_max_cmd_len) +else + AC_MSG_RESULT(none) +fi +max_cmd_len=$lt_cv_sys_max_cmd_len +_LT_DECL([], [max_cmd_len], [0], + [What is the maximum length of a command?]) +])# LT_CMD_MAX_LEN + +# Old name: +AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) + + +# _LT_HEADER_DLFCN +# ---------------- +m4_defun([_LT_HEADER_DLFCN], +[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl +])# _LT_HEADER_DLFCN + + +# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# ---------------------------------------------------------------- +m4_defun([_LT_TRY_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test "$cross_compiling" = yes; then : + [$4] +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +[#line __oline__ "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +}] +_LT_EOF + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_dlunknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_TRY_DLOPEN_SELF + + +# LT_SYS_DLOPEN_SELF +# ------------------ +AC_DEFUN([LT_SYS_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32* | cegcc*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ]) + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen="shl_load"], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen="dlopen"], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test "x$lt_cv_dlopen_self" = xyes; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +_LT_DECL([dlopen_support], [enable_dlopen], [0], + [Whether dlopen is supported]) +_LT_DECL([dlopen_self], [enable_dlopen_self], [0], + [Whether dlopen of programs is supported]) +_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], + [Whether dlopen of statically linked programs is supported]) +])# LT_SYS_DLOPEN_SELF + +# Old name: +AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) + + +# _LT_COMPILER_C_O([TAGNAME]) +# --------------------------- +# Check to see if options -c and -o are simultaneously supported by compiler. +# This macro does not hard code the compiler like AC_PROG_CC_C_O. +m4_defun([_LT_COMPILER_C_O], +[m4_require([_LT_DECL_SED])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + fi + fi + chmod u+w . 2>&AS_MESSAGE_LOG_FD + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* +]) +_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], + [Does compiler simultaneously support -c and -o options?]) +])# _LT_COMPILER_C_O + + +# _LT_COMPILER_FILE_LOCKS([TAGNAME]) +# ---------------------------------- +# Check to see if we can do hard links to lock some files if needed +m4_defun([_LT_COMPILER_FILE_LOCKS], +[m4_require([_LT_ENABLE_LOCK])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_COMPILER_C_O([$1]) + +hard_links="nottested" +if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test "$hard_links" = no; then + AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) +])# _LT_COMPILER_FILE_LOCKS + + +# _LT_CHECK_OBJDIR +# ---------------- +m4_defun([_LT_CHECK_OBJDIR], +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], +[rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null]) +objdir=$lt_cv_objdir +_LT_DECL([], [objdir], [0], + [The name of the directory that contains temporary libtool files])dnl +m4_pattern_allow([LT_OBJDIR])dnl +AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", + [Define to the sub-directory in which libtool stores uninstalled libraries.]) +])# _LT_CHECK_OBJDIR + + +# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) +# -------------------------------------- +# Check hardcoding attributes. +m4_defun([_LT_LINKER_HARDCODE_LIBPATH], +[AC_MSG_CHECKING([how to hardcode library paths into programs]) +_LT_TAGVAR(hardcode_action, $1)= +if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || + test -n "$_LT_TAGVAR(runpath_var, $1)" || + test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then + + # We can hardcode non-existent directories. + if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && + test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then + # Linking always hardcodes the temporary library directory. + _LT_TAGVAR(hardcode_action, $1)=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + _LT_TAGVAR(hardcode_action, $1)=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + _LT_TAGVAR(hardcode_action, $1)=unsupported +fi +AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) + +if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || + test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi +_LT_TAGDECL([], [hardcode_action], [0], + [How to hardcode a shared library path into an executable]) +])# _LT_LINKER_HARDCODE_LIBPATH + + +# _LT_CMD_STRIPLIB +# ---------------- +m4_defun([_LT_CMD_STRIPLIB], +[m4_require([_LT_DECL_EGREP]) +striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac +fi +_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) +_LT_DECL([], [striplib], [1]) +])# _LT_CMD_STRIPLIB + + +# _LT_SYS_DYNAMIC_LINKER([TAG]) +# ----------------------------- +# PORTME Fill in your ld.so characteristics +m4_defun([_LT_SYS_DYNAMIC_LINKER], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_OBJDUMP])dnl +m4_require([_LT_DECL_SED])dnl +AC_MSG_CHECKING([dynamic linker characteristics]) +m4_if([$1], + [], [ +if test "$GCC" = yes; then + case $host_os in + darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; + *) lt_awk_arg="/^libraries:/" ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'` + else + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary. + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path/$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" + else + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk ' +BEGIN {RS=" "; FS="/|\n";} { + lt_foo=""; + lt_count=0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo="/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[[lt_foo]]++; } + if (lt_freq[[lt_foo]] == 1) { print lt_foo; } +}'` + sys_lib_search_path_spec=`$ECHO $lt_search_path_spec` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix[[4-9]]*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[[45]]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + #soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + soname_spec='`echo ${libname} | sed -e 's/^lib//'`${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + #soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + soname_spec='`echo ${libname} | $SED -e 's/^lib//'`${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' +m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[[123]]*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[[01]]* | freebsdelf3.[[01]]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ + freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +interix[[3-9]]*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # Some binutils ld are patched to set DT_RUNPATH + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ + LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], + [shlibpath_overrides_runpath=yes])]) + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd*) + version_type=sunos + sys_lib_dlsearch_path_spec="/usr/lib" + need_lib_prefix=no + # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. + case $host_os in + openbsd3.3 | openbsd3.3.*) need_version=yes ;; + *) need_version=no ;; + esac + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[[89]] | openbsd2.[[89]].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=freebsd-elf + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test "$with_gnu_ld" = yes; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test "$dynamic_linker" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then + sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" +fi +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then + sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" +fi + +_LT_DECL([], [variables_saved_for_relink], [1], + [Variables whose values should be saved in libtool wrapper scripts and + restored at link time]) +_LT_DECL([], [need_lib_prefix], [0], + [Do we need the "lib" prefix for modules?]) +_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) +_LT_DECL([], [version_type], [0], [Library versioning type]) +_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) +_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) +_LT_DECL([], [shlibpath_overrides_runpath], [0], + [Is shlibpath searched before the hard-coded library search path?]) +_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) +_LT_DECL([], [library_names_spec], [1], + [[List of archive names. First name is the real one, the rest are links. + The last name is the one that the linker finds with -lNAME]]) +_LT_DECL([], [soname_spec], [1], + [[The coded name of the library, if different from the real name]]) +_LT_DECL([], [postinstall_cmds], [2], + [Command to use after installation of a shared archive]) +_LT_DECL([], [postuninstall_cmds], [2], + [Command to use after uninstallation of a shared archive]) +_LT_DECL([], [finish_cmds], [2], + [Commands used to finish a libtool library installation in a directory]) +_LT_DECL([], [finish_eval], [1], + [[As "finish_cmds", except a single script fragment to be evaled but + not shown]]) +_LT_DECL([], [hardcode_into_libs], [0], + [Whether we should hardcode library paths into libraries]) +_LT_DECL([], [sys_lib_search_path_spec], [2], + [Compile-time system search path for libraries]) +_LT_DECL([], [sys_lib_dlsearch_path_spec], [2], + [Run-time system search path for libraries]) +])# _LT_SYS_DYNAMIC_LINKER + + +# _LT_PATH_TOOL_PREFIX(TOOL) +# -------------------------- +# find a file program which can recognize shared library +AC_DEFUN([_LT_PATH_TOOL_PREFIX], +[m4_require([_LT_DECL_EGREP])dnl +AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in +[[\\/*] | ?:[\\/]*]) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="m4_if([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$1; then + lt_cv_path_MAGIC_CMD="$ac_dir/$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac]) +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +_LT_DECL([], [MAGIC_CMD], [0], + [Used to examine libraries when file_magic_cmd begins with "file"])dnl +])# _LT_PATH_TOOL_PREFIX + +# Old name: +AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) + + +# _LT_PATH_MAGIC +# -------------- +# find a file program which can recognize a shared library +m4_defun([_LT_PATH_MAGIC], +[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) + else + MAGIC_CMD=: + fi +fi +])# _LT_PATH_MAGIC + + +# LT_PATH_LD +# ---------- +# find the pathname to the GNU or non-GNU linker +AC_DEFUN([LT_PATH_LD], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl + +AC_ARG_WITH([gnu-ld], + [AS_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld @<:@default=no@:>@])], + [test "$withval" = no || with_gnu_ld=yes], + [with_gnu_ld=no])dnl + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + lt_cv_deplibs_check_method=pass_all + ;; + +cegcc) + # use the weaker test based on 'objdump'. See mingw*. + lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[[3-9]]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux* | k*bsd*-gnu) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +esac +]) +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + +_LT_DECL([], [deplibs_check_method], [1], + [Method to check whether dependent libraries are shared objects]) +_LT_DECL([], [file_magic_cmd], [1], + [Command to use when deplibs_check_method == "file_magic"]) +])# _LT_CHECK_MAGIC_METHOD + + +# LT_PATH_NM +# ---------- +# find the pathname to a BSD- or MS-compatible name lister +AC_DEFUN([LT_PATH_NM], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_nm_to_check="${ac_tool_prefix}nm" + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/$lt_tmp_nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS="$lt_save_ifs" + done + : ${lt_cv_path_NM=no} +fi]) +if test "$lt_cv_path_NM" != "no"; then + NM="$lt_cv_path_NM" +else + # Didn't find any BSD compatible name lister, look for dumpbin. + AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :) + AC_SUBST([DUMPBIN]) + if test "$DUMPBIN" != ":"; then + NM="$DUMPBIN" + fi +fi +test -z "$NM" && NM=nm +AC_SUBST([NM]) +_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl + +AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], + [lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD) + cat conftest.out >&AS_MESSAGE_LOG_FD + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest*]) +])# LT_PATH_NM + +# Old names: +AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) +AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_PROG_NM], []) +dnl AC_DEFUN([AC_PROG_NM], []) + + +# LT_LIB_M +# -------- +# check for math library +AC_DEFUN([LT_LIB_M], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, cos, LIBM="-lm") + ;; +esac +AC_SUBST([LIBM]) +])# LT_LIB_M + +# Old name: +AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_CHECK_LIBM], []) + + +# _LT_COMPILER_NO_RTTI([TAGNAME]) +# ------------------------------- +m4_defun([_LT_COMPILER_NO_RTTI], +[m4_require([_LT_TAG_COMPILER])dnl + +_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + +if test "$GCC" = yes; then + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + + _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], + lt_cv_prog_compiler_rtti_exceptions, + [-fno-rtti -fno-exceptions], [], + [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) +fi +_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], + [Compiler flag to turn off builtin functions]) +])# _LT_COMPILER_NO_RTTI + + +# _LT_CMD_GLOBAL_SYMBOLS +# ---------------------- +m4_defun([_LT_CMD_GLOBAL_SYMBOLS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_PATH_NM])dnl +AC_REQUIRE([LT_PATH_LD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_TAG_COMPILER])dnl + +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output from $compiler object]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], +[ +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[[BCDEGRST]]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[[BCDT]]' + ;; +cygwin* | mingw* | pw32* | cegcc*) + symcode='[[ABCDGISTW]]' + ;; +hpux*) + if test "$host_cpu" = ia64; then + symcode='[[ABCDEGRST]]' + fi + ;; +irix* | nonstopux*) + symcode='[[BCDEGRST]]' + ;; +osf*) + symcode='[[BCDEGQRST]]' + ;; +solaris*) + symcode='[[BDRT]]' + ;; +sco3.2v5*) + symcode='[[DT]]' + ;; +sysv4.2uw2*) + symcode='[[DT]]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[[ABDT]]' + ;; +sysv4) + symcode='[[DFNSTU]]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[[ABCDGIRSTW]]' ;; +esac + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function + # and D for any global variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK ['"\ +" {last_section=section; section=\$ 3};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ +" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ +" s[1]~/^[@?]/{print s[1], s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx]" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_LT_EOF + + if AC_TRY_EVAL(ac_compile); then + # Now try to grab the symbols. + nlist=conftest.nm + if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[[]] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi + +_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], + [Take the output of nm and produce a listing of raw symbols and C names]) +_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], + [Transform the output of nm in a proper C declaration]) +_LT_DECL([global_symbol_to_c_name_address], + [lt_cv_sys_global_symbol_to_c_name_address], [1], + [Transform the output of nm in a C name address pair]) +_LT_DECL([global_symbol_to_c_name_address_lib_prefix], + [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], + [Transform the output of nm in a C name address pair when lib prefix is needed]) +]) # _LT_CMD_GLOBAL_SYMBOLS + + +# _LT_COMPILER_PIC([TAGNAME]) +# --------------------------- +m4_defun([_LT_COMPILER_PIC], +[m4_require([_LT_TAG_COMPILER])dnl +_LT_TAGVAR(lt_prog_compiler_wl, $1)= +_LT_TAGVAR(lt_prog_compiler_pic, $1)= +_LT_TAGVAR(lt_prog_compiler_static, $1)= + +AC_MSG_CHECKING([for $compiler option to produce PIC]) +m4_if([$1], [CXX], [ + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + case $host_os in + aix[[4-9]]*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + dgux*) + case $cc_basename in + ec++*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + if test "$host_cpu" != ia64; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + fi + ;; + aCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # KAI C++ Compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + ecpc* ) + # old Intel C++ for x86_64 which still supported -KPIC. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + icpc* ) + # Intel C++, used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xlc* | xlC*) + # IBM XL 8.0 on PPC + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + esac + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd*) + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + cxx*) + # Digital/Compaq C++ + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + lcc*) + # Lucid + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + *) + ;; + esac + ;; + vxworks*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +], +[ + if test "$GCC" = yes; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + + hpux9* | hpux10* | hpux11*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC (with -KPIC) is the default. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + linux* | k*bsd*-gnu) + case $cc_basename in + # old Intel for x86_64 which still supported -KPIC. + ecc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' + _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' + ;; + pgcc* | pgf77* | pgf90* | pgf95*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + ccc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All Alpha code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xl*) + # IBM XL C 8.0/Fortran 10.1 on PPC + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + *Sun\ F*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='' + ;; + esac + ;; + esac + ;; + + newsos6) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All OSF/1 code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + rdos*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + solaris*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + case $cc_basename in + f77* | f90* | f95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; + *) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; + esac + ;; + + sunos4*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + unicos*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + + uts4*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +]) +case $host_os in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" + ;; +esac +AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) +_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], + [How to pass a linker flag through the compiler]) + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], + [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], + [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], + [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in + "" | " "*) ;; + *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; + esac], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) +fi +_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], + [Additional compiler flags for building library objects]) + +# +# Check to make sure the static flag actually works. +# +wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" +_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], + _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), + $lt_tmp_static_flag, + [], + [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) +_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], + [Compiler flag to prevent dynamic linking]) +])# _LT_COMPILER_PIC + + +# _LT_LINKER_SHLIBS([TAGNAME]) +# ---------------------------- +# See if the linker supports building shared libraries. +m4_defun([_LT_LINKER_SHLIBS], +[AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +m4_if([$1], [CXX], [ + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + case $host_os in + aix[[4-9]]*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" + ;; + cygwin* | mingw* | cegcc*) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] +], [ + runpath_var= + _LT_TAGVAR(allow_undefined_flag, $1)= + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(archive_cmds, $1)= + _LT_TAGVAR(archive_expsym_cmds, $1)= + _LT_TAGVAR(compiler_needs_object, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(hardcode_automatic, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= + _LT_TAGVAR(hardcode_libdir_separator, $1)= + _LT_TAGVAR(hardcode_minus_L, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_TAGVAR(inherit_rpath, $1)=no + _LT_TAGVAR(link_all_deplibs, $1)=unknown + _LT_TAGVAR(module_cmds, $1)= + _LT_TAGVAR(module_expsym_cmds, $1)= + _LT_TAGVAR(old_archive_from_new_cmds, $1)= + _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= + _LT_TAGVAR(thread_safe_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + _LT_TAGVAR(include_expsyms, $1)= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. +dnl Note also adjust exclude_expsyms for C++ above. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + _LT_TAGVAR(ld_shlibs, $1)=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + supports_anon_versioning=no + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[[3-9]]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu) + tmp_diet=no + if test "$host_os" = linux-dietlibc; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test "$tmp_diet" = no + then + tmp_addflag= + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + lf95*) # Lahey Fortran 8.1 + _LT_TAGVAR(whole_archive_flag_spec, $1)= + tmp_sharedflag='--shared' ;; + xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + xlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' + _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + sunos4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + + if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then + runpath_var= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + _LT_TAGVAR(hardcode_direct, $1)=unsupported + fi + ;; + + aix[[4-9]]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' + + if test "$GCC" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + ;; + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + bsdi[[45]]*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' + _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + freebsd1*) + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + hpux9*) + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + + hpux10*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + fi + ;; + + hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" + AC_LINK_IFELSE(int foo(void) {}, + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' + ) + LDFLAGS="$save_LDFLAGS" + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + newsos6) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *nto* | *qnx*) + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + else + case $host_os in + openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + ;; + esac + fi + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + solaris*) + _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' + if test "$GCC" = yes; then + wlarc='${wl}' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='${wl}' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. GCC discards it without `$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test "$GCC" = yes; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + fi + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4) + case $host_vendor in + sni) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' + _LT_TAGVAR(hardcode_direct, $1)=no + ;; + motorola) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4.3*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + _LT_TAGVAR(ld_shlibs, $1)=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + if test "$GCC" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + if test x$host_vendor = xsni; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' + ;; + esac + fi + fi +]) +AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) +test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld + +_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl +_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl +_LT_DECL([], [extract_expsyms_cmds], [2], + [The commands to extract the exported symbol list from a shared archive]) + +# +# Do we need to explicitly link libc? +# +case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in +x|xyes) + # Assume -lc should be added + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $_LT_TAGVAR(archive_cmds, $1) in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_MSG_CHECKING([whether -lc should be explicitly linked in]) + $RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) + pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) + _LT_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) + then + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + else + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)]) + ;; + esac + fi + ;; +esac + +_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], + [Whether or not to add -lc for building shared libraries]) +_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], + [enable_shared_with_static_runtimes], [0], + [Whether or not to disallow shared libs when runtime libs are static]) +_LT_TAGDECL([], [export_dynamic_flag_spec], [1], + [Compiler flag to allow reflexive dlopens]) +_LT_TAGDECL([], [whole_archive_flag_spec], [1], + [Compiler flag to generate shared objects directly from archives]) +_LT_TAGDECL([], [compiler_needs_object], [1], + [Whether the compiler copes with passing no objects directly]) +_LT_TAGDECL([], [old_archive_from_new_cmds], [2], + [Create an old-style archive from a shared archive]) +_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], + [Create a temporary old-style archive to link instead of a shared archive]) +_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) +_LT_TAGDECL([], [archive_expsym_cmds], [2]) +_LT_TAGDECL([], [module_cmds], [2], + [Commands used to build a loadable module if different from building + a shared archive.]) +_LT_TAGDECL([], [module_expsym_cmds], [2]) +_LT_TAGDECL([], [with_gnu_ld], [1], + [Whether we are building with GNU ld or not]) +_LT_TAGDECL([], [allow_undefined_flag], [1], + [Flag that allows shared libraries with undefined symbols to be built]) +_LT_TAGDECL([], [no_undefined_flag], [1], + [Flag that enforces no undefined symbols]) +_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], + [Flag to hardcode $libdir into a binary during linking. + This must work even if $libdir does not exist]) +_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], + [[If ld is used when linking, flag to hardcode $libdir into a binary + during linking. This must work even if $libdir does not exist]]) +_LT_TAGDECL([], [hardcode_libdir_separator], [1], + [Whether we need a single "-rpath" flag with a separated argument]) +_LT_TAGDECL([], [hardcode_direct], [0], + [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes + DIR into the resulting binary]) +_LT_TAGDECL([], [hardcode_direct_absolute], [0], + [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes + DIR into the resulting binary and the resulting library dependency is + "absolute", i.e impossible to change by setting ${shlibpath_var} if the + library is relocated]) +_LT_TAGDECL([], [hardcode_minus_L], [0], + [Set to "yes" if using the -LDIR flag during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_shlibpath_var], [0], + [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_automatic], [0], + [Set to "yes" if building a shared library automatically hardcodes DIR + into the library and all subsequent libraries and executables linked + against it]) +_LT_TAGDECL([], [inherit_rpath], [0], + [Set to yes if linker adds runtime paths of dependent libraries + to runtime path list]) +_LT_TAGDECL([], [link_all_deplibs], [0], + [Whether libtool must link a program against all its dependency libraries]) +_LT_TAGDECL([], [fix_srcfile_path], [1], + [Fix the shell variable $srcfile for the compiler]) +_LT_TAGDECL([], [always_export_symbols], [0], + [Set to "yes" if exported symbols are required]) +_LT_TAGDECL([], [export_symbols_cmds], [2], + [The commands to list exported symbols]) +_LT_TAGDECL([], [exclude_expsyms], [1], + [Symbols that should not be listed in the preloaded symbols]) +_LT_TAGDECL([], [include_expsyms], [1], + [Symbols that must always be exported]) +_LT_TAGDECL([], [prelink_cmds], [2], + [Commands necessary for linking programs (against libraries) with templates]) +_LT_TAGDECL([], [file_list_spec], [1], + [Specify filename containing input files]) +dnl FIXME: Not yet implemented +dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], +dnl [Compiler flag to generate thread safe objects]) +])# _LT_LINKER_SHLIBS + + +# _LT_LANG_C_CONFIG([TAG]) +# ------------------------ +# Ensure that the configuration variables for a C compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to `libtool'. +m4_defun([_LT_LANG_C_CONFIG], +[m4_require([_LT_DECL_EGREP])dnl +lt_save_CC="$CC" +AC_LANG_PUSH(C) + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + +_LT_TAG_COMPILER +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + LT_SYS_DLOPEN_SELF + _LT_CMD_STRIPLIB + + # Report which library types will actually be built + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_CONFIG($1) +fi +AC_LANG_POP +CC="$lt_save_CC" +])# _LT_LANG_C_CONFIG + + +# _LT_PROG_CXX +# ------------ +# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++ +# compiler, we have our own version here. +m4_defun([_LT_PROG_CXX], +[ +pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes]) +AC_PROG_CXX +if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + AC_PROG_CXXCPP +else + _lt_caught_CXX_error=yes +fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_CXX + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_CXX], []) + + +# _LT_LANG_CXX_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a C++ compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to `libtool'. +m4_defun([_LT_LANG_CXX_CONFIG], +[AC_REQUIRE([_LT_PROG_CXX])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl + +AC_LANG_PUSH(C++) +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(compiler_needs_object, $1)=no +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the CXX compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_caught_CXX_error" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="int some_variable = 0;" + + # Code to be used in simple link tests + lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_LD=$LD + lt_save_GCC=$GCC + GCC=$GXX + lt_save_with_gnu_ld=$with_gnu_ld + lt_save_path_LD=$lt_cv_path_LD + if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx + else + $as_unset lt_cv_prog_gnu_ld + fi + if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX + else + $as_unset lt_cv_path_LD + fi + test -z "${LDCXX+set}" || LD=$LDCXX + CC=${CXX-"c++"} + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + # We don't want -fno-exception when compiling C++ code, so set the + # no_builtin_flag separately + if test "$GXX" = yes; then + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + else + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + fi + + if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + LT_PATH_LD + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | + $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + + else + GXX=no + with_gnu_ld=no + wlarc= + fi + + # PORTME: fill in a description of your system's C++ link characteristics + AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) + _LT_TAGVAR(ld_shlibs, $1)=yes + case $host_os in + aix3*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aix[[4-9]]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' + + if test "$GXX" = yes; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + esac + shared_flag='-shared' + if test "$aix_use_runtimelinking" = yes; then + shared_flag="$shared_flag "'${wl}-G' + fi + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to + # export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty + # executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds its shared + # libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + freebsd[[12]]*) + # C++ shared libraries reported to be fairly broken before + # switch to ELF + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + freebsd-elf*) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + + freebsd* | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + gnu*) + ;; + + hpux9*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib' + fi + fi + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + esac + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + ;; + + linux* | k*bsd*-gnu) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc* | ecpc* ) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + case `$CC -V` in + *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*) + _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ + compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"' + _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ + $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~ + $RANLIB $oldlib' + _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + ;; + *) # Version 6 will use weak symbols + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + ;; + cxx*) + # Compaq C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + xl*) + # IBM XL 8.0 on PPC, with GNU ld + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + if test "x$supports_anon_versioning" = xyes; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + fi + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + + # Not sure whether something based on + # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 + # would be better. + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + esac + ;; + esac + ;; + + lynxos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + m88k*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + + *nto* | *qnx*) + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + openbsd2*) + # C++ shared libraries are fairly broken + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + openbsd*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + fi + output_verbose_link_cmd=echo + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + case $host in + osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; + *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; + esac + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + cxx*) + case $host in + osf3*) + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + ;; + *) + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~ + $RM $lib.exp' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + case $host in + osf3*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + psos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + solaris*) + case $cc_basename in + CC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(archive_cmds_need_lc,$1)=yes + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands `-z linker_flag'. + # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + + output_verbose_link_cmd='echo' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' + if $CC --version | $GREP -v '^2\.7' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"' + fi + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + ;; + esac + fi + ;; + esac + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We can NOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + vxworks*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) + test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + + _LT_TAGVAR(GCC, $1)="$GXX" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + CC=$lt_save_CC + LDCXX=$LD + LD=$lt_save_LD + GCC=$lt_save_GCC + with_gnu_ld=$lt_save_with_gnu_ld + lt_cv_path_LDCXX=$lt_cv_path_LD + lt_cv_path_LD=$lt_save_path_LD + lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld + lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +fi # test "$_lt_caught_CXX_error" != yes + +AC_LANG_POP +])# _LT_LANG_CXX_CONFIG + + +# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) +# --------------------------------- +# Figure out "hidden" library dependencies from verbose +# compiler output when linking a shared library. +# Parse the compiler output and extract the necessary +# objects, libraries and library flags. +m4_defun([_LT_SYS_HIDDEN_LIBDEPS], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +# Dependencies to place before and after the object being linked: +_LT_TAGVAR(predep_objects, $1)= +_LT_TAGVAR(postdep_objects, $1)= +_LT_TAGVAR(predeps, $1)= +_LT_TAGVAR(postdeps, $1)= +_LT_TAGVAR(compiler_lib_search_path, $1)= + +dnl we can't use the lt_simple_compile_test_code here, +dnl because it contains code intended for an executable, +dnl not a library. It's possible we should let each +dnl tag define a new lt_????_link_test_code variable, +dnl but it's only used here... +m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF +int a; +void foo (void) { a = 0; } +_LT_EOF +], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF +class Foo +{ +public: + Foo (void) { a = 0; } +private: + int a; +}; +_LT_EOF +], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer*4 a + a=0 + return + end +_LT_EOF +], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer a + a=0 + return + end +_LT_EOF +], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF +public class foo { + private int a; + public void bar (void) { + a = 0; + } +}; +_LT_EOF +]) +dnl Parse the compiler output and extract the necessary +dnl objects, libraries and library flags. +if AC_TRY_EVAL(ac_compile); then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + for p in `eval "$output_verbose_link_cmd"`; do + case $p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test $p = "-L" || + test $p = "-R"; then + prev=$p + continue + else + prev= + fi + + if test "$pre_test_object_deps_done" = no; then + case $p in + -L* | -R*) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then + _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" + else + _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$_LT_TAGVAR(postdeps, $1)"; then + _LT_TAGVAR(postdeps, $1)="${prev}${p}" + else + _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" + fi + fi + ;; + + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test "$pre_test_object_deps_done" = no; then + if test -z "$_LT_TAGVAR(predep_objects, $1)"; then + _LT_TAGVAR(predep_objects, $1)="$p" + else + _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" + fi + else + if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then + _LT_TAGVAR(postdep_objects, $1)="$p" + else + _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling $1 test program" +fi + +$RM -f confest.$objext + +# PORTME: override above test on systems where it is broken +m4_if([$1], [CXX], +[case $host_os in +interix[[3-9]]*) + # Interix 3.5 installs completely hosed .la files for C++, so rather than + # hack all around it, let's just trust "g++" to DTRT. + _LT_TAGVAR(predep_objects,$1)= + _LT_TAGVAR(postdep_objects,$1)= + _LT_TAGVAR(postdeps,$1)= + ;; + +linux*) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + + if test "$solaris_use_stlport4" != yes; then + _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' + fi + ;; + esac + ;; + +solaris*) + case $cc_basename in + CC*) + # The more standards-conforming stlport4 library is + # incompatible with the Cstd library. Avoid specifying + # it if it's in CXXFLAGS. Ignore libCrun as + # -library=stlport4 depends on it. + case " $CXX $CXXFLAGS " in + *" -library=stlport4 "*) + solaris_use_stlport4=yes + ;; + esac + + # Adding this requires a known-good setup of shared libraries for + # Sun compiler versions before 5.6, else PIC objects from an old + # archive will be linked into the output, leading to subtle bugs. + if test "$solaris_use_stlport4" != yes; then + _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' + fi + ;; + esac + ;; +esac +]) + +case " $_LT_TAGVAR(postdeps, $1) " in +*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; +esac + _LT_TAGVAR(compiler_lib_search_dirs, $1)= +if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then + _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` +fi +_LT_TAGDECL([], [compiler_lib_search_dirs], [1], + [The directories searched by this compiler when creating a shared library]) +_LT_TAGDECL([], [predep_objects], [1], + [Dependencies to place before and after the objects being linked to + create a shared library]) +_LT_TAGDECL([], [postdep_objects], [1]) +_LT_TAGDECL([], [predeps], [1]) +_LT_TAGDECL([], [postdeps], [1]) +_LT_TAGDECL([], [compiler_lib_search_path], [1], + [The library search path used internally by the compiler when linking + a shared library]) +])# _LT_SYS_HIDDEN_LIBDEPS + + +# _LT_PROG_F77 +# ------------ +# Since AC_PROG_F77 is broken, in that it returns the empty string +# if there is no fortran compiler, we have our own version here. +m4_defun([_LT_PROG_F77], +[ +pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes]) +AC_PROG_F77 +if test -z "$F77" || test "X$F77" = "Xno"; then + _lt_disable_F77=yes +fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_F77 + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_F77], []) + + +# _LT_LANG_F77_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a Fortran 77 compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_F77_CONFIG], +[AC_REQUIRE([_LT_PROG_F77])dnl +AC_LANG_PUSH(Fortran 77) + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for f77 test sources. +ac_ext=f + +# Object file extension for compiled f77 test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the F77 compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_disable_F77" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC="$CC" + lt_save_GCC=$GCC + CC=${F77-"f77"} + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + GCC=$G77 + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)="$G77" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC="$lt_save_CC" +fi # test "$_lt_disable_F77" != yes + +AC_LANG_POP +])# _LT_LANG_F77_CONFIG + + +# _LT_PROG_FC +# ----------- +# Since AC_PROG_FC is broken, in that it returns the empty string +# if there is no fortran compiler, we have our own version here. +m4_defun([_LT_PROG_FC], +[ +pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes]) +AC_PROG_FC +if test -z "$FC" || test "X$FC" = "Xno"; then + _lt_disable_FC=yes +fi +popdef([AC_MSG_ERROR]) +])# _LT_PROG_FC + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([_LT_PROG_FC], []) + + +# _LT_LANG_FC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for a Fortran compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_FC_CONFIG], +[AC_REQUIRE([_LT_PROG_FC])dnl +AC_LANG_PUSH(Fortran) + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for fc test sources. +ac_ext=${ac_fc_srcext-f} + +# Object file extension for compiled fc test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the FC compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test "$_lt_disable_FC" != yes; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC="$CC" + lt_save_GCC=$GCC + CC=${FC-"f95"} + compiler=$CC + GCC=$ac_cv_fc_compiler_gnu + + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test "$can_build_shared" = "no" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test "$enable_shared" = yes || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" + _LT_TAGVAR(LD, $1)="$LD" + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC="$lt_save_CC" +fi # test "$_lt_disable_FC" != yes + +AC_LANG_POP +])# _LT_LANG_FC_CONFIG + + +# _LT_LANG_GCJ_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Java Compiler compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_GCJ_CONFIG], +[AC_REQUIRE([LT_PROG_GCJ])dnl +AC_LANG_SAVE + +# Source file extension for Java test sources. +ac_ext=java + +# Object file extension for compiled Java test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="class foo {}" + +# Code to be used in simple link tests +lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +lt_save_GCC=$GCC +GCC=yes +CC=${GCJ-"gcj"} +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)="$LD" +_LT_CC_BASENAME([$compiler]) + +# GCJ did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC="$lt_save_CC" +])# _LT_LANG_GCJ_CONFIG + + +# _LT_LANG_RC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for the Windows resource compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to `libtool'. +m4_defun([_LT_LANG_RC_CONFIG], +[AC_REQUIRE([LT_PROG_RC])dnl +AC_LANG_SAVE + +# Source file extension for RC test sources. +ac_ext=rc + +# Object file extension for compiled RC test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' + +# Code to be used in simple link tests +lt_simple_link_test_code="$lt_simple_compile_test_code" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +lt_save_GCC=$GCC +GCC= +CC=${RC-"windres"} +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) +_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + +if test -n "$compiler"; then + : + _LT_CONFIG($1) +fi + +GCC=$lt_save_GCC +AC_LANG_RESTORE +CC="$lt_save_CC" +])# _LT_LANG_RC_CONFIG + + +# LT_PROG_GCJ +# ----------- +AC_DEFUN([LT_PROG_GCJ], +[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], + [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], + [AC_CHECK_TOOL(GCJ, gcj,) + test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" + AC_SUBST(GCJFLAGS)])])[]dnl +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_GCJ], []) + + +# LT_PROG_RC +# ---------- +AC_DEFUN([LT_PROG_RC], +[AC_CHECK_TOOL(RC, windres,) +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_RC], []) + + +# _LT_DECL_EGREP +# -------------- +# If we don't have a new enough Autoconf to choose the best grep +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_EGREP], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_REQUIRE([AC_PROG_FGREP])dnl +test -z "$GREP" && GREP=grep +_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) +_LT_DECL([], [EGREP], [1], [An ERE matcher]) +_LT_DECL([], [FGREP], [1], [A literal string matcher]) +dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too +AC_SUBST([GREP]) +]) + + +# _LT_DECL_OBJDUMP +# -------------- +# If we don't have a new enough Autoconf to choose the best objdump +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_OBJDUMP], +[AC_CHECK_TOOL(OBJDUMP, objdump, false) +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) +AC_SUBST([OBJDUMP]) +]) + + +# _LT_DECL_SED +# ------------ +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. +m4_defun([_LT_DECL_SED], +[AC_PROG_SED +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" +_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) +_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], + [Sed that helps us avoid accidentally triggering echo(1) options like -n]) +])# _LT_DECL_SED + +m4_ifndef([AC_PROG_SED], [ +############################################################ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +############################################################ + +m4_defun([AC_PROG_SED], +[AC_MSG_CHECKING([for a sed that does not truncate output]) +AC_CACHE_VAL(lt_cv_path_SED, +[# Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +IFS=$as_save_IFS +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && continue + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +]) +SED=$lt_cv_path_SED +AC_SUBST([SED]) +AC_MSG_RESULT([$SED]) +])#AC_PROG_SED +])#m4_ifndef + +# Old name: +AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_SED], []) + + +# _LT_CHECK_SHELL_FEATURES +# ------------------------ +# Find out whether the shell is Bourne or XSI compatible, +# or has some other useful features. +m4_defun([_LT_CHECK_SHELL_FEATURES], +[AC_MSG_CHECKING([whether the shell understands some XSI constructs]) +# Try some XSI features +xsi_shell=no +( _lt_dummy="a/b/c" + test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \ + = c,a/b,, \ + && eval 'test $(( 1 + 1 )) -eq 2 \ + && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ + && xsi_shell=yes +AC_MSG_RESULT([$xsi_shell]) +_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) + +AC_MSG_CHECKING([whether the shell understands "+="]) +lt_shell_append=no +( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ + >/dev/null 2>&1 \ + && lt_shell_append=yes +AC_MSG_RESULT([$lt_shell_append]) +_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) + +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi +_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl + +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac +_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl +_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl +])# _LT_CHECK_SHELL_FEATURES + + +# _LT_PROG_XSI_SHELLFNS +# --------------------- +# Bourne and XSI compatible variants of some useful shell functions. +m4_defun([_LT_PROG_XSI_SHELLFNS], +[case $xsi_shell in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac +} + +# func_basename file +func_basename () +{ + func_basename_result="${1##*/}" +} + +# func_dirname_and_basename file append nondir_replacement +# perform func_basename and func_dirname in a single function +# call: +# dirname: Compute the dirname of FILE. If nonempty, +# add APPEND to the result, otherwise set result +# to NONDIR_REPLACEMENT. +# value returned in "$func_dirname_result" +# basename: Compute filename of FILE. +# value retuned in "$func_basename_result" +# Implementation must be kept synchronized with func_dirname +# and func_basename. For efficiency, we do not delegate to +# those functions but instead duplicate the functionality here. +func_dirname_and_basename () +{ + case ${1} in + */*) func_dirname_result="${1%/*}${2}" ;; + * ) func_dirname_result="${3}" ;; + esac + func_basename_result="${1##*/}" +} + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +func_stripname () +{ + # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are + # positional parameters, so assign one to ordinary parameter first. + func_stripname_result=${3} + func_stripname_result=${func_stripname_result#"${1}"} + func_stripname_result=${func_stripname_result%"${2}"} +} + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=${1%%=*} + func_opt_split_arg=${1#*=} +} + +# func_lo2o object +func_lo2o () +{ + case ${1} in + *.lo) func_lo2o_result=${1%.lo}.${objext} ;; + *) func_lo2o_result=${1} ;; + esac +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=${1%.*}.lo +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=$(( $[*] )) +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=${#1} +} + +_LT_EOF + ;; + *) # Bourne compatible functions. + cat << \_LT_EOF >> "$cfgfile" + +# func_dirname file append nondir_replacement +# Compute the dirname of FILE. If nonempty, add APPEND to the result, +# otherwise set result to NONDIR_REPLACEMENT. +func_dirname () +{ + # Extract subdirectory from the argument. + func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` + if test "X$func_dirname_result" = "X${1}"; then + func_dirname_result="${3}" + else + func_dirname_result="$func_dirname_result${2}" + fi +} + +# func_basename file +func_basename () +{ + func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` +} + +dnl func_dirname_and_basename +dnl A portable version of this function is already defined in general.m4sh +dnl so there is no need for it here. + +# func_stripname prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# func_strip_suffix prefix name +func_stripname () +{ + case ${2} in + .*) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;; + *) func_stripname_result=`$ECHO "X${3}" \ + | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;; + esac +} + +# sed scripts: +my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q' +my_sed_long_arg='1s/^-[[^=]]*=//' + +# func_opt_split +func_opt_split () +{ + func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"` + func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"` +} + +# func_lo2o object +func_lo2o () +{ + func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"` +} + +# func_xform libobj-or-source +func_xform () +{ + func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'` +} + +# func_arith arithmetic-term... +func_arith () +{ + func_arith_result=`expr "$[@]"` +} + +# func_len string +# STRING may not start with a hyphen. +func_len () +{ + func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len` +} + +_LT_EOF +esac + +case $lt_shell_append in + yes) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$[1]+=\$[2]" +} +_LT_EOF + ;; + *) + cat << \_LT_EOF >> "$cfgfile" + +# func_append var value +# Append VALUE to the end of shell variable VAR. +func_append () +{ + eval "$[1]=\$$[1]\$[2]" +} + +_LT_EOF + ;; + esac +]) + +############################################################################## +# ltdl.m4 - Configure ltdl for the target system. -*-Autoconf-*- +# +# Copyright (C) 1999-2006, 2007, 2008 Free Software Foundation, Inc. +# Written by Thomas Tanner, 1999 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 17 LTDL_INIT + +# LT_CONFIG_LTDL_DIR(DIRECTORY, [LTDL-MODE]) +# ------------------------------------------ +# DIRECTORY contains the libltdl sources. It is okay to call this +# function multiple times, as long as the same DIRECTORY is always given. +AC_DEFUN([LT_CONFIG_LTDL_DIR], +[AC_BEFORE([$0], [LTDL_INIT]) +_$0($*) +])# LT_CONFIG_LTDL_DIR + +# We break this out into a separate macro, so that we can call it safely +# internally without being caught accidentally by the sed scan in libtoolize. +m4_defun([_LT_CONFIG_LTDL_DIR], +[dnl remove trailing slashes +m4_pushdef([_ARG_DIR], m4_bpatsubst([$1], [/*$])) +m4_case(_LTDL_DIR, + [], [dnl only set lt_ltdl_dir if _ARG_DIR is not simply `.' + m4_if(_ARG_DIR, [.], + [], + [m4_define([_LTDL_DIR], _ARG_DIR) + _LT_SHELL_INIT([lt_ltdl_dir=']_ARG_DIR['])])], + [m4_if(_ARG_DIR, _LTDL_DIR, + [], + [m4_fatal([multiple libltdl directories: `]_LTDL_DIR[', `]_ARG_DIR['])])]) +m4_popdef([_ARG_DIR]) +])# _LT_CONFIG_LTDL_DIR + +# Initialise: +m4_define([_LTDL_DIR], []) + + +# _LT_BUILD_PREFIX +# ---------------- +# If Autoconf is new enough, expand to `${top_build_prefix}', otherwise +# to `${top_builddir}/'. +m4_define([_LT_BUILD_PREFIX], +[m4_ifdef([AC_AUTOCONF_VERSION], + [m4_if(m4_version_compare(m4_defn([AC_AUTOCONF_VERSION]), [2.62]), + [-1], [m4_ifdef([_AC_HAVE_TOP_BUILD_PREFIX], + [${top_build_prefix}], + [${top_builddir}/])], + [${top_build_prefix}])], + [${top_builddir}/])[]dnl +]) + + +# LTDL_CONVENIENCE +# ---------------- +# sets LIBLTDL to the link flags for the libltdl convenience library and +# LTDLINCL to the include flags for the libltdl header and adds +# --enable-ltdl-convenience to the configure arguments. Note that +# AC_CONFIG_SUBDIRS is not called here. LIBLTDL will be prefixed with +# '${top_build_prefix}' if available, otherwise with '${top_builddir}/', +# and LTDLINCL will be prefixed with '${top_srcdir}/' (note the single +# quotes!). If your package is not flat and you're not using automake, +# define top_build_prefix, top_builddir, and top_srcdir appropriately +# in your Makefiles. +AC_DEFUN([LTDL_CONVENIENCE], +[AC_BEFORE([$0], [LTDL_INIT])dnl +dnl Although the argument is deprecated and no longer documented, +dnl LTDL_CONVENIENCE used to take a DIRECTORY orgument, if we have one +dnl here make sure it is the same as any other declaration of libltdl's +dnl location! This also ensures lt_ltdl_dir is set when configure.ac is +dnl not yet using an explicit LT_CONFIG_LTDL_DIR. +m4_ifval([$1], [_LT_CONFIG_LTDL_DIR([$1])])dnl +_$0() +])# LTDL_CONVENIENCE + +# AC_LIBLTDL_CONVENIENCE accepted a directory argument in older libtools, +# now we have LT_CONFIG_LTDL_DIR: +AU_DEFUN([AC_LIBLTDL_CONVENIENCE], +[_LT_CONFIG_LTDL_DIR([m4_default([$1], [libltdl])]) +_LTDL_CONVENIENCE]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBLTDL_CONVENIENCE], []) + + +# _LTDL_CONVENIENCE +# ----------------- +# Code shared by LTDL_CONVENIENCE and LTDL_INIT([convenience]). +m4_defun([_LTDL_CONVENIENCE], +[case $enable_ltdl_convenience in + no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; + "") enable_ltdl_convenience=yes + ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; +esac +LIBLTDL='_LT_BUILD_PREFIX'"${lt_ltdl_dir+$lt_ltdl_dir/}libltdlc.la" +LTDLDEPS=$LIBLTDL +LTDLINCL='-I${top_srcdir}'"${lt_ltdl_dir+/$lt_ltdl_dir}" + +AC_SUBST([LIBLTDL]) +AC_SUBST([LTDLDEPS]) +AC_SUBST([LTDLINCL]) + +# For backwards non-gettext consistent compatibility... +INCLTDL="$LTDLINCL" +AC_SUBST([INCLTDL]) +])# _LTDL_CONVENIENCE + + +# LTDL_INSTALLABLE +# ---------------- +# sets LIBLTDL to the link flags for the libltdl installable library +# and LTDLINCL to the include flags for the libltdl header and adds +# --enable-ltdl-install to the configure arguments. Note that +# AC_CONFIG_SUBDIRS is not called from here. If an installed libltdl +# is not found, LIBLTDL will be prefixed with '${top_build_prefix}' if +# available, otherwise with '${top_builddir}/', and LTDLINCL will be +# prefixed with '${top_srcdir}/' (note the single quotes!). If your +# package is not flat and you're not using automake, define top_build_prefix, +# top_builddir, and top_srcdir appropriately in your Makefiles. +# In the future, this macro may have to be called after LT_INIT. +AC_DEFUN([LTDL_INSTALLABLE], +[AC_BEFORE([$0], [LTDL_INIT])dnl +dnl Although the argument is deprecated and no longer documented, +dnl LTDL_INSTALLABLE used to take a DIRECTORY orgument, if we have one +dnl here make sure it is the same as any other declaration of libltdl's +dnl location! This also ensures lt_ltdl_dir is set when configure.ac is +dnl not yet using an explicit LT_CONFIG_LTDL_DIR. +m4_ifval([$1], [_LT_CONFIG_LTDL_DIR([$1])])dnl +_$0() +])# LTDL_INSTALLABLE + +# AC_LIBLTDL_INSTALLABLE accepted a directory argument in older libtools, +# now we have LT_CONFIG_LTDL_DIR: +AU_DEFUN([AC_LIBLTDL_INSTALLABLE], +[_LT_CONFIG_LTDL_DIR([m4_default([$1], [libltdl])]) +_LTDL_INSTALLABLE]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBLTDL_INSTALLABLE], []) + + +# _LTDL_INSTALLABLE +# ----------------- +# Code shared by LTDL_INSTALLABLE and LTDL_INIT([installable]). +m4_defun([_LTDL_INSTALLABLE], +[if test -f $prefix/lib/libltdl.la; then + lt_save_LDFLAGS="$LDFLAGS" + LDFLAGS="-L$prefix/lib $LDFLAGS" + AC_CHECK_LIB([ltdl], [lt_dlinit], [lt_lib_ltdl=yes]) + LDFLAGS="$lt_save_LDFLAGS" + if test x"${lt_lib_ltdl-no}" = xyes; then + if test x"$enable_ltdl_install" != xyes; then + # Don't overwrite $prefix/lib/libltdl.la without --enable-ltdl-install + AC_MSG_WARN([not overwriting libltdl at $prefix, force with `--enable-ltdl-install']) + enable_ltdl_install=no + fi + elif test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + fi +fi + +# If configure.ac declared an installable ltdl, and the user didn't override +# with --disable-ltdl-install, we will install the shipped libltdl. +case $enable_ltdl_install in + no) ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + LTDLDEPS= + LTDLINCL= + ;; + *) enable_ltdl_install=yes + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL='_LT_BUILD_PREFIX'"${lt_ltdl_dir+$lt_ltdl_dir/}libltdl.la" + LTDLDEPS=$LIBLTDL + LTDLINCL='-I${top_srcdir}'"${lt_ltdl_dir+/$lt_ltdl_dir}" + ;; +esac + +AC_SUBST([LIBLTDL]) +AC_SUBST([LTDLDEPS]) +AC_SUBST([LTDLINCL]) + +# For backwards non-gettext consistent compatibility... +INCLTDL="$LTDLINCL" +AC_SUBST([INCLTDL]) +])# LTDL_INSTALLABLE + + +# _LTDL_MODE_DISPATCH +# ------------------- +m4_define([_LTDL_MODE_DISPATCH], +[dnl If _LTDL_DIR is `.', then we are configuring libltdl itself: +m4_if(_LTDL_DIR, [], + [], + dnl if _LTDL_MODE was not set already, the default value is `subproject': + [m4_case(m4_default(_LTDL_MODE, [subproject]), + [subproject], [AC_CONFIG_SUBDIRS(_LTDL_DIR) + _LT_SHELL_INIT([lt_dlopen_dir="$lt_ltdl_dir"])], + [nonrecursive], [_LT_SHELL_INIT([lt_dlopen_dir="$lt_ltdl_dir"; lt_libobj_prefix="$lt_ltdl_dir/"])], + [recursive], [], + [m4_fatal([unknown libltdl mode: ]_LTDL_MODE)])])dnl +dnl Be careful not to expand twice: +m4_define([$0], []) +])# _LTDL_MODE_DISPATCH + + +# _LT_LIBOBJ(MODULE_NAME) +# ----------------------- +# Like AC_LIBOBJ, except that MODULE_NAME goes into _LT_LIBOBJS instead +# of into LIBOBJS. +AC_DEFUN([_LT_LIBOBJ], [ + m4_pattern_allow([^_LT_LIBOBJS$]) + _LT_LIBOBJS="$_LT_LIBOBJS $1.$ac_objext" +])# _LT_LIBOBJS + + +# LTDL_INIT([OPTIONS]) +# -------------------- +# Clients of libltdl can use this macro to allow the installer to +# choose between a shipped copy of the ltdl sources or a preinstalled +# version of the library. If the shipped ltdl sources are not in a +# subdirectory named libltdl, the directory name must be given by +# LT_CONFIG_LTDL_DIR. +AC_DEFUN([LTDL_INIT], +[dnl Parse OPTIONS +_LT_SET_OPTIONS([$0], [$1]) + +dnl We need to keep our own list of libobjs separate from our parent project, +dnl and the easiest way to do that is redefine the AC_LIBOBJs macro while +dnl we look for our own LIBOBJs. +m4_pushdef([AC_LIBOBJ], m4_defn([_LT_LIBOBJ])) +m4_pushdef([AC_LIBSOURCES]) + +dnl If not otherwise defined, default to the 1.5.x compatible subproject mode: +m4_if(_LTDL_MODE, [], + [m4_define([_LTDL_MODE], m4_default([$2], [subproject])) + m4_if([-1], [m4_bregexp(_LTDL_MODE, [\(subproject\|\(non\)?recursive\)])], + [m4_fatal([unknown libltdl mode: ]_LTDL_MODE)])]) + +AC_ARG_WITH([included_ltdl], + [AS_HELP_STRING([--with-included-ltdl], + [use the GNU ltdl sources included here])]) + +if test "x$with_included_ltdl" != xyes; then + # We are not being forced to use the included libltdl sources, so + # decide whether there is a useful installed version we can use. + AC_CHECK_HEADER([ltdl.h], + [AC_CHECK_DECL([lt_dlinterface_register], + [AC_CHECK_LIB([ltdl], [lt_dladvise_preload], + [with_included_ltdl=no], + [with_included_ltdl=yes])], + [with_included_ltdl=yes], + [AC_INCLUDES_DEFAULT + #include ])], + [with_included_ltdl=yes], + [AC_INCLUDES_DEFAULT] + ) +fi + +dnl If neither LT_CONFIG_LTDL_DIR, LTDL_CONVENIENCE nor LTDL_INSTALLABLE +dnl was called yet, then for old times' sake, we assume libltdl is in an +dnl eponymous directory: +AC_PROVIDE_IFELSE([LT_CONFIG_LTDL_DIR], [], [_LT_CONFIG_LTDL_DIR([libltdl])]) + +AC_ARG_WITH([ltdl_include], + [AS_HELP_STRING([--with-ltdl-include=DIR], + [use the ltdl headers installed in DIR])]) + +if test -n "$with_ltdl_include"; then + if test -f "$with_ltdl_include/ltdl.h"; then : + else + AC_MSG_ERROR([invalid ltdl include directory: `$with_ltdl_include']) + fi +else + with_ltdl_include=no +fi + +AC_ARG_WITH([ltdl_lib], + [AS_HELP_STRING([--with-ltdl-lib=DIR], + [use the libltdl.la installed in DIR])]) + +if test -n "$with_ltdl_lib"; then + if test -f "$with_ltdl_lib/libltdl.la"; then : + else + AC_MSG_ERROR([invalid ltdl library directory: `$with_ltdl_lib']) + fi +else + with_ltdl_lib=no +fi + +case ,$with_included_ltdl,$with_ltdl_include,$with_ltdl_lib, in + ,yes,no,no,) + m4_case(m4_default(_LTDL_TYPE, [convenience]), + [convenience], [_LTDL_CONVENIENCE], + [installable], [_LTDL_INSTALLABLE], + [m4_fatal([unknown libltdl build type: ]_LTDL_TYPE)]) + ;; + ,no,no,no,) + # If the included ltdl is not to be used, then use the + # preinstalled libltdl we found. + AC_DEFINE([HAVE_LTDL], [1], + [Define this if a modern libltdl is already installed]) + LIBLTDL=-lltdl + LTDLDEPS= + LTDLINCL= + ;; + ,no*,no,*) + AC_MSG_ERROR([`--with-ltdl-include' and `--with-ltdl-lib' options must be used together]) + ;; + *) with_included_ltdl=no + LIBLTDL="-L$with_ltdl_lib -lltdl" + LTDLDEPS= + LTDLINCL="-I$with_ltdl_include" + ;; +esac +INCLTDL="$LTDLINCL" + +# Report our decision... +AC_MSG_CHECKING([where to find libltdl headers]) +AC_MSG_RESULT([$LTDLINCL]) +AC_MSG_CHECKING([where to find libltdl library]) +AC_MSG_RESULT([$LIBLTDL]) + +_LTDL_SETUP + +dnl restore autoconf definition. +m4_popdef([AC_LIBOBJ]) +m4_popdef([AC_LIBSOURCES]) + +AC_CONFIG_COMMANDS_PRE([ + _ltdl_libobjs= + _ltdl_ltlibobjs= + if test -n "$_LT_LIBOBJS"; then + # Remove the extension. + _lt_sed_drop_objext='s/\.o$//;s/\.obj$//' + for i in `for i in $_LT_LIBOBJS; do echo "$i"; done | sed "$_lt_sed_drop_objext" | sort -u`; do + _ltdl_libobjs="$_ltdl_libobjs $lt_libobj_prefix$i.$ac_objext" + _ltdl_ltlibobjs="$_ltdl_ltlibobjs $lt_libobj_prefix$i.lo" + done + fi + AC_SUBST([ltdl_LIBOBJS], [$_ltdl_libobjs]) + AC_SUBST([ltdl_LTLIBOBJS], [$_ltdl_ltlibobjs]) +]) + +# Only expand once: +m4_define([LTDL_INIT]) +])# LTDL_INIT + +# Old names: +AU_DEFUN([AC_LIB_LTDL], [LTDL_INIT($@)]) +AU_DEFUN([AC_WITH_LTDL], [LTDL_INIT($@)]) +AU_DEFUN([LT_WITH_LTDL], [LTDL_INIT($@)]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIB_LTDL], []) +dnl AC_DEFUN([AC_WITH_LTDL], []) +dnl AC_DEFUN([LT_WITH_LTDL], []) + + +# _LTDL_SETUP +# ----------- +# Perform all the checks necessary for compilation of the ltdl objects +# -- including compiler checks and header checks. This is a public +# interface mainly for the benefit of libltdl's own configure.ac, most +# other users should call LTDL_INIT instead. +AC_DEFUN([_LTDL_SETUP], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_SYS_MODULE_EXT])dnl +AC_REQUIRE([LT_SYS_MODULE_PATH])dnl +AC_REQUIRE([LT_SYS_DLSEARCH_PATH])dnl +AC_REQUIRE([LT_LIB_DLLOAD])dnl +AC_REQUIRE([LT_SYS_SYMBOL_USCORE])dnl +AC_REQUIRE([LT_FUNC_DLSYM_USCORE])dnl +AC_REQUIRE([LT_SYS_DLOPEN_DEPLIBS])dnl +AC_REQUIRE([gl_FUNC_ARGZ])dnl + +m4_require([_LT_CHECK_OBJDIR])dnl +m4_require([_LT_HEADER_DLFCN])dnl +m4_require([_LT_CHECK_DLPREOPEN])dnl +m4_require([_LT_DECL_SED])dnl + +dnl Don't require this, or it will be expanded earlier than the code +dnl that sets the variables it relies on: +_LT_ENABLE_INSTALL + +dnl _LTDL_MODE specific code must be called at least once: +_LTDL_MODE_DISPATCH + +# In order that ltdl.c can compile, find out the first AC_CONFIG_HEADERS +# the user used. This is so that ltdl.h can pick up the parent projects +# config.h file, The first file in AC_CONFIG_HEADERS must contain the +# definitions required by ltdl.c. +# FIXME: Remove use of undocumented AC_LIST_HEADERS (2.59 compatibility). +AC_CONFIG_COMMANDS_PRE([dnl +m4_pattern_allow([^LT_CONFIG_H$])dnl +m4_ifset([AH_HEADER], + [LT_CONFIG_H=AH_HEADER], + [m4_ifset([AC_LIST_HEADERS], + [LT_CONFIG_H=`echo "AC_LIST_HEADERS" | $SED 's,^[[ ]]*,,;s,[[ :]].*$,,'`], + [])])]) +AC_SUBST([LT_CONFIG_H]) + +AC_CHECK_HEADERS([unistd.h dl.h sys/dl.h dld.h mach-o/dyld.h dirent.h], + [], [], [AC_INCLUDES_DEFAULT]) + +AC_CHECK_FUNCS([closedir opendir readdir], [], [AC_LIBOBJ([lt__dirent])]) +AC_CHECK_FUNCS([strlcat strlcpy], [], [AC_LIBOBJ([lt__strl])]) + +AC_DEFINE_UNQUOTED([LT_LIBEXT],["$libext"],[The archive extension]) + +name=ltdl +LTDLOPEN=`eval "\\$ECHO \"$libname_spec\""` +AC_SUBST([LTDLOPEN]) +])# _LTDL_SETUP + + +# _LT_ENABLE_INSTALL +# ------------------ +m4_define([_LT_ENABLE_INSTALL], +[AC_ARG_ENABLE([ltdl-install], + [AS_HELP_STRING([--enable-ltdl-install], [install libltdl])]) + +case ,${enable_ltdl_install},${enable_ltdl_convenience} in + *yes*) ;; + *) enable_ltdl_convenience=yes ;; +esac + +m4_ifdef([AM_CONDITIONAL], +[AM_CONDITIONAL(INSTALL_LTDL, test x"${enable_ltdl_install-no}" != xno) + AM_CONDITIONAL(CONVENIENCE_LTDL, test x"${enable_ltdl_convenience-no}" != xno)]) +])# _LT_ENABLE_INSTALL + + +# LT_SYS_DLOPEN_DEPLIBS +# --------------------- +AC_DEFUN([LT_SYS_DLOPEN_DEPLIBS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_CACHE_CHECK([whether deplibs are loaded by dlopen], + [lt_cv_sys_dlopen_deplibs], + [# PORTME does your system automatically load deplibs for dlopen? + # or its logical equivalent (e.g. shl_load for HP-UX < 11) + # For now, we just catch OSes we know something about -- in the + # future, we'll try test this programmatically. + lt_cv_sys_dlopen_deplibs=unknown + case $host_os in + aix3*|aix4.1.*|aix4.2.*) + # Unknown whether this is true for these versions of AIX, but + # we want this `case' here to explicitly catch those versions. + lt_cv_sys_dlopen_deplibs=unknown + ;; + aix[[4-9]]*) + lt_cv_sys_dlopen_deplibs=yes + ;; + amigaos*) + case $host_cpu in + powerpc) + lt_cv_sys_dlopen_deplibs=no + ;; + esac + ;; + darwin*) + # Assuming the user has installed a libdl from somewhere, this is true + # If you are looking for one http://www.opendarwin.org/projects/dlcompat + lt_cv_sys_dlopen_deplibs=yes + ;; + freebsd* | dragonfly*) + lt_cv_sys_dlopen_deplibs=yes + ;; + gnu* | linux* | k*bsd*-gnu) + # GNU and its variants, using gnu ld.so (Glibc) + lt_cv_sys_dlopen_deplibs=yes + ;; + hpux10*|hpux11*) + lt_cv_sys_dlopen_deplibs=yes + ;; + interix*) + lt_cv_sys_dlopen_deplibs=yes + ;; + irix[[12345]]*|irix6.[[01]]*) + # Catch all versions of IRIX before 6.2, and indicate that we don't + # know how it worked for any of those versions. + lt_cv_sys_dlopen_deplibs=unknown + ;; + irix*) + # The case above catches anything before 6.2, and it's known that + # at 6.2 and later dlopen does load deplibs. + lt_cv_sys_dlopen_deplibs=yes + ;; + netbsd*) + lt_cv_sys_dlopen_deplibs=yes + ;; + openbsd*) + lt_cv_sys_dlopen_deplibs=yes + ;; + osf[[1234]]*) + # dlopen did load deplibs (at least at 4.x), but until the 5.x series, + # it did *not* use an RPATH in a shared library to find objects the + # library depends on, so we explicitly say `no'. + lt_cv_sys_dlopen_deplibs=no + ;; + osf5.0|osf5.0a|osf5.1) + # dlopen *does* load deplibs and with the right loader patch applied + # it even uses RPATH in a shared library to search for shared objects + # that the library depends on, but there's no easy way to know if that + # patch is installed. Since this is the case, all we can really + # say is unknown -- it depends on the patch being installed. If + # it is, this changes to `yes'. Without it, it would be `no'. + lt_cv_sys_dlopen_deplibs=unknown + ;; + osf*) + # the two cases above should catch all versions of osf <= 5.1. Read + # the comments above for what we know about them. + # At > 5.1, deplibs are loaded *and* any RPATH in a shared library + # is used to find them so we can finally say `yes'. + lt_cv_sys_dlopen_deplibs=yes + ;; + qnx*) + lt_cv_sys_dlopen_deplibs=yes + ;; + solaris*) + lt_cv_sys_dlopen_deplibs=yes + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + libltdl_cv_sys_dlopen_deplibs=yes + ;; + esac + ]) +if test "$lt_cv_sys_dlopen_deplibs" != yes; then + AC_DEFINE([LTDL_DLOPEN_DEPLIBS], [1], + [Define if the OS needs help to load dependent libraries for dlopen().]) +fi +])# LT_SYS_DLOPEN_DEPLIBS + +# Old name: +AU_ALIAS([AC_LTDL_SYS_DLOPEN_DEPLIBS], [LT_SYS_DLOPEN_DEPLIBS]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LTDL_SYS_DLOPEN_DEPLIBS], []) + + +# LT_SYS_MODULE_EXT +# ----------------- +AC_DEFUN([LT_SYS_MODULE_EXT], +[m4_require([_LT_SYS_DYNAMIC_LINKER])dnl +AC_CACHE_CHECK([which extension is used for runtime loadable modules], + [libltdl_cv_shlibext], +[ +module=yes +eval libltdl_cv_shlibext=$shrext_cmds + ]) +if test -n "$libltdl_cv_shlibext"; then + m4_pattern_allow([LT_MODULE_EXT])dnl + AC_DEFINE_UNQUOTED([LT_MODULE_EXT], ["$libltdl_cv_shlibext"], + [Define to the extension used for runtime loadable modules, say, ".so".]) +fi +])# LT_SYS_MODULE_EXT + +# Old name: +AU_ALIAS([AC_LTDL_SHLIBEXT], [LT_SYS_MODULE_EXT]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LTDL_SHLIBEXT], []) + + +# LT_SYS_MODULE_PATH +# ------------------ +AC_DEFUN([LT_SYS_MODULE_PATH], +[m4_require([_LT_SYS_DYNAMIC_LINKER])dnl +AC_CACHE_CHECK([which variable specifies run-time module search path], + [lt_cv_module_path_var], [lt_cv_module_path_var="$shlibpath_var"]) +if test -n "$lt_cv_module_path_var"; then + m4_pattern_allow([LT_MODULE_PATH_VAR])dnl + AC_DEFINE_UNQUOTED([LT_MODULE_PATH_VAR], ["$lt_cv_module_path_var"], + [Define to the name of the environment variable that determines the run-time module search path.]) +fi +])# LT_SYS_MODULE_PATH + +# Old name: +AU_ALIAS([AC_LTDL_SHLIBPATH], [LT_SYS_MODULE_PATH]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LTDL_SHLIBPATH], []) + + +# LT_SYS_DLSEARCH_PATH +# -------------------- +AC_DEFUN([LT_SYS_DLSEARCH_PATH], +[m4_require([_LT_SYS_DYNAMIC_LINKER])dnl +AC_CACHE_CHECK([for the default library search path], + [lt_cv_sys_dlsearch_path], + [lt_cv_sys_dlsearch_path="$sys_lib_dlsearch_path_spec"]) +if test -n "$lt_cv_sys_dlsearch_path"; then + sys_dlsearch_path= + for dir in $lt_cv_sys_dlsearch_path; do + if test -z "$sys_dlsearch_path"; then + sys_dlsearch_path="$dir" + else + sys_dlsearch_path="$sys_dlsearch_path$PATH_SEPARATOR$dir" + fi + done + m4_pattern_allow([LT_DLSEARCH_PATH])dnl + AC_DEFINE_UNQUOTED([LT_DLSEARCH_PATH], ["$sys_dlsearch_path"], + [Define to the system default library search path.]) +fi +])# LT_SYS_DLSEARCH_PATH + +# Old name: +AU_ALIAS([AC_LTDL_SYSSEARCHPATH], [LT_SYS_DLSEARCH_PATH]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LTDL_SYSSEARCHPATH], []) + + +# _LT_CHECK_DLPREOPEN +# ------------------- +m4_defun([_LT_CHECK_DLPREOPEN], +[m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +AC_CACHE_CHECK([whether libtool supports -dlopen/-dlpreopen], + [libltdl_cv_preloaded_symbols], + [if test -n "$lt_cv_sys_global_symbol_pipe"; then + libltdl_cv_preloaded_symbols=yes + else + libltdl_cv_preloaded_symbols=no + fi + ]) +if test x"$libltdl_cv_preloaded_symbols" = xyes; then + AC_DEFINE([HAVE_PRELOADED_SYMBOLS], [1], + [Define if libtool can extract symbol lists from object files.]) +fi +])# _LT_CHECK_DLPREOPEN + + +# LT_LIB_DLLOAD +# ------------- +AC_DEFUN([LT_LIB_DLLOAD], +[m4_pattern_allow([^LT_DLLOADERS$]) +LT_DLLOADERS= +AC_SUBST([LT_DLLOADERS]) + +AC_LANG_PUSH([C]) + +LIBADD_DLOPEN= +AC_SEARCH_LIBS([dlopen], [dl], + [AC_DEFINE([HAVE_LIBDL], [1], + [Define if you have the libdl library or equivalent.]) + if test "$ac_cv_search_dlopen" != "none required" ; then + LIBADD_DLOPEN="-ldl" + fi + libltdl_cv_lib_dl_dlopen="yes" + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la"], + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if HAVE_DLFCN_H +# include +#endif + ]], [[dlopen(0, 0);]])], + [AC_DEFINE([HAVE_LIBDL], [1], + [Define if you have the libdl library or equivalent.]) + libltdl_cv_func_dlopen="yes" + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la"], + [AC_CHECK_LIB([svld], [dlopen], + [AC_DEFINE([HAVE_LIBDL], [1], + [Define if you have the libdl library or equivalent.]) + LIBADD_DLOPEN="-lsvld" libltdl_cv_func_dlopen="yes" + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la"])])]) +if test x"$libltdl_cv_func_dlopen" = xyes || test x"$libltdl_cv_lib_dl_dlopen" = xyes +then + lt_save_LIBS="$LIBS" + LIBS="$LIBS $LIBADD_DLOPEN" + AC_CHECK_FUNCS([dlerror]) + LIBS="$lt_save_LIBS" +fi +AC_SUBST([LIBADD_DLOPEN]) + +LIBADD_SHL_LOAD= +AC_CHECK_FUNC([shl_load], + [AC_DEFINE([HAVE_SHL_LOAD], [1], + [Define if you have the shl_load function.]) + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}shl_load.la"], + [AC_CHECK_LIB([dld], [shl_load], + [AC_DEFINE([HAVE_SHL_LOAD], [1], + [Define if you have the shl_load function.]) + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}shl_load.la" + LIBADD_SHL_LOAD="-ldld"])]) +AC_SUBST([LIBADD_SHL_LOAD]) + +case $host_os in +darwin[[1567]].*) +# We only want this for pre-Mac OS X 10.4. + AC_CHECK_FUNC([_dyld_func_lookup], + [AC_DEFINE([HAVE_DYLD], [1], + [Define if you have the _dyld_func_lookup function.]) + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dyld.la"]) + ;; +beos*) + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}load_add_on.la" + ;; +cygwin* | mingw* | os2* | pw32*) + AC_CHECK_DECLS([cygwin_conv_path], [], [], [[#include ]]) + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}loadlibrary.la" + ;; +esac + +AC_CHECK_LIB([dld], [dld_link], + [AC_DEFINE([HAVE_DLD], [1], + [Define if you have the GNU dld library.]) + LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dld_link.la"]) +AC_SUBST([LIBADD_DLD_LINK]) + +m4_pattern_allow([^LT_DLPREOPEN$]) +LT_DLPREOPEN= +if test -n "$LT_DLLOADERS" +then + for lt_loader in $LT_DLLOADERS; do + LT_DLPREOPEN="$LT_DLPREOPEN-dlpreopen $lt_loader " + done + AC_DEFINE([HAVE_LIBDLLOADER], [1], + [Define if libdlloader will be built on this platform]) +fi +AC_SUBST([LT_DLPREOPEN]) + +dnl This isn't used anymore, but set it for backwards compatibility +LIBADD_DL="$LIBADD_DLOPEN $LIBADD_SHL_LOAD" +AC_SUBST([LIBADD_DL]) + +AC_LANG_POP +])# LT_LIB_DLLOAD + +# Old name: +AU_ALIAS([AC_LTDL_DLLIB], [LT_LIB_DLLOAD]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LTDL_DLLIB], []) + + +# LT_SYS_SYMBOL_USCORE +# -------------------- +# does the compiler prefix global symbols with an underscore? +AC_DEFUN([LT_SYS_SYMBOL_USCORE], +[m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +AC_CACHE_CHECK([for _ prefix in compiled symbols], + [lt_cv_sys_symbol_underscore], + [lt_cv_sys_symbol_underscore=no + cat > conftest.$ac_ext <<_LT_EOF +void nm_test_func(){} +int main(){nm_test_func;return 0;} +_LT_EOF + if AC_TRY_EVAL(ac_compile); then + # Now try to grab the symbols. + ac_nlist=conftest.nm + if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then + # See whether the symbols have a leading underscore. + if grep '^. _nm_test_func' "$ac_nlist" >/dev/null; then + lt_cv_sys_symbol_underscore=yes + else + if grep '^. nm_test_func ' "$ac_nlist" >/dev/null; then + : + else + echo "configure: cannot find nm_test_func in $ac_nlist" >&AS_MESSAGE_LOG_FD + fi + fi + else + echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.c >&AS_MESSAGE_LOG_FD + fi + rm -rf conftest* + ]) + sys_symbol_underscore=$lt_cv_sys_symbol_underscore + AC_SUBST([sys_symbol_underscore]) +])# LT_SYS_SYMBOL_USCORE + +# Old name: +AU_ALIAS([AC_LTDL_SYMBOL_USCORE], [LT_SYS_SYMBOL_USCORE]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LTDL_SYMBOL_USCORE], []) + + +# LT_FUNC_DLSYM_USCORE +# -------------------- +AC_DEFUN([LT_FUNC_DLSYM_USCORE], +[AC_REQUIRE([LT_SYS_SYMBOL_USCORE])dnl +if test x"$lt_cv_sys_symbol_underscore" = xyes; then + if test x"$libltdl_cv_func_dlopen" = xyes || + test x"$libltdl_cv_lib_dl_dlopen" = xyes ; then + AC_CACHE_CHECK([whether we have to add an underscore for dlsym], + [libltdl_cv_need_uscore], + [libltdl_cv_need_uscore=unknown + save_LIBS="$LIBS" + LIBS="$LIBS $LIBADD_DLOPEN" + _LT_TRY_DLOPEN_SELF( + [libltdl_cv_need_uscore=no], [libltdl_cv_need_uscore=yes], + [], [libltdl_cv_need_uscore=cross]) + LIBS="$save_LIBS" + ]) + fi +fi + +if test x"$libltdl_cv_need_uscore" = xyes; then + AC_DEFINE([NEED_USCORE], [1], + [Define if dlsym() requires a leading underscore in symbol names.]) +fi +])# LT_FUNC_DLSYM_USCORE + +# Old name: +AU_ALIAS([AC_LTDL_DLSYM_USCORE], [LT_FUNC_DLSYM_USCORE]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LTDL_DLSYM_USCORE], []) + +############################################################################## +# Helper functions for option handling. -*- Autoconf -*- +# +# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 6 ltoptions.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) + + +# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) +# ------------------------------------------ +m4_define([_LT_MANGLE_OPTION], +[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) + + +# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) +# --------------------------------------- +# Set option OPTION-NAME for macro MACRO-NAME, and if there is a +# matching handler defined, dispatch to it. Other OPTION-NAMEs are +# saved as a flag. +m4_define([_LT_SET_OPTION], +[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl +m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), + _LT_MANGLE_DEFUN([$1], [$2]), + [m4_warning([Unknown $1 option `$2'])])[]dnl +]) + + +# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) +# ------------------------------------------------------------ +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +m4_define([_LT_IF_OPTION], +[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) + + +# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) +# ------------------------------------------------------- +# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME +# are set. +m4_define([_LT_UNLESS_OPTIONS], +[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), + [m4_define([$0_found])])])[]dnl +m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 +])[]dnl +]) + + +# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) +# ---------------------------------------- +# OPTION-LIST is a space-separated list of Libtool options associated +# with MACRO-NAME. If any OPTION has a matching handler declared with +# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about +# the unknown option and exit. +m4_defun([_LT_SET_OPTIONS], +[# Set options +m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [_LT_SET_OPTION([$1], _LT_Option)]) + +m4_if([$1],[LT_INIT],[ + dnl + dnl Simply set some default values (i.e off) if boolean options were not + dnl specified: + _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no + ]) + _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no + ]) + dnl + dnl If no reference was made to various pairs of opposing options, then + dnl we run the default mode handler for the pair. For example, if neither + dnl `shared' nor `disable-shared' was passed, we enable building of shared + dnl archives by default: + _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) + _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], + [_LT_ENABLE_FAST_INSTALL]) + ]) +])# _LT_SET_OPTIONS + + +## --------------------------------- ## +## Macros to handle LT_INIT options. ## +## --------------------------------- ## + +# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) +# ----------------------------------------- +m4_define([_LT_MANGLE_DEFUN], +[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) + + +# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) +# ----------------------------------------------- +m4_define([LT_OPTION_DEFINE], +[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl +])# LT_OPTION_DEFINE + + +# dlopen +# ------ +LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes +]) + +AU_DEFUN([AC_LIBTOOL_DLOPEN], +[_LT_SET_OPTION([LT_INIT], [dlopen]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `dlopen' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) + + +# win32-dll +# --------- +# Declare package support for building win32 dll's. +LT_OPTION_DEFINE([LT_INIT], [win32-dll], +[enable_win32_dll=yes + +case $host in +*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +esac + +test -z "$AS" && AS=as +_LT_DECL([], [AS], [0], [Assembler program])dnl + +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl + +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl +])# win32-dll + +AU_DEFUN([AC_LIBTOOL_WIN32_DLL], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +_LT_SET_OPTION([LT_INIT], [win32-dll]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `win32-dll' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) + + +# _LT_ENABLE_SHARED([DEFAULT]) +# ---------------------------- +# implement the --enable-shared flag, and supports the `shared' and +# `disable-shared' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_SHARED], +[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([shared], + [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], + [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) + + _LT_DECL([build_libtool_libs], [enable_shared], [0], + [Whether or not to build shared libraries]) +])# _LT_ENABLE_SHARED + +LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) +]) + +AC_DEFUN([AC_DISABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], [disable-shared]) +]) + +AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_SHARED], []) +dnl AC_DEFUN([AM_DISABLE_SHARED], []) + + + +# _LT_ENABLE_STATIC([DEFAULT]) +# ---------------------------- +# implement the --enable-static flag, and support the `static' and +# `disable-static' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_STATIC], +[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([static], + [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], + [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_static=]_LT_ENABLE_STATIC_DEFAULT) + + _LT_DECL([build_old_libs], [enable_static], [0], + [Whether or not to build static libraries]) +])# _LT_ENABLE_STATIC + +LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) +]) + +AC_DEFUN([AC_DISABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], [disable-static]) +]) + +AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_STATIC], []) +dnl AC_DEFUN([AM_DISABLE_STATIC], []) + + + +# _LT_ENABLE_FAST_INSTALL([DEFAULT]) +# ---------------------------------- +# implement the --enable-fast-install flag, and support the `fast-install' +# and `disable-fast-install' LT_INIT options. +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +m4_define([_LT_ENABLE_FAST_INSTALL], +[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([fast-install], + [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], + [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) + +_LT_DECL([fast_install], [enable_fast_install], [0], + [Whether or not to optimize for fast installation])dnl +])# _LT_ENABLE_FAST_INSTALL + +LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) + +# Old names: +AU_DEFUN([AC_ENABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the `fast-install' option into LT_INIT's first parameter.]) +]) + +AU_DEFUN([AC_DISABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the `disable-fast-install' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) +dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) + + +# _LT_WITH_PIC([MODE]) +# -------------------- +# implement the --with-pic flag, and support the `pic-only' and `no-pic' +# LT_INIT options. +# MODE is either `yes' or `no'. If omitted, it defaults to `both'. +m4_define([_LT_WITH_PIC], +[AC_ARG_WITH([pic], + [AS_HELP_STRING([--with-pic], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [pic_mode="$withval"], + [pic_mode=default]) + +test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) + +_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl +])# _LT_WITH_PIC + +LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) + +# Old name: +AU_DEFUN([AC_LIBTOOL_PICMODE], +[_LT_SET_OPTION([LT_INIT], [pic-only]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the `pic-only' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) + +## ----------------- ## +## LTDL_INIT Options ## +## ----------------- ## + +m4_define([_LTDL_MODE], []) +LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], + [m4_define([_LTDL_MODE], [nonrecursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [recursive], + [m4_define([_LTDL_MODE], [recursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [subproject], + [m4_define([_LTDL_MODE], [subproject])]) + +m4_define([_LTDL_TYPE], []) +LT_OPTION_DEFINE([LTDL_INIT], [installable], + [m4_define([_LTDL_TYPE], [installable])]) +LT_OPTION_DEFINE([LTDL_INIT], [convenience], + [m4_define([_LTDL_TYPE], [convenience])]) + +############################################################################## +# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- +# +# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 6 ltsugar.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) + + +# lt_join(SEP, ARG1, [ARG2...]) +# ----------------------------- +# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their +# associated separator. +# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier +# versions in m4sugar had bugs. +m4_define([lt_join], +[m4_if([$#], [1], [], + [$#], [2], [[$2]], + [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) +m4_define([_lt_join], +[m4_if([$#$2], [2], [], + [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) + + +# lt_car(LIST) +# lt_cdr(LIST) +# ------------ +# Manipulate m4 lists. +# These macros are necessary as long as will still need to support +# Autoconf-2.59 which quotes differently. +m4_define([lt_car], [[$1]]) +m4_define([lt_cdr], +[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], + [$#], 1, [], + [m4_dquote(m4_shift($@))])]) +m4_define([lt_unquote], $1) + + +# lt_append(MACRO-NAME, STRING, [SEPARATOR]) +# ------------------------------------------ +# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. +# Note that neither SEPARATOR nor STRING are expanded; they are appended +# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). +# No SEPARATOR is output if MACRO-NAME was previously undefined (different +# than defined and empty). +# +# This macro is needed until we can rely on Autoconf 2.62, since earlier +# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. +m4_define([lt_append], +[m4_define([$1], + m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) + + + +# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) +# ---------------------------------------------------------- +# Produce a SEP delimited list of all paired combinations of elements of +# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list +# has the form PREFIXmINFIXSUFFIXn. +# Needed until we can rely on m4_combine added in Autoconf 2.62. +m4_define([lt_combine], +[m4_if(m4_eval([$# > 3]), [1], + [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl +[[m4_foreach([_Lt_prefix], [$2], + [m4_foreach([_Lt_suffix], + ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, + [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) + + +# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) +# ----------------------------------------------------------------------- +# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited +# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. +m4_define([lt_if_append_uniq], +[m4_ifdef([$1], + [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], + [lt_append([$1], [$2], [$3])$4], + [$5])], + [lt_append([$1], [$2], [$3])$4])]) + + +# lt_dict_add(DICT, KEY, VALUE) +# ----------------------------- +m4_define([lt_dict_add], +[m4_define([$1($2)], [$3])]) + + +# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) +# -------------------------------------------- +m4_define([lt_dict_add_subkey], +[m4_define([$1($2:$3)], [$4])]) + + +# lt_dict_fetch(DICT, KEY, [SUBKEY]) +# ---------------------------------- +m4_define([lt_dict_fetch], +[m4_ifval([$3], + m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), + m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) + + +# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) +# ----------------------------------------------------------------- +m4_define([lt_if_dict_fetch], +[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], + [$5], + [$6])]) + + +# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) +# -------------------------------------------------------------- +m4_define([lt_dict_filter], +[m4_if([$5], [], [], + [lt_join(m4_quote(m4_default([$4], [[, ]])), + lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), + [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl +]) + +############################################################################## +# ltversion.m4 -- version numbers -*- Autoconf -*- +# +# Copyright (C) 2004 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# Generated from ltversion.in. + +# serial 3012 ltversion.m4 +# This file is part of GNU Libtool + +m4_define([LT_PACKAGE_VERSION], [2.2.6]) +m4_define([LT_PACKAGE_REVISION], [1.3012]) + +AC_DEFUN([LTVERSION_VERSION], +[macro_version='2.2.6' +macro_revision='1.3012' +_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) +_LT_DECL(, macro_revision, 0) +]) + +############################################################################## +# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- +# +# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004. +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 4 lt~obsolete.m4 + +# These exist entirely to fool aclocal when bootstrapping libtool. +# +# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) +# which have later been changed to m4_define as they aren't part of the +# exported API, or moved to Autoconf or Automake where they belong. +# +# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN +# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us +# using a macro with the same name in our local m4/libtool.m4 it'll +# pull the old libtool.m4 in (it doesn't see our shiny new m4_define +# and doesn't know about Autoconf macros at all.) +# +# So we provide this file, which has a silly filename so it's always +# included after everything else. This provides aclocal with the +# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything +# because those macros already exist, or will be overwritten later. +# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. +# +# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. +# Yes, that means every name once taken will need to remain here until +# we give up compatibility with versions before 1.7, at which point +# we need to keep only those names which we still refer to. + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) + +m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) +m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) +m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) +m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) +m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) +m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) +m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) +m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) +m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) +m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) +m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) +m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) +m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) +m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) +m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) +m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) +m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) +m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) +m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) +m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) +m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) +m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) +m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) +m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) +m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) +m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) +m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) +m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) +m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) +m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) +m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) +m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) +m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) +m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) +m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) +m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) +m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) +m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) +m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])]) +m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) +m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) +m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) +m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) +m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) +m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) +m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) +m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# +# Copyright © 2004 Scott James Remnant . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) +# ---------------------------------- +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.9.0]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi + +fi[]dnl +])# PKG_PROG_PKG_CONFIG + +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Check to see whether a particular set of modules exists. Similar +# to PKG_CHECK_MODULES(), but does not set variables or print errors. +# +# +# Similar to PKG_CHECK_MODULES, make sure that the first instance of +# this or PKG_CHECK_MODULES is called, or make sure to call +# PKG_CHECK_EXISTS manually +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_ifval([$2], [$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + + +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +# --------------------------------------------- +m4_define([_PKG_CONFIG], +[if test -n "$PKG_CONFIG"; then + if test -n "$$1"; then + pkg_cv_[]$1="$$1" + else + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], + [pkg_failed=yes]) + fi +else + pkg_failed=untried +fi[]dnl +])# _PKG_CONFIG + +# _PKG_SHORT_ERRORS_SUPPORTED +# ----------------------------- +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])# _PKG_SHORT_ERRORS_SUPPORTED + + +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +# [ACTION-IF-NOT-FOUND]) +# +# +# Note that if there is a possibility the first call to +# PKG_CHECK_MODULES might not happen, you should be sure to include an +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +# +# +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_MODULES], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl + +pkg_failed=no +AC_MSG_CHECKING([for $1]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + ifelse([$4], , [AC_MSG_ERROR(dnl +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +_PKG_TEXT +])], + [AC_MSG_RESULT([no]) + $4]) +elif test $pkg_failed = untried; then + ifelse([$4], , [AC_MSG_FAILURE(dnl +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +_PKG_TEXT + +To get pkg-config, see .])], + [$4]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) + ifelse([$3], , :, [$3]) +fi[]dnl +])# PKG_CHECK_MODULES +# Configure paths for SDL +# Sam Lantinga 9/21/99 +# stolen from Manish Singh +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +# serial 1 + +dnl AM_PATH_SDL2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS +dnl +AC_DEFUN([AM_PATH_SDL2], +[dnl +dnl Get the cflags and libraries from the sdl2-config script +dnl +AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], + sdl_prefix="$withval", sdl_prefix="") +AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], + sdl_exec_prefix="$withval", sdl_exec_prefix="") +AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], + , enable_sdltest=yes) + + min_sdl_version=ifelse([$1], ,2.0.0,$1) + + if test "x$sdl_prefix$sdl_exec_prefix" = x ; then + PKG_CHECK_MODULES([SDL], [sdl2 >= $min_sdl_version], + [sdl_pc=yes], + [sdl_pc=no]) + else + sdl_pc=no + if test x$sdl_exec_prefix != x ; then + sdl_config_args="$sdl_config_args --exec-prefix=$sdl_exec_prefix" + if test x${SDL2_CONFIG+set} != xset ; then + SDL2_CONFIG=$sdl_exec_prefix/bin/sdl2-config + fi + fi + if test x$sdl_prefix != x ; then + sdl_config_args="$sdl_config_args --prefix=$sdl_prefix" + if test x${SDL2_CONFIG+set} != xset ; then + SDL2_CONFIG=$sdl_prefix/bin/sdl2-config + fi + fi + fi + + if test "x$sdl_pc" = xyes ; then + no_sdl="" + SDL2_CONFIG="pkg-config sdl2" + else + as_save_PATH="$PATH" + if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then + PATH="$prefix/bin:$prefix/usr/bin:$PATH" + fi + AC_PATH_PROG(SDL2_CONFIG, sdl2-config, no, [$PATH]) + PATH="$as_save_PATH" + AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) + no_sdl="" + + if test "$SDL2_CONFIG" = "no" ; then + no_sdl=yes + else + SDL_CFLAGS=`$SDL2_CONFIG $sdl_config_args --cflags` + SDL_LIBS=`$SDL2_CONFIG $sdl_config_args --libs` + + sdl_major_version=`$SDL2_CONFIG $sdl_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + sdl_minor_version=`$SDL2_CONFIG $sdl_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + sdl_micro_version=`$SDL2_CONFIG $sdl_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_sdltest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_CXXFLAGS="$CXXFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $SDL_CFLAGS" + CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" +dnl +dnl Now check if the installed SDL is sufficiently new. (Also sanity +dnl checks the results of sdl2-config to some extent +dnl + rm -f conf.sdltest + AC_TRY_RUN([ +#include +#include +#include +#include "SDL.h" + +char* +my_strdup (char *str) +{ + char *new_str; + + if (str) + { + new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); + strcpy (new_str, str); + } + else + new_str = NULL; + + return new_str; +} + +int main (int argc, char *argv[]) +{ + int major, minor, micro; + char *tmp_version; + + /* This hangs on some systems (?) + system ("touch conf.sdltest"); + */ + { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = my_strdup("$min_sdl_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_sdl_version"); + exit(1); + } + + if (($sdl_major_version > major) || + (($sdl_major_version == major) && ($sdl_minor_version > minor)) || + (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'sdl2-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); + printf("*** of SDL required is %d.%d.%d. If sdl2-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If sdl2-config was wrong, set the environment variable SDL2_CONFIG\n"); + printf("*** to point to the correct copy of sdl2-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + CXXFLAGS="$ac_save_CXXFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_sdl" = x ; then + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + fi + fi + if test "x$no_sdl" = x ; then + ifelse([$2], , :, [$2]) + else + if test "$SDL2_CONFIG" = "no" ; then + echo "*** The sdl2-config script installed by SDL could not be found" + echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the SDL2_CONFIG environment variable to the" + echo "*** full path to sdl2-config." + else + if test -f conf.sdltest ; then + : + else + echo "*** Could not run SDL test program, checking why..." + CFLAGS="$CFLAGS $SDL_CFLAGS" + CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" + AC_TRY_LINK([ +#include +#include "SDL.h" + +int main(int argc, char *argv[]) +{ return 0; } +#undef main +#define main K_and_R_C_main +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding SDL or finding the wrong" + echo "*** version of SDL. If it is not finding SDL, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means SDL was incorrectly installed" + echo "*** or that you have moved SDL since it was installed. In the latter case, you" + echo "*** may want to edit the sdl2-config script: $SDL2_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + CXXFLAGS="$ac_save_CXXFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + SDL_CFLAGS="" + SDL_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(SDL_CFLAGS) + AC_SUBST(SDL_LIBS) + rm -f conf.sdltest +]) +# Configure paths for SMPEG +# Nicolas Vignal 11/19/2000 +# stolen from Sam Lantinga +# stolen from Manish Singh +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_SMPEG2([MINIMUM-VERSION, [ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]]) +dnl Test for SMPEG, and define SMPEG_CFLAGS and SMPEG_LIBS +dnl +AC_DEFUN([AM_PATH_SMPEG2], +[dnl +dnl Get the cflags and libraries from the smpeg2-config script +dnl +AC_ARG_WITH([smpeg-prefix], + AS_HELP_STRING([--with-smpeg-prefix=PFX], + [Prefix where SMPEG is installed (optional)]), + [smpeg_prefix="$withval"], [smpeg_prefix=""]) +AC_ARG_WITH([smpeg-exec-prefix], + AS_HELP_STRING([--with-smpeg-exec-prefix=PFX], + [Exec prefix where SMPEG is installed (optional)]), + [smpeg_exec_prefix="$withval"], [smpeg_exec_prefix=""]) +AC_ARG_ENABLE([smpegtest], + AS_HELP_STRING([--disable-smpegtest], + [Do not try to compile and run a test SMPEG program]), + [], [enable_smpegtest=yes]) + + if test x$smpeg_exec_prefix != x ; then + smpeg_args="$smpeg_args --exec-prefix=$smpeg_exec_prefix" + if test x${SMPEG_CONFIG+set} != xset ; then + SMPEG_CONFIG=$smpeg_exec_prefix/bin/smpeg2-config + fi + fi + if test x$smpeg_prefix != x ; then + smpeg_args="$smpeg_args --prefix=$smpeg_prefix" + if test x${SMPEG_CONFIG+set} != xset ; then + SMPEG_CONFIG=$smpeg_prefix/bin/smpeg2-config + fi + fi + + AC_PATH_PROG([SMPEG_CONFIG], [smpeg2-config], [no]) + min_smpeg_version=ifelse([$1], [], [2.0.0], [$1]) + AC_MSG_CHECKING([for SMPEG - version >= $min_smpeg_version]) + no_smpeg="" + if test "$SMPEG_CONFIG" = "no" ; then + no_smpeg=yes + else + SMPEG_CFLAGS=`$SMPEG_CONFIG $smpegconf_args --cflags` + SMPEG_LIBS=`$SMPEG_CONFIG $smpegconf_args --libs` + + smpeg_major_version=`$SMPEG_CONFIG $smpeg_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + smpeg_minor_version=`$SMPEG_CONFIG $smpeg_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + smpeg_micro_version=`$SMPEG_CONFIG $smpeg_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_smpegtest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $SMPEG_CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SMPEG_LIBS $SDL_LIBS" +dnl +dnl Now check if the installed SMPEG is sufficiently new. (Also sanity +dnl checks the results of smpeg2-config to some extent +dnl + rm -f conf.smpegtest + AC_RUN_IFELSE([AC_LANG_SOURCE([[ +#include +#include +#include +#include "smpeg.h" + +char* +my_strdup (char *str) +{ + char *new_str; + + if (str) + { + new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); + strcpy (new_str, str); + } + else + new_str = NULL; + + return new_str; +} + +int main (int argc, char *argv[]) +{ + int major, minor, micro; + char *tmp_version; + + /* This hangs on some systems (?) + system ("touch conf.smpegtest"); + */ + { FILE *fp = fopen("conf.smpegtest", "a"); if ( fp ) fclose(fp); } + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = my_strdup("$min_smpeg_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_smpeg_version"); + exit(1); + } + + if (($smpeg_major_version > major) || + (($smpeg_major_version == major) && ($smpeg_minor_version > minor)) || + (($smpeg_major_version == major) && ($smpeg_minor_version == minor) && ($smpeg_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'smpeg2-config --version' returned %d.%d.%d, but the minimum version\n", $smpeg_major_version, $smpeg_minor_version, $smpeg_micro_version); + printf("*** of SMPEG required is %d.%d.%d. If smpeg2-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If smpeg2-config was wrong, set the environment variable SMPEG_CONFIG\n"); + printf("*** to point to the correct copy of smpeg2-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +]])],[],[no_smpeg=yes], [echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_smpeg" = x ; then + AC_MSG_RESULT([yes]) + ifelse([$2], [], [:], [$2]) + else + AC_MSG_RESULT([no]) + if test "$SMPEG_CONFIG" = "no" ; then + echo "*** The smpeg2-config script installed by SMPEG could not be found" + echo "*** If SMPEG was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the SMPEG_CONFIG environment variable to the" + echo "*** full path to smpeg2-config." + else + if test -f conf.smpegtest ; then + : + else + echo "*** Could not run SMPEG test program, checking why..." + CFLAGS="$CFLAGS $SMPEG_CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SMPEG_LIBS $SDL_LIBS" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include +#include "smpeg.h" +]], + [[ return 0; ]])], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding SMPEG or finding the wrong" + echo "*** version of SMPEG. If it is not finding SMPEG, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means SMPEG was incorrectly installed" + echo "*** or that you have moved SMPEG since it was installed. In the latter case, you" + echo "*** may want to edit the smpeg2-config script: $SMPEG_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + SMPEG_CFLAGS="" + SMPEG_LIBS="" + ifelse([$3], [], [:], [$3]) + fi + AC_SUBST([SMPEG_CFLAGS]) + AC_SUBST([SMPEG_LIBS]) + rm -f conf.smpegtest +]) diff --git a/build-scripts/config.guess b/build-scripts/config.guess old file mode 100755 new file mode 100644 index ddb3622..a744844 100644 --- a/build-scripts/config.guess +++ b/build-scripts/config.guess @@ -1,14 +1,12 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011, 2012 Free Software Foundation, Inc. - -timestamp='2012-08-14' +# Copyright 1992-2017 Free Software Foundation, Inc. + +timestamp='2017-08-08' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -22,19 +20,17 @@ # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Originally written by Per Bothner. Please send patches (context -# diff format) to and include a ChangeLog -# entry. +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). # -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# +# Please send patches to . + me=`echo "$0" | sed -e 's,.*/,,'` @@ -54,9 +50,7 @@ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 -Free Software Foundation, Inc. +Copyright 1992-2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -138,6 +132,27 @@ UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown +case "${UNAME_SYSTEM}" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval $set_cc_for_build + cat <<-EOF > $dummy.c + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + ;; +esac + # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in @@ -153,19 +168,29 @@ # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + /sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || \ + echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; + earmv*) + arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` + machine=${arch}${endian}-unknown + ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. + # to ELF recently (or will in the future) and ABI. case "${UNAME_MACHINE_ARCH}" in + earm*) + os=netbsdelf + ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ @@ -182,6 +207,13 @@ os=netbsd ;; esac + # Determine ABI tags. + case "${UNAME_MACHINE_ARCH}" in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + ;; + esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need @@ -192,13 +224,13 @@ release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" + echo "${machine}-${os}${release}${abi}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` @@ -208,6 +240,10 @@ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE} + exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; @@ -219,6 +255,12 @@ exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:Sortix:*:*) + echo ${UNAME_MACHINE}-unknown-sortix + exit ;; + *:Redox:*:*) + echo ${UNAME_MACHINE}-unknown-redox exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in @@ -236,42 +278,42 @@ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; + UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; + UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; + UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; + UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; + UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; + UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; + UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; + UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; + UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 @@ -306,7 +348,7 @@ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) + arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) @@ -344,16 +386,16 @@ exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build - SUN_ARCH="i386" + SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then - SUN_ARCH="x86_64" + SUN_ARCH=x86_64 fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` @@ -378,7 +420,7 @@ exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} @@ -564,8 +606,9 @@ else IBM_ARCH=powerpc fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi @@ -602,13 +645,13 @@ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in - 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 - 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi @@ -647,11 +690,11 @@ exit (0); } EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = "hppa2.0w" ] + if [ ${HP_ARCH} = hppa2.0w ] then eval $set_cc_for_build @@ -664,12 +707,12 @@ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then - HP_ARCH="hppa2.0w" + HP_ARCH=hppa2.0w else - HP_ARCH="hppa64" + HP_ARCH=hppa64 fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} @@ -774,14 +817,14 @@ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) - FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) - FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) @@ -797,10 +840,11 @@ UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; esac + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin @@ -811,7 +855,7 @@ *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; - i*:MSYS*:*) + *:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) @@ -859,21 +903,21 @@ exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in @@ -886,63 +930,60 @@ EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else - case `sed -n '/^Hardware/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - BCM2708) MANUFACTURER=raspberry;; - *) MANUFACTURER=unknown;; - esac if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo ${UNAME_MACHINE}-${MANUFACTURER}-linux-gnueabi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else - echo ${UNAME_MACHINE}-${MANUFACTURER}-linux-gnueabihf + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + e2k:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) - LIBC=gnu - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + k1om:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build @@ -961,54 +1002,69 @@ #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; - or32:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + mips64el:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + openrisc*:Linux:*:*) + echo or1k-unknown-linux-${LIBC} + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) - echo sparc-unknown-linux-gnu + echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu + echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; + PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; + PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; + *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu + echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu + echo powerpc-unknown-linux-${LIBC} + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-${LIBC} + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-${LIBC} + exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux + echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-gnu + echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -1084,7 +1140,7 @@ # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configury will decide that + # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; @@ -1233,6 +1289,9 @@ SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux${UNAME_RELEASE} + exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; @@ -1241,24 +1300,43 @@ exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - i386) - eval $set_cc_for_build - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - UNAME_PROCESSOR="x86_64" - fi - fi ;; - unknown) UNAME_PROCESSOR=powerpc ;; - esac + eval $set_cc_for_build + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then + if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi @@ -1267,14 +1345,17 @@ *:QNX:*:4*) echo i386-pc-qnx exit ;; - NEO-?:NONSTOP_KERNEL:*:*) + NEO-*:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; - NSR-?:NONSTOP_KERNEL:*:*) + NSR-*:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + NSX-*:NONSTOP_KERNEL:*:*) + echo nsx-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux @@ -1289,7 +1370,7 @@ # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = "386"; then + if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" @@ -1331,7 +1412,7 @@ echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos @@ -1342,171 +1423,25 @@ x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs + exit ;; esac - -eval $set_cc_for_build -cat >$dummy.c < -# include -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif - -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif - -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} -EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - c34*) - echo c34-convex-bsd - exit ;; - c38*) - echo c38-convex-bsd - exit ;; - c4*) - echo c4-convex-bsd - exit ;; - esac -fi cat >&2 < in order to provide the needed -information to handle your system. + http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub + +If $0 has already been updated, send the following data and any +information you think might be pertinent to config-patches@gnu.org to +provide the necessary information to handle your system. config.guess timestamp = $timestamp diff --git a/build-scripts/config.sub b/build-scripts/config.sub old file mode 100755 new file mode 100644 index ce5e0e6..dcf4133 100644 --- a/build-scripts/config.sub +++ b/build-scripts/config.sub @@ -1,24 +1,18 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -# 2011, 2012 Free Software Foundation, Inc. - -timestamp='2012-08-18' - -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or +# Copyright 1992-2017 Free Software Foundation, Inc. + +timestamp='2017-04-02' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . @@ -26,11 +20,12 @@ # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Please send patches to . Submit a context -# diff and a properly formatted GNU ChangeLog entry. +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). + + +# Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. @@ -38,7 +33,7 @@ # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -58,8 +53,7 @@ me=`echo "$0" | sed -e 's,.*/,,'` usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. @@ -73,9 +67,7 @@ version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, -2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 -Free Software Foundation, Inc. +Copyright 1992-2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -124,8 +116,8 @@ case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | \ - kopensolaris*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ + kopensolaris*-gnu* | cloudabi*-eabi* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` @@ -156,7 +148,7 @@ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze) + -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; @@ -259,21 +251,25 @@ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ - | be32 | be64 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | ba \ + | be32 | be64 \ | bfin \ - | c4x | clipper \ + | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ - | epiphany \ - | fido | fr30 | frv \ + | e2k | epiphany \ + | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ - | i370 | i860 | i960 | ia64 \ + | i370 | i860 | i960 | ia16 | ia64 \ | ip2k | iq2000 \ + | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore | mep | metag \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ @@ -287,26 +283,30 @@ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ - | nios | nios2 \ + | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ - | open8 \ - | or32 \ + | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ | pyramid \ + | riscv32 | riscv64 \ | rl78 | rx \ | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ @@ -314,6 +314,8 @@ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | visium \ + | wasm32 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) @@ -328,7 +330,10 @@ c6x) basic_machine=tic6x-unknown ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; @@ -383,26 +388,29 @@ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ + | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | clipper-* | craynv-* | cydra-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ + | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ + | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ | ip2k-* | iq2000-* \ + | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ @@ -416,28 +424,34 @@ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ + | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ | pyramid-* \ + | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ @@ -445,6 +459,8 @@ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ + | visium-* \ + | wasm32-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ @@ -521,6 +537,9 @@ basic_machine=i386-pc os=-aros ;; + asmjs) + basic_machine=asmjs-unknown + ;; aux) basic_machine=m68k-apple os=-aux @@ -640,6 +659,14 @@ dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 + ;; + e500v[12]) + basic_machine=powerpc-unknown + os=$os"spe" + ;; + e500v[12]-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + os=$os"spe" ;; ebmon29k) basic_machine=a29k-amd @@ -782,6 +809,9 @@ basic_machine=m68k-isi os=-sysv ;; + leon-*|leon[3-9]-*) + basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` + ;; m68knommu) basic_machine=m68k-unknown os=-linux @@ -801,7 +831,7 @@ basic_machine=ns32k-utek os=-sysv ;; - microblaze) + microblaze*) basic_machine=microblaze-xilinx ;; mingw64) @@ -809,7 +839,7 @@ os=-mingw64 ;; mingw32) - basic_machine=i386-pc + basic_machine=i686-pc os=-mingw32 ;; mingw32ce) @@ -837,6 +867,10 @@ basic_machine=powerpc-unknown os=-morphos ;; + moxiebox) + basic_machine=moxie-unknown + os=-moxiebox + ;; msdos) basic_machine=i386-pc os=-msdos @@ -845,7 +879,7 @@ basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) - basic_machine=i386-pc + basic_machine=i686-pc os=-msys ;; mvs) @@ -933,6 +967,9 @@ nsr-tandem) basic_machine=nsr-tandem ;; + nsx-tandem) + basic_machine=nsx-tandem + ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf @@ -1017,7 +1054,7 @@ ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - ppcle | powerpclittle | ppc-le | powerpc-little) + ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) @@ -1027,7 +1064,7 @@ ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) + ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) @@ -1040,7 +1077,11 @@ basic_machine=i586-unknown os=-pw32 ;; - rdos) + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) basic_machine=i386-pc os=-rdos ;; @@ -1223,6 +1264,9 @@ vxworks29k) basic_machine=a29k-wrs os=-vxworks + ;; + wasm32) + basic_machine=wasm32-unknown ;; w65*) basic_machine=w65-wdc @@ -1367,29 +1411,30 @@ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* \ + | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ + | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -bitrig* | -openbsd* | -solidbsd* \ + | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ + | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* \ + | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ + | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1437,6 +1482,9 @@ -os400*) os=-os400 ;; + -cegcc*) + os=-cegcc + ;; -wince*) os=-wince ;; @@ -1518,9 +1566,6 @@ ;; -aros*) os=-aros - ;; - -kaos*) - os=-kaos ;; -zvmoe) os=-zvmoe @@ -1534,6 +1579,10 @@ -pnacl*) os=-pnacl ;; + -ios) + ;; + -emscripten*) + ;; -none) ;; *) @@ -1574,6 +1623,9 @@ c4x-* | tic4x-*) os=-coff ;; + c8051-*) + os=-elf + ;; hexagon-*) os=-elf ;; @@ -1625,6 +1677,9 @@ ;; sparc-* | *-sun) os=-sunos4.1.1 + ;; + pru-*) + os=-elf ;; *-be) os=-beos diff --git a/configure b/configure index 7c45b7f..554ed55 100755 --- a/configure +++ b/configure @@ -919,6 +919,9 @@ with_smpeg_exec_prefix enable_smpegtest enable_music_mp3_mad_gpl +enable_music_mp3_mad_gpl_dithering +enable_music_mp3_mpg123 +enable_music_mp3_mpg123_shared ' ac_precious_vars='build_alias host_alias @@ -1583,12 +1586,18 @@ dynamically load FLAC library [[default=yes]] --enable-music-mp3 enable MP3 music [[default=yes]] --enable-music-mp3-smpeg - enable MP3 music via smpeg [[default=yes]] + enable MP3 music via smpeg [[default=no]] --enable-music-mp3-smpeg-shared dynamically load smpeg library [[default=yes]] --disable-smpegtest Do not try to compile and run a test SMPEG program --enable-music-mp3-mad-gpl enable MP3 music via libmad GPL code [[default=no]] + --enable-music-mp3-mad-gpl-dithering + enable MP3 music via libmad GPL code [[default=yes]] + --enable-music-mp3-mpg123 + enable MP3 music via libmpg123 [[default=yes]] + --enable-music-mp3-mpg123-shared + dynamically load libmpg123 library [[default=yes]] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -2439,9 +2448,9 @@ # MAJOR_VERSION=2 MINOR_VERSION=0 -MICRO_VERSION=1 -INTERFACE_AGE=1 -BINARY_AGE=1 +MICRO_VERSION=2 +INTERFACE_AGE=0 +BINARY_AGE=2 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION @@ -3921,13 +3930,13 @@ else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:3924: $ac_compile\"" >&5) + (eval echo "\"\$as_me:3933: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:3927: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:3936: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:3930: output\"" >&5) + (eval echo "\"\$as_me:3939: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -5138,7 +5147,7 @@ ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 5141 "configure"' > conftest.$ac_ext + echo '#line 5150 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -5210,7 +5219,10 @@ x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; - ppc*-*linux*|powerpc*-*linux*) + powerpc64le-*linux*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc64-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) @@ -6965,11 +6977,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6968: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6980: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6972: \$? = $ac_status" >&5 + echo "$as_me:6984: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7304,11 +7316,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7307: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7319: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:7311: \$? = $ac_status" >&5 + echo "$as_me:7323: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -7409,11 +7421,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7412: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7424: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7416: \$? = $ac_status" >&5 + echo "$as_me:7428: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -7464,11 +7476,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:7467: $lt_compile\"" >&5) + (eval echo "\"\$as_me:7479: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:7471: \$? = $ac_status" >&5 + echo "$as_me:7483: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9833,7 +9845,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9836 "configure" +#line 9848 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -9929,7 +9941,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 9932 "configure" +#line 9944 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11080,20 +11092,12 @@ fi ;; *) - SOURCES="" EXE="" ;; esac # Standard C sources -SOURCES="$SOURCES \ -$srcdir/effect_position.c \ -$srcdir/effect_stereoreverse.c \ -$srcdir/effects_internal.c \ -$srcdir/load_aiff.c \ -$srcdir/load_voc.c \ -$srcdir/mixer.c \ -$srcdir/music.c" +SOURCES=`ls $srcdir/*.c | fgrep -v playwave.c | fgrep -v playmus.c` base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'` @@ -11157,7 +11161,7 @@ done } -SDL_VERSION=2.0.0 +SDL_VERSION=2.0.7 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then @@ -11716,8 +11720,7 @@ enable_music_cmd=no fi if test "x$enable_music_cmd" != xno; then - SOURCES="$SOURCES $srcdir/music_cmd.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DCMD_MUSIC" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_CMD" fi fi @@ -11729,8 +11732,7 @@ fi if test x$enable_music_wave = xyes; then - SOURCES="$SOURCES $srcdir/wavestream.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DWAV_MUSIC" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_WAV" fi # Check whether --enable-music-mod was given. @@ -11823,9 +11825,9 @@ fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for have_libmodplug_lib=yes in -lmodplug" >&5 -$as_echo_n "checking for have_libmodplug_lib=yes in -lmodplug... " >&6; } -if ${ac_cv_lib_modplug_have_libmodplug_lib_yes+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ModPlug_Load in -lmodplug" >&5 +$as_echo_n "checking for ModPlug_Load in -lmodplug... " >&6; } +if ${ac_cv_lib_modplug_ModPlug_Load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -11839,33 +11841,28 @@ #ifdef __cplusplus extern "C" #endif -char have_libmodplug_lib=yes (); +char ModPlug_Load (); int main () { -return have_libmodplug_lib=yes (); +return ModPlug_Load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_modplug_have_libmodplug_lib_yes=yes -else - ac_cv_lib_modplug_have_libmodplug_lib_yes=no + ac_cv_lib_modplug_ModPlug_Load=yes +else + ac_cv_lib_modplug_ModPlug_Load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_modplug_have_libmodplug_lib_yes" >&5 -$as_echo "$ac_cv_lib_modplug_have_libmodplug_lib_yes" >&6; } -if test "x$ac_cv_lib_modplug_have_libmodplug_lib_yes" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBMODPLUG 1 -_ACEOF - - LIBS="-lmodplug $LIBS" - +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_modplug_ModPlug_Load" >&5 +$as_echo "$ac_cv_lib_modplug_ModPlug_Load" >&6; } +if test "x$ac_cv_lib_modplug_ModPlug_Load" = xyes; then : + have_libmodplug_lib=yes fi @@ -11876,9 +11873,9 @@ fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for have_libmodplug_lib=yes in -lmodplug" >&5 -$as_echo_n "checking for have_libmodplug_lib=yes in -lmodplug... " >&6; } -if ${ac_cv_lib_modplug_have_libmodplug_lib_yes+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ModPlug_Load in -lmodplug" >&5 +$as_echo_n "checking for ModPlug_Load in -lmodplug... " >&6; } +if ${ac_cv_lib_modplug_ModPlug_Load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -11892,33 +11889,28 @@ #ifdef __cplusplus extern "C" #endif -char have_libmodplug_lib=yes (); +char ModPlug_Load (); int main () { -return have_libmodplug_lib=yes (); +return ModPlug_Load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_modplug_have_libmodplug_lib_yes=yes -else - ac_cv_lib_modplug_have_libmodplug_lib_yes=no + ac_cv_lib_modplug_ModPlug_Load=yes +else + ac_cv_lib_modplug_ModPlug_Load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_modplug_have_libmodplug_lib_yes" >&5 -$as_echo "$ac_cv_lib_modplug_have_libmodplug_lib_yes" >&6; } -if test "x$ac_cv_lib_modplug_have_libmodplug_lib_yes" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBMODPLUG 1 -_ACEOF - - LIBS="-lmodplug $LIBS" - +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_modplug_ModPlug_Load" >&5 +$as_echo "$ac_cv_lib_modplug_ModPlug_Load" >&6; } +if test "x$ac_cv_lib_modplug_ModPlug_Load" = xyes; then : + have_libmodplug_lib=yes fi @@ -11948,8 +11940,7 @@ fi ;; esac - SOURCES="$SOURCES $srcdir/*_modplug.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_MUSIC $MODPLUG_CFLAGS" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MODPLUG $MODPLUG_CFLAGS" if test x$enable_music_mod_modplug_shared = xyes && test x$modplug_lib != x; then echo "-- dynamic libmodplug -> $modplug_lib" EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_DYNAMIC=\\\"$modplug_lib\\\"" @@ -12027,7 +12018,7 @@ CFLAGS_SAVED="$CFLAGS" LIBS_SAVED="$LIBS" - CFLAGS="$CFLAGS -DLIBMIKMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`" + CFLAGS="$CFLAGS `$LIBMIKMOD_CONFIG --cflags`" LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`" have_libmikmod=yes { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libmikmod - version >= $libmikmod_ver" >&5 @@ -12080,11 +12071,10 @@ fi ;; esac - SOURCES="$SOURCES $srcdir/*_mod.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MIKMOD `$LIBMIKMOD_CONFIG --cflags`" if test x$enable_music_mod_mikmod_shared = xyes && test x$mikmod_lib != x; then echo "-- dynamic libmikmod -> $mikmod_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_DYNAMIC=\\\"$mikmod_lib\\\"" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMIKMOD_DYNAMIC=\\\"$mikmod_lib\\\"" else EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`" fi @@ -12107,7 +12097,7 @@ fi if test x$enable_music_midi = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMID_MUSIC" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID" # Check whether --enable-music-midi-timidity was given. if test "${enable_music_midi_timidity+set}" = set; then : enableval=$enable_music_midi_timidity; @@ -12116,7 +12106,7 @@ fi if test x$enable_music_midi_timidity = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_TIMIDITY_MIDI -I\$(srcdir)/timidity" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_TIMIDITY -I\$(srcdir)/timidity" SOURCES="$SOURCES $srcdir/timidity/*.c" fi # Check whether --enable-music-midi-native was given. @@ -12146,10 +12136,10 @@ ;; esac if test x$use_music_midi_native = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi" SOURCES="$SOURCES $srcdir/native_midi/*.c" elif test x$use_music_midi_native = xyes_cpp; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi" SOURCES="$SOURCES $srcdir/native_midi/*.c" SOURCES_CXX="$SOURCES_CXX $srcdir/native_midi/*.cpp" fi @@ -12231,10 +12221,9 @@ fi ;; esac - SOURCES="$SOURCES $srcdir/dynamic_fluidsynth.c $srcdir/fluidsynth.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_FLUIDSYNTH_MIDI" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_FLUIDSYNTH" if test x$enable_music_midi_fluidsynth_shared = xyes && test x$fluidsynth_lib != x; then - echo "-- dynamic libfluidsyth -> $fluidsynth_lib" + echo "-- dynamic libfluidsynth -> $fluidsynth_lib" EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLUIDSYNTH_DYNAMIC=\\\"$fluidsynth_lib\\\"" else EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lfluidsynth" @@ -12341,8 +12330,7 @@ fi ;; esac - SOURCES="$SOURCES $srcdir/*_ogg.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC -DOGG_USE_TREMOR" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG -DOGG_USE_TREMOR" if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then echo "-- dynamic libvorbisidec -> $ogg_lib" EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\"" @@ -12419,8 +12407,7 @@ fi ;; esac - SOURCES="$SOURCES $srcdir/*_ogg.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG" if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then echo "-- dynamic libvorbisfile -> $ogg_lib" EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\"" @@ -12555,8 +12542,7 @@ fi ;; esac - SOURCES="$SOURCES $srcdir/*_flac.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_MUSIC" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_FLAC" if test x$enable_music_flac_shared = xyes && test x$flac_lib != x; then echo "-- dynamic libFLAC -> $flac_lib" EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_DYNAMIC=\\\"$flac_lib\\\"" @@ -12584,7 +12570,7 @@ if test "${enable_music_mp3_smpeg+set}" = set; then : enableval=$enable_music_mp3_smpeg; else - enable_music_mp3_smpeg=yes + enable_music_mp3_smpeg=no fi # Check whether --enable-music-mp3-smpeg-shared was given. @@ -12848,11 +12834,10 @@ smpeg_lib=`find_lib "libsmpeg2*.so.*"` ;; esac - SOURCES="$SOURCES $srcdir/*_mp3.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MUSIC $SMPEG_CFLAGS" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_SMPEG $SMPEG_CFLAGS" if test x$enable_music_mp3_smpeg_shared = xyes && test x$smpeg_lib != x; then echo "-- dynamic libsmpeg -> $smpeg_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_DYNAMIC=\\\"$smpeg_lib\\\"" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DSMPEG_DYNAMIC=\\\"$smpeg_lib\\\"" else EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SMPEG_LIBS" fi @@ -12869,6 +12854,13 @@ enable_music_mp3_mad_gpl=no fi +# Check whether --enable-music-mp3-mad-gpl-dithering was given. +if test "${enable_music_mp3_mad_gpl_dithering+set}" = set; then : + enableval=$enable_music_mp3_mad_gpl_dithering; +else + enable_music_mp3_mad_gpl_dithering=yes +fi + if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_mad_gpl = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libmad headers" >&5 $as_echo_n "checking for libmad headers... " >&6; } @@ -12896,13 +12888,12 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_libmad" >&5 $as_echo "$have_libmad" >&6; } if test x$have_libmad = xyes; then - SOURCES="$SOURCES $srcdir/music_mad.c" - if echo "$SOURCES" | grep "load_mp3.c" >/dev/null; then - : - else - SOURCES="$SOURCES $srcdir/load_mp3.c" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD" + if test x$enable_music_mp3_mad_gpl_dithering = xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Using GPL libmad and MP3 dithering routines, this build of SDL_mixer is now under the GPL" >&5 +$as_echo "$as_me: WARNING: *** Using GPL libmad and MP3 dithering routines, this build of SDL_mixer is now under the GPL" >&2;} + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD_GPL_DITHERING" fi - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MAD_MUSIC" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad" else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find MAD library (http://www.underbit.com/products/mad/)" >&5 @@ -12910,7 +12901,98 @@ fi fi -if test x$have_smpeg != xyes -a x$have_libmad != xyes; then +# Check whether --enable-music-mp3-mpg123 was given. +if test "${enable_music_mp3_mpg123+set}" = set; then : + enableval=$enable_music_mp3_mpg123; +else + enable_music_mp3_mpg123=yes +fi + +# Check whether --enable-music-mp3-mpg123-shared was given. +if test "${enable_music_mp3_mpg123_shared+set}" = set; then : + enableval=$enable_music_mp3_mpg123_shared; +else + enable_music_mp3_mpg123_shared=yes +fi + +if test x$enable_music_mp3_mpg123 = xyes; then + ac_fn_c_check_header_mongrel "$LINENO" "mpg123.h" "ac_cv_header_mpg123_h" "$ac_includes_default" +if test "x$ac_cv_header_mpg123_h" = xyes; then : + have_mpg123_hdr=yes +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mpg123_replace_reader_handle in -lmpg123" >&5 +$as_echo_n "checking for mpg123_replace_reader_handle in -lmpg123... " >&6; } +if ${ac_cv_lib_mpg123_mpg123_replace_reader_handle+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lmpg123 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char mpg123_replace_reader_handle (); +int +main () +{ +return mpg123_replace_reader_handle (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_mpg123_mpg123_replace_reader_handle=yes +else + ac_cv_lib_mpg123_mpg123_replace_reader_handle=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mpg123_mpg123_replace_reader_handle" >&5 +$as_echo "$ac_cv_lib_mpg123_mpg123_replace_reader_handle" >&6; } +if test "x$ac_cv_lib_mpg123_mpg123_replace_reader_handle" = xyes; then : + have_mpg123_lib=yes +fi + + if test x$have_mpg123_hdr = xyes -a x$have_mpg123_lib = xyes; then + have_mpg123=yes + case "$host" in + *-*-darwin*) + mpg123_lib=`find_lib libmpg123.dylib` + ;; + *-*-cygwin* | *-*-mingw32*) + mpg123_lib=`find_lib "libmpg123*.dll"` + ;; + *) + mpg123_lib=`find_lib "libmpg123.so.*"` + ;; + esac + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MPG123" + if test x$enable_music_mp3_mpg123_shared = xyes && test x$mpg123_lib != x; then + echo "-- dynamic libmpg123 -> $mpg123_lib" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMPG123_DYNAMIC=\\\"$mpg123_lib\\\"" + else + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmpg123" + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find mpg123 library (https://www.mpg123.de)" >&5 +$as_echo "$as_me: WARNING: *** Unable to find mpg123 library (https://www.mpg123.de)" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: mpg123 support disabled" >&5 +$as_echo "$as_me: WARNING: mpg123 support disabled" >&2;} + fi +fi + +if test x$have_smpeg = xyes -o x$have_libmad = xyes -o x$have_libmpg123; then + : +else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MP3 support disabled" >&5 $as_echo "$as_me: WARNING: MP3 support disabled" >&2;} fi diff --git a/configure.in b/configure.in index 77dc3fe..6aed16e 100644 --- a/configure.in +++ b/configure.in @@ -14,9 +14,9 @@ # MAJOR_VERSION=2 MINOR_VERSION=0 -MICRO_VERSION=1 -INTERFACE_AGE=1 -BINARY_AGE=1 +MICRO_VERSION=2 +INTERFACE_AGE=0 +BINARY_AGE=2 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION AC_SUBST(MAJOR_VERSION) @@ -130,20 +130,12 @@ fi ;; *) - SOURCES="" EXE="" ;; esac # Standard C sources -SOURCES="$SOURCES \ -$srcdir/effect_position.c \ -$srcdir/effect_stereoreverse.c \ -$srcdir/effects_internal.c \ -$srcdir/load_aiff.c \ -$srcdir/load_voc.c \ -$srcdir/mixer.c \ -$srcdir/music.c" +SOURCES=`ls $srcdir/*.c | fgrep -v playwave.c | fgrep -v playmus.c` dnl set this to use on systems that use lib64 instead of lib base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'` @@ -196,7 +188,7 @@ } dnl Check for SDL -SDL_VERSION=2.0.0 +SDL_VERSION=2.0.7 AM_PATH_SDL2($SDL_VERSION, :, AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!]) @@ -229,8 +221,7 @@ enable_music_cmd=no fi if test "x$enable_music_cmd" != xno; then - SOURCES="$SOURCES $srcdir/music_cmd.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DCMD_MUSIC" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_CMD" fi fi @@ -238,8 +229,7 @@ AC_HELP_STRING([--enable-music-wave], [enable streaming WAVE music [[default=yes]]]), [], [enable_music_wave=yes]) if test x$enable_music_wave = xyes; then - SOURCES="$SOURCES $srcdir/wavestream.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DWAV_MUSIC" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_WAV" fi AC_ARG_ENABLE([music-mod], @@ -258,7 +248,7 @@ have_libmodplug_lib=yes ], [dnl AC_CHECK_HEADER([libmodplug/modplug.h], [have_libmodplug_hdr=yes]) - AC_CHECK_LIB([modplug], [have_libmodplug_lib=yes]) + AC_CHECK_LIB([modplug], [ModPlug_Load], [have_libmodplug_lib=yes]) ]) if test x$have_libmodplug_hdr = xyes -a x$have_libmodplug_lib = xyes; then @@ -277,8 +267,7 @@ fi ;; esac - SOURCES="$SOURCES $srcdir/*_modplug.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_MUSIC $MODPLUG_CFLAGS" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MODPLUG $MODPLUG_CFLAGS" if test x$enable_music_mod_modplug_shared = xyes && test x$modplug_lib != x; then echo "-- dynamic libmodplug -> $modplug_lib" EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_DYNAMIC=\\\"$modplug_lib\\\"" @@ -307,7 +296,7 @@ CFLAGS_SAVED="$CFLAGS" LIBS_SAVED="$LIBS" - CFLAGS="$CFLAGS -DLIBMIKMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`" + CFLAGS="$CFLAGS `$LIBMIKMOD_CONFIG --cflags`" LIBS="$LIBS `$LIBMIKMOD_CONFIG --libs`" have_libmikmod=yes AC_MSG_CHECKING([for libmikmod - version >= $libmikmod_ver]) @@ -345,11 +334,10 @@ fi ;; esac - SOURCES="$SOURCES $srcdir/*_mod.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_MUSIC `$LIBMIKMOD_CONFIG --cflags`" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MOD_MIKMOD `$LIBMIKMOD_CONFIG --cflags`" if test x$enable_music_mod_mikmod_shared = xyes && test x$mikmod_lib != x; then echo "-- dynamic libmikmod -> $mikmod_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMOD_DYNAMIC=\\\"$mikmod_lib\\\"" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMIKMOD_DYNAMIC=\\\"$mikmod_lib\\\"" else EXTRA_LDFLAGS="$EXTRA_LDFLAGS `$LIBMIKMOD_CONFIG --libs`" fi @@ -366,12 +354,12 @@ AC_HELP_STRING([--enable-music-midi], [enable MIDI music [[default=yes]]]), [], [enable_music_midi=yes]) if test x$enable_music_midi = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMID_MUSIC" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID" AC_ARG_ENABLE([music-midi-timidity], AC_HELP_STRING([--enable-music-midi-timidity], [enable timidity MIDI output [[default=yes]]]), [], [enable_music_midi_timidity=yes]) if test x$enable_music_midi_timidity = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_TIMIDITY_MIDI -I\$(srcdir)/timidity" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_TIMIDITY -I\$(srcdir)/timidity" SOURCES="$SOURCES $srcdir/timidity/*.c" fi AC_ARG_ENABLE([music-midi-native], @@ -397,10 +385,10 @@ ;; esac if test x$use_music_midi_native = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi" SOURCES="$SOURCES $srcdir/native_midi/*.c" elif test x$use_music_midi_native = xyes_cpp; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_NATIVE_MIDI -I\$(srcdir)/native_midi" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_NATIVE -I\$(srcdir)/native_midi" SOURCES="$SOURCES $srcdir/native_midi/*.c" SOURCES_CXX="$SOURCES_CXX $srcdir/native_midi/*.cpp" fi @@ -430,10 +418,9 @@ fi ;; esac - SOURCES="$SOURCES $srcdir/dynamic_fluidsynth.c $srcdir/fluidsynth.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DUSE_FLUIDSYNTH_MIDI" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MID_FLUIDSYNTH" if test x$enable_music_midi_fluidsynth_shared = xyes && test x$fluidsynth_lib != x; then - echo "-- dynamic libfluidsyth -> $fluidsynth_lib" + echo "-- dynamic libfluidsynth -> $fluidsynth_lib" EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLUIDSYNTH_DYNAMIC=\\\"$fluidsynth_lib\\\"" else EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lfluidsynth" @@ -479,8 +466,7 @@ fi ;; esac - SOURCES="$SOURCES $srcdir/*_ogg.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC -DOGG_USE_TREMOR" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG -DOGG_USE_TREMOR" if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then echo "-- dynamic libvorbisidec -> $ogg_lib" EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\"" @@ -509,8 +495,7 @@ fi ;; esac - SOURCES="$SOURCES $srcdir/*_ogg.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_MUSIC" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_OGG" if test x$enable_music_ogg_shared = xyes && test x$ogg_lib != x; then echo "-- dynamic libvorbisfile -> $ogg_lib" EXTRA_CFLAGS="$EXTRA_CFLAGS -DOGG_DYNAMIC=\\\"$ogg_lib\\\"" @@ -569,8 +554,7 @@ fi ;; esac - SOURCES="$SOURCES $srcdir/*_flac.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_MUSIC" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_FLAC" if test x$enable_music_flac_shared = xyes && test x$flac_lib != x; then echo "-- dynamic libFLAC -> $flac_lib" EXTRA_CFLAGS="$EXTRA_CFLAGS -DFLAC_DYNAMIC=\\\"$flac_lib\\\"" @@ -589,8 +573,8 @@ [], enable_music_mp3=yes) AC_ARG_ENABLE(music-mp3-smpeg, -AC_HELP_STRING([--enable-music-mp3-smpeg], [enable MP3 music via smpeg [[default=yes]]]), - [], enable_music_mp3_smpeg=yes) +AC_HELP_STRING([--enable-music-mp3-smpeg], [enable MP3 music via smpeg [[default=no]]]), + [], enable_music_mp3_smpeg=no) AC_ARG_ENABLE([music-mp3-smpeg-shared], AC_HELP_STRING([--enable-music-mp3-smpeg-shared], [dynamically load smpeg library [[default=yes]]]), [], [enable_music_mp3_smpeg_shared=yes]) @@ -609,11 +593,10 @@ smpeg_lib=[`find_lib "libsmpeg2*.so.*"`] ;; esac - SOURCES="$SOURCES $srcdir/*_mp3.c" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MUSIC $SMPEG_CFLAGS" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_SMPEG $SMPEG_CFLAGS" if test x$enable_music_mp3_smpeg_shared = xyes && test x$smpeg_lib != x; then echo "-- dynamic libsmpeg -> $smpeg_lib" - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_DYNAMIC=\\\"$smpeg_lib\\\"" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DSMPEG_DYNAMIC=\\\"$smpeg_lib\\\"" else EXTRA_LDFLAGS="$EXTRA_LDFLAGS $SMPEG_LIBS" fi @@ -625,6 +608,9 @@ AC_ARG_ENABLE(music-mp3-mad-gpl, AC_HELP_STRING([--enable-music-mp3-mad-gpl], [enable MP3 music via libmad GPL code [[default=no]]]), [], [enable_music_mp3_mad_gpl=no]) +AC_ARG_ENABLE(music-mp3-mad-gpl-dithering, +AC_HELP_STRING([--enable-music-mp3-mad-gpl-dithering], [enable MP3 music via libmad GPL code [[default=yes]]]), + [], [enable_music_mp3_mad_gpl_dithering=yes]) if test x$enable_music_mp3 = xyes -a x$enable_music_mp3_mad_gpl = xyes; then AC_MSG_CHECKING(for libmad headers) have_libmad=no @@ -636,20 +622,55 @@ ]) AC_MSG_RESULT($have_libmad) if test x$have_libmad = xyes; then - SOURCES="$SOURCES $srcdir/music_mad.c" - if echo "$SOURCES" | grep "load_mp3.c" >/dev/null; then - : + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD" + if test x$enable_music_mp3_mad_gpl_dithering = xyes; then + AC_MSG_WARN([*** Using GPL libmad and MP3 dithering routines, this build of SDL_mixer is now under the GPL]) + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MAD_GPL_DITHERING" + fi + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad" + else + AC_MSG_WARN([*** Unable to find MAD library (http://www.underbit.com/products/mad/)]) + fi +fi + +AC_ARG_ENABLE(music-mp3-mpg123, +AC_HELP_STRING([--enable-music-mp3-mpg123], [enable MP3 music via libmpg123 [[default=yes]]]), + [], [enable_music_mp3_mpg123=yes]) +AC_ARG_ENABLE([music-mp3-mpg123-shared], +AC_HELP_STRING([--enable-music-mp3-mpg123-shared], [dynamically load libmpg123 library [[default=yes]]]), + [], [enable_music_mp3_mpg123_shared=yes]) +if test x$enable_music_mp3_mpg123 = xyes; then + AC_CHECK_HEADER([mpg123.h], [have_mpg123_hdr=yes]) + AC_CHECK_LIB([mpg123], [mpg123_replace_reader_handle], [have_mpg123_lib=yes]) + if test x$have_mpg123_hdr = xyes -a x$have_mpg123_lib = xyes; then + have_mpg123=yes + case "$host" in + *-*-darwin*) + mpg123_lib=[`find_lib libmpg123.dylib`] + ;; + *-*-cygwin* | *-*-mingw32*) + mpg123_lib=[`find_lib "libmpg123*.dll"`] + ;; + *) + mpg123_lib=[`find_lib "libmpg123.so.*"`] + ;; + esac + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMUSIC_MP3_MPG123" + if test x$enable_music_mp3_mpg123_shared = xyes && test x$mpg123_lib != x; then + echo "-- dynamic libmpg123 -> $mpg123_lib" + EXTRA_CFLAGS="$EXTRA_CFLAGS -DMPG123_DYNAMIC=\\\"$mpg123_lib\\\"" else - SOURCES="$SOURCES $srcdir/load_mp3.c" - fi - EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MAD_MUSIC" - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad" - else - AC_MSG_WARN([*** Unable to find MAD library (http://www.underbit.com/products/mad/)]) - fi -fi - -if test x$have_smpeg != xyes -a x$have_libmad != xyes; then + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmpg123" + fi + else + AC_MSG_WARN([*** Unable to find mpg123 library (https://www.mpg123.de)]) + AC_MSG_WARN([mpg123 support disabled]) + fi +fi + +if test x$have_smpeg = xyes -o x$have_libmad = xyes -o x$have_libmpg123; then + : +else AC_MSG_WARN([MP3 support disabled]) fi diff --git a/dynamic_flac.c b/dynamic_flac.c deleted file mode 100644 index cc728f2..0000000 --- a/dynamic_flac.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Implementation of the dynamic loading functionality for libFLAC. - ~ Austen Dicken (admin@cvpcs.org) -*/ - -#ifdef FLAC_MUSIC - -#include "SDL_loadso.h" -#include "SDL_mixer.h" -#include "dynamic_flac.h" - -flac_loader flac = { - 0, NULL -}; - -#ifdef FLAC_DYNAMIC -int Mix_InitFLAC() -{ - if ( flac.loaded == 0 ) { - flac.handle = SDL_LoadObject(FLAC_DYNAMIC); - if ( flac.handle == NULL ) { - return -1; - } - flac.FLAC__stream_decoder_new = - (FLAC__StreamDecoder *(*)()) - SDL_LoadFunction(flac.handle, "FLAC__stream_decoder_new"); - if ( flac.FLAC__stream_decoder_new == NULL ) { - SDL_UnloadObject(flac.handle); - return -1; - } - flac.FLAC__stream_decoder_delete = - (void (*)(FLAC__StreamDecoder *)) - SDL_LoadFunction(flac.handle, "FLAC__stream_decoder_delete"); - if ( flac.FLAC__stream_decoder_delete == NULL ) { - SDL_UnloadObject(flac.handle); - return -1; - } - flac.FLAC__stream_decoder_init_stream = - (FLAC__StreamDecoderInitStatus (*)( - FLAC__StreamDecoder *, - FLAC__StreamDecoderReadCallback, - FLAC__StreamDecoderSeekCallback, - FLAC__StreamDecoderTellCallback, - FLAC__StreamDecoderLengthCallback, - FLAC__StreamDecoderEofCallback, - FLAC__StreamDecoderWriteCallback, - FLAC__StreamDecoderMetadataCallback, - FLAC__StreamDecoderErrorCallback, - void *)) - SDL_LoadFunction(flac.handle, "FLAC__stream_decoder_init_stream"); - if ( flac.FLAC__stream_decoder_init_stream == NULL ) { - SDL_UnloadObject(flac.handle); - return -1; - } - flac.FLAC__stream_decoder_finish = - (FLAC__bool (*)(FLAC__StreamDecoder *)) - SDL_LoadFunction(flac.handle, "FLAC__stream_decoder_finish"); - if ( flac.FLAC__stream_decoder_finish == NULL ) { - SDL_UnloadObject(flac.handle); - return -1; - } - flac.FLAC__stream_decoder_flush = - (FLAC__bool (*)(FLAC__StreamDecoder *)) - SDL_LoadFunction(flac.handle, "FLAC__stream_decoder_flush"); - if ( flac.FLAC__stream_decoder_flush == NULL ) { - SDL_UnloadObject(flac.handle); - return -1; - } - flac.FLAC__stream_decoder_process_single = - (FLAC__bool (*)(FLAC__StreamDecoder *)) - SDL_LoadFunction(flac.handle, - "FLAC__stream_decoder_process_single"); - if ( flac.FLAC__stream_decoder_process_single == NULL ) { - SDL_UnloadObject(flac.handle); - return -1; - } - flac.FLAC__stream_decoder_process_until_end_of_metadata = - (FLAC__bool (*)(FLAC__StreamDecoder *)) - SDL_LoadFunction(flac.handle, - "FLAC__stream_decoder_process_until_end_of_metadata"); - if ( flac.FLAC__stream_decoder_process_until_end_of_metadata == NULL ) { - SDL_UnloadObject(flac.handle); - return -1; - } - flac.FLAC__stream_decoder_process_until_end_of_stream = - (FLAC__bool (*)(FLAC__StreamDecoder *)) - SDL_LoadFunction(flac.handle, - "FLAC__stream_decoder_process_until_end_of_stream"); - if ( flac.FLAC__stream_decoder_process_until_end_of_stream == NULL ) { - SDL_UnloadObject(flac.handle); - return -1; - } - flac.FLAC__stream_decoder_seek_absolute = - (FLAC__bool (*)(FLAC__StreamDecoder *, FLAC__uint64)) - SDL_LoadFunction(flac.handle, "FLAC__stream_decoder_seek_absolute"); - if ( flac.FLAC__stream_decoder_seek_absolute == NULL ) { - SDL_UnloadObject(flac.handle); - return -1; - } - flac.FLAC__stream_decoder_get_state = - (FLAC__StreamDecoderState (*)(const FLAC__StreamDecoder *decoder)) - SDL_LoadFunction(flac.handle, "FLAC__stream_decoder_get_state"); - if ( flac.FLAC__stream_decoder_get_state == NULL ) { - SDL_UnloadObject(flac.handle); - return -1; - } - } - ++flac.loaded; - - return 0; -} -void Mix_QuitFLAC() -{ - if ( flac.loaded == 0 ) { - return; - } - if ( flac.loaded == 1 ) { - SDL_UnloadObject(flac.handle); - } - --flac.loaded; -} -#else -int Mix_InitFLAC() -{ - if ( flac.loaded == 0 ) { -#ifdef __MACOSX__ - extern FLAC__StreamDecoder *FLAC__stream_decoder_new(void) __attribute__((weak_import)); - if ( FLAC__stream_decoder_new == NULL ) - { - /* Missing weakly linked framework */ - Mix_SetError("Missing FLAC.framework"); - return -1; - } -#endif // __MACOSX__ - - flac.FLAC__stream_decoder_new = FLAC__stream_decoder_new; - flac.FLAC__stream_decoder_delete = FLAC__stream_decoder_delete; - flac.FLAC__stream_decoder_init_stream = - FLAC__stream_decoder_init_stream; - flac.FLAC__stream_decoder_finish = FLAC__stream_decoder_finish; - flac.FLAC__stream_decoder_flush = FLAC__stream_decoder_flush; - flac.FLAC__stream_decoder_process_single = - FLAC__stream_decoder_process_single; - flac.FLAC__stream_decoder_process_until_end_of_metadata = - FLAC__stream_decoder_process_until_end_of_metadata; - flac.FLAC__stream_decoder_process_until_end_of_stream = - FLAC__stream_decoder_process_until_end_of_stream; - flac.FLAC__stream_decoder_seek_absolute = - FLAC__stream_decoder_seek_absolute; - flac.FLAC__stream_decoder_get_state = - FLAC__stream_decoder_get_state; - } - ++flac.loaded; - - return 0; -} -void Mix_QuitFLAC() -{ - if ( flac.loaded == 0 ) { - return; - } - if ( flac.loaded == 1 ) { - } - --flac.loaded; -} -#endif /* FLAC_DYNAMIC */ - -#endif /* FLAC_MUSIC */ diff --git a/dynamic_flac.h b/dynamic_flac.h deleted file mode 100644 index 75d7144..0000000 --- a/dynamic_flac.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - The following file defines all of the functions/objects used to dynamically - link to the libFLAC library. - ~ Austen Dicken (admin@cvpcs.org) -*/ - -#ifdef FLAC_MUSIC - -#include - -typedef struct { - int loaded; - void *handle; - FLAC__StreamDecoder *(*FLAC__stream_decoder_new)(); - void (*FLAC__stream_decoder_delete)(FLAC__StreamDecoder *decoder); - FLAC__StreamDecoderInitStatus (*FLAC__stream_decoder_init_stream)( - FLAC__StreamDecoder *decoder, - FLAC__StreamDecoderReadCallback read_callback, - FLAC__StreamDecoderSeekCallback seek_callback, - FLAC__StreamDecoderTellCallback tell_callback, - FLAC__StreamDecoderLengthCallback length_callback, - FLAC__StreamDecoderEofCallback eof_callback, - FLAC__StreamDecoderWriteCallback write_callback, - FLAC__StreamDecoderMetadataCallback metadata_callback, - FLAC__StreamDecoderErrorCallback error_callback, - void *client_data); - FLAC__bool (*FLAC__stream_decoder_finish)(FLAC__StreamDecoder *decoder); - FLAC__bool (*FLAC__stream_decoder_flush)(FLAC__StreamDecoder *decoder); - FLAC__bool (*FLAC__stream_decoder_process_single)( - FLAC__StreamDecoder *decoder); - FLAC__bool (*FLAC__stream_decoder_process_until_end_of_metadata)( - FLAC__StreamDecoder *decoder); - FLAC__bool (*FLAC__stream_decoder_process_until_end_of_stream)( - FLAC__StreamDecoder *decoder); - FLAC__bool (*FLAC__stream_decoder_seek_absolute)( - FLAC__StreamDecoder *decoder, - FLAC__uint64 sample); - FLAC__StreamDecoderState (*FLAC__stream_decoder_get_state)( - const FLAC__StreamDecoder *decoder); -} flac_loader; - -extern flac_loader flac; - -#endif /* FLAC_MUSIC */ - -extern int Mix_InitFLAC(); -extern void Mix_QuitFLAC(); diff --git a/dynamic_fluidsynth.c b/dynamic_fluidsynth.c deleted file mode 100644 index edc7660..0000000 --- a/dynamic_fluidsynth.c +++ /dev/null @@ -1,87 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - James Le Cuirot - chewi@aura-online.co.uk -*/ - -#ifdef USE_FLUIDSYNTH_MIDI - -#include "SDL_loadso.h" -#include "dynamic_fluidsynth.h" - -fluidsynth_loader fluidsynth = { - 0, NULL -}; - -#ifdef FLUIDSYNTH_DYNAMIC -#define FLUIDSYNTH_LOADER(FUNC, SIG) \ - fluidsynth.FUNC = (SIG) SDL_LoadFunction(fluidsynth.handle, #FUNC); \ - if (fluidsynth.FUNC == NULL) { SDL_UnloadObject(fluidsynth.handle); return -1; } -#else -#define FLUIDSYNTH_LOADER(FUNC, SIG) \ - fluidsynth.FUNC = FUNC; -#endif - -int Mix_InitFluidSynth() -{ - if ( fluidsynth.loaded == 0 ) { -#ifdef FLUIDSYNTH_DYNAMIC - fluidsynth.handle = SDL_LoadObject(FLUIDSYNTH_DYNAMIC); - if ( fluidsynth.handle == NULL ) return -1; -#endif - - FLUIDSYNTH_LOADER(delete_fluid_player, int (*)(fluid_player_t*)); - FLUIDSYNTH_LOADER(delete_fluid_settings, void (*)(fluid_settings_t*)); - FLUIDSYNTH_LOADER(delete_fluid_synth, int (*)(fluid_synth_t*)); - FLUIDSYNTH_LOADER(fluid_player_add, int (*)(fluid_player_t*, const char*)); - FLUIDSYNTH_LOADER(fluid_player_add_mem, int (*)(fluid_player_t*, const void*, size_t)); - FLUIDSYNTH_LOADER(fluid_player_get_status, int (*)(fluid_player_t*)); - FLUIDSYNTH_LOADER(fluid_player_play, int (*)(fluid_player_t*)); - FLUIDSYNTH_LOADER(fluid_player_set_loop, int (*)(fluid_player_t*, int)); - FLUIDSYNTH_LOADER(fluid_player_stop, int (*)(fluid_player_t*)); - FLUIDSYNTH_LOADER(fluid_settings_setnum, int (*)(fluid_settings_t*, const char*, double)); - FLUIDSYNTH_LOADER(fluid_synth_get_settings, fluid_settings_t* (*)(fluid_synth_t*)); - FLUIDSYNTH_LOADER(fluid_synth_set_gain, void (*)(fluid_synth_t*, float)); - FLUIDSYNTH_LOADER(fluid_synth_sfload, int(*)(fluid_synth_t*, const char*, int)); - FLUIDSYNTH_LOADER(fluid_synth_write_s16, int(*)(fluid_synth_t*, int, void*, int, int, void*, int, int)); - FLUIDSYNTH_LOADER(new_fluid_player, fluid_player_t* (*)(fluid_synth_t*)); - FLUIDSYNTH_LOADER(new_fluid_settings, fluid_settings_t* (*)(void)); - FLUIDSYNTH_LOADER(new_fluid_synth, fluid_synth_t* (*)(fluid_settings_t*)); - } - ++fluidsynth.loaded; - - return 0; -} - -void Mix_QuitFluidSynth() -{ - if ( fluidsynth.loaded == 0 ) { - return; - } - if ( fluidsynth.loaded == 1 ) { -#ifdef FLUIDSYNTH_DYNAMIC - SDL_UnloadObject(fluidsynth.handle); -#endif - } - --fluidsynth.loaded; -} - -#endif /* USE_FLUIDSYNTH_MIDI */ diff --git a/dynamic_fluidsynth.h b/dynamic_fluidsynth.h deleted file mode 100644 index e3e3b67..0000000 --- a/dynamic_fluidsynth.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - James Le Cuirot - chewi@aura-online.co.uk -*/ - -#ifdef USE_FLUIDSYNTH_MIDI - -#include - -typedef struct { - int loaded; - void *handle; - - int (*delete_fluid_player)(fluid_player_t*); - void (*delete_fluid_settings)(fluid_settings_t*); - int (*delete_fluid_synth)(fluid_synth_t*); - int (*fluid_player_add)(fluid_player_t*, const char*); - int (*fluid_player_add_mem)(fluid_player_t*, const void*, size_t); - int (*fluid_player_get_status)(fluid_player_t*); - int (*fluid_player_play)(fluid_player_t*); - int (*fluid_player_set_loop)(fluid_player_t*, int); - int (*fluid_player_stop)(fluid_player_t*); - int (*fluid_settings_setnum)(fluid_settings_t*, const char*, double); - fluid_settings_t* (*fluid_synth_get_settings)(fluid_synth_t*); - void (*fluid_synth_set_gain)(fluid_synth_t*, float); - int (*fluid_synth_sfload)(fluid_synth_t*, const char*, int); - int (*fluid_synth_write_s16)(fluid_synth_t*, int, void*, int, int, void*, int, int); - fluid_player_t* (*new_fluid_player)(fluid_synth_t*); - fluid_settings_t* (*new_fluid_settings)(void); - fluid_synth_t* (*new_fluid_synth)(fluid_settings_t*); -} fluidsynth_loader; - -extern fluidsynth_loader fluidsynth; - -#endif /* USE_FLUIDSYNTH_MIDI */ - -extern int Mix_InitFluidSynth(); -extern void Mix_QuitFluidSynth(); diff --git a/dynamic_mod.c b/dynamic_mod.c deleted file mode 100644 index 788ccb9..0000000 --- a/dynamic_mod.c +++ /dev/null @@ -1,297 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef MOD_MUSIC - -#include "SDL_loadso.h" -#include "SDL_mixer.h" -#include "dynamic_mod.h" - -mikmod_loader mikmod = { - 0, NULL -}; - -#ifdef MOD_DYNAMIC -int Mix_InitMOD() -{ - if ( mikmod.loaded == 0 ) { - mikmod.handle = SDL_LoadObject(MOD_DYNAMIC); - if ( mikmod.handle == NULL ) { - return -1; - } - mikmod.MikMod_Exit = - (void (*)(void)) - SDL_LoadFunction(mikmod.handle, "MikMod_Exit"); - if ( mikmod.MikMod_Exit == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.MikMod_InfoDriver = - (CHAR* (*)(void)) - SDL_LoadFunction(mikmod.handle, "MikMod_InfoDriver"); - if ( mikmod.MikMod_InfoDriver == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.MikMod_InfoLoader = - (CHAR* (*)(void)) - SDL_LoadFunction(mikmod.handle, "MikMod_InfoLoader"); - if ( mikmod.MikMod_InfoLoader == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.MikMod_Init = - (BOOL (*)(CHAR*)) - SDL_LoadFunction(mikmod.handle, "MikMod_Init"); - if ( mikmod.MikMod_Init == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.MikMod_RegisterAllLoaders = - (void (*)(void)) - SDL_LoadFunction(mikmod.handle, "MikMod_RegisterAllLoaders"); - if ( mikmod.MikMod_RegisterAllLoaders == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.MikMod_RegisterDriver = - (void (*)(struct MDRIVER*)) - SDL_LoadFunction(mikmod.handle, "MikMod_RegisterDriver"); - if ( mikmod.MikMod_RegisterDriver == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.MikMod_errno = - (int*) - SDL_LoadFunction(mikmod.handle, "MikMod_errno"); - if ( mikmod.MikMod_errno == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.MikMod_strerror = - (char* (*)(int)) - SDL_LoadFunction(mikmod.handle, "MikMod_strerror"); - if ( mikmod.MikMod_strerror == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.MikMod_free = - (void (*)(void*)) - SDL_LoadFunction(mikmod.handle, "MikMod_free"); - if ( mikmod.MikMod_free == NULL ) { - /* libmikmod 3.1 and earlier doesn't have it */ - mikmod.MikMod_free = free; - } - mikmod.Player_Active = - (BOOL (*)(void)) - SDL_LoadFunction(mikmod.handle, "Player_Active"); - if ( mikmod.Player_Active == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.Player_Free = - (void (*)(MODULE*)) - SDL_LoadFunction(mikmod.handle, "Player_Free"); - if ( mikmod.Player_Free == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.Player_LoadGeneric = - (MODULE* (*)(MREADER*,int,BOOL)) - SDL_LoadFunction(mikmod.handle, "Player_LoadGeneric"); - if ( mikmod.Player_LoadGeneric == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.Player_SetPosition = - (void (*)(UWORD)) - SDL_LoadFunction(mikmod.handle, "Player_SetPosition"); - if ( mikmod.Player_SetPosition == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.Player_SetVolume = - (void (*)(SWORD)) - SDL_LoadFunction(mikmod.handle, "Player_SetVolume"); - if ( mikmod.Player_SetVolume == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.Player_Start = - (void (*)(MODULE*)) - SDL_LoadFunction(mikmod.handle, "Player_Start"); - if ( mikmod.Player_Start == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.Player_Stop = - (void (*)(void)) - SDL_LoadFunction(mikmod.handle, "Player_Stop"); - if ( mikmod.Player_Stop == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.VC_WriteBytes = - (ULONG (*)(SBYTE*,ULONG)) - SDL_LoadFunction(mikmod.handle, "VC_WriteBytes"); - if ( mikmod.VC_WriteBytes == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.drv_nos = - (MDRIVER*) - SDL_LoadFunction(mikmod.handle, "drv_nos"); - if ( mikmod.drv_nos == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.md_device = - (UWORD*) - SDL_LoadFunction(mikmod.handle, "md_device"); - if ( mikmod.md_device == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.md_mixfreq = - (UWORD*) - SDL_LoadFunction(mikmod.handle, "md_mixfreq"); - if ( mikmod.md_mixfreq == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.md_mode = - (UWORD*) - SDL_LoadFunction(mikmod.handle, "md_mode"); - if ( mikmod.md_mode == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.md_musicvolume = - (UBYTE*) - SDL_LoadFunction(mikmod.handle, "md_musicvolume"); - if ( mikmod.md_musicvolume == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.md_pansep = - (UBYTE*) - SDL_LoadFunction(mikmod.handle, "md_pansep"); - if ( mikmod.md_pansep == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.md_reverb = - (UBYTE*) - SDL_LoadFunction(mikmod.handle, "md_reverb"); - if ( mikmod.md_reverb == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.md_sndfxvolume = - (UBYTE*) - SDL_LoadFunction(mikmod.handle, "md_sndfxvolume"); - if ( mikmod.md_sndfxvolume == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - mikmod.md_volume = - (UBYTE*) - SDL_LoadFunction(mikmod.handle, "md_volume"); - if ( mikmod.md_volume == NULL ) { - SDL_UnloadObject(mikmod.handle); - return -1; - } - } - ++mikmod.loaded; - - return 0; -} -void Mix_QuitMOD() -{ - if ( mikmod.loaded == 0 ) { - return; - } - if ( mikmod.loaded == 1 ) { - SDL_UnloadObject(mikmod.handle); - } - --mikmod.loaded; -} -#else -int Mix_InitMOD() -{ - if ( mikmod.loaded == 0 ) { -#ifdef __MACOSX__ - extern void Player_Start(MODULE*) __attribute__((weak_import)); - if ( Player_Start == NULL ) - { - /* Missing weakly linked framework */ - Mix_SetError("Missing mikmod.framework"); - return -1; - } -#endif // __MACOSX__ - - mikmod.MikMod_Exit = MikMod_Exit; - mikmod.MikMod_InfoDriver = MikMod_InfoDriver; - mikmod.MikMod_InfoLoader = MikMod_InfoLoader; - mikmod.MikMod_Init = MikMod_Init; - mikmod.MikMod_RegisterAllLoaders = MikMod_RegisterAllLoaders; - mikmod.MikMod_RegisterDriver = MikMod_RegisterDriver; - mikmod.MikMod_errno = &MikMod_errno; - mikmod.MikMod_strerror = MikMod_strerror; -#if LIBMIKMOD_VERSION < ((3<<16)|(2<<8)) - mikmod.MikMod_free = free; -#else - mikmod.MikMod_free = MikMod_free; -#endif - mikmod.Player_Active = Player_Active; - mikmod.Player_Free = Player_Free; - mikmod.Player_LoadGeneric = Player_LoadGeneric; - mikmod.Player_SetPosition = Player_SetPosition; - mikmod.Player_SetVolume = Player_SetVolume; - mikmod.Player_Start = Player_Start; - mikmod.Player_Stop = Player_Stop; - mikmod.VC_WriteBytes = VC_WriteBytes; - mikmod.drv_nos = &drv_nos; - mikmod.md_device = &md_device; - mikmod.md_mixfreq = &md_mixfreq; - mikmod.md_mode = &md_mode; - mikmod.md_musicvolume = &md_musicvolume; - mikmod.md_pansep = &md_pansep; - mikmod.md_reverb = &md_reverb; - mikmod.md_sndfxvolume = &md_sndfxvolume; - mikmod.md_volume = &md_volume; - } - ++mikmod.loaded; - - return 0; -} -void Mix_QuitMOD() -{ - if ( mikmod.loaded == 0 ) { - return; - } - if ( mikmod.loaded == 1 ) { - } - --mikmod.loaded; -} -#endif /* MOD_DYNAMIC */ - -#endif /* MOD_MUSIC */ diff --git a/dynamic_mod.h b/dynamic_mod.h deleted file mode 100644 index 5cb3df9..0000000 --- a/dynamic_mod.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef MOD_MUSIC - -#include "mikmod.h" - -typedef struct { - int loaded; - void *handle; - - void (*MikMod_Exit)(void); - CHAR* (*MikMod_InfoDriver)(void); - CHAR* (*MikMod_InfoLoader)(void); - BOOL (*MikMod_Init)(CHAR*); - void (*MikMod_RegisterAllLoaders)(void); - void (*MikMod_RegisterDriver)(struct MDRIVER*); - int* MikMod_errno; - char* (*MikMod_strerror)(int); - void (*MikMod_free)(void*); - BOOL (*Player_Active)(void); - void (*Player_Free)(MODULE*); - MODULE* (*Player_LoadGeneric)(MREADER*,int,BOOL); - void (*Player_SetPosition)(UWORD); - void (*Player_SetVolume)(SWORD); - void (*Player_Start)(MODULE*); - void (*Player_Stop)(void); - ULONG (*VC_WriteBytes)(SBYTE*,ULONG); - struct MDRIVER* drv_nos; - UWORD* md_device; - UWORD* md_mixfreq; - UWORD* md_mode; - UBYTE* md_musicvolume; - UBYTE* md_pansep; - UBYTE* md_reverb; - UBYTE* md_sndfxvolume; - UBYTE* md_volume; -} mikmod_loader; - -extern mikmod_loader mikmod; - -#endif /* MOD_MUSIC */ - -extern int Mix_InitMOD(); -extern void Mix_QuitMOD(); diff --git a/dynamic_modplug.c b/dynamic_modplug.c deleted file mode 100644 index 20a8dc9..0000000 --- a/dynamic_modplug.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef MODPLUG_MUSIC - -#include "SDL_loadso.h" -#include "SDL_mixer.h" -#include "dynamic_modplug.h" - -modplug_loader modplug = { - 0, NULL -}; - -#ifdef MODPLUG_DYNAMIC -int Mix_InitModPlug() -{ - if ( modplug.loaded == 0 ) { - modplug.handle = SDL_LoadObject(MODPLUG_DYNAMIC); - if ( modplug.handle == NULL ) { - return -1; - } - - modplug.ModPlug_Load = - (ModPlugFile* (*)(const void* data, int size)) - SDL_LoadFunction(modplug.handle, "ModPlug_Load"); - - modplug.ModPlug_Unload = - (void (*)(ModPlugFile* file)) - SDL_LoadFunction(modplug.handle, "ModPlug_Unload"); - - modplug.ModPlug_Read = - (int (*)(ModPlugFile* file, void* buffer, int size)) - SDL_LoadFunction(modplug.handle, "ModPlug_Read"); - - modplug.ModPlug_Seek = - (void (*)(ModPlugFile* file, int millisecond)) - SDL_LoadFunction(modplug.handle, "ModPlug_Seek"); - - modplug.ModPlug_GetSettings = - (void (*)(ModPlug_Settings* settings)) - SDL_LoadFunction(modplug.handle, "ModPlug_GetSettings"); - - modplug.ModPlug_SetSettings = - (void (*)(const ModPlug_Settings* settings)) - SDL_LoadFunction(modplug.handle, "ModPlug_SetSettings"); - - modplug.ModPlug_SetMasterVolume = - (void (*)(ModPlugFile* file,unsigned int cvol)) - SDL_LoadFunction(modplug.handle, "ModPlug_SetMasterVolume"); - } - ++modplug.loaded; - - return 0; -} - -void Mix_QuitModPlug() -{ - if ( modplug.loaded == 0 ) { - return; - } - if ( modplug.loaded == 1 ) { - SDL_UnloadObject(modplug.handle); - } - --modplug.loaded; -} -#else -int Mix_InitModPlug() -{ - if ( modplug.loaded == 0 ) { -#ifdef __MACOSX__ - extern ModPlugFile* ModPlug_Load(const void* data, int size) __attribute__((weak_import)); - if ( ModPlug_Load == NULL ) - { - /* Missing weakly linked framework */ - Mix_SetError("Missing modplug.framework"); - return -1; - } -#endif // __MACOSX__ - - modplug.ModPlug_Load = ModPlug_Load; - modplug.ModPlug_Unload = ModPlug_Unload; - modplug.ModPlug_Read = ModPlug_Read; - modplug.ModPlug_Seek = ModPlug_Seek; - modplug.ModPlug_GetSettings = ModPlug_GetSettings; - modplug.ModPlug_SetSettings = ModPlug_SetSettings; - modplug.ModPlug_SetMasterVolume = ModPlug_SetMasterVolume; - } - ++modplug.loaded; - - return 0; -} -void Mix_QuitModPlug() -{ - if ( modplug.loaded == 0 ) { - return; - } - if ( modplug.loaded == 1 ) { - } - --modplug.loaded; -} -#endif /* MODPLUG_DYNAMIC */ - -#endif /* MODPLUG_MUSIC */ diff --git a/dynamic_modplug.h b/dynamic_modplug.h deleted file mode 100644 index ac4e076..0000000 --- a/dynamic_modplug.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef MODPLUG_MUSIC - -#ifdef MODPLUG_HEADER -#include MODPLUG_HEADER -#else -#include -#endif - -typedef struct { - int loaded; - void *handle; - - ModPlugFile* (*ModPlug_Load)(const void* data, int size); - void (*ModPlug_Unload)(ModPlugFile* file); - int (*ModPlug_Read)(ModPlugFile* file, void* buffer, int size); - void (*ModPlug_Seek)(ModPlugFile* file, int millisecond); - void (*ModPlug_GetSettings)(ModPlug_Settings* settings); - void (*ModPlug_SetSettings)(const ModPlug_Settings* settings); - void (*ModPlug_SetMasterVolume)(ModPlugFile* file,unsigned int cvol) ; -} modplug_loader; - -extern modplug_loader modplug; - -#endif /* MODPLUG_MUSIC */ - -extern int Mix_InitModPlug(); -extern void Mix_QuitModPlug(); diff --git a/dynamic_mp3.c b/dynamic_mp3.c deleted file mode 100644 index 1f00920..0000000 --- a/dynamic_mp3.c +++ /dev/null @@ -1,181 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef MP3_MUSIC - -#include "SDL_loadso.h" -#include "SDL_mixer.h" -#include "dynamic_mp3.h" - -smpeg_loader smpeg = { - 0, NULL -}; - -#ifdef MP3_DYNAMIC -int Mix_InitMP3() -{ - if ( smpeg.loaded == 0 ) { - smpeg.handle = SDL_LoadObject(MP3_DYNAMIC); - if ( smpeg.handle == NULL ) { - return -1; - } - smpeg.SMPEG_actualSpec = - (void (*)( SMPEG *, SDL_AudioSpec * )) - SDL_LoadFunction(smpeg.handle, "SMPEG_actualSpec"); - if ( smpeg.SMPEG_actualSpec == NULL ) { - SDL_UnloadObject(smpeg.handle); - return -1; - } - smpeg.SMPEG_delete = - (void (*)( SMPEG* )) - SDL_LoadFunction(smpeg.handle, "SMPEG_delete"); - if ( smpeg.SMPEG_delete == NULL ) { - SDL_UnloadObject(smpeg.handle); - return -1; - } - smpeg.SMPEG_enableaudio = - (void (*)( SMPEG*, int )) - SDL_LoadFunction(smpeg.handle, "SMPEG_enableaudio"); - if ( smpeg.SMPEG_enableaudio == NULL ) { - SDL_UnloadObject(smpeg.handle); - return -1; - } - smpeg.SMPEG_enablevideo = - (void (*)( SMPEG*, int )) - SDL_LoadFunction(smpeg.handle, "SMPEG_enablevideo"); - if ( smpeg.SMPEG_enablevideo == NULL ) { - SDL_UnloadObject(smpeg.handle); - return -1; - } - smpeg.SMPEG_new_rwops = - (SMPEG* (*)(SDL_RWops *, SMPEG_Info*, int, int)) - SDL_LoadFunction(smpeg.handle, "SMPEG_new_rwops"); - if ( smpeg.SMPEG_new_rwops == NULL ) { - SDL_UnloadObject(smpeg.handle); - return -1; - } - smpeg.SMPEG_play = - (void (*)( SMPEG* )) - SDL_LoadFunction(smpeg.handle, "SMPEG_play"); - if ( smpeg.SMPEG_play == NULL ) { - SDL_UnloadObject(smpeg.handle); - return -1; - } - smpeg.SMPEG_playAudio = - (int (*)( SMPEG *, Uint8 *, int )) - SDL_LoadFunction(smpeg.handle, "SMPEG_playAudio"); - if ( smpeg.SMPEG_playAudio == NULL ) { - SDL_UnloadObject(smpeg.handle); - return -1; - } - smpeg.SMPEG_rewind = - (void (*)( SMPEG* )) - SDL_LoadFunction(smpeg.handle, "SMPEG_rewind"); - if ( smpeg.SMPEG_rewind == NULL ) { - SDL_UnloadObject(smpeg.handle); - return -1; - } - smpeg.SMPEG_setvolume = - (void (*)( SMPEG*, int )) - SDL_LoadFunction(smpeg.handle, "SMPEG_setvolume"); - if ( smpeg.SMPEG_setvolume == NULL ) { - SDL_UnloadObject(smpeg.handle); - return -1; - } - smpeg.SMPEG_skip = - (void (*)( SMPEG*, float )) - SDL_LoadFunction(smpeg.handle, "SMPEG_skip"); - if ( smpeg.SMPEG_skip == NULL ) { - SDL_UnloadObject(smpeg.handle); - return -1; - } - smpeg.SMPEG_status = - (SMPEGstatus (*)( SMPEG* )) - SDL_LoadFunction(smpeg.handle, "SMPEG_status"); - if ( smpeg.SMPEG_status == NULL ) { - SDL_UnloadObject(smpeg.handle); - return -1; - } - smpeg.SMPEG_stop = - (void (*)( SMPEG* )) - SDL_LoadFunction(smpeg.handle, "SMPEG_stop"); - if ( smpeg.SMPEG_stop == NULL ) { - SDL_UnloadObject(smpeg.handle); - return -1; - } - } - ++smpeg.loaded; - - return 0; -} -void Mix_QuitMP3() -{ - if ( smpeg.loaded == 0 ) { - return; - } - if ( smpeg.loaded == 1 ) { - SDL_UnloadObject(smpeg.handle); - } - --smpeg.loaded; -} -#else -int Mix_InitMP3() -{ - if ( smpeg.loaded == 0 ) { -#ifdef __MACOSX__ - extern SMPEG* SMPEG_new_rwops(SDL_RWops*, SMPEG_Info*, int, int) __attribute__((weak_import)); - if ( SMPEG_new_rwops == NULL ) - { - /* Missing weakly linked framework */ - Mix_SetError("Missing smpeg2.framework"); - return -1; - } -#endif // __MACOSX__ - - smpeg.SMPEG_actualSpec = SMPEG_actualSpec; - smpeg.SMPEG_delete = SMPEG_delete; - smpeg.SMPEG_enableaudio = SMPEG_enableaudio; - smpeg.SMPEG_enablevideo = SMPEG_enablevideo; - smpeg.SMPEG_new_rwops = SMPEG_new_rwops; - smpeg.SMPEG_play = SMPEG_play; - smpeg.SMPEG_playAudio = SMPEG_playAudio; - smpeg.SMPEG_rewind = SMPEG_rewind; - smpeg.SMPEG_setvolume = SMPEG_setvolume; - smpeg.SMPEG_skip = SMPEG_skip; - smpeg.SMPEG_status = SMPEG_status; - smpeg.SMPEG_stop = SMPEG_stop; - } - ++smpeg.loaded; - - return 0; -} -void Mix_QuitMP3() -{ - if ( smpeg.loaded == 0 ) { - return; - } - if ( smpeg.loaded == 1 ) { - } - --smpeg.loaded; -} -#endif /* MP3_DYNAMIC */ - -#endif /* MP3_MUSIC */ diff --git a/dynamic_mp3.h b/dynamic_mp3.h deleted file mode 100644 index 3586b70..0000000 --- a/dynamic_mp3.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef MP3_MUSIC -#include "smpeg.h" - -typedef struct { - int loaded; - void *handle; - void (*SMPEG_actualSpec)( SMPEG *mpeg, SDL_AudioSpec *spec ); - void (*SMPEG_delete)( SMPEG* mpeg ); - void (*SMPEG_enableaudio)( SMPEG* mpeg, int enable ); - void (*SMPEG_enablevideo)( SMPEG* mpeg, int enable ); - SMPEG* (*SMPEG_new_rwops)(SDL_RWops *src, SMPEG_Info* info, int freesrc, int sdl_audio); - void (*SMPEG_play)( SMPEG* mpeg ); - int (*SMPEG_playAudio)( SMPEG *mpeg, Uint8 *stream, int len ); - void (*SMPEG_rewind)( SMPEG* mpeg ); - void (*SMPEG_setvolume)( SMPEG* mpeg, int volume ); - void (*SMPEG_skip)( SMPEG* mpeg, float seconds ); - SMPEGstatus (*SMPEG_status)( SMPEG* mpeg ); - void (*SMPEG_stop)( SMPEG* mpeg ); -} smpeg_loader; - -extern smpeg_loader smpeg; - -#endif /* MUSIC_MP3 */ - -extern int Mix_InitMP3(); -extern void Mix_QuitMP3(); diff --git a/dynamic_ogg.c b/dynamic_ogg.c deleted file mode 100644 index 26bd011..0000000 --- a/dynamic_ogg.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef OGG_MUSIC - -#include "SDL_loadso.h" -#include "SDL_mixer.h" -#include "dynamic_ogg.h" - -vorbis_loader vorbis = { - 0, NULL -}; - -#ifdef OGG_DYNAMIC -int Mix_InitOgg() -{ - if ( vorbis.loaded == 0 ) { - vorbis.handle = SDL_LoadObject(OGG_DYNAMIC); - if ( vorbis.handle == NULL ) { - return -1; - } - vorbis.ov_clear = - (int (*)(OggVorbis_File *)) - SDL_LoadFunction(vorbis.handle, "ov_clear"); - if ( vorbis.ov_clear == NULL ) { - SDL_UnloadObject(vorbis.handle); - return -1; - } - vorbis.ov_info = - (vorbis_info *(*)(OggVorbis_File *,int)) - SDL_LoadFunction(vorbis.handle, "ov_info"); - if ( vorbis.ov_info == NULL ) { - SDL_UnloadObject(vorbis.handle); - return -1; - } - vorbis.ov_open_callbacks = - (int (*)(void *, OggVorbis_File *, const char *, long, ov_callbacks)) - SDL_LoadFunction(vorbis.handle, "ov_open_callbacks"); - if ( vorbis.ov_open_callbacks == NULL ) { - SDL_UnloadObject(vorbis.handle); - return -1; - } - vorbis.ov_pcm_total = - (ogg_int64_t (*)(OggVorbis_File *,int)) - SDL_LoadFunction(vorbis.handle, "ov_pcm_total"); - if ( vorbis.ov_pcm_total == NULL ) { - SDL_UnloadObject(vorbis.handle); - return -1; - } - vorbis.ov_read = -#ifdef OGG_USE_TREMOR - (long (*)(OggVorbis_File *,char *,int,int *)) -#else - (long (*)(OggVorbis_File *,char *,int,int,int,int,int *)) -#endif - SDL_LoadFunction(vorbis.handle, "ov_read"); - if ( vorbis.ov_read == NULL ) { - SDL_UnloadObject(vorbis.handle); - return -1; - } - vorbis.ov_time_seek = -#ifdef OGG_USE_TREMOR - (long (*)(OggVorbis_File *,ogg_int64_t)) -#else - (int (*)(OggVorbis_File *,double)) -#endif - SDL_LoadFunction(vorbis.handle, "ov_time_seek"); - if ( vorbis.ov_time_seek == NULL ) { - SDL_UnloadObject(vorbis.handle); - return -1; - } - } - ++vorbis.loaded; - - return 0; -} -void Mix_QuitOgg() -{ - if ( vorbis.loaded == 0 ) { - return; - } - if ( vorbis.loaded == 1 ) { - SDL_UnloadObject(vorbis.handle); - } - --vorbis.loaded; -} -#else -int Mix_InitOgg() -{ - if ( vorbis.loaded == 0 ) { -#ifdef __MACOSX__ - extern int ov_open_callbacks(void*, OggVorbis_File*, const char*, long, ov_callbacks) __attribute__((weak_import)); - if ( ov_open_callbacks == NULL ) - { - /* Missing weakly linked framework */ - Mix_SetError("Missing Vorbis.framework"); - return -1; - } -#endif // __MACOSX__ - - vorbis.ov_clear = ov_clear; - vorbis.ov_info = ov_info; - vorbis.ov_open_callbacks = ov_open_callbacks; - vorbis.ov_pcm_total = ov_pcm_total; - vorbis.ov_read = ov_read; - vorbis.ov_time_seek = ov_time_seek; - } - ++vorbis.loaded; - - return 0; -} -void Mix_QuitOgg() -{ - if ( vorbis.loaded == 0 ) { - return; - } - if ( vorbis.loaded == 1 ) { - } - --vorbis.loaded; -} -#endif /* OGG_DYNAMIC */ - -#endif /* OGG_MUSIC */ diff --git a/dynamic_ogg.h b/dynamic_ogg.h deleted file mode 100644 index 1f0bda4..0000000 --- a/dynamic_ogg.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifdef OGG_MUSIC -#if defined(OGG_HEADER) -#include OGG_HEADER -#elif defined(OGG_USE_TREMOR) -#include -#else -#include -#endif - -typedef struct { - int loaded; - void *handle; - int (*ov_clear)(OggVorbis_File *vf); - vorbis_info *(*ov_info)(OggVorbis_File *vf,int link); - int (*ov_open_callbacks)(void *datasource, OggVorbis_File *vf, const char *initial, long ibytes, ov_callbacks callbacks); - ogg_int64_t (*ov_pcm_total)(OggVorbis_File *vf,int i); -#ifdef OGG_USE_TREMOR - long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int *bitstream); -#else - long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int bigendianp,int word,int sgned,int *bitstream); -#endif -#ifdef OGG_USE_TREMOR - int (*ov_time_seek)(OggVorbis_File *vf,ogg_int64_t pos); -#else - int (*ov_time_seek)(OggVorbis_File *vf,double pos); -#endif -} vorbis_loader; - -extern vorbis_loader vorbis; - -#endif /* OGG_MUSIC */ - -extern int Mix_InitOgg(); -extern void Mix_QuitOgg(); diff --git a/effect_position.c b/effect_position.c index 2ec1c42..8bec6a0 100644 --- a/effect_position.c +++ b/effect_position.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -31,8 +31,9 @@ #include #include "SDL.h" +#include "SDL_endian.h" #include "SDL_mixer.h" -#include "SDL_endian.h" +#include "mixer.h" #define __MIX_INTERNAL_EFFECT__ #include "effects_internal.h" @@ -98,7 +99,7 @@ /* This just frees up the callback-specific data. */ -static void _Eff_PositionDone(int channel, void *udata) +static void SDLCALL _Eff_PositionDone(int channel, void *udata) { if (channel < 0) { if (pos_args_global != NULL) { @@ -114,7 +115,7 @@ } -static void _Eff_position_u8(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_u8(int chan, void *stream, int len, void *udata) { volatile position_args *args = (volatile position_args *) udata; Uint8 *ptr = (Uint8 *) stream; @@ -151,7 +152,7 @@ ptr++; } } -static void _Eff_position_u8_c4(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_u8_c4(int chan, void *stream, int len, void *udata) { volatile position_args *args = (volatile position_args *) udata; Uint8 *ptr = (Uint8 *) stream; @@ -235,7 +236,7 @@ } -static void _Eff_position_u8_c6(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_u8_c6(int chan, void *stream, int len, void *udata) { volatile position_args *args = (volatile position_args *) udata; Uint8 *ptr = (Uint8 *) stream; @@ -357,7 +358,7 @@ * in case the user has called Mix_SetPanning() or whatnot again while this * callback is running. */ -static void _Eff_position_table_u8(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_table_u8(int chan, void *stream, int len, void *udata) { volatile position_args *args = (volatile position_args *) udata; Uint8 *ptr = (Uint8 *) stream; @@ -394,19 +395,19 @@ *p = (d[l[(*p & 0xFF000000) >> 24]] << 24) | (d[r[(*p & 0x00FF0000) >> 16]] << 16) | (d[l[(*p & 0x0000FF00) >> 8]] << 8) | - (d[r[(*p & 0x000000FF) ]] ) ; + (d[r[(*p & 0x000000FF) ]] ) ; #else *p = (d[r[(*p & 0xFF000000) >> 24]] << 24) | (d[l[(*p & 0x00FF0000) >> 16]] << 16) | (d[r[(*p & 0x0000FF00) >> 8]] << 8) | - (d[l[(*p & 0x000000FF) ]] ) ; + (d[l[(*p & 0x000000FF) ]] ) ; #endif ++p; } } -static void _Eff_position_s8(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_s8(int chan, void *stream, int len, void *udata) { volatile position_args *args = (volatile position_args *) udata; Sint8 *ptr = (Sint8 *) stream; @@ -438,7 +439,7 @@ ptr++; } } -static void _Eff_position_s8_c4(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_s8_c4(int chan, void *stream, int len, void *udata) { volatile position_args *args = (volatile position_args *) udata; Sint8 *ptr = (Sint8 *) stream; @@ -484,7 +485,7 @@ } } } -static void _Eff_position_s8_c6(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_s8_c6(int chan, void *stream, int len, void *udata) { volatile position_args *args = (volatile position_args *) udata; Sint8 *ptr = (Sint8 *) stream; @@ -551,7 +552,7 @@ * in case the user has called Mix_SetPanning() or whatnot again while this * callback is running. */ -static void _Eff_position_table_s8(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_table_s8(int chan, void *stream, int len, void *udata) { volatile position_args *args = (volatile position_args *) udata; Sint8 *ptr = (Sint8 *) stream; @@ -585,12 +586,12 @@ *p = (d[l[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) | (d[r[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) | (d[l[((Sint16)(Sint8)((*p & 0x0000FF00) >> 8))+128]] << 8) | - (d[r[((Sint16)(Sint8)((*p & 0x000000FF) ))+128]] ) ; + (d[r[((Sint16)(Sint8)((*p & 0x000000FF) ))+128]] ) ; #else *p = (d[r[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) | (d[l[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) | (d[r[((Sint16)(Sint8)((*p & 0x0000FF00) >> 8))+128]] << 8) | - (d[l[((Sint16)(Sint8)((*p & 0x000000FF) ))+128]] ) ; + (d[l[((Sint16)(Sint8)((*p & 0x000000FF) ))+128]] ) ; #endif ++p; } @@ -601,7 +602,7 @@ /* !!! FIXME : Optimize the code for 16-bit samples? */ -static void _Eff_position_u16lsb(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_u16lsb(int chan, void *stream, int len, void *udata) { volatile position_args *args = (volatile position_args *) udata; Uint16 *ptr = (Uint16 *) stream; @@ -626,7 +627,7 @@ } } } -static void _Eff_position_u16lsb_c4(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_u16lsb_c4(int chan, void *stream, int len, void *udata) { volatile position_args *args = (volatile position_args *) udata; Uint16 *ptr = (Uint16 *) stream; @@ -675,7 +676,7 @@ } } } -static void _Eff_position_u16lsb_c6(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_u16lsb_c6(int chan, void *stream, int len, void *udata) { volatile position_args *args = (volatile position_args *) udata; Uint16 *ptr = (Uint16 *) stream; @@ -739,7 +740,7 @@ } } -static void _Eff_position_s16lsb(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_s16lsb(int chan, void *stream, int len, void *udata) { /* 16 signed bits (lsb) * 2 channels. */ volatile position_args *args = (volatile position_args *) udata; @@ -768,7 +769,7 @@ } } } -static void _Eff_position_s16lsb_c4(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_s16lsb_c4(int chan, void *stream, int len, void *udata) { /* 16 signed bits (lsb) * 4 channels. */ volatile position_args *args = (volatile position_args *) udata; @@ -813,7 +814,7 @@ } } -static void _Eff_position_s16lsb_c6(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_s16lsb_c6(int chan, void *stream, int len, void *udata) { /* 16 signed bits (lsb) * 6 channels. */ volatile position_args *args = (volatile position_args *) udata; @@ -870,7 +871,7 @@ } } -static void _Eff_position_u16msb(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_u16msb(int chan, void *stream, int len, void *udata) { /* 16 signed bits (lsb) * 2 channels. */ volatile position_args *args = (volatile position_args *) udata; @@ -896,7 +897,7 @@ } } } -static void _Eff_position_u16msb_c4(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_u16msb_c4(int chan, void *stream, int len, void *udata) { /* 16 signed bits (lsb) * 4 channels. */ volatile position_args *args = (volatile position_args *) udata; @@ -946,7 +947,7 @@ } } } -static void _Eff_position_u16msb_c6(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_u16msb_c6(int chan, void *stream, int len, void *udata) { /* 16 signed bits (lsb) * 6 channels. */ volatile position_args *args = (volatile position_args *) udata; @@ -1011,7 +1012,7 @@ } } -static void _Eff_position_s16msb(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_s16msb(int chan, void *stream, int len, void *udata) { /* 16 signed bits (lsb) * 2 channels. */ volatile position_args *args = (volatile position_args *) udata; @@ -1027,7 +1028,7 @@ *(ptr++) = (Sint16) SDL_SwapBE16(swapr); } } -static void _Eff_position_s16msb_c4(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_s16msb_c4(int chan, void *stream, int len, void *udata) { /* 16 signed bits (lsb) * 4 channels. */ volatile position_args *args = (volatile position_args *) udata; @@ -1071,7 +1072,7 @@ } } } -static void _Eff_position_s16msb_c6(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_position_s16msb_c6(int chan, void *stream, int len, void *udata) { /* 16 signed bits (lsb) * 6 channels. */ volatile position_args *args = (volatile position_args *) udata; @@ -1129,6 +1130,361 @@ } } +static void SDLCALL _Eff_position_s32lsb(int chan, void *stream, int len, void *udata) +{ + /* 32 signed bits (lsb) * 2 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint32 *ptr = (Sint32 *) stream; + int i; + +#if 0 + if (len % (sizeof(Sint32) * 2)) { + fprintf(stderr,"Not an even number of frames! len=%d\n", len); + return; + } +#endif + + for (i = 0; i < len; i += sizeof (Sint32) * 2) { + Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) * + args->right_f) * args->distance_f); + if (args->room_angle == 180) { + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + } + else { + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + } + } +} +static void SDLCALL _Eff_position_s32lsb_c4(int chan, void *stream, int len, void *udata) +{ + /* 32 signed bits (lsb) * 4 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint32 *ptr = (Sint32 *) stream; + int i; + + for (i = 0; i < len; i += sizeof (Sint32) * 4) { + Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) * + args->right_f) * args->distance_f); + Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) * + args->left_rear_f) * args->distance_f); + Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+2))) * + args->right_rear_f) * args->distance_f); + switch (args->room_angle) { + case 0: + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); + break; + case 90: + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); + break; + case 180: + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + break; + case 270: + *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + break; + } + } +} + +static void SDLCALL _Eff_position_s32lsb_c6(int chan, void *stream, int len, void *udata) +{ + /* 32 signed bits (lsb) * 6 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint32 *ptr = (Sint32 *) stream; + int i; + + for (i = 0; i < len; i += sizeof (Sint32) * 6) { + Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+1))) * + args->right_f) * args->distance_f); + Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+2))) * + args->left_rear_f) * args->distance_f); + Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+3))) * + args->right_rear_f) * args->distance_f); + Sint32 swapce = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+4))) * + args->center_f) * args->distance_f); + Sint32 swapwf = (Sint32) ((((float) (Sint32) SDL_SwapLE32(*(ptr+5))) * + args->lfe_f) * args->distance_f); + switch (args->room_angle) { + case 0: + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapce); + *(ptr++) = (Sint32) SDL_SwapLE32(swapwf); + break; + case 90: + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapr)/2 + (Sint32) SDL_SwapLE32(swaprr)/2; + *(ptr++) = (Sint32) SDL_SwapLE32(swapwf); + break; + case 180: + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr)/2 + (Sint32) SDL_SwapLE32(swaplr)/2; + *(ptr++) = (Sint32) SDL_SwapLE32(swapwf); + break; + case 270: + *(ptr++) = (Sint32) SDL_SwapLE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapl); + *(ptr++) = (Sint32) SDL_SwapLE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapr); + *(ptr++) = (Sint32) SDL_SwapLE32(swapl)/2 + (Sint32) SDL_SwapLE32(swaplr)/2; + *(ptr++) = (Sint32) SDL_SwapLE32(swapwf); + break; + } + } +} + +static void SDLCALL _Eff_position_s32msb(int chan, void *stream, int len, void *udata) +{ + /* 32 signed bits (lsb) * 2 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint32 *ptr = (Sint32 *) stream; + int i; + + for (i = 0; i < len; i += sizeof (Sint32) * 2) { + Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) * + args->right_f) * args->distance_f); + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + } +} +static void SDLCALL _Eff_position_s32msb_c4(int chan, void *stream, int len, void *udata) +{ + /* 32 signed bits (lsb) * 4 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint32 *ptr = (Sint32 *) stream; + int i; + + for (i = 0; i < len; i += sizeof (Sint32) * 4) { + Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) * + args->right_f) * args->distance_f); + Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+2))) * + args->left_rear_f) * args->distance_f); + Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+3))) * + args->right_rear_f) * args->distance_f); + switch (args->room_angle) { + case 0: + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); + break; + case 90: + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); + break; + case 180: + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + break; + case 270: + *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + break; + } + } +} +static void SDLCALL _Eff_position_s32msb_c6(int chan, void *stream, int len, void *udata) +{ + /* 32 signed bits (lsb) * 6 channels. */ + volatile position_args *args = (volatile position_args *) udata; + Sint32 *ptr = (Sint32 *) stream; + int i; + + for (i = 0; i < len; i += sizeof (Sint32) * 6) { + Sint32 swapl = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+0))) * + args->left_f) * args->distance_f); + Sint32 swapr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+1))) * + args->right_f) * args->distance_f); + Sint32 swaplr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+2))) * + args->left_rear_f) * args->distance_f); + Sint32 swaprr = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+3))) * + args->right_rear_f) * args->distance_f); + Sint32 swapce = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+4))) * + args->center_f) * args->distance_f); + Sint32 swapwf = (Sint32) ((((float) (Sint32) SDL_SwapBE32(*(ptr+5))) * + args->lfe_f) * args->distance_f); + + switch (args->room_angle) { + case 0: + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapce); + *(ptr++) = (Sint32) SDL_SwapBE32(swapwf); + break; + case 90: + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapr)/2 + (Sint32) SDL_SwapBE32(swaprr)/2; + *(ptr++) = (Sint32) SDL_SwapBE32(swapwf); + break; + case 180: + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr)/2 + (Sint32) SDL_SwapBE32(swaplr)/2; + *(ptr++) = (Sint32) SDL_SwapBE32(swapwf); + break; + case 270: + *(ptr++) = (Sint32) SDL_SwapBE32(swaplr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapl); + *(ptr++) = (Sint32) SDL_SwapBE32(swaprr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapr); + *(ptr++) = (Sint32) SDL_SwapBE32(swapl)/2 + (Sint32) SDL_SwapBE32(swaplr)/2; + *(ptr++) = (Sint32) SDL_SwapBE32(swapwf); + break; + } + } +} + +static void SDLCALL _Eff_position_f32sys(int chan, void *stream, int len, void *udata) +{ + /* float * 2 channels. */ + volatile position_args *args = (volatile position_args *) udata; + float *ptr = (float *) stream; + int i; + + for (i = 0; i < len; i += sizeof (float) * 2) { + float swapl = ((*(ptr+0) * args->left_f) * args->distance_f); + float swapr = ((*(ptr+1) * args->right_f) * args->distance_f); + *(ptr++) = swapl; + *(ptr++) = swapr; + } +} +static void SDLCALL _Eff_position_f32sys_c4(int chan, void *stream, int len, void *udata) +{ + /* float * 4 channels. */ + volatile position_args *args = (volatile position_args *) udata; + float *ptr = (float *) stream; + int i; + + for (i = 0; i < len; i += sizeof (float) * 4) { + float swapl = ((*(ptr+0) * args->left_f) * args->distance_f); + float swapr = ((*(ptr+1) * args->right_f) * args->distance_f); + float swaplr = ((*(ptr+2) * args->left_rear_f) * args->distance_f); + float swaprr = ((*(ptr+3) * args->right_rear_f) * args->distance_f); + switch (args->room_angle) { + case 0: + *(ptr++) = swapl; + *(ptr++) = swapr; + *(ptr++) = swaplr; + *(ptr++) = swaprr; + break; + case 90: + *(ptr++) = swapr; + *(ptr++) = swaprr; + *(ptr++) = swapl; + *(ptr++) = swaplr; + break; + case 180: + *(ptr++) = swaprr; + *(ptr++) = swaplr; + *(ptr++) = swapr; + *(ptr++) = swapl; + break; + case 270: + *(ptr++) = swaplr; + *(ptr++) = swapl; + *(ptr++) = swaprr; + *(ptr++) = swapr; + break; + } + } +} +static void SDLCALL _Eff_position_f32sys_c6(int chan, void *stream, int len, void *udata) +{ + /* float * 6 channels. */ + volatile position_args *args = (volatile position_args *) udata; + float *ptr = (float *) stream; + int i; + + for (i = 0; i < len; i += sizeof (float) * 6) { + float swapl = ((*(ptr+0) * args->left_f) * args->distance_f); + float swapr = ((*(ptr+1) * args->right_f) * args->distance_f); + float swaplr = ((*(ptr+2) * args->left_rear_f) * args->distance_f); + float swaprr = ((*(ptr+3) * args->right_rear_f) * args->distance_f); + float swapce = ((*(ptr+4) * args->center_f) * args->distance_f); + float swapwf = ((*(ptr+5) * args->lfe_f) * args->distance_f); + + switch (args->room_angle) { + case 0: + *(ptr++) = swapl; + *(ptr++) = swapr; + *(ptr++) = swaplr; + *(ptr++) = swaprr; + *(ptr++) = swapce; + *(ptr++) = swapwf; + break; + case 90: + *(ptr++) = swapr; + *(ptr++) = swaprr; + *(ptr++) = swapl; + *(ptr++) = swaplr; + *(ptr++) = swapr/2.0f + swaprr/2.0f; + *(ptr++) = swapwf; + break; + case 180: + *(ptr++) = swaprr; + *(ptr++) = swaplr; + *(ptr++) = swapr; + *(ptr++) = swapl; + *(ptr++) = swaprr/2.0f + swaplr/2.0f; + *(ptr++) = swapwf; + break; + case 270: + *(ptr++) = swaplr; + *(ptr++) = swapl; + *(ptr++) = swaprr; + *(ptr++) = swapr; + *(ptr++) = swapl/2.0f + swaplr/2.0f; + *(ptr++) = swapwf; + break; + } + } +} + static void init_position_args(position_args *args) { SDL_memset(args, '\0', sizeof (position_args)); @@ -1195,96 +1551,169 @@ switch (channels) { case 1: case 2: - f = (_Eff_build_volume_table_u8()) ? _Eff_position_table_u8 : + f = (_Eff_build_volume_table_u8()) ? _Eff_position_table_u8 : _Eff_position_u8; break; - case 4: - f = _Eff_position_u8_c4; - break; - case 6: - f = _Eff_position_u8_c6; - break; - } - break; + case 4: + f = _Eff_position_u8_c4; + break; + case 6: + f = _Eff_position_u8_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; case AUDIO_S8: switch (channels) { case 1: case 2: - f = (_Eff_build_volume_table_s8()) ? _Eff_position_table_s8 : + f = (_Eff_build_volume_table_s8()) ? _Eff_position_table_s8 : _Eff_position_s8; break; - case 4: - f = _Eff_position_s8_c4; - break; - case 6: - f = _Eff_position_s8_c6; - break; - } - break; + case 4: + f = _Eff_position_s8_c4; + break; + case 6: + f = _Eff_position_s8_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; case AUDIO_U16LSB: switch (channels) { case 1: case 2: - f = _Eff_position_u16lsb; - break; - case 4: - f = _Eff_position_u16lsb_c4; - break; - case 6: - f = _Eff_position_u16lsb_c6; - break; - } - break; + f = _Eff_position_u16lsb; + break; + case 4: + f = _Eff_position_u16lsb_c4; + break; + case 6: + f = _Eff_position_u16lsb_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; case AUDIO_S16LSB: switch (channels) { case 1: case 2: - f = _Eff_position_s16lsb; - break; - case 4: - f = _Eff_position_s16lsb_c4; - break; - case 6: - f = _Eff_position_s16lsb_c6; - break; - } - break; + f = _Eff_position_s16lsb; + break; + case 4: + f = _Eff_position_s16lsb_c4; + break; + case 6: + f = _Eff_position_s16lsb_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; case AUDIO_U16MSB: switch (channels) { case 1: case 2: - f = _Eff_position_u16msb; - break; - case 4: - f = _Eff_position_u16msb_c4; - break; - case 6: - f = _Eff_position_u16msb_c6; - break; - } - break; + f = _Eff_position_u16msb; + break; + case 4: + f = _Eff_position_u16msb_c4; + break; + case 6: + f = _Eff_position_u16msb_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; case AUDIO_S16MSB: switch (channels) { case 1: case 2: - f = _Eff_position_s16msb; - break; - case 4: - f = _Eff_position_s16msb_c4; - break; - case 6: - f = _Eff_position_s16msb_c6; - break; - } - break; + f = _Eff_position_s16msb; + break; + case 4: + f = _Eff_position_s16msb_c4; + break; + case 6: + f = _Eff_position_s16msb_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; + + case AUDIO_S32MSB: + switch (channels) { + case 1: + case 2: + f = _Eff_position_s32msb; + break; + case 4: + f = _Eff_position_s32msb_c4; + break; + case 6: + f = _Eff_position_s32msb_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; + + case AUDIO_S32LSB: + switch (channels) { + case 1: + case 2: + f = _Eff_position_s32lsb; + break; + case 4: + f = _Eff_position_s32lsb_c4; + break; + case 6: + f = _Eff_position_s32lsb_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; + + case AUDIO_F32SYS: + switch (channels) { + case 1: + case 2: + f = _Eff_position_f32sys; + break; + case 4: + f = _Eff_position_f32sys_c4; + break; + case 6: + f = _Eff_position_f32sys_c6; + break; + default: + Mix_SetError("Unsupported audio channels"); + break; + } + break; default: Mix_SetError("Unsupported audio format"); + break; } return(f); @@ -1446,17 +1875,17 @@ angle = -angle; angle = angle * 90 / 128; /* Make it larger for more effect? */ } - return( Mix_SetPosition(channel, angle, 0) ); + return(Mix_SetPosition(channel, angle, 0)); } f = get_position_effect_func(format, channels); if (f == NULL) return(0); - SDL_LockAudio(); + Mix_LockAudio(); args = get_position_arg(channel); if (!args) { - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(0); } @@ -1464,10 +1893,10 @@ if ((args->distance_u8 == 255) && (left == 255) && (right == 255)) { if (args->in_use) { retval = _Mix_UnregisterEffect_locked(channel, f); - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(retval); } else { - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(1); } } @@ -1483,7 +1912,7 @@ retval=_Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void*)args); } - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(retval); } @@ -1501,10 +1930,10 @@ if (f == NULL) return(0); - SDL_LockAudio(); + Mix_LockAudio(); args = get_position_arg(channel); if (!args) { - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(0); } @@ -1514,10 +1943,10 @@ if ((distance == 255) && (args->left_u8 == 255) && (args->right_u8 == 255)) { if (args->in_use) { retval = _Mix_UnregisterEffect_locked(channel, f); - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(retval); } else { - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(1); } } @@ -1529,7 +1958,7 @@ retval = _Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void *) args); } - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(retval); } @@ -1550,10 +1979,10 @@ angle = SDL_abs(angle) % 360; /* make angle between 0 and 359. */ - SDL_LockAudio(); + Mix_LockAudio(); args = get_position_arg(channel); if (!args) { - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(0); } @@ -1561,10 +1990,10 @@ if ((!distance) && (!angle)) { if (args->in_use) { retval = _Mix_UnregisterEffect_locked(channel, f); - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(retval); } else { - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(1); } } @@ -1610,10 +2039,11 @@ retval = _Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void *) args); } - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(retval); } /* end of effects_position.c ... */ +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/effect_stereoreverse.c b/effect_stereoreverse.c index 860035f..f4677e1 100644 --- a/effect_stereoreverse.c +++ b/effect_stereoreverse.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -55,7 +55,22 @@ * Stereo reversal effect...this one's pretty straightforward... */ -static void _Eff_reversestereo16(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_reversestereo32(int chan, void *stream, int len, void *udata) +{ + /* 16 bits * 2 channels. */ + Uint32 *ptr = (Uint32 *) stream; + Uint32 tmp; + int i; + + for (i = 0; i < len; i += 2 * sizeof (Uint32), ptr += 2) { + tmp = ptr[0]; + ptr[0] = ptr[1]; + ptr[1] = tmp; + } +} + + +static void SDLCALL _Eff_reversestereo16(int chan, void *stream, int len, void *udata) { /* 16 bits * 2 channels. */ Uint32 *ptr = (Uint32 *) stream; @@ -67,7 +82,7 @@ } -static void _Eff_reversestereo8(int chan, void *stream, int len, void *udata) +static void SDLCALL _Eff_reversestereo8(int chan, void *stream, int len, void *udata) { /* 8 bits * 2 channels. */ Uint32 *ptr = (Uint32 *) stream; @@ -96,11 +111,18 @@ Mix_QuerySpec(NULL, &format, &channels); if (channels == 2) { - if ((format & 0xFF) == 16) + int bits = (format & 0xFF); + switch (bits) { + case 8: + f = _Eff_reversestereo8; + break; + case 16: f = _Eff_reversestereo16; - else if ((format & 0xFF) == 8) - f = _Eff_reversestereo8; - else { + break; + case 32: + f = _Eff_reversestereo32; + break; + default: Mix_SetError("Unsupported audio format"); return(0); } @@ -110,6 +132,9 @@ } else { return(Mix_RegisterEffect(channel, f, NULL, NULL)); } + } else { + Mix_SetError("Trying to reverse stereo on a non-stereo stream"); + return(0); } return(1); @@ -118,3 +143,4 @@ /* end of effect_stereoreverse.c ... */ +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/effects_internal.c b/effects_internal.c index edee647..c4ba220 100644 --- a/effects_internal.c +++ b/effects_internal.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -122,3 +122,4 @@ /* end of effects.c ... */ +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/effects_internal.h b/effects_internal.h index 7a2522b..bb85df0 100644 --- a/effects_internal.h +++ b/effects_internal.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -30,11 +30,6 @@ #include "SDL_mixer.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - extern int _Mix_effects_max_speed; extern void *_Eff_volume_table; void *_Eff_build_volume_table_u8(void); @@ -49,12 +44,6 @@ int _Mix_UnregisterEffect_locked(int channel, Mix_EffectFunc_t f); int _Mix_UnregisterAllEffects_locked(int channel); +#endif /* _INCLUDE_EFFECTS_INTERNAL_H_ */ -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -} -#endif - - -#endif - +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/fluidsynth.c b/fluidsynth.c deleted file mode 100644 index 0a5d2dc..0000000 --- a/fluidsynth.c +++ /dev/null @@ -1,223 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - James Le Cuirot - chewi@aura-online.co.uk -*/ - -#ifdef USE_FLUIDSYNTH_MIDI - -#include -#include - -#include "SDL_mixer.h" -#include "fluidsynth.h" - -static Uint16 format; -static Uint8 channels; -static int freq; - -int fluidsynth_check_soundfont(const char *path, void *data) -{ - FILE *file = fopen(path, "r"); - - if (file) { - fclose(file); - return 1; - } else { - Mix_SetError("Failed to access the SoundFont %s", path); - return 0; - } -} - -int fluidsynth_load_soundfont(const char *path, void *data) -{ - /* If this fails, it's too late to try Timidity so pray that at least one works. */ - fluidsynth.fluid_synth_sfload((fluid_synth_t*) data, path, 1); - return 1; -} - -int fluidsynth_init(SDL_AudioSpec *mixer) -{ - if (!Mix_EachSoundFont(fluidsynth_check_soundfont, NULL)) - return -1; - - format = mixer->format; - channels = mixer->channels; - freq = mixer->freq; - - return 0; -} - -static FluidSynthMidiSong *fluidsynth_loadsong_common(int (*function)(FluidSynthMidiSong*, void*), void *data) -{ - FluidSynthMidiSong *song; - fluid_settings_t *settings = NULL; - - if (!Mix_Init(MIX_INIT_FLUIDSYNTH)) { - return NULL; - } - - if ((song = SDL_malloc(sizeof(FluidSynthMidiSong)))) { - SDL_memset(song, 0, sizeof(FluidSynthMidiSong)); - - if (SDL_BuildAudioCVT(&song->convert, AUDIO_S16, 2, freq, format, channels, freq) >= 0) { - if ((settings = fluidsynth.new_fluid_settings())) { - fluidsynth.fluid_settings_setnum(settings, "synth.sample-rate", (double) freq); - - if ((song->synth = fluidsynth.new_fluid_synth(settings))) { - if (Mix_EachSoundFont(fluidsynth_load_soundfont, (void*) song->synth)) { - if ((song->player = fluidsynth.new_fluid_player(song->synth))) { - if (function(song, data)) return song; - fluidsynth.delete_fluid_player(song->player); - } else { - Mix_SetError("Failed to create FluidSynth player"); - } - } - fluidsynth.delete_fluid_synth(song->synth); - } else { - Mix_SetError("Failed to create FluidSynth synthesizer"); - } - fluidsynth.delete_fluid_settings(settings); - } else { - Mix_SetError("Failed to create FluidSynth settings"); - } - } else { - Mix_SetError("Failed to set up audio conversion"); - } - SDL_free(song); - } else { - Mix_SetError("Insufficient memory for song"); - } - return NULL; -} - -static int fluidsynth_loadsong_RW_internal(FluidSynthMidiSong *song, void *data) -{ - Sint64 offset; - size_t size; - char *buffer; - SDL_RWops *src = (SDL_RWops*) data; - - offset = SDL_RWtell(src); - SDL_RWseek(src, 0, RW_SEEK_END); - size = (size_t)(SDL_RWtell(src) - offset); - SDL_RWseek(src, offset, RW_SEEK_SET); - - if ((buffer = (char*) SDL_malloc(size))) { - if(SDL_RWread(src, buffer, size, 1) == 1) { - if (fluidsynth.fluid_player_add_mem(song->player, buffer, size) == FLUID_OK) { - SDL_free(buffer); - return 1; - } else { - Mix_SetError("FluidSynth failed to load in-memory song"); - } - } else { - Mix_SetError("Failed to read in-memory song"); - } - SDL_free(buffer); - } else { - Mix_SetError("Insufficient memory for song"); - } - return 0; -} - -FluidSynthMidiSong *fluidsynth_loadsong_RW(SDL_RWops *src, int freesrc) -{ - FluidSynthMidiSong *song; - - song = fluidsynth_loadsong_common(fluidsynth_loadsong_RW_internal, (void*) src); - if (song && freesrc) { - SDL_RWclose(src); - } - return song; -} - -void fluidsynth_freesong(FluidSynthMidiSong *song) -{ - if (!song) return; - fluidsynth.delete_fluid_player(song->player); - fluidsynth.delete_fluid_settings(fluidsynth.fluid_synth_get_settings(song->synth)); - fluidsynth.delete_fluid_synth(song->synth); - SDL_free(song); -} - -void fluidsynth_start(FluidSynthMidiSong *song) -{ - fluidsynth.fluid_player_set_loop(song->player, 1); - fluidsynth.fluid_player_play(song->player); -} - -void fluidsynth_stop(FluidSynthMidiSong *song) -{ - fluidsynth.fluid_player_stop(song->player); -} - -int fluidsynth_active(FluidSynthMidiSong *song) -{ - return fluidsynth.fluid_player_get_status(song->player) == FLUID_PLAYER_PLAYING ? 1 : 0; -} - -void fluidsynth_setvolume(FluidSynthMidiSong *song, int volume) -{ - /* FluidSynth's default is 0.2. Make 1.2 the maximum. */ - fluidsynth.fluid_synth_set_gain(song->synth, (float) (volume * 1.2 / MIX_MAX_VOLUME)); -} - -int fluidsynth_playsome(FluidSynthMidiSong *song, void *dest, int dest_len) -{ - int result = -1; - int frames = dest_len / channels / ((format & 0xFF) / 8); - int src_len = frames * 4; /* 16-bit stereo */ - void *src = dest; - - if (dest_len < src_len) { - if (!(src = SDL_malloc(src_len))) { - Mix_SetError("Insufficient memory for audio conversion"); - return result; - } - } - - if (fluidsynth.fluid_synth_write_s16(song->synth, frames, src, 0, 2, src, 1, 2) != FLUID_OK) { - Mix_SetError("Error generating FluidSynth audio"); - goto finish; - } - - song->convert.buf = src; - song->convert.len = src_len; - - if (SDL_ConvertAudio(&song->convert) < 0) { - Mix_SetError("Error during audio conversion"); - goto finish; - } - - if (src != dest) - SDL_memcpy(dest, src, dest_len); - - result = 0; - -finish: - if (src != dest) - SDL_free(src); - - return result; -} - -#endif /* USE_FLUIDSYNTH_MIDI */ diff --git a/fluidsynth.h b/fluidsynth.h deleted file mode 100644 index ae3f2cb..0000000 --- a/fluidsynth.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - James Le Cuirot - chewi@aura-online.co.uk -*/ - -#ifndef _FLUIDSYNTH_H_ -#define _FLUIDSYNTH_H_ - -#ifdef USE_FLUIDSYNTH_MIDI - -#include "dynamic_fluidsynth.h" -#include -#include - -typedef struct { - SDL_AudioCVT convert; - fluid_synth_t *synth; - fluid_player_t* player; -} FluidSynthMidiSong; - -int fluidsynth_init(SDL_AudioSpec *mixer); -FluidSynthMidiSong *fluidsynth_loadsong_RW(SDL_RWops *rw, int freerw); -void fluidsynth_freesong(FluidSynthMidiSong *song); -void fluidsynth_start(FluidSynthMidiSong *song); -void fluidsynth_stop(FluidSynthMidiSong *song); -int fluidsynth_active(FluidSynthMidiSong *song); -void fluidsynth_setvolume(FluidSynthMidiSong *song, int volume); -int fluidsynth_playsome(FluidSynthMidiSong *song, void *stream, int len); - -#endif /* USE_FLUIDSYNTH_MIDI */ - -#endif /* _FLUIDSYNTH_H_ */ diff --git a/load_aiff.c b/load_aiff.c index a112882..16d0263 100644 --- a/load_aiff.c +++ b/load_aiff.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -28,11 +28,6 @@ in december 2002. */ -/* $Id$ */ - -#include -#include - #include "SDL_endian.h" #include "SDL_mixer.h" #include "load_aiff.h" @@ -57,8 +52,8 @@ static Uint32 SANE_to_Uint32 (Uint8 *sanebuf) { /* Is the frequency outside of what we can represent with Uint32? */ - if ( (sanebuf[0] & 0x80) || (sanebuf[0] <= 0x3F) || (sanebuf[0] > 0x40) - || (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C) ) + if ((sanebuf[0] & 0x80) || (sanebuf[0] <= 0x3F) || (sanebuf[0] > 0x40) + || (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C)) return 0; return ((sanebuf[2] << 23) | (sanebuf[3] << 15) | (sanebuf[4] << 7) @@ -98,21 +93,21 @@ /* Make sure we are passed a valid data source */ was_error = 0; - if ( src == NULL ) { + if (src == NULL) { was_error = 1; goto done; } FORMchunk = SDL_ReadLE32(src); chunk_length = SDL_ReadBE32(src); - if ( chunk_length == AIFF ) { /* The FORMchunk has already been read */ + if (chunk_length == AIFF) { /* The FORMchunk has already been read */ AIFFmagic = chunk_length; chunk_length = FORMchunk; FORMchunk = FORM; } else { AIFFmagic = SDL_ReadLE32(src); } - if ( (FORMchunk != FORM) || ( (AIFFmagic != AIFF) && (AIFFmagic != _8SVX) ) ) { + if ((FORMchunk != FORM) || ((AIFFmagic != AIFF) && (AIFFmagic != _8SVX))) { SDL_SetError("Unrecognized file type (not AIFF nor 8SVX)"); was_error = 1; goto done; @@ -177,29 +172,29 @@ /* a 0 pad byte can be stored for any odd-length chunk */ if (chunk_length&1) next_chunk++; - } while ( ( ( (AIFFmagic == AIFF) && ( !found_SSND || !found_COMM ) ) - || ( (AIFFmagic == _8SVX ) && ( !found_VHDR || !found_BODY ) ) ) - && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != 1 ); - - if ( (AIFFmagic == AIFF) && !found_SSND ) { + } while ((((AIFFmagic == AIFF) && (!found_SSND || !found_COMM)) + || ((AIFFmagic == _8SVX) && (!found_VHDR || !found_BODY))) + && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != 1); + + if ((AIFFmagic == AIFF) && !found_SSND) { SDL_SetError("Bad AIFF (no SSND chunk)"); was_error = 1; goto done; } - if ( (AIFFmagic == AIFF) && !found_COMM ) { + if ((AIFFmagic == AIFF) && !found_COMM) { SDL_SetError("Bad AIFF (no COMM chunk)"); was_error = 1; goto done; } - if ( (AIFFmagic == _8SVX) && !found_VHDR ) { + if ((AIFFmagic == _8SVX) && !found_VHDR) { SDL_SetError("Bad 8SVX (no VHDR chunk)"); was_error = 1; goto done; } - if ( (AIFFmagic == _8SVX) && !found_BODY ) { + if ((AIFFmagic == _8SVX) && !found_BODY) { SDL_SetError("Bad 8SVX (no BODY chunk)"); was_error = 1; goto done; @@ -225,12 +220,12 @@ *audio_len = channels * numsamples * (samplesize / 8); *audio_buf = (Uint8 *)SDL_malloc(*audio_len); - if ( *audio_buf == NULL ) { + if (*audio_buf == NULL) { SDL_SetError("Out of memory"); return(NULL); } SDL_RWseek(src, start, RW_SEEK_SET); - if ( SDL_RWread(src, *audio_buf, *audio_len, 1) != 1 ) { + if (SDL_RWread(src, *audio_buf, *audio_len, 1) != 1) { SDL_SetError("Unable to read audio data"); return(NULL); } @@ -248,3 +243,4 @@ return(spec); } +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/load_aiff.h b/load_aiff.h index 490ad2b..a786d83 100644 --- a/load_aiff.h +++ b/load_aiff.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -26,8 +26,8 @@ This file by Torbjörn Andersson (torbjorn.andersson@eurotime.se) */ -/* $Id$ */ - /* Don't call this directly; use Mix_LoadWAV_RW() for now. */ SDL_AudioSpec *Mix_LoadAIFF_RW (SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/load_flac.c b/load_flac.c deleted file mode 100644 index bf9fc51..0000000 --- a/load_flac.c +++ /dev/null @@ -1,329 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - This is the source needed to decode a FLAC into a waveform. - ~ Austen Dicken (admin@cvpcs.org). -*/ - -#ifdef FLAC_MUSIC - -#include -#include -#include - -#include "SDL_mutex.h" -#include "SDL_endian.h" -#include "SDL_timer.h" - -#include "SDL_mixer.h" -#include "dynamic_flac.h" -#include "load_flac.h" - -#include - -typedef struct { - SDL_RWops* sdl_src; - SDL_AudioSpec* sdl_spec; - Uint8** sdl_audio_buf; - Uint32* sdl_audio_len; - int sdl_audio_read; - FLAC__uint64 flac_total_samples; - unsigned flac_bps; -} FLAC_SDL_Data; - -static FLAC__StreamDecoderReadStatus flac_read_load_cb( - const FLAC__StreamDecoder *decoder, - FLAC__byte buffer[], - size_t *bytes, - void *client_data) -{ - // make sure there is something to be reading - if (*bytes > 0) { - FLAC_SDL_Data *data = (FLAC_SDL_Data *)client_data; - - *bytes = SDL_RWread (data->sdl_src, buffer, sizeof (FLAC__byte), - *bytes); - - if (*bytes == 0) { // error or no data was read (EOF) - return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - } else { // data was read, continue - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; - } - } else { - return FLAC__STREAM_DECODER_READ_STATUS_ABORT; - } -} - -static FLAC__StreamDecoderSeekStatus flac_seek_load_cb( - const FLAC__StreamDecoder *decoder, - FLAC__uint64 absolute_byte_offset, - void *client_data) -{ - FLAC_SDL_Data *data = (FLAC_SDL_Data *)client_data; - - if (SDL_RWseek (data->sdl_src, absolute_byte_offset, RW_SEEK_SET) < 0) { - return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; - } else { - return FLAC__STREAM_DECODER_SEEK_STATUS_OK; - } -} - -static FLAC__StreamDecoderTellStatus flac_tell_load_cb( - const FLAC__StreamDecoder *decoder, - FLAC__uint64 *absolute_byte_offset, - void *client_data) -{ - FLAC_SDL_Data *data = (FLAC_SDL_Data *)client_data; - - Sint64 pos = SDL_RWtell (data->sdl_src); - - if (pos < 0) { - return FLAC__STREAM_DECODER_TELL_STATUS_ERROR; - } else { - *absolute_byte_offset = (FLAC__uint64)pos; - return FLAC__STREAM_DECODER_TELL_STATUS_OK; - } -} - -static FLAC__StreamDecoderLengthStatus flac_length_load_cb( - const FLAC__StreamDecoder *decoder, - FLAC__uint64 *stream_length, - void *client_data) -{ - FLAC_SDL_Data *data = (FLAC_SDL_Data *)client_data; - - Sint64 pos = SDL_RWtell (data->sdl_src); - Sint64 length = SDL_RWseek (data->sdl_src, 0, RW_SEEK_END); - - if (SDL_RWseek (data->sdl_src, pos, RW_SEEK_SET) != pos || length < 0) { - /* there was an error attempting to return the stream to the original - * position, or the length was invalid. */ - return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR; - } else { - *stream_length = (FLAC__uint64)length; - return FLAC__STREAM_DECODER_LENGTH_STATUS_OK; - } -} - -static FLAC__bool flac_eof_load_cb(const FLAC__StreamDecoder *decoder, - void *client_data) -{ - FLAC_SDL_Data *data = (FLAC_SDL_Data *)client_data; - - Sint64 pos = SDL_RWtell (data->sdl_src); - Sint64 end = SDL_RWseek (data->sdl_src, 0, RW_SEEK_END); - - // was the original position equal to the end (a.k.a. the seek didn't move)? - if (pos == end) { - // must be EOF - return true; - } else { - // not EOF, return to the original position - SDL_RWseek (data->sdl_src, pos, RW_SEEK_SET); - return false; - } -} - -static FLAC__StreamDecoderWriteStatus flac_write_load_cb( - const FLAC__StreamDecoder *decoder, - const FLAC__Frame *frame, - const FLAC__int32 *const buffer[], - void *client_data) -{ - FLAC_SDL_Data *data = (FLAC_SDL_Data *)client_data; - size_t i; - Uint8 *buf; - - if (data->flac_total_samples == 0) { - SDL_SetError ("Given FLAC file does not specify its sample count."); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - - if (data->sdl_spec->channels != 2 || data->flac_bps != 16) { - SDL_SetError ("Current FLAC support is only for 16 bit Stereo files."); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - - // check if it is the first audio frame so we can initialize the output - // buffer - if (frame->header.number.sample_number == 0) { - *(data->sdl_audio_len) = data->sdl_spec->size; - data->sdl_audio_read = 0; - *(data->sdl_audio_buf) = SDL_malloc (*(data->sdl_audio_len)); - - if (*(data->sdl_audio_buf) == NULL) { - SDL_SetError - ("Unable to allocate memory to store the FLAC stream."); - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } - } - - buf = *(data->sdl_audio_buf); - - for (i = 0; i < frame->header.blocksize; i++) { - FLAC__int16 i16; - FLAC__uint16 ui16; - - i16 = (FLAC__int16)buffer[0][i]; - ui16 = (FLAC__uint16)i16; - - *(buf + (data->sdl_audio_read++)) = (char)(ui16); - *(buf + (data->sdl_audio_read++)) = (char)(ui16 >> 8); - - i16 = (FLAC__int16)buffer[1][i]; - ui16 = (FLAC__uint16)i16; - - *(buf + (data->sdl_audio_read++)) = (char)(ui16); - *(buf + (data->sdl_audio_read++)) = (char)(ui16 >> 8); - } - - return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; -} - -static void flac_metadata_load_cb( - const FLAC__StreamDecoder *decoder, - const FLAC__StreamMetadata *metadata, - void *client_data) -{ - FLAC_SDL_Data *data = (FLAC_SDL_Data *)client_data; - FLAC__uint64 total_samples; - unsigned bps; - - if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { - // save the metadata right now for use later on - *(data->sdl_audio_buf) = NULL; - *(data->sdl_audio_len) = 0; - memset (data->sdl_spec, '\0', sizeof (SDL_AudioSpec)); - - data->sdl_spec->format = AUDIO_S16; - data->sdl_spec->freq = (int)(metadata->data.stream_info.sample_rate); - data->sdl_spec->channels = (Uint8)(metadata->data.stream_info.channels); - data->sdl_spec->samples = 8192; /* buffer size */ - - total_samples = metadata->data.stream_info.total_samples; - bps = metadata->data.stream_info.bits_per_sample; - - data->sdl_spec->size = (Uint32)(total_samples * data->sdl_spec->channels * (bps / 8)); - data->flac_total_samples = total_samples; - data->flac_bps = bps; - } -} - -static void flac_error_load_cb( - const FLAC__StreamDecoder *decoder, - FLAC__StreamDecoderErrorStatus status, - void *client_data) -{ - // print an SDL error based on the error status - switch (status) { - case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC: - SDL_SetError ("Error processing the FLAC file [LOST_SYNC]."); - break; - case FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER: - SDL_SetError ("Error processing the FLAC file [BAD_HEADER]."); - break; - case FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH: - SDL_SetError ("Error processing the FLAC file [CRC_MISMATCH]."); - break; - case FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM: - SDL_SetError ("Error processing the FLAC file [UNPARSEABLE]."); - break; - default: - SDL_SetError ("Error processing the FLAC file [UNKNOWN]."); - break; - } -} - -/* don't call this directly; use Mix_LoadWAV_RW() for now. */ -SDL_AudioSpec *Mix_LoadFLAC_RW (SDL_RWops *src, int freesrc, - SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) -{ - FLAC__StreamDecoder *decoder = 0; - FLAC__StreamDecoderInitStatus init_status; - int was_error = 1; - int was_init = 0; - Uint32 samplesize; - - // create the client data passing information - FLAC_SDL_Data* client_data; - client_data = (FLAC_SDL_Data *)SDL_malloc (sizeof (FLAC_SDL_Data)); - - if ((!src) || (!audio_buf) || (!audio_len)) /* sanity checks. */ - goto done; - - if (!Mix_Init(MIX_INIT_FLAC)) - goto done; - - if ((decoder = flac.FLAC__stream_decoder_new ()) == NULL) { - SDL_SetError ("Unable to allocate FLAC decoder."); - goto done; - } - - init_status = flac.FLAC__stream_decoder_init_stream (decoder, - flac_read_load_cb, flac_seek_load_cb, - flac_tell_load_cb, flac_length_load_cb, - flac_eof_load_cb, flac_write_load_cb, - flac_metadata_load_cb, flac_error_load_cb, - client_data); - - if (init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) { - SDL_SetError ("Unable to initialize FLAC stream decoder."); - goto done; - } - - was_init = 1; - - client_data->sdl_src = src; - client_data->sdl_spec = spec; - client_data->sdl_audio_buf = audio_buf; - client_data->sdl_audio_len = audio_len; - - if (!flac.FLAC__stream_decoder_process_until_end_of_stream (decoder)) { - SDL_SetError ("Unable to process FLAC file."); - goto done; - } - - was_error = 0; - - /* Don't return a buffer that isn't a multiple of samplesize */ - samplesize = ((spec->format & 0xFF) / 8) * spec->channels; - *audio_len &= ~(samplesize - 1); - -done: - if (was_init && decoder) { - flac.FLAC__stream_decoder_finish (decoder); - } - - if (decoder) { - flac.FLAC__stream_decoder_delete (decoder); - } - - if (freesrc && src) { - SDL_RWclose (src); - } - - if (was_error) { - spec = NULL; - } - - return spec; -} - -#endif // FLAC_MUSIC diff --git a/load_flac.h b/load_flac.h deleted file mode 100644 index 6cd0442..0000000 --- a/load_flac.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - This is the source needed to decode a FLAC into a waveform. - ~ Austen Dicken (admin@cvpcs.org). -*/ - -/* $Id: $ */ - -#ifdef FLAC_MUSIC -/* Don't call this directly; use Mix_LoadWAV_RW() for now. */ -SDL_AudioSpec *Mix_LoadFLAC_RW (SDL_RWops *src, int freesrc, - SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); -#endif diff --git a/load_mp3.c b/load_mp3.c deleted file mode 100644 index 40e031c..0000000 --- a/load_mp3.c +++ /dev/null @@ -1,195 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - This is the source needed to decode an MP3 into a waveform. -*/ - -/* $Id$ */ - -#if defined(MP3_MUSIC) || defined(MP3_MAD_MUSIC) - -#include "SDL_mixer.h" - -#include "load_mp3.h" - -#if defined(MP3_MUSIC) -#include "dynamic_mp3.h" -#elif defined(MP3_MAD_MUSIC) -#include "music_mad.h" -#endif - -SDL_AudioSpec *Mix_LoadMP3_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) -{ - /* note: spec is initialized to mixer spec */ - -#if defined(MP3_MUSIC) - SMPEG* mp3; - SMPEG_Info info; -#elif defined(MP3_MAD_MUSIC) - mad_data *mp3_mad; -#endif - long samplesize; - int read_len; - const Uint32 chunk_len = 4096; - int err = 0; - - if ((!src) || (!spec) || (!audio_buf) || (!audio_len)) - { - return NULL; - } - - if (!err) - { - *audio_len = 0; - *audio_buf = (Uint8*) SDL_malloc(chunk_len); - err = (*audio_buf == NULL); - } - - if (!err) - { - err = ((Mix_Init(MIX_INIT_MP3) & MIX_INIT_MP3) == 0); - } - - if (!err) - { -#if defined(MP3_MUSIC) - mp3 = smpeg.SMPEG_new_rwops(src, &info, freesrc, 0); - err = (mp3 == NULL); -#elif defined(MP3_MAD_MUSIC) - mp3_mad = mad_openFileRW(src, spec, freesrc); - err = (mp3_mad == NULL); -#endif - } - -#if defined(MP3_MUSIC) - if (!err) - { - err = !info.has_audio; - } -#endif - - if (!err) - { -#if defined(MP3_MUSIC) - - smpeg.SMPEG_actualSpec(mp3, spec); - - smpeg.SMPEG_enableaudio(mp3, 1); - smpeg.SMPEG_enablevideo(mp3, 0); - - smpeg.SMPEG_play(mp3); - - /* read once for audio length */ - while ((read_len = smpeg.SMPEG_playAudio(mp3, *audio_buf, chunk_len)) > 0) - { - *audio_len += read_len; - } - - smpeg.SMPEG_stop(mp3); - -#elif defined(MP3_MAD_MUSIC) - - mad_start(mp3_mad); - - /* read once for audio length */ - while ((read_len = mad_getSamples(mp3_mad, *audio_buf, chunk_len)) > 0) - { - *audio_len += read_len; - } - - mad_stop(mp3_mad); - -#endif - - err = (read_len < 0); - } - - if (!err) - { - /* reallocate, if needed */ - if ((*audio_len > 0) && (*audio_len != chunk_len)) - { - *audio_buf = (Uint8*) SDL_realloc(*audio_buf, *audio_len); - err = (*audio_buf == NULL); - } - } - - if (!err) - { - /* read again for audio buffer, if needed */ - if (*audio_len > chunk_len) - { -#if defined(MP3_MUSIC) - smpeg.SMPEG_rewind(mp3); - smpeg.SMPEG_play(mp3); - err = (*audio_len != smpeg.SMPEG_playAudio(mp3, *audio_buf, *audio_len)); - smpeg.SMPEG_stop(mp3); -#elif defined(MP3_MAD_MUSIC) - mad_seek(mp3_mad, 0); - mad_start(mp3_mad); - err = (*audio_len != mad_getSamples(mp3_mad, *audio_buf, *audio_len)); - mad_stop(mp3_mad); -#endif - } - } - - if (!err) - { - /* Don't return a buffer that isn't a multiple of samplesize */ - samplesize = ((spec->format & 0xFF)/8)*spec->channels; - *audio_len &= ~(samplesize-1); - } - -#if defined(MP3_MUSIC) - if (mp3) - { - smpeg.SMPEG_delete(mp3); mp3 = NULL; - /* Deleting the MP3 closed the source if desired */ - freesrc = SDL_FALSE; - } -#elif defined(MP3_MAD_MUSIC) - if (mp3_mad) - { - mad_closeFile(mp3_mad); mp3_mad = NULL; - /* Deleting the MP3 closed the source if desired */ - freesrc = SDL_FALSE; - } -#endif - - if (freesrc) - { - SDL_RWclose(src); src = NULL; - } - - /* handle error */ - if (err) - { - if (*audio_buf != NULL) - { - SDL_free(*audio_buf); *audio_buf = NULL; - } - *audio_len = 0; - spec = NULL; - } - - return spec; -} - -#endif diff --git a/load_mp3.h b/load_mp3.h deleted file mode 100644 index 8a8ea56..0000000 --- a/load_mp3.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - This is the source needed to decode an MP3 into a waveform. -*/ - -/* $Id$ */ - -#if defined(MP3_MUSIC) || defined(MP3_MAD_MUSIC) -/* Don't call this directly; use Mix_LoadWAV_RW() for now. */ -SDL_AudioSpec *Mix_LoadMP3_RW (SDL_RWops *src, int freesrc, - SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); -#endif diff --git a/load_ogg.c b/load_ogg.c deleted file mode 100644 index 3a0e293..0000000 --- a/load_ogg.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - This is the source needed to decode an Ogg Vorbis into a waveform. - This file by Vaclav Slavik (vaclav.slavik@matfyz.cz). -*/ - -/* $Id$ */ - -#ifdef OGG_MUSIC - -#include -#include -#include - -#include "SDL_mutex.h" -#include "SDL_endian.h" -#include "SDL_timer.h" - -#include "SDL_mixer.h" -#include "dynamic_ogg.h" -#include "load_ogg.h" - -static size_t sdl_read_func(void *ptr, size_t size, size_t nmemb, void *datasource) -{ - return SDL_RWread((SDL_RWops*)datasource, ptr, size, nmemb); -} - -static int sdl_seek_func(void *datasource, ogg_int64_t offset, int whence) -{ - return (int)SDL_RWseek((SDL_RWops*)datasource, offset, whence); -} - -static int sdl_close_func_freesrc(void *datasource) -{ - return SDL_RWclose((SDL_RWops*)datasource); -} - -static int sdl_close_func_nofreesrc(void *datasource) -{ - SDL_RWseek((SDL_RWops*)datasource, 0, RW_SEEK_SET); - return 0; -} - -static long sdl_tell_func(void *datasource) -{ - return (long)SDL_RWtell((SDL_RWops*)datasource); -} - - -/* don't call this directly; use Mix_LoadWAV_RW() for now. */ -SDL_AudioSpec *Mix_LoadOGG_RW (SDL_RWops *src, int freesrc, - SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) -{ - OggVorbis_File vf; - ov_callbacks callbacks; - vorbis_info *info; - Uint8 *buf; - int bitstream = -1; - long samplesize; - long samples; - int read, to_read; - int must_close = 1; - int was_error = 1; - - if ( (!src) || (!audio_buf) || (!audio_len) ) /* sanity checks. */ - goto done; - - if ( !Mix_Init(MIX_INIT_OGG) ) - goto done; - - callbacks.read_func = sdl_read_func; - callbacks.seek_func = sdl_seek_func; - callbacks.tell_func = sdl_tell_func; - callbacks.close_func = freesrc ? - sdl_close_func_freesrc : sdl_close_func_nofreesrc; - - if (vorbis.ov_open_callbacks(src, &vf, NULL, 0, callbacks) != 0) - { - SDL_SetError("OGG bitstream is not valid Vorbis stream!"); - goto done; - } - - must_close = 0; - - info = vorbis.ov_info(&vf, -1); - - *audio_buf = NULL; - *audio_len = 0; - memset(spec, '\0', sizeof (SDL_AudioSpec)); - - spec->format = AUDIO_S16; - spec->channels = info->channels; - spec->freq = info->rate; - spec->samples = 4096; /* buffer size */ - - samples = (long)vorbis.ov_pcm_total(&vf, -1); - - *audio_len = spec->size = samples * spec->channels * 2; - *audio_buf = (Uint8 *)SDL_malloc(*audio_len); - if (*audio_buf == NULL) - goto done; - - buf = *audio_buf; - to_read = *audio_len; -#ifdef OGG_USE_TREMOR - for (read = vorbis.ov_read(&vf, (char *)buf, to_read, &bitstream); - read > 0; - read = vorbis.ov_read(&vf, (char *)buf, to_read, &bitstream)) -#else - for (read = vorbis.ov_read(&vf, (char *)buf, to_read, 0/*LE*/, 2/*16bit*/, 1/*signed*/, &bitstream); - read > 0; - read = vorbis.ov_read(&vf, (char *)buf, to_read, 0, 2, 1, &bitstream)) -#endif - { - if (read == OV_HOLE || read == OV_EBADLINK) - break; /* error */ - - to_read -= read; - buf += read; - } - - vorbis.ov_clear(&vf); - was_error = 0; - - /* Don't return a buffer that isn't a multiple of samplesize */ - samplesize = ((spec->format & 0xFF)/8)*spec->channels; - *audio_len &= ~(samplesize-1); - -done: - if (freesrc && src && must_close) { - SDL_RWclose(src); - } - - if (was_error) { - spec = NULL; - } - - return(spec); -} /* Mix_LoadOGG_RW */ - -/* end of load_ogg.c ... */ - -#endif diff --git a/load_ogg.h b/load_ogg.h deleted file mode 100644 index a13ef6c..0000000 --- a/load_ogg.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - This is the source needed to decode an Ogg Vorbis into a waveform. - This file by Vaclav Slavik (vaclav.slavik@matfyz.cz). -*/ - -/* $Id$ */ - -#ifdef OGG_MUSIC -/* Don't call this directly; use Mix_LoadWAV_RW() for now. */ -SDL_AudioSpec *Mix_LoadOGG_RW (SDL_RWops *src, int freesrc, - SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); -#endif diff --git a/load_voc.c b/load_voc.c index cc495f7..4669756 100644 --- a/load_voc.c +++ b/load_voc.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -28,16 +28,6 @@ Heavily borrowed from sox v12.17.1's voc.c. (http://www.freshmeat.net/projects/sox/) */ - -/* $Id$ */ - -#include -#include -#include - -#include "SDL_mutex.h" -#include "SDL_endian.h" -#include "SDL_timer.h" #include "SDL_mixer.h" #include "load_voc.h" @@ -99,7 +89,7 @@ if (SDL_RWread(src, signature, sizeof (signature), 1) != 1) return(0); - if (memcmp(signature, "Creative Voice File\032", sizeof (signature)) != 0) { + if (SDL_memcmp(signature, "Creative Voice File\032", sizeof (signature)) != 0) { SDL_SetError("Unrecognized file type (not VOC)"); return(0); } @@ -142,7 +132,7 @@ return 1; /* assume that's the end of the file. */ /* Size is an 24-bit value. Ugh. */ - sblen = ( (bits24[0]) | (bits24[1] << 8) | (bits24[2] << 16) ); + sblen = ((bits24[0]) | (bits24[1] << 8) | (bits24[2] << 16)); switch(block) { @@ -329,7 +319,7 @@ static int voc_read(SDL_RWops *src, vs_t *v, Uint8 *buf, SDL_AudioSpec *spec) { - int done = 0; + Uint32 done = 0; Uint8 silence = 0x80; if (v->rest == 0) @@ -354,7 +344,7 @@ else { - done = SDL_RWread(src, buf, 1, v->rest); + done = (Uint32)SDL_RWread(src, buf, 1, v->rest); v->rest -= done; if (v->size == ST_SIZE_WORD) { @@ -384,10 +374,10 @@ Uint8 *fillptr; void *ptr; - if ( (!src) || (!audio_buf) || (!audio_len) ) /* sanity checks. */ + if ((!src) || (!audio_buf) || (!audio_len)) /* sanity checks. */ goto done; - if ( !voc_check_header(src) ) + if (!voc_check_header(src)) goto done; v.rate = -1; @@ -457,3 +447,5 @@ } /* Mix_LoadVOC_RW */ /* end of load_voc.c ... */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/load_voc.h b/load_voc.h index 6afd2f6..8099c26 100644 --- a/load_voc.h +++ b/load_voc.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -29,8 +29,8 @@ (http://www.freshmeat.net/projects/sox/) */ -/* $Id$ */ - /* Don't call this directly; use Mix_LoadWAV_RW() for now. */ SDL_AudioSpec *Mix_LoadVOC_RW (SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/mixer.c b/mixer.c index bebb6c0..8a54e20 100644 --- a/mixer.c +++ b/mixer.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -25,22 +25,13 @@ #include #include -#include "SDL_mutex.h" -#include "SDL_endian.h" -#include "SDL_timer.h" +#include "SDL.h" #include "SDL_mixer.h" +#include "mixer.h" +#include "music.h" #include "load_aiff.h" #include "load_voc.h" -#include "load_mp3.h" -#include "load_ogg.h" -#include "load_flac.h" -#include "dynamic_flac.h" -#include "dynamic_fluidsynth.h" -#include "dynamic_modplug.h" -#include "dynamic_mod.h" -#include "dynamic_mp3.h" -#include "dynamic_ogg.h" #define __MIX_INTERNAL_EFFECT__ #include "effects_internal.h" @@ -49,12 +40,11 @@ #define RIFF 0x46464952 /* "RIFF" */ #define WAVE 0x45564157 /* "WAVE" */ #define FORM 0x4d524f46 /* "FORM" */ -#define OGGS 0x5367674f /* "OggS" */ #define CREA 0x61657243 /* "Crea" */ -#define FLAC 0x43614C66 /* "fLaC" */ static int audio_opened = 0; static SDL_AudioSpec mixer; +static SDL_AudioDeviceID audio_device; typedef struct _Mix_effectinfo { @@ -89,30 +79,20 @@ /* Support for hooking into the mixer callback system */ -static void (*mix_postmix)(void *udata, Uint8 *stream, int len) = NULL; +static void (SDLCALL *mix_postmix)(void *udata, Uint8 *stream, int len) = NULL; static void *mix_postmix_data = NULL; /* rcg07062001 callback to alert when channels are done playing. */ -static void (*channel_done_callback)(int channel) = NULL; - -/* Music function declarations */ -extern int open_music(SDL_AudioSpec *mixer); -extern void close_music(void); - -/* Support for user defined music functions, plus the default one */ -extern int volatile music_active; -extern void music_mixer(void *udata, Uint8 *stream, int len); -static void (*mix_music)(void *udata, Uint8 *stream, int len) = music_mixer; +static void (SDLCALL *channel_done_callback)(int channel) = NULL; + +/* Support for user defined music functions */ +static void (SDLCALL *mix_music)(void *udata, Uint8 *stream, int len) = music_mixer; static void *music_data = NULL; /* rcg06042009 report available decoders at runtime. */ static const char **chunk_decoders = NULL; static int num_decoders = 0; -/* Semicolon-separated SoundFont paths */ -#ifdef MID_MUSIC -extern char* soundfont_paths; -#endif int Mix_GetNumChunkDecoders(void) { @@ -125,6 +105,17 @@ return NULL; } return(chunk_decoders[index]); +} + +SDL_bool Mix_HasChunkDecoder(const char *name) +{ + int index; + for (index = 0; index < num_decoders; ++index) { + if (SDL_strcasecmp(name, chunk_decoders[index]) == 0) { + return SDL_TRUE; + } + } + return SDL_FALSE; } static void add_chunk_decoder(const char *decoder) @@ -145,119 +136,60 @@ return(&linked_version); } -static int initialized = 0; - int Mix_Init(int flags) { int result = 0; - if (flags & MIX_INIT_FLUIDSYNTH) { -#ifdef USE_FLUIDSYNTH_MIDI - if ((initialized & MIX_INIT_FLUIDSYNTH) || Mix_InitFluidSynth() == 0) { - result |= MIX_INIT_FLUIDSYNTH; - } -#else - Mix_SetError("Mixer not built with FluidSynth support"); -#endif - } + load_music(); + if (flags & MIX_INIT_FLAC) { -#ifdef FLAC_MUSIC - if ((initialized & MIX_INIT_FLAC) || Mix_InitFLAC() == 0) { + if (has_music(MUS_FLAC)) { result |= MIX_INIT_FLAC; - } -#else - Mix_SetError("Mixer not built with FLAC support"); -#endif - } - if (flags & MIX_INIT_MODPLUG) { -#ifdef MODPLUG_MUSIC - if ((initialized & MIX_INIT_MODPLUG) || Mix_InitModPlug() == 0) { - result |= MIX_INIT_MODPLUG; - } -#else - Mix_SetError("Mixer not built with MOD modplug support"); -#endif + } else { + Mix_SetError("FLAC support not available"); + } } if (flags & MIX_INIT_MOD) { -#ifdef MOD_MUSIC - if ((initialized & MIX_INIT_MOD) || Mix_InitMOD() == 0) { + if (has_music(MUS_MOD)) { result |= MIX_INIT_MOD; - } -#else - Mix_SetError("Mixer not built with MOD mikmod support"); -#endif + } else { + Mix_SetError("MOD support not available"); + } } if (flags & MIX_INIT_MP3) { -#ifdef MP3_MUSIC - if ((initialized & MIX_INIT_MP3) || Mix_InitMP3() == 0) { + if (has_music(MUS_MP3)) { result |= MIX_INIT_MP3; - } -#elif defined(MP3_MAD_MUSIC) - result |= MIX_INIT_MP3; -#else - Mix_SetError("Mixer not built with MP3 support"); -#endif + } else { + Mix_SetError("MP3 support not available"); + } } if (flags & MIX_INIT_OGG) { -#ifdef OGG_MUSIC - if ((initialized & MIX_INIT_OGG) || Mix_InitOgg() == 0) { + if (has_music(MUS_OGG)) { result |= MIX_INIT_OGG; - } -#else - Mix_SetError("Mixer not built with Ogg Vorbis support"); -#endif - } - initialized |= result; - + } else { + Mix_SetError("OGG support not available"); + } + } + if (flags & MIX_INIT_MID) { + if (has_music(MUS_MID)) { + result |= MIX_INIT_MID; + } else { + Mix_SetError("MIDI support not available"); + } + } return (result); } void Mix_Quit() { -#ifdef USE_FLUIDSYNTH_MIDI - if (initialized & MIX_INIT_FLUIDSYNTH) { - Mix_QuitFluidSynth(); - } -#endif -#ifdef FLAC_MUSIC - if (initialized & MIX_INIT_FLAC) { - Mix_QuitFLAC(); - } -#endif -#ifdef MODPLUG_MUSIC - if (initialized & MIX_INIT_MODPLUG) { - Mix_QuitModPlug(); - } -#endif -#ifdef MOD_MUSIC - if (initialized & MIX_INIT_MOD) { - Mix_QuitMOD(); - } -#endif -#ifdef MP3_MUSIC - if (initialized & MIX_INIT_MP3) { - Mix_QuitMP3(); - } -#endif -#ifdef OGG_MUSIC - if (initialized & MIX_INIT_OGG) { - Mix_QuitOgg(); - } -#endif -#ifdef MID_MUSIC - if (soundfont_paths) { - SDL_free(soundfont_paths); - soundfont_paths = NULL; - } -#endif - initialized = 0; + unload_music(); } static int _Mix_remove_all_effects(int channel, effect_info **e); /* * rcg06122001 Cleanup effect callbacks. - * MAKE SURE SDL_LockAudio() is called before this (or you're in the + * MAKE SURE Mix_LockAudio() is called before this (or you're in the * audio callback). */ static void _Mix_channel_done_playing(int channel) @@ -303,10 +235,11 @@ /* Mixing function */ -static void mix_channels(void *udata, Uint8 *stream, int len) +static void SDLCALL +mix_channels(void *udata, Uint8 *stream, int len) { Uint8 *mix_input; - int i, mixable, volume = SDL_MIX_MAXVOLUME; + int i, mixable, volume = MIX_MAX_VOLUME; Uint32 sdl_ticks; #if SDL_VERSION_ATLEAST(1, 3, 0) @@ -315,26 +248,24 @@ #endif /* Mix the music (must be done before the channels are added) */ - if ( music_active || (mix_music != music_mixer) ) { - mix_music(music_data, stream, len); - } + mix_music(music_data, stream, len); /* Mix any playing channels... */ sdl_ticks = SDL_GetTicks(); - for ( i=0; i 0 && mix_channel[i].expire < sdl_ticks ) { + for (i=0; i 0 && mix_channel[i].expire < sdl_ticks) { /* Expiration delay for that channel is reached */ mix_channel[i].playing = 0; mix_channel[i].looping = 0; mix_channel[i].fading = MIX_NO_FADING; mix_channel[i].expire = 0; _Mix_channel_done_playing(i); - } else if ( mix_channel[i].fading != MIX_NO_FADING ) { + } else if (mix_channel[i].fading != MIX_NO_FADING) { Uint32 ticks = sdl_ticks - mix_channel[i].ticks_fade; - if ( ticks >= mix_channel[i].fade_length ) { + if (ticks >= mix_channel[i].fade_length) { Mix_Volume(i, mix_channel[i].fade_volume_reset); /* Restore the volume */ - if( mix_channel[i].fading == MIX_FADING_OUT ) { + if(mix_channel[i].fading == MIX_FADING_OUT) { mix_channel[i].playing = 0; mix_channel[i].looping = 0; mix_channel[i].expire = 0; @@ -342,27 +273,27 @@ } mix_channel[i].fading = MIX_NO_FADING; } else { - if ( mix_channel[i].fading == MIX_FADING_OUT ) { + if (mix_channel[i].fading == MIX_FADING_OUT) { Mix_Volume(i, (mix_channel[i].fade_volume * (mix_channel[i].fade_length-ticks)) - / mix_channel[i].fade_length ); + / mix_channel[i].fade_length); } else { - Mix_Volume(i, (mix_channel[i].fade_volume * ticks) / mix_channel[i].fade_length ); + Mix_Volume(i, (mix_channel[i].fade_volume * ticks) / mix_channel[i].fade_length); } } } - if ( mix_channel[i].playing > 0 ) { + if (mix_channel[i].playing > 0) { int index = 0; int remaining = len; while (mix_channel[i].playing > 0 && index < len) { remaining = len - index; volume = (mix_channel[i].volume*mix_channel[i].chunk->volume) / MIX_MAX_VOLUME; mixable = mix_channel[i].playing; - if ( mixable > remaining ) { + if (mixable > remaining) { mixable = remaining; } mix_input = Mix_DoEffects(i, mix_channel[i].samples, mixable); - SDL_MixAudio(stream+index,mix_input,mixable,volume); + SDL_MixAudioFormat(stream+index,mix_input,mixer.format,mixable,volume); if (mix_input != mix_channel[i].samples) SDL_free(mix_input); @@ -378,7 +309,7 @@ /* If looping the sample and we are at its end, make sure we will still return a full buffer */ - while ( mix_channel[i].looping && index < len ) { + while (mix_channel[i].looping && index < len) { int alen = mix_channel[i].chunk->alen; remaining = len - index; if (remaining > alen) { @@ -386,7 +317,7 @@ } mix_input = Mix_DoEffects(i, mix_channel[i].chunk->abuf, remaining); - SDL_MixAudio(stream+index, mix_input, remaining, volume); + SDL_MixAudioFormat(stream+index, mix_input, mixer.format, remaining, volume); if (mix_input != mix_channel[i].chunk->abuf) SDL_free(mix_input); @@ -397,7 +328,7 @@ mix_channel[i].playing = mix_channel[i].chunk->alen - remaining; index += remaining; } - if ( ! mix_channel[i].playing && mix_channel[i].looping ) { + if (! mix_channel[i].playing && mix_channel[i].looping) { if (mix_channel[i].looping > 0) { --mix_channel[i].looping; } @@ -411,7 +342,7 @@ /* rcg06122001 run posteffects... */ Mix_DoEffects(MIX_CHANNEL_POST, stream, len); - if ( mix_postmix ) { + if (mix_postmix) { mix_postmix(mix_postmix_data, stream, len); } } @@ -426,20 +357,29 @@ } #endif - /* Open the mixer with a certain desired audio format */ -int Mix_OpenAudio(int frequency, Uint16 format, int nchannels, int chunksize) +int Mix_OpenAudioDevice(int frequency, Uint16 format, int nchannels, int chunksize, + const char* device, int allowed_changes) { int i; SDL_AudioSpec desired; + /* This used to call SDL_OpenAudio(), which initializes the audio + subsystem if necessary. Since SDL_OpenAudioDevice() doesn't, + we have to handle this case here. */ + if (!SDL_WasInit(SDL_INIT_AUDIO)) { + if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) { + return -1; + } + } + /* If the mixer is already opened, increment open count */ - if ( audio_opened ) { - if ( format == mixer.format && nchannels == mixer.channels ) { + if (audio_opened) { + if (format == mixer.format && nchannels == mixer.channels) { ++audio_opened; return(0); } - while ( audio_opened ) { + while (audio_opened) { Mix_CloseAudio(); } } @@ -453,7 +393,7 @@ desired.userdata = NULL; /* Accept nearly any audio format */ - if ( SDL_OpenAudio(&desired, &mixer) < 0 ) { + if ((audio_device = SDL_OpenAudioDevice(device, 0, &desired, &mixer, allowed_changes)) == 0) { return(-1); } #if 0 @@ -461,8 +401,9 @@ #endif /* Initialize the music players */ - if ( open_music(&mixer) < 0 ) { - SDL_CloseAudio(); + load_music(); + if (open_music(&mixer) < 0) { + SDL_CloseAudioDevice(audio_device); return(-1); } @@ -470,7 +411,7 @@ mix_channel = (struct _Mix_Channel *) SDL_malloc(num_channels * sizeof(struct _Mix_Channel)); /* Clear out the audio channels */ - for ( i=0; i num_channels ) { + if (numchans > num_channels) { /* Initialize the new channels */ int i; for(i=num_channels; i < numchans; i++) { mix_channel[i].chunk = NULL; mix_channel[i].playing = 0; mix_channel[i].looping = 0; - mix_channel[i].volume = SDL_MIX_MAXVOLUME; - mix_channel[i].fade_volume = SDL_MIX_MAXVOLUME; - mix_channel[i].fade_volume_reset = SDL_MIX_MAXVOLUME; + mix_channel[i].volume = MIX_MAX_VOLUME; + mix_channel[i].fade_volume = MIX_MAX_VOLUME; + mix_channel[i].fade_volume_reset = MIX_MAX_VOLUME; mix_channel[i].fading = MIX_NO_FADING; mix_channel[i].tag = -1; mix_channel[i].expire = 0; @@ -543,64 +497,187 @@ } } num_channels = numchans; - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(num_channels); } /* Return the actual mixer parameters */ int Mix_QuerySpec(int *frequency, Uint16 *format, int *channels) { - if ( audio_opened ) { - if ( frequency ) { + if (audio_opened) { + if (frequency) { *frequency = mixer.freq; } - if ( format ) { + if (format) { *format = mixer.format; } - if ( channels ) { + if (channels) { *channels = mixer.channels; } } return(audio_opened); } -static int detect_mp3(Uint8 *magic) -{ - if ( strncmp((char *)magic, "ID3", 3) == 0 ) { - return 1; - } - - /* Detection code lifted from SMPEG */ - if(((magic[0] & 0xff) != 0xff) || // No sync bits - ((magic[1] & 0xf0) != 0xf0) || // - ((magic[2] & 0xf0) == 0x00) || // Bitrate is 0 - ((magic[2] & 0xf0) == 0xf0) || // Bitrate is 15 - ((magic[2] & 0x0c) == 0x0c) || // Frequency is 3 - ((magic[1] & 0x06) == 0x00)) { // Layer is 4 - return(0); - } - return 1; +typedef struct _MusicFragment +{ + Uint8 *data; + int size; + struct _MusicFragment *next; +} MusicFragment; + +static SDL_AudioSpec *Mix_LoadMusic_RW(Mix_MusicType music_type, SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len) +{ + int i; + Mix_MusicInterface *interface = NULL; + void *music = NULL; + Sint64 start; + SDL_bool playing; + MusicFragment *first = NULL, *last = NULL, *fragment = NULL; + int count = 0; + int fragment_size; + + *spec = mixer; + + /* Use fragments sized on full audio frame boundaries - this'll do */ + fragment_size = spec->size; + + start = SDL_RWtell(src); + for (i = 0; i < get_num_music_interfaces(); ++i) { + interface = get_music_interface(i); + if (interface->type != music_type) { + continue; + } + if (!interface->CreateFromRW || !interface->GetAudio) { + continue; + } + + /* These music interfaces are not safe to use while music is playing */ + if (interface->api == MIX_MUSIC_CMD || + interface->api == MIX_MUSIC_MIKMOD || + interface->api == MIX_MUSIC_NATIVEMIDI) { + continue; + } + + music = interface->CreateFromRW(src, freesrc); + if (music) { + /* The interface owns the data source now */ + freesrc = SDL_FALSE; + break; + } + + /* Reset the stream for the next decoder */ + SDL_RWseek(src, start, RW_SEEK_SET); + } + + if (!music) { + if (freesrc) { + SDL_RWclose(src); + } + Mix_SetError("Unrecognized audio format"); + return NULL; + } + + Mix_LockAudio(); + + if (interface->Play) { + interface->Play(music, 1); + } + playing = SDL_TRUE; + + while (playing) { + int left; + + fragment = (MusicFragment *)SDL_malloc(sizeof(*fragment)); + if (!fragment) { + /* Uh oh, out of memory, let's return what we have */ + break; + } + fragment->data = (Uint8 *)SDL_malloc(fragment_size); + if (!fragment->data) { + /* Uh oh, out of memory, let's return what we have */ + SDL_free(fragment); + break; + } + fragment->next = NULL; + + left = interface->GetAudio(music, fragment->data, fragment_size); + if (left > 0) { + playing = SDL_FALSE; + } else if (interface->IsPlaying) { + playing = interface->IsPlaying(music); + } + fragment->size = (fragment_size - left); + + if (!first) { + first = fragment; + } + if (last) { + last->next = fragment; + } + last = fragment; + ++count; + } + + if (interface->Stop) { + interface->Stop(music); + } + + if (music) { + interface->Delete(music); + } + + Mix_UnlockAudio(); + + if (count > 0) { + *audio_len = (count - 1) * fragment_size + fragment->size; + *audio_buf = (Uint8 *)SDL_malloc(*audio_len); + if (*audio_buf) { + Uint8 *dst = *audio_buf; + for (fragment = first; fragment; fragment = fragment->next) { + SDL_memcpy(dst, fragment->data, fragment->size); + dst += fragment->size; + } + } else { + SDL_OutOfMemory(); + spec = NULL; + } + } else { + Mix_SetError("No audio data"); + spec = NULL; + } + + while (first) { + fragment = first; + first = first->next; + SDL_free(fragment->data); + SDL_free(fragment); + } + + if (freesrc) { + SDL_RWclose(src); + } + return spec; } /* Load a wave file */ Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc) { - Uint32 magic; + Uint8 magic[4]; Mix_Chunk *chunk; SDL_AudioSpec wavespec, *loaded; SDL_AudioCVT wavecvt; int samplesize; /* rcg06012001 Make sure src is valid */ - if ( ! src ) { + if (!src) { SDL_SetError("Mix_LoadWAV_RW with NULL src"); return(NULL); } /* Make sure audio has been opened */ - if ( ! audio_opened ) { + if (!audio_opened) { SDL_SetError("Audio device hasn't been opened"); - if ( freesrc ) { + if (freesrc) { SDL_RWclose(src); } return(NULL); @@ -608,64 +685,36 @@ /* Allocate the chunk memory */ chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk)); - if ( chunk == NULL ) { + if (chunk == NULL) { SDL_SetError("Out of memory"); - if ( freesrc ) { + if (freesrc) { SDL_RWclose(src); } return(NULL); } /* Find out what kind of audio file this is */ - magic = SDL_ReadLE32(src); + if (SDL_RWread(src, magic, 1, 4) != 4) { + if (freesrc) { + SDL_RWclose(src); + } + Mix_SetError("Couldn't read first 4 bytes of audio data"); + return NULL; + } /* Seek backwards for compatibility with older loaders */ - SDL_RWseek(src, -(int)sizeof(Uint32), RW_SEEK_CUR); - - switch (magic) { - case WAVE: - case RIFF: - loaded = SDL_LoadWAV_RW(src, freesrc, &wavespec, - (Uint8 **)&chunk->abuf, &chunk->alen); - break; - case FORM: - loaded = Mix_LoadAIFF_RW(src, freesrc, &wavespec, - (Uint8 **)&chunk->abuf, &chunk->alen); - break; -#ifdef OGG_MUSIC - case OGGS: - loaded = Mix_LoadOGG_RW(src, freesrc, &wavespec, - (Uint8 **)&chunk->abuf, &chunk->alen); - break; -#endif -#ifdef FLAC_MUSIC - case FLAC: - loaded = Mix_LoadFLAC_RW(src, freesrc, &wavespec, - (Uint8 **)&chunk->abuf, &chunk->alen); - break; -#endif - case CREA: - loaded = Mix_LoadVOC_RW(src, freesrc, &wavespec, - (Uint8 **)&chunk->abuf, &chunk->alen); - break; - default: -#if defined(MP3_MUSIC) || defined(MP3_MAD_MUSIC) - if (detect_mp3((Uint8*)&magic)) - { - /* note: send a copy of the mixer spec */ - wavespec = mixer; - loaded = Mix_LoadMP3_RW(src, freesrc, &wavespec, - (Uint8 **)&chunk->abuf, &chunk->alen); - break; - } -#endif - SDL_SetError("Unrecognized sound file type"); - if ( freesrc ) { - SDL_RWclose(src); - } - loaded = NULL; - break; - } - if ( !loaded ) { + SDL_RWseek(src, -4, RW_SEEK_CUR); + + if (SDL_memcmp(magic, "WAVE", 4) == 0 || SDL_memcmp(magic, "RIFF", 4) == 0) { + loaded = SDL_LoadWAV_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen); + } else if (SDL_memcmp(magic, "FORM", 4) == 0) { + loaded = Mix_LoadAIFF_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen); + } else if (SDL_memcmp(magic, "CREA", 4) == 0) { + loaded = Mix_LoadVOC_RW(src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen); + } else { + Mix_MusicType music_type = detect_music_type_from_magic(magic); + loaded = Mix_LoadMusic_RW(music_type, src, freesrc, &wavespec, (Uint8 **)&chunk->abuf, &chunk->alen); + } + if (!loaded) { /* The individual loaders have closed src if needed */ SDL_free(chunk); return(NULL); @@ -677,12 +726,12 @@ #endif /* Build the audio converter and create conversion buffers */ - if ( wavespec.format != mixer.format || + if (wavespec.format != mixer.format || wavespec.channels != mixer.channels || - wavespec.freq != mixer.freq ) { - if ( SDL_BuildAudioCVT(&wavecvt, + wavespec.freq != mixer.freq) { + if (SDL_BuildAudioCVT(&wavecvt, wavespec.format, wavespec.channels, wavespec.freq, - mixer.format, mixer.channels, mixer.freq) < 0 ) { + mixer.format, mixer.channels, mixer.freq) < 0) { SDL_free(chunk->abuf); SDL_free(chunk); return(NULL); @@ -690,17 +739,17 @@ samplesize = ((wavespec.format & 0xFF)/8)*wavespec.channels; wavecvt.len = chunk->alen & ~(samplesize-1); wavecvt.buf = (Uint8 *)SDL_calloc(1, wavecvt.len*wavecvt.len_mult); - if ( wavecvt.buf == NULL ) { + if (wavecvt.buf == NULL) { SDL_SetError("Out of memory"); SDL_free(chunk->abuf); SDL_free(chunk); return(NULL); } - SDL_memcpy(wavecvt.buf, chunk->abuf, chunk->alen); + SDL_memcpy(wavecvt.buf, chunk->abuf, wavecvt.len); SDL_free(chunk->abuf); /* Run the audio converter */ - if ( SDL_ConvertAudio(&wavecvt) < 0 ) { + if (SDL_ConvertAudio(&wavecvt) < 0) { SDL_free(wavecvt.buf); SDL_free(chunk); return(NULL); @@ -723,14 +772,14 @@ Uint8 magic[4]; /* Make sure audio has been opened */ - if ( ! audio_opened ) { + if (! audio_opened) { SDL_SetError("Audio device hasn't been opened"); return(NULL); } /* Allocate the chunk memory */ chunk = (Mix_Chunk *)SDL_calloc(1,sizeof(Mix_Chunk)); - if ( chunk == NULL ) { + if (chunk == NULL) { SDL_SetError("Out of memory"); return(NULL); } @@ -745,7 +794,7 @@ mem += 4; chunk->abuf = mem; mem += chunk->alen; - } while ( memcmp(magic, "data", 4) != 0 ); + } while (memcmp(magic, "data", 4) != 0); chunk->volume = MIX_MAX_VOLUME; return(chunk); @@ -757,14 +806,14 @@ Mix_Chunk *chunk; /* Make sure audio has been opened */ - if ( ! audio_opened ) { + if (! audio_opened) { SDL_SetError("Audio device hasn't been opened"); return(NULL); } /* Allocate the chunk memory */ chunk = (Mix_Chunk *)SDL_malloc(sizeof(Mix_Chunk)); - if ( chunk == NULL ) { + if (chunk == NULL) { SDL_SetError("Out of memory"); return(NULL); } @@ -784,20 +833,20 @@ int i; /* Caution -- if the chunk is playing, the mixer will crash */ - if ( chunk ) { + if (chunk) { /* Guarantee that this chunk isn't playing */ - SDL_LockAudio(); - if ( mix_channel ) { - for ( i=0; iallocated ) { + if (chunk->allocated) { SDL_free(chunk->abuf); } SDL_free(chunk); @@ -808,30 +857,30 @@ This can be used to provide real-time visual display of the audio stream or add a custom mixer filter for the stream data. */ -void Mix_SetPostMix(void (*mix_func) +void Mix_SetPostMix(void (SDLCALL *mix_func) (void *udata, Uint8 *stream, int len), void *arg) { - SDL_LockAudio(); + Mix_LockAudio(); mix_postmix_data = arg; mix_postmix = mix_func; - SDL_UnlockAudio(); + Mix_UnlockAudio(); } /* Add your own music player or mixer function. If 'mix_func' is NULL, the default music player is re-enabled. */ -void Mix_HookMusic(void (*mix_func)(void *udata, Uint8 *stream, int len), +void Mix_HookMusic(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg) { - SDL_LockAudio(); - if ( mix_func != NULL ) { + Mix_LockAudio(); + if (mix_func != NULL) { music_data = arg; mix_music = mix_func; } else { music_data = NULL; mix_music = music_mixer; } - SDL_UnlockAudio(); + Mix_UnlockAudio(); } void *Mix_GetMusicHookData(void) @@ -839,11 +888,11 @@ return(music_data); } -void Mix_ChannelFinished(void (*channel_finished)(int channel)) -{ - SDL_LockAudio(); +void Mix_ChannelFinished(void (SDLCALL *channel_finished)(int channel)) +{ + Mix_LockAudio(); channel_done_callback = channel_finished; - SDL_UnlockAudio(); + Mix_UnlockAudio(); } @@ -880,25 +929,25 @@ int i; /* Don't play null pointers :-) */ - if ( chunk == NULL ) { + if (chunk == NULL) { Mix_SetError("Tried to play a NULL chunk"); return(-1); } - if ( !checkchunkintegral(chunk)) { + if (!checkchunkintegral(chunk)) { Mix_SetError("Tried to play a chunk with a bad frame"); return(-1); } /* Lock the mixer while modifying the playing channels */ - SDL_LockAudio(); + Mix_LockAudio(); { /* If which is -1, play on the first free channel */ - if ( which == -1 ) { - for ( i=reserved_channels; i= 0 && which < num_channels ) { + if (which >= 0 && which < num_channels) { Uint32 sdl_ticks = SDL_GetTicks(); if (Mix_Playing(which)) _Mix_channel_done_playing(which); @@ -921,7 +970,7 @@ mix_channel[which].expire = (ticks>0) ? (sdl_ticks + ticks) : 0; } } - SDL_UnlockAudio(); + Mix_UnlockAudio(); /* Return the channel on which the sound is being played */ return(which); @@ -932,15 +981,15 @@ { int status = 0; - if ( which == -1 ) { + if (which == -1) { int i; - for ( i=0; i < num_channels; ++ i ) { + for (i=0; i < num_channels; ++ i) { status += Mix_ExpireChannel(i, ticks); } - } else if ( which < num_channels ) { - SDL_LockAudio(); + } else if (which < num_channels) { + Mix_LockAudio(); mix_channel[which].expire = (ticks>0) ? (SDL_GetTicks() + ticks) : 0; - SDL_UnlockAudio(); + Mix_UnlockAudio(); ++ status; } return(status); @@ -952,24 +1001,24 @@ int i; /* Don't play null pointers :-) */ - if ( chunk == NULL ) { + if (chunk == NULL) { return(-1); } - if ( !checkchunkintegral(chunk)) { + if (!checkchunkintegral(chunk)) { Mix_SetError("Tried to play a chunk with a bad frame"); return(-1); } /* Lock the mixer while modifying the playing channels */ - SDL_LockAudio(); + Mix_LockAudio(); { /* If which is -1, play on the first free channel */ - if ( which == -1 ) { - for ( i=reserved_channels; i= 0 && which < num_channels ) { + if (which >= 0 && which < num_channels) { Uint32 sdl_ticks = SDL_GetTicks(); if (Mix_Playing(which)) _Mix_channel_done_playing(which); @@ -995,7 +1044,7 @@ mix_channel[which].expire = (ticks > 0) ? (sdl_ticks+ticks) : 0; } } - SDL_UnlockAudio(); + Mix_UnlockAudio(); /* Return the channel on which the sound is being played */ return(which); @@ -1007,16 +1056,16 @@ int i; int prev_volume = 0; - if ( which == -1 ) { - for ( i=0; i= 0 ) { - if ( volume > SDL_MIX_MAXVOLUME ) { - volume = SDL_MIX_MAXVOLUME; + if (volume >= 0) { + if (volume > MIX_MAX_VOLUME) { + volume = MIX_MAX_VOLUME; } mix_channel[which].volume = volume; } @@ -1029,8 +1078,8 @@ int prev_volume; prev_volume = chunk->volume; - if ( volume >= 0 ) { - if ( volume > MIX_MAX_VOLUME ) { + if (volume >= 0) { + if (volume > MIX_MAX_VOLUME) { volume = MIX_MAX_VOLUME; } chunk->volume = volume; @@ -1043,12 +1092,12 @@ { int i; - if ( which == -1 ) { - for ( i=0; i 0) && - (mix_channel[which].fading != MIX_FADING_OUT) ) { + (mix_channel[which].fading != MIX_FADING_OUT)) { mix_channel[which].fade_volume = mix_channel[which].volume; mix_channel[which].fading = MIX_FADING_OUT; mix_channel[which].fade_length = (Uint32)ms; @@ -1105,7 +1154,7 @@ } ++status; } - SDL_UnlockAudio(); + Mix_UnlockAudio(); } } return(status); @@ -1116,8 +1165,8 @@ { int i; int status = 0; - for ( i=0; i= num_channels ) { + if (which < 0 || which >= num_channels) { return MIX_NO_FADING; } return mix_channel[which].fading; @@ -1140,19 +1189,19 @@ int status; status = 0; - if ( which == -1 ) { + if (which == -1) { int i; - for ( i=0; i 0) || mix_channel[i].looping) { ++status; } } - } else if ( which < num_channels ) { - if ( (mix_channel[which].playing > 0) || - mix_channel[which].looping ) + } else if (which < num_channels) { + if ((mix_channel[which].playing > 0) || + mix_channel[which].looping) { ++status; } @@ -1177,16 +1226,18 @@ { int i; - if ( audio_opened ) { - if ( audio_opened == 1 ) { + if (audio_opened) { + if (audio_opened == 1) { for (i = 0; i < num_channels; i++) { Mix_UnregisterAllEffects(i); } Mix_UnregisterAllEffects(MIX_CHANNEL_POST); close_music(); + Mix_SetMusicCMD(NULL); Mix_HaltChannel(-1); _Mix_DeinitEffects(); - SDL_CloseAudio(); + SDL_CloseAudioDevice(audio_device); + audio_device = 0; SDL_free(mix_channel); mix_channel = NULL; @@ -1203,16 +1254,16 @@ void Mix_Pause(int which) { Uint32 sdl_ticks = SDL_GetTicks(); - if ( which == -1 ) { + if (which == -1) { int i; - for ( i=0; i 0 ) { + for (i=0; i 0) { mix_channel[i].paused = sdl_ticks; } } - } else if ( which < num_channels ) { - if ( mix_channel[which].playing > 0 ) { + } else if (which < num_channels) { + if (mix_channel[which].playing > 0) { mix_channel[which].paused = sdl_ticks; } } @@ -1223,39 +1274,39 @@ { Uint32 sdl_ticks = SDL_GetTicks(); - SDL_LockAudio(); - if ( which == -1 ) { + Mix_LockAudio(); + if (which == -1) { int i; - for ( i=0; i 0 ) { + for (i=0; i 0) { if(mix_channel[i].expire > 0) mix_channel[i].expire += sdl_ticks - mix_channel[i].paused; mix_channel[i].paused = 0; } } - } else if ( which < num_channels ) { - if ( mix_channel[which].playing > 0 ) { + } else if (which < num_channels) { + if (mix_channel[which].playing > 0) { if(mix_channel[which].expire > 0) mix_channel[which].expire += sdl_ticks - mix_channel[which].paused; mix_channel[which].paused = 0; } } - SDL_UnlockAudio(); + Mix_UnlockAudio(); } int Mix_Paused(int which) { - if ( which < 0 ) { + if (which < 0) { int status = 0; int i; - for( i=0; i < num_channels; ++i ) { - if ( mix_channel[i].paused ) { + for(i=0; i < num_channels; ++i) { + if (mix_channel[i].paused) { ++ status; } } return(status); - } else if ( which < num_channels ) { + } else if (which < num_channels) { return(mix_channel[which].paused != 0); } else { return(0); @@ -1265,12 +1316,12 @@ /* Change the group of a channel */ int Mix_GroupChannel(int which, int tag) { - if ( which < 0 || which > num_channels ) + if (which < 0 || which > num_channels) return(0); - SDL_LockAudio(); + Mix_LockAudio(); mix_channel[which].tag = tag; - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(1); } @@ -1278,7 +1329,7 @@ int Mix_GroupChannels(int from, int to, int tag) { int status = 0; - for( ; from <= to; ++ from ) { + for(; from <= to; ++ from) { status += Mix_GroupChannel(from, tag); } return(status); @@ -1288,9 +1339,9 @@ int Mix_GroupAvailable(int tag) { int i; - for( i=0; i < num_channels; i ++ ) { - if ( ((tag == -1) || (tag == mix_channel[i].tag)) && - (mix_channel[i].playing <= 0) ) + for(i=0; i < num_channels; i ++) { + if (((tag == -1) || (tag == mix_channel[i].tag)) && + (mix_channel[i].playing <= 0)) return i; } return(-1); @@ -1300,8 +1351,8 @@ { int count = 0; int i; - for( i=0; i < num_channels; i ++ ) { - if ( mix_channel[i].tag==tag || tag==-1 ) + for(i=0; i < num_channels; i ++) { + if (mix_channel[i].tag==tag || tag==-1) ++ count; } return(count); @@ -1313,9 +1364,9 @@ int chan = -1; Uint32 mintime = SDL_GetTicks(); int i; - for( i=0; i < num_channels; i ++ ) { - if ( (mix_channel[i].tag==tag || tag==-1) && mix_channel[i].playing > 0 - && mix_channel[i].start_time <= mintime ) { + for(i=0; i < num_channels; i ++) { + if ((mix_channel[i].tag==tag || tag==-1) && mix_channel[i].playing > 0 + && mix_channel[i].start_time <= mintime) { mintime = mix_channel[i].start_time; chan = i; } @@ -1329,9 +1380,9 @@ int chan = -1; Uint32 maxtime = 0; int i; - for( i=0; i < num_channels; i ++ ) { - if ( (mix_channel[i].tag==tag || tag==-1) && mix_channel[i].playing > 0 - && mix_channel[i].start_time >= maxtime ) { + for(i=0; i < num_channels; i ++) { + if ((mix_channel[i].tag==tag || tag==-1) && mix_channel[i].playing > 0 + && mix_channel[i].start_time >= maxtime) { maxtime = mix_channel[i].start_time; chan = i; } @@ -1347,7 +1398,7 @@ * as Mix_SetPanning(). */ -/* MAKE SURE you hold the audio lock (SDL_LockAudio()) before calling this! */ +/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ static int _Mix_register_effect(effect_info **e, Mix_EffectFunc_t f, Mix_EffectDone_t d, void *arg) { @@ -1392,7 +1443,7 @@ } -/* MAKE SURE you hold the audio lock (SDL_LockAudio()) before calling this! */ +/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ static int _Mix_remove_effect(int channel, effect_info **e, Mix_EffectFunc_t f) { effect_info *cur; @@ -1427,7 +1478,7 @@ } -/* MAKE SURE you hold the audio lock (SDL_LockAudio()) before calling this! */ +/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ static int _Mix_remove_all_effects(int channel, effect_info **e) { effect_info *cur; @@ -1451,7 +1502,7 @@ } -/* MAKE SURE you hold the audio lock (SDL_LockAudio()) before calling this! */ +/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ int _Mix_RegisterEffect_locked(int channel, Mix_EffectFunc_t f, Mix_EffectDone_t d, void *arg) { @@ -1474,14 +1525,14 @@ Mix_EffectDone_t d, void *arg) { int retval; - SDL_LockAudio(); + Mix_LockAudio(); retval = _Mix_RegisterEffect_locked(channel, f, d, arg); - SDL_UnlockAudio(); + Mix_UnlockAudio(); return retval; } -/* MAKE SURE you hold the audio lock (SDL_LockAudio()) before calling this! */ +/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ int _Mix_UnregisterEffect_locked(int channel, Mix_EffectFunc_t f) { effect_info **e = NULL; @@ -1502,13 +1553,13 @@ int Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f) { int retval; - SDL_LockAudio(); + Mix_LockAudio(); retval = _Mix_UnregisterEffect_locked(channel, f); - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(retval); } -/* MAKE SURE you hold the audio lock (SDL_LockAudio()) before calling this! */ +/* MAKE SURE you hold the audio lock (Mix_LockAudio()) before calling this! */ int _Mix_UnregisterAllEffects_locked(int channel) { effect_info **e = NULL; @@ -1529,11 +1580,22 @@ int Mix_UnregisterAllEffects(int channel) { int retval; - SDL_LockAudio(); + Mix_LockAudio(); retval = _Mix_UnregisterAllEffects_locked(channel); - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(retval); } +void Mix_LockAudio(void) +{ + SDL_LockAudioDevice(audio_device); +} + +void Mix_UnlockAudio(void) +{ + SDL_UnlockAudioDevice(audio_device); +} + /* end of mixer.c ... */ +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/mixer.h b/mixer.h new file mode 100644 index 0000000..53d1d2b --- /dev/null +++ b/mixer.h @@ -0,0 +1,26 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* Locking wrapper functions */ +extern void Mix_LockAudio(void); +extern void Mix_UnlockAudio(void); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music.c b/music.c index bbaf4a3..1b2dfe4 100644 --- a/music.c +++ b/music.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -18,123 +18,46 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ - -/* $Id$ */ - -#include -#include -#include -#include -#include "SDL_endian.h" -#include "SDL_audio.h" +#include /* for strtok() and strtok_s() */ + +#include "SDL_hints.h" +#include "SDL_log.h" #include "SDL_timer.h" #include "SDL_mixer.h" - -#ifdef CMD_MUSIC +#include "mixer.h" +#include "music.h" + #include "music_cmd.h" -#endif -#ifdef WAV_MUSIC -#include "wavestream.h" -#endif -#ifdef MODPLUG_MUSIC +#include "music_wav.h" +#include "music_mikmod.h" #include "music_modplug.h" -#endif -#ifdef MOD_MUSIC -#include "music_mod.h" -#endif -#ifdef MID_MUSIC -# ifdef USE_TIMIDITY_MIDI -# include "timidity.h" -# endif -# ifdef USE_FLUIDSYNTH_MIDI -# include "fluidsynth.h" -# endif -# ifdef USE_NATIVE_MIDI -# include "native_midi.h" -# endif -#endif -#ifdef OGG_MUSIC +#include "music_nativemidi.h" +#include "music_fluidsynth.h" +#include "music_timidity.h" #include "music_ogg.h" -#endif -#ifdef MP3_MUSIC -#include "dynamic_mp3.h" -#endif -#ifdef MP3_MAD_MUSIC +#include "music_mpg123.h" #include "music_mad.h" -#endif -#ifdef FLAC_MUSIC +#include "music_smpeg.h" #include "music_flac.h" -#endif - -#if defined(MP3_MUSIC) || defined(MP3_MAD_MUSIC) -static SDL_AudioSpec used_mixer; -#endif - - -int volatile music_active = 1; -static int volatile music_stopped = 0; -static int music_loops = 0; -static char *music_cmd = NULL; +#include "native_midi/native_midi.h" + + +char *music_cmd = NULL; +static SDL_bool music_active = SDL_TRUE; +static int music_volume = MIX_MAX_VOLUME; static Mix_Music * volatile music_playing = NULL; -static int music_volume = MIX_MAX_VOLUME; +SDL_AudioSpec music_spec; struct _Mix_Music { - Mix_MusicType type; - union { -#ifdef CMD_MUSIC - MusicCMD *cmd; -#endif -#ifdef WAV_MUSIC - WAVStream *wave; -#endif -#ifdef MODPLUG_MUSIC - modplug_data *modplug; -#endif -#ifdef MOD_MUSIC - struct MODULE *module; -#endif -#ifdef MID_MUSIC -#ifdef USE_TIMIDITY_MIDI - MidiSong *midi; -#endif -#ifdef USE_FLUIDSYNTH_MIDI - FluidSynthMidiSong *fluidsynthmidi; -#endif -#ifdef USE_NATIVE_MIDI - NativeMidiSong *nativemidi; -#endif -#endif -#ifdef OGG_MUSIC - OGG_music *ogg; -#endif -#ifdef MP3_MUSIC - SMPEG *mp3; -#endif -#ifdef MP3_MAD_MUSIC - mad_data *mp3_mad; -#endif -#ifdef FLAC_MUSIC - FLAC_music *flac; -#endif - } data; + Mix_MusicInterface *interface; + void *context; + + SDL_bool playing; Mix_Fading fading; int fade_step; int fade_steps; - int error; }; -#ifdef MID_MUSIC -#ifdef USE_TIMIDITY_MIDI -static int timidity_ok; -static int samplesize; -#endif -#ifdef USE_FLUIDSYNTH_MIDI -static int fluidsynth_ok; -#endif -#ifdef USE_NATIVE_MIDI -static int native_midi_ok; -#endif -#endif /* Used to calculate fading steps */ static int ms_per_step; @@ -144,9 +67,58 @@ static int num_decoders = 0; /* Semicolon-separated SoundFont paths */ -#ifdef MID_MUSIC -char* soundfont_paths = NULL; -#endif +static char* soundfont_paths = NULL; + +/* Interfaces for the various music interfaces, ordered by priority */ +static Mix_MusicInterface *s_music_interfaces[] = +{ +#ifdef MUSIC_CMD + &Mix_MusicInterface_CMD, +#endif +#ifdef MUSIC_WAV + &Mix_MusicInterface_WAV, +#endif +#ifdef MUSIC_FLAC + &Mix_MusicInterface_FLAC, +#endif +#ifdef MUSIC_OGG + &Mix_MusicInterface_OGG, +#endif +#ifdef MUSIC_MP3_MPG123 + &Mix_MusicInterface_MPG123, +#endif +#ifdef MUSIC_MP3_MAD + &Mix_MusicInterface_MAD, +#endif +#ifdef MUSIC_MP3_SMPEG + &Mix_MusicInterface_SMPEG, +#endif +#ifdef MUSIC_MOD_MODPLUG + &Mix_MusicInterface_MODPLUG, +#endif +#ifdef MUSIC_MOD_MIKMOD + &Mix_MusicInterface_MIKMOD, +#endif +#ifdef MUSIC_MID_FLUIDSYNTH + &Mix_MusicInterface_FLUIDSYNTH, +#endif +#ifdef MUSIC_MID_TIMIDITY + &Mix_MusicInterface_TIMIDITY, +#endif +#ifdef MUSIC_MID_NATIVE + &Mix_MusicInterface_NATIVEMIDI, +#endif +}; + +int get_num_music_interfaces(void) +{ + return SDL_arraysize(s_music_interfaces); +} + +Mix_MusicInterface *get_music_interface(int index) +{ + return s_music_interfaces[index]; +} int Mix_GetNumMusicDecoders(void) { @@ -174,87 +146,79 @@ /* Local low-level functions prototypes */ static void music_internal_initialize_volume(void); static void music_internal_volume(int volume); -static int music_internal_play(Mix_Music *music, double position); +static int music_internal_play(Mix_Music *music, int play_count, double position); static int music_internal_position(double position); -static int music_internal_playing(); +static SDL_bool music_internal_playing(void); static void music_internal_halt(void); /* Support for hooking when the music has finished */ -static void (*music_finished_hook)(void) = NULL; - -void Mix_HookMusicFinished(void (*music_finished)(void)) -{ - SDL_LockAudio(); +static void (SDLCALL *music_finished_hook)(void) = NULL; + +void Mix_HookMusicFinished(void (SDLCALL *music_finished)(void)) +{ + Mix_LockAudio(); music_finished_hook = music_finished; - SDL_UnlockAudio(); -} - - -/* If music isn't playing, halt it if no looping is required, restart it */ -/* othesrchise. NOP if the music is playing */ -static int music_halt_or_loop (void) -{ - /* Restart music if it has to loop */ - - if (!music_internal_playing()) - { -#ifdef USE_NATIVE_MIDI - /* Native MIDI handles looping internally */ - if (music_playing->type == MUS_MID && native_midi_ok) { - music_loops = 0; - } -#endif - - /* Restart music if it has to loop at a high level */ - if (music_loops) - { - Mix_Fading current_fade; - if (music_loops > 0) { - --music_loops; - } - current_fade = music_playing->fading; - music_internal_play(music_playing, 0.0); - music_playing->fading = current_fade; - } - else - { - music_internal_halt(); - if (music_finished_hook) - music_finished_hook(); - - return 0; - } - } - - return 1; -} - - + Mix_UnlockAudio(); +} + +/* Convenience function to fill audio and mix at the specified volume + This is called from many music player's GetAudio callback. + */ +int music_pcm_getaudio(void *context, void *data, int bytes, int volume, + int (*GetSome)(void *context, void *data, int bytes, SDL_bool *done)) +{ + Uint8 *snd = (Uint8 *)data; + Uint8 *dst; + int len = bytes; + SDL_bool done = SDL_FALSE; + + if (volume == MIX_MAX_VOLUME) { + dst = snd; + } else { + dst = SDL_stack_alloc(Uint8, bytes); + } + while (len > 0 && !done) { + int consumed = GetSome(context, dst, len, &done); + if (consumed < 0) { + break; + } + + if (volume == MIX_MAX_VOLUME) { + dst += consumed; + } else { + SDL_MixAudioFormat(snd, dst, music_spec.format, (Uint32)consumed, volume); + snd += consumed; + } + len -= consumed; + } + if (volume != MIX_MAX_VOLUME) { + SDL_stack_free(dst); + } + return len; +} /* Mixing function */ -void music_mixer(void *udata, Uint8 *stream, int len) -{ - int left = 0; - - if ( music_playing && music_active ) { +void SDLCALL music_mixer(void *udata, Uint8 *stream, int len) +{ + while (music_playing && music_active && len > 0) { /* Handle fading */ - if ( music_playing->fading != MIX_NO_FADING ) { - if ( music_playing->fade_step++ < music_playing->fade_steps ) { + if (music_playing->fading != MIX_NO_FADING) { + if (music_playing->fade_step++ < music_playing->fade_steps) { int volume; int fade_step = music_playing->fade_step; int fade_steps = music_playing->fade_steps; - if ( music_playing->fading == MIX_FADING_OUT ) { + if (music_playing->fading == MIX_FADING_OUT) { volume = (music_volume * (fade_steps-fade_step)) / fade_steps; } else { /* Fading in */ volume = (music_volume * fade_step) / fade_steps; } music_internal_volume(volume); } else { - if ( music_playing->fading == MIX_FADING_OUT ) { + if (music_playing->fading == MIX_FADING_OUT) { music_internal_halt(); - if ( music_finished_hook ) { + if (music_finished_hook) { music_finished_hook(); } return; @@ -263,243 +227,144 @@ } } - music_halt_or_loop(); - if (!music_internal_playing()) - return; - - switch (music_playing->type) { -#ifdef CMD_MUSIC - case MUS_CMD: - /* The playing is done externally */ - break; -#endif -#ifdef WAV_MUSIC - case MUS_WAV: - left = WAVStream_PlaySome(stream, len); - break; -#endif -#ifdef MODPLUG_MUSIC - case MUS_MODPLUG: - left = modplug_playAudio(music_playing->data.modplug, stream, len); - break; -#endif -#ifdef MOD_MUSIC - case MUS_MOD: - left = MOD_playAudio(music_playing->data.module, stream, len); - break; -#endif -#ifdef MID_MUSIC - case MUS_MID: -#ifdef USE_NATIVE_MIDI - if ( native_midi_ok ) { - /* Native midi is handled asynchronously */ - goto skip; - } -#endif -#ifdef USE_FLUIDSYNTH_MIDI - if ( fluidsynth_ok ) { - fluidsynth_playsome(music_playing->data.fluidsynthmidi, stream, len); - goto skip; - } -#endif -#ifdef USE_TIMIDITY_MIDI - if ( timidity_ok ) { - int samples = len / samplesize; - Timidity_PlaySome(stream, samples); - goto skip; - } -#endif - break; -#endif -#ifdef OGG_MUSIC - case MUS_OGG: - - left = OGG_playAudio(music_playing->data.ogg, stream, len); - break; -#endif -#ifdef FLAC_MUSIC - case MUS_FLAC: - left = FLAC_playAudio(music_playing->data.flac, stream, len); - break; -#endif -#ifdef MP3_MUSIC - case MUS_MP3: - left = (len - smpeg.SMPEG_playAudio(music_playing->data.mp3, stream, len)); - break; -#endif -#ifdef MP3_MAD_MUSIC - case MUS_MP3_MAD: - left = mad_getSamples(music_playing->data.mp3_mad, stream, len); - break; -#endif - default: - /* Unknown music type?? */ - break; - } - } - -skip: - /* Handle seamless music looping */ - if (left > 0 && left < len) { - music_halt_or_loop(); - if (music_internal_playing()) - music_mixer(udata, stream+(len-left), left); - } -} - -/* Initialize the music players with a certain desired audio format */ -int open_music(SDL_AudioSpec *mixer) -{ -#ifdef WAV_MUSIC - if ( WAVStream_Init(mixer) == 0 ) { - add_music_decoder("WAVE"); - } -#endif -#ifdef MODPLUG_MUSIC - if ( modplug_init(mixer) == 0 ) { - add_music_decoder("MODPLUG"); - } -#endif -#ifdef MOD_MUSIC - if ( MOD_init(mixer) == 0 ) { - add_music_decoder("MIKMOD"); - } -#endif -#ifdef MID_MUSIC -#ifdef USE_TIMIDITY_MIDI - samplesize = mixer->size / mixer->samples; - if ( Timidity_Init(mixer->freq, mixer->format, - mixer->channels, mixer->samples) == 0 ) { - timidity_ok = 1; - add_music_decoder("TIMIDITY"); - } else { - timidity_ok = 0; - } -#endif -#ifdef USE_FLUIDSYNTH_MIDI - if ( fluidsynth_init(mixer) == 0 ) { - fluidsynth_ok = 1; - add_music_decoder("FLUIDSYNTH"); - } else { - fluidsynth_ok = 0; - } -#endif -#ifdef USE_NATIVE_MIDI -#ifdef USE_FLUIDSYNTH_MIDI - native_midi_ok = !fluidsynth_ok; - if ( native_midi_ok ) -#endif -#ifdef USE_TIMIDITY_MIDI - native_midi_ok = !timidity_ok; - if ( !native_midi_ok ) { - native_midi_ok = (getenv("SDL_NATIVE_MUSIC") != NULL); - } - if ( native_midi_ok ) -#endif - native_midi_ok = native_midi_detect(); - if ( native_midi_ok ) - add_music_decoder("NATIVEMIDI"); -#endif -#endif -#ifdef OGG_MUSIC - if ( OGG_init(mixer) == 0 ) { - add_music_decoder("OGG"); - } -#endif -#ifdef FLAC_MUSIC - if ( FLAC_init(mixer) == 0 ) { - add_music_decoder("FLAC"); - } -#endif -#if defined(MP3_MUSIC) || defined(MP3_MAD_MUSIC) - /* Keep a copy of the mixer */ - used_mixer = *mixer; - add_music_decoder("MP3"); -#endif - - music_playing = NULL; - music_stopped = 0; - Mix_VolumeMusic(SDL_MIX_MAXVOLUME); + if (music_playing->interface->GetAudio) { + int left = music_playing->interface->GetAudio(music_playing->context, stream, len); + if (left != 0) { + /* Either an error or finished playing with data left */ + music_playing->playing = SDL_FALSE; + } + if (left > 0) { + stream += (len - left); + len = left; + } else { + len = 0; + } + } else { + len = 0; + } + + if (!music_internal_playing()) { + music_internal_halt(); + if (music_finished_hook) { + music_finished_hook(); + } + } + } +} + +/* Load the music interface libraries */ +int load_music(void) +{ + char hint[128]; + + int i; + for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { + Mix_MusicInterface *interface = s_music_interfaces[i]; + if (interface->loaded) { + continue; + } + + SDL_snprintf(hint, sizeof(hint), "SDL_MIXER_DISABLE_%s", interface->tag); + if (SDL_GetHintBoolean(hint, SDL_FALSE)) { + continue; + } + + if (!interface->Load || interface->Load() == 0) { + interface->loaded = SDL_TRUE; + } + } + return 0; +} + +/* Return SDL_TRUE if the music type is available */ +SDL_bool has_music(Mix_MusicType type) +{ + int i; + for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { + Mix_MusicInterface *interface = s_music_interfaces[i]; + if (interface->type != type) { + continue; + } + if (interface->opened) { + return SDL_TRUE; + } + } + return SDL_FALSE; +} + +/* Initialize the music interfaces with a certain desired audio format */ +int open_music(const SDL_AudioSpec *spec) +{ + int i; + SDL_bool use_native_midi = SDL_FALSE; + +#ifdef MIX_INIT_SOUNDFONT_PATHS + if (!soundfont_paths) { + soundfont_paths = SDL_strdup(MIX_INIT_SOUNDFONT_PATHS); + } +#endif + + +#ifdef MUSIC_MID_NATIVE + if (SDL_GetHintBoolean("SDL_NATIVE_MUSIC", SDL_FALSE) && native_midi_detect()) { + use_native_midi = SDL_TRUE; + } +#endif + + music_spec = *spec; + for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { + Mix_MusicInterface *interface = s_music_interfaces[i]; + if (!interface->loaded) { + continue; + } + + if (interface->type == MUS_MID && use_native_midi && interface->api != MIX_MUSIC_NATIVEMIDI) { + continue; + } + + if (!interface->Open || interface->Open(spec) == 0) { + interface->opened = SDL_TRUE; + add_music_decoder(interface->tag); + } + } + + if (has_music(MUS_MOD)) { + add_music_decoder("MOD"); + } + if (has_music(MUS_MID)) { + add_music_decoder("MIDI"); + } + if (has_music(MUS_MP3)) { + add_music_decoder("MP3"); + } + + Mix_VolumeMusic(MIX_MAX_VOLUME); /* Calculate the number of ms for each callback */ - ms_per_step = (int) (((float)mixer->samples * 1000.0) / mixer->freq); - - return(0); -} - -/* Portable case-insensitive string compare function */ -int MIX_string_equals(const char *str1, const char *str2) -{ - while ( *str1 && *str2 ) { - if ( toupper((unsigned char)*str1) != - toupper((unsigned char)*str2) ) - break; - ++str1; - ++str2; - } - return (!*str1 && !*str2); -} - -static int detect_mp3(Uint8 *magic) -{ - if ( strncmp((char *)magic, "ID3", 3) == 0 ) { - return 1; - } - - /* Detection code lifted from SMPEG */ - if(((magic[0] & 0xff) != 0xff) || // No sync bits - ((magic[1] & 0xf0) != 0xf0) || // - ((magic[2] & 0xf0) == 0x00) || // Bitrate is 0 - ((magic[2] & 0xf0) == 0xf0) || // Bitrate is 15 - ((magic[2] & 0x0c) == 0x0c) || // Frequency is 3 - ((magic[1] & 0x06) == 0x00)) { // Layer is 4 - return(0); - } - return 1; -} - -/* MUS_MOD can't be auto-detected. If no other format was detected, MOD is - * assumed and MUS_MOD will be returned, meaning that the format might not - * actually be MOD-based. - * - * Returns MUS_NONE in case of errors. */ -static Mix_MusicType detect_music_type(SDL_RWops *src) -{ - Uint8 magic[5]; - Uint8 moremagic[9]; - - Sint64 start = SDL_RWtell(src); - if (SDL_RWread(src, magic, 1, 4) != 4 || SDL_RWread(src, moremagic, 1, 8) != 8 ) { - Mix_SetError("Couldn't read from RWops"); - return MUS_NONE; - } - SDL_RWseek(src, start, RW_SEEK_SET); - magic[4]='\0'; - moremagic[8] = '\0'; - - /* WAVE files have the magic four bytes "RIFF" - AIFF files have the magic 12 bytes "FORM" XXXX "AIFF" */ - if (((strcmp((char *)magic, "RIFF") == 0) && (strcmp((char *)(moremagic+4), "WAVE") == 0)) || - (strcmp((char *)magic, "FORM") == 0)) { - return MUS_WAV; - } - + ms_per_step = (int) (((float)spec->samples * 1000.0) / spec->freq); + + return 0; +} + +Mix_MusicType detect_music_type_from_magic(const Uint8 *magic) +{ /* Ogg Vorbis files have the magic four bytes "OggS" */ - if (strcmp((char *)magic, "OggS") == 0) { + if (SDL_memcmp(magic, "OggS", 4) == 0) { return MUS_OGG; } /* FLAC files have the magic four bytes "fLaC" */ - if (strcmp((char *)magic, "fLaC") == 0) { + if (SDL_memcmp(magic, "fLaC", 4) == 0) { return MUS_FLAC; } /* MIDI files have the magic four bytes "MThd" */ - if (strcmp((char *)magic, "MThd") == 0) { + if (SDL_memcmp(magic, "MThd", 4) == 0) { return MUS_MID; } - if (detect_mp3(magic)) { + if (SDL_memcmp(magic, "ID3", 3) == 0 || + (magic[0] == 0xFF && (magic[1] & 0xFE) == 0xFA)) { return MUS_MP3; } @@ -511,35 +376,57 @@ return MUS_MOD; } +static Mix_MusicType detect_music_type(SDL_RWops *src) +{ + Uint8 magic[12]; + + if (SDL_RWread(src, magic, 1, 12) != 12) { + Mix_SetError("Couldn't read first 12 bytes of audio data"); + return MUS_NONE; + } + SDL_RWseek(src, -12, RW_SEEK_CUR); + + /* WAVE files have the magic four bytes "RIFF" + AIFF files have the magic 12 bytes "FORM" XXXX "AIFF" */ + if (((SDL_memcmp(magic, "RIFF", 4) == 0) && (SDL_memcmp((magic+8), "WAVE", 4) == 0)) || + (SDL_memcmp(magic, "FORM", 4) == 0)) { + return MUS_WAV; + } + + return detect_music_type_from_magic(magic); +} + /* Load a music file */ Mix_Music *Mix_LoadMUS(const char *file) { + int i; + void *context; + char *ext; + Mix_MusicType type; SDL_RWops *src; - Mix_Music *music; - Mix_MusicType type; - char *ext = strrchr(file, '.'); - -#ifdef CMD_MUSIC - if ( music_cmd ) { - /* Allocate memory for the music structure */ - music = (Mix_Music *)SDL_malloc(sizeof(Mix_Music)); - if ( music == NULL ) { - Mix_SetError("Out of memory"); - return(NULL); - } - music->error = 0; - music->type = MUS_CMD; - music->data.cmd = MusicCMD_LoadSong(music_cmd, file); - if ( music->data.cmd == NULL ) { - SDL_free(music); - music = NULL; - } - return music; - } -#endif + + for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { + Mix_MusicInterface *interface = s_music_interfaces[i]; + if (!interface->opened || !interface->CreateFromFile) { + continue; + } + + context = interface->CreateFromFile(file); + if (context) { + /* Allocate memory for the music structure */ + Mix_Music *music = (Mix_Music *)SDL_calloc(1, sizeof(Mix_Music)); + if (music == NULL) { + Mix_SetError("Out of memory"); + return NULL; + } + music->interface = interface; + music->context = context; + return music; + } + } src = SDL_RWFromFile(file, "rb"); - if ( src == NULL ) { + if (src == NULL) { Mix_SetError("Couldn't open '%s'", file); return NULL; } @@ -547,39 +434,48 @@ /* Use the extension as a first guess on the file type */ type = MUS_NONE; ext = strrchr(file, '.'); - /* No need to guard these with #ifdef *_MUSIC stuff, - * since we simply call Mix_LoadMUSType_RW() later */ - if ( ext ) { + if (ext) { ++ext; /* skip the dot in the extension */ - if ( MIX_string_equals(ext, "WAV") ) { + if (SDL_strcasecmp(ext, "WAV") == 0) { type = MUS_WAV; - } else if ( MIX_string_equals(ext, "MID") || - MIX_string_equals(ext, "MIDI") || - MIX_string_equals(ext, "KAR") ) { + } else if (SDL_strcasecmp(ext, "MID") == 0 || + SDL_strcasecmp(ext, "MIDI") == 0 || + SDL_strcasecmp(ext, "KAR") == 0) { type = MUS_MID; - } else if ( MIX_string_equals(ext, "OGG") ) { + } else if (SDL_strcasecmp(ext, "OGG") == 0) { type = MUS_OGG; - } else if ( MIX_string_equals(ext, "FLAC") ) { + } else if (SDL_strcasecmp(ext, "FLAC") == 0) { type = MUS_FLAC; - } else if ( MIX_string_equals(ext, "MPG") || - MIX_string_equals(ext, "MPEG") || - MIX_string_equals(ext, "MP3") || - MIX_string_equals(ext, "MAD") ) { + } else if (SDL_strcasecmp(ext, "MPG") == 0 || + SDL_strcasecmp(ext, "MPEG") == 0 || + SDL_strcasecmp(ext, "MP3") == 0 || + SDL_strcasecmp(ext, "MAD") == 0) { type = MUS_MP3; - } - } - if ( type == MUS_NONE ) { - type = detect_music_type(src); - } - - /* We need to know if a specific error occurs; if not, we'll set a - * generic one, so we clear the current one. */ - SDL_ClearError(); - music = Mix_LoadMUSType_RW(src, type, SDL_TRUE); - if ( music == NULL && Mix_GetError()[0] == '\0' ) { - Mix_SetError("Unrecognized music format"); - } - return music; + } else if (SDL_strcasecmp(ext, "669") == 0 || + SDL_strcasecmp(ext, "AMF") == 0 || + SDL_strcasecmp(ext, "AMS") == 0 || + SDL_strcasecmp(ext, "DBM") == 0 || + SDL_strcasecmp(ext, "DSM") == 0 || + SDL_strcasecmp(ext, "FAR") == 0 || + SDL_strcasecmp(ext, "IT") == 0 || + SDL_strcasecmp(ext, "MED") == 0 || + SDL_strcasecmp(ext, "MDL") == 0 || + SDL_strcasecmp(ext, "MOD") == 0 || + SDL_strcasecmp(ext, "MOL") == 0 || + SDL_strcasecmp(ext, "MTM") == 0 || + SDL_strcasecmp(ext, "NST") == 0 || + SDL_strcasecmp(ext, "OKT") == 0 || + SDL_strcasecmp(ext, "PTM") == 0 || + SDL_strcasecmp(ext, "S3M") == 0 || + SDL_strcasecmp(ext, "STM") == 0 || + SDL_strcasecmp(ext, "ULT") == 0 || + SDL_strcasecmp(ext, "UMX") == 0 || + SDL_strcasecmp(ext, "WOW") == 0 || + SDL_strcasecmp(ext, "XM") == 0) { + type = MUS_MOD; + } + } + return Mix_LoadMUSType_RW(src, type, SDL_TRUE); } Mix_Music *Mix_LoadMUS_RW(SDL_RWops *src, int freesrc) @@ -589,7 +485,8 @@ Mix_Music *Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc) { - Mix_Music *music; + int i; + void *context; Sint64 start; if (!src) { @@ -602,8 +499,7 @@ * this is. */ if (type == MUS_NONE) { if ((type = detect_music_type(src)) == MUS_NONE) { - /* Don't call Mix_SetError() here since detect_music_type() - * does that. */ + /* Don't call Mix_SetError() since detect_music_type() does that. */ if (freesrc) { SDL_RWclose(src); } @@ -611,242 +507,67 @@ } } - /* Allocate memory for the music structure */ - music = (Mix_Music *)SDL_malloc(sizeof(Mix_Music)); - if (music == NULL ) { - Mix_SetError("Out of memory"); - if (freesrc) { - SDL_RWclose(src); - } - return NULL; - } - music->error = 1; - - switch (type) { -#ifdef WAV_MUSIC - case MUS_WAV: - music->type = MUS_WAV; - music->data.wave = WAVStream_LoadSong_RW(src, freesrc); - if (music->data.wave) { - music->error = 0; - } - break; -#endif -#ifdef OGG_MUSIC - case MUS_OGG: - music->type = MUS_OGG; - music->data.ogg = OGG_new_RW(src, freesrc); - if (music->data.ogg) { - music->error = 0; - } - break; -#endif -#ifdef FLAC_MUSIC - case MUS_FLAC: - music->type = MUS_FLAC; - music->data.flac = FLAC_new_RW(src, freesrc); - if (music->data.flac) { - music->error = 0; - } - break; -#endif -#ifdef MP3_MUSIC - case MUS_MP3: - if (Mix_Init(MIX_INIT_MP3)) { - SMPEG_Info info; - music->type = MUS_MP3; - music->data.mp3 = smpeg.SMPEG_new_rwops(src, &info, freesrc, 0); - if (!info.has_audio) { - Mix_SetError("MPEG file does not have any audio stream."); - smpeg.SMPEG_delete(music->data.mp3); - /* Deleting the MP3 closed the source if desired */ - freesrc = SDL_FALSE; - } else { - smpeg.SMPEG_actualSpec(music->data.mp3, &used_mixer); - music->error = 0; - } - } - break; -#elif defined(MP3_MAD_MUSIC) - case MUS_MP3: - music->type = MUS_MP3_MAD; - music->data.mp3_mad = mad_openFileRW(src, &used_mixer, freesrc); - if (music->data.mp3_mad) { - music->error = 0; - } else { - Mix_SetError("Could not initialize MPEG stream."); - } - break; -#endif -#ifdef MID_MUSIC - case MUS_MID: - music->type = MUS_MID; -#ifdef USE_NATIVE_MIDI - if (native_midi_ok) { - SDL_RWseek(src, start, RW_SEEK_SET); - music->data.nativemidi = native_midi_loadsong_RW(src, freesrc); - if (music->data.nativemidi) { - music->error = 0; - } else { - Mix_SetError("%s", native_midi_error()); - } - break; - } -#endif -#ifdef USE_FLUIDSYNTH_MIDI - if (fluidsynth_ok) { - SDL_RWseek(src, start, RW_SEEK_SET); - music->data.fluidsynthmidi = fluidsynth_loadsong_RW(src, freesrc); - if (music->data.fluidsynthmidi) { - music->error = 0; - } - break; - } -#endif -#ifdef USE_TIMIDITY_MIDI - if (timidity_ok) { - SDL_RWseek(src, start, RW_SEEK_SET); - music->data.midi = Timidity_LoadSong_RW(src, freesrc); - if (music->data.midi) { - music->error = 0; - } else { - Mix_SetError("%s", Timidity_Error()); - } - } else { - Mix_SetError("%s", Timidity_Error()); - } -#endif - break; -#endif -#if defined(MODPLUG_MUSIC) || defined(MOD_MUSIC) - case MUS_MOD: -#ifdef MODPLUG_MUSIC - if (music->error) { - SDL_RWseek(src, start, RW_SEEK_SET); - music->type = MUS_MODPLUG; - music->data.modplug = modplug_new_RW(src, freesrc); - if (music->data.modplug) { - music->error = 0; - } - } -#endif -#ifdef MOD_MUSIC - if (music->error) { - SDL_RWseek(src, start, RW_SEEK_SET); - music->type = MUS_MOD; - music->data.module = MOD_new_RW(src, freesrc); - if (music->data.module) { - music->error = 0; - } - } -#endif - break; -#endif - - default: - Mix_SetError("Unrecognized music format"); - break; - } /* switch (want) */ - - if (music->error) { - SDL_free(music); - if (freesrc) { - SDL_RWclose(src); - } else { - SDL_RWseek(src, start, RW_SEEK_SET); - } - music = NULL; - } - return music; + Mix_ClearError(); + + for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { + Mix_MusicInterface *interface = s_music_interfaces[i]; + if (!interface->opened || type != interface->type || !interface->CreateFromRW) { + continue; + } + + context = interface->CreateFromRW(src, freesrc); + if (context) { + /* Allocate memory for the music structure */ + Mix_Music *music = (Mix_Music *)SDL_calloc(1, sizeof(Mix_Music)); + if (music == NULL) { + interface->Delete(context); + Mix_SetError("Out of memory"); + return NULL; + } + music->interface = interface; + music->context = context; +#ifdef DEBUG_MUSIC + /* This would be useful to expose via an API */ + SDL_Log("Music playing with %s\n", interface->tag); +#endif + return music; + } + + /* Reset the stream for the next decoder */ + SDL_RWseek(src, start, RW_SEEK_SET); + } + + if (!*Mix_GetError()) { + Mix_SetError("Unrecognized audio format"); + } + if (freesrc) { + SDL_RWclose(src); + } else { + SDL_RWseek(src, start, RW_SEEK_SET); + } + return NULL; } /* Free a music chunk previously loaded */ void Mix_FreeMusic(Mix_Music *music) { - if ( music ) { + if (music) { /* Stop the music if it's currently playing */ - SDL_LockAudio(); - if ( music == music_playing ) { + Mix_LockAudio(); + if (music == music_playing) { /* Wait for any fade out to finish */ - while ( music->fading == MIX_FADING_OUT ) { - SDL_UnlockAudio(); + while (music->fading == MIX_FADING_OUT) { + Mix_UnlockAudio(); SDL_Delay(100); - SDL_LockAudio(); - } - if ( music == music_playing ) { + Mix_LockAudio(); + } + if (music == music_playing) { music_internal_halt(); } } - SDL_UnlockAudio(); - switch (music->type) { -#ifdef CMD_MUSIC - case MUS_CMD: - MusicCMD_FreeSong(music->data.cmd); - break; -#endif -#ifdef WAV_MUSIC - case MUS_WAV: - WAVStream_FreeSong(music->data.wave); - break; -#endif -#ifdef MODPLUG_MUSIC - case MUS_MODPLUG: - modplug_delete(music->data.modplug); - break; -#endif -#ifdef MOD_MUSIC - case MUS_MOD: - MOD_delete(music->data.module); - break; -#endif -#ifdef MID_MUSIC - case MUS_MID: -#ifdef USE_NATIVE_MIDI - if ( native_midi_ok ) { - native_midi_freesong(music->data.nativemidi); - goto skip; - } -#endif -#ifdef USE_FLUIDSYNTH_MIDI - if ( fluidsynth_ok ) { - fluidsynth_freesong(music->data.fluidsynthmidi); - goto skip; - } -#endif -#ifdef USE_TIMIDITY_MIDI - if ( timidity_ok ) { - Timidity_FreeSong(music->data.midi); - goto skip; - } -#endif - break; -#endif -#ifdef OGG_MUSIC - case MUS_OGG: - OGG_delete(music->data.ogg); - break; -#endif -#ifdef FLAC_MUSIC - case MUS_FLAC: - FLAC_delete(music->data.flac); - break; -#endif -#ifdef MP3_MUSIC - case MUS_MP3: - smpeg.SMPEG_delete(music->data.mp3); - break; -#endif -#ifdef MP3_MAD_MUSIC - case MUS_MP3_MAD: - mad_closeFile(music->data.mp3_mad); - break; -#endif - default: - /* Unknown music type?? */ - break; - } - - skip: + Mix_UnlockAudio(); + + music->interface->Delete(music->context); SDL_free(music); } } @@ -858,29 +579,29 @@ { Mix_MusicType type = MUS_NONE; - if ( music ) { - type = music->type; + if (music) { + type = music->interface->type; } else { - SDL_LockAudio(); - if ( music_playing ) { - type = music_playing->type; - } - SDL_UnlockAudio(); + Mix_LockAudio(); + if (music_playing) { + type = music_playing->interface->type; + } + Mix_UnlockAudio(); } return(type); } /* Play a music chunk. Returns 0, or -1 if there was an error. */ -static int music_internal_play(Mix_Music *music, double position) +static int music_internal_play(Mix_Music *music, int play_count, double position) { int retval = 0; -#if defined(__MACOSX__) && defined(USE_NATIVE_MIDI) +#if defined(__MACOSX__) && defined(MID_MUSIC_NATIVE) /* This fixes a bug with native MIDI on Mac OS X, where you can't really stop and restart MIDI from the audio callback. */ - if ( music == music_playing && music->type == MUS_MID && native_midi_ok ) { + if (music == music_playing && music->api == MIX_MUSIC_NATIVEMIDI) { /* Just a seek suffices to restart playing */ music_internal_position(position); return 0; @@ -888,97 +609,22 @@ #endif /* Note the music we're playing */ - if ( music_playing ) { + if (music_playing) { music_internal_halt(); } music_playing = music; + music_playing->playing = SDL_TRUE; /* Set the initial volume */ - if ( music->type != MUS_MOD ) { - music_internal_initialize_volume(); - } + music_internal_initialize_volume(); /* Set up for playback */ - switch (music->type) { -#ifdef CMD_MUSIC - case MUS_CMD: - MusicCMD_Start(music->data.cmd); - break; -#endif -#ifdef WAV_MUSIC - case MUS_WAV: - WAVStream_Start(music->data.wave); - break; -#endif -#ifdef MODPLUG_MUSIC - case MUS_MODPLUG: - /* can't set volume until file is loaded, so finally set it now */ - music_internal_initialize_volume(); - modplug_play(music->data.modplug); - break; -#endif -#ifdef MOD_MUSIC - case MUS_MOD: - MOD_play(music->data.module); - /* Player_SetVolume() does nothing before Player_Start() */ - music_internal_initialize_volume(); - break; -#endif -#ifdef MID_MUSIC - case MUS_MID: -#ifdef USE_NATIVE_MIDI - if ( native_midi_ok ) { - native_midi_start(music->data.nativemidi, music_loops); - goto skip; - } -#endif -#ifdef USE_FLUIDSYNTH_MIDI - if (fluidsynth_ok ) { - fluidsynth_start(music->data.fluidsynthmidi); - goto skip; - } -#endif -#ifdef USE_TIMIDITY_MIDI - if ( timidity_ok ) { - Timidity_Start(music->data.midi); - goto skip; - } -#endif - break; -#endif -#ifdef OGG_MUSIC - case MUS_OGG: - OGG_play(music->data.ogg); - break; -#endif -#ifdef FLAC_MUSIC - case MUS_FLAC: - FLAC_play(music->data.flac); - break; -#endif -#ifdef MP3_MUSIC - case MUS_MP3: - smpeg.SMPEG_enableaudio(music->data.mp3,1); - smpeg.SMPEG_enablevideo(music->data.mp3,0); - smpeg.SMPEG_play(music_playing->data.mp3); - break; -#endif -#ifdef MP3_MAD_MUSIC - case MUS_MP3_MAD: - mad_start(music->data.mp3_mad); - break; -#endif - default: - Mix_SetError("Can't play unknown music type"); - retval = -1; - break; - } - -skip: + retval = music->interface->Play(music->context, play_count); + /* Set the playback position, note any errors if an offset is used */ - if ( retval == 0 ) { - if ( position > 0.0 ) { - if ( music_internal_position(position) < 0 ) { + if (retval == 0) { + if (position > 0.0) { + if (music_internal_position(position) < 0) { Mix_SetError("Position not implemented for music type"); retval = -1; } @@ -988,28 +634,30 @@ } /* If the setup failed, we're not playing any music anymore */ - if ( retval < 0 ) { + if (retval < 0) { + music->playing = SDL_FALSE; music_playing = NULL; } return(retval); } + int Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position) { int retval; - if ( ms_per_step == 0 ) { + if (ms_per_step == 0) { SDL_SetError("Audio device hasn't been opened"); return(-1); } /* Don't play null pointers :-) */ - if ( music == NULL ) { + if (music == NULL) { Mix_SetError("music parameter was NULL"); return(-1); } /* Setup the data */ - if ( ms ) { + if (ms) { music->fading = MIX_FADING_IN; } else { music->fading = MIX_NO_FADING; @@ -1018,21 +666,19 @@ music->fade_steps = ms/ms_per_step; /* Play the puppy */ - SDL_LockAudio(); + Mix_LockAudio(); /* If the current music is fading out, wait for the fade to complete */ - while ( music_playing && (music_playing->fading == MIX_FADING_OUT) ) { - SDL_UnlockAudio(); + while (music_playing && (music_playing->fading == MIX_FADING_OUT)) { + Mix_UnlockAudio(); SDL_Delay(100); - SDL_LockAudio(); - } - music_active = 1; - if (loops == 1) { + Mix_LockAudio(); + } + if (loops == 0) { /* Loop is the number of times to play the audio */ - loops = 0; - } - music_loops = loops; - retval = music_internal_play(music, position); - SDL_UnlockAudio(); + loops = 1; + } + retval = music_internal_play(music, loops, position); + Mix_UnlockAudio(); return(retval); } @@ -1048,65 +694,26 @@ /* Set the playing music position */ int music_internal_position(double position) { - int retval = 0; - - switch (music_playing->type) { -#ifdef MODPLUG_MUSIC - case MUS_MODPLUG: - modplug_jump_to_time(music_playing->data.modplug, position); - break; -#endif -#ifdef MOD_MUSIC - case MUS_MOD: - MOD_jump_to_time(music_playing->data.module, position); - break; -#endif -#ifdef OGG_MUSIC - case MUS_OGG: - OGG_jump_to_time(music_playing->data.ogg, position); - break; -#endif -#ifdef FLAC_MUSIC - case MUS_FLAC: - FLAC_jump_to_time(music_playing->data.flac, position); - break; -#endif -#ifdef MP3_MUSIC - case MUS_MP3: - smpeg.SMPEG_rewind(music_playing->data.mp3); - smpeg.SMPEG_play(music_playing->data.mp3); - if ( position > 0.0 ) { - smpeg.SMPEG_skip(music_playing->data.mp3, (float)position); - } - break; -#endif -#ifdef MP3_MAD_MUSIC - case MUS_MP3_MAD: - mad_seek(music_playing->data.mp3_mad, position); - break; -#endif - default: - /* TODO: Implement this for other music backends */ - retval = -1; - break; - } - return(retval); + if (music_playing->interface->Seek) { + return music_playing->interface->Seek(music_playing->context, position); + } + return -1; } int Mix_SetMusicPosition(double position) { int retval; - SDL_LockAudio(); - if ( music_playing ) { + Mix_LockAudio(); + if (music_playing) { retval = music_internal_position(position); - if ( retval < 0 ) { + if (retval < 0) { Mix_SetError("Position not implemented for music type"); } } else { Mix_SetError("Music isn't playing"); retval = -1; } - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(retval); } @@ -1114,7 +721,7 @@ /* Set the music's initial volume */ static void music_internal_initialize_volume(void) { - if ( music_playing->fading == MIX_FADING_IN ) { + if (music_playing->fading == MIX_FADING_IN) { music_internal_volume(0); } else { music_internal_volume(music_volume); @@ -1124,72 +731,8 @@ /* Set the music volume */ static void music_internal_volume(int volume) { - switch (music_playing->type) { -#ifdef CMD_MUSIC - case MUS_CMD: - MusicCMD_SetVolume(volume); - break; -#endif -#ifdef WAV_MUSIC - case MUS_WAV: - WAVStream_SetVolume(volume); - break; -#endif -#ifdef MODPLUG_MUSIC - case MUS_MODPLUG: - modplug_setvolume(music_playing->data.modplug, volume); - break; -#endif -#ifdef MOD_MUSIC - case MUS_MOD: - MOD_setvolume(music_playing->data.module, volume); - break; -#endif -#ifdef MID_MUSIC - case MUS_MID: -#ifdef USE_NATIVE_MIDI - if ( native_midi_ok ) { - native_midi_setvolume(volume); - return; - } -#endif -#ifdef USE_FLUIDSYNTH_MIDI - if ( fluidsynth_ok ) { - fluidsynth_setvolume(music_playing->data.fluidsynthmidi, volume); - return; - } -#endif -#ifdef USE_TIMIDITY_MIDI - if ( timidity_ok ) { - Timidity_SetVolume(volume); - return; - } -#endif - break; -#endif -#ifdef OGG_MUSIC - case MUS_OGG: - OGG_setvolume(music_playing->data.ogg, volume); - break; -#endif -#ifdef FLAC_MUSIC - case MUS_FLAC: - FLAC_setvolume(music_playing->data.flac, volume); - break; -#endif -#ifdef MP3_MUSIC - case MUS_MP3: - smpeg.SMPEG_setvolume(music_playing->data.mp3,(int)(((float)volume/(float)MIX_MAX_VOLUME)*100.0)); - break; -#endif -#ifdef MP3_MAD_MUSIC - case MUS_MP3_MAD: - mad_setVolume(music_playing->data.mp3_mad, volume); - break; -#endif - default: - /* Unknown music type?? */ - break; + if (music_playing->interface->SetVolume) { + music_playing->interface->SetVolume(music_playing->context, volume); } } int Mix_VolumeMusic(int volume) @@ -1197,106 +740,42 @@ int prev_volume; prev_volume = music_volume; - if ( volume < 0 ) { + if (volume < 0) { return prev_volume; } - if ( volume > SDL_MIX_MAXVOLUME ) { + if (volume > SDL_MIX_MAXVOLUME) { volume = SDL_MIX_MAXVOLUME; } music_volume = volume; - SDL_LockAudio(); - if ( music_playing ) { + Mix_LockAudio(); + if (music_playing) { music_internal_volume(music_volume); } - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(prev_volume); } /* Halt playing of music */ static void music_internal_halt(void) { - switch (music_playing->type) { -#ifdef CMD_MUSIC - case MUS_CMD: - MusicCMD_Stop(music_playing->data.cmd); - break; -#endif -#ifdef WAV_MUSIC - case MUS_WAV: - WAVStream_Stop(); - break; -#endif -#ifdef MODPLUG_MUSIC - case MUS_MODPLUG: - modplug_stop(music_playing->data.modplug); - break; -#endif -#ifdef MOD_MUSIC - case MUS_MOD: - MOD_stop(music_playing->data.module); - break; -#endif -#ifdef MID_MUSIC - case MUS_MID: -#ifdef USE_NATIVE_MIDI - if ( native_midi_ok ) { - native_midi_stop(); - goto skip; - } -#endif -#ifdef USE_FLUIDSYNTH_MIDI - if ( fluidsynth_ok ) { - fluidsynth_stop(music_playing->data.fluidsynthmidi); - goto skip; - } -#endif -#ifdef USE_TIMIDITY_MIDI - if ( timidity_ok ) { - Timidity_Stop(); - goto skip; - } -#endif - break; -#endif -#ifdef OGG_MUSIC - case MUS_OGG: - OGG_stop(music_playing->data.ogg); - break; -#endif -#ifdef FLAC_MUSIC - case MUS_FLAC: - FLAC_stop(music_playing->data.flac); - break; -#endif -#ifdef MP3_MUSIC - case MUS_MP3: - smpeg.SMPEG_stop(music_playing->data.mp3); - break; -#endif -#ifdef MP3_MAD_MUSIC - case MUS_MP3_MAD: - mad_stop(music_playing->data.mp3_mad); - break; -#endif - default: - /* Unknown music type?? */ - return; - } - -skip: + if (music_playing->interface->Stop) { + music_playing->interface->Stop(music_playing->context); + } + + music_playing->playing = SDL_FALSE; music_playing->fading = MIX_NO_FADING; music_playing = NULL; } int Mix_HaltMusic(void) { - SDL_LockAudio(); - if ( music_playing ) { + Mix_LockAudio(); + if (music_playing) { music_internal_halt(); - if ( music_finished_hook ) { + if (music_finished_hook) { music_finished_hook(); } } - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(0); } @@ -1306,7 +785,7 @@ { int retval = 0; - if ( ms_per_step == 0 ) { + if (ms_per_step == 0) { SDL_SetError("Audio device hasn't been opened"); return 0; } @@ -1316,28 +795,26 @@ return 1; } - SDL_LockAudio(); - if ( music_playing) { - int fade_steps = (ms + ms_per_step - 1)/ms_per_step; - if ( music_playing->fading == MIX_NO_FADING ) { - music_playing->fade_step = 0; - } else { - int step; - int old_fade_steps = music_playing->fade_steps; - if ( music_playing->fading == MIX_FADING_OUT ) { - step = music_playing->fade_step; - } else { - step = old_fade_steps - - music_playing->fade_step + 1; - } - music_playing->fade_step = (step * fade_steps) - / old_fade_steps; - } + Mix_LockAudio(); + if (music_playing) { + int fade_steps = (ms + ms_per_step - 1) / ms_per_step; + if (music_playing->fading == MIX_NO_FADING) { + music_playing->fade_step = 0; + } else { + int step; + int old_fade_steps = music_playing->fade_steps; + if (music_playing->fading == MIX_FADING_OUT) { + step = music_playing->fade_step; + } else { + step = old_fade_steps - music_playing->fade_step + 1; + } + music_playing->fade_step = (step * fade_steps) / old_fade_steps; + } music_playing->fading = MIX_FADING_OUT; music_playing->fade_steps = fade_steps; retval = 1; } - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(retval); } @@ -1346,11 +823,11 @@ { Mix_Fading fading = MIX_NO_FADING; - SDL_LockAudio(); - if ( music_playing ) { + Mix_LockAudio(); + if (music_playing) { fading = music_playing->fading; } - SDL_UnlockAudio(); + Mix_UnlockAudio(); return(fading); } @@ -1358,12 +835,26 @@ /* Pause/Resume the music stream */ void Mix_PauseMusic(void) { - music_active = 0; + Mix_LockAudio(); + if (music_playing) { + if (music_playing->interface->Pause) { + music_playing->interface->Pause(music_playing->context); + } + } + music_active = SDL_FALSE; + Mix_UnlockAudio(); } void Mix_ResumeMusic(void) { - music_active = 1; + Mix_LockAudio(); + if (music_playing) { + if (music_playing->interface->Resume) { + music_playing->interface->Resume(music_playing->context); + } + } + music_active = SDL_TRUE; + Mix_UnlockAudio(); } void Mix_RewindMusic(void) @@ -1373,136 +864,49 @@ int Mix_PausedMusic(void) { - return (music_active == 0); + return (music_active == SDL_FALSE); } /* Check the status of the music */ -static int music_internal_playing() -{ - int playing = 1; - - if (music_playing == NULL) { - return 0; - } - - switch (music_playing->type) { -#ifdef CMD_MUSIC - case MUS_CMD: - if (!MusicCMD_Active(music_playing->data.cmd)) { - playing = 0; - } - break; -#endif -#ifdef WAV_MUSIC - case MUS_WAV: - if ( ! WAVStream_Active() ) { - playing = 0; - } - break; -#endif -#ifdef MODPLUG_MUSIC - case MUS_MODPLUG: - if ( ! modplug_playing(music_playing->data.modplug) ) { - playing = 0; - } - break; -#endif -#ifdef MOD_MUSIC - case MUS_MOD: - if ( ! MOD_playing(music_playing->data.module) ) { - playing = 0; - } - break; -#endif -#ifdef MID_MUSIC - case MUS_MID: -#ifdef USE_NATIVE_MIDI - if ( native_midi_ok ) { - if ( ! native_midi_active() ) - playing = 0; - goto skip; - } -#endif -#ifdef USE_FLUIDSYNTH_MIDI - if ( fluidsynth_ok ) { - if ( ! fluidsynth_active(music_playing->data.fluidsynthmidi) ) - playing = 0; - goto skip; - } -#endif -#ifdef USE_TIMIDITY_MIDI - if ( timidity_ok ) { - if ( ! Timidity_Active() ) - playing = 0; - goto skip; - } -#endif - break; -#endif -#ifdef OGG_MUSIC - case MUS_OGG: - if ( ! OGG_playing(music_playing->data.ogg) ) { - playing = 0; - } - break; -#endif -#ifdef FLAC_MUSIC - case MUS_FLAC: - if ( ! FLAC_playing(music_playing->data.flac) ) { - playing = 0; - } - break; -#endif -#ifdef MP3_MUSIC - case MUS_MP3: - if ( smpeg.SMPEG_status(music_playing->data.mp3) != SMPEG_PLAYING ) - playing = 0; - break; -#endif -#ifdef MP3_MAD_MUSIC - case MUS_MP3_MAD: - if (!mad_isPlaying(music_playing->data.mp3_mad)) { - playing = 0; - } - break; -#endif - default: - playing = 0; - break; - } - -skip: - return(playing); +static SDL_bool music_internal_playing(void) +{ + if (!music_playing) { + return SDL_FALSE; + } + + if (music_playing->interface->IsPlaying) { + music_playing->playing = music_playing->interface->IsPlaying(music_playing->context); + } + return music_playing->playing; } int Mix_PlayingMusic(void) { - int playing = 0; - - SDL_LockAudio(); - if ( music_playing ) { - playing = music_loops || music_internal_playing(); - } - SDL_UnlockAudio(); - - return(playing); + SDL_bool playing; + + Mix_LockAudio(); + playing = music_internal_playing(); + Mix_UnlockAudio(); + + return playing ? 1 : 0; } /* Set the external music playback command */ int Mix_SetMusicCMD(const char *command) { Mix_HaltMusic(); - if ( music_cmd ) { + if (music_cmd) { SDL_free(music_cmd); music_cmd = NULL; } - if ( command ) { - music_cmd = (char *)SDL_malloc(strlen(command)+1); - if ( music_cmd == NULL ) { - return(-1); - } - strcpy(music_cmd, command); - } - return(0); + if (command) { + size_t length = SDL_strlen(command) + 1; + music_cmd = (char *)SDL_malloc(length); + if (music_cmd == NULL) { + return SDL_OutOfMemory(); + } + SDL_memcpy(music_cmd, command, length); + } + return 0; } int Mix_SetSynchroValue(int i) @@ -1518,36 +922,59 @@ } -/* Uninitialize the music players */ +/* Uninitialize the music interfaces */ void close_music(void) { + int i; + Mix_HaltMusic(); -#ifdef CMD_MUSIC - Mix_SetMusicCMD(NULL); -#endif -#ifdef MODPLUG_MUSIC - modplug_exit(); -#endif -#ifdef MOD_MUSIC - MOD_exit(); -#endif -#ifdef MID_MUSIC -# ifdef USE_TIMIDITY_MIDI - Timidity_Close(); -# endif -#endif + + for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { + Mix_MusicInterface *interface = s_music_interfaces[i]; + if (!interface || !interface->opened) { + continue; + } + + if (interface->Close) { + interface->Close(); + } + interface->opened = SDL_FALSE; + } + + if (soundfont_paths) { + SDL_free(soundfont_paths); + soundfont_paths = NULL; + } /* rcg06042009 report available decoders at runtime. */ - SDL_free((void *)music_decoders); - music_decoders = NULL; + if (music_decoders) { + SDL_free((void *)music_decoders); + music_decoders = NULL; + } num_decoders = 0; ms_per_step = 0; } +/* Unload the music interface libraries */ +void unload_music(void) +{ + int i; + for (i = 0; i < SDL_arraysize(s_music_interfaces); ++i) { + Mix_MusicInterface *interface = s_music_interfaces[i]; + if (!interface || !interface->loaded) { + continue; + } + + if (interface->Unload) { + interface->Unload(); + } + interface->loaded = SDL_FALSE; + } +} + int Mix_SetSoundFonts(const char *paths) { -#ifdef MID_MUSIC if (soundfont_paths) { SDL_free(soundfont_paths); soundfont_paths = NULL; @@ -1559,26 +986,48 @@ return 0; } } -#endif return 1; } -#ifdef MID_MUSIC const char* Mix_GetSoundFonts(void) { - const char* force = getenv("SDL_FORCE_SOUNDFONTS"); - - if (!soundfont_paths || (force && force[0] == '1')) { - return getenv("SDL_SOUNDFONTS"); - } else { + const char *env_paths = SDL_getenv("SDL_SOUNDFONTS"); + SDL_bool force_env_paths = SDL_GetHintBoolean("SDL_FORCE_SOUNDFONTS", SDL_FALSE); + if (force_env_paths && (!env_paths || !*env_paths)) { + force_env_paths = SDL_FALSE; + } + if (soundfont_paths && *soundfont_paths && !force_env_paths) { return soundfont_paths; } -} - -int Mix_EachSoundFont(int (*function)(const char*, void*), void *data) + if (env_paths) { + return env_paths; + } + + /* We don't have any sound fonts set programmatically or in the environment + Time to start guessing where they might be... + */ + { + static char *s_soundfont_paths[] = { + "/usr/share/sounds/sf2/FluidR3_GM.sf2" /* Remember to add ',' here */ + }; + unsigned i; + + for (i = 0; i < SDL_arraysize(s_soundfont_paths); ++i) { + SDL_RWops *rwops = SDL_RWFromFile(s_soundfont_paths[i], "rb"); + if (rwops) { + SDL_RWclose(rwops); + return s_soundfont_paths[i]; + } + } + } + return NULL; +} + +int Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data) { char *context, *path, *paths; const char* cpaths = Mix_GetSoundFonts(); + int soundfonts_found = 0; if (!cpaths) { Mix_SetError("No SoundFonts have been requested"); @@ -1590,7 +1039,7 @@ return 0; } -#if defined(__MINGW32__) || defined(__MINGW64__) +#if defined(__MINGW32__) || defined(__MINGW64__) || defined(__WATCOMC__) for (path = strtok(paths, ";"); path; path = strtok(NULL, ";")) { #elif defined(_WIN32) for (path = strtok_s(paths, ";", &context); path; path = strtok_s(NULL, ";", &context)) { @@ -1598,12 +1047,17 @@ for (path = strtok_r(paths, ":;", &context); path; path = strtok_r(NULL, ":;", &context)) { #endif if (!function(path, data)) { - SDL_free(paths); - return 0; + continue; + } else { + soundfonts_found++; } } SDL_free(paths); - return 1; -} -#endif + if (soundfonts_found > 0) + return 1; + else + return 0; +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music.h b/music.h new file mode 100644 index 0000000..a9b7923 --- /dev/null +++ b/music.h @@ -0,0 +1,123 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_mixer.h" + +#ifndef MUSIC_H_ +#define MUSIC_H_ + +/* Supported music APIs, in order of preference */ + +typedef enum +{ + MIX_MUSIC_CMD, + MIX_MUSIC_WAVE, + MIX_MUSIC_MODPLUG, + MIX_MUSIC_MIKMOD, + MIX_MUSIC_FLUIDSYNTH, + MIX_MUSIC_TIMIDITY, + MIX_MUSIC_NATIVEMIDI, + MIX_MUSIC_OGG, + MIX_MUSIC_MPG123, + MIX_MUSIC_MAD, + MIX_MUSIC_SMPEG, + MIX_MUSIC_FLAC, + MIX_MUSIC_LAST +} Mix_MusicAPI; + + +/* Music API implementation */ + +typedef struct +{ + const char *tag; + Mix_MusicAPI api; + Mix_MusicType type; + SDL_bool loaded; + SDL_bool opened; + + /* Load the library */ + int (*Load)(void); + + /* Initialize for the audio output */ + int (*Open)(const SDL_AudioSpec *spec); + + /* Create a music object from an SDL_RWops stream + * If the function returns NULL, 'src' will be freed if needed by the caller. + */ + void *(*CreateFromRW)(SDL_RWops *src, int freesrc); + + /* Create a music object from a file, if SDL_RWops are not supported */ + void *(*CreateFromFile)(const char *file); + + /* Set the volume */ + void (*SetVolume)(void *music, int volume); + + /* Start playing music from the beginning with an optional loop count */ + int (*Play)(void *music, int play_count); + + /* Returns SDL_TRUE if music is still playing */ + SDL_bool (*IsPlaying)(void *music); + + /* Get music data, returns the number of bytes left */ + int (*GetAudio)(void *music, void *data, int bytes); + + /* Seek to a play position (in seconds) */ + int (*Seek)(void *music, double position); + + /* Pause playing music */ + void (*Pause)(void *music); + + /* Resume playing music */ + void (*Resume)(void *music); + + /* Stop playing music */ + void (*Stop)(void *music); + + /* Delete a music object */ + void (*Delete)(void *music); + + /* Close the library and clean up */ + void (*Close)(void); + + /* Unload the library */ + void (*Unload)(void); + +} Mix_MusicInterface; + + +extern int load_music(void); +extern Mix_MusicType detect_music_type_from_magic(const Uint8 *magic); +extern int get_num_music_interfaces(void); +extern Mix_MusicInterface *get_music_interface(int index); +extern SDL_bool has_music(Mix_MusicType type); +extern int open_music(const SDL_AudioSpec *spec); +extern int music_pcm_getaudio(void *context, void *data, int bytes, int volume, + int (*GetSome)(void *context, void *data, int bytes, SDL_bool *done)); +extern void SDLCALL music_mixer(void *udata, Uint8 *stream, int len); +extern void close_music(void); +extern void unload_music(void); + +extern char *music_cmd; +extern SDL_AudioSpec music_spec; + +#endif /* MUSIC_H_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_cmd.c b/music_cmd.c index 0989ac0..8c5900d 100644 --- a/music_cmd.c +++ b/music_cmd.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -22,7 +22,7 @@ /* This file supports an external command for playing music */ -#ifdef CMD_MUSIC +#ifdef MUSIC_CMD #include #include @@ -32,33 +32,44 @@ #include #include #include - -#include "SDL_mixer.h" +#include +#if defined(__linux__) && defined(__arm__) +# include +#endif + #include "music_cmd.h" -/* Unimplemented */ -void MusicCMD_SetVolume(int volume) -{ - Mix_SetError("No way to modify external player volume"); -} + +typedef struct { + char *file; + char *cmd; + pid_t pid; + int play_count; +} MusicCMD; + /* Load a music stream from the given file */ -MusicCMD *MusicCMD_LoadSong(const char *cmd, const char *file) +static void *MusicCMD_CreateFromFile(const char *file) { MusicCMD *music; + if (!music_cmd) { + Mix_SetError("You must call Mix_SetMusicCMD() first"); + return NULL; + } + /* Allocate and fill the music structure */ - music = (MusicCMD *)SDL_malloc(sizeof *music); - if ( music == NULL ) { + music = (MusicCMD *)SDL_calloc(1, sizeof *music); + if (music == NULL) { Mix_SetError("Out of memory"); - return(NULL); + return NULL; } music->file = SDL_strdup(file); - music->cmd = SDL_strdup(cmd); + music->cmd = SDL_strdup(music_cmd); music->pid = 0; /* We're done */ - return(music); + return music; } /* Parse a command line buffer into arguments */ @@ -68,44 +79,44 @@ int argc; argc = 0; - for ( bufp = cmdline; *bufp; ) { + for (bufp = cmdline; *bufp;) { /* Skip leading whitespace */ - while ( isspace(*bufp) ) { + while (isspace(*bufp)) { ++bufp; } /* Skip over argument */ - if ( *bufp == '"' ) { + if (*bufp == '"') { ++bufp; - if ( *bufp ) { - if ( argv ) { + if (*bufp) { + if (argv) { argv[argc] = bufp; } ++argc; } /* Skip over word */ - while ( *bufp && (*bufp != '"') ) { + while (*bufp && (*bufp != '"')) { ++bufp; } } else { - if ( *bufp ) { - if ( argv ) { + if (*bufp) { + if (argv) { argv[argc] = bufp; } ++argc; } /* Skip over word */ - while ( *bufp && ! isspace(*bufp) ) { + while (*bufp && ! isspace(*bufp)) { ++bufp; } } - if ( *bufp ) { - if ( argv ) { + if (*bufp) { + if (argv) { *bufp = '\0'; } ++bufp; } } - if ( argv ) { + if (argv) { argv[argc] = NULL; } return(argc); @@ -118,17 +129,17 @@ /* Parse the command line */ argc = ParseCommandLine(command, NULL); - if ( last_arg ) { + if (last_arg) { ++argc; } argv = (char **)SDL_malloc((argc+1)*(sizeof *argv)); - if ( argv == NULL ) { + if (argv == NULL) { return(NULL); } argc = ParseCommandLine(command, argv); /* Add last command line argument */ - if ( last_arg ) { + if (last_arg) { argv[argc++] = last_arg; } argv[argc] = NULL; @@ -138,59 +149,103 @@ } /* Start playback of a given music stream */ -void MusicCMD_Start(MusicCMD *music) -{ +static int MusicCMD_Play(void *context, int play_count) +{ + MusicCMD *music = (MusicCMD *)context; + + music->play_count = play_count; #ifdef HAVE_FORK music->pid = fork(); #else music->pid = vfork(); #endif switch(music->pid) { - /* Failed fork() system call */ - case -1: + /* Failed fork() system call */ + case -1: Mix_SetError("fork() failed"); - return; - - /* Child process - executes here */ - case 0: { - char *command; - char **argv; - - /* Unblock signals in case we're called from a thread */ - { + return -1; + + /* Child process - executes here */ + case 0: { + char **argv; + + /* Unblock signals in case we're called from a thread */ + { sigset_t mask; sigemptyset(&mask); sigprocmask(SIG_SETMASK, &mask, NULL); - } - - /* Execute the command */ - command = SDL_strdup(music->cmd); - argv = parse_args(command, music->file); - if ( argv != NULL ) { + } + + /* Execute the command */ + argv = parse_args(music->cmd, music->file); + if (argv != NULL) { execvp(argv[0], argv); - } - SDL_free(command); /* exec() failed */ perror(argv[0]); - _exit(-1); - } + } + _exit(-1); + } + break; + + /* Parent process - executes here */ + default: break; - - /* Parent process - executes here */ - default: - break; - } - return; + } + return 0; +} + +/* Return non-zero if a stream is currently playing */ +static SDL_bool MusicCMD_IsPlaying(void *context) +{ + MusicCMD *music = (MusicCMD *)context; + int status; + + if (music->pid > 0) { + waitpid(music->pid, &status, WNOHANG); + if (kill(music->pid, 0) == 0) { + return SDL_TRUE; + } + + /* We might want to loop */ + if (music->play_count != 1) { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + MusicCMD_Play(music, play_count); + return SDL_TRUE; + } + } + return SDL_FALSE; +} + +/* Pause playback of a given music stream */ +static void MusicCMD_Pause(void *context) +{ + MusicCMD *music = (MusicCMD *)context; + if (music->pid > 0) { + kill(music->pid, SIGSTOP); + } +} + +/* Resume playback of a given music stream */ +static void MusicCMD_Resume(void *context) +{ + MusicCMD *music = (MusicCMD *)context; + if (music->pid > 0) { + kill(music->pid, SIGCONT); + } } /* Stop playback of a stream previously started with MusicCMD_Start() */ -void MusicCMD_Stop(MusicCMD *music) -{ +static void MusicCMD_Stop(void *context) +{ + MusicCMD *music = (MusicCMD *)context; int status; - if ( music->pid > 0 ) { - while ( kill(music->pid, 0) == 0 ) { + if (music->pid > 0) { + while (kill(music->pid, 0) == 0) { kill(music->pid, SIGTERM); sleep(1); waitpid(music->pid, &status, WNOHANG); @@ -199,44 +254,39 @@ } } -/* Pause playback of a given music stream */ -void MusicCMD_Pause(MusicCMD *music) -{ - if ( music->pid > 0 ) { - kill(music->pid, SIGSTOP); - } -} - -/* Resume playback of a given music stream */ -void MusicCMD_Resume(MusicCMD *music) -{ - if ( music->pid > 0 ) { - kill(music->pid, SIGCONT); - } -} - /* Close the given music stream */ -void MusicCMD_FreeSong(MusicCMD *music) -{ +void MusicCMD_Delete(void *context) +{ + MusicCMD *music = (MusicCMD *)context; SDL_free(music->file); - SDL_free(music->cmd); SDL_free(music); } -/* Return non-zero if a stream is currently playing */ -int MusicCMD_Active(MusicCMD *music) -{ - int status; - int active; - - active = 0; - if ( music->pid > 0 ) { - waitpid(music->pid, &status, WNOHANG); - if ( kill(music->pid, 0) == 0 ) { - active = 1; - } - } - return(active); -} - -#endif /* CMD_MUSIC */ +Mix_MusicInterface Mix_MusicInterface_CMD = +{ + "CMD", + MIX_MUSIC_CMD, + MUS_CMD, + SDL_FALSE, + SDL_FALSE, + + NULL, /* Load */ + NULL, /* Open */ + NULL, /* CreateFromRW */ + MusicCMD_CreateFromFile, + NULL, /* SetVolume */ + MusicCMD_Play, + MusicCMD_IsPlaying, + NULL, /* GetAudio */ + NULL, /* Seek */ + MusicCMD_Pause, + MusicCMD_Resume, + MusicCMD_Stop, + MusicCMD_Delete, + NULL, /* Close */ + NULL, /* Unload */ +}; + +#endif /* MUSIC_CMD */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_cmd.h b/music_cmd.h index 976fd72..1104afb 100644 --- a/music_cmd.h +++ b/music_cmd.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -21,42 +21,8 @@ /* This file supports an external command for playing music */ -#ifdef CMD_MUSIC +#include "music.h" -#include -#include -#include -#if defined(__linux__) && defined(__arm__) -# include -#endif -typedef struct { - char *file; - char *cmd; - pid_t pid; -} MusicCMD; +extern Mix_MusicInterface Mix_MusicInterface_CMD; -/* Unimplemented */ -extern void MusicCMD_SetVolume(int volume); - -/* Load a music stream from the given file */ -extern MusicCMD *MusicCMD_LoadSong(const char *cmd, const char *file); - -/* Start playback of a given music stream */ -extern void MusicCMD_Start(MusicCMD *music); - -/* Stop playback of a stream previously started with MusicCMD_Start() */ -extern void MusicCMD_Stop(MusicCMD *music); - -/* Pause playback of a given music stream */ -extern void MusicCMD_Pause(MusicCMD *music); - -/* Resume playback of a given music stream */ -extern void MusicCMD_Resume(MusicCMD *music); - -/* Close the given music stream */ -extern void MusicCMD_FreeSong(MusicCMD *music); - -/* Return non-zero if a stream is currently playing */ -extern int MusicCMD_Active(MusicCMD *music); - -#endif /* CMD_MUSIC */ +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_flac.c b/music_flac.c index 4d56283..babba16 100644 --- a/music_flac.c +++ b/music_flac.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -22,33 +22,132 @@ ~ Austen Dicken (admin@cvpcs.org) */ -#ifdef FLAC_MUSIC - -#include -#include -#include - -#include "SDL_mixer.h" -#include "dynamic_flac.h" +#ifdef MUSIC_FLAC + +#include "SDL_assert.h" +#include "SDL_loadso.h" + #include "music_flac.h" -/* This is the format of the audio mixer data */ -static SDL_AudioSpec mixer; - -/* Initialize the FLAC player, with the given mixer settings - This function returns 0, or -1 if there was an error. - */ -int FLAC_init(SDL_AudioSpec *mixerfmt) -{ - mixer = *mixerfmt; - return(0); -} - -/* Set the volume for an FLAC stream */ -void FLAC_setvolume(FLAC_music *music, int volume) -{ - music->volume = volume; -} +#include + + +typedef struct { + int loaded; + void *handle; + FLAC__StreamDecoder *(*FLAC__stream_decoder_new)(void); + void (*FLAC__stream_decoder_delete)(FLAC__StreamDecoder *decoder); + FLAC__StreamDecoderInitStatus (*FLAC__stream_decoder_init_stream)( + FLAC__StreamDecoder *decoder, + FLAC__StreamDecoderReadCallback read_callback, + FLAC__StreamDecoderSeekCallback seek_callback, + FLAC__StreamDecoderTellCallback tell_callback, + FLAC__StreamDecoderLengthCallback length_callback, + FLAC__StreamDecoderEofCallback eof_callback, + FLAC__StreamDecoderWriteCallback write_callback, + FLAC__StreamDecoderMetadataCallback metadata_callback, + FLAC__StreamDecoderErrorCallback error_callback, + void *client_data); + FLAC__bool (*FLAC__stream_decoder_finish)(FLAC__StreamDecoder *decoder); + FLAC__bool (*FLAC__stream_decoder_flush)(FLAC__StreamDecoder *decoder); + FLAC__bool (*FLAC__stream_decoder_process_single)( + FLAC__StreamDecoder *decoder); + FLAC__bool (*FLAC__stream_decoder_process_until_end_of_metadata)( + FLAC__StreamDecoder *decoder); + FLAC__bool (*FLAC__stream_decoder_process_until_end_of_stream)( + FLAC__StreamDecoder *decoder); + FLAC__bool (*FLAC__stream_decoder_seek_absolute)( + FLAC__StreamDecoder *decoder, + FLAC__uint64 sample); + FLAC__StreamDecoderState (*FLAC__stream_decoder_get_state)( + const FLAC__StreamDecoder *decoder); +} flac_loader; + +static flac_loader flac = { + 0, NULL +}; + +#ifdef FLAC_DYNAMIC +#define FUNCTION_LOADER(FUNC, SIG) \ + flac.FUNC = (SIG) SDL_LoadFunction(flac.handle, #FUNC); \ + if (flac.FUNC == NULL) { SDL_UnloadObject(flac.handle); return -1; } +#else +#define FUNCTION_LOADER(FUNC, SIG) \ + flac.FUNC = FUNC; +#endif + +static int FLAC_Load(void) +{ + if (flac.loaded == 0) { +#ifdef FLAC_DYNAMIC + flac.handle = SDL_LoadObject(FLAC_DYNAMIC); + if (flac.handle == NULL) { + return -1; + } +#elif defined(__MACOSX__) + extern FLAC__StreamDecoder *FLAC__stream_decoder_new(void) __attribute__((weak_import)); + if (FLAC__stream_decoder_new == NULL) + { + /* Missing weakly linked framework */ + Mix_SetError("Missing FLAC.framework"); + return -1; + } +#endif + + FUNCTION_LOADER(FLAC__stream_decoder_new, FLAC__StreamDecoder *(*)(void)) + FUNCTION_LOADER(FLAC__stream_decoder_delete, void (*)(FLAC__StreamDecoder *)) + FUNCTION_LOADER(FLAC__stream_decoder_init_stream, FLAC__StreamDecoderInitStatus (*)( + FLAC__StreamDecoder *, + FLAC__StreamDecoderReadCallback, + FLAC__StreamDecoderSeekCallback, + FLAC__StreamDecoderTellCallback, + FLAC__StreamDecoderLengthCallback, + FLAC__StreamDecoderEofCallback, + FLAC__StreamDecoderWriteCallback, + FLAC__StreamDecoderMetadataCallback, + FLAC__StreamDecoderErrorCallback, + void *)) + FUNCTION_LOADER(FLAC__stream_decoder_finish, FLAC__bool (*)(FLAC__StreamDecoder *)) + FUNCTION_LOADER(FLAC__stream_decoder_flush, FLAC__bool (*)(FLAC__StreamDecoder *)) + FUNCTION_LOADER(FLAC__stream_decoder_process_single, FLAC__bool (*)(FLAC__StreamDecoder *)) + FUNCTION_LOADER(FLAC__stream_decoder_process_until_end_of_metadata, FLAC__bool (*)(FLAC__StreamDecoder *)) + FUNCTION_LOADER(FLAC__stream_decoder_process_until_end_of_stream, FLAC__bool (*)(FLAC__StreamDecoder *)) + FUNCTION_LOADER(FLAC__stream_decoder_seek_absolute, FLAC__bool (*)(FLAC__StreamDecoder *, FLAC__uint64)) + FUNCTION_LOADER(FLAC__stream_decoder_get_state, FLAC__StreamDecoderState (*)(const FLAC__StreamDecoder *decoder)) + } + ++flac.loaded; + + return 0; +} + +static void FLAC_Unload(void) +{ + if (flac.loaded == 0) { + return; + } + if (flac.loaded == 1) { +#ifdef FLAC_DYNAMIC + SDL_UnloadObject(flac.handle); +#endif + } + --flac.loaded; +} + + +typedef struct { + int volume; + int play_count; + FLAC__StreamDecoder *flac_decoder; + unsigned sample_rate; + unsigned channels; + unsigned bits_per_sample; + SDL_RWops *src; + int freesrc; + SDL_AudioStream *stream; +} FLAC_Music; + + +static int FLAC_Seek(void *context, double position); static FLAC__StreamDecoderReadStatus flac_read_music_cb( const FLAC__StreamDecoder *decoder, @@ -56,15 +155,15 @@ size_t *bytes, void *client_data) { - FLAC_music *data = (FLAC_music*)client_data; - - // make sure there is something to be reading + FLAC_Music *data = (FLAC_Music*)client_data; + + /* make sure there is something to be reading */ if (*bytes > 0) { *bytes = SDL_RWread (data->src, buffer, sizeof (FLAC__byte), *bytes); - if (*bytes == 0 ) { // error or no data was read (EOF) + if (*bytes == 0) { /* error or no data was read (EOF) */ return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; - } else { // data was read, continue + } else { /* data was read, continue */ return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; } } else { @@ -77,9 +176,9 @@ FLAC__uint64 absolute_byte_offset, void *client_data) { - FLAC_music *data = (FLAC_music*)client_data; - - if (SDL_RWseek (data->src, absolute_byte_offset, RW_SEEK_SET) < 0) { + FLAC_Music *data = (FLAC_Music*)client_data; + + if (SDL_RWseek(data->src, absolute_byte_offset, RW_SEEK_SET) < 0) { return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; } else { return FLAC__STREAM_DECODER_SEEK_STATUS_OK; @@ -89,11 +188,11 @@ static FLAC__StreamDecoderTellStatus flac_tell_music_cb( const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, - void *client_data ) -{ - FLAC_music *data = (FLAC_music*)client_data; - - Sint64 pos = SDL_RWtell (data->src); + void *client_data) +{ + FLAC_Music *data = (FLAC_Music*)client_data; + + Sint64 pos = SDL_RWtell(data->src); if (pos < 0) { return FLAC__STREAM_DECODER_TELL_STATUS_ERROR; @@ -103,17 +202,17 @@ } } -static FLAC__StreamDecoderLengthStatus flac_length_music_cb ( +static FLAC__StreamDecoderLengthStatus flac_length_music_cb( const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) { - FLAC_music *data = (FLAC_music*)client_data; - - Sint64 pos = SDL_RWtell (data->src); - Sint64 length = SDL_RWseek (data->src, 0, RW_SEEK_END); - - if (SDL_RWseek (data->src, pos, RW_SEEK_SET) != pos || length < 0) { + FLAC_Music *data = (FLAC_Music*)client_data; + + Sint64 pos = SDL_RWtell(data->src); + Sint64 length = SDL_RWseek(data->src, 0, RW_SEEK_END); + + if (SDL_RWseek(data->src, pos, RW_SEEK_SET) != pos || length < 0) { /* there was an error attempting to return the stream to the original * position, or the length was invalid. */ return FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR; @@ -125,20 +224,20 @@ static FLAC__bool flac_eof_music_cb( const FLAC__StreamDecoder *decoder, - void *client_data ) -{ - FLAC_music *data = (FLAC_music*)client_data; - - Sint64 pos = SDL_RWtell (data->src); - Sint64 end = SDL_RWseek (data->src, 0, RW_SEEK_END); - - // was the original position equal to the end (a.k.a. the seek didn't move)? + void *client_data) +{ + FLAC_Music *data = (FLAC_Music*)client_data; + + Sint64 pos = SDL_RWtell(data->src); + Sint64 end = SDL_RWseek(data->src, 0, RW_SEEK_END); + + /* was the original position equal to the end (a.k.a. the seek didn't move)? */ if (pos == end) { - // must be EOF + /* must be EOF */ return true; } else { - // not EOF, return to the original position - SDL_RWseek (data->src, pos, RW_SEEK_SET); + /* not EOF, return to the original position */ + SDL_RWseek(data->src, pos, RW_SEEK_SET); return false; } } @@ -149,98 +248,81 @@ const FLAC__int32 *const buffer[], void *client_data) { - FLAC_music *data = (FLAC_music *)client_data; - size_t i; - - if (data->flac_data.total_samples == 0) { - SDL_SetError ("Given FLAC file does not specify its sample count."); + FLAC_Music *music = (FLAC_Music *)client_data; + Sint16 *data; + unsigned int i, j, channels; + int shift_amount = 0; + + if (!music->stream) { return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; } - if (data->flac_data.channels != 2 || - data->flac_data.bits_per_sample != 16) { - SDL_SetError("Current FLAC support is only for 16 bit Stereo files."); + switch (music->bits_per_sample) { + case 16: + shift_amount = 0; + break; + case 20: + shift_amount = 4; + break; + case 24: + shift_amount = 8; + break; + default: + SDL_SetError("FLAC decoder doesn't support %d bits_per_sample", music->bits_per_sample); return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; } - for (i = 0; i < frame->header.blocksize; i++) { - FLAC__int16 i16; - FLAC__uint16 ui16; - - // make sure we still have at least two bytes that can be read (one for - // each channel) - if (data->flac_data.max_to_read >= 4) { - // does the data block exist? - if (!data->flac_data.data) { - data->flac_data.data_len = data->flac_data.max_to_read; - data->flac_data.data_read = 0; - - // create it - data->flac_data.data = - (char *)SDL_malloc (data->flac_data.data_len); - - if (!data->flac_data.data) { - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } + if (music->channels == 3) { + /* We'll just drop the center channel for now */ + channels = 2; + } else { + channels = music->channels; + } + + data = SDL_stack_alloc(Sint16, (frame->header.blocksize * channels)); + if (!data) { + SDL_SetError("Couldn't allocate %d bytes stack memory", (int)(frame->header.blocksize * channels * sizeof(*data))); + return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; + } + if (music->channels == 3) { + Sint16 *dst = data; + for (i = 0; i < frame->header.blocksize; ++i) { + Sint16 FL = (buffer[0][i] >> shift_amount); + Sint16 FR = (buffer[1][i] >> shift_amount); + Sint16 FCmix = (Sint16)((buffer[2][i] >> shift_amount) * 0.5f); + int sample; + + sample = (FL + FCmix); + if (sample > SDL_MAX_SINT16) { + *dst = SDL_MAX_SINT16; + } else if (sample < SDL_MIN_SINT16) { + *dst = SDL_MIN_SINT16; + } else { + *dst = sample; } - - i16 = (FLAC__int16)buffer[0][i]; - ui16 = (FLAC__uint16)i16; - - *((data->flac_data.data) + (data->flac_data.data_read++)) = - (char)(ui16); - *((data->flac_data.data) + (data->flac_data.data_read++)) = - (char)(ui16 >> 8); - - i16 = (FLAC__int16)buffer[1][i]; - ui16 = (FLAC__uint16)i16; - - *((data->flac_data.data) + (data->flac_data.data_read++)) = - (char)(ui16); - *((data->flac_data.data) + (data->flac_data.data_read++)) = - (char)(ui16 >> 8); - - data->flac_data.max_to_read -= 4; - - if (data->flac_data.max_to_read < 4) { - // we need to set this so that the read halts from the - // FLAC_getsome function. - data->flac_data.max_to_read = 0; + ++dst; + + sample = (FR + FCmix); + if (sample > SDL_MAX_SINT16) { + *dst = SDL_MAX_SINT16; + } else if (sample < SDL_MIN_SINT16) { + *dst = SDL_MIN_SINT16; + } else { + *dst = sample; } - } - else { - // we need to write to the overflow - if (!data->flac_data.overflow) { - data->flac_data.overflow_len = - 4 * (frame->header.blocksize - i); - data->flac_data.overflow_read = 0; - - // make it big enough for the rest of the block - data->flac_data.overflow = - (char *)SDL_malloc (data->flac_data.overflow_len); - - if (!data->flac_data.overflow) { - return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; - } + ++dst; + } + } else { + for (i = 0; i < channels; ++i) { + Sint16 *dst = data + i; + for (j = 0; j < frame->header.blocksize; ++j) { + *dst = (buffer[i][j] >> shift_amount); + dst += channels; } - - i16 = (FLAC__int16)buffer[0][i]; - ui16 = (FLAC__uint16)i16; - - *((data->flac_data.overflow) + (data->flac_data.overflow_read++)) = - (char)(ui16); - *((data->flac_data.overflow) + (data->flac_data.overflow_read++)) = - (char)(ui16 >> 8); - - i16 = (FLAC__int16)buffer[1][i]; - ui16 = (FLAC__uint16)i16; - - *((data->flac_data.overflow) + (data->flac_data.overflow_read++)) = - (char)(ui16); - *((data->flac_data.overflow) + (data->flac_data.overflow_read++)) = - (char)(ui16 >> 8); - } - } + } + } + SDL_AudioStreamPut(music->stream, data, (frame->header.blocksize * channels * sizeof(*data))); + SDL_stack_free(data); return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; } @@ -250,18 +332,30 @@ const FLAC__StreamMetadata *metadata, void *client_data) { - FLAC_music *data = (FLAC_music *)client_data; - - if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { - data->flac_data.sample_rate = metadata->data.stream_info.sample_rate; - data->flac_data.channels = metadata->data.stream_info.channels; - data->flac_data.total_samples = - metadata->data.stream_info.total_samples; - data->flac_data.bits_per_sample = - metadata->data.stream_info.bits_per_sample; - data->flac_data.sample_size = data->flac_data.channels * - ((data->flac_data.bits_per_sample) / 8); - } + FLAC_Music *music = (FLAC_Music *)client_data; + int channels; + + if (metadata->type != FLAC__METADATA_TYPE_STREAMINFO) { + return; + } + + music->sample_rate = metadata->data.stream_info.sample_rate; + music->channels = metadata->data.stream_info.channels; + music->bits_per_sample = metadata->data.stream_info.bits_per_sample; +/*printf("FLAC: Sample rate = %d, channels = %d, bits_per_sample = %d\n", music->sample_rate, music->channels, music->bits_per_sample);*/ + + /* SDL's channel mapping and FLAC channel mapping are the same, + except for 3 channels: SDL is FL FR LFE and FLAC is FL FR FC + */ + if (music->channels == 3) { + channels = 2; + } else { + channels = music->channels; + } + /* We check for NULL stream later when we get data */ + SDL_assert(!music->stream); + music->stream = SDL_NewAudioStream(AUDIO_S16SYS, channels, music->sample_rate, + music_spec.format, music_spec.channels, music_spec.freq); } static void flac_error_music_cb( @@ -269,308 +363,205 @@ FLAC__StreamDecoderErrorStatus status, void *client_data) { - // print an SDL error based on the error status + /* print an SDL error based on the error status */ switch (status) { - case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC: - SDL_SetError ("Error processing the FLAC file [LOST_SYNC]."); - break; - case FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER: - SDL_SetError ("Error processing the FLAC file [BAD_HEADER]."); - break; - case FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH: - SDL_SetError ("Error processing the FLAC file [CRC_MISMATCH]."); - break; - case FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM: - SDL_SetError ("Error processing the FLAC file [UNPARSEABLE]."); - break; - default: - SDL_SetError ("Error processing the FLAC file [UNKNOWN]."); + case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC: + SDL_SetError("Error processing the FLAC file [LOST_SYNC]."); + break; + case FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER: + SDL_SetError("Error processing the FLAC file [BAD_HEADER]."); + break; + case FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH: + SDL_SetError("Error processing the FLAC file [CRC_MISMATCH]."); + break; + case FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM: + SDL_SetError("Error processing the FLAC file [UNPARSEABLE]."); + break; + default: + SDL_SetError("Error processing the FLAC file [UNKNOWN]."); break; } } /* Load an FLAC stream from an SDL_RWops object */ -FLAC_music *FLAC_new_RW(SDL_RWops *src, int freesrc) -{ - FLAC_music *music; +static void *FLAC_CreateFromRW(SDL_RWops *src, int freesrc) +{ + FLAC_Music *music; int init_stage = 0; int was_error = 1; - if (!Mix_Init(MIX_INIT_FLAC)) { + music = (FLAC_Music *)SDL_calloc(1, sizeof(*music)); + if (!music) { + SDL_OutOfMemory(); return NULL; } - - music = (FLAC_music *)SDL_malloc ( sizeof (*music)); - if (music) { - /* Initialize the music structure */ - memset (music, 0, (sizeof (*music))); - FLAC_stop (music); - FLAC_setvolume (music, MIX_MAX_VOLUME); - music->section = -1; - music->src = src; - music->freesrc = freesrc; - music->flac_data.max_to_read = 0; - music->flac_data.overflow = NULL; - music->flac_data.overflow_len = 0; - music->flac_data.overflow_read = 0; - music->flac_data.data = NULL; - music->flac_data.data_len = 0; - music->flac_data.data_read = 0; - - init_stage++; // stage 1! - - music->flac_decoder = flac.FLAC__stream_decoder_new (); - - if (music->flac_decoder != NULL) { - init_stage++; // stage 2! - - if (flac.FLAC__stream_decoder_init_stream( - music->flac_decoder, - flac_read_music_cb, flac_seek_music_cb, - flac_tell_music_cb, flac_length_music_cb, - flac_eof_music_cb, flac_write_music_cb, - flac_metadata_music_cb, flac_error_music_cb, - music) == FLAC__STREAM_DECODER_INIT_STATUS_OK ) { - init_stage++; // stage 3! - - if (flac.FLAC__stream_decoder_process_until_end_of_metadata - (music->flac_decoder)) { - was_error = 0; - } else { - SDL_SetError("FLAC__stream_decoder_process_until_end_of_metadata() failed"); - } + music->src = src; + music->volume = MIX_MAX_VOLUME; + + music->flac_decoder = flac.FLAC__stream_decoder_new(); + if (music->flac_decoder) { + init_stage++; /* stage 1! */ + + if (flac.FLAC__stream_decoder_init_stream( + music->flac_decoder, + flac_read_music_cb, flac_seek_music_cb, + flac_tell_music_cb, flac_length_music_cb, + flac_eof_music_cb, flac_write_music_cb, + flac_metadata_music_cb, flac_error_music_cb, + music) == FLAC__STREAM_DECODER_INIT_STATUS_OK) { + init_stage++; /* stage 2! */ + + if (flac.FLAC__stream_decoder_process_until_end_of_metadata(music->flac_decoder)) { + was_error = 0; } else { - SDL_SetError("FLAC__stream_decoder_init_stream() failed"); + SDL_SetError("FLAC__stream_decoder_process_until_end_of_metadata() failed"); } } else { - SDL_SetError("FLAC__stream_decoder_new() failed"); - } - - if (was_error) { - switch (init_stage) { - case 3: - flac.FLAC__stream_decoder_finish( music->flac_decoder ); - case 2: - flac.FLAC__stream_decoder_delete( music->flac_decoder ); - case 1: - case 0: - SDL_free(music); - break; + SDL_SetError("FLAC__stream_decoder_init_stream() failed"); + } + } else { + SDL_SetError("FLAC__stream_decoder_new() failed"); + } + + if (was_error) { + switch (init_stage) { + case 2: + flac.FLAC__stream_decoder_finish(music->flac_decoder); + case 1: + flac.FLAC__stream_decoder_delete(music->flac_decoder); + case 0: + SDL_free(music); + break; + } + return NULL; + } + + music->freesrc = freesrc; + return music; +} + +/* Set the volume for an FLAC stream */ +static void FLAC_SetVolume(void *context, int volume) +{ + FLAC_Music *music = (FLAC_Music *)context; + music->volume = volume; +} + +/* Start playback of a given FLAC stream */ +static int FLAC_Play(void *context, int play_count) +{ + FLAC_Music *music = (FLAC_Music *)context; + music->play_count = play_count; + return FLAC_Seek(music, 0.0); +} + +/* Read some FLAC stream data and convert it for output */ +static int FLAC_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + FLAC_Music *music = (FLAC_Music *)context; + int filled; + + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + if (!flac.FLAC__stream_decoder_process_single(music->flac_decoder)) { + SDL_SetError("FLAC__stream_decoder_process_single() failed"); + return -1; + } + + if (flac.FLAC__stream_decoder_get_state(music->flac_decoder) == FLAC__STREAM_DECODER_END_OF_STREAM) { + if (music->play_count == 1) { + music->play_count = 0; + SDL_AudioStreamFlush(music->stream); + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); } - return NULL; - } - } else { - SDL_OutOfMemory(); - return NULL; - } - - return music; -} - -/* Start playback of a given FLAC stream */ -void FLAC_play(FLAC_music *music) -{ - music->playing = 1; -} - -/* Return non-zero if a stream is currently playing */ -int FLAC_playing(FLAC_music *music) -{ - return(music->playing); -} - -/* Read some FLAC stream data and convert it for output */ -static void FLAC_getsome(FLAC_music *music) -{ - SDL_AudioCVT *cvt; - - /* GET AUDIO WAVE DATA */ - // set the max number of characters to read - music->flac_data.max_to_read = 8192; - music->flac_data.data_len = music->flac_data.max_to_read; - music->flac_data.data_read = 0; - if (!music->flac_data.data) { - music->flac_data.data = (char *)SDL_malloc (music->flac_data.data_len); - } - - // we have data to read - while(music->flac_data.max_to_read > 0) { - // first check if there is data in the overflow from before - if (music->flac_data.overflow) { - size_t overflow_len = music->flac_data.overflow_read; - - if (overflow_len > (size_t)music->flac_data.max_to_read) { - size_t overflow_extra_len = overflow_len - - music->flac_data.max_to_read; - - SDL_memcpy (music->flac_data.data+music->flac_data.data_read, - music->flac_data.overflow, music->flac_data.max_to_read); - music->flac_data.data_read += music->flac_data.max_to_read; - SDL_memcpy (music->flac_data.overflow, - music->flac_data.overflow + music->flac_data.max_to_read, - overflow_extra_len); - music->flac_data.overflow_len = overflow_extra_len; - music->flac_data.overflow_read = overflow_extra_len; - music->flac_data.max_to_read = 0; - } else { - SDL_memcpy (music->flac_data.data+music->flac_data.data_read, - music->flac_data.overflow, overflow_len); - music->flac_data.data_read += overflow_len; - SDL_free (music->flac_data.overflow); - music->flac_data.overflow = NULL; - music->flac_data.overflow_len = 0; - music->flac_data.overflow_read = 0; - music->flac_data.max_to_read -= overflow_len; + if (FLAC_Play(music, play_count) < 0) { + return -1; } } - else { - if (!flac.FLAC__stream_decoder_process_single ( - music->flac_decoder)) { - music->flac_data.max_to_read = 0; - } - - if (flac.FLAC__stream_decoder_get_state (music->flac_decoder) - == FLAC__STREAM_DECODER_END_OF_STREAM) { - music->flac_data.max_to_read = 0; - } - } - } - - if (music->flac_data.data_read <= 0) { - if (music->flac_data.data_read == 0) { - music->playing = 0; - } - return; - } - cvt = &music->cvt; - if (music->section < 0) { - SDL_BuildAudioCVT (cvt, AUDIO_S16, (Uint8)music->flac_data.channels, - (int)music->flac_data.sample_rate, mixer.format, - mixer.channels, mixer.freq); - if (cvt->buf) { - SDL_free (cvt->buf); - } - cvt->buf = (Uint8 *)SDL_malloc (music->flac_data.data_len * cvt->len_mult); - music->section = 0; - } - if (cvt->buf) { - SDL_memcpy (cvt->buf, music->flac_data.data, music->flac_data.data_read); - if (cvt->needed) { - cvt->len = music->flac_data.data_read; - SDL_ConvertAudio (cvt); - } - else { - cvt->len_cvt = music->flac_data.data_read; - } - music->len_available = music->cvt.len_cvt; - music->snd_available = music->cvt.buf; - } - else { - SDL_SetError ("Out of memory"); - music->playing = 0; - } + } + return 0; } /* Play some of a stream previously started with FLAC_play() */ -int FLAC_playAudio(FLAC_music *music, Uint8 *snd, int len) -{ - int mixable; - - while ((len > 0) && music->playing) { - if (!music->len_available) { - FLAC_getsome (music); - } - mixable = len; - if (mixable > music->len_available) { - mixable = music->len_available; - } - if (music->volume == MIX_MAX_VOLUME) { - SDL_memcpy (snd, music->snd_available, mixable); - } - else { - SDL_MixAudio (snd, music->snd_available, mixable, music->volume); - } - music->len_available -= mixable; - music->snd_available += mixable; - len -= mixable; - snd += mixable; - } - - return len; -} - -/* Stop playback of a stream previously started with FLAC_play() */ -void FLAC_stop(FLAC_music *music) -{ - music->playing = 0; -} - -/* Close the given FLAC_music object */ -void FLAC_delete(FLAC_music *music) -{ +static int FLAC_GetAudio(void *context, void *data, int bytes) +{ + FLAC_Music *music = (FLAC_Music *)context; + return music_pcm_getaudio(context, data, bytes, music->volume, FLAC_GetSome); +} + +/* Jump (seek) to a given position (position is in seconds) */ +static int FLAC_Seek(void *context, double position) +{ + FLAC_Music *music = (FLAC_Music *)context; + double seek_sample = music->sample_rate * position; + + if (!flac.FLAC__stream_decoder_seek_absolute(music->flac_decoder, (FLAC__uint64)seek_sample)) { + if (flac.FLAC__stream_decoder_get_state(music->flac_decoder) == FLAC__STREAM_DECODER_SEEK_ERROR) { + flac.FLAC__stream_decoder_flush(music->flac_decoder); + } + + SDL_SetError("Seeking of FLAC stream failed: libFLAC seek failed."); + return -1; + } + return 0; +} + +/* Close the given FLAC_Music object */ +static void FLAC_Delete(void *context) +{ + FLAC_Music *music = (FLAC_Music *)context; if (music) { if (music->flac_decoder) { - flac.FLAC__stream_decoder_finish (music->flac_decoder); - flac.FLAC__stream_decoder_delete (music->flac_decoder); - } - - if (music->flac_data.data) { - SDL_free (music->flac_data.data); - } - - if (music->flac_data.overflow) { - SDL_free (music->flac_data.overflow); - } - - if (music->cvt.buf) { - SDL_free (music->cvt.buf); - } - + flac.FLAC__stream_decoder_finish(music->flac_decoder); + flac.FLAC__stream_decoder_delete(music->flac_decoder); + } + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } if (music->freesrc) { SDL_RWclose(music->src); } - SDL_free (music); - } -} - -/* Jump (seek) to a given position (time is in seconds) */ -void FLAC_jump_to_time(FLAC_music *music, double time) -{ - if (music) { - if (music->flac_decoder) { - double seek_sample = music->flac_data.sample_rate * time; - - // clear data if it has data - if (music->flac_data.data) { - SDL_free (music->flac_data.data); - music->flac_data.data = NULL; - } - - // clear overflow if it has data - if (music->flac_data.overflow) { - SDL_free (music->flac_data.overflow); - music->flac_data.overflow = NULL; - } - - if (!flac.FLAC__stream_decoder_seek_absolute (music->flac_decoder, - (FLAC__uint64)seek_sample)) { - if (flac.FLAC__stream_decoder_get_state (music->flac_decoder) - == FLAC__STREAM_DECODER_SEEK_ERROR) { - flac.FLAC__stream_decoder_flush (music->flac_decoder); - } - - SDL_SetError - ("Seeking of FLAC stream failed: libFLAC seek failed."); - } - } - else { - SDL_SetError - ("Seeking of FLAC stream failed: FLAC decoder was NULL."); - } - } - else { - SDL_SetError ("Seeking of FLAC stream failed: music was NULL."); - } -} - -#endif /* FLAC_MUSIC */ + SDL_free(music); + } +} + +Mix_MusicInterface Mix_MusicInterface_FLAC = +{ + "FLAC", + MIX_MUSIC_FLAC, + MUS_FLAC, + SDL_FALSE, + SDL_FALSE, + + FLAC_Load, + NULL, /* Open */ + FLAC_CreateFromRW, + NULL, /* CreateFromFile */ + FLAC_SetVolume, + FLAC_Play, + NULL, /* IsPlaying */ + FLAC_GetAudio, + FLAC_Seek, + NULL, /* Pause */ + NULL, /* Resume */ + NULL, /* Stop */ + FLAC_Delete, + NULL, /* Close */ + FLAC_Unload, +}; + +#endif /* MUSIC_FLAC */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_flac.h b/music_flac.h index 5c877ec..2d8224c 100644 --- a/music_flac.h +++ b/music_flac.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -17,74 +17,10 @@ 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. - - Header to handle loading FLAC music files in SDL. - ~ Austen Dicken (admin@cvpcs.org) */ -/* $Id: $ */ +#include "music.h" -#ifdef FLAC_MUSIC +extern Mix_MusicInterface Mix_MusicInterface_FLAC; -#include - -typedef struct { - FLAC__uint64 sample_size; - unsigned sample_rate; - unsigned channels; - unsigned bits_per_sample; - FLAC__uint64 total_samples; - - // the following are used to handle the callback nature of the writer - int max_to_read; - char *data; // pointer to beginning of data array - int data_len; // size of data array - int data_read; // amount of data array used - char *overflow; // pointer to beginning of overflow array - int overflow_len; // size of overflow array - int overflow_read; // amount of overflow array used -} FLAC_Data; - -typedef struct { - int playing; - int volume; - int section; - FLAC__StreamDecoder *flac_decoder; - FLAC_Data flac_data; - SDL_RWops *src; - int freesrc; - SDL_AudioCVT cvt; - int len_available; - Uint8 *snd_available; -} FLAC_music; - -/* Initialize the FLAC player, with the given mixer settings - This function returns 0, or -1 if there was an error. - */ -extern int FLAC_init(SDL_AudioSpec *mixer); - -/* Set the volume for a FLAC stream */ -extern void FLAC_setvolume(FLAC_music *music, int volume); - -/* Load an FLAC stream from an SDL_RWops object */ -extern FLAC_music *FLAC_new_RW(SDL_RWops *src, int freesrc); - -/* Start playback of a given FLAC stream */ -extern void FLAC_play(FLAC_music *music); - -/* Return non-zero if a stream is currently playing */ -extern int FLAC_playing(FLAC_music *music); - -/* Play some of a stream previously started with FLAC_play() */ -extern int FLAC_playAudio(FLAC_music *music, Uint8 *stream, int len); - -/* Stop playback of a stream previously started with FLAC_play() */ -extern void FLAC_stop(FLAC_music *music); - -/* Close the given FLAC stream */ -extern void FLAC_delete(FLAC_music *music); - -/* Jump (seek) to a given position (time is in seconds) */ -extern void FLAC_jump_to_time(FLAC_music *music, double time); - -#endif /* FLAC_MUSIC */ +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_fluidsynth.c b/music_fluidsynth.c new file mode 100644 index 0000000..c1e79ff --- /dev/null +++ b/music_fluidsynth.c @@ -0,0 +1,309 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + James Le Cuirot + chewi@aura-online.co.uk +*/ + +#ifdef MUSIC_MID_FLUIDSYNTH + +#include + +#include "SDL_loadso.h" + +#include "music_fluidsynth.h" + +#include + + +typedef struct { + int loaded; + void *handle; + + int (*delete_fluid_player)(fluid_player_t*); + void (*delete_fluid_settings)(fluid_settings_t*); + int (*delete_fluid_synth)(fluid_synth_t*); + int (*fluid_player_add)(fluid_player_t*, const char*); + int (*fluid_player_add_mem)(fluid_player_t*, const void*, size_t); + int (*fluid_player_get_status)(fluid_player_t*); + int (*fluid_player_play)(fluid_player_t*); + int (*fluid_player_set_loop)(fluid_player_t*, int); + int (*fluid_player_stop)(fluid_player_t*); + int (*fluid_settings_setnum)(fluid_settings_t*, const char*, double); + fluid_settings_t* (*fluid_synth_get_settings)(fluid_synth_t*); + void (*fluid_synth_set_gain)(fluid_synth_t*, float); + int (*fluid_synth_sfload)(fluid_synth_t*, const char*, int); + int (*fluid_synth_write_s16)(fluid_synth_t*, int, void*, int, int, void*, int, int); + fluid_player_t* (*new_fluid_player)(fluid_synth_t*); + fluid_settings_t* (*new_fluid_settings)(void); + fluid_synth_t* (*new_fluid_synth)(fluid_settings_t*); +} fluidsynth_loader; + +static fluidsynth_loader fluidsynth = { + 0, NULL +}; + +#ifdef FLUIDSYNTH_DYNAMIC +#define FUNCTION_LOADER(FUNC, SIG) \ + fluidsynth.FUNC = (SIG) SDL_LoadFunction(fluidsynth.handle, #FUNC); \ + if (fluidsynth.FUNC == NULL) { SDL_UnloadObject(fluidsynth.handle); return -1; } +#else +#define FUNCTION_LOADER(FUNC, SIG) \ + fluidsynth.FUNC = FUNC; +#endif + +static int FLUIDSYNTH_Load() +{ + if (fluidsynth.loaded == 0) { +#ifdef FLUIDSYNTH_DYNAMIC + fluidsynth.handle = SDL_LoadObject(FLUIDSYNTH_DYNAMIC); + if (fluidsynth.handle == NULL) { + return -1; + } +#endif + FUNCTION_LOADER(delete_fluid_player, int (*)(fluid_player_t*)) + FUNCTION_LOADER(delete_fluid_settings, void (*)(fluid_settings_t*)) + FUNCTION_LOADER(delete_fluid_synth, int (*)(fluid_synth_t*)) + FUNCTION_LOADER(fluid_player_add, int (*)(fluid_player_t*, const char*)) + FUNCTION_LOADER(fluid_player_add_mem, int (*)(fluid_player_t*, const void*, size_t)) + FUNCTION_LOADER(fluid_player_get_status, int (*)(fluid_player_t*)) + FUNCTION_LOADER(fluid_player_play, int (*)(fluid_player_t*)) + FUNCTION_LOADER(fluid_player_set_loop, int (*)(fluid_player_t*, int)) + FUNCTION_LOADER(fluid_player_stop, int (*)(fluid_player_t*)) + FUNCTION_LOADER(fluid_settings_setnum, int (*)(fluid_settings_t*, const char*, double)) + FUNCTION_LOADER(fluid_synth_get_settings, fluid_settings_t* (*)(fluid_synth_t*)) + FUNCTION_LOADER(fluid_synth_set_gain, void (*)(fluid_synth_t*, float)) + FUNCTION_LOADER(fluid_synth_sfload, int(*)(fluid_synth_t*, const char*, int)) + FUNCTION_LOADER(fluid_synth_write_s16, int(*)(fluid_synth_t*, int, void*, int, int, void*, int, int)) + FUNCTION_LOADER(new_fluid_player, fluid_player_t* (*)(fluid_synth_t*)) + FUNCTION_LOADER(new_fluid_settings, fluid_settings_t* (*)(void)) + FUNCTION_LOADER(new_fluid_synth, fluid_synth_t* (*)(fluid_settings_t*)) + } + ++fluidsynth.loaded; + + return 0; +} + +static void FLUIDSYNTH_Unload() +{ + if (fluidsynth.loaded == 0) { + return; + } + if (fluidsynth.loaded == 1) { +#ifdef FLUIDSYNTH_DYNAMIC + SDL_UnloadObject(fluidsynth.handle); +#endif + } + --fluidsynth.loaded; +} + + +typedef struct { + fluid_synth_t *synth; + fluid_player_t *player; + SDL_AudioStream *stream; + void *buffer; + int buffer_size; +} FLUIDSYNTH_Music; + + +static int SDLCALL fluidsynth_check_soundfont(const char *path, void *data) +{ + FILE *file = fopen(path, "r"); + + if (file) { + fclose(file); + return 1; + } else { + Mix_SetError("Failed to access the SoundFont %s", path); + return 0; + } +} + +static int SDLCALL fluidsynth_load_soundfont(const char *path, void *data) +{ + /* If this fails, it's too late to try Timidity so pray that at least one works. */ + fluidsynth.fluid_synth_sfload((fluid_synth_t*) data, path, 1); + return 1; +} + +static int FLUIDSYNTH_Open(const SDL_AudioSpec *spec) +{ + if (!Mix_EachSoundFont(fluidsynth_check_soundfont, NULL)) { + return -1; + } + return 0; +} + +static FLUIDSYNTH_Music *FLUIDSYNTH_LoadMusic(void *data) +{ + SDL_RWops *src = (SDL_RWops *)data; + FLUIDSYNTH_Music *music; + fluid_settings_t *settings; + + if ((music = SDL_calloc(1, sizeof(FLUIDSYNTH_Music)))) { + int channels = 2; + if ((music->stream = SDL_NewAudioStream(AUDIO_S16SYS, channels, music_spec.freq, music_spec.format, music_spec.channels, music_spec.freq))) { + music->buffer_size = music_spec.samples * sizeof(Sint16) * channels; + if ((music->buffer = SDL_malloc(music->buffer_size))) { + if ((settings = fluidsynth.new_fluid_settings())) { + fluidsynth.fluid_settings_setnum(settings, "synth.sample-rate", (double) music_spec.freq); + + if ((music->synth = fluidsynth.new_fluid_synth(settings))) { + if (Mix_EachSoundFont(fluidsynth_load_soundfont, (void*) music->synth)) { + if ((music->player = fluidsynth.new_fluid_player(music->synth))) { + void *buffer; + size_t size; + + buffer = SDL_LoadFile_RW(src, &size, SDL_FALSE); + if (buffer) { + if (fluidsynth.fluid_player_add_mem(music->player, buffer, size) == FLUID_OK) { + SDL_free(buffer); + return music; + } else { + Mix_SetError("FluidSynth failed to load in-memory song"); + } + SDL_free(buffer); + } else { + SDL_OutOfMemory(); + } + fluidsynth.delete_fluid_player(music->player); + } else { + Mix_SetError("Failed to create FluidSynth player"); + } + } + fluidsynth.delete_fluid_synth(music->synth); + } else { + Mix_SetError("Failed to create FluidSynth synthesizer"); + } + fluidsynth.delete_fluid_settings(settings); + } else { + Mix_SetError("Failed to create FluidSynth settings"); + } + } else { + SDL_OutOfMemory(); + } + } + SDL_free(music); + } else { + SDL_OutOfMemory(); + } + return NULL; +} + +static void *FLUIDSYNTH_CreateFromRW(SDL_RWops *src, int freesrc) +{ + FLUIDSYNTH_Music *music; + + music = FLUIDSYNTH_LoadMusic(src); + if (music && freesrc) { + SDL_RWclose(src); + } + return music; +} + +static void FLUIDSYNTH_SetVolume(void *context, int volume) +{ + FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; + /* FluidSynth's default is 0.2. Make 1.2 the maximum. */ + fluidsynth.fluid_synth_set_gain(music->synth, (float) (volume * 1.2 / MIX_MAX_VOLUME)); +} + +static int FLUIDSYNTH_Play(void *context, int play_count) +{ + FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; + fluidsynth.fluid_player_set_loop(music->player, play_count); + fluidsynth.fluid_player_play(music->player); + return 0; +} + +static SDL_bool FLUIDSYNTH_IsPlaying(void *context) +{ + FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; + return fluidsynth.fluid_player_get_status(music->player) == FLUID_PLAYER_PLAYING ? SDL_TRUE : SDL_FALSE; +} + +static int FLUIDSYNTH_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; + int filled; + + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + + if (fluidsynth.fluid_synth_write_s16(music->synth, music_spec.samples, music->buffer, 0, 2, music->buffer, 1, 2) != FLUID_OK) { + Mix_SetError("Error generating FluidSynth audio"); + return -1; + } + if (SDL_AudioStreamPut(music->stream, music->buffer, music->buffer_size) < 0) { + return -1; + } + return 0; +} +static int FLUIDSYNTH_GetAudio(void *context, void *data, int bytes) +{ + return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, FLUIDSYNTH_GetSome); +} + +static void FLUIDSYNTH_Stop(void *context) +{ + FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; + fluidsynth.fluid_player_stop(music->player); +} + +static void FLUIDSYNTH_Delete(void *context) +{ + FLUIDSYNTH_Music *music = (FLUIDSYNTH_Music *)context; + fluidsynth.delete_fluid_player(music->player); + fluidsynth.delete_fluid_settings(fluidsynth.fluid_synth_get_settings(music->synth)); + fluidsynth.delete_fluid_synth(music->synth); + SDL_free(music); +} + +Mix_MusicInterface Mix_MusicInterface_FLUIDSYNTH = +{ + "FLUIDSYNTH", + MIX_MUSIC_FLUIDSYNTH, + MUS_MID, + SDL_FALSE, + SDL_FALSE, + + FLUIDSYNTH_Load, + FLUIDSYNTH_Open, + FLUIDSYNTH_CreateFromRW, + NULL, /* CreateFromFile */ + FLUIDSYNTH_SetVolume, + FLUIDSYNTH_Play, + FLUIDSYNTH_IsPlaying, + FLUIDSYNTH_GetAudio, + NULL, /* Seek */ + NULL, /* Pause */ + NULL, /* Resume */ + FLUIDSYNTH_Stop, + FLUIDSYNTH_Delete, + NULL, /* Close */ + FLUIDSYNTH_Unload, +}; + +#endif /* MUSIC_MID_FLUIDSYNTH */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_fluidsynth.h b/music_fluidsynth.h new file mode 100644 index 0000000..23785fe --- /dev/null +++ b/music_fluidsynth.h @@ -0,0 +1,31 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + James Le Cuirot + chewi@aura-online.co.uk +*/ + +/* This file supports playing MIDI files with FluidSynth */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_FLUIDSYNTH; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_mad.c b/music_mad.c index e66dfc2..23517b3 100644 --- a/music_mad.c +++ b/music_mad.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -19,309 +19,439 @@ 3. This notice may not be removed or altered from any source distribution. */ -#ifdef MP3_MAD_MUSIC - -#include +#ifdef MUSIC_MP3_MAD #include "music_mad.h" -mad_data * -mad_openFileRW(SDL_RWops *src, SDL_AudioSpec *mixer, int freesrc) -{ - mad_data *mp3_mad; - - mp3_mad = (mad_data *)SDL_malloc(sizeof(mad_data)); - if (mp3_mad) { - mp3_mad->src = src; - mp3_mad->freesrc = freesrc; - mad_stream_init(&mp3_mad->stream); - mad_frame_init(&mp3_mad->frame); - mad_synth_init(&mp3_mad->synth); - mp3_mad->frames_read = 0; - mad_timer_reset(&mp3_mad->next_frame_start); - mp3_mad->volume = MIX_MAX_VOLUME; - mp3_mad->status = 0; - mp3_mad->output_begin = 0; - mp3_mad->output_end = 0; - mp3_mad->mixer = *mixer; - } - return mp3_mad; -} - -void -mad_closeFile(mad_data *mp3_mad) -{ - mad_stream_finish(&mp3_mad->stream); - mad_frame_finish(&mp3_mad->frame); - mad_synth_finish(&mp3_mad->synth); - - if (mp3_mad->freesrc) { - SDL_RWclose(mp3_mad->src); - } - SDL_free(mp3_mad); +#include "mad.h" + + +/* NOTE: The dithering functions are GPL, which should be fine if your + application is GPL (which would need to be true if you enabled + libmad support in SDL_mixer). If you're using libmad under the + commercial license, you need to disable this code. +*/ +/************************ dithering functions ***************************/ + +#ifdef MUSIC_MP3_MAD_GPL_DITHERING + +/* All dithering done here is taken from the GPL'ed xmms-mad plugin. */ + +/* Copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura. */ +/* Any feedback is very welcome. For any question, comments, */ +/* see http://www.math.keio.ac.jp/matumoto/emt.html or email */ +/* matumoto@math.keio.ac.jp */ + +/* Period parameters */ +#define MP3_DITH_N 624 +#define MP3_DITH_M 397 +#define MATRIX_A 0x9908b0df /* constant vector a */ +#define UPPER_MASK 0x80000000 /* most significant w-r bits */ +#define LOWER_MASK 0x7fffffff /* least significant r bits */ + +/* Tempering parameters */ +#define TEMPERING_MASK_B 0x9d2c5680 +#define TEMPERING_MASK_C 0xefc60000 +#define TEMPERING_SHIFT_U(y) (y >> 11) +#define TEMPERING_SHIFT_S(y) (y << 7) +#define TEMPERING_SHIFT_T(y) (y << 15) +#define TEMPERING_SHIFT_L(y) (y >> 18) + +static unsigned long mt[MP3_DITH_N]; /* the array for the state vector */ +static int mti=MP3_DITH_N+1; /* mti==MP3_DITH_N+1 means mt[MP3_DITH_N] is not initialized */ + +/* initializing the array with a NONZERO seed */ +static void sgenrand(unsigned long seed) +{ + /* setting initial seeds to mt[MP3_DITH_N] using */ + /* the generator Line 25 of Table 1 in */ + /* [KNUTH 1981, The Art of Computer Programming */ + /* Vol. 2 (2nd Ed.), pp102] */ + mt[0]= seed & 0xffffffff; + for (mti=1; mti= MP3_DITH_N) { /* generate MP3_DITH_N words at one time */ + int kk; + + if (mti == MP3_DITH_N+1) /* if sgenrand() has not been called, */ + sgenrand(4357); /* a default initial seed is used */ + + for (kk=0;kk> 1) ^ mag01[y & 0x1]; + } + for (;kk> 1) ^ mag01[y & 0x1]; + } + y = (mt[MP3_DITH_N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK); + mt[MP3_DITH_N-1] = mt[MP3_DITH_M-1] ^ (y >> 1) ^ mag01[y & 0x1]; + + mti = 0; + } + + y = mt[mti++]; + y ^= TEMPERING_SHIFT_U(y); + y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B; + y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C; + y ^= TEMPERING_SHIFT_L(y); + + return y; +} + +static long triangular_dither_noise(int nbits) { + /* parameter nbits : the peak-to-peak amplitude desired (in bits) + * use with nbits set to 2 + nber of bits to be trimmed. + * (because triangular is made from two uniformly distributed processes, + * it starts at 2 bits peak-to-peak amplitude) + * see The Theory of Dithered Quantization by Robert Alexander Wannamaker + * for complete proof of why that's optimal + */ + long v = (genrand()/2 - genrand()/2); /* in ]-2^31, 2^31[ */ + long P = 1 << (32 - nbits); /* the power of 2 */ + v /= P; + /* now v in ]-2^(nbits-1), 2^(nbits-1) [ */ + + return v; +} + +#endif /* MUSIC_MP3_MAD_GPL_DITHERING */ + + +#define MAD_INPUT_BUFFER_SIZE (5*8192) + +enum { + MS_input_eof = 0x0001, + MS_input_error = 0x0001, + MS_decode_error = 0x0002, + MS_error_flags = 0x000f, +}; + +typedef struct { + int play_count; + SDL_RWops *src; + int freesrc; + struct mad_stream stream; + struct mad_frame frame; + struct mad_synth synth; + mad_timer_t next_frame_start; + int volume; + int status; + SDL_AudioStream *audiostream; + + unsigned char input_buffer[MAD_INPUT_BUFFER_SIZE + MAD_BUFFER_GUARD]; +} MAD_Music; + + +static int MAD_Seek(void *context, double position); + +static void *MAD_CreateFromRW(SDL_RWops *src, int freesrc) +{ + MAD_Music *music; + + music = (MAD_Music *)SDL_calloc(1, sizeof(MAD_Music)); + if (!music) { + SDL_OutOfMemory(); + return NULL; + } + music->src = src; + music->volume = MIX_MAX_VOLUME; + + mad_stream_init(&music->stream); + mad_frame_init(&music->frame); + mad_synth_init(&music->synth); + mad_timer_reset(&music->next_frame_start); + + music->freesrc = freesrc; + return music; +} + +static void MAD_SetVolume(void *context, int volume) +{ + MAD_Music *music = (MAD_Music *)context; + music->volume = volume; } /* Starts the playback. */ -void -mad_start(mad_data *mp3_mad) { - mp3_mad->status |= MS_playing; -} - -/* Stops the playback. */ -void -mad_stop(mad_data *mp3_mad) { - mp3_mad->status &= ~MS_playing; -} - -/* Returns true if the playing is engaged, false otherwise. */ -int -mad_isPlaying(mad_data *mp3_mad) { - return ((mp3_mad->status & MS_playing) != 0); -} - -/* Reads the next frame from the file. Returns true on success or - false on failure. */ -static int -read_next_frame(mad_data *mp3_mad) { - if (mp3_mad->stream.buffer == NULL || - mp3_mad->stream.error == MAD_ERROR_BUFLEN) { - size_t read_size; - size_t remaining; - unsigned char *read_start; - - /* There might be some bytes in the buffer left over from last - time. If so, move them down and read more bytes following - them. */ - if (mp3_mad->stream.next_frame != NULL) { - remaining = mp3_mad->stream.bufend - mp3_mad->stream.next_frame; - memmove(mp3_mad->input_buffer, mp3_mad->stream.next_frame, remaining); - read_start = mp3_mad->input_buffer + remaining; - read_size = MAD_INPUT_BUFFER_SIZE - remaining; - +static int MAD_Play(void *context, int play_count) +{ + MAD_Music *music = (MAD_Music *)context; + music->play_count = play_count; + return MAD_Seek(music, 0.0); +} + +/* Reads the next frame from the file. + Returns true on success or false on failure. + */ +static SDL_bool read_next_frame(MAD_Music *music) +{ + if (music->stream.buffer == NULL || + music->stream.error == MAD_ERROR_BUFLEN) { + size_t read_size; + size_t remaining; + unsigned char *read_start; + + /* There might be some bytes in the buffer left over from last + time. If so, move them down and read more bytes following + them. */ + if (music->stream.next_frame != NULL) { + remaining = music->stream.bufend - music->stream.next_frame; + memmove(music->input_buffer, music->stream.next_frame, remaining); + read_start = music->input_buffer + remaining; + read_size = MAD_INPUT_BUFFER_SIZE - remaining; + + } else { + read_size = MAD_INPUT_BUFFER_SIZE; + read_start = music->input_buffer; + remaining = 0; + } + + /* Now read additional bytes from the input file. */ + read_size = SDL_RWread(music->src, read_start, 1, read_size); + + if (read_size == 0) { + if ((music->status & (MS_input_eof | MS_input_error)) == 0) { + /* FIXME: how to detect error? */ + music->status |= MS_input_eof; + + /* At the end of the file, we must stuff MAD_BUFFER_GUARD + number of 0 bytes. */ + SDL_memset(read_start + read_size, 0, MAD_BUFFER_GUARD); + read_size += MAD_BUFFER_GUARD; + } + } + + /* Now feed those bytes into the libmad stream. */ + mad_stream_buffer(&music->stream, music->input_buffer, + read_size + remaining); + music->stream.error = MAD_ERROR_NONE; + } + + /* Now ask libmad to extract a frame from the data we just put in + its buffer. */ + if (mad_frame_decode(&music->frame, &music->stream)) { + if (MAD_RECOVERABLE(music->stream.error)) { + return SDL_FALSE; + + } else if (music->stream.error == MAD_ERROR_BUFLEN) { + return SDL_FALSE; + + } else { + Mix_SetError("mad_frame_decode() failed, corrupt stream?"); + music->status |= MS_decode_error; + return SDL_FALSE; + } + } + + mad_timer_add(&music->next_frame_start, music->frame.header.duration); + + return SDL_TRUE; +} + +/* Scale a MAD sample to 16 bits for output. */ +static Sint16 scale(mad_fixed_t sample) +{ + const int n_bits_to_loose = MAD_F_FRACBITS + 1 - 16; + + /* round */ + sample += (1L << (n_bits_to_loose - 1)); + +#ifdef MUSIC_MP3_MAD_GPL_DITHERING + sample += triangular_dither_noise(n_bits_to_loose + 1); +#endif + + /* clip */ + if (sample >= MAD_F_ONE) + sample = MAD_F_ONE - 1; + else if (sample < -MAD_F_ONE) + sample = -MAD_F_ONE; + + /* quantize */ + return (Sint16)(sample >> n_bits_to_loose); +} + +/* Once the frame has been read, copies its samples into the output buffer. */ +static SDL_bool decode_frame(MAD_Music *music) +{ + struct mad_pcm *pcm; + unsigned int i, nchannels, nsamples; + mad_fixed_t const *left_ch, *right_ch; + Sint16 *buffer, *dst; + int result; + + mad_synth_frame(&music->synth, &music->frame); + pcm = &music->synth.pcm; + + if (!music->audiostream) { + music->audiostream = SDL_NewAudioStream(AUDIO_S16, pcm->channels, pcm->samplerate, music_spec.format, music_spec.channels, music_spec.freq); + if (!music->audiostream) { + return SDL_FALSE; + } + } + + nchannels = pcm->channels; + nsamples = pcm->length; + left_ch = pcm->samples[0]; + right_ch = pcm->samples[1]; + buffer = SDL_stack_alloc(Sint16, nsamples*nchannels); + if (!buffer) { + SDL_OutOfMemory(); + return SDL_FALSE; + } + + dst = buffer; + if (nchannels == 1) { + for (i = nsamples; i--;) { + *dst++ = scale(*left_ch++); + } } else { - read_size = MAD_INPUT_BUFFER_SIZE; - read_start = mp3_mad->input_buffer; - remaining = 0; - } - - /* Now read additional bytes from the input file. */ - read_size = SDL_RWread(mp3_mad->src, read_start, 1, read_size); - - if (read_size <= 0) { - if ((mp3_mad->status & (MS_input_eof | MS_input_error)) == 0) { - if (read_size == 0) { - mp3_mad->status |= MS_input_eof; - } else { - mp3_mad->status |= MS_input_error; - } - - /* At the end of the file, we must stuff MAD_BUFFER_GUARD - number of 0 bytes. */ - SDL_memset(read_start + read_size, 0, MAD_BUFFER_GUARD); - read_size += MAD_BUFFER_GUARD; - } - } - - /* Now feed those bytes into the libmad stream. */ - mad_stream_buffer(&mp3_mad->stream, mp3_mad->input_buffer, - read_size + remaining); - mp3_mad->stream.error = MAD_ERROR_NONE; - } - - /* Now ask libmad to extract a frame from the data we just put in - its buffer. */ - if (mad_frame_decode(&mp3_mad->frame, &mp3_mad->stream)) { - if (MAD_RECOVERABLE(mp3_mad->stream.error)) { - return 0; - - } else if (mp3_mad->stream.error == MAD_ERROR_BUFLEN) { - return 0; - - } else { - mp3_mad->status |= MS_decode_error; - return 0; - } - } - - mp3_mad->frames_read++; - mad_timer_add(&mp3_mad->next_frame_start, mp3_mad->frame.header.duration); - - return 1; -} - -/* Scale a MAD sample to 16 bits for output. */ -static signed int -scale(mad_fixed_t sample) { - /* round */ - sample += (1L << (MAD_F_FRACBITS - 16)); - - /* clip */ - if (sample >= MAD_F_ONE) - sample = MAD_F_ONE - 1; - else if (sample < -MAD_F_ONE) - sample = -MAD_F_ONE; - - /* quantize */ - return sample >> (MAD_F_FRACBITS + 1 - 16); -} - -/* Once the frame has been read, copies its samples into the output - buffer. */ -static void -decode_frame(mad_data *mp3_mad) { - struct mad_pcm *pcm; - unsigned int nchannels, nsamples; - mad_fixed_t const *left_ch, *right_ch; - unsigned char *out; - int ret; - - mad_synth_frame(&mp3_mad->synth, &mp3_mad->frame); - pcm = &mp3_mad->synth.pcm; - out = mp3_mad->output_buffer + mp3_mad->output_end; - - if ((mp3_mad->status & MS_cvt_decoded) == 0) { - mp3_mad->status |= MS_cvt_decoded; - - /* The first frame determines some key properties of the stream. - In particular, it tells us enough to set up the convert - structure now. */ - SDL_BuildAudioCVT(&mp3_mad->cvt, AUDIO_S16, pcm->channels, mp3_mad->frame.header.samplerate, mp3_mad->mixer.format, mp3_mad->mixer.channels, mp3_mad->mixer.freq); - } - - /* pcm->samplerate contains the sampling frequency */ - - nchannels = pcm->channels; - nsamples = pcm->length; - left_ch = pcm->samples[0]; - right_ch = pcm->samples[1]; - - while (nsamples--) { - signed int sample; - - /* output sample(s) in 16-bit signed little-endian PCM */ - - sample = scale(*left_ch++); - *out++ = ((sample >> 0) & 0xff); - *out++ = ((sample >> 8) & 0xff); - - if (nchannels == 2) { - sample = scale(*right_ch++); - *out++ = ((sample >> 0) & 0xff); - *out++ = ((sample >> 8) & 0xff); - } - } - - mp3_mad->output_end = out - mp3_mad->output_buffer; - /*assert(mp3_mad->output_end <= MAD_OUTPUT_BUFFER_SIZE);*/ -} - -int -mad_getSamples(mad_data *mp3_mad, Uint8 *stream, int len) { - int bytes_remaining; - int num_bytes; - Uint8 *out; - - if ((mp3_mad->status & MS_playing) == 0) { - /* We're not supposed to be playing, so send silence instead. */ - SDL_memset(stream, 0, len); + for (i = nsamples; i--;) { + *dst++ = scale(*left_ch++); + *dst++ = scale(*right_ch++); + } + } + + result = SDL_AudioStreamPut(music->audiostream, buffer, (nsamples * nchannels * sizeof(Sint16))); + SDL_stack_free(buffer); + + if (result < 0) { + return SDL_FALSE; + } + return SDL_TRUE; +} + +static int MAD_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + MAD_Music *music = (MAD_Music *)context; + int filled; + + if (music->audiostream) { + filled = SDL_AudioStreamGet(music->audiostream, data, bytes); + if (filled != 0) { + return filled; + } + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + if (read_next_frame(music)) { + if (!decode_frame(music)) { + return -1; + } + } else if (music->status & MS_input_eof) { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + if (MAD_Play(music, play_count) < 0) { + return -1; + } + } else if (music->status & MS_decode_error) { + return -1; + } return 0; - } - - out = stream; - bytes_remaining = len; - while (bytes_remaining > 0) { - if (mp3_mad->output_end == mp3_mad->output_begin) { - /* We need to get a new frame. */ - mp3_mad->output_begin = 0; - mp3_mad->output_end = 0; - if (!read_next_frame(mp3_mad)) { - if ((mp3_mad->status & MS_error_flags) != 0) { - /* Couldn't read a frame; either an error condition or - end-of-file. Stop. */ - SDL_memset(out, 0, bytes_remaining); - mp3_mad->status &= ~MS_playing; - return bytes_remaining; - } - } else { - decode_frame(mp3_mad); - - /* Now convert the frame data to the appropriate format for - output. */ - mp3_mad->cvt.buf = mp3_mad->output_buffer; - mp3_mad->cvt.len = mp3_mad->output_end; - - mp3_mad->output_end = (int)(mp3_mad->output_end * mp3_mad->cvt.len_ratio); - /*assert(mp3_mad->output_end <= MAD_OUTPUT_BUFFER_SIZE);*/ - SDL_ConvertAudio(&mp3_mad->cvt); - } - } - - num_bytes = mp3_mad->output_end - mp3_mad->output_begin; - if (bytes_remaining < num_bytes) { - num_bytes = bytes_remaining; - } - - if (mp3_mad->volume == MIX_MAX_VOLUME) { - SDL_memcpy(out, mp3_mad->output_buffer + mp3_mad->output_begin, num_bytes); - } else { - SDL_MixAudio(out, mp3_mad->output_buffer + mp3_mad->output_begin, - num_bytes, mp3_mad->volume); - } - out += num_bytes; - mp3_mad->output_begin += num_bytes; - bytes_remaining -= num_bytes; - } - return 0; -} - -void -mad_seek(mad_data *mp3_mad, double position) { - mad_timer_t target; - int int_part; - - int_part = (int)position; - mad_timer_set(&target, int_part, - (int)((position - int_part) * 1000000), 1000000); - - if (mad_timer_compare(mp3_mad->next_frame_start, target) > 0) { - /* In order to seek backwards in a VBR file, we have to rewind and - start again from the beginning. This isn't necessary if the - file happens to be CBR, of course; in that case we could seek - directly to the frame we want. But I leave that little - optimization for the future developer who discovers she really - needs it. */ - mp3_mad->frames_read = 0; - mad_timer_reset(&mp3_mad->next_frame_start); - mp3_mad->status &= ~MS_error_flags; - mp3_mad->output_begin = 0; - mp3_mad->output_end = 0; - - SDL_RWseek(mp3_mad->src, 0, RW_SEEK_SET); - } - - /* Now we have to skip frames until we come to the right one. - Again, only truly necessary if the file is VBR. */ - while (mad_timer_compare(mp3_mad->next_frame_start, target) < 0) { - if (!read_next_frame(mp3_mad)) { - if ((mp3_mad->status & MS_error_flags) != 0) { - /* Couldn't read a frame; either an error condition or - end-of-file. Stop. */ - mp3_mad->status &= ~MS_playing; - return; - } - } - } - - /* Here we are, at the beginning of the frame that contains the - target time. Ehh, I say that's close enough. If we wanted to, - we could get more precise by decoding the frame now and counting - the appropriate number of samples out of it. */ -} - -void -mad_setVolume(mad_data *mp3_mad, int volume) { - mp3_mad->volume = volume; -} - - -#endif /* MP3_MAD_MUSIC */ +} +static int MAD_GetAudio(void *context, void *data, int bytes) +{ + MAD_Music *music = (MAD_Music *)context; + return music_pcm_getaudio(context, data, bytes, music->volume, MAD_GetSome); +} + +static int MAD_Seek(void *context, double position) +{ + MAD_Music *music = (MAD_Music *)context; + mad_timer_t target; + int int_part; + + int_part = (int)position; + mad_timer_set(&target, int_part, (int)((position - int_part) * 1000000), 1000000); + + if (mad_timer_compare(music->next_frame_start, target) > 0) { + /* In order to seek backwards in a VBR file, we have to rewind and + start again from the beginning. This isn't necessary if the + file happens to be CBR, of course; in that case we could seek + directly to the frame we want. But I leave that little + optimization for the future developer who discovers she really + needs it. */ + mad_timer_reset(&music->next_frame_start); + music->status &= ~MS_error_flags; + + SDL_RWseek(music->src, 0, RW_SEEK_SET); + } + + /* Now we have to skip frames until we come to the right one. + Again, only truly necessary if the file is VBR. */ + while (mad_timer_compare(music->next_frame_start, target) < 0) { + if (!read_next_frame(music)) { + if ((music->status & MS_error_flags) != 0) { + /* Couldn't read a frame; either an error condition or + end-of-file. Stop. */ + return Mix_SetError("Seek position out of range"); + } + } + } + + /* Here we are, at the beginning of the frame that contains the + target time. Ehh, I say that's close enough. If we wanted to, + we could get more precise by decoding the frame now and counting + the appropriate number of samples out of it. */ + return 0; +} + +static void MAD_Delete(void *context) +{ + MAD_Music *music = (MAD_Music *)context; + + mad_stream_finish(&music->stream); + mad_frame_finish(&music->frame); + mad_synth_finish(&music->synth); + + if (music->audiostream) { + SDL_FreeAudioStream(music->audiostream); + } + if (music->freesrc) { + SDL_RWclose(music->src); + } + SDL_free(music); +} + +Mix_MusicInterface Mix_MusicInterface_MAD = +{ + "MAD", + MIX_MUSIC_MAD, + MUS_MP3, + SDL_FALSE, + SDL_FALSE, + + NULL, /* Load */ + NULL, /* Open */ + MAD_CreateFromRW, + NULL, /* CreateFromFile */ + MAD_SetVolume, + MAD_Play, + NULL, /* IsPlaying */ + MAD_GetAudio, + MAD_Seek, + NULL, /* Pause */ + NULL, /* Resume */ + NULL, /* Stop */ + MAD_Delete, + NULL, /* Close */ + NULL, /* Unload */ +}; + +#endif /* MUSIC_MP3_MAD */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_mad.h b/music_mad.h index 16a0875..d04ee57 100644 --- a/music_mad.h +++ b/music_mad.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -19,54 +19,10 @@ 3. This notice may not be removed or altered from any source distribution. */ -#ifdef MP3_MAD_MUSIC +/* This file supports playing MP3 files with libmad */ -#include "mad.h" -#include "SDL_rwops.h" -#include "SDL_audio.h" -#include "SDL_mixer.h" +#include "music.h" -#define MAD_INPUT_BUFFER_SIZE (5*8192) -#define MAD_OUTPUT_BUFFER_SIZE 8192 +extern Mix_MusicInterface Mix_MusicInterface_MAD; -enum { - MS_input_eof = 0x0001, - MS_input_error = 0x0001, - MS_decode_eof = 0x0002, - MS_decode_error = 0x0004, - MS_error_flags = 0x000f, - - MS_playing = 0x0100, - MS_cvt_decoded = 0x0200, -}; - -typedef struct { - SDL_RWops *src; - int freesrc; - struct mad_stream stream; - struct mad_frame frame; - struct mad_synth synth; - int frames_read; - mad_timer_t next_frame_start; - int volume; - int status; - int output_begin, output_end; - SDL_AudioSpec mixer; - SDL_AudioCVT cvt; - - unsigned char input_buffer[MAD_INPUT_BUFFER_SIZE + MAD_BUFFER_GUARD]; - unsigned char output_buffer[MAD_OUTPUT_BUFFER_SIZE]; -} mad_data; - -mad_data *mad_openFileRW(SDL_RWops *src, SDL_AudioSpec *mixer, int freesrc); -void mad_closeFile(mad_data *mp3_mad); - -void mad_start(mad_data *mp3_mad); -void mad_stop(mad_data *mp3_mad); -int mad_isPlaying(mad_data *mp3_mad); - -int mad_getSamples(mad_data *mp3_mad, Uint8 *stream, int len); -void mad_seek(mad_data *mp3_mad, double position); -void mad_setVolume(mad_data *mp3_mad, int volume); - -#endif +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_mikmod.c b/music_mikmod.c new file mode 100644 index 0000000..9ad59c5 --- /dev/null +++ b/music_mikmod.c @@ -0,0 +1,487 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef MUSIC_MOD_MIKMOD + +/* This file supports MOD tracker music streams */ + +#include "SDL_loadso.h" + +#include "music_mikmod.h" + +#include "mikmod.h" + + +/* libmikmod >= 3.3.2 constified several funcs */ +#if (LIBMIKMOD_VERSION < 0x030302) +#define MIKMOD3_CONST +#else +#define MIKMOD3_CONST const +#endif + +typedef struct { + int loaded; + void *handle; + + void (*MikMod_Exit)(void); + CHAR* (*MikMod_InfoDriver)(void); + CHAR* (*MikMod_InfoLoader)(void); + int (*MikMod_Init)(MIKMOD3_CONST CHAR*); + void (*MikMod_RegisterAllLoaders)(void); + void (*MikMod_RegisterDriver)(struct MDRIVER*); + int* MikMod_errno; + MIKMOD3_CONST char* (*MikMod_strerror)(int); + void (*MikMod_free)(void*); + BOOL (*Player_Active)(void); + void (*Player_Free)(MODULE*); + MODULE* (*Player_LoadGeneric)(MREADER*,int,BOOL); + void (*Player_SetPosition)(UWORD); + void (*Player_SetVolume)(SWORD); + void (*Player_Start)(MODULE*); + void (*Player_Stop)(void); + ULONG (*VC_WriteBytes)(SBYTE*,ULONG); + struct MDRIVER* drv_nos; + UWORD* md_device; + UWORD* md_mixfreq; + UWORD* md_mode; + UBYTE* md_musicvolume; + UBYTE* md_pansep; + UBYTE* md_reverb; + UBYTE* md_sndfxvolume; + UBYTE* md_volume; +} mikmod_loader; + +static mikmod_loader mikmod = { + 0, NULL +}; + +#ifdef MIKMOD_DYNAMIC +#define FUNCTION_LOADER(FUNC, SIG) \ + mikmod.FUNC = (SIG) SDL_LoadFunction(mikmod.handle, #FUNC); \ + if (mikmod.FUNC == NULL) { SDL_UnloadObject(mikmod.handle); return -1; } +#define VARIABLE_LOADER(NAME, SIG) \ + mikmod.NAME = (SIG) SDL_LoadFunction(mikmod.handle, #NAME); \ + if (mikmod.NAME == NULL) { SDL_UnloadObject(mikmod.handle); return -1; } +#else +#define FUNCTION_LOADER(FUNC, SIG) \ + mikmod.FUNC = FUNC; +#define VARIABLE_LOADER(NAME, SIG) \ + mikmod.NAME = &NAME; +#endif + +static int MIKMOD_Load() +{ + if (mikmod.loaded == 0) { +#ifdef MIKMOD_DYNAMIC + mikmod.handle = SDL_LoadObject(MIKMOD_DYNAMIC); + if (mikmod.handle == NULL) { + return -1; + } +#elif defined(__MACOSX__) + extern void Player_Start(MODULE*) __attribute__((weak_import)); + if (Player_Start == NULL) + { + /* Missing weakly linked framework */ + Mix_SetError("Missing mikmod.framework"); + return -1; + } +#endif + FUNCTION_LOADER(MikMod_Exit, void (*)(void)) + FUNCTION_LOADER(MikMod_InfoDriver, CHAR* (*)(void)) + FUNCTION_LOADER(MikMod_InfoLoader, CHAR* (*)(void)) + FUNCTION_LOADER(MikMod_Init, int (*)(MIKMOD3_CONST CHAR*)) + FUNCTION_LOADER(MikMod_RegisterAllLoaders, void (*)(void)) + FUNCTION_LOADER(MikMod_RegisterDriver, void (*)(struct MDRIVER*)) + VARIABLE_LOADER(MikMod_errno, int*) + FUNCTION_LOADER(MikMod_strerror, MIKMOD3_CONST char* (*)(int)) +#ifdef MIKMOD_DYNAMIC + mikmod.MikMod_free = (void (*)(void*)) SDL_LoadFunction(mikmod.handle, "MikMod_free"); + if (!mikmod.MikMod_free) { + /* libmikmod 3.1 and earlier doesn't have it */ + mikmod.MikMod_free = free; + } +#else +#if LIBMIKMOD_VERSION < ((3<<16)|(2<<8)) + mikmod.MikMod_free = free; +#else + mikmod.MikMod_free = MikMod_free; +#endif +#endif /* MIKMOD_DYNAMIC */ + FUNCTION_LOADER(Player_Active, BOOL (*)(void)) + FUNCTION_LOADER(Player_Free, void (*)(MODULE*)) + FUNCTION_LOADER(Player_LoadGeneric, MODULE* (*)(MREADER*,int,BOOL)) + FUNCTION_LOADER(Player_SetPosition, void (*)(UWORD)) + FUNCTION_LOADER(Player_SetVolume, void (*)(SWORD)) + FUNCTION_LOADER(Player_Start, void (*)(MODULE*)) + FUNCTION_LOADER(Player_Stop, void (*)(void)) + FUNCTION_LOADER(VC_WriteBytes, ULONG (*)(SBYTE*,ULONG)) + VARIABLE_LOADER(drv_nos, MDRIVER*) + VARIABLE_LOADER(md_device, UWORD*) + VARIABLE_LOADER(md_mixfreq, UWORD*) + VARIABLE_LOADER(md_mode, UWORD*) + VARIABLE_LOADER(md_musicvolume, UBYTE*) + VARIABLE_LOADER(md_pansep, UBYTE*) + VARIABLE_LOADER(md_reverb, UBYTE*) + VARIABLE_LOADER(md_sndfxvolume, UBYTE*) + VARIABLE_LOADER(md_volume, UBYTE*) + } + ++mikmod.loaded; + + return 0; +} + +static void MIKMOD_Unload() +{ + if (mikmod.loaded == 0) { + return; + } + if (mikmod.loaded == 1) { +#ifdef MIKMOD_DYNAMIC + SDL_UnloadObject(mikmod.handle); +#endif + } + --mikmod.loaded; +} + + +typedef struct +{ + int play_count; + int volume; + MODULE *module; + SDL_AudioStream *stream; + SBYTE *buffer; + ULONG buffer_size; +} MIKMOD_Music; + + +static int MIKMOD_Seek(void *context, double position); +static void MIKMOD_Delete(void *context); + +/* Initialize the MOD player, with the given mixer settings + This function returns 0, or -1 if there was an error. + */ +static int MIKMOD_Open(const SDL_AudioSpec *spec) +{ + CHAR *list; + + /* Set the MikMod music format */ + if (spec->format == AUDIO_S8 || spec->format == AUDIO_U8) { + /* MIKMOD audio format is AUDIO_U8 */ + *mikmod.md_mode = 0; + } else { + /* MIKMOD audio format is AUDIO_S16SYS */ + *mikmod.md_mode = DMODE_16BITS; + } + if (spec->channels > 1) { + *mikmod.md_mode |= DMODE_STEREO; + } + *mikmod.md_mixfreq = spec->freq; + *mikmod.md_device = 0; + *mikmod.md_volume = 96; + *mikmod.md_musicvolume = 128; + *mikmod.md_sndfxvolume = 128; + *mikmod.md_pansep = 128; + *mikmod.md_reverb = 0; + *mikmod.md_mode |= DMODE_HQMIXER|DMODE_SOFT_MUSIC|DMODE_SURROUND; + + list = mikmod.MikMod_InfoDriver(); + if (list) { + mikmod.MikMod_free(list); + } else { + mikmod.MikMod_RegisterDriver(mikmod.drv_nos); + } + + list = mikmod.MikMod_InfoLoader(); + if (list) { + mikmod.MikMod_free(list); + } else { + mikmod.MikMod_RegisterAllLoaders(); + } + + if (mikmod.MikMod_Init(NULL)) { + Mix_SetError("%s", mikmod.MikMod_strerror(*mikmod.MikMod_errno)); + return -1; + } + return 0; +} + +/* Uninitialize the music players */ +static void MIKMOD_Close(void) +{ + if (mikmod.MikMod_Exit) { + mikmod.MikMod_Exit(); + } +} + +typedef struct +{ + MREADER mr; + /* struct MREADER in libmikmod <= 3.2.0-beta2 + * doesn't have iobase members. adding them here + * so that if we compile against 3.2.0-beta2, we + * can still run OK against 3.2.0b3 and newer. */ + long iobase, prev_iobase; + Sint64 offset; + Sint64 eof; + SDL_RWops *src; +} LMM_MREADER; + +int LMM_Seek(struct MREADER *mr,long to,int dir) +{ + Sint64 offset = to; + LMM_MREADER* lmmmr = (LMM_MREADER*)mr; + if (dir == SEEK_SET) { + offset += lmmmr->offset; + if (offset < lmmmr->offset) + return -1; + } + return (int)(SDL_RWseek(lmmmr->src, offset, dir)); +} +long LMM_Tell(struct MREADER *mr) +{ + LMM_MREADER* lmmmr = (LMM_MREADER*)mr; + return (long)(SDL_RWtell(lmmmr->src) - lmmmr->offset); +} +BOOL LMM_Read(struct MREADER *mr,void *buf,size_t sz) +{ + LMM_MREADER* lmmmr = (LMM_MREADER*)mr; + return SDL_RWread(lmmmr->src, buf, sz, 1); +} +int LMM_Get(struct MREADER *mr) +{ + unsigned char c; + LMM_MREADER* lmmmr = (LMM_MREADER*)mr; + if (SDL_RWread(lmmmr->src, &c, 1, 1)) { + return c; + } + return EOF; +} +BOOL LMM_Eof(struct MREADER *mr) +{ + Sint64 offset; + LMM_MREADER* lmmmr = (LMM_MREADER*)mr; + offset = LMM_Tell(mr); + return offset >= lmmmr->eof; +} +MODULE *MikMod_LoadSongRW(SDL_RWops *src, int maxchan) +{ + LMM_MREADER lmmmr = { + { LMM_Seek, LMM_Tell, LMM_Read, LMM_Get, LMM_Eof }, + 0, + 0, + 0 + }; + lmmmr.offset = SDL_RWtell(src); + SDL_RWseek(src, 0, RW_SEEK_END); + lmmmr.eof = SDL_RWtell(src); + SDL_RWseek(src, lmmmr.offset, RW_SEEK_SET); + lmmmr.src = src; + return mikmod.Player_LoadGeneric((MREADER*)&lmmmr, maxchan, 0); +} + +/* Load a MOD stream from an SDL_RWops object */ +void *MIKMOD_CreateFromRW(SDL_RWops *src, int freesrc) +{ + MIKMOD_Music *music; + SDL_AudioFormat format; + Uint8 channels; + + music = (MIKMOD_Music *)SDL_calloc(1, sizeof(*music)); + if (!music) { + SDL_OutOfMemory(); + return NULL; + } + music->volume = MIX_MAX_VOLUME; + + music->module = MikMod_LoadSongRW(src, 64); + if (!music->module) { + Mix_SetError("%s", mikmod.MikMod_strerror(*mikmod.MikMod_errno)); + MIKMOD_Delete(music); + return NULL; + } + + /* Allow implicit looping, disable fade out and other flags. */ + music->module->extspd = 1; + music->module->panflag = 1; + music->module->wrap = 0; + music->module->loop = 1; + music->module->fadeout = 0; + + if ((*mikmod.md_mode & DMODE_16BITS) == DMODE_16BITS) { + format = AUDIO_S16SYS; + } else { + format = AUDIO_U8; + } + if ((*mikmod.md_mode & DMODE_STEREO) == DMODE_STEREO) { + channels = 2; + } else { + channels = 1; + } + music->stream = SDL_NewAudioStream(format, channels, *mikmod.md_mixfreq, + music_spec.format, music_spec.channels, music_spec.freq); + if (!music->stream) { + MIKMOD_Delete(music); + return NULL; + } + + music->buffer_size = music_spec.samples * (SDL_AUDIO_BITSIZE(format) / 8) * channels; + music->buffer = (SBYTE *)SDL_malloc(music->buffer_size); + if (!music->buffer) { + SDL_OutOfMemory(); + MIKMOD_Delete(music); + return NULL; + } + + if (freesrc) { + SDL_RWclose(src); + } + return music; +} + +/* Set the volume for a MOD stream */ +static void MIKMOD_SetVolume(void *context, int volume) +{ + MIKMOD_Music *music = (MIKMOD_Music *)context; + music->volume = volume; + mikmod.Player_SetVolume((SWORD)volume); +} + +/* Start playback of a given MOD stream */ +static int MIKMOD_Play(void *context, int play_count) +{ + MIKMOD_Music *music = (MIKMOD_Music *)context; + music->play_count = play_count; + music->module->initvolume = music->volume; + mikmod.Player_Start(music->module); + return MIKMOD_Seek(music, 0.0); +} + +/* Return non-zero if a stream is currently playing */ +static SDL_bool MIKMOD_IsPlaying(void *context) +{ + return mikmod.Player_Active() ? SDL_TRUE : SDL_FALSE; +} + +/* Play some of a stream previously started with MOD_play() */ +static int MIKMOD_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + MIKMOD_Music *music = (MIKMOD_Music *)context; + int filled; + + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + /* This never fails, and always writes a full buffer */ + mikmod.VC_WriteBytes(music->buffer, music->buffer_size); + + if (SDL_AudioStreamPut(music->stream, music->buffer, music->buffer_size) < 0) { + return -1; + } + + /* Check to see if we're done now */ + if (!mikmod.Player_Active()) { + if (music->play_count == 1) { + music->play_count = 0; + SDL_AudioStreamFlush(music->stream); + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + if (MIKMOD_Play(music, play_count) < 0) { + return -1; + } + } + } + return 0; +} +static int MIKMOD_GetAudio(void *context, void *data, int bytes) +{ + return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, MIKMOD_GetSome); +} + +/* Jump (seek) to a given position (time is in seconds) */ +static int MIKMOD_Seek(void *context, double position) +{ + mikmod.Player_SetPosition((UWORD)position); + return 0; +} + +/* Stop playback of a stream previously started with MOD_play() */ +static void MIKMOD_Stop(void *context) +{ + mikmod.Player_Stop(); +} + +/* Close the given MOD stream */ +static void MIKMOD_Delete(void *context) +{ + MIKMOD_Music *music = (MIKMOD_Music *)context; + + if (music->module) { + mikmod.Player_Free(music->module); + } + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } + if (music->buffer) { + SDL_free(music->buffer); + } + SDL_free(music); +} + +Mix_MusicInterface Mix_MusicInterface_MIKMOD = +{ + "MIKMOD", + MIX_MUSIC_MIKMOD, + MUS_MOD, + SDL_FALSE, + SDL_FALSE, + + MIKMOD_Load, + MIKMOD_Open, + MIKMOD_CreateFromRW, + NULL, /* CreateFromFile */ + MIKMOD_SetVolume, + MIKMOD_Play, + MIKMOD_IsPlaying, + MIKMOD_GetAudio, + MIKMOD_Seek, + NULL, /* Pause */ + NULL, /* Resume */ + MIKMOD_Stop, + MIKMOD_Delete, + MIKMOD_Close, + MIKMOD_Unload, +}; + +#endif /* MUSIC_MOD_MIKMOD */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_mikmod.h b/music_mikmod.h new file mode 100644 index 0000000..5cd633a --- /dev/null +++ b/music_mikmod.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports playing MOD files with libmikmod */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_MIKMOD; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_mod.c b/music_mod.c deleted file mode 100644 index 4b04d25..0000000 --- a/music_mod.c +++ /dev/null @@ -1,341 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* $Id: music_mod.c 4211 2008-12-08 00:27:32Z slouken $ */ - -#ifdef MOD_MUSIC - -/* This file supports MOD tracker music streams */ - -#include "SDL_mixer.h" -#include "dynamic_mod.h" -#include "music_mod.h" - -#include "mikmod.h" - -#define SDL_SURROUND -#ifdef SDL_SURROUND -#define MAX_OUTPUT_CHANNELS 6 -#else -#define MAX_OUTPUT_CHANNELS 2 -#endif - -/* Reference for converting mikmod output to 4/6 channels */ -static int current_output_channels; -static Uint16 current_output_format; - -static int music_swap8; -static int music_swap16; - -/* Initialize the MOD player, with the given mixer settings - This function returns 0, or -1 if there was an error. - */ -int MOD_init(SDL_AudioSpec *mixerfmt) -{ - CHAR *list; - - if ( !Mix_Init(MIX_INIT_MOD) ) { - return -1; - } - - /* Set the MikMod music format */ - music_swap8 = 0; - music_swap16 = 0; - switch (mixerfmt->format) { - - case AUDIO_U8: - case AUDIO_S8: { - if ( mixerfmt->format == AUDIO_S8 ) { - music_swap8 = 1; - } - *mikmod.md_mode = 0; - } - break; - - case AUDIO_S16LSB: - case AUDIO_S16MSB: { - /* See if we need to correct MikMod mixing */ -#if SDL_BYTEORDER == SDL_LIL_ENDIAN - if ( mixerfmt->format == AUDIO_S16MSB ) { -#else - if ( mixerfmt->format == AUDIO_S16LSB ) { -#endif - music_swap16 = 1; - } - *mikmod.md_mode = DMODE_16BITS; - } - break; - - default: { - Mix_SetError("Unknown hardware audio format"); - return -1; - } - } - current_output_channels = mixerfmt->channels; - current_output_format = mixerfmt->format; - if ( mixerfmt->channels > 1 ) { - if ( mixerfmt->channels > MAX_OUTPUT_CHANNELS ) { - Mix_SetError("Hardware uses more channels than mixerfmt"); - return -1; - } - *mikmod.md_mode |= DMODE_STEREO; - } - *mikmod.md_mixfreq = mixerfmt->freq; - *mikmod.md_device = 0; - *mikmod.md_volume = 96; - *mikmod.md_musicvolume = 128; - *mikmod.md_sndfxvolume = 128; - *mikmod.md_pansep = 128; - *mikmod.md_reverb = 0; - *mikmod.md_mode |= DMODE_HQMIXER|DMODE_SOFT_MUSIC|DMODE_SURROUND; - - list = mikmod.MikMod_InfoDriver(); - if ( list ) - mikmod.MikMod_free(list); - else - mikmod.MikMod_RegisterDriver(mikmod.drv_nos); - - list = mikmod.MikMod_InfoLoader(); - if ( list ) - mikmod.MikMod_free(list); - else - mikmod.MikMod_RegisterAllLoaders(); - - if ( mikmod.MikMod_Init(NULL) ) { - Mix_SetError("%s", mikmod.MikMod_strerror(*mikmod.MikMod_errno)); - return -1; - } - - return 0; -} - -/* Uninitialize the music players */ -void MOD_exit(void) -{ - if (mikmod.MikMod_Exit) { - mikmod.MikMod_Exit(); - } -} - -/* Set the volume for a MOD stream */ -void MOD_setvolume(MODULE *music, int volume) -{ - mikmod.Player_SetVolume((SWORD)volume); -} - -typedef struct -{ - MREADER mr; - Sint64 offset; - Sint64 eof; - SDL_RWops *src; -} LMM_MREADER; - -BOOL LMM_Seek(struct MREADER *mr,long to,int dir) -{ - Sint64 offset = to; - LMM_MREADER* lmmmr = (LMM_MREADER*)mr; - if ( dir == SEEK_SET ) { - offset += lmmmr->offset; - } - return (SDL_RWseek(lmmmr->src, offset, dir) < lmmmr->offset); -} -long LMM_Tell(struct MREADER *mr) -{ - LMM_MREADER* lmmmr = (LMM_MREADER*)mr; - return (long)(SDL_RWtell(lmmmr->src) - lmmmr->offset); -} -BOOL LMM_Read(struct MREADER *mr,void *buf,size_t sz) -{ - LMM_MREADER* lmmmr = (LMM_MREADER*)mr; - return SDL_RWread(lmmmr->src, buf, sz, 1); -} -int LMM_Get(struct MREADER *mr) -{ - unsigned char c; - LMM_MREADER* lmmmr = (LMM_MREADER*)mr; - if ( SDL_RWread(lmmmr->src, &c, 1, 1) ) { - return c; - } - return EOF; -} -BOOL LMM_Eof(struct MREADER *mr) -{ - Sint64 offset; - LMM_MREADER* lmmmr = (LMM_MREADER*)mr; - offset = LMM_Tell(mr); - return offset >= lmmmr->eof; -} -MODULE *MikMod_LoadSongRW(SDL_RWops *src, int maxchan) -{ - LMM_MREADER lmmmr = { - { LMM_Seek, LMM_Tell, LMM_Read, LMM_Get, LMM_Eof }, - 0, - 0, - 0 - }; - lmmmr.offset = SDL_RWtell(src); - SDL_RWseek(src, 0, RW_SEEK_END); - lmmmr.eof = SDL_RWtell(src); - SDL_RWseek(src, lmmmr.offset, RW_SEEK_SET); - lmmmr.src = src; - return mikmod.Player_LoadGeneric((MREADER*)&lmmmr, maxchan, 0); -} - -/* Load a MOD stream from an SDL_RWops object */ -MODULE *MOD_new_RW(SDL_RWops *src, int freesrc) -{ - MODULE *module; - - /* Make sure the mikmod library is loaded */ - if ( !Mix_Init(MIX_INIT_MOD) ) { - return NULL; - } - - module = MikMod_LoadSongRW(src, 64); - if (!module) { - Mix_SetError("%s", mikmod.MikMod_strerror(*mikmod.MikMod_errno)); - return NULL; - } - - /* Stop implicit looping, fade out and other flags. */ - module->extspd = 1; - module->panflag = 1; - module->wrap = 0; - module->loop = 0; -#if 0 /* Don't set fade out by default - unfortunately there's no real way -to query the status of the song or set trigger actions. Hum. */ - module->fadeout = 1; -#endif - - if ( freesrc ) { - SDL_RWclose(src); - } - return module; -} - -/* Start playback of a given MOD stream */ -void MOD_play(MODULE *music) -{ - mikmod.Player_Start(music); -} - -/* Return non-zero if a stream is currently playing */ -int MOD_playing(MODULE *music) -{ - return mikmod.Player_Active(); -} - -/* Play some of a stream previously started with MOD_play() */ -int MOD_playAudio(MODULE *music, Uint8 *stream, int len) -{ - if (current_output_channels > 2) { - int small_len = 2 * len / current_output_channels; - int i; - Uint8 *src, *dst; - - mikmod.VC_WriteBytes((SBYTE *)stream, small_len); - /* and extend to len by copying channels */ - src = stream + small_len; - dst = stream + len; - - switch (current_output_format & 0xFF) { - case 8: - for ( i=small_len/2; i; --i ) { - src -= 2; - dst -= current_output_channels; - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[0]; - dst[3] = src[1]; - if (current_output_channels == 6) { - dst[4] = src[0]; - dst[5] = src[1]; - } - } - break; - case 16: - for ( i=small_len/4; i; --i ) { - src -= 4; - dst -= 2 * current_output_channels; - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; - dst[4] = src[0]; - dst[5] = src[1]; - dst[6] = src[2]; - dst[7] = src[3]; - if (current_output_channels == 6) { - dst[8] = src[0]; - dst[9] = src[1]; - dst[10] = src[2]; - dst[11] = src[3]; - } - } - break; - } - } else { - mikmod.VC_WriteBytes((SBYTE *)stream, len); - } - if ( music_swap8 ) { - Uint8 *dst; - int i; - - dst = stream; - for ( i=len; i; --i ) { - *dst++ ^= 0x80; - } - } else - if ( music_swap16 ) { - Uint8 *dst, tmp; - int i; - - dst = stream; - for ( i=(len/2); i; --i ) { - tmp = dst[0]; - dst[0] = dst[1]; - dst[1] = tmp; - dst += 2; - } - } - return 0; -} - -/* Stop playback of a stream previously started with MOD_play() */ -void MOD_stop(MODULE *music) -{ - mikmod.Player_Stop(); -} - -/* Close the given MOD stream */ -void MOD_delete(MODULE *music) -{ - mikmod.Player_Free(music); -} - -/* Jump (seek) to a given position (time is in seconds) */ -void MOD_jump_to_time(MODULE *music, double time) -{ - mikmod.Player_SetPosition((UWORD)time); -} - -#endif /* MOD_MUSIC */ diff --git a/music_mod.h b/music_mod.h deleted file mode 100644 index a4055ae..0000000 --- a/music_mod.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* $Id: music_mod.h 4211 2008-12-08 00:27:32Z slouken $ */ - -#ifdef MOD_MUSIC - -/* This file supports MOD tracker music streams */ - -struct MODULE; - -/* Initialize the Ogg Vorbis player, with the given mixer settings - This function returns 0, or -1 if there was an error. - */ -extern int MOD_init(SDL_AudioSpec *mixer); - -/* Uninitialize the music players */ -extern void MOD_exit(void); - -/* Set the volume for a MOD stream */ -extern void MOD_setvolume(struct MODULE *music, int volume); - -/* Load a MOD stream from an SDL_RWops object */ -extern struct MODULE *MOD_new_RW(SDL_RWops *rw, int freerw); - -/* Start playback of a given MOD stream */ -extern void MOD_play(struct MODULE *music); - -/* Return non-zero if a stream is currently playing */ -extern int MOD_playing(struct MODULE *music); - -/* Play some of a stream previously started with MOD_play() */ -extern int MOD_playAudio(struct MODULE *music, Uint8 *stream, int len); - -/* Stop playback of a stream previously started with MOD_play() */ -extern void MOD_stop(struct MODULE *music); - -/* Close the given MOD stream */ -extern void MOD_delete(struct MODULE *music); - -/* Jump (seek) to a given position (time is in seconds) */ -extern void MOD_jump_to_time(struct MODULE *music, double time); - -#endif /* MOD_MUSIC */ diff --git a/music_modplug.c b/music_modplug.c index 04c42a3..7e40039 100644 --- a/music_modplug.c +++ b/music_modplug.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -19,246 +19,292 @@ 3. This notice may not be removed or altered from any source distribution. */ -#ifdef MODPLUG_MUSIC - -#include "SDL_mixer.h" -#include "dynamic_modplug.h" +#ifdef MUSIC_MOD_MODPLUG + +#include "SDL_loadso.h" + #include "music_modplug.h" -static int current_output_channels=0; -static int music_swap8=0; -static int music_swap16=0; +#ifdef MODPLUG_HEADER +#include MODPLUG_HEADER +#else +#include +#endif + +typedef struct { + int loaded; + void *handle; + + ModPlugFile* (*ModPlug_Load)(const void* data, int size); + void (*ModPlug_Unload)(ModPlugFile* file); + int (*ModPlug_Read)(ModPlugFile* file, void* buffer, int size); + void (*ModPlug_Seek)(ModPlugFile* file, int millisecond); + void (*ModPlug_GetSettings)(ModPlug_Settings* settings); + void (*ModPlug_SetSettings)(const ModPlug_Settings* settings); + void (*ModPlug_SetMasterVolume)(ModPlugFile* file,unsigned int cvol) ; +} modplug_loader; + +static modplug_loader modplug = { + 0, NULL +}; + + static ModPlug_Settings settings; -int modplug_init(SDL_AudioSpec *spec) -{ - if ( !Mix_Init(MIX_INIT_MODPLUG) ) { - return -1; - } - +#ifdef MODPLUG_DYNAMIC +#define FUNCTION_LOADER(FUNC, SIG) \ + modplug.FUNC = (SIG) SDL_LoadFunction(modplug.handle, #FUNC); \ + if (modplug.FUNC == NULL) { SDL_UnloadObject(modplug.handle); return -1; } +#else +#define FUNCTION_LOADER(FUNC, SIG) \ + modplug.FUNC = FUNC; +#endif + +static int MODPLUG_Load(void) +{ + if (modplug.loaded == 0) { +#ifdef MODPLUG_DYNAMIC + modplug.handle = SDL_LoadObject(MODPLUG_DYNAMIC); + if (modplug.handle == NULL) { + return -1; + } +#elif defined(__MACOSX__) + extern ModPlugFile* ModPlug_Load(const void* data, int size) __attribute__((weak_import)); + if (ModPlug_Load == NULL) + { + /* Missing weakly linked framework */ + Mix_SetError("Missing modplug.framework"); + return -1; + } +#endif + FUNCTION_LOADER(ModPlug_Load, ModPlugFile* (*)(const void* data, int size)) + FUNCTION_LOADER(ModPlug_Unload, void (*)(ModPlugFile* file)) + FUNCTION_LOADER(ModPlug_Read, int (*)(ModPlugFile* file, void* buffer, int size)) + FUNCTION_LOADER(ModPlug_Seek, void (*)(ModPlugFile* file, int millisecond)) + FUNCTION_LOADER(ModPlug_GetSettings, void (*)(ModPlug_Settings* settings)) + FUNCTION_LOADER(ModPlug_SetSettings, void (*)(const ModPlug_Settings* settings)) + FUNCTION_LOADER(ModPlug_SetMasterVolume, void (*)(ModPlugFile* file,unsigned int cvol)) + } + ++modplug.loaded; + + return 0; +} + +static void MODPLUG_Unload(void) +{ + if (modplug.loaded == 0) { + return; + } + if (modplug.loaded == 1) { +#ifdef MODPLUG_DYNAMIC + SDL_UnloadObject(modplug.handle); +#endif + } + --modplug.loaded; +} + + +typedef struct +{ + int play_count; + ModPlugFile *file; + SDL_AudioStream *stream; + void *buffer; + int buffer_size; +} MODPLUG_Music; + + +static int MODPLUG_Seek(void *context, double position); +static void MODPLUG_Delete(void *context); + +static int MODPLUG_Open(const SDL_AudioSpec *spec) +{ + /* ModPlug supports U8 or S16 audio output */ modplug.ModPlug_GetSettings(&settings); - settings.mFlags=MODPLUG_ENABLE_OVERSAMPLING; - current_output_channels=spec->channels; - settings.mChannels=spec->channels>1?2:1; - settings.mBits=spec->format&0xFF; - - music_swap8 = 0; - music_swap16 = 0; - - switch(spec->format) - { - case AUDIO_U8: - case AUDIO_S8: { - if ( spec->format == AUDIO_S8 ) { - music_swap8 = 1; - } - settings.mBits=8; - } - break; - - case AUDIO_S16LSB: - case AUDIO_S16MSB: { - /* See if we need to correct MikMod mixing */ -#if SDL_BYTEORDER == SDL_LIL_ENDIAN - if ( spec->format == AUDIO_S16MSB ) { -#else - if ( spec->format == AUDIO_S16LSB ) { -#endif - music_swap16 = 1; - } - settings.mBits=16; - } - break; - - default: { - Mix_SetError("Unknown hardware audio format"); - return -1; - } - - } - - settings.mFrequency=spec->freq; /*TODO: limit to 11025, 22050, or 44100 ? */ - settings.mResamplingMode=MODPLUG_RESAMPLE_FIR; - settings.mReverbDepth=0; - settings.mReverbDelay=100; - settings.mBassAmount=0; - settings.mBassRange=50; - settings.mSurroundDepth=0; - settings.mSurroundDelay=10; - settings.mLoopCount=0; + settings.mFlags = MODPLUG_ENABLE_OVERSAMPLING; + if (spec->channels == 1) { + settings.mChannels = 1; + } else { + settings.mChannels = 2; + } + if (SDL_AUDIO_BITSIZE(spec->format) == 8) { + settings.mBits = 8; + } else { + settings.mBits = 16; + } + if (spec->freq >= 44100) { + settings.mFrequency = 44100; + } else if (spec->freq >= 22050) { + settings.mFrequency = 22050; + } else { + settings.mFrequency = 11025; + } + settings.mResamplingMode = MODPLUG_RESAMPLE_FIR; + settings.mReverbDepth = 0; + settings.mReverbDelay = 100; + settings.mBassAmount = 0; + settings.mBassRange = 50; + settings.mSurroundDepth = 0; + settings.mSurroundDelay = 10; + settings.mLoopCount = 0; modplug.ModPlug_SetSettings(&settings); return 0; } -/* Uninitialize the music players */ -void modplug_exit() -{ +/* Load a modplug stream from an SDL_RWops object */ +void *MODPLUG_CreateFromRW(SDL_RWops *src, int freesrc) +{ + MODPLUG_Music *music; + void *buffer; + size_t size; + + music = (MODPLUG_Music *)SDL_calloc(1, sizeof(*music)); + if (!music) { + SDL_OutOfMemory(); + return NULL; + } + + music->stream = SDL_NewAudioStream((settings.mBits == 8) ? AUDIO_U8 : AUDIO_S16SYS, settings.mChannels, settings.mFrequency, + music_spec.format, music_spec.channels, music_spec.freq); + if (!music->stream) { + MODPLUG_Delete(music); + return NULL; + } + + music->buffer_size = music_spec.samples * (settings.mBits / 8) * settings.mChannels; + music->buffer = SDL_malloc(music->buffer_size); + if (!music->buffer) { + MODPLUG_Delete(music); + return NULL; + } + + buffer = SDL_LoadFile_RW(src, &size, SDL_FALSE); + if (buffer) { + music->file = modplug.ModPlug_Load(buffer, (int)size); + if (!music->file) { + Mix_SetError("ModPlug_Load failed"); + } + SDL_free(buffer); + } + + if (!music->file) { + MODPLUG_Delete(music); + return NULL; + } + + if (freesrc) { + SDL_RWclose(src); + } + return music; } /* Set the volume for a modplug stream */ -void modplug_setvolume(modplug_data *music, int volume) -{ +static void MODPLUG_SetVolume(void *context, int volume) +{ + MODPLUG_Music *music = (MODPLUG_Music *)context; modplug.ModPlug_SetMasterVolume(music->file, volume*4); } -/* Load a modplug stream from an SDL_RWops object */ -modplug_data *modplug_new_RW(SDL_RWops *src, int freesrc) -{ - modplug_data *music = NULL; - Sint64 offset; - size_t sz; - char *buf; - - /* Make sure the modplug library is loaded */ - if ( !Mix_Init(MIX_INIT_MODPLUG) ) { - return NULL; - } - - offset = SDL_RWtell(src); - SDL_RWseek(src, 0, RW_SEEK_END); - sz = (size_t)(SDL_RWtell(src) - offset); - SDL_RWseek(src, offset, RW_SEEK_SET); - buf = (char*)SDL_malloc(sz); - if (buf) { - if (SDL_RWread(src, buf, sz, 1) == 1) { - music = (modplug_data*)SDL_malloc(sizeof(modplug_data)); - if (music) { - music->playing = 0; - music->file = modplug.ModPlug_Load(buf, sz); - if (!music->file) { - SDL_free(music); - music = NULL; - } - } else { - SDL_OutOfMemory(); +/* Start playback of a given modplug stream */ +static int MODPLUG_Play(void *context, int play_count) +{ + MODPLUG_Music *music = (MODPLUG_Music *)context; + music->play_count = play_count; + return MODPLUG_Seek(music, 0.0); +} + +/* Play some of a stream previously started with modplug_play() */ +static int MODPLUG_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + MODPLUG_Music *music = (MODPLUG_Music *)context; + int filled, amount; + + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + amount = modplug.ModPlug_Read(music->file, music->buffer, music->buffer_size); + if (amount > 0) { + if (SDL_AudioStreamPut(music->stream, music->buffer, amount) < 0) { + return -1; + } + } else { + if (music->play_count == 1) { + music->play_count = 0; + SDL_AudioStreamFlush(music->stream); + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); } - } - SDL_free(buf); - } else { - SDL_OutOfMemory(); - } - if (music && freesrc) { - SDL_RWclose(src); - } - return music; -} - -/* Start playback of a given modplug stream */ -void modplug_play(modplug_data *music) -{ - modplug.ModPlug_Seek(music->file,0); - music->playing=1; -} - -/* Return non-zero if a stream is currently playing */ -int modplug_playing(modplug_data *music) -{ - return music && music->playing; -} - -/* Play some of a stream previously started with modplug_play() */ -int modplug_playAudio(modplug_data *music, Uint8 *stream, int len) -{ - if (current_output_channels > 2) { - int small_len = 2 * len / current_output_channels; - int i; - Uint8 *src, *dst; - - i=modplug.ModPlug_Read(music->file, stream, small_len); - if(iplaying=0; - } - /* and extend to len by copying channels */ - src = stream + small_len; - dst = stream + len; - - switch (settings.mBits) { - case 8: - for ( i=small_len/2; i; --i ) { - src -= 2; - dst -= current_output_channels; - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[0]; - dst[3] = src[1]; - if (current_output_channels == 6) { - dst[4] = src[0]; - dst[5] = src[1]; - } - } - break; - case 16: - for ( i=small_len/4; i; --i ) { - src -= 4; - dst -= 2 * current_output_channels; - dst[0] = src[0]; - dst[1] = src[1]; - dst[2] = src[2]; - dst[3] = src[3]; - dst[4] = src[0]; - dst[5] = src[1]; - dst[6] = src[2]; - dst[7] = src[3]; - if (current_output_channels == 6) { - dst[8] = src[0]; - dst[9] = src[1]; - dst[10] = src[2]; - dst[11] = src[3]; - } - } - break; - } - } else { - int i=modplug.ModPlug_Read(music->file, stream, len); - if(iplaying=0; - } - } - if ( music_swap8 ) { - Uint8 *dst; - int i; - - dst = stream; - for ( i=len; i; --i ) { - *dst++ ^= 0x80; - } - } else - if ( music_swap16 ) { - Uint8 *dst, tmp; - int i; - - dst = stream; - for ( i=(len/2); i; --i ) { - tmp = dst[0]; - dst[0] = dst[1]; - dst[1] = tmp; - dst += 2; + if (MODPLUG_Play(music, play_count) < 0) { + return -1; + } } } return 0; } - -/* Stop playback of a stream previously started with modplug_play() */ -void modplug_stop(modplug_data *music) -{ - music->playing=0; +static int MODPLUG_GetAudio(void *context, void *data, int bytes) +{ + return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, MODPLUG_GetSome); +} + +/* Jump (seek) to a given position */ +static int MODPLUG_Seek(void *context, double position) +{ + MODPLUG_Music *music = (MODPLUG_Music *)context; + modplug.ModPlug_Seek(music->file, (int)(position*1000)); + return 0; } /* Close the given modplug stream */ -void modplug_delete(modplug_data *music) -{ - modplug.ModPlug_Unload(music->file); +static void MODPLUG_Delete(void *context) +{ + MODPLUG_Music *music = (MODPLUG_Music *)context; + if (music->file) { + modplug.ModPlug_Unload(music->file); + } + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } + if (music->buffer) { + SDL_free(music->buffer); + } SDL_free(music); } -/* Jump (seek) to a given position (time is in seconds) */ -void modplug_jump_to_time(modplug_data *music, double time) -{ - modplug.ModPlug_Seek(music->file,(int)(time*1000)); -} - -#endif /* MODPLUG_MUSIC */ +Mix_MusicInterface Mix_MusicInterface_MODPLUG = +{ + "MODPLUG", + MIX_MUSIC_MODPLUG, + MUS_MOD, + SDL_FALSE, + SDL_FALSE, + + MODPLUG_Load, + MODPLUG_Open, + MODPLUG_CreateFromRW, + NULL, /* CreateFromFile */ + MODPLUG_SetVolume, + MODPLUG_Play, + NULL, /* IsPlaying */ + MODPLUG_GetAudio, + MODPLUG_Seek, + NULL, /* Pause */ + NULL, /* Resume */ + NULL, /* Stop */ + MODPLUG_Delete, + NULL, /* Close */ + MODPLUG_Unload, +}; + +#endif /* MUSIC_MOD_MODPLUG */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_modplug.h b/music_modplug.h index 952dc86..ce28d05 100644 --- a/music_modplug.h +++ b/music_modplug.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -19,49 +19,10 @@ 3. This notice may not be removed or altered from any source distribution. */ -#ifdef MODPLUG_MUSIC +/* This file supports playing MOD files with libmodplug */ -#ifdef MODPLUG_HEADER -#include MODPLUG_HEADER -#else -#include -#endif -#include "SDL_rwops.h" -#include "SDL_audio.h" -#include "SDL_mixer.h" +#include "music.h" -typedef struct { - ModPlugFile *file; - int playing; -} modplug_data; +extern Mix_MusicInterface Mix_MusicInterface_MODPLUG; -int modplug_init(SDL_AudioSpec *mixer); - -/* Uninitialize the music players */ -void modplug_exit(void); - -/* Set the volume for a modplug stream */ -void modplug_setvolume(modplug_data *music, int volume); - -/* Load a modplug stream from an SDL_RWops object */ -modplug_data *modplug_new_RW(SDL_RWops *rw, int freerw); - -/* Start playback of a given modplug stream */ -void modplug_play(modplug_data *music); - -/* Return non-zero if a stream is currently playing */ -int modplug_playing(modplug_data *music); - -/* Play some of a stream previously started with modplug_play() */ -int modplug_playAudio(modplug_data *music, Uint8 *stream, int len); - -/* Stop playback of a stream previously started with modplug_play() */ -void modplug_stop(modplug_data *music); - -/* Close the given modplug stream */ -void modplug_delete(modplug_data *music); - -/* Jump (seek) to a given position (time is in seconds) */ -void modplug_jump_to_time(modplug_data *music, double time); - -#endif /* MODPLUG_MUSIC */ +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_mpg123.c b/music_mpg123.c new file mode 100644 index 0000000..f75e9ce --- /dev/null +++ b/music_mpg123.c @@ -0,0 +1,431 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports playing MP3 files with mpg123 */ + +#ifdef MUSIC_MP3_MPG123 + +#include // For SEEK_SET + +#include "SDL_assert.h" +#include "SDL_loadso.h" + +#include "music_mpg123.h" + +#include + + +typedef struct { + int loaded; + void *handle; + + int (*mpg123_close)(mpg123_handle *mh); + void (*mpg123_delete)(mpg123_handle *mh); + void (*mpg123_exit)(void); + int (*mpg123_format)( mpg123_handle *mh, long rate, int channels, int encodings ); + int (*mpg123_format_none)(mpg123_handle *mh); + int (*mpg123_getformat)( mpg123_handle *mh, long *rate, int *channels, int *encoding ); + int (*mpg123_init)(void); + mpg123_handle *(*mpg123_new)(const char* decoder, int *error); + int (*mpg123_open_handle)(mpg123_handle *mh, void *iohandle); + const char* (*mpg123_plain_strerror)(int errcode); + void (*mpg123_rates)(const long **list, size_t *number); + int (*mpg123_read)(mpg123_handle *mh, unsigned char *outmemory, size_t outmemsize, size_t *done ); + int (*mpg123_replace_reader_handle)( mpg123_handle *mh, ssize_t (*r_read) (void *, void *, size_t), off_t (*r_lseek)(void *, off_t, int), void (*cleanup)(void*) ); + off_t (*mpg123_seek)( mpg123_handle *mh, off_t sampleoff, int whence ); + const char* (*mpg123_strerror)(mpg123_handle *mh); +} mpg123_loader; + +static mpg123_loader mpg123 = { + 0, NULL +}; + +#ifdef MPG123_DYNAMIC +#define FUNCTION_LOADER(FUNC, SIG) \ + mpg123.FUNC = (SIG) SDL_LoadFunction(mpg123.handle, #FUNC); \ + if (mpg123.FUNC == NULL) { SDL_UnloadObject(mpg123.handle); return -1; } +#else +#define FUNCTION_LOADER(FUNC, SIG) \ + mpg123.FUNC = FUNC; +#endif + +static int MPG123_Load(void) +{ + if (mpg123.loaded == 0) { +#ifdef MPG123_DYNAMIC + mpg123.handle = SDL_LoadObject(MPG123_DYNAMIC); + if (mpg123.handle == NULL) { + return -1; + } +#elif defined(__MACOSX__) + extern int mpg123_init(void) __attribute__((weak_import)); + if (mpg123_init == NULL) + { + /* Missing weakly linked framework */ + Mix_SetError("Missing mpg123.framework"); + return -1; + } +#endif + FUNCTION_LOADER(mpg123_close, int (*)(mpg123_handle *mh)) + FUNCTION_LOADER(mpg123_delete, void (*)(mpg123_handle *mh)) + FUNCTION_LOADER(mpg123_exit, void (*)(void)) + FUNCTION_LOADER(mpg123_format, int (*)( mpg123_handle *mh, long rate, int channels, int encodings )) + FUNCTION_LOADER(mpg123_format_none, int (*)(mpg123_handle *mh)) + FUNCTION_LOADER(mpg123_getformat, int (*)( mpg123_handle *mh, long *rate, int *channels, int *encoding )) + FUNCTION_LOADER(mpg123_init, int (*)(void)) + FUNCTION_LOADER(mpg123_new, mpg123_handle *(*)(const char* decoder, int *error)) + FUNCTION_LOADER(mpg123_open_handle, int (*)(mpg123_handle *mh, void *iohandle)) + FUNCTION_LOADER(mpg123_plain_strerror, const char* (*)(int errcode)) + FUNCTION_LOADER(mpg123_rates, void (*)(const long **list, size_t *number)); + FUNCTION_LOADER(mpg123_read, int (*)(mpg123_handle *mh, unsigned char *outmemory, size_t outmemsize, size_t *done )) + FUNCTION_LOADER(mpg123_replace_reader_handle, int (*)( mpg123_handle *mh, ssize_t (*r_read) (void *, void *, size_t), off_t (*r_lseek)(void *, off_t, int), void (*cleanup)(void*) )) + FUNCTION_LOADER(mpg123_seek, off_t (*)( mpg123_handle *mh, off_t sampleoff, int whence )) + FUNCTION_LOADER(mpg123_strerror, const char* (*)(mpg123_handle *mh)) + } + ++mpg123.loaded; + + return 0; +} + +static void MPG123_Unload(void) +{ + if (mpg123.loaded == 0) { + return; + } + if (mpg123.loaded == 1) { +#ifdef MPG123_DYNAMIC + SDL_UnloadObject(mpg123.handle); +#endif + } + --mpg123.loaded; +} + + +typedef struct +{ + int play_count; + SDL_RWops* src; + int freesrc; + int volume; + + mpg123_handle* handle; + SDL_AudioStream *stream; + unsigned char *buffer; + size_t buffer_size; +} MPG123_Music; + + +static int MPG123_Seek(void *context, double secs); +static void MPG123_Delete(void *context); + +static int mpg123_format_to_sdl(int fmt) +{ + switch (fmt) + { + case MPG123_ENC_SIGNED_8: return AUDIO_S8; + case MPG123_ENC_UNSIGNED_8: return AUDIO_U8; + case MPG123_ENC_SIGNED_16: return AUDIO_S16SYS; + case MPG123_ENC_UNSIGNED_16: return AUDIO_U16SYS; + case MPG123_ENC_SIGNED_32: return AUDIO_S32SYS; + case MPG123_ENC_FLOAT_32: return AUDIO_F32SYS; + default: return -1; + } +} + +/* +static const char *mpg123_format_str(int fmt) +{ + switch (fmt) + { +#define f(x) case x: return #x; + f(MPG123_ENC_UNSIGNED_8) + f(MPG123_ENC_UNSIGNED_16) + f(MPG123_ENC_SIGNED_8) + f(MPG123_ENC_SIGNED_16) + f(MPG123_ENC_SIGNED_32) + f(MPG123_ENC_FLOAT_32) +#undef f + } + return "unknown"; +} +*/ + +static char const* mpg_err(mpg123_handle* mpg, int result) +{ + char const* err = "unknown error"; + + if (mpg && result == MPG123_ERR) { + err = mpg123.mpg123_strerror(mpg); + } else { + err = mpg123.mpg123_plain_strerror(result); + } + return err; +} + +/* we're gonna override mpg123's I/O with these wrappers for RWops */ +static ssize_t rwops_read(void* p, void* dst, size_t n) +{ + return (ssize_t)SDL_RWread((SDL_RWops*)p, dst, 1, n); +} + +static off_t rwops_seek(void* p, off_t offset, int whence) +{ + return (off_t)SDL_RWseek((SDL_RWops*)p, (Sint64)offset, whence); +} + +static void rwops_cleanup(void* p) +{ + (void)p; + /* do nothing, we will free the file later */ +} + + +static int MPG123_Open(const SDL_AudioSpec *spec) +{ + if (mpg123.mpg123_init() != MPG123_OK) { + Mix_SetError("mpg123_init() failed"); + return -1; + } + return 0; +} + +static void *MPG123_CreateFromRW(SDL_RWops *src, int freesrc) +{ + MPG123_Music *music; + int result; + const long *rates; + size_t i, num_rates; + + music = (MPG123_Music*)SDL_calloc(1, sizeof(*music)); + if (!music) { + return NULL; + } + music->src = src; + music->volume = MIX_MAX_VOLUME; + + /* Just assume 16-bit 2 channel audio for now */ + music->buffer_size = music_spec.samples * sizeof(Sint16) * 2; + music->buffer = (unsigned char *)SDL_malloc(music->buffer_size); + if (!music->buffer) { + MPG123_Delete(music); + SDL_OutOfMemory(); + return NULL; + } + + music->handle = mpg123.mpg123_new(0, &result); + if (result != MPG123_OK) { + MPG123_Delete(music); + Mix_SetError("mpg123_new failed"); + return NULL; + } + + result = mpg123.mpg123_replace_reader_handle( + music->handle, + rwops_read, rwops_seek, rwops_cleanup + ); + if (result != MPG123_OK) { + MPG123_Delete(music); + Mix_SetError("mpg123_replace_reader_handle: %s", mpg_err(music->handle, result)); + return NULL; + } + + result = mpg123.mpg123_format_none(music->handle); + if (result != MPG123_OK) { + MPG123_Delete(music); + Mix_SetError("mpg123_format_none: %s", mpg_err(music->handle, result)); + return NULL; + } + + mpg123.mpg123_rates(&rates, &num_rates); + for (i = 0; i < num_rates; ++i) { + const int channels = (MPG123_MONO|MPG123_STEREO); + const int formats = (MPG123_ENC_SIGNED_8 | + MPG123_ENC_UNSIGNED_8 | + MPG123_ENC_SIGNED_16 | + MPG123_ENC_UNSIGNED_16 | + MPG123_ENC_SIGNED_32 | + MPG123_ENC_FLOAT_32); + + mpg123.mpg123_format(music->handle, rates[i], channels, formats); + } + + result = mpg123.mpg123_open_handle(music->handle, music->src); + if (result != MPG123_OK) { + MPG123_Delete(music); + Mix_SetError("mpg123_open_handle: %s", mpg_err(music->handle, result)); + return NULL; + } + + music->freesrc = freesrc; + return music; +} + +static void MPG123_SetVolume(void *context, int volume) +{ + MPG123_Music *music = (MPG123_Music *)context; + music->volume = volume; +} + +static int MPG123_Play(void *context, int play_count) +{ + MPG123_Music *music = (MPG123_Music *)context; + music->play_count = play_count; + return MPG123_Seek(music, 0.0); +} + +/* read some mp3 stream data and convert it for output */ +static int MPG123_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + MPG123_Music *music = (MPG123_Music *)context; + int filled, result; + size_t amount; + long rate; + int channels, encoding, format; + + if (music->stream) { + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + result = mpg123.mpg123_read(music->handle, music->buffer, music->buffer_size, &amount); + switch (result) { + case MPG123_OK: + if (SDL_AudioStreamPut(music->stream, music->buffer, (int)amount) < 0) { + return -1; + } + break; + + case MPG123_NEW_FORMAT: + result = mpg123.mpg123_getformat(music->handle, &rate, &channels, &encoding); + if (result != MPG123_OK) { + Mix_SetError("mpg123_getformat: %s", mpg_err(music->handle, result)); + return -1; + } +/*printf("MPG123 format: %s, channels = %d, rate = %ld\n", mpg123_format_str(encoding), channels, rate);*/ + + format = mpg123_format_to_sdl(encoding); + SDL_assert(format != -1); + + music->stream = SDL_NewAudioStream(format, channels, (int)rate, + music_spec.format, music_spec.channels, music_spec.freq); + if (!music->stream) { + return -1; + } + break; + + case MPG123_DONE: + if (music->play_count == 1) { + music->play_count = 0; + SDL_AudioStreamFlush(music->stream); + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + if (MPG123_Play(music, play_count) < 0) { + return -1; + } + } + break; + default: + Mix_SetError("mpg123_read: %s", mpg_err(music->handle, result)); + return -1; + } + return 0; +} +static int MPG123_GetAudio(void *context, void *data, int bytes) +{ + MPG123_Music *music = (MPG123_Music *)context; + return music_pcm_getaudio(context, data, bytes, music->volume, MPG123_GetSome); +} + +static int MPG123_Seek(void *context, double secs) +{ + MPG123_Music *music = (MPG123_Music *)context; + off_t offset = (off_t)(music_spec.freq * secs); + + if ((offset = mpg123.mpg123_seek(music->handle, offset, SEEK_SET)) < 0) { + return Mix_SetError("mpg123_seek: %s", mpg_err(music->handle, (int)-offset)); + } + return 0; +} + +static void MPG123_Delete(void *context) +{ + MPG123_Music *music = (MPG123_Music *)context; + + if (music->handle) { + mpg123.mpg123_close(music->handle); + mpg123.mpg123_delete(music->handle); + } + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } + if (music->buffer) { + SDL_free(music->buffer); + } + if (music->freesrc) { + SDL_RWclose(music->src); + } + SDL_free(music); +} + +static void MPG123_Close(void) +{ + mpg123.mpg123_exit(); +} + +Mix_MusicInterface Mix_MusicInterface_MPG123 = +{ + "MPG123", + MIX_MUSIC_MPG123, + MUS_MP3, + SDL_FALSE, + SDL_FALSE, + + MPG123_Load, + MPG123_Open, + MPG123_CreateFromRW, + NULL, /* CreateFromFile */ + MPG123_SetVolume, + MPG123_Play, + NULL, /* IsPlaying */ + MPG123_GetAudio, + MPG123_Seek, + NULL, /* Pause */ + NULL, /* Resume */ + NULL, /* Stop */ + MPG123_Delete, + MPG123_Close, + MPG123_Unload +}; + +#endif /* MUSIC_MP3_MPG123 */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_mpg123.h b/music_mpg123.h new file mode 100644 index 0000000..5b5657f --- /dev/null +++ b/music_mpg123.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports playing MP3 files with mpg123 */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_MPG123; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_nativemidi.c b/music_nativemidi.c new file mode 100644 index 0000000..846f3bd --- /dev/null +++ b/music_nativemidi.c @@ -0,0 +1,108 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef MUSIC_MID_NATIVE + +/* This file supports playing MIDI files with OS APIs */ + +#include "music_nativemidi.h" +#include "native_midi/native_midi.h" + + +static void *NATIVEMIDI_CreateFromRW(SDL_RWops *src, int freesrc) +{ + NativeMidiSong *music = native_midi_loadsong_RW(src, freesrc); + if (!music) { + Mix_SetError("%s", native_midi_error()); + } + return music; +} + +static int NATIVEMIDI_Play(void *context, int play_count) +{ + NativeMidiSong *music = (NativeMidiSong *)context; + int loops = play_count; + if (loops > 0) { + --loops; + } + native_midi_start(music, loops); + return 0; +} + +static void NATIVEMIDI_SetVolume(void *context, int volume) +{ + native_midi_setvolume(volume); +} + +static SDL_bool NATIVEMIDI_IsPlaying(void *context) +{ + return native_midi_active() ? SDL_TRUE : SDL_FALSE; +} + +static void NATIVEMIDI_Pause(void *context) +{ + native_midi_pause(); +} + +static void NATIVEMIDI_Resume(void *context) +{ + native_midi_resume(); +} + +static void NATIVEMIDI_Stop(void *context) +{ + native_midi_stop(); +} + +static void NATIVEMIDI_Delete(void *context) +{ + NativeMidiSong *music = (NativeMidiSong *)context; + native_midi_freesong(music); +} + +Mix_MusicInterface Mix_MusicInterface_NATIVEMIDI = +{ + "NATIVEMIDI", + MIX_MUSIC_NATIVEMIDI, + MUS_MID, + SDL_FALSE, + SDL_FALSE, + + NULL, /* Load */ + NULL, /* Open */ + NATIVEMIDI_CreateFromRW, + NULL, /* CreateFromFile */ + NATIVEMIDI_SetVolume, + NATIVEMIDI_Play, + NATIVEMIDI_IsPlaying, + NULL, /* GetAudio */ + NULL, /* Seek */ + NATIVEMIDI_Pause, + NATIVEMIDI_Resume, + NATIVEMIDI_Stop, + NATIVEMIDI_Delete, + NULL, /* Close */ + NULL, /* Unload */ +}; + +#endif /* MUSIC_MID_NATIVE */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_nativemidi.h b/music_nativemidi.h new file mode 100644 index 0000000..d3902e2 --- /dev/null +++ b/music_nativemidi.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports playing MIDI files with OS APIs */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_NATIVEMIDI; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_ogg.c b/music_ogg.c index 788f891..f54cdda 100644 --- a/music_ogg.c +++ b/music_ogg.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -19,36 +19,150 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* $Id$ */ - -#ifdef OGG_MUSIC +#ifdef MUSIC_OGG /* This file supports Ogg Vorbis music streams */ -#include -#include -#include - -#include "SDL_mixer.h" -#include "dynamic_ogg.h" +#include "SDL_loadso.h" + #include "music_ogg.h" -/* This is the format of the audio mixer data */ -static SDL_AudioSpec mixer; - -/* Initialize the Ogg Vorbis player, with the given mixer settings - This function returns 0, or -1 if there was an error. - */ -int OGG_init(SDL_AudioSpec *mixerfmt) -{ - mixer = *mixerfmt; - return(0); -} - -/* Set the volume for an OGG stream */ -void OGG_setvolume(OGG_music *music, int volume) -{ - music->volume = volume; +#if defined(OGG_HEADER) +#include OGG_HEADER +#elif defined(OGG_USE_TREMOR) +#include +#else +#include +#endif + +typedef struct { + int loaded; + void *handle; + int (*ov_clear)(OggVorbis_File *vf); + vorbis_info *(*ov_info)(OggVorbis_File *vf,int link); + vorbis_comment *(*ov_comment)(OggVorbis_File *vf,int link); + int (*ov_open_callbacks)(void *datasource, OggVorbis_File *vf, const char *initial, long ibytes, ov_callbacks callbacks); + ogg_int64_t (*ov_pcm_total)(OggVorbis_File *vf,int i); +#ifdef OGG_USE_TREMOR + long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int *bitstream); +#else + long (*ov_read)(OggVorbis_File *vf,char *buffer,int length, int bigendianp,int word,int sgned,int *bitstream); +#endif +#ifdef OGG_USE_TREMOR + int (*ov_time_seek)(OggVorbis_File *vf,ogg_int64_t pos); +#else + int (*ov_time_seek)(OggVorbis_File *vf,double pos); +#endif + int (*ov_pcm_seek)(OggVorbis_File *vf, ogg_int64_t pos); + ogg_int64_t (*ov_pcm_tell)(OggVorbis_File *vf); +} vorbis_loader; + +static vorbis_loader vorbis = { + 0, NULL +}; + +#ifdef OGG_DYNAMIC +#define FUNCTION_LOADER(FUNC, SIG) \ + vorbis.FUNC = (SIG) SDL_LoadFunction(vorbis.handle, #FUNC); \ + if (vorbis.FUNC == NULL) { SDL_UnloadObject(vorbis.handle); return -1; } +#else +#define FUNCTION_LOADER(FUNC, SIG) \ + vorbis.FUNC = FUNC; +#endif + +static int OGG_Load(void) +{ + if (vorbis.loaded == 0) { +#ifdef OGG_DYNAMIC + vorbis.handle = SDL_LoadObject(OGG_DYNAMIC); + if (vorbis.handle == NULL) { + return -1; + } +#elif defined(__MACOSX__) + extern int ov_open_callbacks(void*, OggVorbis_File*, const char*, long, ov_callbacks) __attribute__((weak_import)); + if (ov_open_callbacks == NULL) + { + /* Missing weakly linked framework */ + Mix_SetError("Missing Vorbis.framework"); + return -1; + } +#endif + FUNCTION_LOADER(ov_clear, int (*)(OggVorbis_File *)) + FUNCTION_LOADER(ov_info, vorbis_info *(*)(OggVorbis_File *,int)) + FUNCTION_LOADER(ov_comment, vorbis_comment *(*)(OggVorbis_File *,int)) + FUNCTION_LOADER(ov_open_callbacks, int (*)(void *, OggVorbis_File *, const char *, long, ov_callbacks)) + FUNCTION_LOADER(ov_pcm_total, ogg_int64_t (*)(OggVorbis_File *,int)) +#ifdef OGG_USE_TREMOR + FUNCTION_LOADER(ov_read, long (*)(OggVorbis_File *,char *,int,int *)) + FUNCTION_LOADER(ov_time_seek, long (*)(OggVorbis_File *,ogg_int64_t)) +#else + FUNCTION_LOADER(ov_read, long (*)(OggVorbis_File *,char *,int,int,int,int,int *)) + FUNCTION_LOADER(ov_time_seek, int (*)(OggVorbis_File *,double)) +#endif + FUNCTION_LOADER(ov_pcm_seek, int (*)(OggVorbis_File *,ogg_int64_t)) + FUNCTION_LOADER(ov_pcm_tell, ogg_int64_t (*)(OggVorbis_File *)) + } + ++vorbis.loaded; + + return 0; +} + +static void OGG_Unload(void) +{ + if (vorbis.loaded == 0) { + return; + } + if (vorbis.loaded == 1) { +#ifdef OGG_DYNAMIC + SDL_UnloadObject(vorbis.handle); +#endif + } + --vorbis.loaded; +} + + +typedef struct { + SDL_RWops *src; + int freesrc; + int play_count; + int volume; + OggVorbis_File vf; + vorbis_info vi; + int section; + SDL_AudioStream *stream; + char *buffer; + int buffer_size; + int loop; + ogg_int64_t loop_start; + ogg_int64_t loop_end; + ogg_int64_t loop_len; + ogg_int64_t channels; +} OGG_music; + + +static int set_ov_error(const char *function, int error) +{ +#define HANDLE_ERROR_CASE(X) case X: Mix_SetError("%s: %s", function, #X); break; + switch (error) { + HANDLE_ERROR_CASE(OV_FALSE); + HANDLE_ERROR_CASE(OV_EOF); + HANDLE_ERROR_CASE(OV_HOLE); + HANDLE_ERROR_CASE(OV_EREAD); + HANDLE_ERROR_CASE(OV_EFAULT); + HANDLE_ERROR_CASE(OV_EIMPL); + HANDLE_ERROR_CASE(OV_EINVAL); + HANDLE_ERROR_CASE(OV_ENOTVORBIS); + HANDLE_ERROR_CASE(OV_EBADHEADER); + HANDLE_ERROR_CASE(OV_EVERSION); + HANDLE_ERROR_CASE(OV_ENOTAUDIO); + HANDLE_ERROR_CASE(OV_EBADPACKET); + HANDLE_ERROR_CASE(OV_EBADLINK); + HANDLE_ERROR_CASE(OV_ENOSEEK); + default: + Mix_SetError("%s: unknown error %d\n", function, error); + break; + } + return -1; } static size_t sdl_read_func(void *ptr, size_t size, size_t nmemb, void *datasource) @@ -66,160 +180,277 @@ return (long)SDL_RWtell((SDL_RWops*)datasource); } +static int OGG_Seek(void *context, double time); +static void OGG_Delete(void *context); + +static int OGG_UpdateSection(OGG_music *music) +{ + vorbis_info *vi; + + vi = vorbis.ov_info(&music->vf, -1); + if (!vi) { + Mix_SetError("ov_info returned NULL"); + return -1; + } + + if (vi->channels == music->vi.channels && vi->rate == music->vi.rate) { + return 0; + } + SDL_memcpy(&music->vi, vi, sizeof(*vi)); + + if (music->buffer) { + SDL_free(music->buffer); + music->buffer = NULL; + } + + if (music->stream) { + SDL_FreeAudioStream(music->stream); + music->stream = NULL; + } + + music->stream = SDL_NewAudioStream(AUDIO_S16, vi->channels, (int)vi->rate, + music_spec.format, music_spec.channels, music_spec.freq); + if (!music->stream) { + return -1; + } + + music->buffer_size = music_spec.samples * sizeof(Sint16) * vi->channels; + music->buffer = (char *)SDL_malloc(music->buffer_size); + if (!music->buffer) { + return -1; + } + return 0; +} + /* Load an OGG stream from an SDL_RWops object */ -OGG_music *OGG_new_RW(SDL_RWops *src, int freesrc) +static void *OGG_CreateFromRW(SDL_RWops *src, int freesrc) { OGG_music *music; ov_callbacks callbacks; - - if ( !Mix_Init(MIX_INIT_OGG) ) { - return(NULL); - } - - SDL_memset(&callbacks, 0, sizeof(callbacks)); + vorbis_comment *vc; + int isLoopLength = 0, i; + ogg_int64_t fullLength; + + music = (OGG_music *)SDL_calloc(1, sizeof *music); + if (!music) { + SDL_OutOfMemory(); + return NULL; + } + music->src = src; + music->volume = MIX_MAX_VOLUME; + music->section = -1; + music->loop = -1; + music->loop_start = -1; + music->loop_end = 0; + music->loop_len = 0; + + SDL_zero(callbacks); callbacks.read_func = sdl_read_func; callbacks.seek_func = sdl_seek_func; callbacks.tell_func = sdl_tell_func; - music = (OGG_music *)SDL_malloc(sizeof *music); - if ( music ) { - /* Initialize the music structure */ - SDL_memset(music, 0, (sizeof *music)); - music->src = src; - music->freesrc = freesrc; - OGG_stop(music); - OGG_setvolume(music, MIX_MAX_VOLUME); - music->section = -1; - - if ( vorbis.ov_open_callbacks(src, &music->vf, NULL, 0, callbacks) < 0 ) { - SDL_SetError("Not an Ogg Vorbis audio stream"); - SDL_free(music); - return(NULL); - } + if (vorbis.ov_open_callbacks(src, &music->vf, NULL, 0, callbacks) < 0) { + SDL_SetError("Not an Ogg Vorbis audio stream"); + SDL_free(music); + return NULL; + } + + if (OGG_UpdateSection(music) < 0) { + OGG_Delete(music); + return NULL; + } + + vc = vorbis.ov_comment(&music->vf, -1); + for (i = 0; i < vc->comments; i++) { + char *param = SDL_strdup(vc->user_comments[i]); + char *argument = param; + char *value = SDL_strchr(param, '='); + if (value == NULL) { + value = param + SDL_strlen(param); + } else { + *(value++) = '\0'; + } + + if (SDL_strcasecmp(argument, "LOOPSTART") == 0) + music->loop_start = SDL_strtoull(value, NULL, 0); + else if (SDL_strcasecmp(argument, "LOOPLENGTH") == 0) { + music->loop_len = SDL_strtoull(value, NULL, 0); + isLoopLength = 1; + } else if (SDL_strcasecmp(argument, "LOOPEND") == 0) { + isLoopLength = 0; + music->loop_end = SDL_strtoull(value, NULL, 0); + } + SDL_free(param); + } + + if (isLoopLength == 1) { + music->loop_end = music->loop_start + music->loop_len; } else { - SDL_OutOfMemory(); - return(NULL); - } - return(music); + music->loop_len = music->loop_end - music->loop_start; + } + + fullLength = vorbis.ov_pcm_total(&music->vf, -1); + if (((music->loop_start >= 0) || (music->loop_end > 0)) && + ((music->loop_start < music->loop_end) || (music->loop_end == 0)) && + (music->loop_start < fullLength) && + (music->loop_end <= fullLength)) { + if (music->loop_start < 0) music->loop_start = 0; + if (music->loop_end == 0) music->loop_end = fullLength; + music->loop = 1; + } + + music->freesrc = freesrc; + return music; +} + +/* Set the volume for an OGG stream */ +static void OGG_SetVolume(void *context, int volume) +{ + OGG_music *music = (OGG_music *)context; + music->volume = volume; } /* Start playback of a given OGG stream */ -void OGG_play(OGG_music *music) -{ - music->playing = 1; -} - -/* Return non-zero if a stream is currently playing */ -int OGG_playing(OGG_music *music) -{ - return(music->playing); -} - -/* Read some Ogg stream data and convert it for output */ -static void OGG_getsome(OGG_music *music) -{ +static int OGG_Play(void *context, int play_count) +{ + OGG_music *music = (OGG_music *)context; + music->play_count = play_count; + return OGG_Seek(music, 0.0); +} + +/* Play some of a stream previously started with OGG_play() */ +static int OGG_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + OGG_music *music = (OGG_music *)context; + SDL_bool looped = SDL_FALSE; + int filled, amount, result; int section; - int len; - char data[4096]; - SDL_AudioCVT *cvt; - + ogg_int64_t pcmPos; + + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + section = music->section; #ifdef OGG_USE_TREMOR - len = vorbis.ov_read(&music->vf, data, sizeof(data), §ion); -#else - len = vorbis.ov_read(&music->vf, data, sizeof(data), 0, 2, 1, §ion); -#endif - if ( len <= 0 ) { - if ( len == 0 ) { - music->playing = 0; - } - return; - } - cvt = &music->cvt; - if ( section != music->section ) { - vorbis_info *vi; - - vi = vorbis.ov_info(&music->vf, -1); - SDL_BuildAudioCVT(cvt, AUDIO_S16, vi->channels, vi->rate, - mixer.format,mixer.channels,mixer.freq); - if ( cvt->buf ) { - SDL_free(cvt->buf); - } - cvt->buf = (Uint8 *)SDL_malloc(sizeof(data)*cvt->len_mult); + amount = vorbis.ov_read(&music->vf, music->buffer, music->buffer_size, §ion); +#else + amount = (int)vorbis.ov_read(&music->vf, music->buffer, music->buffer_size, 0, 2, 1, §ion); +#endif + if (amount < 0) { + set_ov_error("ov_read", amount); + return -1; + } + + if (section != music->section) { music->section = section; - } - if ( cvt->buf ) { - SDL_memcpy(cvt->buf, data, len); - if ( cvt->needed ) { - cvt->len = len; - SDL_ConvertAudio(cvt); + if (OGG_UpdateSection(music) < 0) { + return -1; + } + } + + pcmPos = vorbis.ov_pcm_tell(&music->vf); + if ((music->loop == 1) && (pcmPos >= music->loop_end)) { + amount -= (int)((pcmPos - music->loop_end) * music->channels) * sizeof(Sint16); + result = vorbis.ov_pcm_seek(&music->vf, music->loop_start); + if (result < 0) { + set_ov_error("ov_pcm_seek", result); + return -1; + } + looped = SDL_TRUE; + } + + if (amount > 0) { + if (SDL_AudioStreamPut(music->stream, music->buffer, amount) < 0) { + return -1; + } + } else if (!looped) { + if (music->play_count == 1) { + music->play_count = 0; + SDL_AudioStreamFlush(music->stream); } else { - cvt->len_cvt = len; - } - music->len_available = music->cvt.len_cvt; - music->snd_available = music->cvt.buf; - } else { - SDL_SetError("Out of memory"); - music->playing = 0; - } -} - -/* Play some of a stream previously started with OGG_play() */ -int OGG_playAudio(OGG_music *music, Uint8 *snd, int len) -{ - int mixable; - - while ( (len > 0) && music->playing ) { - if ( ! music->len_available ) { - OGG_getsome(music); - } - mixable = len; - if ( mixable > music->len_available ) { - mixable = music->len_available; - } - if ( music->volume == MIX_MAX_VOLUME ) { - SDL_memcpy(snd, music->snd_available, mixable); - } else { - SDL_MixAudio(snd, music->snd_available, mixable, - music->volume); - } - music->len_available -= mixable; - music->snd_available += mixable; - len -= mixable; - snd += mixable; - } - - return len; -} - -/* Stop playback of a stream previously started with OGG_play() */ -void OGG_stop(OGG_music *music) -{ - music->playing = 0; + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + if (OGG_Play(music, play_count) < 0) { + return -1; + } + } + } + return 0; +} +static int OGG_GetAudio(void *context, void *data, int bytes) +{ + OGG_music *music = (OGG_music *)context; + return music_pcm_getaudio(context, data, bytes, music->volume, OGG_GetSome); +} + +/* Jump (seek) to a given position (time is in seconds) */ +static int OGG_Seek(void *context, double time) +{ + OGG_music *music = (OGG_music *)context; + int result; +#ifdef OGG_USE_TREMOR + result = vorbis.ov_time_seek(&music->vf, (ogg_int64_t)(time * 1000.0)); +#else + result = vorbis.ov_time_seek(&music->vf, time); +#endif + if (result < 0) { + return set_ov_error("ov_time_seek", result); + } + return 0; } /* Close the given OGG stream */ -void OGG_delete(OGG_music *music) -{ - if ( music ) { - if ( music->cvt.buf ) { - SDL_free(music->cvt.buf); - } - if ( music->freesrc ) { - SDL_RWclose(music->src); - } - vorbis.ov_clear(&music->vf); - SDL_free(music); - } -} - -/* Jump (seek) to a given position (time is in seconds) */ -void OGG_jump_to_time(OGG_music *music, double time) -{ -#ifdef OGG_USE_TREMOR - vorbis.ov_time_seek( &music->vf, (ogg_int64_t)(time * 1000.0) ); -#else - vorbis.ov_time_seek( &music->vf, time ); -#endif -} - -#endif /* OGG_MUSIC */ +static void OGG_Delete(void *context) +{ + OGG_music *music = (OGG_music *)context; + vorbis.ov_clear(&music->vf); + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } + if (music->buffer) { + SDL_free(music->buffer); + } + if (music->freesrc) { + SDL_RWclose(music->src); + } + SDL_free(music); +} + +Mix_MusicInterface Mix_MusicInterface_OGG = +{ + "OGG", + MIX_MUSIC_OGG, + MUS_OGG, + SDL_FALSE, + SDL_FALSE, + + OGG_Load, + NULL, /* Open */ + OGG_CreateFromRW, + NULL, /* CreateFromFile */ + OGG_SetVolume, + OGG_Play, + NULL, /* IsPlaying */ + OGG_GetAudio, + OGG_Seek, + NULL, /* Pause */ + NULL, /* Resume */ + NULL, /* Stop */ + OGG_Delete, + NULL, /* Close */ + OGG_Unload, +}; + +#endif /* MUSIC_OGG */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_ogg.h b/music_ogg.h index c04798d..146b12f 100644 --- a/music_ogg.h +++ b/music_ogg.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -19,59 +19,10 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* $Id$ */ - -#ifdef OGG_MUSIC - /* This file supports Ogg Vorbis music streams */ -#if defined(OGG_HEADER) -#include OGG_HEADER -#elif defined(OGG_USE_TREMOR) -#include -#else -#include -#endif +#include "music.h" -typedef struct { - SDL_RWops *src; - int freesrc; - int playing; - int volume; - OggVorbis_File vf; - int section; - SDL_AudioCVT cvt; - int len_available; - Uint8 *snd_available; -} OGG_music; +extern Mix_MusicInterface Mix_MusicInterface_OGG; -/* Initialize the Ogg Vorbis player, with the given mixer settings - This function returns 0, or -1 if there was an error. - */ -extern int OGG_init(SDL_AudioSpec *mixer); - -/* Set the volume for an OGG stream */ -extern void OGG_setvolume(OGG_music *music, int volume); - -/* Load an OGG stream from an SDL_RWops object */ -extern OGG_music *OGG_new_RW(SDL_RWops *src, int freesrc); - -/* Start playback of a given OGG stream */ -extern void OGG_play(OGG_music *music); - -/* Return non-zero if a stream is currently playing */ -extern int OGG_playing(OGG_music *music); - -/* Play some of a stream previously started with OGG_play() */ -extern int OGG_playAudio(OGG_music *music, Uint8 *stream, int len); - -/* Stop playback of a stream previously started with OGG_play() */ -extern void OGG_stop(OGG_music *music); - -/* Close the given OGG stream */ -extern void OGG_delete(OGG_music *music); - -/* Jump (seek) to a given position (time is in seconds) */ -extern void OGG_jump_to_time(OGG_music *music, double time); - -#endif /* OGG_MUSIC */ +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_smpeg.c b/music_smpeg.c new file mode 100644 index 0000000..b333bcb --- /dev/null +++ b/music_smpeg.c @@ -0,0 +1,236 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef MUSIC_MP3_SMPEG + +#include "SDL_loadso.h" + +#include "music_smpeg.h" + +#if SDL_VERSION_ATLEAST(2, 0, 0) +/* Forward declaration for SDL 2.0 because struct is not available there but + still used in a file included with smpeg.h. May not compile if missing. */ +typedef struct SDL_Overlay SDL_Overlay; +#endif + +#include "smpeg.h" + +typedef struct { + int loaded; + void *handle; + void (*SMPEG_actualSpec)(SMPEG *mpeg, SDL_AudioSpec *spec); + void (*SMPEG_delete)(SMPEG* mpeg); + void (*SMPEG_enableaudio)(SMPEG* mpeg, int enable); + void (*SMPEG_enablevideo)(SMPEG* mpeg, int enable); + SMPEG* (*SMPEG_new_rwops)(SDL_RWops *src, SMPEG_Info* info, int freesrc, int sdl_audio); + void (*SMPEG_play)(SMPEG* mpeg); + int (*SMPEG_playAudio)(SMPEG *mpeg, Uint8 *stream, int len); + void (*SMPEG_rewind)(SMPEG* mpeg); + void (*SMPEG_setvolume)(SMPEG* mpeg, int volume); + void (*SMPEG_skip)(SMPEG* mpeg, float seconds); + SMPEGstatus (*SMPEG_status)(SMPEG* mpeg); + void (*SMPEG_stop)(SMPEG* mpeg); +} smpeg_loader; + +static smpeg_loader smpeg = { + 0, NULL +}; + +#ifdef SMPEG_DYNAMIC +#define FUNCTION_LOADER(FUNC, SIG) \ + smpeg.FUNC = (SIG) SDL_LoadFunction(smpeg.handle, #FUNC); \ + if (smpeg.FUNC == NULL) { SDL_UnloadObject(smpeg.handle); return -1; } +#else +#define FUNCTION_LOADER(FUNC, SIG) \ + smpeg.FUNC = FUNC; +#endif + +static int SMPEG_Load(void) +{ + if (smpeg.loaded == 0) { +#ifdef SMPEG_DYNAMIC + smpeg.handle = SDL_LoadObject(SMPEG_DYNAMIC); + if (smpeg.handle == NULL) { + return -1; + } +#elif defined(__MACOSX__) + extern SMPEG* SMPEG_new_rwops(SDL_RWops*, SMPEG_Info*, int, int) __attribute__((weak_import)); + if (SMPEG_new_rwops == NULL) + { + /* Missing weakly linked framework */ + Mix_SetError("Missing smpeg2.framework"); + return -1; + } +#endif + FUNCTION_LOADER(SMPEG_actualSpec, void (*)(SMPEG *, SDL_AudioSpec *)) + FUNCTION_LOADER(SMPEG_delete, void (*)(SMPEG*)) + FUNCTION_LOADER(SMPEG_enableaudio, void (*)(SMPEG*, int)) + FUNCTION_LOADER(SMPEG_enablevideo, void (*)(SMPEG*, int)) + FUNCTION_LOADER(SMPEG_new_rwops, SMPEG* (*)(SDL_RWops *, SMPEG_Info*, int, int)) + FUNCTION_LOADER(SMPEG_play, void (*)(SMPEG*)) + FUNCTION_LOADER(SMPEG_playAudio, int (*)(SMPEG *, Uint8 *, int)) + FUNCTION_LOADER(SMPEG_rewind, void (*)(SMPEG*)) + FUNCTION_LOADER(SMPEG_setvolume, void (*)(SMPEG*, int)) + FUNCTION_LOADER(SMPEG_skip, void (*)(SMPEG*, float)) + FUNCTION_LOADER(SMPEG_status, SMPEGstatus (*)(SMPEG*)) + FUNCTION_LOADER(SMPEG_stop, void (*)(SMPEG*)) + } + ++smpeg.loaded; + + return 0; +} + +static void SMPEG_Unload(void) +{ + if (smpeg.loaded == 0) { + return; + } + if (smpeg.loaded == 1) { +#ifdef SMPEG_DYNAMIC + SDL_UnloadObject(smpeg.handle); +#endif + } + --smpeg.loaded; +} + + +typedef struct +{ + SMPEG *mp3; + SDL_RWops *src; + int freesrc; +} SMPEG_Music; + +static void *SMPEG_CreateFromRW(SDL_RWops *src, int freesrc) +{ + SMPEG_Music *music; + SMPEG_Info info; + + music = (SMPEG_Music *)SDL_calloc(1, sizeof(*music)); + if (!music) { + SDL_OutOfMemory(); + return NULL; + } + music->src = src; + + music->mp3 = smpeg.SMPEG_new_rwops(src, &info, SDL_FALSE, 0); + if (!info.has_audio) { + Mix_SetError("MPEG file does not have any audio stream."); + smpeg.SMPEG_delete(music->mp3); + SDL_free(music); + return NULL; + } + smpeg.SMPEG_actualSpec(mp3, &music_spec); + + music->freesrc = freesrc; + return music; +} + +static void SMPEG_SetVolume(void *context, int volume) +{ + SMPEG_Music *music = (SMPEG_Music *)context; + smpeg.SMPEG_setvolume(music->mp3,(int)(((float)volume/(float)MIX_MAX_VOLUME)*100.0)); +} + +static int SMPEG_Play(void *context) +{ + SMPEG_Music *music = (SMPEG_Music *)context; + smpeg.SMPEG_enableaudio(music->mp3, 1); + smpeg.SMPEG_enablevideo(music->mp3, 0); + smpeg.SMPEG_rewind(music->mp3); + smpeg.SMPEG_play(music->mp3); + return 0; +} + +static SDL_bool SMPEG_IsPlaying(void *context) +{ + SMPEG_Music *music = (SMPEG_Music *)context; + return smpeg.SMPEG_status(music->mp3) == SMPEG_PLAYING ? SDL_TRUE : SDL_FALSE; +} + +static int SMPEG_GetAudio(void *context, void *data, int bytes) +{ + SMPEG_Music *music = (SMPEG_Music *)context; + Uint8 *stream = (Uint8 *)data; + int len = bytes; + int left = (len - smpeg.SMPEG_playAudio(music->mp3, stream, len)); + if (left > 0) { + stream += (len - left); + return left; +} + +static int SMPEG_Seek(void *context, double position) +{ + SMPEG_Music *music = (SMPEG_Music *)context; + smpeg.SMPEG_rewind(music->mp3); + smpeg.SMPEG_play(music->mp3); + if (position > 0.0) { + smpeg.SMPEG_skip(music->mp3, (float)position); + } + return 0; +} + +static void SMPEG_Stop(void *context) +{ + SMPEG_Music *music = (SMPEG_Music *)context; + smpeg.SMPEG_stop(music->mp3); +} + +static void SMPEG_Delete(void *context) +{ + SMPEG_Music *music = (SMPEG_Music *)context; + + smpeg.SMPEG_delete(music->mp3); + + if (music->freesrc) { + SDL_RWclose(music->src); + } + SDL_free(music); +} + +Mix_MusicInterface Mix_MusicInterface_SMPEG = +{ + "SMPEG", + MIX_MUSIC_SMPEG, + MUS_MP3, + SDL_FALSE, + SDL_FALSE, + + SMPEG_Load, + NULL, /* Open */ + SMPEG_CreateFromRW, + NULL, /* CreateFromFile */ + SMPEG_SetVolume, + SMPEG_Play, + SMPEG_IsPlaying, + SMPEG_GetAudio, + SMPEG_Seek, + NULL, /* Pause */ + NULL, /* Resume */ + SMPEG_Stop, + SMPEG_Delete, + NULL, /* Close */ + SMPEG_Unload, +}; + +#endif /* MUSIC_MP3_SMPEG */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_smpeg.h b/music_smpeg.h new file mode 100644 index 0000000..ddea251 --- /dev/null +++ b/music_smpeg.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports playing MP3 files with smpeg */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_SMPEG; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_timidity.c b/music_timidity.c new file mode 100644 index 0000000..bca278b --- /dev/null +++ b/music_timidity.c @@ -0,0 +1,220 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports playing MIDI files with timidity */ + +#ifdef MUSIC_MID_TIMIDITY + +#include "music_timidity.h" + +#include "timidity/timidity.h" + + +typedef struct +{ + int play_count; + MidiSong *song; + SDL_AudioStream *stream; + void *buffer; + Sint32 buffer_size; +} TIMIDITY_Music; + + +static int TIMIDITY_Seek(void *context, double position); +static void TIMIDITY_Delete(void *context); + +static int TIMIDITY_Open(const SDL_AudioSpec *spec) +{ + return Timidity_Init(); +} + +static void TIMIDITY_Close(void) +{ + Timidity_Exit(); +} + +void *TIMIDITY_CreateFromRW(SDL_RWops *src, int freesrc) +{ + TIMIDITY_Music *music; + SDL_AudioSpec spec; + SDL_bool need_stream = SDL_FALSE; + + music = (TIMIDITY_Music *)SDL_calloc(1, sizeof(*music)); + if (!music) { + SDL_OutOfMemory(); + return NULL; + } + + SDL_memcpy(&spec, &music_spec, sizeof(spec)); + if (spec.channels > 2) { + need_stream = SDL_TRUE; + spec.channels = 2; + } + music->song = Timidity_LoadSong(src, &spec); + if (!music->song) { + TIMIDITY_Delete(music); + return NULL; + } + + if (need_stream) { + music->stream = SDL_NewAudioStream(spec.format, spec.channels, spec.freq, + music_spec.format, music_spec.channels, music_spec.freq); + if (!music->stream) { + TIMIDITY_Delete(music); + return NULL; + } + + music->buffer_size = spec.samples * (SDL_AUDIO_BITSIZE(spec.format) / 8) * spec.channels; + music->buffer = SDL_malloc(music->buffer_size); + if (!music->buffer) { + SDL_OutOfMemory(); + TIMIDITY_Delete(music); + return NULL; + } + } + + if (freesrc) { + SDL_RWclose(src); + } + return music; +} + +static void TIMIDITY_SetVolume(void *context, int volume) +{ + TIMIDITY_Music *music = (TIMIDITY_Music *)context; + Timidity_SetVolume(music->song, volume); +} + +static int TIMIDITY_Play(void *context, int play_count) +{ + TIMIDITY_Music *music = (TIMIDITY_Music *)context; + music->play_count = play_count; + Timidity_Start(music->song); + return TIMIDITY_Seek(music, 0.0); +} + +static int TIMIDITY_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + TIMIDITY_Music *music = (TIMIDITY_Music *)context; + int filled, amount, expected; + + if (music->stream) { + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + if (music->stream) { + expected = music->buffer_size; + amount = Timidity_PlaySome(music->song, music->buffer, music->buffer_size); + if (SDL_AudioStreamPut(music->stream, music->buffer, amount) < 0) { + return -1; + } + } else { + expected = bytes; + amount = Timidity_PlaySome(music->song, data, bytes); + } + + if (amount < expected) { + if (music->play_count == 1) { + /* We didn't consume anything and we're done */ + music->play_count = 0; + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + if (TIMIDITY_Play(music, play_count) < 0) { + return -1; + } + } + } + if (music->stream) { + /* We'll pick it up from the stream next time around */ + return 0; + } else { + /* We wrote output data */ + return amount; + } +} +static int TIMIDITY_GetAudio(void *context, void *data, int bytes) +{ + return music_pcm_getaudio(context, data, bytes, MIX_MAX_VOLUME, TIMIDITY_GetSome); +} + +static int TIMIDITY_Seek(void *context, double position) +{ + TIMIDITY_Music *music = (TIMIDITY_Music *)context; + Timidity_Seek(music->song, (Uint32)(position * 1000)); + return 0; +} + +static void TIMIDITY_Delete(void *context) +{ + TIMIDITY_Music *music = (TIMIDITY_Music *)context; + + if (music->song) { + Timidity_FreeSong(music->song); + } + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } + if (music->buffer) { + SDL_free(music->buffer); + } + SDL_free(music); +} + +Mix_MusicInterface Mix_MusicInterface_TIMIDITY = +{ + "TIMIDITY", + MIX_MUSIC_TIMIDITY, + MUS_MID, + SDL_FALSE, + SDL_FALSE, + + NULL, /* Load */ + TIMIDITY_Open, + TIMIDITY_CreateFromRW, + NULL, /* CreateFromFile */ + TIMIDITY_SetVolume, + TIMIDITY_Play, + NULL, /* IsPlaying */ + TIMIDITY_GetAudio, + TIMIDITY_Seek, + NULL, /* Pause */ + NULL, /* Resume */ + NULL, /* Stop */ + TIMIDITY_Delete, + TIMIDITY_Close, + NULL, /* Unload */ +}; + +#endif /* MUSIC_MID_TIMIDITY */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_timidity.h b/music_timidity.h new file mode 100644 index 0000000..62301d8 --- /dev/null +++ b/music_timidity.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports playing MIDI files with timidity */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_TIMIDITY; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_wav.c b/music_wav.c new file mode 100644 index 0000000..5eb34b1 --- /dev/null +++ b/music_wav.c @@ -0,0 +1,638 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifdef MUSIC_WAV + +/* This file supports streaming WAV files */ + +#include "music_wav.h" + + +typedef struct { + SDL_bool active; + Uint32 start; + Uint32 stop; + Uint32 initial_play_count; + Uint32 current_play_count; +} WAVLoopPoint; + +typedef struct { + SDL_RWops *src; + SDL_bool freesrc; + SDL_AudioSpec spec; + int volume; + int play_count; + Sint64 start; + Sint64 stop; + Uint8 *buffer; + SDL_AudioStream *stream; + int numloops; + WAVLoopPoint *loops; +} WAV_Music; + +/* + Taken with permission from SDL_wave.h, part of the SDL library, + available at: http://www.libsdl.org/ + and placed under the same license as this mixer library. +*/ + +/* WAVE files are little-endian */ + +/*******************************************/ +/* Define values for Microsoft WAVE format */ +/*******************************************/ +#define RIFF 0x46464952 /* "RIFF" */ +#define WAVE 0x45564157 /* "WAVE" */ +#define FMT 0x20746D66 /* "fmt " */ +#define DATA 0x61746164 /* "data" */ +#define SMPL 0x6c706d73 /* "smpl" */ +#define PCM_CODE 1 +#define ADPCM_CODE 2 +#define WAVE_MONO 1 +#define WAVE_STEREO 2 + +typedef struct { +/* Not saved in the chunk we read: + Uint32 chunkID; + Uint32 chunkLen; +*/ + Uint16 encoding; + Uint16 channels; /* 1 = mono, 2 = stereo */ + Uint32 frequency; /* One of 11025, 22050, or 44100 Hz */ + Uint32 byterate; /* Average bytes per second */ + Uint16 blockalign; /* Bytes per sample block */ + Uint16 bitspersample; /* One of 8, 12, 16, or 4 for ADPCM */ +} WaveFMT; + +typedef struct { + Uint32 identifier; + Uint32 type; + Uint32 start; + Uint32 end; + Uint32 fraction; + Uint32 play_count; +} SampleLoop; + +typedef struct { +/* Not saved in the chunk we read: + Uint32 chunkID; + Uint32 chunkLen; +*/ + Uint32 manufacturer; + Uint32 product; + Uint32 sample_period; + Uint32 MIDI_unity_note; + Uint32 MIDI_pitch_fraction; + Uint32 SMTPE_format; + Uint32 SMTPE_offset; + Uint32 sample_loops; + Uint32 sampler_data; + SampleLoop loops[1]; +} SamplerChunk; + +/*********************************************/ +/* Define values for AIFF (IFF audio) format */ +/*********************************************/ +#define FORM 0x4d524f46 /* "FORM" */ +#define AIFF 0x46464941 /* "AIFF" */ +#define SSND 0x444e5353 /* "SSND" */ +#define COMM 0x4d4d4f43 /* "COMM" */ + + +/* Function to load the WAV/AIFF stream */ +static SDL_bool LoadWAVMusic(WAV_Music *wave); +static SDL_bool LoadAIFFMusic(WAV_Music *wave); + +static void WAV_Delete(void *context); + +/* Load a WAV stream from the given RWops object */ +static void *WAV_CreateFromRW(SDL_RWops *src, int freesrc) +{ + WAV_Music *music; + Uint32 magic; + SDL_bool loaded = SDL_FALSE; + + music = (WAV_Music *)SDL_calloc(1, sizeof(*music)); + if (!music) { + SDL_OutOfMemory(); + return NULL; + } + music->src = src; + music->volume = MIX_MAX_VOLUME; + + magic = SDL_ReadLE32(src); + if (magic == RIFF || magic == WAVE) { + loaded = LoadWAVMusic(music); + } else if (magic == FORM) { + loaded = LoadAIFFMusic(music); + } else { + Mix_SetError("Unknown WAVE format"); + } + if (!loaded) { + SDL_free(music); + return NULL; + } + music->buffer = (Uint8*)SDL_malloc(music->spec.size); + if (!music->buffer) { + WAV_Delete(music); + return NULL; + } + music->stream = SDL_NewAudioStream( + music->spec.format, music->spec.channels, music->spec.freq, + music_spec.format, music_spec.channels, music_spec.freq); + if (!music->stream) { + WAV_Delete(music); + return NULL; + } + + music->freesrc = freesrc; + return music; +} + +static void WAV_SetVolume(void *context, int volume) +{ + WAV_Music *music = (WAV_Music *)context; + music->volume = volume; +} + +/* Start playback of a given WAV stream */ +static int WAV_Play(void *context, int play_count) +{ + WAV_Music *music = (WAV_Music *)context; + int i; + for (i = 0; i < music->numloops; ++i) { + WAVLoopPoint *loop = &music->loops[i]; + loop->active = SDL_TRUE; + loop->current_play_count = loop->initial_play_count; + } + music->play_count = play_count; + if (SDL_RWseek(music->src, music->start, RW_SEEK_SET) < 0) { + return -1; + } + return 0; +} + +/* Play some of a stream previously started with WAV_Play() */ +static int WAV_GetSome(void *context, void *data, int bytes, SDL_bool *done) +{ + WAV_Music *music = (WAV_Music *)context; + Sint64 pos, stop; + WAVLoopPoint *loop; + Sint64 loop_start; + Sint64 loop_stop; + SDL_bool looped = SDL_FALSE; + int i; + int filled, amount, result; + + filled = SDL_AudioStreamGet(music->stream, data, bytes); + if (filled != 0) { + return filled; + } + + if (!music->play_count) { + /* All done */ + *done = SDL_TRUE; + return 0; + } + + pos = SDL_RWtell(music->src); + stop = music->stop; + loop = NULL; + for (i = 0; i < music->numloops; ++i) { + loop = &music->loops[i]; + if (loop->active) { + const int bytes_per_sample = (SDL_AUDIO_BITSIZE(music->spec.format) / 8) * music->spec.channels; + loop_start = music->start + loop->start * bytes_per_sample; + loop_stop = music->start + (loop->stop + 1) * bytes_per_sample; + if (pos >= loop_start && pos < loop_stop) + { + stop = loop_stop; + break; + } + } + loop = NULL; + } + + amount = music->spec.size; + if ((stop - pos) < amount) { + amount = (int)(stop - pos); + } + amount = (int)SDL_RWread(music->src, music->buffer, 1, amount); + if (amount > 0) { + result = SDL_AudioStreamPut(music->stream, music->buffer, amount); + if (result < 0) { + return -1; + } + } else { + /* We might be looping, continue */ + } + + if (loop && SDL_RWtell(music->src) >= stop) { + if (loop->current_play_count == 1) { + loop->active = SDL_FALSE; + } else { + if (loop->current_play_count > 0) { + --loop->current_play_count; + } + SDL_RWseek(music->src, loop_start, RW_SEEK_SET); + looped = SDL_TRUE; + } + } + + if (!looped && SDL_RWtell(music->src) >= music->stop) { + if (music->play_count == 1) { + music->play_count = 0; + SDL_AudioStreamFlush(music->stream); + } else { + int play_count = -1; + if (music->play_count > 0) { + play_count = (music->play_count - 1); + } + if (WAV_Play(music, play_count) < 0) { + return -1; + } + } + } + + /* We'll get called again in the case where we looped or have more data */ + return 0; +} + +static int WAV_GetAudio(void *context, void *data, int bytes) +{ + WAV_Music *music = (WAV_Music *)context; + return music_pcm_getaudio(context, data, bytes, music->volume, WAV_GetSome); +} + +/* Close the given WAV stream */ +static void WAV_Delete(void *context) +{ + WAV_Music *music = (WAV_Music *)context; + + /* Clean up associated data */ + if (music->loops) { + SDL_free(music->loops); + } + if (music->stream) { + SDL_FreeAudioStream(music->stream); + } + if (music->buffer) { + SDL_free(music->buffer); + } + if (music->freesrc) { + SDL_RWclose(music->src); + } + SDL_free(music); +} + +static SDL_bool ParseFMT(WAV_Music *wave, Uint32 chunk_length) +{ + SDL_AudioSpec *spec = &wave->spec; + WaveFMT *format; + Uint8 *data; + SDL_bool loaded = SDL_FALSE; + + if (chunk_length < sizeof(*format)) { + Mix_SetError("Wave format chunk too small"); + return SDL_FALSE; + } + + data = (Uint8 *)SDL_malloc(chunk_length); + if (!data) { + Mix_SetError("Out of memory"); + return SDL_FALSE; + } + if (!SDL_RWread(wave->src, data, chunk_length, 1)) { + Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length); + return SDL_FALSE; + } + format = (WaveFMT *)data; + + /* Decode the audio data format */ + switch (SDL_SwapLE16(format->encoding)) { + case PCM_CODE: + /* We can understand this */ + break; + default: + Mix_SetError("Unknown WAVE data format"); + goto done; + } + spec->freq = SDL_SwapLE32(format->frequency); + switch (SDL_SwapLE16(format->bitspersample)) { + case 8: + spec->format = AUDIO_U8; + break; + case 16: + spec->format = AUDIO_S16; + break; + default: + Mix_SetError("Unknown PCM data format"); + goto done; + } + spec->channels = (Uint8) SDL_SwapLE16(format->channels); + spec->samples = 4096; /* Good default buffer size */ + /* SDL_CalculateAudioSpec */ + spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8; + spec->size *= spec->channels; + spec->size *= spec->samples; + + loaded = SDL_TRUE; + +done: + SDL_free(data); + return loaded; +} + +static SDL_bool ParseDATA(WAV_Music *wave, Uint32 chunk_length) +{ + wave->start = SDL_RWtell(wave->src); + wave->stop = wave->start + chunk_length; + SDL_RWseek(wave->src, chunk_length, RW_SEEK_CUR); + return SDL_TRUE; +} + +static SDL_bool AddLoopPoint(WAV_Music *wave, Uint32 play_count, Uint32 start, Uint32 stop) +{ + WAVLoopPoint *loop; + WAVLoopPoint *loops = SDL_realloc(wave->loops, (wave->numloops + 1)*sizeof(*wave->loops)); + if (!loops) { + Mix_SetError("Out of memory"); + return SDL_FALSE; + } + + loop = &loops[ wave->numloops ]; + loop->start = start; + loop->stop = stop; + loop->initial_play_count = play_count; + loop->current_play_count = play_count; + + wave->loops = loops; + ++wave->numloops; + return SDL_TRUE; +} + +static SDL_bool ParseSMPL(WAV_Music *wave, Uint32 chunk_length) +{ + SamplerChunk *chunk; + Uint8 *data; + Uint32 i; + SDL_bool loaded = SDL_FALSE; + + data = (Uint8 *)SDL_malloc(chunk_length); + if (!data) { + Mix_SetError("Out of memory"); + return SDL_FALSE; + } + if (!SDL_RWread(wave->src, data, chunk_length, 1)) { + Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length); + return SDL_FALSE; + } + chunk = (SamplerChunk *)data; + + for (i = 0; i < SDL_SwapLE32(chunk->sample_loops); ++i) { + const Uint32 LOOP_TYPE_FORWARD = 0; + Uint32 loop_type = SDL_SwapLE32(chunk->loops[i].type); + if (loop_type == LOOP_TYPE_FORWARD) { + AddLoopPoint(wave, SDL_SwapLE32(chunk->loops[i].play_count), SDL_SwapLE32(chunk->loops[i].start), SDL_SwapLE32(chunk->loops[i].end)); + } + } + + loaded = SDL_TRUE; + SDL_free(data); + return loaded; +} + +static SDL_bool LoadWAVMusic(WAV_Music *wave) +{ + SDL_RWops *src = wave->src; + Uint32 chunk_type; + Uint32 chunk_length; + SDL_bool found_FMT = SDL_FALSE; + SDL_bool found_DATA = SDL_FALSE; + + /* WAV magic header */ + Uint32 wavelen; + Uint32 WAVEmagic; + + /* Check the magic header */ + wavelen = SDL_ReadLE32(src); + WAVEmagic = SDL_ReadLE32(src); + + /* Read the chunks */ + for (; ;) { + chunk_type = SDL_ReadLE32(src); + chunk_length = SDL_ReadLE32(src); + + if (chunk_length == 0) + break; + + switch (chunk_type) + { + case FMT: + found_FMT = SDL_TRUE; + if (!ParseFMT(wave, chunk_length)) + return SDL_FALSE; + break; + case DATA: + found_DATA = SDL_TRUE; + if (!ParseDATA(wave, chunk_length)) + return SDL_FALSE; + break; + case SMPL: + if (!ParseSMPL(wave, chunk_length)) + return SDL_FALSE; + break; + default: + SDL_RWseek(src, chunk_length, RW_SEEK_CUR); + break; + } + } + + if (!found_FMT) { + Mix_SetError("Bad WAV file (no FMT chunk)"); + return SDL_FALSE; + } + + if (!found_DATA) { + Mix_SetError("Bad WAV file (no DATA chunk)"); + return SDL_FALSE; + } + + return SDL_TRUE; +} + +/* I couldn't get SANE_to_double() to work, so I stole this from libsndfile. + * I don't pretend to fully understand it. + */ + +static Uint32 SANE_to_Uint32 (Uint8 *sanebuf) +{ + /* Negative number? */ + if (sanebuf[0] & 0x80) + return 0; + + /* Less than 1? */ + if (sanebuf[0] <= 0x3F) + return 1; + + /* Way too big? */ + if (sanebuf[0] > 0x40) + return 0x4000000; + + /* Still too big? */ + if (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C) + return 800000000; + + return ((sanebuf[2] << 23) | (sanebuf[3] << 15) | (sanebuf[4] << 7) | + (sanebuf[5] >> 1)) >> (29 - sanebuf[1]); +} + +static SDL_bool LoadAIFFMusic(WAV_Music *wave) +{ + SDL_RWops *src = wave->src; + SDL_AudioSpec *spec = &wave->spec; + SDL_bool found_SSND = SDL_FALSE; + SDL_bool found_COMM = SDL_FALSE; + + Uint32 chunk_type; + Uint32 chunk_length; + Sint64 next_chunk; + + /* AIFF magic header */ + Uint32 AIFFmagic; + /* SSND chunk */ + Uint32 offset; + Uint32 blocksize; + /* COMM format chunk */ + Uint16 channels = 0; + Uint32 numsamples = 0; + Uint16 samplesize = 0; + Uint8 sane_freq[10]; + Uint32 frequency = 0; + + /* Check the magic header */ + chunk_length = SDL_ReadBE32(src); + AIFFmagic = SDL_ReadLE32(src); + if (AIFFmagic != AIFF) { + Mix_SetError("Unrecognized file type (not AIFF)"); + return SDL_FALSE; + } + + /* From what I understand of the specification, chunks may appear in + * any order, and we should just ignore unknown ones. + * + * TODO: Better sanity-checking. E.g. what happens if the AIFF file + * contains compressed sound data? + */ + do { + chunk_type = SDL_ReadLE32(src); + chunk_length = SDL_ReadBE32(src); + next_chunk = SDL_RWtell(src) + chunk_length; + + /* Paranoia to avoid infinite loops */ + if (chunk_length == 0) + break; + + switch (chunk_type) { + case SSND: + found_SSND = SDL_TRUE; + offset = SDL_ReadBE32(src); + blocksize = SDL_ReadBE32(src); + wave->start = SDL_RWtell(src) + offset; + break; + + case COMM: + found_COMM = SDL_TRUE; + + /* Read the audio data format chunk */ + channels = SDL_ReadBE16(src); + numsamples = SDL_ReadBE32(src); + samplesize = SDL_ReadBE16(src); + SDL_RWread(src, sane_freq, sizeof(sane_freq), 1); + frequency = SANE_to_Uint32(sane_freq); + break; + + default: + break; + } + } while ((!found_SSND || !found_COMM) + && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != -1); + + if (!found_SSND) { + Mix_SetError("Bad AIFF file (no SSND chunk)"); + return SDL_FALSE; + } + + if (!found_COMM) { + Mix_SetError("Bad AIFF file (no COMM chunk)"); + return SDL_FALSE; + } + + wave->stop = wave->start + channels * numsamples * (samplesize / 8); + + /* Decode the audio data format */ + SDL_memset(spec, 0, (sizeof *spec)); + spec->freq = frequency; + switch (samplesize) { + case 8: + spec->format = AUDIO_S8; + break; + case 16: + spec->format = AUDIO_S16MSB; + break; + default: + Mix_SetError("Unknown samplesize in data format"); + return SDL_FALSE; + } + spec->channels = (Uint8) channels; + spec->samples = 4096; /* Good default buffer size */ + + return SDL_TRUE; +} + +Mix_MusicInterface Mix_MusicInterface_WAV = +{ + "WAVE", + MIX_MUSIC_WAVE, + MUS_WAV, + SDL_FALSE, + SDL_FALSE, + + NULL, /* Load */ + NULL, /* Open */ + WAV_CreateFromRW, + NULL, /* CreateFromFile */ + WAV_SetVolume, + WAV_Play, + NULL, /* IsPlaying */ + WAV_GetAudio, + NULL, /* Seek */ + NULL, /* Pause */ + NULL, /* Resume */ + NULL, /* Stop */ + WAV_Delete, + NULL, /* Close */ + NULL, /* Unload */ +}; + +#endif /* MUSIC_WAV */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/music_wav.h b/music_wav.h new file mode 100644 index 0000000..1deacfb --- /dev/null +++ b/music_wav.h @@ -0,0 +1,28 @@ +/* + SDL_mixer: An audio mixer library based on the SDL library + Copyright (C) 1997-2017 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This file supports streaming WAV files */ + +#include "music.h" + +extern Mix_MusicInterface Mix_MusicInterface_WAV; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/native_midi/native_midi.h b/native_midi/native_midi.h index 1ed050e..92d2535 100644 --- a/native_midi/native_midi.h +++ b/native_midi/native_midi.h @@ -22,16 +22,18 @@ #ifndef _NATIVE_MIDI_H_ #define _NATIVE_MIDI_H_ -#include +#include "SDL_rwops.h" typedef struct _NativeMidiSong NativeMidiSong; -int native_midi_detect(); +int native_midi_detect(void); NativeMidiSong *native_midi_loadsong_RW(SDL_RWops *src, int freesrc); void native_midi_freesong(NativeMidiSong *song); void native_midi_start(NativeMidiSong *song, int loops); -void native_midi_stop(); -int native_midi_active(); +void native_midi_pause(void); +void native_midi_resume(void); +void native_midi_stop(void); +int native_midi_active(void); void native_midi_setvolume(int volume); const char *native_midi_error(void); diff --git a/native_midi/native_midi_common.c b/native_midi/native_midi_common.c index 7726349..68f898d 100644 --- a/native_midi/native_midi_common.c +++ b/native_midi/native_midi_common.c @@ -28,10 +28,8 @@ #include #include - -/* The maximum number of midi tracks that we can handle -#define MIDI_TRACKS 32 */ - +/* The constant 'MThd' */ +#define MIDI_MAGIC 0x4d546864 /* A single midi track as read from the midi file */ typedef struct @@ -230,9 +228,11 @@ return NULL; track = (MIDIEvent**) calloc(1, sizeof(MIDIEvent*) * mididata->nTracks); - if (NULL == track) + { + free(head); return NULL; + } /* First, convert all tracks to MIDIEvent lists */ for (trackID = 0; trackID < mididata->nTracks; trackID++) @@ -293,7 +293,7 @@ /* Make sure this is really a MIDI file */ SDL_RWread(src, &ID, 1, 4); - if (BE_LONG(ID) != 'MThd') + if (BE_LONG(ID) != MIDI_MAGIC) return 0; /* Header size must be 6 */ @@ -381,7 +381,11 @@ *division = mididata->division; eventList = MIDItoStream(mididata); - + if (eventList == NULL) + { + free(mididata); + return NULL; + } for(trackID = 0; trackID < mididata->nTracks; trackID++) { if (mididata->track[trackID].data) diff --git a/native_midi/native_midi_haiku.cpp b/native_midi/native_midi_haiku.cpp index 3d52491..81b847e 100644 --- a/native_midi/native_midi_haiku.cpp +++ b/native_midi/native_midi_haiku.cpp @@ -206,7 +206,7 @@ char lasterr[1024]; -int native_midi_detect() +int native_midi_detect(void) { status_t res = synth.EnableInput(true, false); return res == B_OK; @@ -253,6 +253,7 @@ delete song->store; delete song; song = 0; } + void native_midi_start(NativeMidiSong *song, int loops) { native_midi_stop(); @@ -261,7 +262,16 @@ song->store->Start(); currentSong = song; } -void native_midi_stop() + +void native_midi_pause(void) +{ +} + +void native_midi_resume(void) +{ +} + +void native_midi_stop(void) { if (currentSong == NULL) return; currentSong->store->Stop(); @@ -270,7 +280,8 @@ usleep(1000); currentSong = NULL; } -int native_midi_active() + +int native_midi_active(void) { if (currentSong == NULL) return 0; return currentSong->store->IsPlaying(); diff --git a/native_midi/native_midi_mac.c b/native_midi/native_midi_mac.c index 0a63286..24a3942 100644 --- a/native_midi/native_midi_mac.c +++ b/native_midi/native_midi_mac.c @@ -20,6 +20,7 @@ */ #include "SDL_config.h" #include "SDL_endian.h" +#include "../mixer.h" #if __MACOS__ /*|| __MACOSX__ */ @@ -82,7 +83,7 @@ /* Check whether QuickTime is available */ -int native_midi_detect() +int native_midi_detect(void) { /* TODO */ return 1; @@ -187,7 +188,7 @@ assert (loops == 0); SDL_PauseAudio(1); - SDL_UnlockAudio(); + Mix_UnlockAudio(); /* First, stop the currently playing music */ native_midi_stop(); @@ -237,11 +238,19 @@ } done: - SDL_LockAudio(); + Mix_LockAudio(); SDL_PauseAudio(0); } -void native_midi_stop() +void native_midi_pause(void) +{ +} + +void native_midi_resume(void) +{ +} + +void native_midi_stop(void) { if (gTunePlayer == NULL) return; @@ -253,7 +262,7 @@ TuneUnroll(gTunePlayer); } -int native_midi_active() +int native_midi_active(void) { if (gTunePlayer != NULL) { diff --git a/native_midi/native_midi_macosx.c b/native_midi/native_midi_macosx.c index fa48680..6ee31e0 100644 --- a/native_midi/native_midi_macosx.c +++ b/native_midi/native_midi_macosx.c @@ -31,8 +31,9 @@ #include #include +#include "SDL_endian.h" #include "../SDL_mixer.h" -#include "SDL_endian.h" +#include "../mixer.h" #include "native_midi.h" /* Native Midi song */ @@ -149,7 +150,7 @@ } -int native_midi_detect() +int native_midi_detect(void) { return 1; /* always available. */ } @@ -264,7 +265,7 @@ return; SDL_PauseAudio(1); - SDL_UnlockAudio(); + Mix_UnlockAudio(); if (currentsong) MusicPlayerStop(currentsong->player); @@ -282,23 +283,31 @@ latched_volume++; /* just make this not match. */ native_midi_setvolume(vol); - SDL_LockAudio(); + Mix_LockAudio(); SDL_PauseAudio(0); } -void native_midi_stop() +void native_midi_pause(void) +{ +} + +void native_midi_resume(void) +{ +} + +void native_midi_stop(void) { if (currentsong) { SDL_PauseAudio(1); - SDL_UnlockAudio(); + Mix_UnlockAudio(); MusicPlayerStop(currentsong->player); currentsong = NULL; - SDL_LockAudio(); + Mix_LockAudio(); SDL_PauseAudio(0); } } -int native_midi_active() +int native_midi_active(void) { MusicTimeStamp currentTime = 0; if (currentsong == NULL) diff --git a/native_midi/native_midi_win32.c b/native_midi/native_midi_win32.c index e277b61..44bb055 100644 --- a/native_midi/native_midi_win32.c +++ b/native_midi/native_midi_win32.c @@ -189,7 +189,7 @@ } } -int native_midi_detect() +int native_midi_detect(void) { MMRESULT merr; HMIDISTRM MidiStream; @@ -272,7 +272,21 @@ } } -void native_midi_stop() +void native_midi_pause(void) +{ + if (!hMidiStream) + return; + midiStreamPause(hMidiStream); +} + +void native_midi_resume(void) +{ + if (!hMidiStream) + return; + midiStreamRestart(hMidiStream); +} + +void native_midi_stop(void) { if (!hMidiStream) return; @@ -282,7 +296,7 @@ hMidiStream = NULL; } -int native_midi_active() +int native_midi_active(void) { return currentsong->MusicPlaying; } diff --git a/playmus.c b/playmus.c index ccf1fb0..8ff015d 100644 --- a/playmus.c +++ b/playmus.c @@ -1,6 +1,6 @@ /* PLAYMUS: A test application for the SDL mixer library. - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -20,7 +20,7 @@ */ /* Quiet windows compiler warnings */ -#define _CRT_SECURE_NO_WARNINGS +#define _CRT_SECURE_NO_WARNINGS /* $Id$ */ @@ -46,15 +46,15 @@ void CleanUp(int exitcode) { - if( Mix_PlayingMusic() ) { + if(Mix_PlayingMusic()) { Mix_FadeOutMusic(1500); SDL_Delay(1500); } - if ( music ) { + if (music) { Mix_FreeMusic(music); music = NULL; } - if ( audio_open ) { + if (audio_open) { Mix_CloseAudio(); audio_open = 0; } @@ -64,7 +64,7 @@ void Usage(char *argv0) { - fprintf(stderr, "Usage: %s [-i] [-l] [-8] [-r rate] [-c channels] [-b buffers] [-v N] [-rwops] \n", argv0); + SDL_Log("Usage: %s [-i] [-l] [-8] [-f32] [-r rate] [-c channels] [-b buffers] [-v N] [-rwops] \n", argv0); } void Menu(void) @@ -125,50 +125,53 @@ audio_buffers = 4096; /* Check command line usage */ - for ( i=1; argv[i] && (*argv[i] == '-'); ++i ) { - if ( (strcmp(argv[i], "-r") == 0) && argv[i+1] ) { + for (i=1; argv[i] && (*argv[i] == '-'); ++i) { + if ((strcmp(argv[i], "-r") == 0) && argv[i+1]) { ++i; audio_rate = atoi(argv[i]); } else - if ( strcmp(argv[i], "-m") == 0 ) { + if (strcmp(argv[i], "-m") == 0) { audio_channels = 1; } else - if ( (strcmp(argv[i], "-c") == 0) && argv[i+1] ) { + if ((strcmp(argv[i], "-c") == 0) && argv[i+1]) { ++i; audio_channels = atoi(argv[i]); } else - if ( (strcmp(argv[i], "-b") == 0) && argv[i+1] ) { + if ((strcmp(argv[i], "-b") == 0) && argv[i+1]) { ++i; audio_buffers = atoi(argv[i]); } else - if ( (strcmp(argv[i], "-v") == 0) && argv[i+1] ) { + if ((strcmp(argv[i], "-v") == 0) && argv[i+1]) { ++i; audio_volume = atoi(argv[i]); } else - if ( strcmp(argv[i], "-l") == 0 ) { + if (strcmp(argv[i], "-l") == 0) { looping = -1; } else - if ( strcmp(argv[i], "-i") == 0 ) { + if (strcmp(argv[i], "-i") == 0) { interactive = 1; } else - if ( strcmp(argv[i], "-8") == 0 ) { + if (strcmp(argv[i], "-8") == 0) { audio_format = AUDIO_U8; } else - if ( strcmp(argv[i], "-rwops") == 0 ) { + if (strcmp(argv[i], "-f32") == 0) { + audio_format = AUDIO_F32; + } else + if (strcmp(argv[i], "-rwops") == 0) { rwops = 1; } else { Usage(argv[0]); return(1); } } - if ( ! argv[i] ) { + if (! argv[i]) { Usage(argv[0]); return(1); } /* Initialize the SDL library */ - if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) { - fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError()); + if (SDL_Init(SDL_INIT_AUDIO) < 0) { + SDL_Log("Couldn't initialize SDL: %s\n",SDL_GetError()); return(255); } @@ -179,15 +182,15 @@ /* Open the audio device */ if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) { - fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); + SDL_Log("Couldn't open audio: %s\n", SDL_GetError()); return(2); } else { Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels); - printf("Opened audio at %d Hz %d bit %s (%s), %d bytes audio buffer\n", audio_rate, + SDL_Log("Opened audio at %d Hz %d bit%s %s %d bytes audio buffer\n", audio_rate, (audio_format&0xFF), + (SDL_AUDIO_ISFLOAT(audio_format) ? " (float)" : ""), (audio_channels > 2) ? "surround" : (audio_channels > 1) ? "stereo" : "mono", - (audio_format&0x1000) ? "BE" : "LE", - audio_buffers ); + audio_buffers); } audio_open = 1; @@ -201,21 +204,21 @@ next_track = 0; /* Load the requested music file */ - if ( rwops ) { + if (rwops) { music = Mix_LoadMUS_RW(SDL_RWFromFile(argv[i], "rb"), SDL_TRUE); } else { music = Mix_LoadMUS(argv[i]); } - if ( music == NULL ) { - fprintf(stderr, "Couldn't load %s: %s\n", + if (music == NULL) { + SDL_Log("Couldn't load %s: %s\n", argv[i], SDL_GetError()); CleanUp(2); } /* Play and then exit */ - printf("Playing %s\n", argv[i]); + SDL_Log("Playing %s\n", argv[i]); Mix_FadeInMusic(music,looping,2000); - while ( !next_track && (Mix_PlayingMusic() || Mix_PausedMusic()) ) { + while (!next_track && (Mix_PlayingMusic() || Mix_PausedMusic())) { if(interactive) Menu(); else @@ -226,7 +229,7 @@ /* If the user presses Ctrl-C more than once, exit. */ SDL_Delay(500); - if ( next_track > 1 ) break; + if (next_track > 1) break; i++; } @@ -235,3 +238,5 @@ /* Not reached, but fixes compiler warnings */ return 0; } + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/playwave.c b/playwave.c index a35c63e..ac63636 100644 --- a/playwave.c +++ b/playwave.c @@ -1,6 +1,6 @@ /* PLAYWAVE: A test application for the SDL mixer library. - Copyright (C) 1997-2016 Sam Lantinga + Copyright (C) 1997-2017 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -65,19 +65,19 @@ static void output_test_warnings(void) { #if (defined TEST_MIX_CHANNELFINISHED) - fprintf(stderr, "Warning: TEST_MIX_CHANNELFINISHED is enabled in this binary...\n"); + SDL_Log("Warning: TEST_MIX_CHANNELFINISHED is enabled in this binary...\n"); #endif #if (defined TEST_MIX_PANNING) - fprintf(stderr, "Warning: TEST_MIX_PANNING is enabled in this binary...\n"); + SDL_Log("Warning: TEST_MIX_PANNING is enabled in this binary...\n"); #endif #if (defined TEST_MIX_VERSIONS) - fprintf(stderr, "Warning: TEST_MIX_VERSIONS is enabled in this binary...\n"); + SDL_Log("Warning: TEST_MIX_VERSIONS is enabled in this binary...\n"); #endif #if (defined TEST_MIX_DISTANCE) - fprintf(stderr, "Warning: TEST_MIX_DISTANCE is enabled in this binary...\n"); + SDL_Log("Warning: TEST_MIX_DISTANCE is enabled in this binary...\n"); #endif #if (defined TEST_MIX_POSITION) - fprintf(stderr, "Warning: TEST_MIX_POSITION is enabled in this binary...\n"); + SDL_Log("Warning: TEST_MIX_POSITION is enabled in this binary...\n"); #endif } @@ -91,15 +91,15 @@ { int i, total; - printf("Supported decoders...\n"); + SDL_Log("Supported decoders...\n"); total = Mix_GetNumChunkDecoders(); for (i = 0; i < total; i++) { - fprintf(stderr, " - chunk decoder: %s\n", Mix_GetChunkDecoder(i)); + SDL_Log(" - chunk decoder: %s\n", Mix_GetChunkDecoder(i)); } total = Mix_GetNumMusicDecoders(); for (i = 0; i < total; i++) { - fprintf(stderr, " - music decoder: %s\n", Mix_GetMusicDecoder(i)); + SDL_Log(" - music decoder: %s\n", Mix_GetMusicDecoder(i)); } } #endif @@ -109,8 +109,7 @@ static void output_versions(const char *libname, const SDL_version *compiled, const SDL_version *linked) { - fprintf(stderr, - "This program was compiled against %s %d.%d.%d,\n" + SDL_Log("This program was compiled against %s %d.%d.%d,\n" " and is dynamically linked to %d.%d.%d.\n", libname, compiled->major, compiled->minor, compiled->patch, linked->major, linked->minor, linked->patch); @@ -134,12 +133,12 @@ #ifdef TEST_MIX_CHANNELFINISHED /* rcg06072001 */ static volatile int channel_is_done = 0; -static void channel_complete_callback(int chan) +static void SDLCALL channel_complete_callback (int chan) { Mix_Chunk *done_chunk = Mix_GetChunk(chan); - fprintf(stderr, "We were just alerted that Mixer channel #%d is done.\n", chan); - fprintf(stderr, "Channel's chunk pointer is (%p).\n", done_chunk); - fprintf(stderr, " Which %s correct.\n", (wave == done_chunk) ? "is" : "is NOT"); + SDL_Log("We were just alerted that Mixer channel #%d is done.\n", chan); + SDL_Log("Channel's chunk pointer is (%p).\n", done_chunk); + SDL_Log(" Which %s correct.\n", (wave == done_chunk) ? "is" : "is NOT"); channel_is_done = 1; } #endif @@ -169,20 +168,20 @@ if ((panningok) && (SDL_GetTicks() >= next_panning_update)) { panningok = Mix_SetPanning(0, leftvol, rightvol); if (!panningok) { - fprintf(stderr, "Mix_SetPanning(0, %d, %d) failed!\n", + SDL_Log("Mix_SetPanning(0, %d, %d) failed!\n", (int) leftvol, (int) rightvol); - fprintf(stderr, "Reason: [%s].\n", Mix_GetError()); + SDL_Log("Reason: [%s].\n", Mix_GetError()); } if ((leftvol == 255) || (leftvol == 0)) { if (leftvol == 255) - printf("All the way in the left speaker.\n"); + SDL_Log("All the way in the left speaker.\n"); leftincr *= -1; } if ((rightvol == 255) || (rightvol == 0)) { if (rightvol == 255) - printf("All the way in the right speaker.\n"); + SDL_Log("All the way in the right speaker.\n"); rightincr *= -1; } @@ -205,16 +204,16 @@ if ((distanceok) && (SDL_GetTicks() >= next_distance_update)) { distanceok = Mix_SetDistance(0, distance); if (!distanceok) { - fprintf(stderr, "Mix_SetDistance(0, %d) failed!\n", (int) distance); - fprintf(stderr, "Reason: [%s].\n", Mix_GetError()); + SDL_Log("Mix_SetDistance(0, %d) failed!\n", (int) distance); + SDL_Log("Reason: [%s].\n", Mix_GetError()); } if (distance == 0) { - printf("Distance at nearest point.\n"); + SDL_Log("Distance at nearest point.\n"); distincr *= -1; } else if (distance == 255) { - printf("Distance at furthest point.\n"); + SDL_Log("Distance at furthest point.\n"); distincr *= -1; } @@ -238,18 +237,18 @@ if ((positionok) && (SDL_GetTicks() >= next_position_update)) { positionok = Mix_SetPosition(0, angle, distance); if (!positionok) { - fprintf(stderr, "Mix_SetPosition(0, %d, %d) failed!\n", + SDL_Log("Mix_SetPosition(0, %d, %d) failed!\n", (int) angle, (int) distance); - fprintf(stderr, "Reason: [%s].\n", Mix_GetError()); + SDL_Log("Reason: [%s].\n", Mix_GetError()); } if (angle == 0) { - printf("Due north; now rotating clockwise...\n"); + SDL_Log("Due north; now rotating clockwise...\n"); angleincr = 1; } else if (angle == 360) { - printf("Due north; now rotating counter-clockwise...\n"); + SDL_Log("Due north; now rotating counter-clockwise...\n"); angleincr = -1; } @@ -258,11 +257,11 @@ if (distance < 0) { distance = 0; distincr = 3; - printf("Distance is very, very near. Stepping away by threes...\n"); + SDL_Log("Distance is very, very near. Stepping away by threes...\n"); } else if (distance > 255) { distance = 255; distincr = -3; - printf("Distance is very, very far. Stepping towards by threes...\n"); + SDL_Log("Distance is very, very far. Stepping towards by threes...\n"); } angle += angleincr; @@ -274,11 +273,11 @@ static void CleanUp(int exitcode) { - if ( wave ) { + if (wave) { Mix_FreeChunk(wave); wave = NULL; } - if ( audio_open ) { + if (audio_open) { Mix_CloseAudio(); audio_open = 0; } @@ -290,7 +289,7 @@ static void Usage(char *argv0) { - fprintf(stderr, "Usage: %s [-8] [-r rate] [-c channels] [-f] [-F] [-l] [-m] \n", argv0); + SDL_Log("Usage: %s [-8] [-f32] [-r rate] [-c channels] [-f] [-F] [-l] [-m] \n", argv0); } @@ -350,7 +349,7 @@ break; default: - fprintf(stderr, "Unhandled format in sample flipping.\n"); + SDL_Log("Unhandled format in sample flipping.\n"); return; } } @@ -378,42 +377,45 @@ audio_channels = 2; /* Check command line usage */ - for ( i=1; argv[i] && (*argv[i] == '-'); ++i ) { - if ( (strcmp(argv[i], "-r") == 0) && argv[i+1] ) { + for (i=1; argv[i] && (*argv[i] == '-'); ++i) { + if ((strcmp(argv[i], "-r") == 0) && argv[i+1]) { ++i; audio_rate = atoi(argv[i]); } else - if ( strcmp(argv[i], "-m") == 0 ) { + if (strcmp(argv[i], "-m") == 0) { audio_channels = 1; } else - if ( (strcmp(argv[i], "-c") == 0) && argv[i+1] ) { + if ((strcmp(argv[i], "-c") == 0) && argv[i+1]) { ++i; audio_channels = atoi(argv[i]); } else - if ( strcmp(argv[i], "-l") == 0 ) { + if (strcmp(argv[i], "-l") == 0) { loops = -1; } else - if ( strcmp(argv[i], "-8") == 0 ) { + if (strcmp(argv[i], "-8") == 0) { audio_format = AUDIO_U8; } else - if ( strcmp(argv[i], "-f") == 0 ) { /* rcg06122001 flip stereo */ + if (strcmp(argv[i], "-f32") == 0) { + audio_format = AUDIO_F32; + } else + if (strcmp(argv[i], "-f") == 0) { /* rcg06122001 flip stereo */ reverse_stereo = 1; } else - if ( strcmp(argv[i], "-F") == 0 ) { /* rcg06172001 flip sample */ + if (strcmp(argv[i], "-F") == 0) { /* rcg06172001 flip sample */ reverse_sample = 1; } else { Usage(argv[0]); return(1); } } - if ( ! argv[i] ) { + if (! argv[i]) { Usage(argv[0]); return(1); } /* Initialize the SDL library */ - if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) { - fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError()); + if (SDL_Init(SDL_INIT_AUDIO) < 0) { + SDL_Log("Couldn't initialize SDL: %s\n",SDL_GetError()); return(255); } #ifdef HAVE_SIGNAL_H @@ -423,16 +425,17 @@ /* Open the audio device */ if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, 4096) < 0) { - fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); + SDL_Log("Couldn't open audio: %s\n", SDL_GetError()); CleanUp(2); } else { Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels); - printf("Opened audio at %d Hz %d bit %s", audio_rate, + SDL_Log("Opened audio at %d Hz %d bit%s %s", audio_rate, (audio_format&0xFF), + (SDL_AUDIO_ISFLOAT(audio_format) ? " (float)" : ""), (audio_channels > 2) ? "surround" : (audio_channels > 1) ? "stereo" : "mono"); - if ( loops ) { - printf(" (looping)\n"); + if (loops) { + SDL_Log(" (looping)\n"); } else { putchar('\n'); } @@ -449,8 +452,8 @@ /* Load the requested wave file */ wave = Mix_LoadWAV(argv[i]); - if ( wave == NULL ) { - fprintf(stderr, "Couldn't load %s: %s\n", + if (wave == NULL) { + SDL_Log("Couldn't load %s: %s\n", argv[i], SDL_GetError()); CleanUp(2); } @@ -463,11 +466,11 @@ Mix_ChannelFinished(channel_complete_callback); #endif - if ( (!Mix_SetReverseStereo(MIX_CHANNEL_POST, reverse_stereo)) && - (reverse_stereo) ) + if ((!Mix_SetReverseStereo(MIX_CHANNEL_POST, reverse_stereo)) && + (reverse_stereo)) { - printf("Failed to set up reverse stereo effect!\n"); - printf("Reason: [%s].\n", Mix_GetError()); + SDL_Log("Failed to set up reverse stereo effect!\n"); + SDL_Log("Reason: [%s].\n", Mix_GetError()); } /* Play and then exit */ @@ -499,3 +502,4 @@ /* end of playwave.c ... */ +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/timidity/Android.mk b/timidity/Android.mk new file mode 100644 index 0000000..17585a7 --- /dev/null +++ b/timidity/Android.mk @@ -0,0 +1,24 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := timidity + +LOCAL_C_INCLUDES := + +LOCAL_CFLAGS := + +LOCAL_SRC_FILES += \ + common.c \ + instrum.c \ + mix.c \ + output.c \ + playmidi.c \ + readmidi.c \ + resample.c \ + tables.c \ + timidity.c + +LOCAL_SHARED_LIBRARIES := SDL2 + +include $(BUILD_STATIC_LIBRARY) diff --git a/timidity/CHANGES b/timidity/CHANGES new file mode 100644 index 0000000..ab79e99 --- /dev/null +++ b/timidity/CHANGES @@ -0,0 +1,77 @@ +This version of TiMidity should contain all the fixes from the +September 25 2003 SDL_mixer CVS snapshot. In addition, I've made some +changes of my own, e.g.: + +* All file access is done through SDL_RWops. This means the MIDI + stream no longer has to be a file. (The config file and instruments + still have to be though.) + +* Replacing of TiMidity's endian-handling with SDL's. + +* Removal of much unused or unnecessary code, such as + + + The "hooks" for putting a user interface onto TiMidity. + + The antialias filter. It wasn't active, and even at 4 kHz I + couldn't hear any difference when activating it. + + Removed all traces of LOOKUP_HACK and LOOKUP_INTERPOLATION. + According to the code comments they weren't very good anyway. + ("degrades sound quality noticeably"). I also removed the + disclaimer about the "8-bit uLaw to 16-bit PCM and the 13-bit-PCM + to 8-bit uLaw tables" disclaimer, since I believe those were the + tables I removed. + + Removed LOOKUP_SINE since it was already commented out. I think we + can count on our target audience having math co-processors + nowadays. + + Removed USE_LDEXP since it wasn't being used and "it doesn't make + much of a difference either way". + + Removed decompress hack from open_file() since it didn't look very + portable. + + Removed heaps of unnecessary constants. + + Removed unused functions. + + Assume that LINEAR_INTERPOLATION is always used, so remove all + code dealing with it not being so. It's not that I think the + difference in audio quality is that great, but since it wouldn't + compile without code changes I assume no one's used it for quite + some time... + + Assume PRECALC_LOOPS is always defined. Judging by the comments it + may not make much of a difference either way, so why maintain two + versions of the same code? + +* Moving several static globals into the MidiSong struct. This + includes sample rate, formate, etc. which are now all per-song. + +* Moved some typedefs (e.g. MidiSong) to timidity.h for easy inclusion + into the MIDI decoder. + +* Added free_pathlist(). + +* Replaced TiMidity's own 8, 16 and 32-bit types with SDL's. + +* Made TiMidity look for its configuration file in both /etc and + /usr/local/lib/timidity. (Windows version remains unchanged.) + +* Timidity_PlaySome() now takes three arguments. A MidiSong, a decode + buffer and decode buffer size in bytes. (MidiSong is a new argument, + and buffer size used to be in samples.) + + In addition, it will return the number of bytes decoded. + +* Added Timidity_Exit(). + +* Removed Timidity_Stop() and Timidity_Active(). Stopping playback + should be handled by SDL_sound, and Timidity_PlaySome() will return + 0 when the MIDI stream is finished. + +* Modified the ToneBank stuff to allow some data to be shared between + MidiSongs. + +* The following files have been removed: controls.c, controls.h, + filter.c, filter.h, sdl_a.c, sdl_c.c + +* config.h has been renamed as options.h to avoid confusion with the + automatically generated config.h for SDL_sound. + +* Added support for loading DLS format instruments: + Timidity_LoadDLS(), Timidity_FreeDLS(), Timidity_LoadDLSSong() + +* Added Timidity_Init_NoConfig() diff --git a/timidity/FAQ b/timidity/FAQ index f1f8e23..1ee0b77 100644 --- a/timidity/FAQ +++ b/timidity/FAQ @@ -92,19 +92,7 @@ - Use a smaller number of simultaneous voices. - - Make sure you compiled with FAST_DECAY and PRECALC_LOOPS enabled - in config.h - - - If you don't have hardware to compute sines, recompile with - LOOKUP_SINE enabled in config.h - - - Recompile with LOOKUP_HACK enabled in config.h. - - - Recompile with LINEAR_INTERPOLATION disabled in config.h. - - - Recompile with DANGEROUS_RENICE enabled in config.h, and make - TiMidity setuid root. This will help only if you frequently play - music while other processes are running. + - Make sure you compiled with FAST_DECAY enabled in options.h - Recompile with an Intel-optimized gcc for a 5-15% performance increase. diff --git a/timidity/README b/timidity/README index e0882f3..0dd9892 100644 --- a/timidity/README +++ b/timidity/README @@ -1,4 +1,5 @@ -[This version of timidity has been stripped for simplicity in porting to SDL] +[This version of timidity has been stripped for simplicity in porting to SDL, +and then even further for SDL_sound] ---------------------------------*-text-*--------------------------------- From http://www.cgs.fi/~tt/discontinued.html : diff --git a/timidity/TODO b/timidity/TODO new file mode 100644 index 0000000..69b37ee --- /dev/null +++ b/timidity/TODO @@ -0,0 +1,37 @@ +* I don't like the indentation style at all, but for the most part + I've left it alone. + +* Much of the code looks ugly to me. + +* The return value from SDL_RWread() is checked inconsistenly. + +* Group the members of MidiSong into logical units, i.e. structs? + +* The debug messages are probably a bit too noisy. I've removed one + particularly annoying one, but... + + Some of them should be turned into error messages instead. + +* Can the instrument handling be made more efficient? At the moment + different MidiSongs may separately load the same instrument. + + Note that the MidiSong's audio format affects how the instrument is + loaded, so it's not as easy as just letting all MidiSongs share tone + and drum banks. + + At the moment they do share the data that is simply read from the + config file, but that's just a quick hack to avoid having to read + the config file every time a MIDI song is loaded. + +* Check if any of MidiStruct's members can safely be made into static + globals again. + +* TiMidity++ adds a number of undocumented (?) extensions to the + configuration syntax. These are not implemented here. In particular, + the "map" keyword used by the "eawpats". + +* The other decoders generally only read as much of the file as is + necessary. Could we do that in this decoder as well? (Currently it + seems to convert the entire file into MIDI events first.) + +* Can it be optimized? diff --git a/timidity/common.c b/timidity/common.c index e735258..2cd34a1 100644 --- a/timidity/common.c +++ b/timidity/common.c @@ -1,243 +1,123 @@ /* + TiMidity -- Experimental MIDI to WAVE converter Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ + + common.c +*/ + +#if HAVE_CONFIG_H +# include +#endif #include #include #include -#include -#include "config.h" +#include "SDL.h" + +#include "options.h" #include "common.h" -#include "output.h" -#include "ctrlmode.h" -/* I guess "rb" should be right for any libc */ -#define OPEN_MODE "rb" +/* The paths in this list will be tried whenever we're reading a file */ +static PathList *pathlist = NULL; /* This is a linked list */ -char current_filename[PATH_MAX]; - -static PathList *pathlist=NULL; - -/* Try to open a file for reading. If the filename ends in one of the - defined compressor extensions, pipe the file through the decompressor */ -static FILE *try_to_open(const char *name, int decompress, int noise_mode) +/* This is meant to find and open files for reading */ +SDL_RWops *open_file(const char *name) { - FILE *fp; - - fp=fopen(name, OPEN_MODE); /* First just check that the file exists */ - - if (!fp) - return 0; - -#ifdef DECOMPRESSOR_LIST - if (decompress) - { - int l,el; - static char *decompressor_list[] = DECOMPRESSOR_LIST, **dec; - const char *cp; - char tmp[PATH_MAX], tmp2[PATH_MAX], *cp2; - /* Check if it's a compressed file */ - l=strlen(name); - for (dec=decompressor_list; *dec; dec+=2) - { - el=strlen(*dec); - if ((el>=l) || (strcmp(name+l-el, *dec))) - continue; - - /* Yes. Close the file, open a pipe instead. */ - fclose(fp); - - /* Quote some special characters in the file name */ - cp=name; - cp2=tmp2; - while (*cp) - { - switch(*cp) - { - case '\'': - case '\\': - case ' ': - case '`': - case '!': - case '"': - case '&': - case ';': - *cp2++='\\'; - } - *cp2++=*cp++; - } - *cp2=0; - - sprintf(tmp, *(dec+1), tmp2); - fp=popen(tmp, "r"); - break; - } - } -#endif - - return fp; -} - -/* This is meant to find and open files for reading, possibly piping - them through a decompressor. */ -FILE *open_file(const char *name, int decompress, int noise_mode) -{ - FILE *fp; - PathList *plp; - int l; + SDL_RWops *rw; if (!name || !(*name)) { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Attempted to open nameless file."); + SNDDBG(("Attempted to open nameless file.\n")); return 0; } - if (pathlist==NULL) { - /* Generate path list */ -#ifdef DEFAULT_PATH - add_to_pathlist(DEFAULT_PATH); -#endif -#ifdef DEFAULT_PATH1 - add_to_pathlist(DEFAULT_PATH1); -#endif -#ifdef DEFAULT_PATH2 - add_to_pathlist(DEFAULT_PATH2); -#endif -#ifdef DEFAULT_PATH3 - add_to_pathlist(DEFAULT_PATH3); -#endif - } - /* First try the given name */ - strncpy(current_filename, name, PATH_MAX - 1); - current_filename[PATH_MAX - 1]='\0'; + SNDDBG(("Trying to open %s\n", name)); + if ((rw = SDL_RWFromFile(name, "rb"))) + return rw; - ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Trying to open %s", current_filename); - if ((fp=try_to_open(current_filename, decompress, noise_mode))) - return fp; + if (name[0] != PATH_SEP) + { + char current_filename[1024]; + PathList *plp = pathlist; + size_t l; -#ifdef ENOENT - if (noise_mode && (errno != ENOENT)) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", - current_filename, strerror(errno)); - return 0; - } -#endif - - plp=pathlist; - if (name[0] != PATH_SEP) while (plp) /* Try along the path then */ { - *current_filename=0; - l=strlen(plp->path); + *current_filename = 0; + l = strlen(plp->path); if(l) { strcpy(current_filename, plp->path); - if(current_filename[l-1]!=PATH_SEP) - strcat(current_filename, PATH_STRING); + if(current_filename[l - 1] != PATH_SEP) + { + current_filename[l] = PATH_SEP; + current_filename[l + 1] = '\0'; + } } strcat(current_filename, name); - ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Trying to open %s", current_filename); - if ((fp=try_to_open(current_filename, decompress, noise_mode))) - return fp; -#ifdef ENOENT - if (noise_mode && (errno != ENOENT)) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", - current_filename, strerror(errno)); - return 0; - } -#endif - plp=plp->next; + SNDDBG(("Trying to open %s\n", current_filename)); + if ((rw = SDL_RWFromFile(current_filename, "rb"))) + return rw; + plp = plp->next; } + } /* Nothing could be opened. */ - - *current_filename=0; - - if (noise_mode>=2) - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", name, strerror(errno)); - + SNDDBG(("Could not open %s\n", name)); return 0; -} - -/* This closes files opened with open_file */ -void close_file(FILE *fp) -{ -#ifdef DECOMPRESSOR_LIST - if (pclose(fp)) /* Any better ideas? */ -#endif - fclose(fp); - - strncpy(current_filename, "MIDI file", PATH_MAX - 1); -} - -/* This is meant for skipping a few bytes in a file or fifo. */ -void skip(FILE *fp, size_t len) -{ - size_t c; - char tmp[PATH_MAX]; - while (len>0) - { - c=len; - if (c>PATH_MAX) c=PATH_MAX; - len-=c; - if (c!=fread(tmp, 1, c, fp)) - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: skip: %s", - current_filename, strerror(errno)); - } } /* This'll allocate memory or die. */ void *safe_malloc(size_t count) { void *p; - if (count > (1<<21)) - { - ctl->cmsg(CMSG_FATAL, VERB_NORMAL, - "Strange, I feel like allocating %d bytes. This must be a bug.", - count); - } - else if ((p=malloc(count))) - return p; - else - ctl->cmsg(CMSG_FATAL, VERB_NORMAL, "Sorry. Couldn't malloc %d bytes.", count); - ctl->close(); - exit(10); - return(NULL); + p = malloc(count); + if (p == NULL) { + SNDDBG(("Sorry. Couldn't malloc %d bytes.\n", count)); + } + + return p; } /* This adds a directory to the path list */ void add_to_pathlist(const char *s) { - PathList *plp=safe_malloc(sizeof(PathList)); - strcpy((plp->path=safe_malloc(strlen(s)+1)),s); - plp->next=pathlist; - pathlist=plp; + PathList *plp = safe_malloc(sizeof(PathList)); + + if (plp == NULL) + return; + + plp->path = safe_malloc(strlen(s) + 1); + if (plp->path == NULL) + { + free(plp); + return; + } + + strcpy(plp->path, s); + plp->next = pathlist; + pathlist = plp; } -/* Free memory associated to path list */ void free_pathlist(void) { - PathList *plp, *next_plp; + PathList *plp = pathlist; + PathList *next; - plp = pathlist; - while (plp) { - if (plp->path) { - free(plp->path); - plp->path=NULL; + while (plp) + { + next = plp->next; + free(plp->path); + free(plp); + plp = next; } - next_plp = plp->next; - free(plp); - plp = next_plp; - } - pathlist = NULL; + pathlist = NULL; } diff --git a/timidity/common.h b/timidity/common.h index 8d9c0ec..cd7ab66 100644 --- a/timidity/common.h +++ b/timidity/common.h @@ -1,39 +1,20 @@ /* + TiMidity -- Experimental MIDI to WAVE converter Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ -#include - -#ifndef PATH_MAX /* GNU Hurd doesn't limit path size, thus no PATH_MAX... */ -#define PATH_MAX 1024 /* ...so we'll just impose an arbitrary limit. */ -#endif - -extern char *program_name, current_filename[]; - -extern FILE *msgfp; - -extern int num_ochannels; - -#define MULTICHANNEL_OUT -#define MAX_OUT_CHANNELS 6 + common.h +*/ typedef struct { char *path; void *next; } PathList; -/* Noise modes for open_file */ -#define OF_SILENT 0 -#define OF_NORMAL 1 -#define OF_VERBOSE 2 - -extern FILE *open_file(const char *name, int decompress, int noise_mode); +extern SDL_RWops *open_file(const char *name); extern void add_to_pathlist(const char *s); +extern void *safe_malloc(size_t count); extern void free_pathlist(void); -extern void close_file(FILE *fp); -extern void skip(FILE *fp, size_t len); -extern void *safe_malloc(size_t count); diff --git a/timidity/config.h b/timidity/config.h deleted file mode 100644 index 255acae..0000000 --- a/timidity/config.h +++ /dev/null @@ -1,226 +0,0 @@ -/* - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - */ - -/* This is for use with the SDL library */ -#define SDL -#include "SDL_config.h" -#include "SDL_endian.h" - -#define TIMIDITY_ERROR_SIZE 1024 - -/* When a patch file can't be opened, one of these extensions is - appended to the filename and the open is tried again. - */ -#define PATCH_EXT_LIST { ".pat", 0 } - -/* Acoustic Grand Piano seems to be the usual default instrument. */ -#define DEFAULT_PROGRAM 0 - -/* 9 here is MIDI channel 10, which is the standard percussion channel. - Some files (notably C:\WINDOWS\CANYON.MID) think that 16 is one too. - On the other hand, some files know that 16 is not a drum channel and - try to play music on it. This is now a runtime option, so this isn't - a critical choice anymore. */ -#define DEFAULT_DRUMCHANNELS (1<<9) - -/* A somewhat arbitrary frequency range. The low end of this will - sound terrible as no lowpass filtering is performed on most - instruments before resampling. */ -#define MIN_OUTPUT_RATE 4000 -#define MAX_OUTPUT_RATE 65000 - -/* In percent. */ -/* #define DEFAULT_AMPLIFICATION 70 */ -/* #define DEFAULT_AMPLIFICATION 50 */ -#define DEFAULT_AMPLIFICATION 30 - -/* Default sampling rate, default polyphony, and maximum polyphony. - All but the last can be overridden from the command line. */ -#define DEFAULT_RATE 32000 -/* #define DEFAULT_VOICES 32 */ -/* #define MAX_VOICES 48 */ -#define DEFAULT_VOICES 256 -#define MAX_VOICES 256 -#define MAXCHAN 16 -/* #define MAXCHAN 64 */ -#define MAXNOTE 128 - -/* 1000 here will give a control ratio of 22:1 with 22 kHz output. - Higher CONTROLS_PER_SECOND values allow more accurate rendering - of envelopes and tremolo. The cost is CPU time. */ -#define CONTROLS_PER_SECOND 1000 - -/* Strongly recommended. This option increases CPU usage by half, but - without it sound quality is very poor. */ -#define LINEAR_INTERPOLATION - -/* This is an experimental kludge that needs to be done right, but if - you've got an 8-bit sound card, or cheap multimedia speakers hooked - to your 16-bit output device, you should definitely give it a try. - - Defining LOOKUP_HACK causes table lookups to be used in mixing - instead of multiplication. We convert the sample data to 8 bits at - load time and volumes to logarithmic 7-bit values before looking up - the product, which degrades sound quality noticeably. - - Defining LOOKUP_HACK should save ~20% of CPU on an Intel machine. - LOOKUP_INTERPOLATION might give another ~5% */ -/* #define LOOKUP_HACK - #define LOOKUP_INTERPOLATION */ - -/* Make envelopes twice as fast. Saves ~20% CPU time (notes decay - faster) and sounds more like a GUS. There is now a command line - option to toggle this as well. */ -/* #define FAST_DECAY */ - -/* How many bits to use for the fractional part of sample positions. - This affects tonal accuracy. The entire position counter must fit - in 32 bits, so with FRACTION_BITS equal to 12, the maximum size of - a sample is 1048576 samples (2 megabytes in memory). The GUS gets - by with just 9 bits and a little help from its friends... - "The GUS does not SUCK!!!" -- a happy user :) */ -#define FRACTION_BITS 12 - -#define MAX_SAMPLE_SIZE (1 << (32-FRACTION_BITS)) - -typedef double FLOAT_T; - -/* For some reason the sample volume is always set to maximum in all - patch files. Define this for a crude adjustment that may help - equalize instrument volumes. */ -#define ADJUST_SAMPLE_VOLUMES - -/* The number of samples to use for ramping out a dying note. Affects - click removal. */ -#define MAX_DIE_TIME 20 - -/* On some machines (especially PCs without math coprocessors), - looking up sine values in a table will be significantly faster than - computing them on the fly. Uncomment this to use lookups. */ -/* #define LOOKUP_SINE */ - -/* Shawn McHorse's resampling optimizations. These may not in fact be - faster on your particular machine and compiler. You'll have to run - a benchmark to find out. */ -#define PRECALC_LOOPS - -/* If calling ldexp() is faster than a floating point multiplication - on your machine/compiler/libm, uncomment this. It doesn't make much - difference either way, but hey -- it was on the TODO list, so it - got done. */ -/* #define USE_LDEXP */ - -/**************************************************************************/ -/* Anything below this shouldn't need to be changed unless you're porting - to a new machine with other than 32-bit, big-endian words. */ -/**************************************************************************/ - -/* change FRACTION_BITS above, not these */ -#define INTEGER_BITS (32 - FRACTION_BITS) -#define INTEGER_MASK (0xFFFFFFFF << FRACTION_BITS) -#define FRACTION_MASK (~ INTEGER_MASK) - -/* This is enforced by some computations that must fit in an int */ -#define MAX_CONTROL_RATIO 255 - -typedef unsigned int uint32; -typedef int int32; -typedef unsigned short uint16; -typedef short int16; -typedef unsigned char uint8; -typedef char int8; - -/* Instrument files are little-endian, MIDI files big-endian, so we - need to do some conversions. */ - -#define XCHG_SHORT(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF)) -# define XCHG_LONG(x) ((((x)&0xFF)<<24) | \ - (((x)&0xFF00)<<8) | \ - (((x)&0xFF0000)>>8) | \ - (((x)>>24)&0xFF)) - -#if SDL_BYTEORDER == SDL_LIL_ENDIAN -#define LE_SHORT(x) x -#define LE_LONG(x) x -#define BE_SHORT(x) XCHG_SHORT(x) -#define BE_LONG(x) XCHG_LONG(x) -#else -#define BE_SHORT(x) x -#define BE_LONG(x) x -#define LE_SHORT(x) XCHG_SHORT(x) -#define LE_LONG(x) XCHG_LONG(x) -#endif - -#define MAX_AMPLIFICATION 800 - -/* You could specify a complete path, e.g. "/etc/timidity.cfg", and - then specify the library directory in the configuration file. */ -#define CONFIG_FILE "timidity.cfg" -#define CONFIG_FILE_ETC "/etc/timidity.cfg" -#define CONFIG_FILE_ETC_TIMIDITY_FREEPATS "/etc/timidity/freepats.cfg" - -#if defined(__WIN32__) || defined(__OS2__) -#define DEFAULT_PATH "C:\\TIMIDITY" -#else -#define DEFAULT_PATH "/etc/timidity" -#define DEFAULT_PATH1 "/usr/share/timidity" -#define DEFAULT_PATH2 "/usr/local/share/timidity" -#define DEFAULT_PATH3 "/usr/local/lib/timidity" -#endif - -/* These affect general volume */ -#define GUARD_BITS 3 -#define AMP_BITS (15-GUARD_BITS) - -#ifdef LOOKUP_HACK - typedef int8 sample_t; - typedef uint8 final_volume_t; -# define FINAL_VOLUME(v) (~_l2u[v]) -# define MIXUP_SHIFT 5 -# define MAX_AMP_VALUE 4095 -#else - typedef int16 sample_t; - typedef int32 final_volume_t; -# define FINAL_VOLUME(v) (v) -# define MAX_AMP_VALUE ((1<<(AMP_BITS+1))-1) -#endif - -typedef int16 resample_t; - -#ifdef USE_LDEXP -# define FSCALE(a,b) ldexp((a),(b)) -# define FSCALENEG(a,b) ldexp((a),-(b)) -#else -# define FSCALE(a,b) (float)((a) * (double)(1<<(b))) -# define FSCALENEG(a,b) (float)((a) * (1.0L / (double)(1<<(b)))) -#endif - -/* Vibrato and tremolo Choices of the Day */ -#define SWEEP_TUNING 38 -#define VIBRATO_AMPLITUDE_TUNING 1.0L -#define VIBRATO_RATE_TUNING 38 -#define TREMOLO_AMPLITUDE_TUNING 1.0L -#define TREMOLO_RATE_TUNING 38 - -#define SWEEP_SHIFT 16 -#define RATE_SHIFT 5 - -#define VIBRATO_SAMPLE_INCREMENTS 32 - -#ifndef PI - #define PI 3.14159265358979323846 -#endif - -/* The path separator (D.M.) */ -#if defined(__WIN32__) || defined(__OS2__) -# define PATH_SEP '\\' -# define PATH_STRING "\\" -#else -# define PATH_SEP '/' -# define PATH_STRING "/" -#endif diff --git a/timidity/ctrlmode.c b/timidity/ctrlmode.c deleted file mode 100644 index facaa0b..0000000 --- a/timidity/ctrlmode.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - */ - -#include "config.h" -#include "ctrlmode.h" - -#ifdef SDL - extern ControlMode sdl_control_mode; -# ifndef DEFAULT_CONTROL_MODE -# define DEFAULT_CONTROL_MODE &sdl_control_mode -# endif -#endif - -ControlMode *ctl_list[]={ -#ifdef SDL - &sdl_control_mode, -#endif - 0 -}; - -ControlMode *ctl=DEFAULT_CONTROL_MODE; diff --git a/timidity/ctrlmode.h b/timidity/ctrlmode.h deleted file mode 100644 index 5a116bc..0000000 --- a/timidity/ctrlmode.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - */ - -/* Return values for ControlMode.read */ - -#define RC_ERROR -1 -#define RC_NONE 0 -#define RC_QUIT 1 -#define RC_NEXT 2 -#define RC_PREVIOUS 3 /* Restart this song at beginning, or the previous - song if we're less than a second into this one. */ -#define RC_FORWARD 4 -#define RC_BACK 5 -#define RC_JUMP 6 -#define RC_TOGGLE_PAUSE 7 /* Pause/continue */ -#define RC_RESTART 8 /* Restart song at beginning */ - -#define RC_PAUSE 9 /* Really pause playing */ -#define RC_CONTINUE 10 /* Continue if paused */ -#define RC_REALLY_PREVIOUS 11 /* Really go to the previous song */ -#define RC_CHANGE_VOLUME 12 -#define RC_LOAD_FILE 13 /* Load a new midifile */ -#define RC_TUNE_END 14 /* The tune is over, play it again sam? */ - -#define CMSG_INFO 0 -#define CMSG_WARNING 1 -#define CMSG_ERROR 2 -#define CMSG_FATAL 3 -#define CMSG_TRACE 4 -#define CMSG_TIME 5 -#define CMSG_TOTAL 6 -#define CMSG_FILE 7 -#define CMSG_TEXT 8 - -#define VERB_NORMAL 0 -#define VERB_VERBOSE 1 -#define VERB_NOISY 2 -#define VERB_DEBUG 3 -#define VERB_DEBUG_SILLY 4 - -typedef struct { - char *id_name, id_character; - int verbosity, trace_playing, opened; - - int (*open)(int using_stdin, int using_stdout); - void (*pass_playing_list)(int number_of_files, char *list_of_files[]); - void (*close)(void); - int (*read)(int32 *valp); - int (*cmsg)(int type, int verbosity_level, char *fmt, ...); - - void (*refresh)(void); - void (*reset)(void); - void (*file_name)(char *name); - void (*total_time)(int tt); - void (*current_time)(int ct); - - void (*note)(int v); - void (*master_volume)(int mv); - void (*program)(int channel, int val); /* val<0 means drum set -val */ - void (*volume)(int channel, int val); - void (*expression)(int channel, int val); - void (*panning)(int channel, int val); - void (*sustain)(int channel, int val); - void (*pitch_bend)(int channel, int val); - -} ControlMode; - -extern ControlMode *ctl_list[], *ctl; -extern char timidity_error[]; diff --git a/timidity/filter.c b/timidity/filter.c deleted file mode 100644 index a96dbd0..0000000 --- a/timidity/filter.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - - filter.c: written by Vincent Pagel ( pagel@loria.fr ) - - implements fir antialiasing filter : should help when setting sample - rates as low as 8Khz. - - April 95 - - first draft - - 22/5/95 - - modify "filter" so that it simulate leading and trailing 0 in the buffer - */ - -#include -#include -#include -#include -#include "config.h" -#include "common.h" -#include "ctrlmode.h" -#include "instrum.h" -#include "filter.h" - -/* bessel function */ -static float ino(float x) -{ - float y, de, e, sde; - int i; - - y = x / 2; - e = 1.0; - de = 1.0; - i = 1; - do { - de = de * y / (float) i; - sde = de * de; - e += sde; - } while (!( (e * 1.0e-08 - sde > 0) || (i++ > 25) )); - return(e); -} - -/* Kaiser Window (symetric) */ -static void kaiser(float *w,int n,float beta) -{ - float xind, xi; - int i; - - xind = (float)((2*n - 1) * (2*n - 1)); - for (i =0; i apply the filter given by coef[] to the data buffer - * Note that we simulate leading and trailing 0 at the border of the - * data buffer - */ -static void filter(sample_t *result,sample_t *data, int32 length,float coef[]) -{ - int32 sample,i,sample_window; - int16 peak = 0; - float sum; - - /* Simulate leading 0 at the begining of the buffer */ - for (sample = 0; sample < ORDER2 ; sample++ ) - { - sum = 0.0; - sample_window= sample - ORDER2; - - for (i = 0; i < ORDER ;i++) - sum += (float)(coef[i] * - ((sample_window<0)? 0.0 : data[sample_window++])) ; - - /* Saturation ??? */ - if (sum> 32767.) { sum=32767.; peak++; } - if (sum< -32768.) { sum=-32768; peak++; } - result[sample] = (sample_t) sum; - } - - /* The core of the buffer */ - for (sample = ORDER2; sample < length - ORDER + ORDER2 ; sample++ ) - { - sum = 0.0; - sample_window= sample - ORDER2; - - for (i = 0; i < ORDER ;i++) - sum += data[sample_window++] * coef[i]; - - /* Saturation ??? */ - if (sum> 32767.) { sum=32767.; peak++; } - if (sum< -32768.) { sum=-32768; peak++; } - result[sample] = (sample_t) sum; - } - - /* Simulate 0 at the end of the buffer */ - for (sample = length - ORDER + ORDER2; sample < length ; sample++ ) - { - sum = 0.0; - sample_window= sample - ORDER2; - - for (i = 0; i < ORDER ;i++) - sum += (float)(coef[i] * - ((sample_window>=length)? 0.0 : data[sample_window++])) ; - - /* Saturation ??? */ - if (sum> 32767.) { sum=32767.; peak++; } - if (sum< -32768.) { sum=-32768; peak++; } - result[sample] = (sample_t) sum; - } - - if (peak) - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "Saturation %2.3f %%.", 100.0*peak/ (float) length); -} - -/***********************************************************************/ -/* Prevent aliasing by filtering any freq above the output_rate */ -/* */ -/* I don't worry about looping point -> they will remain soft if they */ -/* were already */ -/***********************************************************************/ -void antialiasing(Sample *sp, int32 output_rate ) -{ - sample_t *temp; - int i; - float fir_symetric[ORDER]; - float fir_coef[ORDER2]; - float freq_cut; /* cutoff frequency [0..1.0] FREQ_CUT/SAMP_FREQ*/ - - - ctl->cmsg(CMSG_INFO, VERB_NOISY, "Antialiasing: Fsample=%iKHz", - sp->sample_rate); - - /* No oversampling */ - if (output_rate>=sp->sample_rate) - return; - - freq_cut= (float) output_rate / (float) sp->sample_rate; - ctl->cmsg(CMSG_INFO, VERB_NOISY, "Antialiasing: cutoff=%f%%", - freq_cut*100.); - - designfir(fir_coef,freq_cut); - - /* Make the filter symetric */ - for (i = 0 ; idata_length); - memcpy(temp,sp->data,sp->data_length); - - filter(sp->data,temp,sp->data_length/sizeof(sample_t),fir_symetric); - - free(temp); -} diff --git a/timidity/filter.h b/timidity/filter.h deleted file mode 100644 index 7913337..0000000 --- a/timidity/filter.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - - filter.h : written by Vincent Pagel ( pagel@loria.fr ) - - implements fir antialiasing filter : should help when setting sample - rates as low as 8Khz. - - */ - -/* Order of the FIR filter = 20 should be enough ! */ -#define ORDER 20 -#define ORDER2 ORDER/2 - -#ifndef PI -#define PI 3.14159265 -#endif - -extern void antialiasing(Sample *sp, int32 output_rate); diff --git a/timidity/instrum.c b/timidity/instrum.c index a549f08..dedbea0 100644 --- a/timidity/instrum.c +++ b/timidity/instrum.c @@ -1,166 +1,81 @@ /* + TiMidity -- Experimental MIDI to WAVE converter Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ + + instrum.c + + Code to load and unload GUS-compatible instrument patches. + +*/ + +#if HAVE_CONFIG_H +# include +#endif #include #include #include -#include "config.h" +#include "SDL.h" + +#include "timidity.h" +#include "options.h" #include "common.h" #include "instrum.h" -#include "playmidi.h" -#include "output.h" -#include "ctrlmode.h" #include "resample.h" #include "tables.h" -#include "filter.h" - -/* Some functions get aggravated if not even the standard banks are - available. */ -static ToneBank standard_tonebank, standard_drumset; -ToneBank - *tonebank[MAXBANK]={&standard_tonebank}, - *drumset[MAXBANK]={&standard_drumset}; - -/* This is a special instrument, used for all melodic programs */ -InstrumentLayer *default_instrument=0; - -/* This is only used for tracks that don't specify a program */ -int default_program=DEFAULT_PROGRAM; - -int antialiasing_allowed=0; -#ifdef FAST_DECAY -int fast_decay=1; -#else -int fast_decay=0; -#endif - - -int current_tune_number = 0; -int last_tune_purged = 0; -int current_patch_memory = 0; -int max_patch_memory = 60000000; - -static void purge_as_required(void); static void free_instrument(Instrument *ip) { Sample *sp; int i; if (!ip) return; - - if (!ip->contents) for (i=0; isamples; i++) { sp=&(ip->sample[i]); - if (sp->data) free(sp->data); + free(sp->data); } free(ip->sample); - - if (!ip->contents) - for (i=0; iright_samples; i++) - { - sp=&(ip->right_sample[i]); - if (sp->data) free(sp->data); - } - if (ip->right_sample) - free(ip->right_sample); free(ip); } - -static void free_layer(InstrumentLayer *lp) -{ - InstrumentLayer *next; - - current_patch_memory -= lp->size; - - for (; lp; lp = next) - { - next = lp->next; - free_instrument(lp->instrument); - free(lp); - } -} - -static void free_bank(int dr, int b) +static void free_bank(MidiSong *song, int dr, int b) { int i; - ToneBank *bank=((dr) ? drumset[b] : tonebank[b]); - for (i=0; itone[i].layer) - { - /* Not that this could ever happen, of course */ - if (bank->tone[i].layer != MAGIC_LOAD_INSTRUMENT) - { - free_layer(bank->tone[i].layer); - bank->tone[i].layer=NULL; - bank->tone[i].last_used=-1; - } - } - if (bank->tone[i].name) - { - free(bank->tone[i].name); - bank->tone[i].name = NULL; - } - } -} - - -static void free_old_bank(int dr, int b, int how_old) -{ - int i; - ToneBank *bank=((dr) ? drumset[b] : tonebank[b]); - for (i=0; itone[i].layer && bank->tone[i].last_used < how_old) + ToneBank *bank=((dr) ? song->drumset[b] : song->tonebank[b]); + for (i=0; iinstrument[i]) { - if (bank->tone[i].layer != MAGIC_LOAD_INSTRUMENT) - { - ctl->cmsg(CMSG_INFO, VERB_DEBUG, - "Unloading %s %s[%d,%d] - last used %d.", - (dr)? "drum" : "inst", bank->tone[i].name, - i, b, bank->tone[i].last_used); - free_layer(bank->tone[i].layer); - bank->tone[i].layer=NULL; - bank->tone[i].last_used=-1; - } + /* Not that this could ever happen, of course */ + if (bank->instrument[i] != MAGIC_LOAD_INSTRUMENT) + free_instrument(bank->instrument[i]); + bank->instrument[i]=0; } } - -int32 convert_envelope_rate_attack(uint8 rate, uint8 fastness) -{ - int32 r; - - r=3-((rate>>6) & 0x3); - r*=3; - r = (int32)(rate & 0x3f) << r; /* 6.9 fixed point */ +static Sint32 convert_envelope_rate(MidiSong *song, Uint8 rate) +{ + Sint32 r; + + r = 3 - ((rate >> 6) & 0x3); + r *= 3; + r = (Sint32) (rate & 0x3f) << r; /* 6.9 fixed point */ /* 15.15 fixed point. */ - return (((r * 44100) / play_mode->rate) * control_ratio) - << 10; -} - -int32 convert_envelope_rate(uint8 rate) -{ - int32 r; - - r=3-((rate>>6) & 0x3); - r*=3; - r = (int32)(rate & 0x3f) << r; /* 6.9 fixed point */ - - /* 15.15 fixed point. */ - return (((r * 44100) / play_mode->rate) * control_ratio) - << ((fast_decay) ? 10 : 9); -} - -int32 convert_envelope_offset(uint8 offset) + r = ((r * 44100) / song->rate) * song->control_ratio; + +#ifdef FAST_DECAY + return r << 10; +#else + return r << 9; +#endif +} + +static Sint32 convert_envelope_offset(Uint8 offset) { /* This is not too good... Can anyone tell me what these values mean? Are they GUS-style "exponential" volumes? And what does that mean? */ @@ -169,49 +84,50 @@ return offset << (7+15); } -int32 convert_tremolo_sweep(uint8 sweep) +static Sint32 convert_tremolo_sweep(MidiSong *song, Uint8 sweep) { if (!sweep) return 0; return - ((control_ratio * SWEEP_TUNING) << SWEEP_SHIFT) / - (play_mode->rate * sweep); -} - -int32 convert_vibrato_sweep(uint8 sweep, int32 vib_control_ratio) + ((song->control_ratio * SWEEP_TUNING) << SWEEP_SHIFT) / + (song->rate * sweep); +} + +static Sint32 convert_vibrato_sweep(MidiSong *song, Uint8 sweep, + Sint32 vib_control_ratio) { if (!sweep) return 0; return - (int32) (FSCALE((double) (vib_control_ratio) * SWEEP_TUNING, SWEEP_SHIFT) - / (double)(play_mode->rate * sweep)); + (Sint32) (FSCALE((double) (vib_control_ratio) * SWEEP_TUNING, SWEEP_SHIFT) + / (double)(song->rate * sweep)); /* this was overflowing with seashore.pat ((vib_control_ratio * SWEEP_TUNING) << SWEEP_SHIFT) / - (play_mode->rate * sweep); */ -} - -int32 convert_tremolo_rate(uint8 rate) + (song->rate * sweep); */ +} + +static Sint32 convert_tremolo_rate(MidiSong *song, Uint8 rate) { return - ((SINE_CYCLE_LENGTH * control_ratio * rate) << RATE_SHIFT) / - (TREMOLO_RATE_TUNING * play_mode->rate); -} - -int32 convert_vibrato_rate(uint8 rate) + ((SINE_CYCLE_LENGTH * song->control_ratio * rate) << RATE_SHIFT) / + (TREMOLO_RATE_TUNING * song->rate); +} + +static Sint32 convert_vibrato_rate(MidiSong *song, Uint8 rate) { /* Return a suitable vibrato_control_ratio value */ return - (VIBRATO_RATE_TUNING * play_mode->rate) / + (VIBRATO_RATE_TUNING * song->rate) / (rate * 2 * VIBRATO_SAMPLE_INCREMENTS); } -static void reverse_data(int16 *sp, int32 ls, int32 le) -{ - int16 s, *ep=sp+le; +static void reverse_data(Sint16 *sp, Sint32 ls, Sint32 le) +{ + Sint16 s, *ep=sp+le; sp+=ls; le-=ls; le/=2; @@ -233,255 +149,113 @@ undefined. TODO: do reverse loops right */ -static InstrumentLayer *load_instrument(const char *name, int font_type, int percussion, - int panning, int amp, int cfg_tuning, int note_to_use, +static Instrument *load_instrument(MidiSong *song, char *name, int percussion, + int panning, int amp, int note_to_use, int strip_loop, int strip_envelope, - int strip_tail, int bank, int gm_num, int sf_ix) -{ - InstrumentLayer *lp, *lastlp, *headlp = 0; + int strip_tail) +{ Instrument *ip; - FILE *fp; - uint8 tmp[1024]; + Sample *sp; + SDL_RWops *rw; + char tmp[1024]; int i,j,noluck=0; -#ifdef PATCH_EXT_LIST static char *patch_ext[] = PATCH_EXT_LIST; -#endif - int sf2flag = 0; - int right_samples = 0; - int stereo_channels = 1, stereo_layer; - int vlayer_list[19][4], vlayer, vlayer_count = 0; if (!name) return 0; /* Open patch file */ - if ((fp=open_file(name, 1, OF_NORMAL)) == NULL) + if ((rw=open_file(name)) == NULL) { noluck=1; -#ifdef PATCH_EXT_LIST /* Try with various extensions */ for (i=0; patch_ext[i]; i++) { - if (strlen(name)+strlen(patch_ext[i])cmsg(CMSG_ERROR, VERB_NORMAL, - "Instrument `%s' can't be found.", name); + SNDDBG(("Instrument `%s' can't be found.\n", name)); return 0; } - /*ctl->cmsg(CMSG_INFO, VERB_NOISY, "Loading instrument %s", current_filename);*/ + SNDDBG(("Loading instrument %s\n", tmp)); /* Read some headers and do cursory sanity checks. There are loads of magic offsets. This could be rewritten... */ - if ((239 != fread(tmp, 1, 239, fp)) || + if ((239 != SDL_RWread(rw, tmp, 1, 239)) || (memcmp(tmp, "GF1PATCH110\0ID#000002", 22) && memcmp(tmp, "GF1PATCH100\0ID#000002", 22))) /* don't know what the differences are */ { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: not an instrument", name); + SNDDBG(("%s: not an instrument\n", name)); + SDL_RWclose(rw); return 0; } - -/* patch layout: - * bytes: info: starts at offset: - * 22 id (see above) 0 - * 60 copyright 22 - * 1 instruments 82 - * 1 voices 83 - * 1 channels 84 - * 2 number of waveforms 85 - * 2 master volume 87 - * 4 datasize 89 - * 36 reserved, but now: 93 - * 7 "SF2EXT\0" id 93 - * 1 right samples 100 - * 28 reserved 101 - * 2 instrument number 129 - * 16 instrument name 131 - * 4 instrument size 147 - * 1 number of layers 151 - * 40 reserved 152 - * 1 layer duplicate 192 - * 1 layer number 193 - * 4 layer size 194 - * 1 number of samples 198 - * 40 reserved 199 - * 239 - * THEN, for each sample, see below - */ - - if (!memcmp(tmp + 93, "SF2EXT", 6)) - { - sf2flag = 1; - vlayer_count = tmp[152]; - } - + if (tmp[82] != 1 && tmp[82] != 0) /* instruments. To some patch makers, 0 means 1 */ { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "Can't handle patches with %d instruments", tmp[82]); + SNDDBG(("Can't handle patches with %d instruments\n", tmp[82])); + SDL_RWclose(rw); return 0; } if (tmp[151] != 1 && tmp[151] != 0) /* layers. What's a layer? */ { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "Can't handle instruments with %d layers", tmp[151]); + SNDDBG(("Can't handle instruments with %d layers\n", tmp[151])); + SDL_RWclose(rw); return 0; } - - if (sf2flag && vlayer_count > 0) { - for (i = 0; i < 9; i++) - for (j = 0; j < 4; j++) - vlayer_list[i][j] = tmp[153+i*4+j]; - for (i = 9; i < 19; i++) - for (j = 0; j < 4; j++) - vlayer_list[i][j] = tmp[199+(i-9)*4+j]; - } - else { - for (i = 0; i < 19; i++) - for (j = 0; j < 4; j++) - vlayer_list[i][j] = 0; - vlayer_list[0][0] = 0; - vlayer_list[0][1] = 127; - vlayer_list[0][2] = tmp[198]; - vlayer_list[0][3] = 0; - vlayer_count = 1; - } - - lastlp = 0; - - for (vlayer = 0; vlayer < vlayer_count; vlayer++) { - - lp=(InstrumentLayer *)safe_malloc(sizeof(InstrumentLayer)); - lp->size = sizeof(InstrumentLayer); - lp->lo = vlayer_list[vlayer][0]; - lp->hi = vlayer_list[vlayer][1]; - ip=(Instrument *)safe_malloc(sizeof(Instrument)); - lp->size += sizeof(Instrument); - lp->instrument = ip; - lp->next = 0; - - if (lastlp) lastlp->next = lp; - else headlp = lp; - - lastlp = lp; - - if (sf2flag) ip->type = INST_SF2; - else ip->type = INST_GUS; - ip->samples = vlayer_list[vlayer][2]; - ip->sample = (Sample *)safe_malloc(sizeof(Sample) * ip->samples); - lp->size += sizeof(Sample) * ip->samples; - ip->left_samples = ip->samples; - ip->left_sample = ip->sample; - right_samples = vlayer_list[vlayer][3]; - ip->right_samples = right_samples; - if (right_samples) - { - ip->right_sample = (Sample *)safe_malloc(sizeof(Sample) * right_samples); - lp->size += sizeof(Sample) * right_samples; - stereo_channels = 2; - } - else ip->right_sample = 0; - ip->contents = 0; - - ctl->cmsg(CMSG_INFO, VERB_NOISY, "%s%s[%d,%d] %s(%d-%d layer %d of %d)", - (percussion)? " ":"", name, - (percussion)? note_to_use : gm_num, bank, - (right_samples)? "(2) " : "", - lp->lo, lp->hi, vlayer+1, vlayer_count); - - for (stereo_layer = 0; stereo_layer < stereo_channels; stereo_layer++) - { - int sample_count = 0; - - if (stereo_layer == 0) sample_count = ip->left_samples; - else if (stereo_layer == 1) sample_count = ip->right_samples; - - for (i=0; i < sample_count; i++) - { - uint8 fractions; - int32 tmplong; - uint16 tmpshort; - uint16 sample_volume = 0; - uint8 tmpchar; - Sample *sp = 0; - uint8 sf2delay = 0; + ip=safe_malloc(sizeof(Instrument)); + ip->samples = tmp[198]; + ip->sample = safe_malloc(sizeof(Sample) * ip->samples); + for (i=0; isamples; i++) + { + + Uint8 fractions; + Sint32 tmplong; + Uint16 tmpshort; + Uint8 tmpchar; #define READ_CHAR(thing) \ - if ((size_t)1 != fread(&tmpchar, 1, 1, fp)) goto fail; \ + if (1 != SDL_RWread(rw, &tmpchar, 1, 1)) goto fail; \ thing = tmpchar; #define READ_SHORT(thing) \ - if ((size_t)1 != fread(&tmpshort, 2, 1, fp)) goto fail; \ - thing = LE_SHORT(tmpshort); + if (1 != SDL_RWread(rw, &tmpshort, 2, 1)) goto fail; \ + thing = SDL_SwapLE16(tmpshort); #define READ_LONG(thing) \ - if ((size_t)1 != fread(&tmplong, 4, 1, fp)) goto fail; \ - thing = LE_LONG(tmplong); - -/* - * 7 sample name - * 1 fractions - * 4 length - * 4 loop start - * 4 loop end - * 2 sample rate - * 4 low frequency - * 4 high frequency - * 2 finetune - * 1 panning - * 6 envelope rates | - * 6 envelope offsets | 18 bytes - * 3 tremolo sweep, rate, depth | - * 3 vibrato sweep, rate, depth | - * 1 sample mode - * 2 scale frequency - * 2 scale factor - * 2 sample volume (??) - * 34 reserved - * Now: 1 delay - * 33 reserved - */ - skip(fp, 7); /* Skip the wave name */ - - if (1 != fread(&fractions, 1, 1, fp)) + if (1 != SDL_RWread(rw, &tmplong, 4, 1)) goto fail; \ + thing = SDL_SwapLE32(tmplong); + + SDL_RWseek(rw, 7, RW_SEEK_CUR); /* Skip the wave name */ + + if (1 != SDL_RWread(rw, &fractions, 1, 1)) { fail: - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Error reading sample %d", i); - if (stereo_layer == 1) - { - for (j=0; jright_sample[j].data); - free(ip->right_sample); - i = ip->left_samples; - } + SNDDBG(("Error reading sample %d\n", i)); for (j=0; jleft_sample[j].data); - free(ip->left_sample); + free(ip->sample[j].data); + free(ip->sample); free(ip); - free(lp); + SDL_RWclose(rw); return 0; } - if (stereo_layer == 0) sp=&(ip->left_sample[i]); - else if (stereo_layer == 1) sp=&(ip->right_sample[i]); - + sp=&(ip->sample[i]); + READ_LONG(sp->data_length); READ_LONG(sp->loop_start); READ_LONG(sp->loop_end); @@ -489,91 +263,62 @@ READ_LONG(sp->low_freq); READ_LONG(sp->high_freq); READ_LONG(sp->root_freq); - skip(fp, 2); /* Why have a "root frequency" and then "tuning"?? */ + SDL_RWseek(rw, 2, RW_SEEK_CUR); /* Why have a "root frequency" and then + * "tuning"?? */ READ_CHAR(tmp[0]); if (panning==-1) sp->panning = (tmp[0] * 8 + 4) & 0x7f; else - sp->panning=(uint8)(panning & 0x7F); - - sp->resonance=0; - sp->cutoff_freq=0; - sp->reverberation=0; - sp->chorusdepth=0; - sp->exclusiveClass=0; - sp->keyToModEnvHold=0; - sp->keyToModEnvDecay=0; - sp->keyToVolEnvHold=0; - sp->keyToVolEnvDecay=0; - - if (cfg_tuning) - { - double tune_factor = (double)(cfg_tuning)/1200.0; - tune_factor = pow(2.0, tune_factor); - sp->root_freq = (uint32)( tune_factor * (double)sp->root_freq ); - } + sp->panning=(Uint8)(panning & 0x7F); /* envelope, tremolo, and vibrato */ - if (18 != fread(tmp, 1, 18, fp)) goto fail; + if (18 != SDL_RWread(rw, tmp, 1, 18)) goto fail; if (!tmp[13] || !tmp[14]) { sp->tremolo_sweep_increment= sp->tremolo_phase_increment=sp->tremolo_depth=0; - ctl->cmsg(CMSG_INFO, VERB_DEBUG, " * no tremolo"); + SNDDBG((" * no tremolo\n")); } else { - sp->tremolo_sweep_increment=convert_tremolo_sweep(tmp[12]); - sp->tremolo_phase_increment=convert_tremolo_rate(tmp[13]); + sp->tremolo_sweep_increment=convert_tremolo_sweep(song, tmp[12]); + sp->tremolo_phase_increment=convert_tremolo_rate(song, tmp[13]); sp->tremolo_depth=tmp[14]; - ctl->cmsg(CMSG_INFO, VERB_DEBUG, - " * tremolo: sweep %d, phase %d, depth %d", + SNDDBG((" * tremolo: sweep %d, phase %d, depth %d\n", sp->tremolo_sweep_increment, sp->tremolo_phase_increment, - sp->tremolo_depth); + sp->tremolo_depth)); } if (!tmp[16] || !tmp[17]) { sp->vibrato_sweep_increment= sp->vibrato_control_ratio=sp->vibrato_depth=0; - ctl->cmsg(CMSG_INFO, VERB_DEBUG, " * no vibrato"); + SNDDBG((" * no vibrato\n")); } else { - sp->vibrato_control_ratio=convert_vibrato_rate(tmp[16]); + sp->vibrato_control_ratio=convert_vibrato_rate(song, tmp[16]); sp->vibrato_sweep_increment= - convert_vibrato_sweep(tmp[15], sp->vibrato_control_ratio); + convert_vibrato_sweep(song, tmp[15], sp->vibrato_control_ratio); sp->vibrato_depth=tmp[17]; - ctl->cmsg(CMSG_INFO, VERB_DEBUG, - " * vibrato: sweep %d, ctl %d, depth %d", + SNDDBG((" * vibrato: sweep %d, ctl %d, depth %d\n", sp->vibrato_sweep_increment, sp->vibrato_control_ratio, - sp->vibrato_depth); + sp->vibrato_depth)); } READ_CHAR(sp->modes); - READ_SHORT(tmpshort); - sp->freq_center = (uint8)tmpshort; - READ_SHORT(sp->freq_scale); - - if (sf2flag) - { - READ_SHORT(sample_volume); - READ_CHAR(sf2delay); - READ_CHAR(sp->exclusiveClass); - skip(fp, 32); - } - else - { - skip(fp, 36); - } + + SDL_RWseek(rw, 40, RW_SEEK_CUR); /* skip the useless scale frequency, scale + factor (what's it mean?), and reserved + space */ /* Mark this as a fixed-pitch instrument if such a deed is desired. */ if (note_to_use!=-1) - sp->note_to_use=(uint8)(note_to_use); + sp->note_to_use=(Uint8)(note_to_use); else sp->note_to_use=0; @@ -590,15 +335,16 @@ (sp->modes & (MODES_SUSTAIN | MODES_LOOPING | MODES_PINGPONG | MODES_REVERSE))) { - ctl->cmsg(CMSG_INFO, VERB_DEBUG, " - Removing loop and/or sustain"); + SNDDBG((" - Removing loop and/or sustain\n")); sp->modes &=~(MODES_SUSTAIN | MODES_LOOPING | MODES_PINGPONG | MODES_REVERSE); } if (strip_envelope==1) { - if (sp->modes & MODES_ENVELOPE) - ctl->cmsg(CMSG_INFO, VERB_DEBUG, " - Removing envelope"); + if (sp->modes & MODES_ENVELOPE) { + SNDDBG((" - Removing envelope\n")); + } sp->modes &= ~MODES_ENVELOPE; } else if (strip_envelope != 0) @@ -609,16 +355,14 @@ /* No loop? Then what's there to sustain? No envelope needed either... */ sp->modes &= ~(MODES_SUSTAIN|MODES_ENVELOPE); - ctl->cmsg(CMSG_INFO, VERB_DEBUG, - " - No loop, removing sustain and envelope"); + SNDDBG((" - No loop, removing sustain and envelope\n")); } else if (!memcmp(tmp, "??????", 6) || tmp[11] >= 100) { /* Envelope rates all maxed out? Envelope end at a high "offset"? That's a weird envelope. Take it out. */ sp->modes &= ~MODES_ENVELOPE; - ctl->cmsg(CMSG_INFO, VERB_DEBUG, - " - Weirdness, removing envelope"); + SNDDBG((" - Weirdness, removing envelope\n")); } else if (!(sp->modes & MODES_SUSTAIN)) { @@ -627,101 +371,68 @@ envelope either... at least the Gravis ones. They're mostly drums. I think. */ sp->modes &= ~MODES_ENVELOPE; - ctl->cmsg(CMSG_INFO, VERB_DEBUG, - " - No sustain, removing envelope"); - } - } - - sp->attenuation = 0; - - for (j=ATTACK; jenvelope_rate[j]= - (j<3)? convert_envelope_rate_attack(tmp[j], 11) : convert_envelope_rate(tmp[j]); + convert_envelope_rate(song, tmp[j]); sp->envelope_offset[j]= convert_envelope_offset(tmp[6+j]); } - if (sf2flag) - { - if (sf2delay > 5) sf2delay = 5; - sp->envelope_rate[DELAY] = (int32)( (sf2delay*play_mode->rate) / 1000 ); - } - else - { - sp->envelope_rate[DELAY]=0; - } - sp->envelope_offset[DELAY]=0; - - for (j=ATTACK; jmodulation_rate[j]=sp->envelope_rate[j]; - sp->modulation_offset[j]=sp->envelope_offset[j]; - } - sp->modulation_rate[DELAY] = sp->modulation_offset[DELAY] = 0; - sp->modEnvToFilterFc=0; - sp->modEnvToPitch=0; - sp->lfo_sweep_increment = 0; - sp->lfo_phase_increment = 0; - sp->modLfoToFilterFc = 0; - sp->vibrato_delay = 0; /* Then read the sample data */ - if (sp->data_length/2 > MAX_SAMPLE_SIZE) - { - goto fail; - } - sp->data = (sample_t *)safe_malloc(sp->data_length + 1); - lp->size += sp->data_length + 1; - - if (1 != fread(sp->data, sp->data_length, 1, fp)) + sp->data = (sample_t *) safe_malloc(sp->data_length+4); + if (1 != SDL_RWread(rw, sp->data, sp->data_length, 1)) goto fail; if (!(sp->modes & MODES_16BIT)) /* convert to 16-bit data */ { - int32 i=sp->data_length; - uint8 *cp=(uint8 *)(sp->data); - uint16 *tmp,*newdta; - tmp=newdta=(uint16 *)safe_malloc(sp->data_length*2 + 2); - while (i--) - *tmp++ = (uint16)(*cp++) << 8; - cp=(uint8 *)(sp->data); - sp->data = (sample_t *)newdta; - free(cp); + Sint32 k=sp->data_length; + Uint8 *cp=(Uint8 *)(sp->data); + Uint16 *tmp16,*new16; sp->data_length *= 2; sp->loop_start *= 2; sp->loop_end *= 2; + tmp16 = new16 = (Uint16 *) safe_malloc(sp->data_length+4); + while (k--) + *tmp16++ = (Uint16)(*cp++) << 8; + free(sp->data); + sp->data = (sample_t *)new16; } #if SDL_BYTEORDER == SDL_BIG_ENDIAN else /* convert to machine byte order */ { - int32 i=sp->data_length/2; - int16 *tmp=(int16 *)sp->data,s; - while (i--) - { - s=LE_SHORT(*tmp); - *tmp++=s; + Sint32 k=sp->data_length/2; + Sint16 *tmp16=(Sint16 *)sp->data,s; + while (k--) + { + s=SDL_SwapLE16(*tmp16); + *tmp16++=s; } } #endif if (sp->modes & MODES_UNSIGNED) /* convert to signed data */ { - int32 i=sp->data_length/2; - int16 *tmp=(int16 *)sp->data; - while (i--) - *tmp++ ^= 0x8000; + Sint32 k=sp->data_length/2; + Sint16 *tmp16=(Sint16 *)sp->data; + while (k--) + *tmp16++ ^= 0x8000; } /* Reverse reverse loops and pass them off as normal loops */ if (sp->modes & MODES_REVERSE) { - int32 t; + Sint32 t; /* The GUS apparently plays reverse loops by reversing the whole sample. We do the same because the GUS does not SUCK. */ - ctl->cmsg(CMSG_WARNING, VERB_NORMAL, "Reverse loop in %s", name); - reverse_data((int16 *)sp->data, 0, sp->data_length/2); + SNDDBG(("Reverse loop in %s\n", name)); + reverse_data((Sint16 *)sp->data, 0, sp->data_length/2); t=sp->loop_start; sp->loop_start=sp->data_length - sp->loop_end; @@ -731,49 +442,26 @@ sp->modes |= MODES_LOOPING; /* just in case */ } - /* If necessary do some anti-aliasing filtering */ - - if (antialiasing_allowed) - antialiasing(sp,play_mode->rate); - #ifdef ADJUST_SAMPLE_VOLUMES if (amp!=-1) - sp->volume=(FLOAT_T)((amp) / 100.0); - else if (sf2flag) - sp->volume=(FLOAT_T)((sample_volume) / 255.0); + sp->volume=(float)((amp) / 100.0); else { /* Try to determine a volume scaling factor for the sample. This is a very crude adjustment, but things sound more balanced with it. Still, this should be a runtime option. */ - uint32 i, numsamps=sp->data_length/2; - uint32 higher=0, highcount=0; - int16 maxamp=0,a; - int16 *tmp=(int16 *)sp->data; - i = numsamps; - while (i--) - { - a=*tmp++; + Sint32 k=sp->data_length/2; + Sint16 maxamp=0,a; + Sint16 *tmp16=(Sint16 *)sp->data; + while (k--) + { + a=*tmp16++; if (a<0) a=-a; if (a>maxamp) maxamp=a; } - tmp=(int16 *)sp->data; - i = numsamps; - while (i--) - { - a=*tmp++; - if (a<0) a=-a; - if (a > 3*maxamp/4) - { - higher += a; - highcount++; - } - } - if (highcount) higher /= highcount; - else higher = 10000; - sp->volume = (32768.0 * 0.875) / (double)higher ; - ctl->cmsg(CMSG_INFO, VERB_DEBUG, " * volume comp: %f", sp->volume); + sp->volume=(float)(32768.0 / maxamp); + SNDDBG((" * volume comp: %f\n", sp->volume)); } #else if (amp!=-1) @@ -783,27 +471,17 @@ #endif sp->data_length /= 2; /* These are in bytes. Convert into samples. */ - sp->loop_start /= 2; sp->loop_end /= 2; - sp->data[sp->data_length] = sp->data[sp->data_length-1]; + + /* initialize the added extra sample space (see the +4 bytes in + allocation) using the last actual sample: */ + sp->data[sp->data_length] = sp->data[sp->data_length+1] = 0; /* Then fractional samples */ sp->data_length <<= FRACTION_BITS; sp->loop_start <<= FRACTION_BITS; sp->loop_end <<= FRACTION_BITS; - - /* trim off zero data at end */ - { - int ls = sp->loop_start>>FRACTION_BITS; - int le = sp->loop_end>>FRACTION_BITS; - int se = sp->data_length>>FRACTION_BITS; - while (se > 1 && !sp->data[se-1]) se--; - if (le > se) le = se; - if (ls >= le) sp->modes &= ~MODES_LOOPING; - sp->loop_end = le<data_length = se<note_to_use && !(sp->modes & MODES_LOOPING)) - pre_resample(sp); - -#ifdef LOOKUP_HACK - /* Squash the 16-bit data into 8 bits. */ - { - uint8 *gulp,*ulp; - int16 *swp; - int l=sp->data_length >> FRACTION_BITS; - gulp=ulp=safe_malloc(l+1); - swp=(int16 *)sp->data; - while(l--) - *ulp++ = (*swp++ >> 8) & 0xFF; - free(sp->data); - sp->data=(sample_t *)gulp; - } -#endif - + pre_resample(song, sp); + if (strip_tail==1) { /* Let's not really, just say we did. */ - ctl->cmsg(CMSG_INFO, VERB_DEBUG, " - Stripping tail"); + SNDDBG((" - Stripping tail\n")); sp->data_length = sp->loop_end; } - } /* end of sample loop */ - } /* end of stereo layer loop */ - } /* end of vlayer loop */ - - - close_file(fp); - return headlp; -} - -static int fill_bank(int dr, int b) + } + + SDL_RWclose(rw); + return ip; +} + +static int fill_bank(MidiSong *song, int dr, int b) { int i, errors=0; - ToneBank *bank=((dr) ? drumset[b] : tonebank[b]); + ToneBank *bank=((dr) ? song->drumset[b] : song->tonebank[b]); if (!bank) { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "Huh. Tried to load instruments in non-existent %s %d", - (dr) ? "drumset" : "tone bank", b); + SNDDBG(("Huh. Tried to load instruments in non-existent %s %d\n", + (dr) ? "drumset" : "tone bank", b)); return 0; } - for (i=0; itone[i].layer==MAGIC_LOAD_INSTRUMENT) + for (i=0; iinstrument[i]==MAGIC_LOAD_INSTRUMENT) { if (!(bank->tone[i].name)) { - ctl->cmsg(CMSG_WARNING, (b!=0) ? VERB_VERBOSE : VERB_NORMAL, - "No instrument mapped to %s %d, program %d%s", + SNDDBG(("No instrument mapped to %s %d, program %d%s\n", (dr)? "drum set" : "tone bank", b, i, - (b!=0) ? "" : " - this instrument will not be heard"); + (b!=0) ? "" : " - this instrument will not be heard")); if (b!=0) { /* Mark the corresponding instrument in the default bank / drumset for loading (if it isn't already) */ if (!dr) { - if (!(standard_tonebank.tone[i].layer)) - standard_tonebank.tone[i].layer= + if (!(song->tonebank[0]->instrument[i])) + song->tonebank[0]->instrument[i] = MAGIC_LOAD_INSTRUMENT; } else { - if (!(standard_drumset.tone[i].layer)) - standard_drumset.tone[i].layer= + if (!(song->drumset[0]->instrument[i])) + song->drumset[0]->instrument[i] = MAGIC_LOAD_INSTRUMENT; } } - bank->tone[i].layer=0; + bank->instrument[i] = 0; errors++; } - else if (!(bank->tone[i].layer= - load_instrument(bank->tone[i].name, - bank->tone[i].font_type, + else if (!(bank->instrument[i] = + load_instrument(song, + bank->tone[i].name, (dr) ? 1 : 0, bank->tone[i].pan, bank->tone[i].amp, - bank->tone[i].tuning, (bank->tone[i].note!=-1) ? - bank->tone[i].note : - ((dr) ? i : -1), + bank->tone[i].note : + ((dr) ? i : -1), (bank->tone[i].strip_loop!=-1) ? bank->tone[i].strip_loop : ((dr) ? 1 : -1), (bank->tone[i].strip_envelope != -1) ? bank->tone[i].strip_envelope : ((dr) ? 1 : -1), - bank->tone[i].strip_tail, - b, - ((dr) ? i + 128 : i), - bank->tone[i].sf_ix - ))) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "Couldn't load instrument %s (%s %d, program %d)", + bank->tone[i].strip_tail ))) + { + SNDDBG(("Couldn't load instrument %s (%s %d, program %d)\n", bank->tone[i].name, - (dr)? "drum set" : "tone bank", b, i); + (dr)? "drum set" : "tone bank", b, i)); errors++; } - else - { /* it's loaded now */ - bank->tone[i].last_used = current_tune_number; - current_patch_memory += bank->tone[i].layer->size; - purge_as_required(); - if (current_patch_memory > max_patch_memory) { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "Not enough memory to load instrument %s (%s %d, program %d)", - bank->tone[i].name, - (dr)? "drum set" : "tone bank", b, i); - errors++; - free_layer(bank->tone[i].layer); - bank->tone[i].layer=0; - bank->tone[i].last_used=-1; - } -#if 0 - if (check_for_rc()) { - free_layer(bank->tone[i].layer); - bank->tone[i].layer=0; - bank->tone[i].last_used=-1; - return 0; - } -#endif - } } } return errors; } -static void free_old_instruments(int how_old) +int load_missing_instruments(MidiSong *song) +{ + int i=MAXBANK,errors=0; + while (i--) + { + if (song->tonebank[i]) + errors+=fill_bank(song,0,i); + if (song->drumset[i]) + errors+=fill_bank(song,1,i); + } + return errors; +} + +void free_instruments(MidiSong *song) { int i=MAXBANK; while(i--) { - if (tonebank[i]) - free_old_bank(0, i, how_old); - if (drumset[i]) - free_old_bank(1, i, how_old); - } -} - -static void purge_as_required(void) -{ - if (!max_patch_memory) return; - - while (last_tune_purged < current_tune_number - && current_patch_memory > max_patch_memory) - { - last_tune_purged++; - free_old_instruments(last_tune_purged); - } -} - - -int load_missing_instruments(void) -{ - int i=MAXBANK,errors=0; - while (i--) - { - if (tonebank[i]) - errors+=fill_bank(0,i); - if (drumset[i]) - errors+=fill_bank(1,i); - } - current_tune_number++; - return errors; -} - -void free_instruments(void) -{ - int i=128; - while(i--) - { - if (tonebank[i]) - free_bank(0,i); - if (drumset[i]) - free_bank(1,i); - } -} - -int set_default_instrument(const char *name) -{ - InstrumentLayer *lp; -/* if (!(lp=load_instrument(name, 0, -1, -1, -1, 0, 0, 0))) */ - if (!(lp=load_instrument(name, FONT_NORMAL, 0, -1, -1, 0, -1, -1, -1, -1, 0, -1, -1))) + if (song->tonebank[i]) + free_bank(song, 0, i); + if (song->drumset[i]) + free_bank(song, 1, i); + } +} + +int set_default_instrument(MidiSong *song, char *name) +{ + Instrument *ip; + if (!(ip=load_instrument(song, name, 0, -1, -1, -1, 0, 0, 0))) return -1; - if (default_instrument) - free_layer(default_instrument); - default_instrument=lp; - default_program=SPECIAL_PROGRAM; + song->default_instrument = ip; + song->default_program = SPECIAL_PROGRAM; return 0; } diff --git a/timidity/instrum.h b/timidity/instrum.h index 7ba0a99..3371fce 100644 --- a/timidity/instrum.h +++ b/timidity/instrum.h @@ -1,44 +1,14 @@ /* + TiMidity -- Experimental MIDI to WAVE converter Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ + instrum.h -typedef struct { - int32 - loop_start, loop_end, data_length, - sample_rate, low_freq, high_freq, root_freq; - uint8 - root_tune, fine_tune; - int32 - envelope_rate[7], envelope_offset[7], - modulation_rate[7], modulation_offset[7]; - FLOAT_T - volume, resonance, - modEnvToFilterFc, modEnvToPitch, modLfoToFilterFc; - sample_t *data; - int32 - tremolo_sweep_increment, tremolo_phase_increment, - lfo_sweep_increment, lfo_phase_increment, - vibrato_sweep_increment, vibrato_control_ratio, - cutoff_freq; - uint8 - reverberation, chorusdepth, - tremolo_depth, vibrato_depth, - modes; - uint8 - attenuation, freq_center; - int8 - panning, note_to_use, exclusiveClass; - int16 - scale_tuning, keyToModEnvHold, keyToModEnvDecay, - keyToVolEnvHold, keyToVolEnvDecay; - int32 - freq_scale, vibrato_delay; -} Sample; + */ /* Bits in modes: */ #define MODES_16BIT (1<<0) @@ -48,121 +18,13 @@ #define MODES_REVERSE (1<<4) #define MODES_SUSTAIN (1<<5) #define MODES_ENVELOPE (1<<6) -#define MODES_FAST_RELEASE (1<<7) -#if 0 -typedef struct { - int samples; - Sample *sample; -} Instrument; -#endif - -#define INST_GUS 0 -#define INST_SF2 1 - -typedef struct { - int type; - int samples; - Sample *sample; - int left_samples; - Sample *left_sample; - int right_samples; - Sample *right_sample; - unsigned char *contents; -} Instrument; - - -typedef struct _InstrumentLayer { - uint8 lo, hi; - int size; - Instrument *instrument; - struct _InstrumentLayer *next; -} InstrumentLayer; - -struct cfg_type { - int font_code; - int num; - const char *name; -}; - -#define FONT_NORMAL 0 -#define FONT_FFF 1 -#define FONT_SBK 2 -#define FONT_TONESET 3 -#define FONT_DRUMSET 4 -#define FONT_PRESET 5 - - -typedef struct { - char *name; - InstrumentLayer *layer; - int font_type, sf_ix, last_used, tuning; - int note, amp, pan, strip_loop, strip_envelope, strip_tail; -} ToneBankElement; - -#if 0 -typedef struct { - char *name; - Instrument *instrument; - int note, amp, pan, strip_loop, strip_envelope, strip_tail; -} ToneBankElement; -#endif /* A hack to delay instrument loading until after reading the entire MIDI file. */ -#define MAGIC_LOAD_INSTRUMENT ((InstrumentLayer *)(-1)) - -#define MAXPROG 128 -#define MAXBANK 130 -#define SFXBANK (MAXBANK-1) -#define SFXDRUM1 (MAXBANK-2) -#define SFXDRUM2 (MAXBANK-1) -#define XGDRUM 1 - -#if 0 -typedef struct { - ToneBankElement tone[128]; -} ToneBank; -#endif - -typedef struct { - char *name; - ToneBankElement tone[MAXPROG]; -} ToneBank; - - -extern char *sf_file; - -extern ToneBank *tonebank[], *drumset[]; - -#if 0 -extern Instrument *default_instrument; -#endif -extern InstrumentLayer *default_instrument; -extern int default_program; -extern int antialiasing_allowed; -extern int fast_decay; -extern int free_instruments_afterwards; +#define MAGIC_LOAD_INSTRUMENT ((Instrument *) (-1)) #define SPECIAL_PROGRAM -1 -extern int load_missing_instruments(void); -extern void free_instruments(void); -extern void end_soundfont(void); -extern int set_default_instrument(const char *name); - - -extern int32 convert_tremolo_sweep(uint8 sweep); -extern int32 convert_vibrato_sweep(uint8 sweep, int32 vib_control_ratio); -extern int32 convert_tremolo_rate(uint8 rate); -extern int32 convert_vibrato_rate(uint8 rate); - -extern int init_soundfont(char *fname, int oldbank, int newbank, int level); -extern InstrumentLayer *load_sbk_patch(const char *name, int gm_num, int bank, int percussion, - int panning, int amp, int note_to_use, int sf_ix); -extern int current_tune_number; -extern int max_patch_memory; -extern int current_patch_memory; -#define XMAPMAX 800 -extern int xmap[XMAPMAX][5]; -extern void pcmap(int *b, int *v, int *p, int *drums); - +extern int load_missing_instruments(MidiSong *song); +extern void free_instruments(MidiSong *song); +extern int set_default_instrument(MidiSong *song, char *name); diff --git a/timidity/mix.c b/timidity/mix.c index 8871ffb..fc30819 100644 --- a/timidity/mix.c +++ b/timidity/mix.c @@ -1,177 +1,159 @@ /* + TiMidity -- Experimental MIDI to WAVE converter Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ + + mix.c */ + +#if HAVE_CONFIG_H +# include +#endif #include #include #include -#include "config.h" -#include "common.h" +#include "SDL.h" + +#include "timidity.h" +#include "options.h" #include "instrum.h" #include "playmidi.h" #include "output.h" -#include "ctrlmode.h" #include "tables.h" #include "resample.h" #include "mix.h" /* Returns 1 if envelope runs out */ -int recompute_envelope(int v) +int recompute_envelope(MidiSong *song, int v) { int stage; - stage = voice[v].envelope_stage; + stage = song->voice[v].envelope_stage; if (stage>5) { /* Envelope ran out. */ - int tmp=(voice[v].status == VOICE_DIE); /* Already displayed as dead */ - voice[v].status = VOICE_FREE; - if(!tmp) - ctl->note(v); + song->voice[v].status = VOICE_FREE; return 1; } - if (voice[v].sample->modes & MODES_ENVELOPE) - { - if (voice[v].status==VOICE_ON || voice[v].status==VOICE_SUSTAINED) + if (song->voice[v].sample->modes & MODES_ENVELOPE) + { + if (song->voice[v].status==VOICE_ON || song->voice[v].status==VOICE_SUSTAINED) { if (stage>2) { /* Freeze envelope until note turns off. Trumpets want this. */ - voice[v].envelope_increment=0; + song->voice[v].envelope_increment=0; return 0; } } } - voice[v].envelope_stage=stage+1; - - if (voice[v].envelope_volume==voice[v].sample->envelope_offset[stage]) - return recompute_envelope(v); - voice[v].envelope_target=voice[v].sample->envelope_offset[stage]; - voice[v].envelope_increment = voice[v].sample->envelope_rate[stage]; - if (voice[v].envelope_targetvoice[v].envelope_stage=stage+1; + + if (song->voice[v].envelope_volume==song->voice[v].sample->envelope_offset[stage] || + (stage > 2 && song->voice[v].envelope_volume < + song->voice[v].sample->envelope_offset[stage])) + return recompute_envelope(song, v); + song->voice[v].envelope_target = song->voice[v].sample->envelope_offset[stage]; + song->voice[v].envelope_increment = song->voice[v].sample->envelope_rate[stage]; + if (song->voice[v].envelope_target < song->voice[v].envelope_volume) + song->voice[v].envelope_increment = -song->voice[v].envelope_increment; return 0; } -void apply_envelope_to_amp(int v) -{ - FLOAT_T lamp=voice[v].left_amp, ramp, lramp, rramp, ceamp, lfeamp; - int32 la,ra, lra, rra, cea, lfea; - if (voice[v].panned == PANNED_MYSTERY) - { - lramp=voice[v].lr_amp; - ramp=voice[v].right_amp; - ceamp=voice[v].ce_amp; - rramp=voice[v].rr_amp; - lfeamp=voice[v].lfe_amp; - - if (voice[v].tremolo_phase_increment) - { - FLOAT_T tv = voice[v].tremolo_volume; - lramp *= tv; - lamp *= tv; - ceamp *= tv; - ramp *= tv; - rramp *= tv; - lfeamp *= tv; - } - if (voice[v].sample->modes & MODES_ENVELOPE) - { - FLOAT_T ev = (FLOAT_T)vol_table[voice[v].envelope_volume>>23]; - lramp *= ev; - lamp *= ev; - ceamp *= ev; - ramp *= ev; - rramp *= ev; - lfeamp *= ev; - } - - la = (int32)FSCALE(lamp,AMP_BITS); - ra = (int32)FSCALE(ramp,AMP_BITS); - lra = (int32)FSCALE(lramp,AMP_BITS); - rra = (int32)FSCALE(rramp,AMP_BITS); - cea = (int32)FSCALE(ceamp,AMP_BITS); - lfea = (int32)FSCALE(lfeamp,AMP_BITS); +void apply_envelope_to_amp(MidiSong *song, int v) +{ + float lamp = song->voice[v].left_amp, ramp; + Sint32 la,ra; + if (song->voice[v].panned == PANNED_MYSTERY) + { + ramp = song->voice[v].right_amp; + if (song->voice[v].tremolo_phase_increment) + { + lamp *= song->voice[v].tremolo_volume; + ramp *= song->voice[v].tremolo_volume; + } + if (song->voice[v].sample->modes & MODES_ENVELOPE) + { + lamp *= (float)vol_table[song->voice[v].envelope_volume>>23]; + ramp *= (float)vol_table[song->voice[v].envelope_volume>>23]; + } + + la = (Sint32)FSCALE(lamp,AMP_BITS); - if (la>MAX_AMP_VALUE) la=MAX_AMP_VALUE; - if (ra>MAX_AMP_VALUE) ra=MAX_AMP_VALUE; - if (lra>MAX_AMP_VALUE) lra=MAX_AMP_VALUE; - if (rra>MAX_AMP_VALUE) rra=MAX_AMP_VALUE; - if (cea>MAX_AMP_VALUE) cea=MAX_AMP_VALUE; - if (lfea>MAX_AMP_VALUE) lfea=MAX_AMP_VALUE; - - voice[v].lr_mix=FINAL_VOLUME(lra); - voice[v].left_mix=FINAL_VOLUME(la); - voice[v].ce_mix=FINAL_VOLUME(cea); - voice[v].right_mix=FINAL_VOLUME(ra); - voice[v].rr_mix=FINAL_VOLUME(rra); - voice[v].lfe_mix=FINAL_VOLUME(lfea); - } - else - { - if (voice[v].tremolo_phase_increment) - lamp *= voice[v].tremolo_volume; - if (voice[v].sample->modes & MODES_ENVELOPE) - lamp *= (FLOAT_T)vol_table[voice[v].envelope_volume>>23]; - - la = (int32)FSCALE(lamp,AMP_BITS); - if (la>MAX_AMP_VALUE) la=MAX_AMP_VALUE; - voice[v].left_mix=FINAL_VOLUME(la); - } -} - -static int update_envelope(int v) -{ - voice[v].envelope_volume += voice[v].envelope_increment; + ra = (Sint32)FSCALE(ramp,AMP_BITS); + if (ra>MAX_AMP_VALUE) + ra=MAX_AMP_VALUE; + + song->voice[v].left_mix = la; + song->voice[v].right_mix = ra; + } + else + { + if (song->voice[v].tremolo_phase_increment) + lamp *= song->voice[v].tremolo_volume; + if (song->voice[v].sample->modes & MODES_ENVELOPE) + lamp *= (float)vol_table[song->voice[v].envelope_volume>>23]; + + la = (Sint32)FSCALE(lamp,AMP_BITS); + + if (la>MAX_AMP_VALUE) + la=MAX_AMP_VALUE; + + song->voice[v].left_mix = la; + } +} + +static int update_envelope(MidiSong *song, int v) +{ + song->voice[v].envelope_volume += song->voice[v].envelope_increment; /* Why is there no ^^ operator?? */ - if (((voice[v].envelope_increment < 0) && - (voice[v].envelope_volume <= voice[v].envelope_target)) || - ((voice[v].envelope_increment > 0) && - (voice[v].envelope_volume >= voice[v].envelope_target))) - { - voice[v].envelope_volume = voice[v].envelope_target; - if (recompute_envelope(v)) + if (((song->voice[v].envelope_increment < 0) && + (song->voice[v].envelope_volume <= song->voice[v].envelope_target)) || + ((song->voice[v].envelope_increment > 0) && + (song->voice[v].envelope_volume >= song->voice[v].envelope_target))) + { + song->voice[v].envelope_volume = song->voice[v].envelope_target; + if (recompute_envelope(song, v)) return 1; } return 0; } -static void update_tremolo(int v) -{ - int32 depth=voice[v].sample->tremolo_depth<<7; - - if (voice[v].tremolo_sweep) +static void update_tremolo(MidiSong *song, int v) +{ + Sint32 depth = song->voice[v].sample->tremolo_depth << 7; + + if (song->voice[v].tremolo_sweep) { /* Update sweep position */ - voice[v].tremolo_sweep_position += voice[v].tremolo_sweep; - if (voice[v].tremolo_sweep_position>=(1<voice[v].tremolo_sweep_position += song->voice[v].tremolo_sweep; + if (song->voice[v].tremolo_sweep_position >= (1 << SWEEP_SHIFT)) + song->voice[v].tremolo_sweep=0; /* Swept to max amplitude */ else { /* Need to adjust depth */ - depth *= voice[v].tremolo_sweep_position; + depth *= song->voice[v].tremolo_sweep_position; depth >>= SWEEP_SHIFT; } } - voice[v].tremolo_phase += voice[v].tremolo_phase_increment; - - /* if (voice[v].tremolo_phase >= (SINE_CYCLE_LENGTH<> RATE_SHIFT) + 1.0) + song->voice[v].tremolo_phase += song->voice[v].tremolo_phase_increment; + + /* if (song->voice[v].tremolo_phase >= (SINE_CYCLE_LENGTH<voice[v].tremolo_phase -= SINE_CYCLE_LENGTH<voice[v].tremolo_volume = (float) + (1.0 - FSCALENEG((sine(song->voice[v].tremolo_phase >> RATE_SHIFT) + 1.0) * depth * TREMOLO_AMPLITUDE_TUNING, 17)); @@ -180,54 +162,37 @@ } /* Returns 1 if the note died */ -static int update_signal(int v) -{ - if (voice[v].envelope_increment && update_envelope(v)) +static int update_signal(MidiSong *song, int v) +{ + if (song->voice[v].envelope_increment && update_envelope(song, v)) return 1; - if (voice[v].tremolo_phase_increment) - update_tremolo(v); - - apply_envelope_to_amp(v); + if (song->voice[v].tremolo_phase_increment) + update_tremolo(song, v); + + apply_envelope_to_amp(song, v); return 0; } -#ifdef LOOKUP_HACK -# define MIXATION(a) *lp++ += mixup[(a<<8) | (uint8)s]; -#else -# define MIXATION(a) *lp++ += (a)*s; -#endif - -#define MIXSKIP lp++ -#define MIXMAX(a,b) *lp++ += ((a>b)?a:b) * s -#define MIXCENT(a,b) *lp++ += (a/2+b/2) * s -#define MIXHALF(a) *lp++ += (a>>1)*s; - -static void mix_mystery_signal(resample_t *sp, int32 *lp, int v, int count) -{ - Voice *vp = voice + v; - final_volume_t - left_rear=vp->lr_mix, +#define MIXATION(a) *lp++ += (a)*s; + +static void mix_mystery_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v, + int count) +{ + Voice *vp = song->voice + v; + final_volume_t left=vp->left_mix, - center=vp->ce_mix, - right=vp->right_mix, - right_rear=vp->rr_mix, - lfe=vp->lfe_mix; + right=vp->right_mix; int cc; - resample_t s; + sample_t s; if (!(cc = vp->control_counter)) { - cc = control_ratio; - if (update_signal(v)) + cc = song->control_ratio; + if (update_signal(song, v)) return; /* Envelope ran out */ - - left_rear = vp->lr_mix; - left = vp->left_mix; - center = vp->ce_mix; - right = vp->right_mix; - right_rear = vp->rr_mix; - lfe = vp->lfe_mix; + left = vp->left_mix; + right = vp->right_mix; } while (count) @@ -237,26 +202,14 @@ while (cc--) { s = *sp++; - MIXATION(left); - MIXATION(right); - if (num_ochannels >= 4) { - MIXATION(left_rear); - MIXATION(right_rear); - } - if (num_ochannels == 6) { - MIXATION(center); - MIXATION(lfe); - } - } - cc = control_ratio; - if (update_signal(v)) + MIXATION(left); + MIXATION(right); + } + cc = song->control_ratio; + if (update_signal(song, v)) return; /* Envelope ran out */ - left_rear = vp->lr_mix; left = vp->left_mix; - center = vp->ce_mix; right = vp->right_mix; - right_rear = vp->rr_mix; - lfe = vp->lfe_mix; } else { @@ -264,33 +217,26 @@ while (count--) { s = *sp++; - MIXATION(left); - MIXATION(right); - if (num_ochannels >= 4) { - MIXATION(left_rear); - MIXATION(right_rear); - } - if (num_ochannels == 6) { - MIXATION(center); - MIXATION(lfe); - } + MIXATION(left); + MIXATION(right); } return; } } -static void mix_center_signal(resample_t *sp, int32 *lp, int v, int count) -{ - Voice *vp = voice + v; +static void mix_center_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v, + int count) +{ + Voice *vp = song->voice + v; final_volume_t left=vp->left_mix; int cc; - resample_t s; + sample_t s; if (!(cc = vp->control_counter)) { - cc = control_ratio; - if (update_signal(v)) + cc = song->control_ratio; + if (update_signal(song, v)) return; /* Envelope ran out */ left = vp->left_mix; } @@ -302,27 +248,11 @@ while (cc--) { s = *sp++; - if (num_ochannels == 2) { - MIXATION(left); - MIXATION(left); - } - else if (num_ochannels == 4) { - MIXATION(left); - MIXSKIP; - MIXATION(left); - MIXSKIP; - } - else if (num_ochannels == 6) { - MIXSKIP; - MIXSKIP; - MIXSKIP; - MIXSKIP; - MIXATION(left); - MIXATION(left); - } - } - cc = control_ratio; - if (update_signal(v)) + MIXATION(left); + MIXATION(left); + } + cc = song->control_ratio; + if (update_signal(song, v)) return; /* Envelope ran out */ left = vp->left_mix; } @@ -332,41 +262,26 @@ while (count--) { s = *sp++; - if (num_ochannels == 2) { - MIXATION(left); - MIXATION(left); - } - else if (num_ochannels == 4) { - MIXATION(left); - MIXSKIP; - MIXATION(left); - MIXSKIP; - } - else if (num_ochannels == 6) { - MIXSKIP; - MIXSKIP; - MIXSKIP; - MIXSKIP; - MIXATION(left); - MIXATION(left); - } + MIXATION(left); + MIXATION(left); } return; } } -static void mix_single_left_signal(resample_t *sp, int32 *lp, int v, int count) -{ - Voice *vp = voice + v; +static void mix_single_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v, + int count) +{ + Voice *vp = song->voice + v; final_volume_t left=vp->left_mix; int cc; - resample_t s; + sample_t s; if (!(cc = vp->control_counter)) { - cc = control_ratio; - if (update_signal(v)) + cc = song->control_ratio; + if (update_signal(song, v)) return; /* Envelope ran out */ left = vp->left_mix; } @@ -378,23 +293,11 @@ while (cc--) { s = *sp++; - if (num_ochannels == 2) { - MIXATION(left); - MIXSKIP; - } - if (num_ochannels >= 4) { - MIXHALF(left); - MIXSKIP; - MIXATION(left); - MIXSKIP; - } - if (num_ochannels == 6) { - MIXSKIP; - MIXATION(left); - } - } - cc = control_ratio; - if (update_signal(v)) + MIXATION(left); + lp++; + } + cc = song->control_ratio; + if (update_signal(song, v)) return; /* Envelope ran out */ left = vp->left_mix; } @@ -404,37 +307,26 @@ while (count--) { s = *sp++; - if (num_ochannels == 2) { - MIXATION(left); - MIXSKIP; - } - if (num_ochannels >= 4) { - MIXHALF(left); - MIXSKIP; - MIXATION(left); - MIXSKIP; - } - if (num_ochannels == 6) { - MIXSKIP; - MIXATION(left); - } + MIXATION(left); + lp++; } return; } } -static void mix_single_right_signal(resample_t *sp, int32 *lp, int v, int count) -{ - Voice *vp = voice + v; +static void mix_mono_signal(MidiSong *song, sample_t *sp, Sint32 *lp, int v, + int count) +{ + Voice *vp = song->voice + v; final_volume_t left=vp->left_mix; int cc; - resample_t s; + sample_t s; if (!(cc = vp->control_counter)) { - cc = control_ratio; - if (update_signal(v)) + cc = song->control_ratio; + if (update_signal(song, v)) return; /* Envelope ran out */ left = vp->left_mix; } @@ -446,22 +338,10 @@ while (cc--) { s = *sp++; - if (num_ochannels == 2) { - MIXSKIP; - MIXATION(left); - } - if (num_ochannels >= 4) { - MIXSKIP; - MIXHALF(left); - MIXSKIP; - MIXATION(left); - } if (num_ochannels == 6) { - MIXSKIP; - MIXATION(left); - } - } - cc = control_ratio; - if (update_signal(v)) + MIXATION(left); + } + cc = song->control_ratio; + if (update_signal(song, v)) return; /* Envelope ran out */ left = vp->left_mix; } @@ -471,238 +351,103 @@ while (count--) { s = *sp++; - if (num_ochannels == 2) { - MIXSKIP; - MIXATION(left); - } - if (num_ochannels >= 4) { - MIXSKIP; - MIXHALF(left); - MIXSKIP; - MIXATION(left); - } if (num_ochannels == 6) { - MIXSKIP; - MIXATION(left); - } + MIXATION(left); } return; } } -static void mix_mono_signal(resample_t *sp, int32 *lp, int v, int count) -{ - Voice *vp = voice + v; - final_volume_t - left=vp->left_mix; - int cc; - resample_t s; - - if (!(cc = vp->control_counter)) - { - cc = control_ratio; - if (update_signal(v)) - return; /* Envelope ran out */ - left = vp->left_mix; - } - - while (count) - if (cc < count) - { - count -= cc; - while (cc--) - { - s = *sp++; - MIXATION(left); - } - cc = control_ratio; - if (update_signal(v)) - return; /* Envelope ran out */ - left = vp->left_mix; - } - else - { - vp->control_counter = cc - count; - while (count--) - { - s = *sp++; - MIXATION(left); - } - return; - } -} - -static void mix_mystery(resample_t *sp, int32 *lp, int v, int count) -{ - final_volume_t - left_rear=voice[v].lr_mix, - left=voice[v].left_mix, - center=voice[v].ce_mix, - right=voice[v].right_mix, - right_rear=voice[v].rr_mix, - lfe=voice[v].lfe_mix; - resample_t s; - - while (count--) - { - s = *sp++; - MIXATION(left); - MIXATION(right); - if (num_ochannels >= 4) { - MIXATION(left_rear); - MIXATION(right_rear); - } - if (num_ochannels == 6) { - MIXATION(center); - MIXATION(lfe); - } - } -} - -static void mix_center(resample_t *sp, int32 *lp, int v, int count) -{ - final_volume_t - left=voice[v].left_mix; - resample_t s; - - while (count--) - { - s = *sp++; - if (num_ochannels == 2) { - MIXATION(left); - MIXATION(left); - } - else if (num_ochannels == 4) { - MIXATION(left); - MIXATION(left); - MIXSKIP; - MIXSKIP; - } - else if (num_ochannels == 6) { - MIXSKIP; - MIXSKIP; - MIXSKIP; - MIXSKIP; - MIXATION(left); - MIXATION(left); - } - } -} - -static void mix_single_left(resample_t *sp, int32 *lp, int v, int count) -{ - final_volume_t - left=voice[v].left_mix; - resample_t s; - - while (count--) - { - s = *sp++; - if (num_ochannels == 2) { - MIXATION(left); - MIXSKIP; - } - if (num_ochannels >= 4) { - MIXHALF(left); - MIXSKIP; - MIXATION(left); - MIXSKIP; - } - if (num_ochannels == 6) { - MIXSKIP; - MIXATION(left); - } - } -} -static void mix_single_right(resample_t *sp, int32 *lp, int v, int count) -{ - final_volume_t - left=voice[v].left_mix; - resample_t s; - - while (count--) - { - s = *sp++; - if (num_ochannels == 2) { - MIXSKIP; - MIXATION(left); - } - if (num_ochannels >= 4) { - MIXSKIP; - MIXHALF(left); - MIXSKIP; - MIXATION(left); - } - if (num_ochannels == 6) { - MIXSKIP; - MIXATION(left); - } - } -} - -static void mix_mono(resample_t *sp, int32 *lp, int v, int count) -{ - final_volume_t - left=voice[v].left_mix; - resample_t s; +static void mix_mystery(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count) +{ + final_volume_t + left = song->voice[v].left_mix, + right = song->voice[v].right_mix; + sample_t s; while (count--) { s = *sp++; MIXATION(left); + MIXATION(right); + } +} + +static void mix_center(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count) +{ + final_volume_t + left = song->voice[v].left_mix; + sample_t s; + + while (count--) + { + s = *sp++; + MIXATION(left); + MIXATION(left); + } +} + +static void mix_single(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count) +{ + final_volume_t + left = song->voice[v].left_mix; + sample_t s; + + while (count--) + { + s = *sp++; + MIXATION(left); + lp++; + } +} + +static void mix_mono(MidiSong *song, sample_t *sp, Sint32 *lp, int v, int count) +{ + final_volume_t + left = song->voice[v].left_mix; + sample_t s; + + while (count--) + { + s = *sp++; + MIXATION(left); } } /* Ramp a note out in c samples */ -static void ramp_out(resample_t *sp, int32 *lp, int v, int32 c) -{ - - /* should be final_volume_t, but uint8 gives trouble. */ - int32 left_rear, left, center, right, right_rear, lfe, li, ri; - - resample_t s = 0; /* silly warning about uninitialized s */ - - /* Fix by James Caldwell */ - if ( c == 0 ) c = 1; - - left = voice[v].left_mix; - li = -(left/c); - if (!li) li = -1; +static void ramp_out(MidiSong *song, sample_t *sp, Sint32 *lp, int v, Sint32 c) +{ + + /* should be final_volume_t, but Uint8 gives trouble. */ + Sint32 left, right, li, ri; + + sample_t s=0; /* silly warning about uninitialized s */ + + left=song->voice[v].left_mix; + li=-(left/c); + if (!li) li=-1; /* printf("Ramping out: left=%d, c=%d, li=%d\n", left, c, li); */ - if (!(play_mode->encoding & PE_MONO)) - { - if (voice[v].panned==PANNED_MYSTERY) - { - left_rear = voice[v].lr_mix; - center=voice[v].ce_mix; - right=voice[v].right_mix; - right_rear = voice[v].rr_mix; - lfe = voice[v].lfe_mix; - + if (!(song->encoding & PE_MONO)) + { + if (song->voice[v].panned==PANNED_MYSTERY) + { + right=song->voice[v].right_mix; ri=-(right/c); while (c--) { - left_rear += li; if (left_rear<0) left_rear=0; - left += li; if (left<0) left=0; - center += li; if (center<0) center=0; - right += ri; if (right<0) right=0; - right_rear += ri; if (right_rear<0) right_rear=0; - lfe += li; if (lfe<0) lfe=0; + left += li; + if (left<0) + left=0; + right += ri; + if (right<0) + right=0; s=*sp++; - MIXATION(left); - MIXATION(right); - if (num_ochannels >= 4) { - MIXATION(left_rear); - MIXATION(right_rear); - } - if (num_ochannels == 6) { - MIXATION(center); - MIXATION(lfe); - } - } - } - else if (voice[v].panned==PANNED_CENTER) + MIXATION(left); + MIXATION(right); + } + } + else if (song->voice[v].panned==PANNED_CENTER) { while (c--) { @@ -710,27 +455,11 @@ if (left<0) return; s=*sp++; - if (num_ochannels == 2) { - MIXATION(left); - MIXATION(left); - } - else if (num_ochannels == 4) { - MIXATION(left); - MIXATION(left); - MIXSKIP; - MIXSKIP; - } - else if (num_ochannels == 6) { - MIXSKIP; - MIXSKIP; - MIXSKIP; - MIXSKIP; - MIXATION(left); - MIXATION(left); - } - } - } - else if (voice[v].panned==PANNED_LEFT) + MIXATION(left); + MIXATION(left); + } + } + else if (song->voice[v].panned==PANNED_LEFT) { while (c--) { @@ -739,17 +468,10 @@ return; s=*sp++; MIXATION(left); - MIXSKIP; - if (num_ochannels >= 4) { - MIXATION(left); - MIXSKIP; - } if (num_ochannels == 6) { - MIXATION(left); - MIXATION(left); - } - } - } - else if (voice[v].panned==PANNED_RIGHT) + lp++; + } + } + else if (song->voice[v].panned==PANNED_RIGHT) { while (c--) { @@ -757,15 +479,8 @@ if (left<0) return; s=*sp++; - MIXSKIP; + lp++; MIXATION(left); - if (num_ochannels >= 4) { - MIXSKIP; - MIXATION(left); - } if (num_ochannels == 6) { - MIXATION(left); - MIXATION(left); - } } } } @@ -786,66 +501,57 @@ /**************** interface function ******************/ -void mix_voice(int32 *buf, int v, int32 c) -{ - Voice *vp=voice+v; - int32 count=c; - resample_t *sp; - if (c<0) return; +void mix_voice(MidiSong *song, Sint32 *buf, int v, Sint32 c) +{ + Voice *vp = song->voice + v; + sample_t *sp; if (vp->status==VOICE_DIE) { - if (count>=MAX_DIE_TIME) - count=MAX_DIE_TIME; - sp=resample_voice(v, &count); - ramp_out(sp, buf, v, count); + if (c>=MAX_DIE_TIME) + c=MAX_DIE_TIME; + sp=resample_voice(song, v, &c); + if(c > 0) + ramp_out(song, sp, buf, v, c); vp->status=VOICE_FREE; } else { - sp=resample_voice(v, &count); - if (count<0) return; - if (play_mode->encoding & PE_MONO) + sp=resample_voice(song, v, &c); + if (song->encoding & PE_MONO) { /* Mono output. */ if (vp->envelope_increment || vp->tremolo_phase_increment) - mix_mono_signal(sp, buf, v, count); + mix_mono_signal(song, sp, buf, v, c); else - mix_mono(sp, buf, v, count); + mix_mono(song, sp, buf, v, c); } else { if (vp->panned == PANNED_MYSTERY) { if (vp->envelope_increment || vp->tremolo_phase_increment) - mix_mystery_signal(sp, buf, v, count); + mix_mystery_signal(song, sp, buf, v, c); else - mix_mystery(sp, buf, v, count); + mix_mystery(song, sp, buf, v, c); } else if (vp->panned == PANNED_CENTER) { if (vp->envelope_increment || vp->tremolo_phase_increment) - mix_center_signal(sp, buf, v, count); + mix_center_signal(song, sp, buf, v, c); else - mix_center(sp, buf, v, count); + mix_center(song, sp, buf, v, c); } else { /* It's either full left or full right. In either case, every other sample is 0. Just get the offset right: */ + if (vp->panned == PANNED_RIGHT) buf++; if (vp->envelope_increment || vp->tremolo_phase_increment) - { - if (vp->panned == PANNED_RIGHT) - mix_single_right_signal(sp, buf, v, count); - else mix_single_left_signal(sp, buf, v, count); - } + mix_single_signal(song, sp, buf, v, c); else - { - if (vp->panned == PANNED_RIGHT) - mix_single_right(sp, buf, v, count); - else mix_single_left(sp, buf, v, count); - } - } - } - } -} + mix_single(song, sp, buf, v, c); + } + } + } +} diff --git a/timidity/mix.h b/timidity/mix.h index 2f582b8..be2a5f1 100644 --- a/timidity/mix.h +++ b/timidity/mix.h @@ -1,11 +1,15 @@ /* + TiMidity -- Experimental MIDI to WAVE converter Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ -extern void mix_voice(int32 *buf, int v, int32 c); -extern int recompute_envelope(int v); -extern void apply_envelope_to_amp(int v); + mix.h + +*/ + +extern void mix_voice(MidiSong *song, Sint32 *buf, int v, Sint32 c); +extern int recompute_envelope(MidiSong *song, int v); +extern void apply_envelope_to_amp(MidiSong *song, int v); diff --git a/timidity/options.h b/timidity/options.h new file mode 100644 index 0000000..7589399 --- /dev/null +++ b/timidity/options.h @@ -0,0 +1,117 @@ +/* + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + This program is free software; you can redistribute it and/or modify + it under the terms of the Perl Artistic License, available in COPYING. +*/ + +/* When a patch file can't be opened, one of these extensions is + appended to the filename and the open is tried again. + */ +#define PATCH_EXT_LIST { ".pat", 0 } + +/* Acoustic Grand Piano seems to be the usual default instrument. */ +#define DEFAULT_PROGRAM 0 + +/* 9 here is MIDI channel 10, which is the standard percussion channel. + Some files (notably C:\WINDOWS\CANYON.MID) think that 16 is one too. + On the other hand, some files know that 16 is not a drum channel and + try to play music on it. This is now a runtime option, so this isn't + a critical choice anymore. */ +#define DEFAULT_DRUMCHANNELS (1<<9) + +/* In percent. */ +#define DEFAULT_AMPLIFICATION 70 + +/* Default polyphony */ +/* #define DEFAULT_VOICES 32 */ +#define DEFAULT_VOICES 256 + +/* 1000 here will give a control ratio of 22:1 with 22 kHz output. + Higher CONTROLS_PER_SECOND values allow more accurate rendering + of envelopes and tremolo. The cost is CPU time. */ +#define CONTROLS_PER_SECOND 1000 + +/* Make envelopes twice as fast. Saves ~20% CPU time (notes decay + faster) and sounds more like a GUS. There is now a command line + option to toggle this as well. */ +#define FAST_DECAY + +/* How many bits to use for the fractional part of sample positions. + This affects tonal accuracy. The entire position counter must fit + in 32 bits, so with FRACTION_BITS equal to 12, the maximum size of + a sample is 1048576 samples (2 megabytes in memory). The GUS gets + by with just 9 bits and a little help from its friends... + "The GUS does not SUCK!!!" -- a happy user :) */ +#define FRACTION_BITS 12 + +/* For some reason the sample volume is always set to maximum in all + patch files. Define this for a crude adjustment that may help + equalize instrument volumes. */ +#define ADJUST_SAMPLE_VOLUMES + +/* The number of samples to use for ramping out a dying note. Affects + click removal. */ +#define MAX_DIE_TIME 20 + +/**************************************************************************/ +/* Anything below this shouldn't need to be changed unless you're porting + to a new machine with other than 32-bit, big-endian words. */ +/**************************************************************************/ + +/* change FRACTION_BITS above, not these */ +#define INTEGER_MASK (0xFFFFFFFF << FRACTION_BITS) +#define FRACTION_MASK (~ INTEGER_MASK) + +/* This is enforced by some computations that must fit in an int */ +#define MAX_CONTROL_RATIO 255 + +#define MAX_AMPLIFICATION 800 + +/* You could specify a complete path, e.g. "/etc/timidity.cfg", and + then specify the library directory in the configuration file. */ +#define CONFIG_FILE "timidity.cfg" +#define CONFIG_FILE_ETC "/etc/timidity.cfg" +#define CONFIG_FILE_ETC_TIMIDITY_FREEPATS "/etc/timidity/freepats.cfg" + +#if defined(__WIN32__) || defined(__OS2__) +#define DEFAULT_PATH "C:\\TIMIDITY" +#else +#define DEFAULT_PATH "/etc/timidity" +#define DEFAULT_PATH1 "/usr/share/timidity" +#define DEFAULT_PATH2 "/usr/local/share/timidity" +#define DEFAULT_PATH3 "/usr/local/lib/timidity" +#endif + +/* These affect general volume */ +#define GUARD_BITS 3 +#define AMP_BITS (15-GUARD_BITS) + +#define MAX_AMP_VALUE ((1<<(AMP_BITS+1))-1) + +#define FSCALE(a,b) (float)((a) * (double)(1<<(b))) +#define FSCALENEG(a,b) (float)((a) * (1.0L / (double)(1<<(b)))) + +/* Vibrato and tremolo Choices of the Day */ +#define SWEEP_TUNING 38 +#define VIBRATO_AMPLITUDE_TUNING 1.0L +#define VIBRATO_RATE_TUNING 38 +#define TREMOLO_AMPLITUDE_TUNING 1.0L +#define TREMOLO_RATE_TUNING 38 + +#define SWEEP_SHIFT 16 +#define RATE_SHIFT 5 + +#ifndef PI + #define PI 3.14159265358979323846 +#endif + +/* The path separator (D.M.) */ +#if defined(__WIN32__) || defined(__OS2__) +# define PATH_SEP '\\' +#else +# define PATH_SEP '/' +#endif + +#define SNDDBG(X) diff --git a/timidity/output.c b/timidity/output.c index 5dab01f..343c760 100644 --- a/timidity/output.c +++ b/timidity/output.c @@ -1,122 +1,129 @@ -/* +/* + TiMidity -- Experimental MIDI to WAVE converter Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ -#include "config.h" -#include "output.h" -#include "tables.h" + output.c + + Audio output (to file / device) functions. +*/ - -#ifdef SDL -extern PlayMode sdl_play_mode; -#define DEFAULT_PLAY_MODE &sdl_play_mode +#if HAVE_CONFIG_H +# include #endif -PlayMode *play_mode_list[] = { -#ifdef DEFAULT_PLAY_MODE - DEFAULT_PLAY_MODE, -#endif - 0 -}; +#include "SDL.h" -#ifdef DEFAULT_PLAY_MODE - PlayMode *play_mode=DEFAULT_PLAY_MODE; -#endif +#include "options.h" +#include "output.h" /*****************************************************************/ /* Some functions to convert signed 32-bit data to other formats */ -void s32tos8(void *dp, int32 *lp, int32 c) +void s32tos8(void *dp, Sint32 *lp, Sint32 c) { - int8 *cp=(int8 *)(dp); - int32 l; + Sint8 *cp=(Sint8 *)(dp); + Sint32 l; while (c--) { l=(*lp++)>>(32-8-GUARD_BITS); if (l>127) l=127; else if (l<-128) l=-128; - *cp++ = (int8) (l); + *cp++ = (Sint8) (l); } } -void s32tou8(void *dp, int32 *lp, int32 c) +void s32tou8(void *dp, Sint32 *lp, Sint32 c) { - uint8 *cp=(uint8 *)(dp); - int32 l; + Uint8 *cp=(Uint8 *)(dp); + Sint32 l; while (c--) { l=(*lp++)>>(32-8-GUARD_BITS); if (l>127) l=127; else if (l<-128) l=-128; - *cp++ = 0x80 ^ ((uint8) l); + *cp++ = 0x80 ^ ((Uint8) l); } } -void s32tos16(void *dp, int32 *lp, int32 c) +void s32tos16(void *dp, Sint32 *lp, Sint32 c) { - int16 *sp=(int16 *)(dp); - int32 l; + Sint16 *sp=(Sint16 *)(dp); + Sint32 l; while (c--) { l=(*lp++)>>(32-16-GUARD_BITS); if (l > 32767) l=32767; else if (l<-32768) l=-32768; - *sp++ = (int16)(l); + *sp++ = (Sint16)(l); } } -void s32tou16(void *dp, int32 *lp, int32 c) +void s32tou16(void *dp, Sint32 *lp, Sint32 c) { - uint16 *sp=(uint16 *)(dp); - int32 l; + Uint16 *sp=(Uint16 *)(dp); + Sint32 l; while (c--) { l=(*lp++)>>(32-16-GUARD_BITS); if (l > 32767) l=32767; else if (l<-32768) l=-32768; - *sp++ = 0x8000 ^ (uint16)(l); + *sp++ = 0x8000 ^ (Uint16)(l); } } -void s32tos16x(void *dp, int32 *lp, int32 c) +void s32tos16x(void *dp, Sint32 *lp, Sint32 c) { - int16 *sp=(int16 *)(dp); - int32 l; + Sint16 *sp=(Sint16 *)(dp); + Sint32 l; while (c--) { l=(*lp++)>>(32-16-GUARD_BITS); if (l > 32767) l=32767; else if (l<-32768) l=-32768; - *sp++ = XCHG_SHORT((int16)(l)); + *sp++ = SDL_Swap16((Sint16)(l)); } } -void s32tou16x(void *dp, int32 *lp, int32 c) +void s32tou16x(void *dp, Sint32 *lp, Sint32 c) { - uint16 *sp=(uint16 *)(dp); - int32 l; + Uint16 *sp=(Uint16 *)(dp); + Sint32 l; while (c--) { l=(*lp++)>>(32-16-GUARD_BITS); if (l > 32767) l=32767; else if (l<-32768) l=-32768; - *sp++ = XCHG_SHORT(0x8000 ^ (uint16)(l)); + *sp++ = SDL_Swap16(0x8000 ^ (Uint16)(l)); } } -void s32toulaw(void *dp, int32 *lp, int32 c) +void s32tof32(void *dp, Sint32 *lp, Sint32 c) { - uint8 *up=(uint8 *)(dp); - int32 l; + float *sp=(float *)(dp); while (c--) { - l=(*lp++)>>(32-13-GUARD_BITS); - if (l > 4095) l=4095; - else if (l<-4096) l=-4096; - *up++ = _l2u[l]; + *sp++ = (float)(*lp++) / 2147483647.0f; } } + +void s32tos32(void *dp, Sint32 *lp, Sint32 c) +{ + Sint32 *sp=(Sint32 *)(dp); + while (c--) + { + *sp++ = (*lp++); + } +} + +void s32tos32x(void *dp, Sint32 *lp, Sint32 c) +{ + Sint32 *sp=(Sint32 *)(dp); + while (c--) + { + *sp++ = SDL_Swap32(*lp++); + } +} diff --git a/timidity/output.h b/timidity/output.h index 598792d..849bb47 100644 --- a/timidity/output.h +++ b/timidity/output.h @@ -1,60 +1,57 @@ -/* +/* + TiMidity -- Experimental MIDI to WAVE converter Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ + + output.h + +*/ /* Data format encoding bits */ #define PE_MONO 0x01 /* versus stereo */ #define PE_SIGNED 0x02 /* versus unsigned */ #define PE_16BIT 0x04 /* versus 8-bit */ -#define PE_ULAW 0x08 /* versus linear */ -#define PE_BYTESWAP 0x10 /* versus the other way */ +#define PE_32BIT 0x08 /* versus 8-bit or 16-bit */ -typedef struct { - int32 rate, encoding; - char *id_name; -} PlayMode; - -extern PlayMode *play_mode_list[], *play_mode; -extern int init_buffers(int kbytes); - -/* Conversion functions -- These overwrite the int32 data in *lp with +/* Conversion functions -- These overwrite the Sint32 data in *lp with data in another format */ -/* The size of the output buffers */ -extern int AUDIO_BUFFER_SIZE; - -/* Actual copy function */ -extern void (*s32tobuf)(void *dp, int32 *lp, int32 c); - /* 8-bit signed and unsigned*/ -extern void s32tos8(void *dp, int32 *lp, int32 c); -extern void s32tou8(void *dp, int32 *lp, int32 c); +extern void s32tos8(void *dp, Sint32 *lp, Sint32 c); +extern void s32tou8(void *dp, Sint32 *lp, Sint32 c); /* 16-bit */ -extern void s32tos16(void *dp, int32 *lp, int32 c); -extern void s32tou16(void *dp, int32 *lp, int32 c); +extern void s32tos16(void *dp, Sint32 *lp, Sint32 c); +extern void s32tou16(void *dp, Sint32 *lp, Sint32 c); /* byte-exchanged 16-bit */ -extern void s32tos16x(void *dp, int32 *lp, int32 c); -extern void s32tou16x(void *dp, int32 *lp, int32 c); +extern void s32tos16x(void *dp, Sint32 *lp, Sint32 c); +extern void s32tou16x(void *dp, Sint32 *lp, Sint32 c); -/* uLaw (8 bits) */ -extern void s32toulaw(void *dp, int32 *lp, int32 c); +/* 32-bit */ +extern void s32tof32(void *dp, Sint32 *lp, Sint32 c); +extern void s32tos32(void *dp, Sint32 *lp, Sint32 c); + +/* byte-exchanged 32-bit */ +extern void s32tos32x(void *dp, Sint32 *lp, Sint32 c); /* little-endian and big-endian specific */ #if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define s32tos16l s32tos16 +#define s32tos16b s32tos16x #define s32tou16l s32tou16 #define s32tou16b s32tou16x -#define s32tos16l s32tos16 -#define s32tos16b s32tos16x +#define s32tos32l s32tos32 +#define s32tos32b s32tos32x #else +#define s32tos16l s32tos16x +#define s32tos16b s32tos16 #define s32tou16l s32tou16x #define s32tou16b s32tou16 -#define s32tos16l s32tos16x -#define s32tos16b s32tos16 +#define s32tos32l s32tos32x +#define s32tos32b s32tos32 #endif diff --git a/timidity/playmidi.c b/timidity/playmidi.c index dd12804..674dccd 100644 --- a/timidity/playmidi.c +++ b/timidity/playmidi.c @@ -1,142 +1,73 @@ /* + TiMidity -- Experimental MIDI to WAVE converter Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ + + playmidi.c -- random stuff in need of rearrangement + +*/ + +#if HAVE_CONFIG_H +# include +#endif #include #include #include -#include - -#include "config.h" -#include "common.h" +#include "SDL.h" + +#include "timidity.h" +#include "options.h" #include "instrum.h" #include "playmidi.h" -#include "readmidi.h" #include "output.h" #include "mix.h" -#include "ctrlmode.h" -#include "timidity.h" - #include "tables.h" - -static int opt_expression_curve = 2; -static int opt_volume_curve = 2; -static int opt_stereo_surround = 0; - - -Channel channel[MAXCHAN]; -Voice voice[MAX_VOICES]; -signed char drumvolume[MAXCHAN][MAXNOTE]; -signed char drumpanpot[MAXCHAN][MAXNOTE]; -signed char drumreverberation[MAXCHAN][MAXNOTE]; -signed char drumchorusdepth[MAXCHAN][MAXNOTE]; - -int - voices=DEFAULT_VOICES; - -int32 - control_ratio=0, - amplification=DEFAULT_AMPLIFICATION; - -FLOAT_T - master_volume; - -int32 drumchannels=DEFAULT_DRUMCHANNELS; -int adjust_panning_immediately=0; - -struct _MidiSong { - int32 samples; - MidiEvent *events; -}; -static int midi_playing = 0; -static int32 lost_notes, cut_notes; -static int32 *buffer_pointer; -static int32 buffered_count; -extern int32 *common_buffer; -extern resample_t *resample_buffer; /* to free it on Timidity_Close */ - -static MidiEvent *event_list, *current_event; -static int32 sample_count, current_sample; - -int GM_System_On=0; -int XG_System_On=0; -int GS_System_On=0; -int XG_System_reverb_type; -int XG_System_chorus_type; -int XG_System_variation_type; - - -static void adjust_amplification(void) +static void adjust_amplification(MidiSong *song) { - master_volume = (FLOAT_T)(amplification) / (FLOAT_T)100.0; - master_volume /= 2; -} - - -static void adjust_master_volume(int32 vol) -{ - master_volume = (double)(vol*amplification) / 1638400.0L; - master_volume /= 2; -} - - -static void reset_voices(void) + song->master_volume = (float)(song->amplification) / (float)100.0; +} + +static void reset_voices(MidiSong *song) { int i; for (i=0; ivoice[i].status=VOICE_FREE; } /* Process the Reset All Controllers event */ -static void reset_controllers(int c) -{ - channel[c].volume=90; /* Some standard says, although the SCC docs say 0. */ - channel[c].expression=127; /* SCC-1 does this. */ - channel[c].sustain=0; - channel[c].pitchbend=0x2000; - channel[c].pitchfactor=0; /* to be computed */ - - channel[c].reverberation = 0; - channel[c].chorusdepth = 0; -} - -static void redraw_controllers(int c) -{ - ctl->volume(c, channel[c].volume); - ctl->expression(c, channel[c].expression); - ctl->sustain(c, channel[c].sustain); - ctl->pitch_bend(c, channel[c].pitchbend); -} - -static void reset_midi(void) +static void reset_controllers(MidiSong *song, int c) +{ + song->channel[c].volume=90; /* Some standard says, although the SCC docs say 0. */ + song->channel[c].expression=127; /* SCC-1 does this. */ + song->channel[c].sustain=0; + song->channel[c].pitchbend=0x2000; + song->channel[c].pitchfactor=0; /* to be computed */ +} + +static void reset_midi(MidiSong *song) { int i; for (i=0; ichannel[i].program=song->default_program; + song->channel[i].panning=NO_PANNING; + song->channel[i].pitchsens=2; + song->channel[i].bank=0; /* tone bank or drum set */ + } + reset_voices(song); +} + +static void select_sample(MidiSong *song, int v, Instrument *ip, int vel) +{ + Sint32 f, cdiff, diff; int s,i; Sample *sp, *closest; @@ -145,11 +76,21 @@ if (s==1) { - voice[v].sample=sp; + song->voice[v].sample=sp; return; } - f=voice[v].orig_frequency; + f=song->voice[v].orig_frequency; + for (i=0; ilow_freq <= f && sp->high_freq >= f) + { + song->voice[v].sample=sp; + return; + } + sp++; + } + /* No suitable sample found! We'll select the sample whose root frequency is closest to the one we want. (Actually we should @@ -158,14 +99,9 @@ cdiff=0x7FFFFFFF; closest=sp=ip->sample; - midfreq = (sp->low_freq + sp->high_freq) / 2; for(i=0; iroot_freq - f; - /* But the root freq. can perfectly well lie outside the keyrange - * frequencies, so let's try: - */ - /* diff=midfreq - f; */ if (diff<0) diff=-diff; if (diffvoice[v].sample=closest; return; } - - -static void select_stereo_samples(int v, InstrumentLayer *lp) -{ - Instrument *ip; - InstrumentLayer *nlp, *bestvel; - int diffvel, midvel, mindiff; - -/* select closest velocity */ - bestvel = lp; - mindiff = 500; - for (nlp = lp; nlp; nlp = nlp->next) { - midvel = (nlp->hi + nlp->lo)/2; - if (!midvel) diffvel = 127; - else if (voice[v].velocity < nlp->lo || voice[v].velocity > nlp->hi) - diffvel = 200; - else diffvel = voice[v].velocity - midvel; - if (diffvel < 0) diffvel = -diffvel; - if (diffvel < mindiff) { - mindiff = diffvel; - bestvel = nlp; - } - } - ip = bestvel->instrument; - - if (ip->right_sample) { - ip->sample = ip->right_sample; - ip->samples = ip->right_samples; - select_sample(v, ip); - voice[v].right_sample = voice[v].sample; - } - else voice[v].right_sample = 0; - ip->sample = ip->left_sample; - ip->samples = ip->left_samples; - select_sample(v, ip); -} - - -static void recompute_freq(int v) +static void recompute_freq(MidiSong *song, int v) { int - sign=(voice[v].sample_increment < 0), /* for bidirectional loops */ - pb=channel[voice[v].channel].pitchbend; + sign=(song->voice[v].sample_increment < 0), /* for bidirectional loops */ + pb=song->channel[song->voice[v].channel].pitchbend; double a; - if (!voice[v].sample->sample_rate) + if (!song->voice[v].sample->sample_rate) return; - if (voice[v].vibrato_control_ratio) + if (song->voice[v].vibrato_control_ratio) { /* This instrument has vibrato. Invalidate any precomputed sample_increments. */ int i=VIBRATO_SAMPLE_INCREMENTS; while (i--) - voice[v].vibrato_sample_increment[i]=0; + song->voice[v].vibrato_sample_increment[i]=0; } if (pb==0x2000 || pb<0 || pb>0x3FFF) - voice[v].frequency=voice[v].orig_frequency; + song->voice[v].frequency = song->voice[v].orig_frequency; else { pb-=0x2000; - if (!(channel[voice[v].channel].pitchfactor)) + if (!(song->channel[song->voice[v].channel].pitchfactor)) { /* Damn. Somebody bent the pitch. */ - int32 i=pb*channel[voice[v].channel].pitchsens; + Sint32 i=pb*song->channel[song->voice[v].channel].pitchsens; if (pb<0) i=-i; - channel[voice[v].channel].pitchfactor= - (FLOAT_T)(bend_fine[(i>>5) & 0xFF] * bend_coarse[i>>13]); + song->channel[song->voice[v].channel].pitchfactor= + (float)(bend_fine[(i>>5) & 0xFF] * bend_coarse[i>>13]); } if (pb>0) - voice[v].frequency= - (int32)(channel[voice[v].channel].pitchfactor * - (double)(voice[v].orig_frequency)); + song->voice[v].frequency= + (Sint32)(song->channel[song->voice[v].channel].pitchfactor * + (double)(song->voice[v].orig_frequency)); else - voice[v].frequency= - (int32)((double)(voice[v].orig_frequency) / - channel[voice[v].channel].pitchfactor); - } - - a = FSCALE(((double)(voice[v].sample->sample_rate) * - (double)(voice[v].frequency)) / - ((double)(voice[v].sample->root_freq) * - (double)(play_mode->rate)), + song->voice[v].frequency= + (Sint32)((double)(song->voice[v].orig_frequency) / + song->channel[song->voice[v].channel].pitchfactor); + } + + a = FSCALE(((double)(song->voice[v].sample->sample_rate) * + (double)(song->voice[v].frequency)) / + ((double)(song->voice[v].sample->root_freq) * + (double)(song->rate)), FRACTION_BITS); if (sign) a = -a; /* need to preserve the loop direction */ - voice[v].sample_increment = (int32)(a); -} - -static int expr_curve[128] = { - 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 11, - 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 14, 14, 14, 14, 15, 15, - 15, 16, 16, 17, 17, 17, 18, 18, 19, 19, 19, 20, 20, 21, 21, 22, - 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 28, 28, 29, 30, 30, 31, - 32, 32, 33, 34, 35, 35, 36, 37, 38, 39, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 53, 54, 55, 56, 57, 59, 60, 61, 63, - 64, 65, 67, 68, 70, 71, 73, 75, 76, 78, 80, 82, 83, 85, 87, 89, - 91, 93, 95, 97, 99, 102, 104, 106, 109, 111, 113, 116, 118, 121, - 124, 127 -}; - -static int panf(int pan, int speaker, int separation) -{ - int val; - val = abs(pan - speaker); - val = (val * 127) / separation; - val = 127 - val; - if (val < 0) val = 0; - if (val > 127) val = 127; - return expr_curve[val]; -} - - -static int vcurve[128] = { -0,0,18,29,36,42,47,51,55,58, -60,63,65,67,69,71,73,74,76,77, -79,80,81,82,83,84,85,86,87,88, -89,90,91,92,92,93,94,95,95,96, -97,97,98,99,99,100,100,101,101,102, -103,103,104,104,105,105,106,106,106,107, -107,108,108,109,109,109,110,110,111,111, -111,112,112,112,113,113,114,114,114,115, -115,115,116,116,116,116,117,117,117,118, -118,118,119,119,119,119,120,120,120,120, -121,121,121,122,122,122,122,123,123,123, -123,123,124,124,124,124,125,125,125,125, -126,126,126,126,126,127,127,127 -}; - -static void recompute_amp(int v) -{ - int32 tempamp; - int chan = voice[v].channel; - int panning = voice[v].panning; - int vol = channel[chan].volume; - int expr = channel[chan].expression; - int vel = vcurve[voice[v].velocity]; - FLOAT_T curved_expression, curved_volume; - - if (channel[chan].kit) - { - int note = voice[v].sample->note_to_use; - if (note>0 && drumvolume[chan][note]>=0) vol = drumvolume[chan][note]; - if (note>0 && drumpanpot[chan][note]>=0) panning = drumpanpot[chan][note]; - } - - if (opt_expression_curve == 2) curved_expression = 127.0 * vol_table[expr]; - else if (opt_expression_curve == 1) curved_expression = 127.0 * expr_table[expr]; - else curved_expression = (FLOAT_T)expr; - - if (opt_volume_curve == 2) curved_volume = 127.0 * vol_table[vol]; - else if (opt_volume_curve == 1) curved_volume = 127.0 * expr_table[vol]; - else curved_volume = (FLOAT_T)vol; - - tempamp= (int32)((FLOAT_T)vel * curved_volume * curved_expression); /* 21 bits */ + song->voice[v].sample_increment = (Sint32)(a); +} + +static void recompute_amp(MidiSong *song, int v) +{ + Sint32 tempamp; /* TODO: use fscale */ - if (num_ochannels > 1) - { - if (panning > 60 && panning < 68) - { - voice[v].panned=PANNED_CENTER; - - if (num_ochannels == 6) voice[v].left_amp = - FSCALENEG((double) (tempamp) * voice[v].sample->volume * - master_volume, 20); - else voice[v].left_amp= - FSCALENEG((double)(tempamp) * voice[v].sample->volume * - master_volume, 21); - } - else if (panning<5) - { - voice[v].panned = PANNED_LEFT; - - voice[v].left_amp= - FSCALENEG((double)(tempamp) * voice[v].sample->volume * master_volume, + tempamp= (song->voice[v].velocity * + song->channel[song->voice[v].channel].volume * + song->channel[song->voice[v].channel].expression); /* 21 bits */ + + if (!(song->encoding & PE_MONO)) + { + if (song->voice[v].panning > 60 && song->voice[v].panning < 68) + { + song->voice[v].panned=PANNED_CENTER; + + song->voice[v].left_amp= + FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume, + 21); + } + else if (song->voice[v].panning<5) + { + song->voice[v].panned = PANNED_LEFT; + + song->voice[v].left_amp= + FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume, 20); } - else if (panning>123) - { - voice[v].panned = PANNED_RIGHT; - - voice[v].left_amp= /* left_amp will be used */ - FSCALENEG((double)(tempamp) * voice[v].sample->volume * master_volume, + else if (song->voice[v].panning>123) + { + song->voice[v].panned = PANNED_RIGHT; + + song->voice[v].left_amp= /* left_amp will be used */ + FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume, 20); } else { - FLOAT_T refv = (double)(tempamp) * voice[v].sample->volume * master_volume; - int wide_panning = 64; - - if (num_ochannels == 4) wide_panning = 95; - - voice[v].panned = PANNED_MYSTERY; - voice[v].lfe_amp = FSCALENEG(refv * 64, 27); - - switch (num_ochannels) - { - case 2: - voice[v].lr_amp = 0; - voice[v].left_amp = FSCALENEG(refv * (128-panning), 27); - voice[v].ce_amp = 0; - voice[v].right_amp = FSCALENEG(refv * panning, 27); - voice[v].rr_amp = 0; - break; - case 4: - voice[v].lr_amp = FSCALENEG(refv * panf(panning, 0, wide_panning), 27); - voice[v].left_amp = FSCALENEG(refv * panf(panning, 32, wide_panning), 27); - voice[v].ce_amp = 0; - voice[v].right_amp = FSCALENEG(refv * panf(panning, 95, wide_panning), 27); - voice[v].rr_amp = FSCALENEG(refv * panf(panning, 128, wide_panning), 27); - break; - case 6: - voice[v].lr_amp = FSCALENEG(refv * panf(panning, 0, wide_panning), 27); - voice[v].left_amp = FSCALENEG(refv * panf(panning, 32, wide_panning), 27); - voice[v].ce_amp = FSCALENEG(refv * panf(panning, 64, wide_panning), 27); - voice[v].right_amp = FSCALENEG(refv * panf(panning, 95, wide_panning), 27); - voice[v].rr_amp = FSCALENEG(refv * panf(panning, 128, wide_panning), 27); - break; - } - - } - } - else - { - voice[v].panned=PANNED_CENTER; - - voice[v].left_amp= - FSCALENEG((double)(tempamp) * voice[v].sample->volume * master_volume, + song->voice[v].panned = PANNED_MYSTERY; + + song->voice[v].left_amp= + FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume, + 27); + song->voice[v].right_amp = song->voice[v].left_amp * (song->voice[v].panning); + song->voice[v].left_amp *= (float)(127 - song->voice[v].panning); + } + } + else + { + song->voice[v].panned = PANNED_CENTER; + + song->voice[v].left_amp= + FSCALENEG((double)(tempamp) * song->voice[v].sample->volume * song->master_volume, 21); } } - -#define NOT_CLONE 0 -#define STEREO_CLONE 1 -#define REVERB_CLONE 2 -#define CHORUS_CLONE 3 - - -/* just a variant of note_on() */ -static int vc_alloc(int j) -{ - int i=voices; +static void start_note(MidiSong *song, MidiEvent *e, int i) +{ + Instrument *ip; + int j; + + if (ISDRUMCHANNEL(song, e->channel)) + { + if (!(ip=song->drumset[song->channel[e->channel].bank]->instrument[e->a])) + { + if (!(ip=song->drumset[0]->instrument[e->a])) + return; /* No instrument? Then we can't play. */ + } + if (ip->samples != 1) + { + SNDDBG(("Strange: percussion instrument with %d samples!", + ip->samples)); + } + + if (ip->sample->note_to_use) /* Do we have a fixed pitch? */ + song->voice[i].orig_frequency = freq_table[(int)(ip->sample->note_to_use)]; + else + song->voice[i].orig_frequency = freq_table[e->a & 0x7F]; + + /* drums are supposed to have only one sample */ + song->voice[i].sample = ip->sample; + } + else + { + if (song->channel[e->channel].program == SPECIAL_PROGRAM) + ip=song->default_instrument; + else if (!(ip=song->tonebank[song->channel[e->channel].bank]-> + instrument[song->channel[e->channel].program])) + { + if (!(ip=song->tonebank[0]->instrument[song->channel[e->channel].program])) + return; /* No instrument? Then we can't play. */ + } + + if (ip->sample->note_to_use) /* Fixed-pitch instrument? */ + song->voice[i].orig_frequency = freq_table[(int)(ip->sample->note_to_use)]; + else + song->voice[i].orig_frequency = freq_table[e->a & 0x7F]; + select_sample(song, i, ip, e->b); + } + + song->voice[i].status = VOICE_ON; + song->voice[i].channel = e->channel; + song->voice[i].note = e->a; + song->voice[i].velocity = e->b; + song->voice[i].sample_offset = 0; + song->voice[i].sample_increment = 0; /* make sure it isn't negative */ + + song->voice[i].tremolo_phase = 0; + song->voice[i].tremolo_phase_increment = song->voice[i].sample->tremolo_phase_increment; + song->voice[i].tremolo_sweep = song->voice[i].sample->tremolo_sweep_increment; + song->voice[i].tremolo_sweep_position = 0; + + song->voice[i].vibrato_sweep = song->voice[i].sample->vibrato_sweep_increment; + song->voice[i].vibrato_sweep_position = 0; + song->voice[i].vibrato_control_ratio = song->voice[i].sample->vibrato_control_ratio; + song->voice[i].vibrato_control_counter = song->voice[i].vibrato_phase = 0; + for (j=0; jvoice[i].vibrato_sample_increment[j] = 0; + + if (song->channel[e->channel].panning != NO_PANNING) + song->voice[i].panning = song->channel[e->channel].panning; + else + song->voice[i].panning = song->voice[i].sample->panning; + + recompute_freq(song, i); + recompute_amp(song, i); + if (song->voice[i].sample->modes & MODES_ENVELOPE) + { + /* Ramp up from 0 */ + song->voice[i].envelope_stage = 0; + song->voice[i].envelope_volume = 0; + song->voice[i].control_counter = 0; + recompute_envelope(song, i); + apply_envelope_to_amp(song, i); + } + else + { + song->voice[i].envelope_increment = 0; + apply_envelope_to_amp(song, i); + } +} + +static void kill_note(MidiSong *song, int i) +{ + song->voice[i].status = VOICE_DIE; +} + +/* Only one instance of a note can be playing on a single channel. */ +static void note_on(MidiSong *song) +{ + int i = song->voices, lowest=-1; + Sint32 lv=0x7FFFFFFF, v; + MidiEvent *e = song->current_event; while (i--) { - if (i == j) continue; - if (voice[i].status & VOICE_FREE) { - return i; - } - } - return -1; -} - -static void kill_note(int i); - -static void kill_others(int i) -{ - int j=voices; - - if (!voice[i].sample->exclusiveClass) return; - - while (j--) - { - if (voice[j].status & (VOICE_FREE|VOICE_OFF|VOICE_DIE)) continue; - if (i == j) continue; - if (voice[i].channel != voice[j].channel) continue; - if (voice[j].sample->note_to_use) - { - if (voice[j].sample->exclusiveClass != voice[i].sample->exclusiveClass) continue; - kill_note(j); - } - } -} - - -static void clone_voice(Instrument *ip, int v, MidiEvent *e, int clone_type, int variationbank) -{ - int w, played_note, chorus=0, reverb=0, milli; - int chan = voice[v].channel; - - if (clone_type == STEREO_CLONE) { - if (!voice[v].right_sample && variationbank != 3) return; - if (variationbank == 6) return; - } - - if (channel[chan].kit) { - reverb = drumreverberation[chan][voice[v].note]; - chorus = drumchorusdepth[chan][voice[v].note]; - } - else { - reverb = channel[chan].reverberation; - chorus = channel[chan].chorusdepth; - } - - if (clone_type == REVERB_CLONE) chorus = 0; - else if (clone_type == CHORUS_CLONE) reverb = 0; - else if (clone_type == STEREO_CLONE) reverb = chorus = 0; - - if (reverb > 127) reverb = 127; - if (chorus > 127) chorus = 127; - - if (clone_type == CHORUS_CLONE) { - if (variationbank == 32) chorus = 30; - else if (variationbank == 33) chorus = 60; - else if (variationbank == 34) chorus = 90; - } - - chorus /= 2; /* This is an ad hoc adjustment. */ - - if (!reverb && !chorus && clone_type != STEREO_CLONE) return; - - if ( (w = vc_alloc(v)) < 0 ) return; - - voice[w] = voice[v]; - if (clone_type==STEREO_CLONE) voice[v].clone_voice = w; - voice[w].clone_voice = v; - voice[w].clone_type = clone_type; - - voice[w].sample = voice[v].right_sample; - voice[w].velocity= e->b; - - milli = play_mode->rate/1000; - - if (clone_type == STEREO_CLONE) { - int left, right, leftpan, rightpan; - int panrequest = voice[v].panning; - if (variationbank == 3) { - voice[v].panning = 0; - voice[w].panning = 127; - } - else { - if (voice[v].sample->panning > voice[w].sample->panning) { - left = w; - right = v; - } - else { - left = v; - right = w; - } -#define INSTRUMENT_SEPARATION 12 - leftpan = panrequest - INSTRUMENT_SEPARATION / 2; - rightpan = leftpan + INSTRUMENT_SEPARATION; - if (leftpan < 0) { - leftpan = 0; - rightpan = leftpan + INSTRUMENT_SEPARATION; - } - if (rightpan > 127) { - rightpan = 127; - leftpan = rightpan - INSTRUMENT_SEPARATION; - } - voice[left].panning = leftpan; - voice[right].panning = rightpan; - voice[right].echo_delay = 20 * milli; - } - } - - voice[w].volume = voice[w].sample->volume; - - if (reverb) { - if (opt_stereo_surround) { - if (voice[w].panning > 64) voice[w].panning = 127; - else voice[w].panning = 0; - } - else { - if (voice[v].panning < 64) voice[w].panning = 64 + reverb/2; - else voice[w].panning = 64 - reverb/2; - } - -/* try 98->99 for melodic instruments ? (bit much for percussion) */ - voice[w].volume *= vol_table[(127-reverb)/8 + 98]; - - voice[w].echo_delay += reverb * milli; - voice[w].envelope_rate[DECAY] *= 2; - voice[w].envelope_rate[RELEASE] /= 2; - - if (XG_System_reverb_type >= 0) { - int subtype = XG_System_reverb_type & 0x07; - int rtype = XG_System_reverb_type >>3; - switch (rtype) { - case 0: /* no effect */ - break; - case 1: /* hall */ - if (subtype) voice[w].echo_delay += 100 * milli; - break; - case 2: /* room */ - voice[w].echo_delay /= 2; - break; - case 3: /* stage */ - voice[w].velocity = voice[v].velocity; - break; - case 4: /* plate */ - voice[w].panning = voice[v].panning; - break; - case 16: /* white room */ - voice[w].echo_delay = 0; - break; - case 17: /* tunnel */ - voice[w].echo_delay *= 2; - voice[w].velocity /= 2; - break; - case 18: /* canyon */ - voice[w].echo_delay *= 2; - break; - case 19: /* basement */ - voice[w].velocity /= 2; - break; - default: break; - } - } - } - played_note = voice[w].sample->note_to_use; - if (!played_note) { - played_note = e->a & 0x7f; - if (variationbank == 35) played_note += 12; - else if (variationbank == 36) played_note -= 12; - else if (variationbank == 37) played_note += 7; - else if (variationbank == 36) played_note -= 7; - } -#if 0 - played_note = ( (played_note - voice[w].sample->freq_center) * voice[w].sample->freq_scale ) / 1024 + - voice[w].sample->freq_center; -#endif - voice[w].note = played_note; - voice[w].orig_frequency = freq_table[played_note]; - - if (chorus) { - if (opt_stereo_surround) { - if (voice[v].panning < 64) voice[w].panning = voice[v].panning + 32; - else voice[w].panning = voice[v].panning - 32; - } - - if (!voice[w].vibrato_control_ratio) { - voice[w].vibrato_control_ratio = 100; - voice[w].vibrato_depth = 6; - voice[w].vibrato_sweep = 74; - } - voice[w].volume *= 0.40; - voice[v].volume = voice[w].volume; - recompute_amp(v); - apply_envelope_to_amp(v); - voice[w].vibrato_sweep = chorus/2; - voice[w].vibrato_depth /= 2; - if (!voice[w].vibrato_depth) voice[w].vibrato_depth = 2; - voice[w].vibrato_control_ratio /= 2; - voice[w].echo_delay += 30 * milli; - - if (XG_System_chorus_type >= 0) { - int subtype = XG_System_chorus_type & 0x07; - int chtype = 0x0f & (XG_System_chorus_type >> 3); - switch (chtype) { - case 0: /* no effect */ - break; - case 1: /* chorus */ - chorus /= 3; - if(channel[ voice[w].channel ].pitchbend + chorus < 0x2000) - voice[w].orig_frequency = - (uint32)( (FLOAT_T)voice[w].orig_frequency * bend_fine[chorus] ); - else voice[w].orig_frequency = - (uint32)( (FLOAT_T)voice[w].orig_frequency / bend_fine[chorus] ); - if (subtype) voice[w].vibrato_depth *= 2; - break; - case 2: /* celeste */ - voice[w].orig_frequency += (voice[w].orig_frequency/128) * chorus; - break; - case 3: /* flanger */ - voice[w].vibrato_control_ratio = 10; - voice[w].vibrato_depth = 100; - voice[w].vibrato_sweep = 8; - voice[w].echo_delay += 200 * milli; - break; - case 4: /* symphonic : cf Children of the Night /128 bad, /1024 ok */ - voice[w].orig_frequency += (voice[w].orig_frequency/512) * chorus; - voice[v].orig_frequency -= (voice[v].orig_frequency/512) * chorus; - recompute_freq(v); - break; - case 8: /* phaser */ - break; - default: - break; - } - } - else { - chorus /= 3; - if(channel[ voice[w].channel ].pitchbend + chorus < 0x2000) - voice[w].orig_frequency = - (uint32)( (FLOAT_T)voice[w].orig_frequency * bend_fine[chorus] ); - else voice[w].orig_frequency = - (uint32)( (FLOAT_T)voice[w].orig_frequency / bend_fine[chorus] ); - } - } -#if 0 - voice[w].loop_start = voice[w].sample->loop_start; - voice[w].loop_end = voice[w].sample->loop_end; -#endif - voice[w].echo_delay_count = voice[w].echo_delay; - if (reverb) voice[w].echo_delay *= 2; - - recompute_freq(w); - recompute_amp(w); - if (voice[w].sample->modes & MODES_ENVELOPE) - { - /* Ramp up from 0 */ - voice[w].envelope_stage=ATTACK; - voice[w].modulation_stage=ATTACK; - voice[w].envelope_volume=0; - voice[w].modulation_volume=0; - voice[w].control_counter=0; - voice[w].modulation_counter=0; - recompute_envelope(w); - /*recompute_modulation(w);*/ - } - else - { - voice[w].envelope_increment=0; - voice[w].modulation_increment=0; - } - apply_envelope_to_amp(w); -} - - -static void xremap(int *banknumpt, int *this_notept, int this_kit) { - int i, newmap; - int banknum = *banknumpt; - int this_note = *this_notept; - int newbank, newnote; - - if (!this_kit) { - if (banknum == SFXBANK && tonebank[SFXBANK]) return; - if (banknum == SFXBANK && tonebank[120]) *banknumpt = 120; - return; - } - - if (this_kit != 127 && this_kit != 126) return; - - for (i = 0; i < XMAPMAX; i++) { - newmap = xmap[i][0]; - if (!newmap) return; - if (this_kit == 127 && newmap != XGDRUM) continue; - if (this_kit == 126 && newmap != SFXDRUM1) continue; - if (xmap[i][1] != banknum) continue; - if (xmap[i][3] != this_note) continue; - newbank = xmap[i][2]; - newnote = xmap[i][4]; - if (newbank == banknum && newnote == this_note) return; - if (!drumset[newbank]) return; - if (!drumset[newbank]->tone[newnote].layer) return; - if (drumset[newbank]->tone[newnote].layer == MAGIC_LOAD_INSTRUMENT) return; - *banknumpt = newbank; - *this_notept = newnote; - return; - } -} - - -static void start_note(MidiEvent *e, int i) -{ - InstrumentLayer *lp; - Instrument *ip; - int j, banknum, ch=e->channel; - int played_note, drumpan=NO_PANNING; - int32 rt; - int attacktime, releasetime, decaytime, variationbank; - int brightness = channel[ch].brightness; - int harmoniccontent = channel[ch].harmoniccontent; - int this_note = e->a; - int this_velocity = e->b; - int drumsflag = channel[ch].kit; - int this_prog = channel[ch].program; - - if (channel[ch].sfx) banknum=channel[ch].sfx; - else banknum=channel[ch].bank; - - voice[i].velocity=this_velocity; - - if (XG_System_On) xremap(&banknum, &this_note, drumsflag); - /* if (current_config_pc42b) pcmap(&banknum, &this_note, &this_prog, &drumsflag); */ - - if (drumsflag) - { - if (!(lp=drumset[banknum]->tone[this_note].layer)) - { - if (!(lp=drumset[0]->tone[this_note].layer)) - return; /* No instrument? Then we can't play. */ - } - ip = lp->instrument; - if (ip->type == INST_GUS && ip->samples != 1) - { - ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, - "Strange: percussion instrument with %d samples!", ip->samples); - } - - if (ip->sample->note_to_use) /* Do we have a fixed pitch? */ - { - voice[i].orig_frequency=freq_table[(int)(ip->sample->note_to_use)]; - drumpan=drumpanpot[ch][(int)ip->sample->note_to_use]; - } - else - voice[i].orig_frequency=freq_table[this_note & 0x7F]; - - } - else - { - if (channel[ch].program==SPECIAL_PROGRAM) - lp=default_instrument; - else if (!(lp=tonebank[channel[ch].bank]-> - tone[channel[ch].program].layer)) - { - if (!(lp=tonebank[0]->tone[this_prog].layer)) - return; /* No instrument? Then we can't play. */ - } - ip = lp->instrument; - if (ip->sample->note_to_use) /* Fixed-pitch instrument? */ - voice[i].orig_frequency=freq_table[(int)(ip->sample->note_to_use)]; - else - voice[i].orig_frequency=freq_table[this_note & 0x7F]; - } - - select_stereo_samples(i, lp); - - voice[i].starttime = e->time; - played_note = voice[i].sample->note_to_use; - - if (!played_note || !drumsflag) played_note = this_note & 0x7f; -#if 0 - played_note = ( (played_note - voice[i].sample->freq_center) * voice[i].sample->freq_scale ) / 1024 + - voice[i].sample->freq_center; -#endif - voice[i].status=VOICE_ON; - voice[i].channel=ch; - voice[i].note=played_note; - voice[i].velocity=this_velocity; - voice[i].sample_offset=0; - voice[i].sample_increment=0; /* make sure it isn't negative */ - - voice[i].tremolo_phase=0; - voice[i].tremolo_phase_increment=voice[i].sample->tremolo_phase_increment; - voice[i].tremolo_sweep=voice[i].sample->tremolo_sweep_increment; - voice[i].tremolo_sweep_position=0; - - voice[i].vibrato_sweep=voice[i].sample->vibrato_sweep_increment; - voice[i].vibrato_sweep_position=0; - voice[i].vibrato_depth=voice[i].sample->vibrato_depth; - voice[i].vibrato_control_ratio=voice[i].sample->vibrato_control_ratio; - voice[i].vibrato_control_counter=voice[i].vibrato_phase=0; - voice[i].vibrato_delay = voice[i].sample->vibrato_delay; - - kill_others(i); - - for (j=0; jcutoff_freq = 800; - break; - case 25: - voice[i].modEnvToFilterFc=-2.0; - voice[i].sample->cutoff_freq = 800; - break; - case 27: - voice[i].modLfoToFilterFc=2.0; - voice[i].lfo_phase_increment=109; - voice[i].lfo_sweep=122; - voice[i].sample->cutoff_freq = 800; - break; - case 28: - voice[i].modLfoToFilterFc=-2.0; - voice[i].lfo_phase_increment=109; - voice[i].lfo_sweep=122; - voice[i].sample->cutoff_freq = 800; - break; -#endif - default: - break; - } - - - for (j=ATTACK; jenvelope_rate[j]; - voice[i].envelope_offset[j]=voice[i].sample->envelope_offset[j]; - } - - voice[i].echo_delay=voice[i].envelope_rate[DELAY]; - voice[i].echo_delay_count = voice[i].echo_delay; - - if (attacktime!=64) - { - rt = voice[i].envelope_rate[ATTACK]; - rt = rt + ( (64-attacktime)*rt ) / 100; - if (rt > 1000) voice[i].envelope_rate[ATTACK] = rt; - } - if (releasetime!=64) - { - rt = voice[i].envelope_rate[RELEASE]; - rt = rt + ( (64-releasetime)*rt ) / 100; - if (rt > 1000) voice[i].envelope_rate[RELEASE] = rt; - } - if (decaytime!=64) - { - rt = voice[i].envelope_rate[DECAY]; - rt = rt + ( (64-decaytime)*rt ) / 100; - if (rt > 1000) voice[i].envelope_rate[DECAY] = rt; - } - - if (channel[ch].panning != NO_PANNING) - voice[i].panning=channel[ch].panning; - else - voice[i].panning=voice[i].sample->panning; - if (drumpan != NO_PANNING) - voice[i].panning=drumpan; - - if (variationbank == 1) { - int pan = voice[i].panning; - int disturb = 0; - /* If they're close up (no reverb) and you are behind the pianist, - * high notes come from the right, so we'll spread piano etc. notes - * out horizontally according to their pitches. - */ - if (this_prog < 21) { - int n = voice[i].velocity - 32; - if (n < 0) n = 0; - if (n > 64) n = 64; - pan = pan/2 + n; - } - /* For other types of instruments, the music sounds more alive if - * notes come from slightly different directions. However, instruments - * do drift around in a sometimes disconcerting way, so the following - * might not be such a good idea. - */ - else disturb = (voice[i].velocity/32 % 8) + - (voice[i].note % 8); /* /16? */ - - if (pan < 64) pan += disturb; - else pan -= disturb; - if (pan < 0) pan = 0; - else if (pan > 127) pan = 127; - voice[i].panning = pan; - } - - recompute_freq(i); - recompute_amp(i); - if (voice[i].sample->modes & MODES_ENVELOPE) - { - /* Ramp up from 0 */ - voice[i].envelope_stage=ATTACK; - voice[i].envelope_volume=0; - voice[i].control_counter=0; - recompute_envelope(i); - } - else - { - voice[i].envelope_increment=0; - } - apply_envelope_to_amp(i); - - voice[i].clone_voice = -1; - voice[i].clone_type = NOT_CLONE; - - clone_voice(ip, i, e, STEREO_CLONE, variationbank); - clone_voice(ip, i, e, CHORUS_CLONE, variationbank); - clone_voice(ip, i, e, REVERB_CLONE, variationbank); - - ctl->note(i); -} - -static void kill_note(int i) -{ - voice[i].status=VOICE_DIE; - if (voice[i].clone_voice >= 0) - voice[ voice[i].clone_voice ].status=VOICE_DIE; - ctl->note(i); -} - - -/* Only one instance of a note can be playing on a single channel. */ -static void note_on(MidiEvent *e) -{ - int i=voices, lowest=-1; - int32 lv=0x7FFFFFFF, v; - + if (song->voice[i].status == VOICE_FREE) + lowest=i; /* Can't get a lower volume than silence */ + else if (song->voice[i].channel==e->channel && + (song->voice[i].note==e->a || song->channel[song->voice[i].channel].mono)) + kill_note(song, i); + } + + if (lowest != -1) + { + /* Found a free voice. */ + start_note(song,e,lowest); + return; + } + + /* Look for the decaying note with the lowest volume */ + i = song->voices; while (i--) { - if (voice[i].status == VOICE_FREE) - lowest=i; /* Can't get a lower volume than silence */ - else if (voice[i].channel==e->channel && - (voice[i].note==e->a || channel[voice[i].channel].mono)) - kill_note(i); - } - - if (lowest != -1) - { - /* Found a free voice. */ - start_note(e,lowest); - return; - } - -#if 0 - /* Look for the decaying note with the lowest volume */ - i=voices; - while (i--) - { - if (voice[i].status & ~(VOICE_ON | VOICE_DIE | VOICE_FREE)) - { - v=voice[i].left_mix; - if ((voice[i].panned==PANNED_MYSTERY) && (voice[i].right_mix>v)) - v=voice[i].right_mix; + if ((song->voice[i].status != VOICE_ON) && + (song->voice[i].status != VOICE_DIE)) + { + v = song->voice[i].left_mix; + if ((song->voice[i].panned == PANNED_MYSTERY) + && (song->voice[i].right_mix > v)) + v = song->voice[i].right_mix; if (vv)) - v=voice[i].right_mix; - if (v= 0) { - if (voice[cl].clone_type==STEREO_CLONE || - (!voice[cl].clone_type && voice[lowest].clone_type==STEREO_CLONE)) - voice[cl].status=VOICE_FREE; - else if (voice[cl].clone_voice==lowest) voice[cl].clone_voice=-1; - } - - cut_notes++; - voice[lowest].status=VOICE_FREE; - ctl->note(lowest); - start_note(e,lowest); - } - else - lost_notes++; -} - -static void finish_note(int i) -{ - if (voice[i].sample->modes & MODES_ENVELOPE) + + song->cut_notes++; + song->voice[lowest].status=VOICE_FREE; + start_note(song,e,lowest); + } + else + song->lost_notes++; +} + +static void finish_note(MidiSong *song, int i) +{ + if (song->voice[i].sample->modes & MODES_ENVELOPE) { /* We need to get the envelope out of Sustain stage */ - voice[i].envelope_stage=3; - voice[i].status=VOICE_OFF; - recompute_envelope(i); - apply_envelope_to_amp(i); - ctl->note(i); + song->voice[i].envelope_stage = 3; + song->voice[i].status = VOICE_OFF; + recompute_envelope(song, i); + apply_envelope_to_amp(song, i); } else { /* Set status to OFF so resample_voice() will let this voice out of its loop, if any. In any case, this voice dies when it hits the end of its data (ofs>=data_length). */ - voice[i].status=VOICE_OFF; - } - - { int v; - if ( (v=voice[i].clone_voice) >= 0) + song->voice[i].status = VOICE_OFF; + } +} + +static void note_off(MidiSong *song) +{ + int i = song->voices; + MidiEvent *e = song->current_event; + + while (i--) + if (song->voice[i].status == VOICE_ON && + song->voice[i].channel == e->channel && + song->voice[i].note == e->a) { - voice[i].clone_voice = -1; - finish_note(v); - } - } -} - -static void note_off(MidiEvent *e) -{ - int i=voices, v; - while (i--) - if (voice[i].status==VOICE_ON && - voice[i].channel==e->channel && - voice[i].note==e->a) - { - if (channel[e->channel].sustain) + if (song->channel[e->channel].sustain) { - voice[i].status=VOICE_SUSTAINED; - - if ( (v=voice[i].clone_voice) >= 0) - { - if (voice[v].status == VOICE_ON) - voice[v].status=VOICE_SUSTAINED; - } - - ctl->note(i); + song->voice[i].status = VOICE_SUSTAINED; } else - finish_note(i); + finish_note(song, i); return; } } /* Process the All Notes Off event */ -static void all_notes_off(int c) -{ - int i=voices; - ctl->cmsg(CMSG_INFO, VERB_DEBUG, "All notes off on channel %d", c); +static void all_notes_off(MidiSong *song) +{ + int i = song->voices; + int c = song->current_event->channel; + + SNDDBG(("All notes off on channel %d", c)); while (i--) - if (voice[i].status==VOICE_ON && - voice[i].channel==c) + if (song->voice[i].status == VOICE_ON && + song->voice[i].channel == c) { - if (channel[c].sustain) - { - voice[i].status=VOICE_SUSTAINED; - ctl->note(i); - } + if (song->channel[c].sustain) + song->voice[i].status = VOICE_SUSTAINED; else - finish_note(i); + finish_note(song, i); } } /* Process the All Sounds Off event */ -static void all_sounds_off(int c) -{ - int i=voices; +static void all_sounds_off(MidiSong *song) +{ + int i = song->voices; + int c = song->current_event->channel; + while (i--) - if (voice[i].channel==c && - voice[i].status != VOICE_FREE && - voice[i].status != VOICE_DIE) + if (song->voice[i].channel == c && + song->voice[i].status != VOICE_FREE && + song->voice[i].status != VOICE_DIE) { - kill_note(i); + kill_note(song, i); } } -static void adjust_pressure(MidiEvent *e) -{ - int i=voices; +static void adjust_pressure(MidiSong *song) +{ + MidiEvent *e = song->current_event; + int i = song->voices; + while (i--) - if (voice[i].status==VOICE_ON && - voice[i].channel==e->channel && - voice[i].note==e->a) + if (song->voice[i].status == VOICE_ON && + song->voice[i].channel == e->channel && + song->voice[i].note == e->a) { - voice[i].velocity=e->b; - recompute_amp(i); - apply_envelope_to_amp(i); + song->voice[i].velocity = e->b; + recompute_amp(song, i); + apply_envelope_to_amp(song, i); return; } } -static void adjust_panning(int c) -{ - int i=voices; +static void drop_sustain(MidiSong *song) +{ + int i = song->voices; + int c = song->current_event->channel; + while (i--) - if ((voice[i].channel==c) && - (voice[i].status==VOICE_ON || voice[i].status==VOICE_SUSTAINED)) + if (song->voice[i].status == VOICE_SUSTAINED && song->voice[i].channel == c) + finish_note(song, i); +} + +static void adjust_pitchbend(MidiSong *song) +{ + int c = song->current_event->channel; + int i = song->voices; + + while (i--) + if (song->voice[i].status != VOICE_FREE && song->voice[i].channel == c) { - if (voice[i].clone_type != NOT_CLONE) continue; - voice[i].panning=channel[c].panning; - recompute_amp(i); - apply_envelope_to_amp(i); + recompute_freq(song, i); } } -static void drop_sustain(int c) -{ - int i=voices; +static void adjust_volume(MidiSong *song) +{ + int c = song->current_event->channel; + int i = song->voices; + while (i--) - if (voice[i].status==VOICE_SUSTAINED && voice[i].channel==c) - finish_note(i); -} - -static void adjust_pitchbend(int c) -{ - int i=voices; - while (i--) - if (voice[i].status!=VOICE_FREE && voice[i].channel==c) + if (song->voice[i].channel == c && + (song->voice[i].status==VOICE_ON || song->voice[i].status==VOICE_SUSTAINED)) { - recompute_freq(i); + recompute_amp(song, i); + apply_envelope_to_amp(song, i); } } -static void adjust_volume(int c) -{ - int i=voices; - while (i--) - if (voice[i].channel==c && - (voice[i].status==VOICE_ON || voice[i].status==VOICE_SUSTAINED)) - { - recompute_amp(i); - apply_envelope_to_amp(i); - } -} - -static void seek_forward(int32 until_time) -{ - reset_voices(); - while (current_event->time < until_time) - { - switch(current_event->type) +static void seek_forward(MidiSong *song, Sint32 until_time) +{ + reset_voices(song); + while (song->current_event->time < until_time) + { + switch(song->current_event->type) { /* All notes stay off. Just handle the parameter changes. */ case ME_PITCH_SENS: - channel[current_event->channel].pitchsens= - current_event->a; - channel[current_event->channel].pitchfactor=0; + song->channel[song->current_event->channel].pitchsens = + song->current_event->a; + song->channel[song->current_event->channel].pitchfactor = 0; break; case ME_PITCHWHEEL: - channel[current_event->channel].pitchbend= - current_event->a + current_event->b * 128; - channel[current_event->channel].pitchfactor=0; + song->channel[song->current_event->channel].pitchbend = + song->current_event->a + song->current_event->b * 128; + song->channel[song->current_event->channel].pitchfactor = 0; break; case ME_MAINVOLUME: - channel[current_event->channel].volume=current_event->a; - break; - - case ME_MASTERVOLUME: - adjust_master_volume(current_event->a + (current_event->b <<7)); + song->channel[song->current_event->channel].volume = + song->current_event->a; break; case ME_PAN: - channel[current_event->channel].panning=current_event->a; + song->channel[song->current_event->channel].panning = + song->current_event->a; break; case ME_EXPRESSION: - channel[current_event->channel].expression=current_event->a; + song->channel[song->current_event->channel].expression = + song->current_event->a; break; case ME_PROGRAM: - /* if (ISDRUMCHANNEL(current_event->channel)) */ - if (channel[current_event->channel].kit) + if (ISDRUMCHANNEL(song, song->current_event->channel)) /* Change drum set */ - channel[current_event->channel].bank=current_event->a; + song->channel[song->current_event->channel].bank = + song->current_event->a; else - channel[current_event->channel].program=current_event->a; + song->channel[song->current_event->channel].program = + song->current_event->a; break; case ME_SUSTAIN: - channel[current_event->channel].sustain=current_event->a; + song->channel[song->current_event->channel].sustain = + song->current_event->a; break; - - case ME_REVERBERATION: - channel[current_event->channel].reverberation=current_event->a; - break; - - case ME_CHORUSDEPTH: - channel[current_event->channel].chorusdepth=current_event->a; - break; - - case ME_HARMONICCONTENT: - channel[current_event->channel].harmoniccontent=current_event->a; - break; - - case ME_RELEASETIME: - channel[current_event->channel].releasetime=current_event->a; - break; - - case ME_ATTACKTIME: - channel[current_event->channel].attacktime=current_event->a; - break; - - case ME_BRIGHTNESS: - channel[current_event->channel].brightness=current_event->a; - break; - - case ME_TONE_KIT: - if (current_event->a==SFX_BANKTYPE) - { - channel[current_event->channel].sfx=SFXBANK; - channel[current_event->channel].kit=0; - } - else - { - channel[current_event->channel].sfx=0; - channel[current_event->channel].kit=current_event->a; - } - break; - - case ME_RESET_CONTROLLERS: - reset_controllers(current_event->channel); + reset_controllers(song, song->current_event->channel); break; case ME_TONE_BANK: - channel[current_event->channel].bank=current_event->a; + song->channel[song->current_event->channel].bank = + song->current_event->a; break; case ME_EOT: - current_sample=current_event->time; + song->current_sample = song->current_event->time; return; } - current_event++; - } - /*current_sample=current_event->time;*/ - if (current_event != event_list) - current_event--; - current_sample=until_time; -} - -static void skip_to(int32 until_time) -{ - if (current_sample > until_time) - current_sample=0; - - reset_midi(); - buffered_count=0; - buffer_pointer=common_buffer; - current_event=event_list; + song->current_event++; + } + /*song->current_sample=song->current_event->time;*/ + if (song->current_event != song->events) + song->current_event--; + song->current_sample=until_time; +} + +static void skip_to(MidiSong *song, Sint32 until_time) +{ + if (song->current_sample > until_time) + song->current_sample = 0; + + reset_midi(song); + song->buffered_count = 0; + song->buffer_pointer = song->common_buffer; + song->current_event = song->events; if (until_time) - seek_forward(until_time); - ctl->reset(); -} - -static int apply_controls(void) -{ - int rc, i, did_skip=0; - int32 val; - /* ASCII renditions of CD player pictograms indicate approximate effect */ - do - switch(rc=ctl->read(&val)) - { - case RC_QUIT: /* [] */ - case RC_LOAD_FILE: - case RC_NEXT: /* >>| */ - case RC_REALLY_PREVIOUS: /* |<< */ - return rc; - - case RC_CHANGE_VOLUME: - if (val>0 || amplification > -val) - amplification += val; - else - amplification=0; - if (amplification > MAX_AMPLIFICATION) - amplification=MAX_AMPLIFICATION; - adjust_amplification(); - for (i=0; imaster_volume(amplification); - break; - - case RC_PREVIOUS: /* |<< */ - if (current_sample < 2*play_mode->rate) - return RC_REALLY_PREVIOUS; - return RC_RESTART; - - case RC_RESTART: /* |<< */ - skip_to(0); - did_skip=1; - break; - - case RC_JUMP: - if (val >= sample_count) - return RC_NEXT; - skip_to(val); - return rc; - - case RC_FORWARD: /* >> */ - if (val+current_sample >= sample_count) - return RC_NEXT; - skip_to(val+current_sample); - did_skip=1; - break; - - case RC_BACK: /* << */ - if (current_sample > val) - skip_to(current_sample-val); - else - skip_to(0); /* We can't seek to end of previous song. */ - did_skip=1; - break; - } - while (rc!= RC_NONE); - - /* Advertise the skip so that we stop computing the audio buffer */ - if (did_skip) - return RC_JUMP; - else - return rc; -} - -static void do_compute_data(uint32 count) + seek_forward(song, until_time); +} + +static void do_compute_data(MidiSong *song, Sint32 count) { int i; - if (!count) return; /* (gl) */ - memset(buffer_pointer, 0, count * num_ochannels * 4); - for (i=0; i= count) voice[i].echo_delay_count -= count; - else - { - mix_voice(buffer_pointer+voice[i].echo_delay_count, i, count-voice[i].echo_delay_count); - voice[i].echo_delay_count = 0; - } - } - else mix_voice(buffer_pointer, i, count); - } - } - current_sample += count; -} - + memset(song->buffer_pointer, 0, + (song->encoding & PE_MONO) ? (count * 4) : (count * 8)); + for (i = 0; i < song->voices; i++) + { + if(song->voice[i].status != VOICE_FREE) + mix_voice(song, song->buffer_pointer, i, count); + } + song->current_sample += count; +} /* count=0 means flush remaining buffered data to output device, then flush the device itself */ -static int compute_data(void *stream, int32 count) -{ - int rc, channels; - - if ( play_mode->encoding & PE_MONO ) +static void compute_data(MidiSong *song, void *stream, Sint32 count) +{ + int channels; + + if ( song->encoding & PE_MONO ) channels = 1; else - channels = num_ochannels; + channels = 2; if (!count) { - if (buffered_count) - s32tobuf(stream, common_buffer, channels*buffered_count); - buffer_pointer=common_buffer; - buffered_count=0; - return RC_NONE; - } - - while ((count+buffered_count) >= AUDIO_BUFFER_SIZE) - { - do_compute_data(AUDIO_BUFFER_SIZE-buffered_count); - count -= AUDIO_BUFFER_SIZE-buffered_count; - s32tobuf(stream, common_buffer, channels*AUDIO_BUFFER_SIZE); - buffer_pointer=common_buffer; - buffered_count=0; - - ctl->current_time(current_sample); - if ((rc=apply_controls())!=RC_NONE) - return rc; + if (song->buffered_count) + song->write(stream, song->common_buffer, channels * song->buffered_count); + song->buffer_pointer = song->common_buffer; + song->buffered_count = 0; + return; + } + + while ((count + song->buffered_count) >= song->buffer_size) + { + do_compute_data(song, song->buffer_size - song->buffered_count); + count -= song->buffer_size - song->buffered_count; + song->write(stream, song->common_buffer, channels * song->buffer_size); + song->buffer_pointer = song->common_buffer; + song->buffered_count = 0; } if (count>0) { - do_compute_data(count); - buffered_count += count; - buffer_pointer += count * channels; - } - return RC_NONE; -} - -int Timidity_PlaySome(void *stream, int samples) -{ - int rc = RC_NONE; - int32 end_sample; - - if ( ! midi_playing ) { - return RC_NONE; - } - end_sample = current_sample+samples; - while ( current_sample < end_sample ) { + do_compute_data(song, count); + song->buffered_count += count; + song->buffer_pointer += (song->encoding & PE_MONO) ? count : count*2; + } +} + +void Timidity_Start(MidiSong *song) +{ + song->playing = 1; + adjust_amplification(song); + skip_to(song, 0); +} + +void Timidity_Seek(MidiSong *song, Uint32 ms) +{ + skip_to(song, (ms * song->rate) / 1000); +} + +Uint32 Timidity_GetSongLength(MidiSong *song) +{ + MidiEvent *last_event = &song->events[song->groomed_event_count - 1]; + /* We want last_event->time * 1000 / song->rate */ + Uint32 retvalue = (last_event->time / song->rate) * 1000; + retvalue += (last_event->time % song->rate) * 1000 / song->rate; + return retvalue; +} + +int Timidity_PlaySome(MidiSong *song, void *stream, Sint32 len) +{ + Sint32 start_sample, end_sample, samples; + int bytes_per_sample; + + if (!song->playing) + return 0; + + bytes_per_sample = 1; + bytes_per_sample *= ((song->encoding & PE_32BIT) ? 4 : ((song->encoding & PE_16BIT) ? 2 : 1)); + bytes_per_sample *= ((song->encoding & PE_MONO) ? 1 : 2); + samples = len / bytes_per_sample; + + start_sample = song->current_sample; + end_sample = song->current_sample+samples; + while ( song->current_sample < end_sample ) { /* Handle all events that should happen at this time */ - while (current_event->time <= current_sample) { - switch(current_event->type) { + while (song->current_event->time <= song->current_sample) { + switch(song->current_event->type) { /* Effects affecting a single note */ case ME_NOTEON: - current_event->a += channel[current_event->channel].transpose; - if (!(current_event->b)) /* Velocity 0? */ - note_off(current_event); + if (!(song->current_event->b)) /* Velocity 0? */ + note_off(song); else - note_on(current_event); + note_on(song); break; case ME_NOTEOFF: - current_event->a += channel[current_event->channel].transpose; - note_off(current_event); + note_off(song); break; case ME_KEYPRESSURE: - adjust_pressure(current_event); + adjust_pressure(song); break; /* Effects affecting a single channel */ case ME_PITCH_SENS: - channel[current_event->channel].pitchsens=current_event->a; - channel[current_event->channel].pitchfactor=0; + song->channel[song->current_event->channel].pitchsens = + song->current_event->a; + song->channel[song->current_event->channel].pitchfactor = 0; break; case ME_PITCHWHEEL: - channel[current_event->channel].pitchbend= - current_event->a + current_event->b * 128; - channel[current_event->channel].pitchfactor=0; + song->channel[song->current_event->channel].pitchbend = + song->current_event->a + song->current_event->b * 128; + song->channel[song->current_event->channel].pitchfactor = 0; /* Adjust pitch for notes already playing */ - adjust_pitchbend(current_event->channel); - ctl->pitch_bend(current_event->channel, - channel[current_event->channel].pitchbend); + adjust_pitchbend(song); break; case ME_MAINVOLUME: - channel[current_event->channel].volume=current_event->a; - adjust_volume(current_event->channel); - ctl->volume(current_event->channel, current_event->a); - break; - - case ME_MASTERVOLUME: - adjust_master_volume(current_event->a + (current_event->b <<7)); - break; - - case ME_REVERBERATION: - channel[current_event->channel].reverberation=current_event->a; - break; - - case ME_CHORUSDEPTH: - channel[current_event->channel].chorusdepth=current_event->a; - break; - + song->channel[song->current_event->channel].volume = + song->current_event->a; + adjust_volume(song); + break; + case ME_PAN: - channel[current_event->channel].panning=current_event->a; - if (adjust_panning_immediately) - adjust_panning(current_event->channel); - ctl->panning(current_event->channel, current_event->a); + song->channel[song->current_event->channel].panning = + song->current_event->a; break; case ME_EXPRESSION: - channel[current_event->channel].expression=current_event->a; - adjust_volume(current_event->channel); - ctl->expression(current_event->channel, current_event->a); + song->channel[song->current_event->channel].expression = + song->current_event->a; + adjust_volume(song); break; case ME_PROGRAM: - /* if (ISDRUMCHANNEL(current_event->channel)) { */ - if (channel[current_event->channel].kit) { + if (ISDRUMCHANNEL(song, song->current_event->channel)) { /* Change drum set */ - channel[current_event->channel].bank=current_event->a; + song->channel[song->current_event->channel].bank = + song->current_event->a; } else - { - channel[current_event->channel].program=current_event->a; - } - ctl->program(current_event->channel, current_event->a); + song->channel[song->current_event->channel].program = + song->current_event->a; break; case ME_SUSTAIN: - channel[current_event->channel].sustain=current_event->a; - if (!current_event->a) - drop_sustain(current_event->channel); - ctl->sustain(current_event->channel, current_event->a); + song->channel[song->current_event->channel].sustain = + song->current_event->a; + if (!song->current_event->a) + drop_sustain(song); break; case ME_RESET_CONTROLLERS: - reset_controllers(current_event->channel); - redraw_controllers(current_event->channel); + reset_controllers(song, song->current_event->channel); break; case ME_ALL_NOTES_OFF: - all_notes_off(current_event->channel); + all_notes_off(song); break; case ME_ALL_SOUNDS_OFF: - all_sounds_off(current_event->channel); - break; - - case ME_HARMONICCONTENT: - channel[current_event->channel].harmoniccontent=current_event->a; - break; - - case ME_RELEASETIME: - channel[current_event->channel].releasetime=current_event->a; - break; - - case ME_ATTACKTIME: - channel[current_event->channel].attacktime=current_event->a; - break; - - case ME_BRIGHTNESS: - channel[current_event->channel].brightness=current_event->a; - break; - + all_sounds_off(song); + break; + case ME_TONE_BANK: - channel[current_event->channel].bank=current_event->a; - break; - - - case ME_TONE_KIT: - if (current_event->a==SFX_BANKTYPE) - { - channel[current_event->channel].sfx=SFXBANK; - channel[current_event->channel].kit=0; - } - else - { - channel[current_event->channel].sfx=0; - channel[current_event->channel].kit=current_event->a; - } - break; - + song->channel[song->current_event->channel].bank = + song->current_event->a; + break; + case ME_EOT: /* Give the last notes a couple of seconds to decay */ - ctl->cmsg(CMSG_INFO, VERB_VERBOSE, - "Playing time: ~%d seconds", current_sample/play_mode->rate+2); - ctl->cmsg(CMSG_INFO, VERB_VERBOSE, - "Notes cut: %d", cut_notes); - ctl->cmsg(CMSG_INFO, VERB_VERBOSE, - "Notes lost totally: %d", lost_notes); - midi_playing = 0; - return RC_TUNE_END; + SNDDBG(("Playing time: ~%d seconds\n", + song->current_sample/song->rate+2)); + SNDDBG(("Notes cut: %d\n", song->cut_notes)); + SNDDBG(("Notes lost totally: %d\n", song->lost_notes)); + song->playing = 0; + return (song->current_sample - start_sample) * bytes_per_sample; } - current_event++; - } - if (current_event->time > end_sample) - rc=compute_data(stream, end_sample-current_sample); + song->current_event++; + } + if (song->current_event->time > end_sample) + compute_data(song, stream, end_sample-song->current_sample); else - rc=compute_data(stream, current_event->time-current_sample); - ctl->refresh(); - if ( (rc!=RC_NONE) && (rc!=RC_JUMP)) - break; + compute_data(song, stream, song->current_event->time-song->current_sample); } - return rc; -} - - -void Timidity_SetVolume(int volume) + return samples * bytes_per_sample; +} + +void Timidity_SetVolume(MidiSong *song, int volume) { int i; if (volume > MAX_AMPLIFICATION) - amplification=MAX_AMPLIFICATION; + song->amplification = MAX_AMPLIFICATION; else if (volume < 0) - amplification=0; - else - amplification=volume; - adjust_amplification(); - for (i=0; iamplification = 0; + else + song->amplification = volume; + adjust_amplification(song); + for (i = 0; i < song->voices; i++) + if (song->voice[i].status != VOICE_FREE) { - recompute_amp(i); - apply_envelope_to_amp(i); + recompute_amp(song, i); + apply_envelope_to_amp(song, i); } - ctl->master_volume(amplification); -} - -MidiSong *Timidity_LoadSong_RW(SDL_RWops *src, int freesrc) -{ - MidiSong *song; - int32 events; - - /* Allocate memory for the song */ - song = (MidiSong *)safe_malloc(sizeof(*song)); - memset(song, 0, sizeof(*song)); - - strcpy(midi_name, "SDLrwops source"); - - song->events = read_midi_file(src, &events, &song->samples); - if (song->events) { - if (freesrc) { - SDL_RWclose(src); - } - } else { - free(song); - song = NULL; - } - return(song); -} - -void Timidity_Start(MidiSong *song) -{ - load_missing_instruments(); - adjust_amplification(); - sample_count = song->samples; - event_list = song->events; - lost_notes=cut_notes=0; - - skip_to(0); - midi_playing = 1; -} - -int Timidity_Active(void) -{ - return(midi_playing); -} - -void Timidity_Stop(void) -{ - midi_playing = 0; -} - -void Timidity_FreeSong(MidiSong *song) -{ - if (free_instruments_afterwards) - free_instruments(); - - free(song->events); - free(song); -} - -void Timidity_Close(void) -{ - if (resample_buffer) { - free(resample_buffer); - resample_buffer=NULL; - } - if (common_buffer) { - free(common_buffer); - common_buffer=NULL; - } - free_instruments(); - free_pathlist(); -} - +} diff --git a/timidity/playmidi.h b/timidity/playmidi.h index 2a32d7e..03b287a 100644 --- a/timidity/playmidi.h +++ b/timidity/playmidi.h @@ -1,15 +1,14 @@ /* + TiMidity -- Experimental MIDI to WAVE converter Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ -typedef struct { - int32 time; - uint8 channel, type, a, b; -} MidiEvent; + playmidi.h + + */ /* Midi events */ #define ME_NONE 0 @@ -31,84 +30,11 @@ #define ME_TONE_BANK 15 #define ME_LYRIC 16 -#define ME_TONE_KIT 17 -#define ME_MASTERVOLUME 18 -#define ME_CHANNEL_PRESSURE 19 - -#define ME_HARMONICCONTENT 71 -#define ME_RELEASETIME 72 -#define ME_ATTACKTIME 73 -#define ME_BRIGHTNESS 74 - -#define ME_REVERBERATION 91 -#define ME_CHORUSDEPTH 93 #define ME_EOT 99 - -#define SFX_BANKTYPE 64 - -typedef struct { - int - bank, program, volume, sustain, panning, pitchbend, expression, - mono, /* one note only on this channel -- not implemented yet */ - /* new stuff */ - variationbank, reverberation, chorusdepth, harmoniccontent, - releasetime, attacktime, brightness, kit, sfx, - /* end new */ - pitchsens; - FLOAT_T - pitchfactor; /* precomputed pitch bend factor to save some fdiv's */ - char transpose; - char *name; -} Channel; - /* Causes the instrument's default panning to be used. */ #define NO_PANNING -1 -/* envelope points */ -#define MAXPOINT 7 - -typedef struct { - uint8 - status, channel, note, velocity, clone_type; - Sample *sample; - Sample *left_sample; - Sample *right_sample; - int32 clone_voice; - int32 - orig_frequency, frequency, - sample_offset, loop_start, loop_end; - int32 - envelope_volume, modulation_volume; - int32 - envelope_target, modulation_target; - int32 - tremolo_sweep, tremolo_sweep_position, tremolo_phase, - lfo_sweep, lfo_sweep_position, lfo_phase, - vibrato_sweep, vibrato_sweep_position, vibrato_depth, vibrato_delay, - starttime, echo_delay_count; - int32 - echo_delay, - sample_increment, - envelope_increment, - modulation_increment, - tremolo_phase_increment, - lfo_phase_increment; - - final_volume_t left_mix, right_mix, lr_mix, rr_mix, ce_mix, lfe_mix; - - FLOAT_T - left_amp, right_amp, lr_amp, rr_amp, ce_amp, lfe_amp, - volume, tremolo_volume, lfo_volume; - int32 - vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS]; - int32 - envelope_rate[MAXPOINT], envelope_offset[MAXPOINT]; - int32 - vibrato_phase, vibrato_control_ratio, vibrato_control_counter, - envelope_stage, modulation_stage, control_counter, - modulation_delay, modulation_counter, panning, panned; -} Voice; /* Voice status options: */ #define VOICE_FREE 0 @@ -124,37 +50,4 @@ #define PANNED_CENTER 3 /* Anything but PANNED_MYSTERY only uses the left volume */ -/* Envelope stages: */ -#define ATTACK 0 -#define HOLD 1 -#define DECAY 2 -#define RELEASE 3 -#define RELEASEB 4 -#define RELEASEC 5 -#define DELAY 6 - -extern Channel channel[16]; -extern Voice voice[MAX_VOICES]; -extern signed char drumvolume[MAXCHAN][MAXNOTE]; -extern signed char drumpanpot[MAXCHAN][MAXNOTE]; -extern signed char drumreverberation[MAXCHAN][MAXNOTE]; -extern signed char drumchorusdepth[MAXCHAN][MAXNOTE]; - -extern int32 control_ratio, amp_with_poly, amplification; -extern int32 drumchannels; -extern int adjust_panning_immediately; -extern int voices; - -#define ISDRUMCHANNEL(c) ((drumchannels & (1<<(c)))) - -extern int GM_System_On; -extern int XG_System_On; -extern int GS_System_On; - -extern int XG_System_reverb_type; -extern int XG_System_chorus_type; -extern int XG_System_variation_type; - -extern int play_midi(MidiEvent *el, int32 events, int32 samples); -extern int play_midi_file(const char *fn); -extern void dumb_pass_playing_list(int number_of_files, char *list_of_files[]); +#define ISDRUMCHANNEL(s, c) (((s)->drumchannels & (1<<(c)))) diff --git a/timidity/readmidi.c b/timidity/readmidi.c index afa79b9..17c359f 100644 --- a/timidity/readmidi.c +++ b/timidity/readmidi.c @@ -1,254 +1,63 @@ /* + TiMidity -- Experimental MIDI to WAVE converter Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ +*/ + +#if HAVE_CONFIG_H +# include +#endif #include #include -#include #include -#include - -#include "config.h" +#include "SDL.h" + +#include "options.h" +#include "timidity.h" #include "common.h" #include "instrum.h" #include "playmidi.h" -#include "readmidi.h" -#include "output.h" -#include "ctrlmode.h" - -int32 quietchannels=0; - -static int midi_port_number; -char midi_name[FILENAME_MAX+1]; - -static int track_info, curr_track, curr_title_track; -static char title[128]; - -#if MAXCHAN <= 16 -#define MERGE_CHANNEL_PORT(ch) ((int)(ch)) -#else -#define MERGE_CHANNEL_PORT(ch) ((int)(ch) | (midi_port_number << 4)) -#endif - -/* to avoid some unnecessary parameter passing */ -static MidiEventList *evlist; -static int32 event_count; -static SDL_RWops *rw; -static int32 at; - -/* These would both fit into 32 bits, but they are often added in - large multiples, so it's simpler to have two roomy ints */ -static int32 sample_increment, sample_correction; /*samples per MIDI delta-t*/ /* Computes how many (fractional) samples one MIDI delta-time unit contains */ -static void compute_sample_increment(int32 tempo, int32 divisions) +static void compute_sample_increment(MidiSong *song, Sint32 tempo, + Sint32 divisions) { double a; - a = (double) (tempo) * (double) (play_mode->rate) * (65536.0/1000000.0) / + a = (double) (tempo) * (double) (song->rate) * (65536.0/1000000.0) / (double)(divisions); - sample_correction = (int32)(a) & 0xFFFF; - sample_increment = (int32)(a) >> 16; - - ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Samples per delta-t: %d (correction %d)", - sample_increment, sample_correction); + song->sample_correction = (Sint32)(a) & 0xFFFF; + song->sample_increment = (Sint32)(a) >> 16; + + SNDDBG(("Samples per delta-t: %d (correction %d)", + song->sample_increment, song->sample_correction)); } /* Read variable-length number (7 bits per byte, MSB first) */ -static int32 getvl(void) -{ - int32 l=0; - uint8 c; +static Sint32 getvl(SDL_RWops *rw) +{ + Sint32 l=0; + Uint8 c; for (;;) { - SDL_RWread(rw,&c,1,1); + if (!SDL_RWread(rw, &c, 1, 1)) return l; l += (c & 0x7f); if (!(c & 0x80)) return l; l<<=7; } } - -static int sysex(uint32 len, uint8 *syschan, uint8 *sysa, uint8 *sysb, SDL_RWops *rw) -{ - unsigned char *s=(unsigned char *)safe_malloc(len); - int id, model, ch, port, adhi, adlo, cd, dta, dtb, dtc; - if (len != (uint32)SDL_RWread(rw, s, 1, len)) - { - free(s); - return 0; - } - if (len<5) { free(s); return 0; } - if (curr_track == curr_title_track && track_info > 1) title[0] = '\0'; - id=s[0]; port=s[1]; model=s[2]; adhi=s[3]; adlo=s[4]; - if (id==0x7e && port==0x7f && model==0x09 && adhi==0x01) - { - ctl->cmsg(CMSG_TEXT, VERB_VERBOSE, "GM System On", len); - GM_System_On=1; - free(s); - return 0; - } - ch = adlo & 0x0f; - *syschan=(uint8)ch; - if (id==0x7f && len==7 && port==0x7f && model==0x04 && adhi==0x01) - { - ctl->cmsg(CMSG_TEXT, VERB_DEBUG, "Master Volume %d", s[4]+(s[5]<<7)); - *sysa = s[4]; - *sysb = s[5]; - free(s); - return ME_MASTERVOLUME; - /** return s[4]+(s[5]<<7); **/ - } - if (len<8) { free(s); return 0; } - port &=0x0f; - ch = (adlo & 0x0f) | ((port & 0x03) << 4); - *syschan=(uint8)ch; - cd=s[5]; dta=s[6]; - if (len >= 8) dtb=s[7]; - else dtb=-1; - if (len >= 9) dtc=s[8]; - else dtc=-1; - free(s); - if (id==0x43 && model==0x4c) - { - if (!adhi && !adlo && cd==0x7e && !dta) - { - ctl->cmsg(CMSG_TEXT, VERB_VERBOSE, "XG System On", len); - XG_System_On=1; - #ifdef tplus - vol_table = xg_vol_table; - #endif - } - else if (adhi == 2 && adlo == 1) - { - if (dtb==8) dtb=3; - switch (cd) - { - case 0x00: - XG_System_reverb_type=(dta<<3)+dtb; - break; - case 0x20: - XG_System_chorus_type=((dta-64)<<3)+dtb; - break; - case 0x40: - XG_System_variation_type=dta; - break; - case 0x5a: - /* dta==0 Insertion; dta==1 System */ - break; - default: break; - } - } - else if (adhi == 8 && cd <= 40) - { - *sysa = dta & 0x7f; - switch (cd) - { - case 0x01: /* bank select MSB */ - return ME_TONE_KIT; - break; - case 0x02: /* bank select LSB */ - return ME_TONE_BANK; - break; - case 0x03: /* program number */ - /** MIDIEVENT(d->at, ME_PROGRAM, lastchan, a, 0); **/ - return ME_PROGRAM; - break; - case 0x08: /* */ - /* d->channel[adlo&0x0f].transpose = (char)(dta-64); */ - channel[ch].transpose = (char)(dta-64); - ctl->cmsg(CMSG_TEXT, VERB_DEBUG, "transpose channel %d by %d", - (adlo&0x0f)+1, dta-64); - break; - case 0x0b: /* volume */ - return ME_MAINVOLUME; - break; - case 0x0e: /* pan */ - return ME_PAN; - break; - case 0x12: /* chorus send */ - return ME_CHORUSDEPTH; - break; - case 0x13: /* reverb send */ - return ME_REVERBERATION; - break; - case 0x14: /* variation send */ - break; - case 0x18: /* filter cutoff */ - return ME_BRIGHTNESS; - break; - case 0x19: /* filter resonance */ - return ME_HARMONICCONTENT; - break; - default: break; - } - } - return 0; - } - else if (id==0x41 && model==0x42 && adhi==0x12 && adlo==0x40) - { - if (dtc<0) return 0; - if (!cd && dta==0x7f && !dtb && dtc==0x41) - { - ctl->cmsg(CMSG_TEXT, VERB_VERBOSE, "GS System On", len); - GS_System_On=1; - #ifdef tplus - vol_table = gs_vol_table; - #endif - } - else if (dta==0x15 && (cd&0xf0)==0x10) - { - int chan=cd&0x0f; - if (!chan) chan=9; - else if (chan<10) chan--; - chan = MERGE_CHANNEL_PORT(chan); - channel[chan].kit=dtb; - } - else if (cd==0x01) switch(dta) - { - case 0x30: - switch(dtb) - { - case 0: XG_System_reverb_type=16+0; break; - case 1: XG_System_reverb_type=16+1; break; - case 2: XG_System_reverb_type=16+2; break; - case 3: XG_System_reverb_type= 8+0; break; - case 4: XG_System_reverb_type= 8+1; break; - case 5: XG_System_reverb_type=32+0; break; - case 6: XG_System_reverb_type=8*17; break; - case 7: XG_System_reverb_type=8*18; break; - } - break; - case 0x38: - switch(dtb) - { - case 0: XG_System_chorus_type= 8+0; break; - case 1: XG_System_chorus_type= 8+1; break; - case 2: XG_System_chorus_type= 8+2; break; - case 3: XG_System_chorus_type= 8+4; break; - case 4: XG_System_chorus_type= -1; break; - case 5: XG_System_chorus_type= 8*3; break; - case 6: XG_System_chorus_type= -1; break; - case 7: XG_System_chorus_type= -1; break; - } - break; - } - return 0; - } - return 0; -} - /* Print a string from the file, followed by a newline. Any non-ASCII or unprintable characters will be converted to periods. */ -static int dumpstring(int32 len, const char *label) +static int dumpstring(SDL_RWops *rw, Sint32 len, char *label) { signed char *s=safe_malloc(len+1); - if (len != (int32)SDL_RWread(rw, s, 1, len)) + if (len != (Sint32) SDL_RWread(rw, s, 1, len)) { free(s); return -1; @@ -259,7 +68,7 @@ if (s[len]<32) s[len]='.'; } - ctl->cmsg(CMSG_TEXT, VERB_VERBOSE, "%s%s", label, s); + SNDDBG(("%s%s", label, s)); free(s); return 0; } @@ -274,82 +83,54 @@ /* Read a MIDI event, returning a freshly allocated element that can be linked to the event list */ -static MidiEventList *read_midi_event(void) -{ - static uint8 laststatus, lastchan; - static uint8 nrpn=0, rpn_msb[16], rpn_lsb[16]; /* one per channel */ - uint8 me, type, a,b,c; - int32 len; +static MidiEventList *read_midi_event(MidiSong *song) +{ + static Uint8 laststatus, lastchan; + static Uint8 nrpn=0, rpn_msb[16], rpn_lsb[16]; /* one per channel */ + Uint8 me, type, a,b,c; + Sint32 len; MidiEventList *new; for (;;) { - at+=getvl(); - if (SDL_RWread(rw,&me,1,1)!=1) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: read_midi_event: %s", - current_filename, strerror(errno)); + song->at += getvl(song->rw); + if (SDL_RWread(song->rw, &me, 1, 1) != 1) + { + SNDDBG(("read_midi_event: SDL_RWread() failure\n")); return 0; } if(me==0xF0 || me == 0xF7) /* SysEx event */ { - int32 sret; - uint8 sysa=0, sysb=0, syschan=0; - - len=getvl(); - sret=sysex(len, &syschan, &sysa, &sysb, rw); - if (sret) - { - MIDIEVENT(at, sret, syschan, sysa, sysb); - } + len=getvl(song->rw); + SDL_RWseek(song->rw, len, RW_SEEK_CUR); } else if(me==0xFF) /* Meta event */ { - SDL_RWread(rw,&type,1,1); - len=getvl(); + SDL_RWread(song->rw, &type, 1, 1); + len=getvl(song->rw); if (type>0 && type<16) { static char *label[]={ "Text event: ", "Text: ", "Copyright: ", "Track name: ", "Instrument: ", "Lyric: ", "Marker: ", "Cue point: "}; - dumpstring(len, label[(type>7) ? 0 : type]); + dumpstring(song->rw, len, label[(type>7) ? 0 : type]); } else switch(type) { - - case 0x21: /* MIDI port number */ - if(len == 1) - { - SDL_RWread(rw,&midi_port_number,1,1); - if(midi_port_number == EOF) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "Warning: \"%s\": Short midi file.", - midi_name); - return 0; - } - midi_port_number &= 0x0f; - if (midi_port_number) - ctl->cmsg(CMSG_INFO, VERB_VERBOSE, - "(MIDI port number %d)", midi_port_number); - midi_port_number &= 0x03; - } - else SDL_RWseek(rw, len, RW_SEEK_CUR); - break; - case 0x2F: /* End of Track */ return MAGIC_EOT; case 0x51: /* Tempo */ - SDL_RWread(rw,&a,1,1); SDL_RWread(rw,&b,1,1); SDL_RWread(rw,&c,1,1); - MIDIEVENT(at, ME_TEMPO, c, a, b); + SDL_RWread(song->rw, &a, 1, 1); + SDL_RWread(song->rw, &b, 1, 1); + SDL_RWread(song->rw, &c, 1, 1); + MIDIEVENT(song->at, ME_TEMPO, c, a, b); default: - ctl->cmsg(CMSG_INFO, VERB_DEBUG, - "(Meta event type 0x%02x, length %ld)", type, len); - SDL_RWseek(rw, len, RW_SEEK_CUR); + SNDDBG(("(Meta event type 0x%02x, length %d)\n", type, len)); + SDL_RWseek(song->rw, len, RW_SEEK_CUR); break; } } @@ -360,30 +141,28 @@ { lastchan=a & 0x0F; laststatus=(a>>4) & 0x07; - SDL_RWread(rw,&a, 1,1); + SDL_RWread(song->rw, &a, 1, 1); a &= 0x7F; } switch(laststatus) { case 0: /* Note off */ - SDL_RWread(rw,&b, 1,1); + SDL_RWread(song->rw, &b, 1, 1); b &= 0x7F; - MIDIEVENT(at, ME_NOTEOFF, lastchan, a,b); + MIDIEVENT(song->at, ME_NOTEOFF, lastchan, a,b); case 1: /* Note on */ - SDL_RWread(rw,&b, 1,1); + SDL_RWread(song->rw, &b, 1, 1); b &= 0x7F; - if (curr_track == curr_title_track && track_info > 1) title[0] = '\0'; - MIDIEVENT(at, ME_NOTEON, lastchan, a,b); - + MIDIEVENT(song->at, ME_NOTEON, lastchan, a,b); case 2: /* Key Pressure */ - SDL_RWread(rw,&b, 1,1); + SDL_RWread(song->rw, &b, 1, 1); b &= 0x7F; - MIDIEVENT(at, ME_KEYPRESSURE, lastchan, a, b); + MIDIEVENT(song->at, ME_KEYPRESSURE, lastchan, a, b); case 3: /* Control change */ - SDL_RWread(rw,&b, 1,1); + SDL_RWread(song->rw, &b, 1, 1); b &= 0x7F; { int control=255; @@ -392,15 +171,7 @@ case 7: control=ME_MAINVOLUME; break; case 10: control=ME_PAN; break; case 11: control=ME_EXPRESSION; break; - case 64: control=ME_SUSTAIN; break; - - case 71: control=ME_HARMONICCONTENT; break; - case 72: control=ME_RELEASETIME; break; - case 73: control=ME_ATTACKTIME; break; - case 74: control=ME_BRIGHTNESS; break; - case 91: control=ME_REVERBERATION; break; - case 93: control=ME_CHORUSDEPTH; break; - + case 64: control=ME_SUSTAIN; b = (b >= 64); break; case 120: control=ME_ALL_SOUNDS_OFF; break; case 121: control=ME_RESET_CONTROLLERS; break; case 123: control=ME_ALL_NOTES_OFF; break; @@ -411,9 +182,16 @@ Also, some MIDI files use 0 as some sort of continuous controller. This will cause lots of warnings about undefined tone banks. */ - case 0: if (XG_System_On) control = ME_TONE_KIT; else control=ME_TONE_BANK; break; - - case 32: if (XG_System_On) control = ME_TONE_BANK; break; + case 0: control=ME_TONE_BANK; break; + case 32: + if (b!=0) { + SNDDBG(("(Strange: tone bank change 0x%02x)\n", b)); + } +#if 0 /* `Bank Select LSB' is not worked at GS. Please ignore it. */ + else + control=ME_TONE_BANK; +#endif + break; case 100: nrpn=0; rpn_msb[lastchan]=b; break; case 101: nrpn=0; rpn_lsb[lastchan]=b; break; @@ -423,47 +201,8 @@ case 6: if (nrpn) { - if (rpn_msb[lastchan]==1) switch (rpn_lsb[lastchan]) - { -#ifdef tplus - case 0x08: control=ME_VIBRATO_RATE; break; - case 0x09: control=ME_VIBRATO_DEPTH; break; - case 0x0a: control=ME_VIBRATO_DELAY; break; -#endif - case 0x20: control=ME_BRIGHTNESS; break; - case 0x21: control=ME_HARMONICCONTENT; break; - /* - case 0x63: envelope attack rate - case 0x64: envelope decay rate - case 0x66: envelope release rate - */ - } - else switch (rpn_msb[lastchan]) - { - /* - case 0x14: filter cutoff frequency - case 0x15: filter resonance - case 0x16: envelope attack rate - case 0x17: envelope decay rate - case 0x18: pitch coarse - case 0x19: pitch fine - */ - case 0x1a: drumvolume[lastchan][0x7f & rpn_lsb[lastchan]] = b; break; - case 0x1c: - if (!b) b=(int) (127.0*rand()/(RAND_MAX)); - drumpanpot[lastchan][0x7f & rpn_lsb[lastchan]] = b; - break; - case 0x1d: drumreverberation[lastchan][0x7f & rpn_lsb[lastchan]] = b; break; - case 0x1e: drumchorusdepth[lastchan][0x7f & rpn_lsb[lastchan]] = b; break; - /* - case 0x1f: variation send level - */ - } - - ctl->cmsg(CMSG_INFO, VERB_DEBUG, - "(Data entry (MSB) for NRPN %02x,%02x: %ld)", - rpn_msb[lastchan], rpn_lsb[lastchan], - b); + SNDDBG(("(Data entry (MSB) for NRPN %02x,%02x: %d)\n", + rpn_msb[lastchan], rpn_lsb[lastchan], b)); break; } @@ -475,45 +214,41 @@ case 0x7F7F: /* RPN reset */ /* reset pitch bend sensitivity to 2 */ - MIDIEVENT(at, ME_PITCH_SENS, lastchan, 2, 0); + MIDIEVENT(song->at, ME_PITCH_SENS, lastchan, 2, 0); default: - ctl->cmsg(CMSG_INFO, VERB_DEBUG, - "(Data entry (MSB) for RPN %02x,%02x: %ld)", - rpn_msb[lastchan], rpn_lsb[lastchan], - b); + SNDDBG(("(Data entry (MSB) for RPN %02x,%02x: %d)\n", + rpn_msb[lastchan], rpn_lsb[lastchan], b)); break; } break; default: - ctl->cmsg(CMSG_INFO, VERB_DEBUG, - "(Control %d: %d)", a, b); + SNDDBG(("(Control %d: %d)\n", a, b)); break; } if (control != 255) { - MIDIEVENT(at, control, lastchan, b, 0); + MIDIEVENT(song->at, control, lastchan, b, 0); } } break; case 4: /* Program change */ a &= 0x7f; - MIDIEVENT(at, ME_PROGRAM, lastchan, a, 0); + MIDIEVENT(song->at, ME_PROGRAM, lastchan, a, 0); case 5: /* Channel pressure - NOT IMPLEMENTED */ break; case 6: /* Pitch wheel */ - SDL_RWread(rw,&b, 1,1); + SDL_RWread(song->rw, &b, 1, 1); b &= 0x7F; - MIDIEVENT(at, ME_PITCHWHEEL, lastchan, a, b); + MIDIEVENT(song->at, ME_PITCHWHEEL, lastchan, a, b); default: - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "*** Can't happen: status 0x%02X, channel 0x%02X", - laststatus, lastchan); + SNDDBG(("*** Can't happen: status 0x%02X, channel 0x%02X\n", + laststatus, lastchan)); break; } } @@ -526,51 +261,50 @@ /* Read a midi track into the linked list, either merging with any previous tracks or appending to them. */ -static int read_track(int append) +static int read_track(MidiSong *song, int append) { MidiEventList *meep; MidiEventList *next, *new; - int32 len; + Sint32 len; Sint64 next_pos, pos; char tmp[4]; - meep=evlist; + meep = song->evlist; if (append && meep) { /* find the last event in the list */ for (; meep->next; meep=meep->next) ; - at=meep->event.time; + song->at = meep->event.time; } else - at=0; + song->at=0; /* Check the formalities */ - if ((SDL_RWread(rw,tmp,1,4) != 4) || (SDL_RWread(rw,&len,4,1) != 1)) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "%s: Can't read track header.", current_filename); + + if (SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_RWread(song->rw, &len, 4, 1) != 1) + { + SNDDBG(("Can't read track header.\n")); return -1; } - len=BE_LONG(len); - next_pos = SDL_RWtell(rw) + len; + len=SDL_SwapBE32(len); + next_pos = SDL_RWtell(song->rw) + len; if (memcmp(tmp, "MTrk", 4)) { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "%s: Corrupt MIDI file.", current_filename); + SNDDBG(("Corrupt MIDI file.\n")); return -2; } for (;;) { - if (!(new=read_midi_event())) /* Some kind of error */ + if (!(new=read_midi_event(song))) /* Some kind of error */ return -2; if (new==MAGIC_EOT) /* End-of-track Hack. */ { - pos = SDL_RWtell(rw); + pos = SDL_RWtell(song->rw); if (pos < next_pos) - SDL_RWseek(rw, next_pos - pos, RW_SEEK_CUR); + SDL_RWseek(song->rw, next_pos - pos, RW_SEEK_CUR); return 0; } @@ -584,147 +318,79 @@ new->next=next; meep->next=new; - event_count++; /* Count the event. (About one?) */ + song->event_count++; /* Count the event. (About one?) */ meep=new; } } /* Free the linked event list from memory. */ -static void free_midi_list(void) +static void free_midi_list(MidiSong *song) { MidiEventList *meep, *next; - if (!(meep=evlist)) return; + if (!(meep = song->evlist)) return; while (meep) { next=meep->next; free(meep); meep=next; } - evlist=0; -} - - -static void xremap_percussion(int *banknumpt, int *this_notept, int this_kit) { - int i, newmap; - int banknum = *banknumpt; - int this_note = *this_notept; - int newbank, newnote; - - if (this_kit != 127 && this_kit != 126) return; - - for (i = 0; i < XMAPMAX; i++) { - newmap = xmap[i][0]; - if (!newmap) return; - if (this_kit == 127 && newmap != XGDRUM) continue; - if (this_kit == 126 && newmap != SFXDRUM1) continue; - if (xmap[i][1] != banknum) continue; - if (xmap[i][3] != this_note) continue; - newbank = xmap[i][2]; - newnote = xmap[i][4]; - if (newbank == banknum && newnote == this_note) return; - if (!drumset[newbank]) return; - *banknumpt = newbank; - *this_notept = newnote; - return; - } + song->evlist=0; } /* Allocate an array of MidiEvents and fill it from the linked list of events, marking used instruments for loading. Convert event times to samples: handle tempo changes. Strip unnecessary events from the list. Free the linked list. */ -static MidiEvent *groom_list(int32 divisions,int32 *eventsp,int32 *samplesp) +static MidiEvent *groom_list(MidiSong *song, Sint32 divisions,Sint32 *eventsp, + Sint32 *samplesp) { MidiEvent *groomed_list, *lp; MidiEventList *meep; - int32 i, our_event_count, tempo, skip_this_event, new_value; - int32 sample_cum, samples_to_do, at, st, dt, counting_time; - - int current_bank[MAXCHAN], current_banktype[MAXCHAN], current_set[MAXCHAN], - current_kit[MAXCHAN], current_program[MAXCHAN]; + Sint32 i, our_event_count, tempo, skip_this_event, new_value; + Sint32 sample_cum, samples_to_do, at, st, dt, counting_time; + + int current_bank[MAXCHAN], current_set[MAXCHAN], current_program[MAXCHAN]; /* Or should each bank have its own current program? */ - int dset, dnote, drumsflag, mprog; for (i=0; idefault_program; } tempo=500000; - compute_sample_increment(tempo, divisions); + compute_sample_increment(song, tempo, divisions); /* This may allocate a bit more than we need */ - groomed_list=lp=safe_malloc(sizeof(MidiEvent) * (event_count+1)); - meep=evlist; + groomed_list=lp=safe_malloc(sizeof(MidiEvent) * (song->event_count+1)); + meep=song->evlist; our_event_count=0; st=at=sample_cum=0; counting_time=2; /* We strip any silence before the first NOTE ON. */ - for (i=0; ievent_count; i++) { skip_this_event=0; - ctl->cmsg(CMSG_INFO, VERB_DEBUG_SILLY, - "%6d: ch %2d: event %d (%d,%d)", - meep->event.time, meep->event.channel + 1, - meep->event.type, meep->event.a, meep->event.b); if (meep->event.type==ME_TEMPO) { - tempo= - meep->event.channel + meep->event.b * 256 + meep->event.a * 65536; - compute_sample_increment(tempo, divisions); skip_this_event=1; } else if (meep->event.channel >= MAXCHAN) - skip_this_event=1; - else if ((quietchannels & (1<event.channel))) - skip_this_event=1; + skip_this_event=1; else switch (meep->event.type) { case ME_PROGRAM: - - if (current_kit[meep->event.channel]) - { - if (current_kit[meep->event.channel]==126) - { - /* note request for 2nd sfx rhythm kit */ - if (meep->event.a && drumset[SFXDRUM2]) - { - current_kit[meep->event.channel]=125; - current_set[meep->event.channel]=SFXDRUM2; - new_value=SFXDRUM2; - } - else if (!meep->event.a && drumset[SFXDRUM1]) - { - current_set[meep->event.channel]=SFXDRUM1; - new_value=SFXDRUM1; - } - else - { - ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, - "XG SFX drum set is undefined"); - skip_this_event=1; - break; - } - } - if (drumset[meep->event.a]) /* Is this a defined drumset? */ + if (ISDRUMCHANNEL(song, meep->event.channel)) + { + if (song->drumset[meep->event.a]) /* Is this a defined drumset? */ new_value=meep->event.a; else { - ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, - "Drum set %d is undefined", meep->event.a); - if (drumset[0]) - new_value=meep->event.a=0; - else - { - skip_this_event=1; - break; - } + SNDDBG(("Drum set %d is undefined\n", meep->event.a)); + new_value=meep->event.a=0; } if (current_set[meep->event.channel] != new_value) current_set[meep->event.channel]=new_value; @@ -745,169 +411,52 @@ case ME_NOTEON: if (counting_time) counting_time=1; - - drumsflag = current_kit[meep->event.channel]; - - if (drumsflag) /* percussion channel? */ - { - dset = current_set[meep->event.channel]; - dnote=meep->event.a; - if (XG_System_On) xremap_percussion(&dset, &dnote, drumsflag); - - /*if (current_config_pc42b) pcmap(&dset, &dnote, &mprog, &drumsflag);*/ - - if (drumsflag) - { + if (ISDRUMCHANNEL(song, meep->event.channel)) + { /* Mark this instrument to be loaded */ - if (!(drumset[dset]->tone[dnote].layer)) - { - drumset[dset]->tone[dnote].layer= + if (!(song->drumset[current_set[meep->event.channel]] + ->instrument[meep->event.a])) + song->drumset[current_set[meep->event.channel]] + ->instrument[meep->event.a] = MAGIC_LOAD_INSTRUMENT; + } + else + { + if (current_program[meep->event.channel]==SPECIAL_PROGRAM) + break; + /* Mark this instrument to be loaded */ + if (!(song->tonebank[current_bank[meep->event.channel]] + ->instrument[current_program[meep->event.channel]])) + song->tonebank[current_bank[meep->event.channel]] + ->instrument[current_program[meep->event.channel]] = MAGIC_LOAD_INSTRUMENT; - } - else drumset[dset]->tone[dnote].last_used - = current_tune_number; - if (!channel[meep->event.channel].name) channel[meep->event.channel].name= - drumset[dset]->name; - } - } - - if (!drumsflag) /* not percussion */ - { - int chan=meep->event.channel; - int banknum; - - if (current_banktype[chan]) banknum=SFXBANK; - else banknum=current_bank[chan]; - - mprog = current_program[chan]; - - if (mprog==SPECIAL_PROGRAM) - break; - - if (XG_System_On && banknum==SFXBANK && !tonebank[SFXBANK] && tonebank[120]) - banknum = 120; - - /*if (current_config_pc42b) pcmap(&banknum, &dnote, &mprog, &drumsflag);*/ - - if (drumsflag) - { - /* Mark this instrument to be loaded */ - if (!(drumset[dset]->tone[dnote].layer)) - { - drumset[dset]->tone[dnote].layer=MAGIC_LOAD_INSTRUMENT; - } - else drumset[dset]->tone[dnote].last_used = current_tune_number; - if (!channel[meep->event.channel].name) channel[meep->event.channel].name= - drumset[dset]->name; - } - if (!drumsflag) - { - /* Mark this instrument to be loaded */ - if (!(tonebank[banknum]->tone[mprog].layer)) - { - tonebank[banknum]->tone[mprog].layer=MAGIC_LOAD_INSTRUMENT; - } - else tonebank[banknum]->tone[mprog].last_used = current_tune_number; - if (!channel[meep->event.channel].name) channel[meep->event.channel].name= - tonebank[banknum]->tone[mprog].name; - } } break; - case ME_TONE_KIT: - if (!meep->event.a || meep->event.a == 127) - { - new_value=meep->event.a; - if (current_kit[meep->event.channel] != new_value) - current_kit[meep->event.channel]=new_value; - else - skip_this_event=1; - break; - } - else if (meep->event.a == 126) - { - if (drumset[SFXDRUM1]) /* Is this a defined tone bank? */ - new_value=meep->event.a; - else - { - ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, - "XG rhythm kit %d is undefined", meep->event.a); - skip_this_event=1; - break; - } - current_set[meep->event.channel]=SFXDRUM1; - current_kit[meep->event.channel]=new_value; - break; - } - else if (meep->event.a != SFX_BANKTYPE) - { - ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, - "XG kit %d is impossible", meep->event.a); + case ME_TONE_BANK: + if (ISDRUMCHANNEL(song, meep->event.channel)) + { skip_this_event=1; break; } - - if (current_kit[meep->event.channel]) - { - skip_this_event=1; - break; - } - if (tonebank[SFXBANK] || tonebank[120]) /* Is this a defined tone bank? */ - new_value=SFX_BANKTYPE; - else - { - ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, - "XG Sfx bank is undefined"); - skip_this_event=1; - break; - } - if (current_banktype[meep->event.channel]!=new_value) - current_banktype[meep->event.channel]=new_value; - else - skip_this_event=1; - break; - - case ME_TONE_BANK: - if (current_kit[meep->event.channel]) - { - skip_this_event=1; - break; - } - if (XG_System_On && meep->event.a > 0 && meep->event.a < 48) { - channel[meep->event.channel].variationbank=meep->event.a; - ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, - "XG variation bank %d", meep->event.a); - new_value=meep->event.a=0; - } - else if (tonebank[meep->event.a]) /* Is this a defined tone bank? */ + if (song->tonebank[meep->event.a]) /* Is this a defined tone bank? */ new_value=meep->event.a; else { - ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, - "Tone bank %d is undefined", meep->event.a); + SNDDBG(("Tone bank %d is undefined\n", meep->event.a)); new_value=meep->event.a=0; } - if (current_bank[meep->event.channel]!=new_value) current_bank[meep->event.channel]=new_value; else skip_this_event=1; break; - - case ME_HARMONICCONTENT: - channel[meep->event.channel].harmoniccontent=meep->event.a; - break; - case ME_BRIGHTNESS: - channel[meep->event.channel].brightness=meep->event.a; - break; - } /* Recompute time in samples*/ if ((dt=meep->event.time - at) && !counting_time) { - samples_to_do=sample_increment * dt; - sample_cum += sample_correction * dt; + samples_to_do = song->sample_increment * dt; + sample_cum += song->sample_correction * dt; if (sample_cum & 0xFFFF0000) { samples_to_do += ((sample_cum >> 16) & 0xFFFF); @@ -916,6 +465,12 @@ st += samples_to_do; } else if (counting_time==1) counting_time=0; + if (meep->event.type==ME_TEMPO) + { + tempo= + meep->event.channel + meep->event.b * 256 + meep->event.a * 65536; + compute_sample_increment(song, tempo, divisions); + } if (!skip_this_event) { /* Add the event to the list */ @@ -931,143 +486,106 @@ lp->time=st; lp->type=ME_EOT; our_event_count++; - free_midi_list(); - + free_midi_list(song); + *eventsp=our_event_count; *samplesp=st; return groomed_list; } -MidiEvent *read_midi_file(SDL_RWops *mrw, int32 *count, int32 *sp) -{ - int32 len, divisions; - int16 format, tracks, divisions_tmp; +MidiEvent *read_midi_file(MidiSong *song, Sint32 *count, Sint32 *sp) +{ + Sint32 len, divisions; + Sint16 format, tracks, divisions_tmp; int i; char tmp[4]; - rw = mrw; - event_count=0; - at=0; - evlist=0; - - GM_System_On=GS_System_On=XG_System_On=0; - /* vol_table = def_vol_table; */ - XG_System_reverb_type=XG_System_chorus_type=XG_System_variation_type=0; - memset(&drumvolume,-1,sizeof(drumvolume)); - memset(&drumchorusdepth,-1,sizeof(drumchorusdepth)); - memset(&drumreverberation,-1,sizeof(drumreverberation)); - memset(&drumpanpot,NO_PANNING,sizeof(drumpanpot)); - - for (i=0; icmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", current_filename, - strerror(errno)); - } - else*/ - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "%s: Not a MIDI file!", current_filename); + song->event_count=0; + song->at=0; + song->evlist=0; + + if (SDL_RWread(song->rw, tmp, 1, 4) != 4 || SDL_RWread(song->rw, &len, 4, 1) != 1) + { + SNDDBG(("Not a MIDI file!\n")); return 0; } - len=BE_LONG(len); - - if (!memcmp(tmp, "RIFF", 4)) - { - SDL_RWread(rw,tmp,1,12); - goto past_riff; - } + len=SDL_SwapBE32(len); if (memcmp(tmp, "MThd", 4) || len < 6) { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "%s: Not a MIDI file!", current_filename); + SNDDBG(("Not a MIDI file!\n")); return 0; } - SDL_RWread(rw,&format, 2, 1); - SDL_RWread(rw,&tracks, 2, 1); - SDL_RWread(rw,&divisions_tmp, 2, 1); - format=BE_SHORT(format); - tracks=BE_SHORT(tracks); - track_info = tracks; - curr_track = 0; - curr_title_track = -1; - divisions_tmp=BE_SHORT(divisions_tmp); + SDL_RWread(song->rw, &format, 2, 1); + SDL_RWread(song->rw, &tracks, 2, 1); + SDL_RWread(song->rw, &divisions_tmp, 2, 1); + format=SDL_SwapBE16(format); + tracks=SDL_SwapBE16(tracks); + divisions_tmp=SDL_SwapBE16(divisions_tmp); if (divisions_tmp<0) { /* SMPTE time -- totally untested. Got a MIDI file that uses this? */ divisions= - (int32)(-(divisions_tmp/256)) * (int32)(divisions_tmp & 0xFF); - } - else divisions=(int32)(divisions_tmp); + (Sint32)(-(divisions_tmp/256)) * (Sint32)(divisions_tmp & 0xFF); + } + else divisions=(Sint32)(divisions_tmp); if (len > 6) { - ctl->cmsg(CMSG_WARNING, VERB_NORMAL, - "%s: MIDI file header size %ld bytes", - current_filename, len); - SDL_RWseek(rw, len-6, RW_SEEK_CUR); /* skip the excess */ + SNDDBG(("MIDI file header size %u bytes", len)); + SDL_RWseek(song->rw, len-6, RW_SEEK_CUR); /* skip the excess */ } if (format<0 || format >2) { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "%s: Unknown MIDI file format %d", current_filename, format); + SNDDBG(("Unknown MIDI file format %d\n", format)); return 0; } - ctl->cmsg(CMSG_INFO, VERB_VERBOSE, - "Format: %d Tracks: %d Divisions: %d", format, tracks, divisions); + if (tracks<1) + { + SNDDBG(("Bad number of tracks %d\n", tracks)); + return 0; + } + if (format==0 && tracks!=1) + { + SNDDBG(("%d tracks with Type-0 MIDI (must be 1.)\n", tracks)); + return 0; + } + SNDDBG(("Format: %d Tracks: %d Divisions: %d\n", + format, tracks, divisions)); /* Put a do-nothing event first in the list for easier processing */ - evlist=safe_malloc(sizeof(MidiEventList)); - evlist->event.time=0; - evlist->event.type=ME_NONE; - evlist->next=0; - event_count++; + song->evlist=safe_malloc(sizeof(MidiEventList)); + memset(song->evlist, 0, sizeof(MidiEventList)); + song->event_count++; switch(format) { case 0: - if (read_track(0)) - { - free_midi_list(); + if (read_track(song, 0)) + { + free_midi_list(song); return 0; } - else curr_track++; break; case 1: for (i=0; i This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ -typedef struct { - MidiEvent event; - void *next; -} MidiEventList; + readmidi.h + + */ -extern int32 quietchannels; - -extern MidiEvent *read_midi_file(SDL_RWops *mrw, int32 *count, int32 *sp); - -extern char midi_name[FILENAME_MAX+1]; +extern MidiEvent *read_midi_file(MidiSong *song, Sint32 *count, Sint32 *sp); diff --git a/timidity/resample.c b/timidity/resample.c index f8b018c..d3de5c8 100644 --- a/timidity/resample.c +++ b/timidity/resample.c @@ -1,77 +1,59 @@ /* + TiMidity -- Experimental MIDI to WAVE converter Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ + + resample.c +*/ + +#if HAVE_CONFIG_H +# include +#endif #include #include #include -#include "config.h" +#include "SDL.h" + +#include "timidity.h" +#include "options.h" #include "common.h" #include "instrum.h" #include "playmidi.h" -#include "output.h" -#include "ctrlmode.h" #include "tables.h" #include "resample.h" -#ifdef LINEAR_INTERPOLATION -# if defined(LOOKUP_HACK) && defined(LOOKUP_INTERPOLATION) -# define RESAMPLATION \ - v1=src[ofs>>FRACTION_BITS];\ - v2=src[(ofs>>FRACTION_BITS)+1];\ - *dest++ = (resample_t)(v1 + (iplookup[(((v2-v1)<<5) & 0x03FE0) | \ - ((ofs & FRACTION_MASK) >> (FRACTION_BITS-5))])); -# else -# define RESAMPLATION \ - v1=src[ofs>>FRACTION_BITS];\ - v2=src[(ofs>>FRACTION_BITS)+1];\ - *dest++ = (resample_t)(v1 + (((v2-v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS)); -# endif -# define INTERPVARS sample_t v1, v2 -#else -/* Earplugs recommended for maximum listening enjoyment */ -# define RESAMPLATION *dest++ = src[ofs>>FRACTION_BITS]; -# define INTERPVARS -#endif - -#define FINALINTERP if (ofs == le) *dest++=src[ofs>>FRACTION_BITS]; -/* So it isn't interpolation. At least it's final. */ - -extern resample_t *resample_buffer; +#define PRECALC_LOOP_COUNT(start, end, incr) (((end) - (start) + (incr) - 1) / (incr)) /*************** resampling with fixed increment *****************/ -static resample_t *rs_plain(int v, int32 *countptr) +static sample_t *rs_plain(MidiSong *song, int v, Sint32 *countptr) { /* Play sample until end, then free the voice. */ - INTERPVARS; + sample_t v1, v2; Voice - *vp=&voice[v]; - resample_t - *dest=resample_buffer; + *vp=&(song->voice[v]); sample_t + *dest=song->resample_buffer, *src=vp->sample->data; - int32 + Sint32 ofs=vp->sample_offset, incr=vp->sample_increment, le=vp->sample->data_length, count=*countptr; - -#ifdef PRECALC_LOOPS - int32 i, j; + Sint32 i, j; if (incr<0) incr = -incr; /* In case we're coming out of a bidir loop */ /* Precalc how many times we should go through the loop. NOTE: Assumes that incr > 0 and that ofs <= le */ - i = (le - ofs) / incr + 1; + i = PRECALC_LOOP_COUNT(ofs, le, incr); if (i > count) { @@ -80,130 +62,101 @@ } else count -= i; - for(j = 0; j < i; j++) - { - RESAMPLATION; + for (j = 0; j < i; j++) + { + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS)+1]; + *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); ofs += incr; } if (ofs >= le) { - FINALINTERP; + if (ofs == le) + *dest++ = src[(ofs>>FRACTION_BITS)-1]/2; vp->status=VOICE_FREE; - ctl->note(v); *countptr-=count+1; } - -#else /* PRECALC_LOOPS */ - while (count--) - { - RESAMPLATION; - ofs += incr; - if (ofs >= le) - { - FINALINTERP; - vp->status=VOICE_FREE; - ctl->note(v); - *countptr-=count+1; - break; - } - } -#endif /* PRECALC_LOOPS */ vp->sample_offset=ofs; /* Update offset */ - return resample_buffer; -} - -static resample_t *rs_loop(Voice *vp, int32 count) + return song->resample_buffer; +} + +static sample_t *rs_loop(MidiSong *song, Voice *vp, Sint32 count) { /* Play sample until end-of-loop, skip back and continue. */ - INTERPVARS; - int32 + sample_t v1, v2; + Sint32 ofs=vp->sample_offset, incr=vp->sample_increment, le=vp->sample->loop_end, ll=le - vp->sample->loop_start; - resample_t - *dest=resample_buffer; sample_t + *dest=song->resample_buffer, *src=vp->sample->data; - -#ifdef PRECALC_LOOPS - int32 i; - - if (ofs < 0 || le < 0) return resample_buffer; - + Sint32 i, j; + while (count) { - if (ofs >= le) - /* NOTE: Assumes that ll > incr and that incr > 0. */ + while (ofs >= le) ofs -= ll; /* Precalc how many times we should go through the loop */ - i = (le - ofs) / incr + 1; + i = PRECALC_LOOP_COUNT(ofs, le, incr); if (i > count) { i = count; count = 0; } else count -= i; - if (i > 0) - while (i--) - { - RESAMPLATION; + for (j = 0; j < i; j++) + { + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS)+1]; + *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); ofs += incr; } } -#else - while (count--) - { - RESAMPLATION; - ofs += incr; - if (ofs>=le) - ofs -= ll; /* Hopefully the loop is longer than an increment. */ - } -#endif vp->sample_offset=ofs; /* Update offset */ - return resample_buffer; -} - -static resample_t *rs_bidir(Voice *vp, int32 count) -{ - INTERPVARS; - int32 + return song->resample_buffer; +} + +static sample_t *rs_bidir(MidiSong *song, Voice *vp, Sint32 count) +{ + sample_t v1, v2; + Sint32 ofs=vp->sample_offset, incr=vp->sample_increment, le=vp->sample->loop_end, ls=vp->sample->loop_start; - resample_t - *dest=resample_buffer; sample_t + *dest=song->resample_buffer, *src=vp->sample->data; - -#ifdef PRECALC_LOOPS - int32 - le2 = le<<1, + Sint32 + le2 = le<<1, ls2 = ls<<1, - i; + i, j; /* Play normally until inside the loop region */ - if (ofs <= ls) + if (incr > 0 && ofs < ls) { /* NOTE: Assumes that incr > 0, which is NOT always the case when doing bidirectional looping. I have yet to see a case where both ofs <= ls AND incr < 0, however. */ - i = (ls - ofs) / incr + 1; + i = PRECALC_LOOP_COUNT(ofs, ls, incr); if (i > count) { i = count; count = 0; } else count -= i; - while (i--) - { - RESAMPLATION; + for (j = 0; j < i; j++) + { + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS)+1]; + *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); ofs += incr; } } @@ -213,16 +166,18 @@ while(count) { /* Precalc how many times we should go through the loop */ - i = ((incr > 0 ? le : ls) - ofs) / incr + 1; + i = PRECALC_LOOP_COUNT(ofs, incr > 0 ? le : ls, incr); if (i > count) { i = count; count = 0; } else count -= i; - while (i--) - { - RESAMPLATION; + for (j = 0; j < i; j++) + { + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS)+1]; + *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); ofs += incr; } if (ofs>=le) @@ -238,43 +193,9 @@ } } -#else /* PRECALC_LOOPS */ - /* Play normally until inside the loop region */ - - if (ofs < ls) - { - while (count--) - { - RESAMPLATION; - ofs += incr; - if (ofs>=ls) - break; - } - } - - /* Then do the bidirectional looping */ - - if (count>0) - while (count--) - { - RESAMPLATION; - ofs += incr; - if (ofs>=le) - { - /* fold the overshoot back in */ - ofs = le - (ofs - le); - incr = -incr; - } - else if (ofs <= ls) - { - ofs = ls + (ls - ofs); - incr = -incr; - } - } -#endif /* PRECALC_LOOPS */ vp->sample_increment=incr; vp->sample_offset=ofs; /* Update offset */ - return resample_buffer; + return song->resample_buffer; } /*********************** vibrato versions ***************************/ @@ -290,9 +211,9 @@ return phase-VIBRATO_SAMPLE_INCREMENTS/2; } -static int32 update_vibrato(Voice *vp, int sign) -{ - int32 depth; +static Sint32 update_vibrato(MidiSong *song, Voice *vp, int sign) +{ + Sint32 depth; int phase, pb; double a; @@ -329,7 +250,7 @@ a = FSCALE(((double)(vp->sample->sample_rate) * (double)(vp->frequency)) / ((double)(vp->sample->root_freq) * - (double)(play_mode->rate)), + (double)(song->rate)), FRACTION_BITS); pb=(int)((sine(vp->vibrato_phase * @@ -346,26 +267,25 @@ /* If the sweep's over, we can store the newly computed sample_increment */ if (!vp->vibrato_sweep) - vp->vibrato_sample_increment[phase]=(int32) a; + vp->vibrato_sample_increment[phase]=(Sint32) a; if (sign) a = -a; /* need to preserve the loop direction */ - return (int32) a; -} - -static resample_t *rs_vib_plain(int v, int32 *countptr) + return (Sint32) a; +} + +static sample_t *rs_vib_plain(MidiSong *song, int v, Sint32 *countptr) { /* Play sample until end, then free the voice. */ - INTERPVARS; - Voice *vp=&voice[v]; - resample_t - *dest=resample_buffer; + sample_t v1, v2; + Voice *vp=&(song->voice[v]); sample_t + *dest=song->resample_buffer, *src=vp->sample->data; - int32 + Sint32 le=vp->sample->data_length, ofs=vp->sample_offset, incr=vp->sample_increment, @@ -382,15 +302,17 @@ if (!cc--) { cc=vp->vibrato_control_ratio; - incr=update_vibrato(vp, 0); - } - RESAMPLATION; + incr=update_vibrato(song, vp, 0); + } + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS)+1]; + *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); ofs += incr; if (ofs >= le) { - FINALINTERP; + if (ofs == le) + *dest++ = src[(ofs>>FRACTION_BITS)-1]/2; vp->status=VOICE_FREE; - ctl->note(v); *countptr-=count+1; break; } @@ -399,40 +321,37 @@ vp->vibrato_control_counter=cc; vp->sample_increment=incr; vp->sample_offset=ofs; /* Update offset */ - return resample_buffer; -} - -static resample_t *rs_vib_loop(Voice *vp, int32 count) + return song->resample_buffer; +} + +static sample_t *rs_vib_loop(MidiSong *song, Voice *vp, Sint32 count) { /* Play sample until end-of-loop, skip back and continue. */ - INTERPVARS; - int32 + sample_t v1, v2; + Sint32 ofs=vp->sample_offset, incr=vp->sample_increment, le=vp->sample->loop_end, ll=le - vp->sample->loop_start; - resample_t - *dest=resample_buffer; sample_t + *dest=song->resample_buffer, *src=vp->sample->data; int cc=vp->vibrato_control_counter; - -#ifdef PRECALC_LOOPS - int32 i; + Sint32 i, j; int vibflag=0; while (count) { /* Hopefully the loop is longer than an increment */ - if(ofs >= le) + while(ofs >= le) ofs -= ll; /* Precalc how many times to go through the loop, taking the vibrato control ratio into account this time. */ - i = (le - ofs) / incr + 1; + i = PRECALC_LOOP_COUNT(ofs, le, incr); if(i > count) i = count; if(i > cc) { @@ -441,69 +360,82 @@ } else cc -= i; count -= i; - while(i--) - { - RESAMPLATION; + for (j = 0; j < i; j++) + { + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS)+1]; + *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); ofs += incr; } if(vibflag) { cc = vp->vibrato_control_ratio; - incr = update_vibrato(vp, 0); + incr = update_vibrato(song, vp, 0); vibflag = 0; } } - -#else /* PRECALC_LOOPS */ - while (count--) - { - if (!cc--) - { - cc=vp->vibrato_control_ratio; - incr=update_vibrato(vp, 0); - } - RESAMPLATION; - ofs += incr; - if (ofs>=le) - ofs -= ll; /* Hopefully the loop is longer than an increment. */ - } -#endif /* PRECALC_LOOPS */ vp->vibrato_control_counter=cc; vp->sample_increment=incr; vp->sample_offset=ofs; /* Update offset */ - return resample_buffer; -} - -static resample_t *rs_vib_bidir(Voice *vp, int32 count) -{ - INTERPVARS; - int32 + return song->resample_buffer; +} + +static sample_t *rs_vib_bidir(MidiSong *song, Voice *vp, Sint32 count) +{ + sample_t v1, v2; + Sint32 ofs=vp->sample_offset, incr=vp->sample_increment, le=vp->sample->loop_end, ls=vp->sample->loop_start; - resample_t - *dest=resample_buffer; sample_t + *dest=song->resample_buffer, *src=vp->sample->data; int cc=vp->vibrato_control_counter; - -#ifdef PRECALC_LOOPS - int32 + Sint32 le2=le<<1, ls2=ls<<1, - i; + i, j; int vibflag = 0; /* Play normally until inside the loop region */ - while (count && (ofs <= ls)) - { - i = (ls - ofs) / incr + 1; + while (count && incr > 0 && ofs < ls) + { + i = PRECALC_LOOP_COUNT(ofs, ls, incr); if (i > count) i = count; if (i > cc) + { + i = cc; + vibflag = 1; + } + else cc -= i; + count -= i; + for (j = 0; j < i; j++) + { + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS)+1]; + *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); + ofs += incr; + } + if (vibflag) + { + cc = vp->vibrato_control_ratio; + incr = update_vibrato(song, vp, 0); + vibflag = 0; + } + } + + /* Then do the bidirectional looping */ + + while (count) + { + /* Precalc how many times we should go through the loop */ + i = PRECALC_LOOP_COUNT(ofs, incr > 0 ? le : ls, incr); + if(i > count) i = count; + if(i > cc) { i = cc; vibflag = 1; @@ -512,40 +444,15 @@ count -= i; while (i--) { - RESAMPLATION; + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS)+1]; + *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); ofs += incr; } if (vibflag) { cc = vp->vibrato_control_ratio; - incr = update_vibrato(vp, 0); - vibflag = 0; - } - } - - /* Then do the bidirectional looping */ - - while (count) - { - /* Precalc how many times we should go through the loop */ - i = ((incr > 0 ? le : ls) - ofs) / incr + 1; - if(i > count) i = count; - if(i > cc) - { - i = cc; - vibflag = 1; - } - else cc -= i; - count -= i; - while (i--) - { - RESAMPLATION; - ofs += incr; - } - if (vibflag) - { - cc = vp->vibrato_control_ratio; - incr = update_vibrato(vp, (incr < 0)); + incr = update_vibrato(song, vp, (incr < 0)); vibflag = 0; } if (ofs >= le) @@ -561,62 +468,17 @@ } } -#else /* PRECALC_LOOPS */ - /* Play normally until inside the loop region */ - - if (ofs < ls) - { - while (count--) - { - if (!cc--) - { - cc=vp->vibrato_control_ratio; - incr=update_vibrato(vp, 0); - } - RESAMPLATION; - ofs += incr; - if (ofs>=ls) - break; - } - } - - /* Then do the bidirectional looping */ - - if (count>0) - while (count--) - { - if (!cc--) - { - cc=vp->vibrato_control_ratio; - incr=update_vibrato(vp, (incr < 0)); - } - RESAMPLATION; - ofs += incr; - if (ofs>=le) - { - /* fold the overshoot back in */ - ofs = le - (ofs - le); - incr = -incr; - } - else if (ofs <= ls) - { - ofs = ls + (ls - ofs); - incr = -incr; - } - } -#endif /* PRECALC_LOOPS */ - vp->vibrato_control_counter=cc; vp->sample_increment=incr; vp->sample_offset=ofs; /* Update offset */ - return resample_buffer; -} - -resample_t *resample_voice(int v, int32 *countptr) -{ - int32 ofs; - uint8 modes; - Voice *vp=&voice[v]; + return song->resample_buffer; +} + +sample_t *resample_voice(MidiSong *song, int v, Sint32 *countptr) +{ + Sint32 ofs; + Uint8 modes; + Voice *vp=&(song->voice[v]); if (!(vp->sample->sample_rate)) { @@ -628,7 +490,6 @@ { /* Note finished. Free the voice. */ vp->status = VOICE_FREE; - ctl->note(v); /* Let the caller know how much data we had left */ *countptr = (vp->sample->data_length>>FRACTION_BITS) - ofs; @@ -636,7 +497,7 @@ else vp->sample_offset += *countptr << FRACTION_BITS; - return (resample_t *)vp->sample->data+ofs; + return vp->sample->data+ofs; } /* Need to resample. Use the proper function. */ @@ -649,12 +510,12 @@ (vp->status==VOICE_ON || vp->status==VOICE_SUSTAINED))) { if (modes & MODES_PINGPONG) - return rs_vib_bidir(vp, *countptr); + return rs_vib_bidir(song, vp, *countptr); else - return rs_vib_loop(vp, *countptr); + return rs_vib_loop(song, vp, *countptr); } else - return rs_vib_plain(v, countptr); + return rs_vib_plain(song, v, countptr); } else { @@ -663,56 +524,70 @@ (vp->status==VOICE_ON || vp->status==VOICE_SUSTAINED))) { if (modes & MODES_PINGPONG) - return rs_bidir(vp, *countptr); + return rs_bidir(song, vp, *countptr); else - return rs_loop(vp, *countptr); + return rs_loop(song, vp, *countptr); } else - return rs_plain(v, countptr); - } -} - -void pre_resample(Sample * sp) + return rs_plain(song, v, countptr); + } +} + +void pre_resample(MidiSong *song, Sample *sp) { double a, xdiff; - int32 incr, ofs, newlen, count; - int16 *src = (int16 *) sp->data; - resample_t *newdata, *dest; - int16 v1, v2, v3, v4, *vptr; + Sint32 incr, ofs, newlen, count; + Sint16 *newdata, *dest, *src = (Sint16 *) sp->data, *vptr; + Sint32 v, v1, v2, v3, v4, v5, i; +#ifdef DEBUG_CHATTER static const char note_name[12][3] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" }; - ctl->cmsg(CMSG_INFO, VERB_NOISY, " * pre-resampling for note %d (%s%d)", - sp->note_to_use, - note_name[sp->note_to_use % 12], (sp->note_to_use & 0x7F) / 12); - - a = ((double) (sp->sample_rate) * freq_table[(int) (sp->note_to_use)]) / - ((double) (sp->root_freq) * play_mode->rate); - if (a <= 0) return; - newlen = (int32)(sp->data_length / a); - if (newlen < 0 || (newlen >> FRACTION_BITS) > MAX_SAMPLE_SIZE) return; - dest = newdata = safe_malloc(newlen >> (FRACTION_BITS - 1)); - + SNDDBG((" * pre-resampling for note %d (%s%d)\n", + sp->note_to_use, + note_name[sp->note_to_use % 12], (sp->note_to_use & 0x7F) / 12)); +#endif + + a = ((double) (sp->root_freq) * song->rate) / + ((double) (sp->sample_rate) * freq_table[(int) (sp->note_to_use)]); + if(sp->data_length * a >= 0x7fffffffL) { /* Too large to compute */ + SNDDBG((" *** Can't pre-resampling for note %d\n", sp->note_to_use)); + return; + } + + newlen = (Sint32)(sp->data_length * a); count = (newlen >> FRACTION_BITS) - 1; ofs = incr = (sp->data_length - (1 << FRACTION_BITS)) / count; + if((double)newlen + incr >= 0x7fffffffL) { /* Too large to compute */ + SNDDBG((" *** Can't pre-resampling for note %d\n", sp->note_to_use)); + return; + } + + dest = newdata = (Sint16 *) safe_malloc((newlen >> (FRACTION_BITS - 1)) + 2); + if (!dest) + return; + if (--count) *dest++ = src[0]; /* Since we're pre-processing and this doesn't have to be done in real-time, we go ahead and do the full sliding cubic interpolation. */ - while (--count) + count--; + for(i = 0; i < count; i++) { vptr = src + (ofs >> FRACTION_BITS); - v1 = (vptr == src) ? *vptr : *(vptr - 1); + v1 = ((vptr>=src+1)? *(vptr - 1):0); v2 = *vptr; v3 = *(vptr + 1); v4 = *(vptr + 2); + v5 = v2 - v3; xdiff = FSCALENEG(ofs & FRACTION_MASK, FRACTION_BITS); - *dest++ = (int16)(v2 + (xdiff / 6.0) * (-2 * v1 - 3 * v2 + 6 * v3 - v4 + - xdiff * (3 * (v1 - 2 * v2 + v3) + xdiff * (-v1 + 3 * (v2 - v3) + v4)))); + v = (Sint32)(v2 + xdiff * (1.0/6.0) * (3 * (v3 - v5) - 2 * v1 - v4 + + xdiff * (3 * (v1 - v2 - v5) + xdiff * (3 * v5 + v4 - v1)))); + *dest++ = (Sint16)((v > 32767) ? 32767 : ((v < -32768) ? -32768 : v)); ofs += incr; } @@ -720,14 +595,18 @@ { v1 = src[ofs >> FRACTION_BITS]; v2 = src[(ofs >> FRACTION_BITS) + 1]; - *dest++ = (resample_t)(v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS)); + *dest++ = (Sint16)(v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS)); } else *dest++ = src[ofs >> FRACTION_BITS]; + *dest = *(dest - 1) / 2; + ++dest; + *dest = *(dest - 1) / 2; + sp->data_length = newlen; - sp->loop_start = (int32)(sp->loop_start / a); - sp->loop_end = (int32)(sp->loop_end / a); + sp->loop_start = (Sint32)(sp->loop_start * a); + sp->loop_end = (Sint32)(sp->loop_end * a); free(sp->data); sp->data = (sample_t *) newdata; sp->sample_rate = 0; diff --git a/timidity/resample.h b/timidity/resample.h index ee24289..10081e1 100644 --- a/timidity/resample.h +++ b/timidity/resample.h @@ -1,10 +1,13 @@ /* + TiMidity -- Experimental MIDI to WAVE converter Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ -extern resample_t *resample_voice(int v, int32 *countptr); -extern void pre_resample(Sample *sp); + resample.h +*/ + +extern sample_t *resample_voice(MidiSong *song, int v, Sint32 *countptr); +extern void pre_resample(MidiSong *song, Sample *sp); diff --git a/timidity/sdl_a.c b/timidity/sdl_a.c deleted file mode 100644 index 6ea0f4c..0000000 --- a/timidity/sdl_a.c +++ /dev/null @@ -1,19 +0,0 @@ -/* - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - */ - -#include "config.h" -#include "output.h" - -/* export the playback mode */ - -#define dpm sdl_play_mode - -PlayMode dpm = { - DEFAULT_RATE, PE_16BIT|PE_SIGNED, - "SDL audio" -}; diff --git a/timidity/sdl_c.c b/timidity/sdl_c.c deleted file mode 100644 index 5f1f5e3..0000000 --- a/timidity/sdl_c.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - TiMidity -- Experimental MIDI to WAVE converter - Copyright (C) 1995 Tuukka Toivonen - - This program is free software; you can redistribute it and/or modify - it under the terms of the Perl Artistic License, available in COPYING. - */ - -#include -#include -#include - -#include "config.h" -#include "common.h" -#include "output.h" -#include "ctrlmode.h" -#include "instrum.h" -#include "playmidi.h" - -static void ctl_refresh(void); -static void ctl_total_time(int tt); -static void ctl_master_volume(int mv); -static void ctl_file_name(char *name); -static void ctl_current_time(int ct); -static void ctl_note(int v); -static void ctl_program(int ch, int val); -static void ctl_volume(int channel, int val); -static void ctl_expression(int channel, int val); -static void ctl_panning(int channel, int val); -static void ctl_sustain(int channel, int val); -static void ctl_pitch_bend(int channel, int val); -static void ctl_reset(void); -static int ctl_open(int using_stdin, int using_stdout); -static void ctl_close(void); -static int ctl_read(int32 *valp); -static int cmsg(int type, int verbosity_level, char *fmt, ...); - -/**********************************/ -/* export the interface functions */ - -#define ctl sdl_control_mode - -ControlMode ctl= -{ - "SDL interface", 's', - 1,0,0, - ctl_open,NULL, ctl_close, ctl_read, cmsg, - ctl_refresh, ctl_reset, ctl_file_name, ctl_total_time, ctl_current_time, - ctl_note, - ctl_master_volume, ctl_program, ctl_volume, - ctl_expression, ctl_panning, ctl_sustain, ctl_pitch_bend -}; - -static int ctl_open(int using_stdin, int using_stdout) -{ - ctl.opened=1; - return 0; -} - -static void ctl_close(void) -{ - ctl.opened=0; -} - -static int ctl_read(int32 *valp) -{ - return RC_NONE; -} - -static int cmsg(int type, int verbosity_level, char *fmt, ...) -{ -#ifdef GREGS_DEBUG - va_list ap; - int flag_newline = 1; - if ((type==CMSG_TEXT || type==CMSG_INFO || type==CMSG_WARNING) && - ctl.verbosity This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ +*/ + +#if HAVE_CONFIG_H +# include +#endif #include -#include "config.h" -#include "common.h" + +#include "SDL.h" + #include "tables.h" -#include "instrum.h" - -int32 freq_table[128]= + +const Sint32 freq_table[128]= { 8176, 8662, 9177, 9723, 10301, 10913, 11562, 12250, @@ -59,7 +64,7 @@ }; /* v=2.^((x/127-1) * 6) */ -double vol_table[128] = +const double vol_table[128] = { 0.015625, 0.016145143728351113, 0.016682602624583379, 0.017237953096759438, 0.017811790741104401, 0.01840473098076444, 0.019017409725829021, 0.019650484055324921, @@ -95,44 +100,7 @@ 0.90643012614631979, 0.93660445864574493, 0.96778327049280244, 1 }; - -/* v=2.^((x/127-1) * 4) */ -FLOAT_T expr_table[128] = { -0.062500000000000000, 0.063879466007418617, 0.065289378838287213, 0.066730410498333517, -0.068203247825430205, 0.069708592816961873, 0.071247162964417632, 0.072819691595368496, -0.074426928222992794, 0.076069638903316056, 0.077748606600335793, 0.079464631559205010, -0.081218531687652529, 0.083011142945821639, 0.084843319744713291, 0.086715935353423396, -0.088629882315368322, 0.090586072873697340, 0.092585439406094330, 0.094628934869176312, -0.096717533252700480, 0.098852230043796174, 0.101034042701443255, 0.103264011141422821, -0.105543198231971461, 0.107872690300375454, 0.110253597650746091, 0.112687055093223104, -0.115174222484858521, 0.117716285282438229, 0.120314455107505686, 0.122969970323856051, -0.125684096627776631, 0.128458127651314785, 0.131293385578860888, 0.134191221777339997, -0.137153017440313080, 0.140180184246293943, 0.143274165031597039, 0.146436434478035005, -0.149668499815795553, 0.152971901541831212, 0.156348214154105547, 0.159799046902044661, -0.163326044553552957, 0.166930888178957210, 0.170615295952254331, 0.174381023970043153, -0.178229867088531585, 0.182163659779017467, 0.186184277002251486, 0.190293635102098180, -0.194493692718921724, 0.198786451723130919, 0.203173958169329677, 0.207658303271526207, -0.212241624399866963, 0.216926106099369798, 0.221713981131142046, 0.226607531536579865, -0.231609089725056033, 0.236721039585614190, 0.241945817623200610, 0.247285914119973582, -0.252743874322244710, 0.258322299653617804, 0.264023848954903828, 0.269851239751401739, -0.275807249548151001, 0.281894717153771790, 0.288116544033524102, 0.294475695692230921, -0.300975203087725074, 0.307618164075491973, 0.314407744885198681, 0.321347181629811129, -0.328439781848020751, 0.335688926080714045, 0.343098069482237422, 0.350670743467224599, -0.358410557393772644, 0.366321200283767356, 0.374406442581179333, 0.382670137949167655, -0.391116225106848792, 0.399748729706605410, 0.408571766252830038, 0.417589540063018294, -0.426806349272146446, 0.436226586881288292, 0.445854742851448105, 0.455695406243607215, -0.465753267406005200, 0.476033120209697069, 0.486539864333452310, 0.497278507599085373, -0.508254168358330150, 0.519472077932396359, 0.530937583105370092, 0.542656148672647887, -0.554633360045617918, 0.566874925913830707, 0.579386680965928047, 0.592174588670625557, -0.605244744119077360, 0.618603376929974136, 0.632256854218762432, 0.646211683632397893, -0.660474516451080240, 0.675052150758448599, 0.689951534681746304, 0.705179769703502823, -0.720744114046307338, 0.736651986132290215, 0.752910968118960744, 0.769528809513084777, -0.786513430864326790, 0.803872927540415394, 0.821615573585632974, 0.839749825664467098, -0.858284327092304622, 0.877227911955088646, 0.896589609319902503, 0.916378647538487301, -0.936604458645744820, 0.957276682855321193, 0.978405173154415220, 1.000000000000000000 -}; - -double bend_fine[256] = { +const double bend_fine[256] = { 1, 1.0002256593050698, 1.0004513695322617, 1.0006771306930664, 1.0009029427989777, 1.0011288058614922, 1.0013547198921082, 1.0015806849023274, 1.0018067009036538, 1.002032767907594, 1.0022588859256572, 1.0024850549693551, @@ -199,7 +167,7 @@ 1.0585073227945128, 1.0587461848213857, 1.058985100749698, 1.0592240705916123 }; -double bend_coarse[128] = { +const double bend_coarse[128] = { 1, 1.0594630943592953, 1.122462048309373, 1.189207115002721, 1.2599210498948732, 1.3348398541700344, 1.4142135623730951, 1.4983070768766815, 1.5874010519681994, 1.681792830507429, 1.7817974362806785, 1.8877486253633868, @@ -233,880 +201,3 @@ 1024, 1084.8902086239189, 1149.4011374687975, 1217.7480857627863, 1290.1591550923506, 1366.8760106701147, 1448.1546878700494, 1534.2664467217226 }; - -#ifdef LOOKUP_SINE -static double sine_table[257]= -{ - 0, 0.0061358846491544753, 0.012271538285719925, 0.01840672990580482, - 0.024541228522912288, 0.030674803176636626, 0.036807222941358832, 0.04293825693494082, - 0.049067674327418015, 0.055195244349689934, 0.061320736302208578, 0.067443919563664051, - 0.073564563599667426, 0.079682437971430126, 0.085797312344439894, 0.091908956497132724, - 0.098017140329560604, 0.10412163387205459, 0.11022220729388306, 0.11631863091190475, - 0.1224106751992162, 0.12849811079379317, 0.13458070850712617, 0.14065823933284921, - 0.14673047445536175, 0.15279718525844344, 0.15885814333386145, 0.16491312048996989, - 0.17096188876030122, 0.17700422041214875, 0.18303988795514095, 0.18906866414980619, - 0.19509032201612825, 0.2011046348420919, 0.20711137619221856, 0.21311031991609136, - 0.2191012401568698, 0.22508391135979283, 0.23105810828067111, 0.2370236059943672, - 0.24298017990326387, 0.24892760574572015, 0.25486565960451457, 0.26079411791527551, - 0.26671275747489837, 0.27262135544994898, 0.27851968938505306, 0.28440753721127188, - 0.29028467725446233, 0.29615088824362379, 0.30200594931922808, 0.30784964004153487, - 0.31368174039889152, 0.31950203081601569, 0.32531029216226293, 0.33110630575987643, - 0.33688985339222005, 0.34266071731199438, 0.34841868024943456, 0.35416352542049034, - 0.35989503653498811, 0.36561299780477385, 0.37131719395183754, 0.37700741021641826, - 0.38268343236508978, 0.38834504669882625, 0.3939920400610481, 0.39962419984564679, - 0.40524131400498986, 0.41084317105790391, 0.41642956009763715, 0.42200027079979968, - 0.42755509343028208, 0.43309381885315196, 0.43861623853852766, 0.4441221445704292, - 0.44961132965460654, 0.45508358712634384, 0.46053871095824001, 0.46597649576796618, - 0.47139673682599764, 0.47679923006332209, 0.48218377207912272, 0.487550160148436, - 0.49289819222978404, 0.49822766697278187, 0.50353838372571758, 0.50883014254310699, - 0.51410274419322166, 0.51935599016558964, 0.52458968267846895, 0.52980362468629461, - 0.53499761988709715, 0.54017147272989285, 0.54532498842204646, 0.55045797293660481, - 0.55557023301960218, 0.56066157619733603, 0.56573181078361312, 0.57078074588696726, - 0.57580819141784534, 0.58081395809576453, 0.58579785745643886, 0.59075970185887416, - 0.59569930449243336, 0.60061647938386897, 0.60551104140432555, 0.61038280627630948, - 0.61523159058062682, 0.6200572117632891, 0.62485948814238634, 0.62963823891492698, - 0.63439328416364549, 0.63912444486377573, 0.64383154288979139, 0.64851440102211244, - 0.65317284295377676, 0.65780669329707864, 0.66241577759017178, 0.66699992230363747, - 0.67155895484701833, 0.67609270357531592, 0.68060099779545302, 0.68508366777270036, - 0.68954054473706683, 0.693971460889654, 0.69837624940897292, 0.7027547444572253, - 0.70710678118654746, 0.71143219574521643, 0.71573082528381859, 0.72000250796138165, - 0.72424708295146689, 0.7284643904482252, 0.73265427167241282, 0.73681656887736979, - 0.74095112535495911, 0.74505778544146595, 0.74913639452345926, 0.75318679904361241, - 0.75720884650648446, 0.76120238548426178, 0.76516726562245896, 0.76910333764557959, - 0.77301045336273699, 0.77688846567323244, 0.78073722857209438, 0.78455659715557524, - 0.78834642762660623, 0.79210657730021239, 0.79583690460888346, 0.79953726910790501, - 0.80320753148064483, 0.80684755354379922, 0.81045719825259477, 0.8140363297059483, - 0.81758481315158371, 0.82110251499110465, 0.82458930278502529, 0.8280450452577558, - 0.83146961230254524, 0.83486287498638001, 0.83822470555483797, 0.84155497743689833, - 0.84485356524970701, 0.84812034480329712, 0.8513551931052652, 0.85455798836540053, - 0.85772861000027212, 0.86086693863776731, 0.8639728561215867, 0.86704624551569265, - 0.87008699110871135, 0.87309497841829009, 0.8760700941954066, 0.87901222642863341, - 0.88192126434835494, 0.88479709843093779, 0.88763962040285393, 0.89044872324475788, - 0.89322430119551532, 0.89596624975618511, 0.89867446569395382, 0.90134884704602203, - 0.90398929312344334, 0.90659570451491533, 0.90916798309052227, 0.91170603200542988, - 0.91420975570353069, 0.9166790599210427, 0.91911385169005777, 0.9215140393420419, - 0.92387953251128674, 0.92621024213831127, 0.92850608047321548, 0.93076696107898371, - 0.93299279883473885, 0.9351835099389475, 0.93733901191257496, 0.93945922360218992, - 0.94154406518302081, 0.94359345816196039, 0.94560732538052128, 0.94758559101774109, - 0.94952818059303667, 0.95143502096900834, 0.95330604035419375, 0.95514116830577067, - 0.95694033573220894, 0.9587034748958716, 0.96043051941556579, 0.96212140426904158, - 0.96377606579543984, 0.9653944416976894, 0.96697647104485207, 0.96852209427441727, - 0.97003125319454397, 0.97150389098625178, 0.97293995220556007, 0.97433938278557586, - 0.97570213003852857, 0.97702814265775439, 0.97831737071962765, 0.97956976568544052, - 0.98078528040323043, 0.98196386910955524, 0.98310548743121629, 0.98421009238692903, - 0.98527764238894122, 0.98630809724459867, 0.98730141815785843, 0.98825756773074946, - 0.98917650996478101, 0.99005821026229712, 0.99090263542778001, 0.99170975366909953, - 0.99247953459870997, 0.9932119492347945, 0.99390697000235606, 0.99456457073425542, - 0.99518472667219682, 0.99576741446765982, 0.996312612182778, 0.99682029929116567, - 0.99729045667869021, 0.99772306664419164, 0.99811811290014918, 0.99847558057329477, - 0.99879545620517241, 0.99907772775264536, 0.99932238458834954, 0.99952941750109314, - 0.99969881869620425, 0.9998305817958234, 0.9999247018391445, 0.99998117528260111, - 1 -}; - -/* - looks up sin(2 * Pi * x / 1024) -*/ -FLOAT_T sine(int x) -{ - int xx = x & 0xFF; - switch ((x>>8) & 0x03) - { - default: /* just to shut gcc up. */ - case 0: - return sine_table[xx]; - case 1: - return sine_table[0x100 - xx]; - case 2: - return -sine_table[xx]; - case 3: - return -sine_table[0x100 - xx]; - } -} -#endif /* LOOKUP_SINE */ - -#ifdef LOOKUP_HACK -int16 _u2l[] = -{ - -32256, -31228, -30200, -29172, -28143, -27115, -26087, -25059, - -24031, -23002, -21974, -20946, -19918, -18889, -17861, -16833, - -16062, -15548, -15033, -14519, -14005, -13491, -12977, -12463, - -11949, -11435, -10920, -10406, -9892, -9378, -8864, -8350, - -7964, -7707, -7450, -7193, -6936, -6679, -6422, -6165, - -5908, -5651, -5394, -5137, -4880, -4623, -4365, -4108, - -3916, -3787, -3659, -3530, -3402, -3273, -3144, -3016, - -2887, -2759, -2630, -2502, -2373, -2245, -2116, -1988, - -1891, -1827, -1763, -1698, -1634, -1570, -1506, -1441, - -1377, -1313, -1249, -1184, -1120, -1056, -992, -927, - -879, -847, -815, -783, -751, -718, -686, -654, - -622, -590, -558, -526, -494, -461, -429, -397, - -373, -357, -341, -325, -309, -293, -277, -261, - -245, -228, -212, -196, -180, -164, -148, -132, - -120, -112, -104, -96, -88, -80, -72, -64, - -56, -48, -40, -32, -24, -16, -8, 0, - 32256, 31228, 30200, 29172, 28143, 27115, 26087, 25059, - 24031, 23002, 21974, 20946, 19918, 18889, 17861, 16833, - 16062, 15548, 15033, 14519, 14005, 13491, 12977, 12463, - 11949, 11435, 10920, 10406, 9892, 9378, 8864, 8350, - 7964, 7707, 7450, 7193, 6936, 6679, 6422, 6165, - 5908, 5651, 5394, 5137, 4880, 4623, 4365, 4108, - 3916, 3787, 3659, 3530, 3402, 3273, 3144, 3016, - 2887, 2759, 2630, 2502, 2373, 2245, 2116, 1988, - 1891, 1827, 1763, 1698, 1634, 1570, 1506, 1441, - 1377, 1313, 1249, 1184, 1120, 1056, 992, 927, - 879, 847, 815, 783, 751, 718, 686, 654, - 622, 590, 558, 526, 494, 461, 429, 397, - 373, 357, 341, 325, 309, 293, 277, 261, - 245, 228, 212, 196, 180, 164, 148, 132, - 120, 112, 104, 96, 88, 80, 72, 64, - 56, 48, 40, 32, 24, 16, 8, 0 -}; - -int32 *mixup; -#ifdef LOOKUP_INTERPOLATION -int8 *iplookup; -#endif - -#endif - -void init_tables(void) -{ -#ifdef LOOKUP_HACK - int i,j,v; - mixup=safe_malloc(1<<(7+8+2)); /* Give your cache a workout! */ - - for (i=0; i<128; i++) - { - v=_u2l[255-i]; - for (j=-128; j<128; j++) - { - mixup[ ((i & 0x7F)<<8) | (j & 0xFF)] = - (v * j) << MIXUP_SHIFT; - } - } - -#ifdef LOOKUP_INTERPOLATION - iplookup=safe_malloc(1<<(9+5)); - for (i=-256; i<256; i++) - for(j=0; j<32; j++) - iplookup[((i<<5) & 0x3FE0) | j] = (i * j)>>5; - /* I don't know. Quantum bits? Magick? */ -#endif - -#endif -} - -uint8 _l2u_[] = -{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, - 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, - 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, - 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, - 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, - 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, - 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, - 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, - 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, - 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, - 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, - 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, - 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, - 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, - 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, - 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, - 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, - 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, - 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, - 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, - 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, - 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, - 0x09, 0x09, 0x09, 0x09, 0x09, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, - 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, - 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, - 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, - 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, - 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, - 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, - 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, - 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, - 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, - 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, - 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, - 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, - 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, - 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, - 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, - 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, - 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, - 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, - 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, - 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, - 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, - 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, - 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, - 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, - 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, - 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, - 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, - 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, - 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, - 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, - 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, - 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, - 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, - 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, - 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, - 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, - 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, - 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, - 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, - 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, - 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, - 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, - 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, - 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, - 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, - 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, - 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, - 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, - 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, - 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, - 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, - 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, - 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, - 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, - 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, - 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, - 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, - 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x19, 0x19, - 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, - 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, - 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, - 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, - 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, - 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, - 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, - 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, - 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, - 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, - 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, - 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, - 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, - 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, - 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, - 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1D, 0x1D, 0x1D, 0x1D, - 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, - 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, - 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, - 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1E, 0x1E, 0x1E, 0x1E, - 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, - 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, - 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, - 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1F, 0x1F, 0x1F, 0x1F, - 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, - 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, - 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, - 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, - 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x21, - 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, - 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, - 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x23, 0x23, 0x23, - 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, - 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x24, 0x24, 0x24, - 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, - 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x25, 0x25, 0x25, - 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, - 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26, - 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, - 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x27, 0x27, 0x27, - 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, - 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x28, 0x28, - 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, - 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x29, 0x29, - 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, - 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x2A, 0x2A, - 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, - 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2B, 0x2B, - 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, - 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2C, 0x2C, - 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, - 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2D, 0x2D, - 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, - 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2E, 0x2E, - 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, - 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2F, 0x2F, - 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, - 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x30, - 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, - 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x32, - 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x33, - 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x34, - 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x35, - 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x36, - 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, - 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x38, - 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x39, - 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x3A, - 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3B, - 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3C, - 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3D, - 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, - 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, - 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, - 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, - 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, - 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, - 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, - 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, - 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, - 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, - 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, - 0x50, 0x50, 0x50, 0x50, 0x51, 0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x52, 0x53, 0x53, 0x53, 0x53, - 0x54, 0x54, 0x54, 0x54, 0x55, 0x55, 0x55, 0x55, 0x56, 0x56, 0x56, 0x56, 0x57, 0x57, 0x57, 0x57, - 0x58, 0x58, 0x58, 0x58, 0x59, 0x59, 0x59, 0x59, 0x5A, 0x5A, 0x5A, 0x5A, 0x5B, 0x5B, 0x5B, 0x5B, - 0x5C, 0x5C, 0x5C, 0x5C, 0x5D, 0x5D, 0x5D, 0x5D, 0x5E, 0x5E, 0x5E, 0x5E, 0x5F, 0x5F, 0x5F, 0x5F, - 0x60, 0x60, 0x61, 0x61, 0x62, 0x62, 0x63, 0x63, 0x64, 0x64, 0x65, 0x65, 0x66, 0x66, 0x67, 0x67, - 0x68, 0x68, 0x68, 0x69, 0x69, 0x6A, 0x6A, 0x6B, 0x6B, 0x6C, 0x6C, 0x6D, 0x6D, 0x6E, 0x6E, 0x6F, - 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, - 0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8, 0xF7, 0xF6, 0xF5, 0xF4, 0xF3, 0xF2, 0xF1, 0xF0, - 0xEF, 0xEF, 0xEE, 0xEE, 0xED, 0xED, 0xEC, 0xEC, 0xEB, 0xEB, 0xEA, 0xEA, 0xE9, 0xE9, 0xE8, 0xE8, - 0xE7, 0xE7, 0xE6, 0xE6, 0xE5, 0xE5, 0xE4, 0xE4, 0xE3, 0xE3, 0xE2, 0xE2, 0xE1, 0xE1, 0xE0, 0xE0, - 0xDF, 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE, 0xDE, 0xDD, 0xDD, 0xDD, 0xDD, 0xDC, 0xDC, 0xDC, 0xDC, - 0xDB, 0xDB, 0xDB, 0xDB, 0xDA, 0xDA, 0xDA, 0xDA, 0xD9, 0xD9, 0xD9, 0xD9, 0xD8, 0xD8, 0xD8, 0xD8, - 0xD7, 0xD7, 0xD7, 0xD7, 0xD6, 0xD6, 0xD6, 0xD6, 0xD5, 0xD5, 0xD5, 0xD5, 0xD4, 0xD4, 0xD4, 0xD4, - 0xD3, 0xD3, 0xD3, 0xD3, 0xD2, 0xD2, 0xD2, 0xD2, 0xD1, 0xD1, 0xD1, 0xD1, 0xD0, 0xD0, 0xD0, 0xD0, - 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, - 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, - 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, - 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, - 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, - 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, - 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, - 0xC2, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, - 0xC0, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, - 0xBF, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, - 0xBE, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, - 0xBD, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, - 0xBC, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, - 0xBB, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, - 0xBA, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, - 0xB9, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, - 0xB8, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, - 0xB7, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, - 0xB6, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, - 0xB5, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, - 0xB4, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, - 0xB3, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, - 0xB2, 0xB2, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, - 0xB1, 0xB1, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, - 0xB0, 0xB0, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, - 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, - 0xAF, 0xAF, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, - 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, - 0xAE, 0xAE, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, - 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, - 0xAD, 0xAD, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, - 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, - 0xAC, 0xAC, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, - 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, - 0xAB, 0xAB, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, - 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, - 0xAA, 0xAA, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, - 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, - 0xA9, 0xA9, 0xA9, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, - 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, - 0xA8, 0xA8, 0xA8, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, - 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, - 0xA7, 0xA7, 0xA7, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, - 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, - 0xA6, 0xA6, 0xA6, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, - 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, - 0xA5, 0xA5, 0xA5, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, - 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, - 0xA4, 0xA4, 0xA4, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, - 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, - 0xA3, 0xA3, 0xA3, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, - 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, - 0xA2, 0xA2, 0xA2, 0xA2, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, - 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, - 0xA1, 0xA1, 0xA1, 0xA1, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, - 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, - 0xA0, 0xA0, 0xA0, 0xA0, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, - 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, - 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, - 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, - 0x9F, 0x9F, 0x9F, 0x9F, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, - 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, - 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, - 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, - 0x9E, 0x9E, 0x9E, 0x9E, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, - 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, - 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, - 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, - 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, - 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, - 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, - 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, - 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, - 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, - 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, - 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, - 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, - 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, - 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, - 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, - 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, - 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, - 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, - 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, - 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, - 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, - 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, - 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, - 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, - 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, - 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, - 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, - 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, - 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, - 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, - 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, - 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, - 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, - 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, - 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, - 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, - 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, - 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, - 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, - 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, - 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, - 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, - 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, - 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, - 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, - 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, - 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, - 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, - 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, - 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, - 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, - 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, - 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, - 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, - 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, - 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, - 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, - 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, - 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, - 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, - 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, - 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, - 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, - 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, - 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, - 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, - 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, - 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, - 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, - 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, - 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, - 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, - 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, - 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, - 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, - 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, - 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, - 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, - 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, - 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, - 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, - 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, - 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, - 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, - 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 -}; - -uint8 *_l2u = _l2u_ + 4096; - - -/* $Id$ Greg Lee */ -int xmap[XMAPMAX][5] = { -{ SFXBANK, 0, 0, 120, 0 }, -{ SFXBANK, 0, 1, 120, 1 }, -{ SFXBANK, 0, 2, 120, 2 }, -{ SFXBANK, 0, 3, 120, 3 }, -{ SFXBANK, 0, 4, 120, 4 }, -{ SFXBANK, 0, 5, 120, 5 }, -{ SFXBANK, 0, 16, 120, 16 }, -{ SFXBANK, 0, 32, 120, 32 }, -{ SFXBANK, 0, 33, 120, 33 }, -{ SFXBANK, 0, 34, 120, 34 }, -{ SFXBANK, 0, 35, 120, 35 }, -{ SFXBANK, 0, 36, 120, 36 }, -{ SFXBANK, 0, 48, 120, 48 }, -{ SFXBANK, 0, 49, 120, 49 }, -{ SFXBANK, 0, 50, 120, 50 }, -{ SFXBANK, 0, 51, 120, 51 }, -{ SFXBANK, 0, 52, 120, 52 }, -{ SFXBANK, 0, 54, 120, 54 }, -{ SFXBANK, 0, 55, 120, 55 }, -{ SFXBANK, 0, 64, 120, 64 }, -{ SFXBANK, 0, 65, 120, 65 }, -{ SFXBANK, 0, 66, 120, 66 }, -{ SFXBANK, 0, 67, 120, 67 }, -{ SFXBANK, 0, 68, 120, 68 }, -{ SFXBANK, 0, 69, 120, 69 }, -{ SFXBANK, 0, 70, 120, 70 }, -{ SFXBANK, 0, 80, 120, 80 }, -{ SFXBANK, 0, 81, 120, 81 }, -{ SFXBANK, 0, 82, 120, 82 }, -{ SFXBANK, 0, 83, 120, 83 }, -{ SFXBANK, 0, 84, 120, 84 }, -{ SFXBANK, 0, 85, 120, 85 }, -{ SFXBANK, 0, 86, 120, 86 }, -{ SFXBANK, 0, 87, 120, 87 }, -{ SFXBANK, 0, 88, 120, 88 }, -{ SFXBANK, 0, 89, 120, 89 }, -{ SFXBANK, 0, 90, 120, 90 }, -{ SFXBANK, 0, 96, 120, 96 }, -{ SFXBANK, 0, 97, 120, 97 }, -{ SFXBANK, 0, 98, 120, 98 }, -{ SFXBANK, 0, 99, 120, 99 }, -{ SFXBANK, 0, 100, 120, 100 }, -{ SFXBANK, 0, 101, 120, 101 }, -{ SFXBANK, 0, 112, 120, 112 }, -{ SFXBANK, 0, 113, 120, 113 }, -{ SFXBANK, 0, 114, 120, 114 }, -{ SFXBANK, 0, 115, 120, 115 }, -{ SFXDRUM1, 0, 36, 121, 36 }, -{ SFXDRUM1, 0, 37, 121, 37 }, -{ SFXDRUM1, 0, 38, 121, 38 }, -{ SFXDRUM1, 0, 39, 121, 39 }, -{ SFXDRUM1, 0, 40, 121, 40 }, -{ SFXDRUM1, 0, 41, 121, 41 }, -{ SFXDRUM1, 0, 52, 121, 52 }, -{ SFXDRUM1, 0, 68, 121, 68 }, -{ SFXDRUM1, 0, 69, 121, 69 }, -{ SFXDRUM1, 0, 70, 121, 70 }, -{ SFXDRUM1, 0, 71, 121, 71 }, -{ SFXDRUM1, 0, 72, 121, 72 }, -{ SFXDRUM1, 0, 84, 121, 84 }, -{ SFXDRUM1, 0, 85, 121, 85 }, -{ SFXDRUM1, 0, 86, 121, 86 }, -{ SFXDRUM1, 0, 87, 121, 87 }, -{ SFXDRUM1, 0, 88, 121, 88 }, -{ SFXDRUM1, 0, 90, 121, 90 }, -{ SFXDRUM1, 0, 91, 121, 91 }, -{ SFXDRUM1, 1, 36, 122, 36 }, -{ SFXDRUM1, 1, 37, 122, 37 }, -{ SFXDRUM1, 1, 38, 122, 38 }, -{ SFXDRUM1, 1, 39, 122, 39 }, -{ SFXDRUM1, 1, 40, 122, 40 }, -{ SFXDRUM1, 1, 41, 122, 41 }, -{ SFXDRUM1, 1, 42, 122, 42 }, -{ SFXDRUM1, 1, 52, 122, 52 }, -{ SFXDRUM1, 1, 53, 122, 53 }, -{ SFXDRUM1, 1, 54, 122, 54 }, -{ SFXDRUM1, 1, 55, 122, 55 }, -{ SFXDRUM1, 1, 56, 122, 56 }, -{ SFXDRUM1, 1, 57, 122, 57 }, -{ SFXDRUM1, 1, 58, 122, 58 }, -{ SFXDRUM1, 1, 59, 122, 59 }, -{ SFXDRUM1, 1, 60, 122, 60 }, -{ SFXDRUM1, 1, 61, 122, 61 }, -{ SFXDRUM1, 1, 62, 122, 62 }, -{ SFXDRUM1, 1, 68, 122, 68 }, -{ SFXDRUM1, 1, 69, 122, 69 }, -{ SFXDRUM1, 1, 70, 122, 70 }, -{ SFXDRUM1, 1, 71, 122, 71 }, -{ SFXDRUM1, 1, 72, 122, 72 }, -{ SFXDRUM1, 1, 73, 122, 73 }, -{ SFXDRUM1, 1, 84, 122, 84 }, -{ SFXDRUM1, 1, 85, 122, 85 }, -{ SFXDRUM1, 1, 86, 122, 86 }, -{ SFXDRUM1, 1, 87, 122, 87 }, -{ XGDRUM, 0, 25, 40, 38 }, -{ XGDRUM, 0, 26, 40, 40 }, -{ XGDRUM, 0, 27, 40, 39 }, -{ XGDRUM, 0, 28, 40, 30 }, -{ XGDRUM, 0, 29, 0, 25 }, -{ XGDRUM, 0, 30, 0, 85 }, -{ XGDRUM, 0, 31, 0, 38 }, -{ XGDRUM, 0, 32, 0, 37 }, -{ XGDRUM, 0, 33, 0, 36 }, -{ XGDRUM, 0, 34, 0, 38 }, -{ XGDRUM, 0, 62, 0, 101 }, -{ XGDRUM, 0, 63, 0, 102 }, -{ XGDRUM, 0, 64, 0, 103 }, -{ XGDRUM, 8, 25, 40, 38 }, -{ XGDRUM, 8, 26, 40, 40 }, -{ XGDRUM, 8, 27, 40, 39 }, -{ XGDRUM, 8, 28, 40, 40 }, -{ XGDRUM, 8, 29, 8, 25 }, -{ XGDRUM, 8, 30, 8, 85 }, -{ XGDRUM, 8, 31, 8, 38 }, -{ XGDRUM, 8, 32, 8, 37 }, -{ XGDRUM, 8, 33, 8, 36 }, -{ XGDRUM, 8, 34, 8, 38 }, -{ XGDRUM, 8, 62, 8, 101 }, -{ XGDRUM, 8, 63, 8, 102 }, -{ XGDRUM, 8, 64, 8, 103 }, -{ XGDRUM, 16, 25, 40, 38 }, -{ XGDRUM, 16, 26, 40, 40 }, -{ XGDRUM, 16, 27, 40, 39 }, -{ XGDRUM, 16, 28, 40, 40 }, -{ XGDRUM, 16, 29, 16, 25 }, -{ XGDRUM, 16, 30, 16, 85 }, -{ XGDRUM, 16, 31, 16, 38 }, -{ XGDRUM, 16, 32, 16, 37 }, -{ XGDRUM, 16, 33, 16, 36 }, -{ XGDRUM, 16, 34, 16, 38 }, -{ XGDRUM, 16, 62, 16, 101 }, -{ XGDRUM, 16, 63, 16, 102 }, -{ XGDRUM, 16, 64, 16, 103 }, -{ XGDRUM, 24, 25, 40, 38 }, -{ XGDRUM, 24, 26, 40, 40 }, -{ XGDRUM, 24, 27, 40, 39 }, -{ XGDRUM, 24, 28, 24, 100 }, -{ XGDRUM, 24, 29, 24, 25 }, -{ XGDRUM, 24, 30, 24, 15 }, -{ XGDRUM, 24, 31, 24, 38 }, -{ XGDRUM, 24, 32, 24, 37 }, -{ XGDRUM, 24, 33, 24, 36 }, -{ XGDRUM, 24, 34, 24, 38 }, -{ XGDRUM, 24, 62, 24, 101 }, -{ XGDRUM, 24, 63, 24, 102 }, -{ XGDRUM, 24, 64, 24, 103 }, -{ XGDRUM, 24, 78, 0, 17 }, -{ XGDRUM, 24, 79, 0, 18 }, -{ XGDRUM, 25, 25, 40, 38 }, -{ XGDRUM, 25, 26, 40, 40 }, -{ XGDRUM, 25, 27, 40, 39 }, -{ XGDRUM, 25, 28, 25, 100 }, -{ XGDRUM, 25, 29, 25, 25 }, -{ XGDRUM, 25, 30, 25, 15 }, -{ XGDRUM, 25, 31, 25, 38 }, -{ XGDRUM, 25, 32, 25, 37 }, -{ XGDRUM, 25, 33, 25, 36 }, -{ XGDRUM, 25, 34, 25, 38 }, -{ XGDRUM, 25, 78, 0, 17 }, -{ XGDRUM, 25, 79, 0, 18 }, -{ XGDRUM, 32, 25, 40, 38 }, -{ XGDRUM, 32, 26, 40, 40 }, -{ XGDRUM, 32, 27, 40, 39 }, -{ XGDRUM, 32, 28, 40, 40 }, -{ XGDRUM, 32, 29, 32, 25 }, -{ XGDRUM, 32, 30, 32, 85 }, -{ XGDRUM, 32, 31, 32, 38 }, -{ XGDRUM, 32, 32, 32, 37 }, -{ XGDRUM, 32, 33, 32, 36 }, -{ XGDRUM, 32, 34, 32, 38 }, -{ XGDRUM, 32, 62, 32, 101 }, -{ XGDRUM, 32, 63, 32, 102 }, -{ XGDRUM, 32, 64, 32, 103 }, -{ XGDRUM, 40, 25, 40, 38 }, -{ XGDRUM, 40, 26, 40, 40 }, -{ XGDRUM, 40, 27, 40, 39 }, -{ XGDRUM, 40, 28, 40, 40 }, -{ XGDRUM, 40, 29, 40, 25 }, -{ XGDRUM, 40, 30, 40, 85 }, -{ XGDRUM, 40, 31, 40, 39 }, -{ XGDRUM, 40, 32, 40, 37 }, -{ XGDRUM, 40, 33, 40, 36 }, -{ XGDRUM, 40, 34, 40, 38 }, -{ XGDRUM, 40, 38, 40, 39 }, -{ XGDRUM, 40, 39, 0, 39 }, -{ XGDRUM, 40, 40, 40, 38 }, -{ XGDRUM, 40, 42, 0, 42 }, -{ XGDRUM, 40, 46, 0, 46 }, -{ XGDRUM, 40, 62, 40, 101 }, -{ XGDRUM, 40, 63, 40, 102 }, -{ XGDRUM, 40, 64, 40, 103 }, -{ XGDRUM, 40, 87, 40, 87 } -}; diff --git a/timidity/tables.h b/timidity/tables.h index 9535966..db71ed7 100644 --- a/timidity/tables.h +++ b/timidity/tables.h @@ -1,36 +1,19 @@ -/* +/* + TiMidity -- Experimental MIDI to WAVE converter Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ -#ifdef LOOKUP_SINE -extern FLOAT_T sine(int x); -#else + tables.h +*/ + #include #define sine(x) (sin((2*PI/1024.0) * (x))) -#endif #define SINE_CYCLE_LENGTH 1024 -extern int32 freq_table[]; -extern double vol_table[]; -extern double expr_table[]; -extern double bend_fine[]; -extern double bend_coarse[]; -extern uint8 *_l2u; /* 13-bit PCM to 8-bit u-law */ -extern uint8 _l2u_[]; /* used in LOOKUP_HACK */ -#ifdef LOOKUP_HACK -extern int16 _u2l[]; -extern int32 *mixup; -#ifdef LOOKUP_INTERPOLATION -extern int8 *iplookup; -#endif -#endif - -extern void init_tables(void); - -#define XMAPMAX 800 -extern int xmap[XMAPMAX][5]; - +extern const Sint32 freq_table[]; +extern const double vol_table[]; +extern const double bend_fine[]; +extern const double bend_coarse[]; diff --git a/timidity/timidity.c b/timidity/timidity.c index 5b96800..5cf5c9a 100644 --- a/timidity/timidity.c +++ b/timidity/timidity.c @@ -1,304 +1,445 @@ /* + TiMidity -- Experimental MIDI to WAVE converter Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ +*/ + +#if HAVE_CONFIG_H +# include +#endif #include #include #include #include "SDL.h" -#include "config.h" + +#include "timidity.h" + +#include "options.h" #include "common.h" #include "instrum.h" #include "playmidi.h" #include "readmidi.h" #include "output.h" -#include "ctrlmode.h" -#include "timidity.h" #include "tables.h" -void (*s32tobuf)(void *dp, int32 *lp, int32 c); -int free_instruments_afterwards=0; -static char def_instr_name[256]=""; - -int AUDIO_BUFFER_SIZE; -resample_t *resample_buffer=NULL; -int32 *common_buffer=NULL; -int num_ochannels; +ToneBank *master_tonebank[MAXBANK], *master_drumset[MAXBANK]; + +static char def_instr_name[256] = ""; #define MAXWORDS 10 + +/* Quick-and-dirty fgets() replacement. */ + +static char *RWgets(SDL_RWops *rw, char *s, int size) +{ + int num_read = 0; + char *p = s; + + --size;/* so that we nul terminate properly */ + + for (; num_read < size; ++p) + { + if (SDL_RWread(rw, p, 1, 1) != 1) + break; + + num_read++; + + /* Unlike fgets(), don't store newline. Under Windows/DOS we'll + * probably get an extra blank line for every line that's being + * read, but that should be ok. + */ + if (*p == '\n' || *p == '\r') + { + *p = '\0'; + return s; + } + } + + *p = '\0'; + + return (num_read != 0) ? s : NULL; +} static int read_config_file(const char *name) { - FILE *fp; - char tmp[PATH_MAX], *w[MAXWORDS], *cp; + SDL_RWops *rw; + char tmp[1024], *w[MAXWORDS], *cp; ToneBank *bank=0; int i, j, k, line=0, words; static int rcf_count=0; if (rcf_count>50) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "Probable source loop in configuration files"); + { + SNDDBG(("Probable source loop in configuration files\n")); return (-1); - } - - if (!(fp=open_file(name, 1, OF_VERBOSE))) + } + + if (!(rw=open_file(name))) return -1; - while (fgets(tmp, sizeof(tmp), fp)) + while (RWgets(rw, tmp, sizeof(tmp))) { line++; - w[words=0]=strtok(tmp, " \t\r\n\240"); - if (!w[0] || (*w[0]=='#')) continue; - while (w[words] && (words < (MAXWORDS-1))) - { - w[++words]=strtok(0," \t\r\n\240"); - if (w[words] && w[words][0]=='#') break; - } - if (!strcmp(w[0], "map")) continue; - if (!strcmp(w[0], "dir")) + words=0; + w[0]=strtok(tmp, " \t\240"); + if (!w[0]) continue; + + /* Originally the TiMidity++ extensions were prefixed like this */ + if (strcmp(w[0], "#extension") == 0) + { + w[0]=strtok(0, " \t\240"); + if (!w[0]) continue; + } + + if (*w[0] == '#') + continue; + + while (w[words] && *w[words] != '#' && (words < (MAXWORDS-1))) + w[++words]=strtok(0," \t\240"); + + /* + * TiMidity++ adds a number of extensions to the config file format. + * Many of them are completely irrelevant to SDL_sound, but at least + * we shouldn't choke on them. + * + * Unfortunately the documentation for these extensions is often quite + * vague, gramatically strange or completely absent. + */ + if ( + !strcmp(w[0], "comm") /* "comm" program second */ + || !strcmp(w[0], "HTTPproxy") /* "HTTPproxy" hostname:port */ + || !strcmp(w[0], "FTPproxy") /* "FTPproxy" hostname:port */ + || !strcmp(w[0], "mailaddr") /* "mailaddr" your-mail-address */ + || !strcmp(w[0], "opt") /* "opt" timidity-options */ + ) + { + /* + * + "comm" sets some kind of comment -- the documentation is too + * vague for me to understand at this time. + * + "HTTPproxy", "FTPproxy" and "mailaddr" are for reading data + * over a network, rather than from the file system. + * + "opt" specifies default options for TiMidity++. + * + * These are all quite useless for our version of TiMidity, so + * they can safely remain no-ops. + */ + } else if (!strcmp(w[0], "timeout")) /* "timeout" program second */ + { + /* + * Specifies a timeout value of the program. A number of seconds + * before TiMidity kills the note. This may be useful to implement + * later, but I don't see any urgent need for it. + */ + SNDDBG(("FIXME: Implement \"timeout\" in TiMidity config.\n")); + } else if (!strcmp(w[0], "copydrumset") /* "copydrumset" drumset */ + || !strcmp(w[0], "copybank")) /* "copybank" bank */ + { + /* + * Copies all the settings of the specified drumset or bank to + * the current drumset or bank. May be useful later, but not a + * high priority. + */ + SNDDBG(("FIXME: Implement \"%s\" in TiMidity config.\n", w[0])); + } else if (!strcmp(w[0], "undef")) /* "undef" progno */ + { + /* + * Undefines the tone "progno" of the current tone bank (or + * drum set?). Not a high priority. + */ + SNDDBG(("FIXME: Implement \"undef\" in TiMidity config.\n")); + } else if (!strcmp(w[0], "altassign")) /* "altassign" prog1 prog2 ... */ + { + /* + * Sets the alternate assign for drum set. Whatever that's + * supposed to mean. + */ + SNDDBG(("FIXME: Implement \"altassign\" in TiMidity config.\n")); + } else if (!strcmp(w[0], "soundfont") + || !strcmp(w[0], "font")) + { + /* + * I can't find any documentation for these, but I guess they're + * an alternative way of loading/unloading instruments. + * + * "soundfont" sf_file "remove" + * "soundfont" sf_file ["order=" order] ["cutoff=" cutoff] + * ["reso=" reso] ["amp=" amp] + * "font" "exclude" bank preset keynote + * "font" "order" order bank preset keynote + */ + SNDDBG(("FIXME: Implmement \"%s\" in TiMidity config.\n", w[0])); + } else if (!strcmp(w[0], "progbase")) + { + /* + * The documentation for this makes absolutely no sense to me, but + * apparently it sets some sort of base offset for tone numbers. + * Why anyone would want to do this is beyond me. + */ + SNDDBG(("FIXME: Implement \"progbase\" in TiMidity config.\n")); + } else if (!strcmp(w[0], "map")) /* "map" name set1 elem1 set2 elem2 */ + { + /* + * This extension is the one we will need to implement, as it is + * used by the "eawpats". Unfortunately I cannot find any + * documentation whatsoever for it, but it looks like it's used + * for remapping one instrument to another somehow. + */ + SNDDBG(("FIXME: Implement \"map\" in TiMidity config.\n")); + } + + /* Standard TiMidity config */ + + else if (!strcmp(w[0], "dir")) { if (words < 2) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "%s: line %d: No directory given\n", name, line); - close_file(fp); - return -2; - } + { + SNDDBG(("%s: line %d: No directory given\n", name, line)); + goto fail; + } for (i=1; icmsg(CMSG_ERROR, VERB_NORMAL, - "%s: line %d: No file name given\n", name, line); - close_file(fp); - return -2; - } - for (i=1; icmsg(CMSG_ERROR, VERB_NORMAL, - "%s: line %d: Must specify exactly one patch name\n", - name, line); - close_file(fp); - return -2; - } - strncpy(def_instr_name, w[1], 255); - def_instr_name[255]='\0'; - } + add_to_pathlist(w[i]); + } + else if (!strcmp(w[0], "source")) + { + if (words < 2) + { + SNDDBG(("%s: line %d: No file name given\n", name, line)); + goto fail; + } + for (i=1; icmsg(CMSG_ERROR, VERB_NORMAL, - "%s: line %d: No drum set number given\n", - name, line); - close_file(fp); - return -2; - } - i=atoi(w[1]); - if (i<0 || i>127) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "%s: line %d: Drum set must be between 0 and 127\n", - name, line); - close_file(fp); - return -2; - } - if (!drumset[i]) - { - drumset[i]=safe_malloc(sizeof(ToneBank)); - memset(drumset[i], 0, sizeof(ToneBank)); - } - bank=drumset[i]; - } + { + if (words < 2) + { + SNDDBG(("%s: line %d: No drum set number given\n", name, line)); + goto fail; + } + i=atoi(w[1]); + if (i<0 || i>(MAXBANK-1)) + { + SNDDBG(("%s: line %d: Drum set must be between 0 and %d\n", + name, line, MAXBANK-1)); + goto fail; + } + if (!master_drumset[i]) + { + master_drumset[i] = safe_malloc(sizeof(ToneBank)); + memset(master_drumset[i], 0, sizeof(ToneBank)); + master_drumset[i]->tone = safe_malloc(128 * sizeof(ToneBankElement)); + memset(master_drumset[i]->tone, 0, 128 * sizeof(ToneBankElement)); + } + bank=master_drumset[i]; + } else if (!strcmp(w[0], "bank")) - { - if (words < 2) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "%s: line %d: No bank number given\n", - name, line); - close_file(fp); - return -2; - } - i=atoi(w[1]); - if (i<0 || i>127) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "%s: line %d: Tone bank must be between 0 and 127\n", - name, line); - close_file(fp); - return -2; - } - if (!tonebank[i]) - { - tonebank[i]=safe_malloc(sizeof(ToneBank)); - memset(tonebank[i], 0, sizeof(ToneBank)); - } - bank=tonebank[i]; - } - else { - if ((words < 2) || (*w[0] < '0' || *w[0] > '9')) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "%s: line %d: syntax error\n", name, line); - continue; - } - i=atoi(w[0]); - if (i<0 || i>127) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "%s: line %d: Program must be between 0 and 127\n", - name, line); - close_file(fp); - return -2; - } - if (!bank) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "%s: line %d: Must specify tone bank or drum set " - "before assignment\n", - name, line); - close_file(fp); - return -2; - } - if (bank->tone[i].name) - free(bank->tone[i].name); - strcpy((bank->tone[i].name=safe_malloc(strlen(w[1])+1)),w[1]); - bank->tone[i].note=bank->tone[i].amp=bank->tone[i].pan= - bank->tone[i].strip_loop=bank->tone[i].strip_envelope= + { + if (words < 2) + { + SNDDBG(("%s: line %d: No bank number given\n", name, line)); + goto fail; + } + i=atoi(w[1]); + if (i<0 || i>(MAXBANK-1)) + { + SNDDBG(("%s: line %d: Tone bank must be between 0 and %d\n", + name, line, MAXBANK-1)); + goto fail; + } + if (!master_tonebank[i]) + { + master_tonebank[i] = safe_malloc(sizeof(ToneBank)); + memset(master_tonebank[i], 0, sizeof(ToneBank)); + master_tonebank[i]->tone = safe_malloc(128 * sizeof(ToneBankElement)); + memset(master_tonebank[i]->tone, 0, 128 * sizeof(ToneBankElement)); + } + bank=master_tonebank[i]; + } + else + { + if ((words < 2) || (*w[0] < '0' || *w[0] > '9')) + { + SNDDBG(("%s: line %d: syntax error\n", name, line)); + continue; + } + i=atoi(w[0]); + if (i<0 || i>127) + { + SNDDBG(("%s: line %d: Program must be between 0 and 127\n", + name, line)); + goto fail; + } + if (!bank) + { + SNDDBG(("%s: line %d: Must specify tone bank or drum set before assignment\n", + name, line)); + goto fail; + } + if (bank->tone[i].name) + free(bank->tone[i].name); + strcpy((bank->tone[i].name=safe_malloc(strlen(w[1])+1)),w[1]); + bank->tone[i].note=bank->tone[i].amp=bank->tone[i].pan= + bank->tone[i].strip_loop=bank->tone[i].strip_envelope= bank->tone[i].strip_tail=-1; - for (j=2; j '9')) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "%s: line %d: amplification must be between " - "0 and %d\n", name, line, MAX_AMPLIFICATION); - close_file(fp); - return -2; - } - bank->tone[i].amp=k; - } - else if (!strcmp(w[j], "note")) - { - k=atoi(cp); - if ((k<0 || k>127) || (*cp < '0' || *cp > '9')) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "%s: line %d: note must be between 0 and 127\n", - name, line); - close_file(fp); - return -2; - } - bank->tone[i].note=k; - } - else if (!strcmp(w[j], "pan")) - { - if (!strcmp(cp, "center")) - k=64; - else if (!strcmp(cp, "left")) - k=0; - else if (!strcmp(cp, "right")) - k=127; - else - k=((atoi(cp)+100) * 100) / 157; - if ((k<0 || k>127) || - (k==0 && *cp!='-' && (*cp < '0' || *cp > '9'))) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "%s: line %d: panning must be left, right, " - "center, or between -100 and 100\n", - name, line); - close_file(fp); - return -2; - } - bank->tone[i].pan=k; - } - else if (!strcmp(w[j], "keep")) - { - if (!strcmp(cp, "env")) - bank->tone[i].strip_envelope=0; - else if (!strcmp(cp, "loop")) - bank->tone[i].strip_loop=0; - else - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "%s: line %d: keep must be env or loop\n", name, line); - close_file(fp); - return -2; - } - } - else if (!strcmp(w[j], "strip")) - { - if (!strcmp(cp, "env")) - bank->tone[i].strip_envelope=1; - else if (!strcmp(cp, "loop")) - bank->tone[i].strip_loop=1; - else if (!strcmp(cp, "tail")) - bank->tone[i].strip_tail=1; - else - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, - "%s: line %d: strip must be env, loop, or tail\n", - name, line); - close_file(fp); - return -2; - } - } - else - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: line %d: bad patch option %s\n", - name, line, w[j]); - close_file(fp); - return -2; - } - } - } - } - if (ferror(fp)) - { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Can't read from %s\n", name); - close_file(fp); - return -2; - } - close_file(fp); + for (j=2; j '9')) + { + SNDDBG(("%s: line %d: amplification must be between 0 and %d\n", + name, line, MAX_AMPLIFICATION)); + goto fail; + } + bank->tone[i].amp=k; + } + else if (!strcmp(w[j], "note")) + { + k=atoi(cp); + if ((k<0 || k>127) || (*cp < '0' || *cp > '9')) + { + SNDDBG(("%s: line %d: note must be between 0 and 127\n", + name, line)); + goto fail; + } + bank->tone[i].note=k; + } + else if (!strcmp(w[j], "pan")) + { + if (!strcmp(cp, "center")) + k=64; + else if (!strcmp(cp, "left")) + k=0; + else if (!strcmp(cp, "right")) + k=127; + else + k=((atoi(cp)+100) * 100) / 157; + if ((k<0 || k>127) || (k==0 && *cp!='-' && (*cp < '0' || *cp > '9'))) + { + SNDDBG(("%s: line %d: panning must be left, right, center, or between -100 and 100\n", + name, line)); + goto fail; + } + bank->tone[i].pan=k; + } + else if (!strcmp(w[j], "keep")) + { + if (!strcmp(cp, "env")) + bank->tone[i].strip_envelope=0; + else if (!strcmp(cp, "loop")) + bank->tone[i].strip_loop=0; + else + { + SNDDBG(("%s: line %d: keep must be env or loop\n", name, line)); + goto fail; + } + } + else if (!strcmp(w[j], "strip")) + { + if (!strcmp(cp, "env")) + bank->tone[i].strip_envelope=1; + else if (!strcmp(cp, "loop")) + bank->tone[i].strip_loop=1; + else if (!strcmp(cp, "tail")) + bank->tone[i].strip_tail=1; + else + { + SNDDBG(("%s: line %d: strip must be env, loop, or tail\n", + name, line)); + goto fail; + } + } + else + { + SNDDBG(("%s: line %d: bad patch option %s\n", name, line, w[j])); + goto fail; + } + } + } + } + SDL_RWclose(rw); + return 0; +fail: + SDL_RWclose(rw); + return -2; +} + +int Timidity_Init_NoConfig() +{ + /* Allocate memory for the standard tonebank and drumset */ + master_tonebank[0] = safe_malloc(sizeof(ToneBank)); + memset(master_tonebank[0], 0, sizeof(ToneBank)); + master_tonebank[0]->tone = safe_malloc(128 * sizeof(ToneBankElement)); + memset(master_tonebank[0]->tone, 0, 128 * sizeof(ToneBankElement)); + + master_drumset[0] = safe_malloc(sizeof(ToneBank)); + memset(master_drumset[0], 0, sizeof(ToneBank)); + master_drumset[0]->tone = safe_malloc(128 * sizeof(ToneBankElement)); + memset(master_drumset[0]->tone, 0, 128 * sizeof(ToneBankElement)); + return 0; } -int Timidity_Init(int rate, int format, int channels, int samples) +int Timidity_Init() { - const char *env = getenv("TIMIDITY_CFG"); + const char *env = SDL_getenv("TIMIDITY_CFG"); + + /* !!! FIXME: This may be ugly, but slightly less so than requiring the + * default search path to have only one element. I think. + * + * We only need to include the likely locations for the config + * file itself since that file should contain any other directory + * that needs to be added to the search path. + */ +#ifdef DEFAULT_PATH + add_to_pathlist(DEFAULT_PATH); +#endif +#ifdef DEFAULT_PATH1 + add_to_pathlist(DEFAULT_PATH1); +#endif +#ifdef DEFAULT_PATH2 + add_to_pathlist(DEFAULT_PATH2); +#endif +#ifdef DEFAULT_PATH3 + add_to_pathlist(DEFAULT_PATH3); +#endif + + Timidity_Init_NoConfig(); + if (!env || read_config_file(env)<0) { if (read_config_file(CONFIG_FILE)<0) { if (read_config_file(CONFIG_FILE_ETC)<0) { @@ -308,74 +449,184 @@ } } } - - if (channels < 1 || channels == 3 || channels == 5 || channels > 6) return(-1); - - num_ochannels = channels; - - /* Set play mode parameters */ - play_mode->rate = rate; - play_mode->encoding = 0; - if ( (format&0xFF) == 16 ) { - play_mode->encoding |= PE_16BIT; - } - if ( (format&0x8000) ) { - play_mode->encoding |= PE_SIGNED; - } - if ( channels == 1 ) { - play_mode->encoding |= PE_MONO; - } - switch (format) { - case AUDIO_S8: - s32tobuf = s32tos8; - break; - case AUDIO_U8: - s32tobuf = s32tou8; - break; - case AUDIO_S16LSB: - s32tobuf = s32tos16l; - break; - case AUDIO_S16MSB: - s32tobuf = s32tos16b; - break; - case AUDIO_U16LSB: - s32tobuf = s32tou16l; - break; - case AUDIO_U16MSB: - s32tobuf = s32tou16b; - break; - default: - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Unsupported audio format"); - return(-1); - } - AUDIO_BUFFER_SIZE = samples; - - /* Allocate memory for mixing (WARNING: Memory leak!) */ - resample_buffer = safe_malloc(AUDIO_BUFFER_SIZE*sizeof(resample_t)+100); - common_buffer = safe_malloc(AUDIO_BUFFER_SIZE*num_ochannels*sizeof(int32)); - - init_tables(); - - if (ctl->open(0, 0)) { - ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Couldn't open %s\n", ctl->id_name); - return(-1); - } - - if (!control_ratio) { - control_ratio = play_mode->rate / CONTROLS_PER_SECOND; - if(control_ratio<1) - control_ratio=1; - else if (control_ratio > MAX_CONTROL_RATIO) - control_ratio=MAX_CONTROL_RATIO; - } + return 0; +} + +MidiSong *Timidity_LoadSong(SDL_RWops *rw, SDL_AudioSpec *audio) +{ + MidiSong *song; + int i; + + if (rw == NULL) + return NULL; + + /* Allocate memory for the song */ + song = (MidiSong *)safe_malloc(sizeof(*song)); + memset(song, 0, sizeof(*song)); + + for (i = 0; i < MAXBANK; i++) + { + if (master_tonebank[i]) + { + song->tonebank[i] = safe_malloc(sizeof(ToneBank)); + memset(song->tonebank[i], 0, sizeof(ToneBank)); + song->tonebank[i]->tone = master_tonebank[i]->tone; + } + if (master_drumset[i]) + { + song->drumset[i] = safe_malloc(sizeof(ToneBank)); + memset(song->drumset[i], 0, sizeof(ToneBank)); + song->drumset[i]->tone = master_drumset[i]->tone; + } + } + + song->amplification = DEFAULT_AMPLIFICATION; + song->voices = DEFAULT_VOICES; + song->drumchannels = DEFAULT_DRUMCHANNELS; + + song->rw = rw; + + song->rate = audio->freq; + song->encoding = 0; + if ((audio->format & 0xFF) == 16) + song->encoding |= PE_16BIT; + else if ((audio->format & 0xFF) == 32) + song->encoding |= PE_32BIT; + if (audio->format & 0x8000) + song->encoding |= PE_SIGNED; + if (audio->channels == 1) + song->encoding |= PE_MONO; + else if (audio->channels > 2) { + SDL_SetError("Surround sound not supported"); + return NULL; + } + switch (audio->format) { + case AUDIO_S8: + song->write = s32tos8; + break; + case AUDIO_U8: + song->write = s32tou8; + break; + case AUDIO_S16LSB: + song->write = s32tos16l; + break; + case AUDIO_S16MSB: + song->write = s32tos16b; + break; + case AUDIO_U16LSB: + song->write = s32tou16l; + break; + case AUDIO_U16MSB: + song->write = s32tou16b; + break; + case AUDIO_S32LSB: + song->write = s32tos32l; + break; + case AUDIO_S32MSB: + song->write = s32tos32b; + break; + case AUDIO_F32SYS: + song->write = s32tof32; + break; + default: + SDL_SetError("Unsupported audio format"); + return NULL; + } + + song->buffer_size = audio->samples; + song->resample_buffer = safe_malloc(audio->samples * sizeof(sample_t)); + song->common_buffer = safe_malloc(audio->samples * 2 * sizeof(Sint32)); + + song->control_ratio = audio->freq / CONTROLS_PER_SECOND; + if (song->control_ratio < 1) + song->control_ratio = 1; + else if (song->control_ratio > MAX_CONTROL_RATIO) + song->control_ratio = MAX_CONTROL_RATIO; + + song->lost_notes = 0; + song->cut_notes = 0; + + song->events = read_midi_file(song, &(song->groomed_event_count), + &song->samples); + + /* The RWops can safely be closed at this point, but let's make that the + * responsibility of the caller. + */ + + /* Make sure everything is okay */ + if (!song->events) { + free(song); + return(NULL); + } + + song->default_instrument = 0; + song->default_program = DEFAULT_PROGRAM; + if (*def_instr_name) - set_default_instrument(def_instr_name); - return(0); + set_default_instrument(song, def_instr_name); + + load_missing_instruments(song); + + return(song); } -char timidity_error[TIMIDITY_ERROR_SIZE] = ""; -const char *Timidity_Error(void) +void Timidity_FreeSong(MidiSong *song) { - return(timidity_error); + int i; + + free_instruments(song); + + for (i = 0; i < 128; i++) + { + if (song->tonebank[i]) + free(song->tonebank[i]); + if (song->drumset[i]) + free(song->drumset[i]); + } + + free(song->common_buffer); + free(song->resample_buffer); + free(song->events); + free(song); } +void Timidity_Exit(void) +{ + int i, j; + + for (i = 0; i < MAXBANK; i++) + { + if (master_tonebank[i]) + { + ToneBankElement *e = master_tonebank[i]->tone; + if (e != NULL) + { + for (j = 0; j < 128; j++) + { + if (e[j].name != NULL) + free(e[j].name); + } + free(e); + } + free(master_tonebank[i]); + master_tonebank[i] = NULL; + } + if (master_drumset[i]) + { + ToneBankElement *e = master_drumset[i]->tone; + if (e != NULL) + { + for (j = 0; j < 128; j++) + { + if (e[j].name != NULL) + free(e[j].name); + } + free(e); + } + free(master_drumset[i]); + master_drumset[i] = NULL; + } + } + + free_pathlist(); +} diff --git a/timidity/timidity.h b/timidity/timidity.h index ec1dbe8..0a9c57d 100644 --- a/timidity/timidity.h +++ b/timidity/timidity.h @@ -1,20 +1,163 @@ /* + TiMidity -- Experimental MIDI to WAVE converter Copyright (C) 1995 Tuukka Toivonen This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License, available in COPYING. - */ +*/ -typedef struct _MidiSong MidiSong; +#ifndef TIMIDITY_H +#define TIMIDITY_H +#ifdef __cplusplus +extern "C" { +#endif -extern int Timidity_Init(int rate, int format, int channels, int samples); -extern const char *Timidity_Error(void); -extern void Timidity_SetVolume(int volume); -extern int Timidity_PlaySome(void *stream, int samples); -extern MidiSong *Timidity_LoadSong_RW(SDL_RWops *rw, int freerw); +typedef Sint16 sample_t; +typedef Sint32 final_volume_t; + +#define VIBRATO_SAMPLE_INCREMENTS 32 + +/* Maximum polyphony. */ +/* #define MAX_VOICES 48 */ +#define MAX_VOICES 256 +#define MAXCHAN 16 +/* #define MAXCHAN 64 */ +#define MAXBANK 128 + +typedef struct { + Sint32 + loop_start, loop_end, data_length, + sample_rate, low_freq, high_freq, root_freq; + Sint32 + envelope_rate[6], envelope_offset[6]; + float + volume; + sample_t *data; + Sint32 + tremolo_sweep_increment, tremolo_phase_increment, + vibrato_sweep_increment, vibrato_control_ratio; + Uint8 + tremolo_depth, vibrato_depth, + modes; + Sint8 + panning, note_to_use; +} Sample; + +typedef struct { + int + bank, program, volume, sustain, panning, pitchbend, expression, + mono, /* one note only on this channel -- not implemented yet */ + pitchsens; + /* chorus, reverb... Coming soon to a 300-MHz, eight-way superscalar + processor near you */ + float + pitchfactor; /* precomputed pitch bend factor to save some fdiv's */ +} Channel; + +typedef struct { + Uint8 + status, channel, note, velocity; + Sample *sample; + Sint32 + orig_frequency, frequency, + sample_offset, sample_increment, + envelope_volume, envelope_target, envelope_increment, + tremolo_sweep, tremolo_sweep_position, + tremolo_phase, tremolo_phase_increment, + vibrato_sweep, vibrato_sweep_position; + + final_volume_t left_mix, right_mix; + + float + left_amp, right_amp, tremolo_volume; + Sint32 + vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS]; + int + vibrato_phase, vibrato_control_ratio, vibrato_control_counter, + envelope_stage, control_counter, panning, panned; + +} Voice; + +typedef struct { + int samples; + Sample *sample; +} Instrument; + +/* Shared data */ +typedef struct { + char *name; + int note, amp, pan, strip_loop, strip_envelope, strip_tail; +} ToneBankElement; + +typedef struct { + ToneBankElement *tone; + Instrument *instrument[128]; +} ToneBank; + +typedef struct { + Sint32 time; + Uint8 channel, type, a, b; +} MidiEvent; + +typedef struct { + MidiEvent event; + void *next; +} MidiEventList; + +typedef struct { + int playing; + SDL_RWops *rw; + Sint32 rate; + Sint32 encoding; + float master_volume; + Sint32 amplification; + ToneBank *tonebank[MAXBANK]; + ToneBank *drumset[MAXBANK]; + Instrument *default_instrument; + int default_program; + void (*write)(void *dp, Sint32 *lp, Sint32 c); + int buffer_size; + sample_t *resample_buffer; + Sint32 *common_buffer; + Sint32 *buffer_pointer; + /* These would both fit into 32 bits, but they are often added in + large multiples, so it's simpler to have two roomy ints */ + /* samples per MIDI delta-t */ + Sint32 sample_increment; + Sint32 sample_correction; + Channel channel[MAXCHAN]; + Voice voice[MAX_VOICES]; + int voices; + Sint32 drumchannels; + Sint32 buffered_count; + Sint32 control_ratio; + Sint32 lost_notes; + Sint32 cut_notes; + Sint32 samples; + MidiEvent *events; + MidiEvent *current_event; + MidiEventList *evlist; + Sint32 current_sample; + Sint32 event_count; + Sint32 at; + Sint32 groomed_event_count; +} MidiSong; + +/* Some of these are not defined in timidity.c but are here for convenience */ + +extern int Timidity_Init(void); +extern int Timidity_Init_NoConfig(void); +extern void Timidity_SetVolume(MidiSong *song, int volume); +extern int Timidity_PlaySome(MidiSong *song, void *stream, Sint32 len); +extern MidiSong *Timidity_LoadSong(SDL_RWops *rw, SDL_AudioSpec *audio); extern void Timidity_Start(MidiSong *song); -extern int Timidity_Active(void); -extern void Timidity_Stop(void); +extern void Timidity_Seek(MidiSong *song, Uint32 ms); +extern Uint32 Timidity_GetSongLength(MidiSong *song); /* returns millseconds */ extern void Timidity_FreeSong(MidiSong *song); -extern void Timidity_Close(void); +extern void Timidity_Exit(void); + +#ifdef __cplusplus +} +#endif +#endif /* TIMIDITY_H */ diff --git a/version.rc b/version.rc index d624e96..1ddf32d 100644 --- a/version.rc +++ b/version.rc @@ -9,8 +9,8 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,0,1,0 - PRODUCTVERSION 2,0,1,0 + FILEVERSION 2,0,2,0 + PRODUCTVERSION 2,0,2,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS 0x40004L @@ -23,12 +23,12 @@ BEGIN VALUE "CompanyName", "\0" VALUE "FileDescription", "SDL_mixer\0" - VALUE "FileVersion", "2, 0, 1, 0\0" + VALUE "FileVersion", "2, 0, 2, 0\0" VALUE "InternalName", "SDL_mixer\0" - VALUE "LegalCopyright", "Copyright © 2016 Sam Lantinga\0" + VALUE "LegalCopyright", "Copyright © 2017 Sam Lantinga\0" VALUE "OriginalFilename", "SDL_mixer.dll\0" VALUE "ProductName", "Simple DirectMedia Layer\0" - VALUE "ProductVersion", "2, 0, 1, 0\0" + VALUE "ProductVersion", "2, 0, 2, 0\0" END END BLOCK "VarFileInfo" diff --git a/wavestream.c b/wavestream.c deleted file mode 100644 index 8dc1683..0000000 --- a/wavestream.c +++ /dev/null @@ -1,628 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* $Id$ */ - -/* This file supports streaming WAV files, without volume adjustment */ - -#include -#include - -#include "SDL_audio.h" -#include "SDL_mutex.h" -#include "SDL_rwops.h" -#include "SDL_endian.h" - -#include "SDL_mixer.h" -#include "wavestream.h" - -/* - Taken with permission from SDL_wave.h, part of the SDL library, - available at: http://www.libsdl.org/ - and placed under the same license as this mixer library. -*/ - -/* WAVE files are little-endian */ - -/*******************************************/ -/* Define values for Microsoft WAVE format */ -/*******************************************/ -#define RIFF 0x46464952 /* "RIFF" */ -#define WAVE 0x45564157 /* "WAVE" */ -#define FMT 0x20746D66 /* "fmt " */ -#define DATA 0x61746164 /* "data" */ -#define SMPL 0x6c706d73 /* "smpl" */ -#define PCM_CODE 1 -#define ADPCM_CODE 2 -#define WAVE_MONO 1 -#define WAVE_STEREO 2 - -typedef struct { -/* Not saved in the chunk we read: - Uint32 chunkID; - Uint32 chunkLen; -*/ - Uint16 encoding; - Uint16 channels; /* 1 = mono, 2 = stereo */ - Uint32 frequency; /* One of 11025, 22050, or 44100 Hz */ - Uint32 byterate; /* Average bytes per second */ - Uint16 blockalign; /* Bytes per sample block */ - Uint16 bitspersample; /* One of 8, 12, 16, or 4 for ADPCM */ -} WaveFMT; - -typedef struct { - Uint32 identifier; - Uint32 type; - Uint32 start; - Uint32 end; - Uint32 fraction; - Uint32 play_count; -} SampleLoop; - -typedef struct { -/* Not saved in the chunk we read: - Uint32 chunkID; - Uint32 chunkLen; -*/ - Uint32 manufacturer; - Uint32 product; - Uint32 sample_period; - Uint32 MIDI_unity_note; - Uint32 MIDI_pitch_fraction; - Uint32 SMTPE_format; - Uint32 SMTPE_offset; - Uint32 sample_loops; - Uint32 sampler_data; - SampleLoop loops[]; -} SamplerChunk; - -/*********************************************/ -/* Define values for AIFF (IFF audio) format */ -/*********************************************/ -#define FORM 0x4d524f46 /* "FORM" */ -#define AIFF 0x46464941 /* "AIFF" */ -#define SSND 0x444e5353 /* "SSND" */ -#define COMM 0x4d4d4f43 /* "COMM" */ - - -/* Currently we only support a single stream at a time */ -static WAVStream *music = NULL; - -/* This is the format of the audio mixer data */ -static SDL_AudioSpec mixer; -static int wavestream_volume = MIX_MAX_VOLUME; - -/* Function to load the WAV/AIFF stream */ -static SDL_bool LoadWAVStream(WAVStream *wave); -static SDL_bool LoadAIFFStream(WAVStream *wave); - -/* Initialize the WAVStream player, with the given mixer settings - This function returns 0, or -1 if there was an error. - */ -int WAVStream_Init(SDL_AudioSpec *mixerfmt) -{ - mixer = *mixerfmt; - return(0); -} - -void WAVStream_SetVolume(int volume) -{ - wavestream_volume = volume; -} - -/* Load a WAV stream from the given RWops object */ -WAVStream *WAVStream_LoadSong_RW(SDL_RWops *src, int freesrc) -{ - WAVStream *wave; - SDL_bool loaded = SDL_FALSE; - - if (!mixer.format) { - Mix_SetError("WAV music output not started"); - return(NULL); - } - - wave = (WAVStream *)SDL_malloc(sizeof *wave); - if (wave) { - Uint32 magic; - - SDL_zerop(wave); - wave->src = src; - wave->freesrc = freesrc; - - magic = SDL_ReadLE32(src); - if (magic == RIFF || magic == WAVE) { - loaded = LoadWAVStream(wave); - } else if (magic == FORM) { - loaded = LoadAIFFStream(wave); - } else { - Mix_SetError("Unknown WAVE format"); - } - if (!loaded) { - WAVStream_FreeSong(wave); - return(NULL); - } - SDL_BuildAudioCVT(&wave->cvt, - wave->spec.format, wave->spec.channels, wave->spec.freq, - mixer.format, mixer.channels, mixer.freq); - } else { - SDL_OutOfMemory(); - return(NULL); - } - return(wave); -} - -/* Start playback of a given WAV stream */ -void WAVStream_Start(WAVStream *wave) -{ - int i; - for (i = 0; i < wave->numloops; ++i) { - WAVLoopPoint *loop = &wave->loops[i]; - loop->active = SDL_TRUE; - loop->current_play_count = loop->initial_play_count; - } - SDL_RWseek(wave->src, wave->start, RW_SEEK_SET); - music = wave; -} - -/* Play some of a stream previously started with WAVStream_Start() */ -static int PlaySome(Uint8 *stream, int len) -{ - Sint64 pos, stop; - WAVLoopPoint *loop; - Sint64 loop_start; - Sint64 loop_stop; - int i; - int consumed; - - pos = SDL_RWtell(music->src); - stop = music->stop; - loop = NULL; - for (i = 0; i < music->numloops; ++i) { - loop = &music->loops[i]; - if (loop->active) { - const int bytes_per_sample = (SDL_AUDIO_BITSIZE(music->spec.format) / 8) * music->spec.channels; - loop_start = music->start + loop->start * bytes_per_sample; - loop_stop = music->start + (loop->stop + 1) * bytes_per_sample; - if (pos >= loop_start && pos < loop_stop) - { - stop = loop_stop; - break; - } - } - loop = NULL; - } - - if (music->cvt.needed) { - int original_len; - - original_len = (int)((double)len/music->cvt.len_ratio); - if (music->cvt.len != original_len) { - int worksize; - if (music->cvt.buf != NULL) { - SDL_free(music->cvt.buf); - } - worksize = original_len*music->cvt.len_mult; - music->cvt.buf=(Uint8 *)SDL_malloc(worksize); - if (music->cvt.buf == NULL) { - return 0; - } - music->cvt.len = original_len; - } - if ((stop - pos) < original_len) { - original_len = (int)(stop - pos); - } - original_len = SDL_RWread(music->src, music->cvt.buf, 1, original_len); - /* At least at the time of writing, SDL_ConvertAudio() - does byte-order swapping starting at the end of the - buffer. Thus, if we are reading 16-bit samples, we - had better make damn sure that we get an even - number of bytes, or we'll get garbage. - */ - if ((music->cvt.src_format & 0x0010) && (original_len & 1)) { - original_len--; - } - music->cvt.len = original_len; - SDL_ConvertAudio(&music->cvt); - SDL_MixAudio(stream, music->cvt.buf, music->cvt.len_cvt, wavestream_volume); - consumed = music->cvt.len_cvt; - } else { - Uint8 *data; - if ((stop - pos) < len) { - len = (int)(stop - pos); - } - data = SDL_stack_alloc(Uint8, len); - if (data) { - len = SDL_RWread(music->src, data, 1, len); - SDL_MixAudio(stream, data, len, wavestream_volume); - SDL_stack_free(data); - } - consumed = len; - } - - if (loop && SDL_RWtell(music->src) >= stop) { - if (loop->current_play_count == 1) { - loop->active = SDL_FALSE; - } else { - if (loop->current_play_count > 0) { - --loop->current_play_count; - } - SDL_RWseek(music->src, loop_start, RW_SEEK_SET); - } - } - return consumed; -} - -int WAVStream_PlaySome(Uint8 *stream, int len) -{ - if (!music) - return 0; - - while ((SDL_RWtell(music->src) < music->stop) && (len > 0)) { - int consumed = PlaySome(stream, len); - if (!consumed) - break; - - stream += consumed; - len -= consumed; - } - return len; -} - -/* Stop playback of a stream previously started with WAVStream_Start() */ -void WAVStream_Stop(void) -{ - music = NULL; -} - -/* Close the given WAV stream */ -void WAVStream_FreeSong(WAVStream *wave) -{ - if (wave) { - /* Clean up associated data */ - if (wave->loops) { - SDL_free(wave->loops); - } - if (wave->cvt.buf) { - SDL_free(wave->cvt.buf); - } - if (wave->freesrc) { - SDL_RWclose(wave->src); - } - SDL_free(wave); - } -} - -/* Return non-zero if a stream is currently playing */ -int WAVStream_Active(void) -{ - int active; - - active = 0; - if (music && (SDL_RWtell(music->src) < music->stop)) { - active = 1; - } - return(active); -} - -static SDL_bool ParseFMT(WAVStream *wave, Uint32 chunk_length) -{ - SDL_RWops *src = wave->src; - SDL_AudioSpec *spec = &wave->spec; - WaveFMT *format; - Uint8 *data; - SDL_bool loaded = SDL_FALSE; - - if (chunk_length < sizeof(*format)) { - Mix_SetError("Wave format chunk too small"); - return SDL_FALSE; - } - - data = (Uint8 *)SDL_malloc(chunk_length); - if (!data) { - Mix_SetError("Out of memory"); - return SDL_FALSE; - } - if (!SDL_RWread(wave->src, data, chunk_length, 1)) { - Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length); - return SDL_FALSE; - } - format = (WaveFMT *)data; - - /* Decode the audio data format */ - switch (SDL_SwapLE16(format->encoding)) { - case PCM_CODE: - /* We can understand this */ - break; - default: - Mix_SetError("Unknown WAVE data format"); - goto done; - } - spec->freq = SDL_SwapLE32(format->frequency); - switch (SDL_SwapLE16(format->bitspersample)) { - case 8: - spec->format = AUDIO_U8; - break; - case 16: - spec->format = AUDIO_S16; - break; - default: - Mix_SetError("Unknown PCM data format"); - goto done; - } - spec->channels = (Uint8) SDL_SwapLE16(format->channels); - spec->samples = 4096; /* Good default buffer size */ - - loaded = SDL_TRUE; - -done: - SDL_free(data); - return loaded; -} - -static SDL_bool ParseDATA(WAVStream *wave, Uint32 chunk_length) -{ - wave->start = SDL_RWtell(wave->src); - wave->stop = wave->start + chunk_length; - SDL_RWseek(wave->src, chunk_length, RW_SEEK_CUR); - return SDL_TRUE; -} - -static SDL_bool AddLoopPoint(WAVStream *wave, Uint32 play_count, Uint32 start, Uint32 stop) -{ - WAVLoopPoint *loop; - WAVLoopPoint *loops = SDL_realloc(wave->loops, (wave->numloops + 1)*sizeof(*wave->loops)); - if (!loops) { - Mix_SetError("Out of memory"); - return SDL_FALSE; - } - - loop = &loops[ wave->numloops ]; - loop->start = start; - loop->stop = stop; - loop->initial_play_count = play_count; - loop->current_play_count = play_count; - - wave->loops = loops; - ++wave->numloops; - return SDL_TRUE; -} - -static SDL_bool ParseSMPL(WAVStream *wave, Uint32 chunk_length) -{ - SamplerChunk *chunk; - Uint8 *data; - int i; - SDL_bool loaded = SDL_FALSE; - - data = (Uint8 *)SDL_malloc(chunk_length); - if (!data) { - Mix_SetError("Out of memory"); - return SDL_FALSE; - } - if (!SDL_RWread(wave->src, data, chunk_length, 1)) { - Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length); - return SDL_FALSE; - } - chunk = (SamplerChunk *)data; - - for (i = 0; i < SDL_SwapLE32(chunk->sample_loops); ++i) { - const Uint32 LOOP_TYPE_FORWARD = 0; - Uint32 loop_type = SDL_SwapLE32(chunk->loops[i].type); - if (loop_type == LOOP_TYPE_FORWARD) { - AddLoopPoint(wave, SDL_SwapLE32(chunk->loops[i].play_count), SDL_SwapLE32(chunk->loops[i].start), SDL_SwapLE32(chunk->loops[i].end)); - } - } - - loaded = SDL_TRUE; - -done: - SDL_free(data); - return loaded; -} - -static SDL_bool LoadWAVStream(WAVStream *wave) -{ - SDL_RWops *src = wave->src; - Uint32 chunk_type; - Uint32 chunk_length; - SDL_bool found_FMT = SDL_FALSE; - SDL_bool found_DATA = SDL_FALSE; - - /* WAV magic header */ - Uint32 wavelen; - Uint32 WAVEmagic; - - /* Check the magic header */ - wavelen = SDL_ReadLE32(src); - WAVEmagic = SDL_ReadLE32(src); - - /* Read the chunks */ - for (; ;) { - chunk_type = SDL_ReadLE32(src); - chunk_length = SDL_ReadLE32(src); - - if (chunk_length == 0) - break; - - switch (chunk_type) - { - case FMT: - found_FMT = SDL_TRUE; - if (!ParseFMT(wave, chunk_length)) - return SDL_FALSE; - break; - case DATA: - found_DATA = SDL_TRUE; - if (!ParseDATA(wave, chunk_length)) - return SDL_FALSE; - break; - case SMPL: - if (!ParseSMPL(wave, chunk_length)) - return SDL_FALSE; - break; - default: - SDL_RWseek(src, chunk_length, RW_SEEK_CUR); - break; - } - } - - if (!found_FMT) { - Mix_SetError("Bad WAV file (no FMT chunk)"); - return SDL_FALSE; - } - - if (!found_DATA) { - Mix_SetError("Bad WAV file (no DATA chunk)"); - return SDL_FALSE; - } - - return SDL_TRUE; -} - -/* I couldn't get SANE_to_double() to work, so I stole this from libsndfile. - * I don't pretend to fully understand it. - */ - -static Uint32 SANE_to_Uint32 (Uint8 *sanebuf) -{ - /* Negative number? */ - if (sanebuf[0] & 0x80) - return 0; - - /* Less than 1? */ - if (sanebuf[0] <= 0x3F) - return 1; - - /* Way too big? */ - if (sanebuf[0] > 0x40) - return 0x4000000; - - /* Still too big? */ - if (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C) - return 800000000; - - return ((sanebuf[2] << 23) | (sanebuf[3] << 15) | (sanebuf[4] << 7) | - (sanebuf[5] >> 1)) >> (29 - sanebuf[1]); -} - -static SDL_bool LoadAIFFStream(WAVStream *wave) -{ - SDL_RWops *src = wave->src; - SDL_AudioSpec *spec = &wave->spec; - SDL_bool found_SSND = SDL_FALSE; - SDL_bool found_COMM = SDL_FALSE; - - Uint32 chunk_type; - Uint32 chunk_length; - Sint64 next_chunk; - - /* AIFF magic header */ - Uint32 AIFFmagic; - /* SSND chunk */ - Uint32 offset; - Uint32 blocksize; - /* COMM format chunk */ - Uint16 channels = 0; - Uint32 numsamples = 0; - Uint16 samplesize = 0; - Uint8 sane_freq[10]; - Uint32 frequency = 0; - - /* Check the magic header */ - chunk_length = SDL_ReadBE32(src); - AIFFmagic = SDL_ReadLE32(src); - if (AIFFmagic != AIFF) { - Mix_SetError("Unrecognized file type (not AIFF)"); - return SDL_FALSE; - } - - /* From what I understand of the specification, chunks may appear in - * any order, and we should just ignore unknown ones. - * - * TODO: Better sanity-checking. E.g. what happens if the AIFF file - * contains compressed sound data? - */ - do { - chunk_type = SDL_ReadLE32(src); - chunk_length = SDL_ReadBE32(src); - next_chunk = SDL_RWtell(src) + chunk_length; - - /* Paranoia to avoid infinite loops */ - if (chunk_length == 0) - break; - - switch (chunk_type) { - case SSND: - found_SSND = SDL_TRUE; - offset = SDL_ReadBE32(src); - blocksize = SDL_ReadBE32(src); - wave->start = SDL_RWtell(src) + offset; - break; - - case COMM: - found_COMM = SDL_TRUE; - - /* Read the audio data format chunk */ - channels = SDL_ReadBE16(src); - numsamples = SDL_ReadBE32(src); - samplesize = SDL_ReadBE16(src); - SDL_RWread(src, sane_freq, sizeof(sane_freq), 1); - frequency = SANE_to_Uint32(sane_freq); - break; - - default: - break; - } - } while ((!found_SSND || !found_COMM) - && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != -1); - - if (!found_SSND) { - Mix_SetError("Bad AIFF file (no SSND chunk)"); - return SDL_FALSE; - } - - if (!found_COMM) { - Mix_SetError("Bad AIFF file (no COMM chunk)"); - return SDL_FALSE; - } - - wave->stop = wave->start + channels * numsamples * (samplesize / 8); - - /* Decode the audio data format */ - SDL_memset(spec, 0, (sizeof *spec)); - spec->freq = frequency; - switch (samplesize) { - case 8: - spec->format = AUDIO_S8; - break; - case 16: - spec->format = AUDIO_S16MSB; - break; - default: - Mix_SetError("Unknown samplesize in data format"); - return SDL_FALSE; - } - spec->channels = (Uint8) channels; - spec->samples = 4096; /* Good default buffer size */ - - return SDL_TRUE; -} - diff --git a/wavestream.h b/wavestream.h deleted file mode 100644 index adb4dbb..0000000 --- a/wavestream.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2016 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -/* $Id$ */ - -/* This file supports streaming WAV files */ - -typedef struct { - SDL_bool active; - Uint32 start; - Uint32 stop; - Uint32 initial_play_count; - Uint32 current_play_count; -} WAVLoopPoint; - -typedef struct { - SDL_RWops *src; - SDL_bool freesrc; - SDL_AudioSpec spec; - Sint64 start; - Sint64 stop; - SDL_AudioCVT cvt; - int numloops; - WAVLoopPoint *loops; -} WAVStream; - -/* Initialize the WAVStream player, with the given mixer settings - This function returns 0, or -1 if there was an error. - */ -extern int WAVStream_Init(SDL_AudioSpec *mixer); - -/* Unimplemented */ -extern void WAVStream_SetVolume(int volume); - -/* Load a WAV stream from an SDL_RWops object */ -extern WAVStream *WAVStream_LoadSong_RW(SDL_RWops *src, int freesrc); - -/* Start playback of a given WAV stream */ -extern void WAVStream_Start(WAVStream *wave); - -/* Play some of a stream previously started with WAVStream_Start() */ -extern int WAVStream_PlaySome(Uint8 *stream, int len); - -/* Stop playback of a stream previously started with WAVStream_Start() */ -extern void WAVStream_Stop(void); - -/* Close the given WAV stream */ -extern void WAVStream_FreeSong(WAVStream *wave); - -/* Return non-zero if a stream is currently playing */ -extern int WAVStream_Active(void);