diff --git a/Android.mk b/Android.mk index 81c94b5..a5b7100 100644 --- a/Android.mk +++ b/Android.mk @@ -6,38 +6,48 @@ # 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 +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 +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 +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 +SUPPORT_OGG ?= true OGG_LIBRARY_PATH := external/libogg-1.3.1 VORBIS_LIBRARY_PATH := external/libvorbisidec-1.2.1 -LOCAL_C_INCLUDES := $(LOCAL_PATH) -LOCAL_CFLAGS := -DWAV_MUSIC +# Enable this if you want to support TiMidity +SUPPORT_TIMIDITY ?= true -LOCAL_SRC_FILES := $(notdir $(filter-out %/playmus.c %/playwave.c, $(wildcard $(LOCAL_PATH)/*.c))) +LOCAL_C_INCLUDES := $(LOCAL_PATH) +LOCAL_CFLAGS := -DWAV_MUSIC + +LOCAL_SRC_FILES := $(notdir $(filter-out %/playmus.c %/playwave.c, $(wildcard $(LOCAL_PATH)/*.c))) \ + 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)) +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 -DHAVE_SETENV -DHAVE_SINF + 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 \ @@ -89,7 +99,13 @@ 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 + 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 \ @@ -110,4 +126,6 @@ LOCAL_EXPORT_C_INCLUDES += $(LOCAL_C_INCLUDES) +LOCAL_ARM_MODE := arm + include $(BUILD_SHARED_LIBRARY) diff --git a/CHANGES.txt b/CHANGES.txt index 29398cf..1eb0834 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,13 @@ +2.0.1: +Sam Lantinga - Tue Jul 7 11:40:33 PDT 2015 + * Added support for 'smpl' format loop points in music WAV files +Sam Lantinga - Sat Aug 23 10:57:26 2014 + * Fixed floating point exception in Mix_Volume() +David Ludwig - Mon Apr 14 22:15:36 2014 + * Added support for building for Windows RT and Windows Phone +Isaac Burns - Sun Sep 15 21:50:27 PDT 2013 + * Added support for loading MP3 files as sound chunks + 2.0.0: Sam Lantinga - Sun Jun 9 14:45:30 PDT 2013 * Made libmodplug the default MOD player as it is now in the public domain diff --git a/COPYING.txt b/COPYING.txt index b92b0da..b7bd3d9 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-2013 Sam Lantinga + 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 diff --git a/Makefile.in b/Makefile.in index 1df22e5..d5e76a2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -39,7 +39,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_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 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 LT_AGE = @LT_AGE@ LT_CURRENT = @LT_CURRENT@ diff --git a/SDL2_mixer.spec b/SDL2_mixer.spec index 297fbdd..dfa45e7 100644 --- a/SDL2_mixer.spec +++ b/SDL2_mixer.spec @@ -1,5 +1,5 @@ %define name SDL2_mixer -%define version 2.0.0 +%define version 2.0.1 %define release 1 Summary: Simple DirectMedia Layer - Sample Mixer Library @@ -45,7 +45,7 @@ %files %defattr(-,root,root) -%doc README CHANGES COPYING +%doc README.txt CHANGES.txt COPYING.txt %{prefix}/lib/lib*.so.* %files devel diff --git a/SDL_mixer.h b/SDL_mixer.h index 53fac6d..71c1f5c 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-2013 Sam Lantinga + 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 @@ -40,7 +40,7 @@ */ #define SDL_MIXER_MAJOR_VERSION 2 #define SDL_MIXER_MINOR_VERSION 0 -#define SDL_MIXER_PATCHLEVEL 0 +#define SDL_MIXER_PATCHLEVEL 1 /* This macro can be used to fill a version structure with the compile-time * version of the SDL_mixer library. @@ -207,8 +207,8 @@ */ extern DECLSPEC void SDLCALL Mix_HookMusic(void (*mix_func)(void *udata, Uint8 *stream, int len), void *arg); -/* Add your own callback when the music has finished playing. - This callback is only called if the music finishes naturally. +/* 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)); diff --git a/build-scripts/config.guess b/build-scripts/config.guess index e792aac..ddb3622 100755 --- a/build-scripts/config.guess +++ b/build-scripts/config.guess @@ -1,10 +1,10 @@ #! /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 -# Free Software Foundation, Inc. - -timestamp='2009-09-18' +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +# 2011, 2012 Free Software Foundation, Inc. + +timestamp='2012-08-14' # 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 @@ -17,9 +17,7 @@ # 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., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -56,8 +54,9 @@ 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 Free Software Foundation, Inc. +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. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -144,7 +143,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or - # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward @@ -180,7 +179,7 @@ fi ;; *) - os=netbsd + os=netbsd ;; esac # The OS release @@ -201,6 +200,10 @@ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} @@ -223,7 +226,7 @@ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on @@ -269,7 +272,10 @@ # 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'` - exit ;; + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead @@ -295,7 +301,7 @@ echo s390-ibm-zvmoe exit ;; *:OS400:*:*) - echo powerpc-ibm-os400 + echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} @@ -332,6 +338,9 @@ exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build @@ -391,23 +400,23 @@ # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; @@ -477,8 +486,8 @@ echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ @@ -491,7 +500,7 @@ else echo i586-dg-dgux${UNAME_RELEASE} fi - exit ;; + exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; @@ -548,7 +557,7 @@ echo rs6000-ibm-aix3.2 fi exit ;; - *:AIX:*:[456]) + *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 @@ -591,52 +600,52 @@ 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then 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 - 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; + 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 + 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 - esac ;; - esac + esac ;; + esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - - #define _HPUX_SOURCE - #include - #include - - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); - - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa @@ -727,22 +736,22 @@ exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd - exit ;; + exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit ;; + exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd - exit ;; + exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd - exit ;; + exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd - exit ;; + exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; @@ -766,14 +775,14 @@ 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_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + 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/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + 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:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} @@ -785,34 +794,39 @@ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) - case ${UNAME_MACHINE} in - pc98) - echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; + i*:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; - *:Interix*:[3456]*) - case ${UNAME_MACHINE} in + *:Interix*:*) + case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; - EM64T | authenticamd | genuineintel) + authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) @@ -853,6 +867,13 @@ exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix + exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in @@ -863,7 +884,7 @@ EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; - esac + 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} @@ -875,23 +896,44 @@ then echo ${UNAME_MACHINE}-unknown-linux-gnu else - echo ${UNAME_MACHINE}-unknown-linux-gnueabi + 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 + else + echo ${UNAME_MACHINE}-${MANUFACTURER}-linux-gnueabihf + fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) - echo cris-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; crisv32:Linux:*:*) - echo crisv32-axis-linux-gnu + echo ${UNAME_MACHINE}-axis-linux-gnu exit ;; frv:Linux:*:*) - echo frv-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-gnu + 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}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu @@ -918,15 +960,11 @@ #endif #endif EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^CPU/{ - s: ::g - p - }'`" + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) - echo or32-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu @@ -952,7 +990,7 @@ echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu @@ -960,14 +998,17 @@ sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -976,11 +1017,11 @@ echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) - # Unixware is an offshoot of SVR4, but it has its own version - # number series starting with 2... - # I am not positive that other SVR4 systems won't match this, + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. - # Use sysv4.2uw... so that sysv4* matches it. + # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) @@ -1012,7 +1053,7 @@ fi exit ;; i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. + # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; @@ -1040,13 +1081,13 @@ exit ;; pc:*:*:*) # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. + # 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 # this is a cross-build. echo i586-pc-msdosdjgpp - exit ;; + exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; @@ -1081,8 +1122,8 @@ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ @@ -1125,10 +1166,10 @@ echo ns32k-sni-sysv fi exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says - echo i586-unisys-sysv4 - exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm @@ -1154,11 +1195,11 @@ exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv${UNAME_RELEASE} else - echo mips-unknown-sysv${UNAME_RELEASE} - fi - exit ;; + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; @@ -1170,6 +1211,9 @@ exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku + exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} @@ -1223,7 +1267,10 @@ *:QNX:*:4*) echo i386-pc-qnx exit ;; - NSE-?: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:*:*) @@ -1268,13 +1315,13 @@ echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` + UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; @@ -1292,10 +1339,10 @@ i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx + exit ;; esac - -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 - "4" + "4" #else - "" -#endif - ); exit (0); + "" +#endif + ); exit (0); #endif #endif diff --git a/build-scripts/config.sub b/build-scripts/config.sub index 5ecc18b..ce5e0e6 100755 --- a/build-scripts/config.sub +++ b/build-scripts/config.sub @@ -1,10 +1,10 @@ #! /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 -# Free Software Foundation, Inc. - -timestamp='2009-10-07' +# 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 @@ -21,9 +21,7 @@ # 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., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -75,8 +73,9 @@ version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +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. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -123,12 +122,17 @@ # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ - uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + 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* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` @@ -156,8 +160,8 @@ os= basic_machine=$1 ;; - -bluegene*) - os=-cnk + -bluegene*) + os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= @@ -173,10 +177,10 @@ os=-chorusos basic_machine=$1 ;; - -chorusrdb) - os=-chorusrdb + -chorusrdb) + os=-chorusrdb basic_machine=$1 - ;; + ;; -hiux*) os=-hiuxwe2 ;; @@ -220,6 +224,12 @@ ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 ;; -lynx*) os=-lynxos @@ -245,17 +255,22 @@ # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ + | aarch64 | aarch64_be \ | 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 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ + | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ + | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ @@ -281,28 +296,39 @@ | moxie \ | mt \ | msp430 \ + | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ + | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ - | rx \ + | 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 \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ - | v850 | v850e \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ - | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; - m6811 | m68hc11 | m6812 | m68hc12 | picochip) - # Motorola 68HC11/12. + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) basic_machine=$basic_machine-unknown os=-none ;; @@ -310,6 +336,21 @@ ;; ms1) basic_machine=mt-unknown + ;; + + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' @@ -318,6 +359,19 @@ i*86 | x86_64) basic_machine=$basic_machine-pc ;; + nacl64*) + basic_machine=x86_64-pc + os=-nacl + ;; + nacl*) + basic_machine=i686-pc + os=-nacl + ;; + pnacl*) + # le32-unknown-pnacl comes from http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi + basic_machine=le32-unknown + os=-pnacl + ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 @@ -326,21 +380,25 @@ # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ + | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ + | be32-* | be64-* \ | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | 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-* \ | ip2k-* | iq2000-* \ + | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ @@ -366,24 +424,29 @@ | mmix-* \ | mt-* \ | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ - | romp-* | rs6000-* | rx-* \ + | 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-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ | tron-* \ - | v850-* | v850e-* | vax-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) @@ -408,7 +471,7 @@ basic_machine=a29k-amd os=-udi ;; - abacus) + abacus) basic_machine=abacus-unknown ;; adobe68k) @@ -478,11 +541,20 @@ basic_machine=powerpc-ibm os=-cnk ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; c90) basic_machine=c90-cray os=-unicos ;; - cegcc) + cegcc) basic_machine=arm-unknown os=-cegcc ;; @@ -514,7 +586,7 @@ basic_machine=craynv-cray os=-unicosmp ;; - cr16) + cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; @@ -672,7 +744,6 @@ i370-ibm* | ibm*) basic_machine=i370-ibm ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 @@ -730,8 +801,12 @@ basic_machine=ns32k-utek os=-sysv ;; - microblaze) + microblaze) basic_machine=microblaze-xilinx + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 ;; mingw32) basic_machine=i386-pc @@ -769,9 +844,21 @@ ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; + msys) + basic_machine=i386-pc + os=-msys + ;; mvs) basic_machine=i370-ibm os=-mvs + ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; + pnacl) + basic_machine=le32-unknown + os=-pnacl ;; ncr3000) basic_machine=i486-ncr @@ -837,6 +924,12 @@ np1) basic_machine=np1-gould ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; nsr-tandem) basic_machine=nsr-tandem ;; @@ -919,9 +1012,10 @@ ;; power) basic_machine=power-ibm ;; - ppc) basic_machine=powerpc-unknown - ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc | ppcbe) basic_machine=powerpc-unknown + ;; + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown @@ -1015,6 +1109,9 @@ basic_machine=i860-stratus os=-sysv4 ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; sun2) basic_machine=m68000-sun ;; @@ -1071,20 +1168,8 @@ basic_machine=t90-cray os=-unicos ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff - ;; tile*) - basic_machine=tile-unknown + basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) @@ -1153,6 +1238,9 @@ ;; xps | xps100) basic_machine=xps100-honeywell + ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray @@ -1251,9 +1339,12 @@ if [ x"$os" != x"" ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. + # First match some system type aliases + # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; @@ -1275,21 +1366,22 @@ # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ - | -kopensolaris* \ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -openbsd* | -solidbsd* \ + | -bitrig* | -openbsd* | -solidbsd* \ | -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* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ @@ -1309,6 +1401,12 @@ ;; esac ;; + -nacl*) + os=-nacl + ;; + -pnacl*) + os=-pnacl + ;; -nto-qnx*) ;; -nto*) @@ -1336,7 +1434,7 @@ -opened*) os=-openedition ;; - -os400*) + -os400*) os=-os400 ;; -wince*) @@ -1385,7 +1483,7 @@ -sinix*) os=-sysv4 ;; - -tpf*) + -tpf*) os=-tpf ;; -triton*) @@ -1429,6 +1527,12 @@ ;; -dicos*) os=-dicos + ;; + -nacl*) + os=-nacl + ;; + -pnacl*) + os=-pnacl ;; -none) ;; @@ -1452,10 +1556,10 @@ # system, and we'll never get to this point. case $basic_machine in - score-*) + score-*) os=-elf ;; - spu-*) + spu-*) os=-elf ;; *-acorn) @@ -1467,8 +1571,20 @@ arm*-semi) os=-aout ;; - c4x-* | tic4x-*) - os=-coff + c4x-* | tic4x-*) + os=-coff + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff ;; # This must come before the *-dec entry. pdp10-*) @@ -1488,14 +1604,11 @@ ;; m68000-sun) os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 ;; m68*-cisco) os=-aout ;; - mep-*) + mep-*) os=-elf ;; mips*-cisco) @@ -1522,7 +1635,7 @@ *-ibm) os=-aix ;; - *-knuth) + *-knuth) os=-mmixware ;; *-wec) diff --git a/configure b/configure index 878381b..7c45b7f 100755 --- a/configure +++ b/configure @@ -906,7 +906,7 @@ enable_music_midi_timidity enable_music_midi_native enable_music_midi_fluidsynth -enable_music_fluidsynth_shared +enable_music_midi_fluidsynth_shared enable_music_ogg enable_music_ogg_tremor enable_music_ogg_shared @@ -2439,9 +2439,9 @@ # MAJOR_VERSION=2 MINOR_VERSION=0 -MICRO_VERSION=0 -INTERFACE_AGE=0 -BINARY_AGE=0 +MICRO_VERSION=1 +INTERFACE_AGE=1 +BINARY_AGE=1 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION @@ -11065,13 +11065,13 @@ *mingw32ce*) #VERSION_SOURCES="$srcdir/version.rc" EXE=".exe" - ;; + ;; *-*-cygwin* | *-*-mingw32*) VERSION_SOURCES="$srcdir/version.rc" EXE=".exe" if test "$build" != "$host"; then # cross-compiling # Default cross-compile location - ac_default_prefix=/usr/local/cross-tools/i386-mingw32 + ac_default_prefix=/usr/local/cross-tools/$host else # Look for the location of the tools and install there if test "$BUILD_PREFIX" != ""; then @@ -11148,7 +11148,7 @@ else host_lib_path="/usr/$base_libdir /usr/local/$base_libdir" fi - for path in $gcc_bin_path $gcc_lib_path $env_lib_path $host_lib_path; do + for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do lib=`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1` if test x$lib != x; then echo $lib @@ -11817,8 +11817,8 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - ac_fn_c_check_header_mongrel "$LINENO" "modplug.h" "ac_cv_header_modplug_h" "$ac_includes_default" -if test "x$ac_cv_header_modplug_h" = xyes; then : + ac_fn_c_check_header_mongrel "$LINENO" "libmodplug/modplug.h" "ac_cv_header_libmodplug_modplug_h" "$ac_includes_default" +if test "x$ac_cv_header_libmodplug_modplug_h" = xyes; then : have_libmodplug_hdr=yes fi @@ -11870,8 +11870,8 @@ elif test $pkg_failed = untried; then - ac_fn_c_check_header_mongrel "$LINENO" "modplug.h" "ac_cv_header_modplug_h" "$ac_includes_default" -if test "x$ac_cv_header_modplug_h" = xyes; then : + ac_fn_c_check_header_mongrel "$LINENO" "libmodplug/modplug.h" "ac_cv_header_libmodplug_modplug_h" "$ac_includes_default" +if test "x$ac_cv_header_libmodplug_modplug_h" = xyes; then : have_libmodplug_hdr=yes fi @@ -11954,7 +11954,7 @@ echo "-- dynamic libmodplug -> $modplug_lib" EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_DYNAMIC=\\\"$modplug_lib\\\"" else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS" + EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)" >&5 @@ -12095,7 +12095,7 @@ fi if test x$have_libmodplug != xyes -a x$have_libmikmod != xyes ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MOD support disabled" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MOD support disabled" >&5 $as_echo "$as_me: WARNING: MOD support disabled" >&2;} fi @@ -12161,9 +12161,9 @@ enable_music_midi_fluidsynth=yes fi - # Check whether --enable-music-fluidsynth-shared was given. -if test "${enable_music_fluidsynth_shared+set}" = set; then : - enableval=$enable_music_fluidsynth_shared; + # Check whether --enable-music-midi-fluidsynth-shared was given. +if test "${enable_music_midi_fluidsynth_shared+set}" = set; then : + enableval=$enable_music_midi_fluidsynth_shared; else enable_music_midi_fluidsynth_shared=yes fi @@ -12251,7 +12251,7 @@ if test x$enable_music_midi_timidity != xyes -a \ x$use_music_midi_native != xyes -a x$use_music_midi_native != xyes_cpp -a \ x$have_fluidsynth != xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MIDI support disabled" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MIDI support disabled" >&5 $as_echo "$as_me: WARNING: MIDI support disabled" >&2;} fi @@ -12897,6 +12897,11 @@ $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" + fi EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MAD_MUSIC" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad" else diff --git a/configure.in b/configure.in index f71c002..77dc3fe 100644 --- a/configure.in +++ b/configure.in @@ -14,9 +14,9 @@ # MAJOR_VERSION=2 MINOR_VERSION=0 -MICRO_VERSION=0 -INTERFACE_AGE=0 -BINARY_AGE=0 +MICRO_VERSION=1 +INTERFACE_AGE=1 +BINARY_AGE=1 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION AC_SUBST(MAJOR_VERSION) @@ -115,13 +115,13 @@ *mingw32ce*) #VERSION_SOURCES="$srcdir/version.rc" EXE=".exe" - ;; + ;; *-*-cygwin* | *-*-mingw32*) VERSION_SOURCES="$srcdir/version.rc" EXE=".exe" if test "$build" != "$host"; then # cross-compiling # Default cross-compile location - ac_default_prefix=/usr/local/cross-tools/i386-mingw32 + ac_default_prefix=/usr/local/cross-tools/$host else # Look for the location of the tools and install there if test "$BUILD_PREFIX" != ""; then @@ -186,7 +186,7 @@ else host_lib_path="/usr/$base_libdir /usr/local/$base_libdir" fi - for path in $gcc_bin_path $gcc_lib_path $env_lib_path $host_lib_path; do + for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do lib=[`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1`] if test x$lib != x; then echo $lib @@ -257,7 +257,7 @@ have_libmodplug_hdr=yes have_libmodplug_lib=yes ], [dnl - AC_CHECK_HEADER([modplug.h], [have_libmodplug_hdr=yes]) + AC_CHECK_HEADER([libmodplug/modplug.h], [have_libmodplug_hdr=yes]) AC_CHECK_LIB([modplug], [have_libmodplug_lib=yes]) ]) @@ -283,7 +283,7 @@ echo "-- dynamic libmodplug -> $modplug_lib" EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_DYNAMIC=\\\"$modplug_lib\\\"" else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS" + EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS" fi else AC_MSG_WARN([*** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)]) @@ -359,7 +359,7 @@ fi if test x$have_libmodplug != xyes -a x$have_libmikmod != xyes ; then - AC_MSG_WARN([MOD support disabled]) + AC_MSG_WARN([MOD support disabled]) fi AC_ARG_ENABLE([music-midi], @@ -408,7 +408,7 @@ AC_ARG_ENABLE([music-midi-fluidsynth], AC_HELP_STRING([--enable-music-midi-fluidsynth], [enable FluidSynth MIDI output [[default=yes]]]), [], [enable_music_midi_fluidsynth=yes]) - AC_ARG_ENABLE([music-fluidsynth-shared], + AC_ARG_ENABLE([music-midi-fluidsynth-shared], AC_HELP_STRING([--enable-music-midi-fluidsynth-shared], [dynamically load FluidSynth library [[default=yes]]]), [], [enable_music_midi_fluidsynth_shared=yes]) if test x$enable_music_midi_fluidsynth = xyes; then @@ -448,7 +448,7 @@ if test x$enable_music_midi_timidity != xyes -a \ x$use_music_midi_native != xyes -a x$use_music_midi_native != xyes_cpp -a \ x$have_fluidsynth != xyes; then - AC_MSG_WARN([MIDI support disabled]) + AC_MSG_WARN([MIDI support disabled]) fi AC_ARG_ENABLE([music-ogg], @@ -637,6 +637,11 @@ 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 + : + else + SOURCES="$SOURCES $srcdir/load_mp3.c" + fi EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MAD_MUSIC" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad" else diff --git a/dynamic_flac.c b/dynamic_flac.c index 9a57b5c..cc728f2 100644 --- a/dynamic_flac.c +++ b/dynamic_flac.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/dynamic_flac.h b/dynamic_flac.h index 10a4046..75d7144 100644 --- a/dynamic_flac.h +++ b/dynamic_flac.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/dynamic_fluidsynth.c b/dynamic_fluidsynth.c index fe0f841..edc7660 100644 --- a/dynamic_fluidsynth.c +++ b/dynamic_fluidsynth.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/dynamic_fluidsynth.h b/dynamic_fluidsynth.h index 455b419..e3e3b67 100644 --- a/dynamic_fluidsynth.h +++ b/dynamic_fluidsynth.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/dynamic_mod.c b/dynamic_mod.c index a1e42a2..788ccb9 100644 --- a/dynamic_mod.c +++ b/dynamic_mod.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/dynamic_mod.h b/dynamic_mod.h index 945d3cf..5cb3df9 100644 --- a/dynamic_mod.h +++ b/dynamic_mod.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/dynamic_modplug.c b/dynamic_modplug.c index 2f5c694..20a8dc9 100644 --- a/dynamic_modplug.c +++ b/dynamic_modplug.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/dynamic_modplug.h b/dynamic_modplug.h index 21eeb33..ac4e076 100644 --- a/dynamic_modplug.h +++ b/dynamic_modplug.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 @@ -21,7 +21,11 @@ #ifdef MODPLUG_MUSIC -#include "modplug.h" +#ifdef MODPLUG_HEADER +#include MODPLUG_HEADER +#else +#include +#endif typedef struct { int loaded; diff --git a/dynamic_mp3.c b/dynamic_mp3.c index 0ed38c5..1f00920 100644 --- a/dynamic_mp3.c +++ b/dynamic_mp3.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/dynamic_mp3.h b/dynamic_mp3.h index 5017e0e..3586b70 100644 --- a/dynamic_mp3.h +++ b/dynamic_mp3.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/dynamic_ogg.c b/dynamic_ogg.c index a4b089a..26bd011 100644 --- a/dynamic_ogg.c +++ b/dynamic_ogg.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/dynamic_ogg.h b/dynamic_ogg.h index d54705a..1f0bda4 100644 --- a/dynamic_ogg.h +++ b/dynamic_ogg.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 @@ -20,8 +20,10 @@ */ #ifdef OGG_MUSIC -#ifdef OGG_USE_TREMOR -#include +#if defined(OGG_HEADER) +#include OGG_HEADER +#elif defined(OGG_USE_TREMOR) +#include #else #include #endif diff --git a/effect_position.c b/effect_position.c index e9559c5..2ec1c42 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-2013 Sam Lantinga + 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 diff --git a/effect_stereoreverse.c b/effect_stereoreverse.c index 5763aea..860035f 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-2013 Sam Lantinga + 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 diff --git a/effects_internal.c b/effects_internal.c index 62d59b2..edee647 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-2013 Sam Lantinga + 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 diff --git a/effects_internal.h b/effects_internal.h index c6e92ee..7a2522b 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-2013 Sam Lantinga + 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 diff --git a/fluidsynth.c b/fluidsynth.c index 213944a..0a5d2dc 100644 --- a/fluidsynth.c +++ b/fluidsynth.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 @@ -124,6 +124,7 @@ 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"); diff --git a/fluidsynth.h b/fluidsynth.h index dfccd1c..ae3f2cb 100644 --- a/fluidsynth.h +++ b/fluidsynth.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/load_aiff.c b/load_aiff.c index 5bc4367..a112882 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-2013 Sam Lantinga + 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 diff --git a/load_aiff.h b/load_aiff.h index 02e3cb8..490ad2b 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-2013 Sam Lantinga + 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 diff --git a/load_flac.c b/load_flac.c index 20b8f00..bf9fc51 100644 --- a/load_flac.c +++ b/load_flac.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/load_flac.h b/load_flac.h index f71f31e..6cd0442 100644 --- a/load_flac.h +++ b/load_flac.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/load_mp3.c b/load_mp3.c new file mode 100644 index 0000000..40e031c --- /dev/null +++ b/load_mp3.c @@ -0,0 +1,195 @@ +/* + 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 new file mode 100644 index 0000000..8a8ea56 --- /dev/null +++ b/load_mp3.h @@ -0,0 +1,30 @@ +/* + 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 index 4b92f44..3a0e293 100644 --- a/load_ogg.c +++ b/load_ogg.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 @@ -43,24 +43,25 @@ return SDL_RWread((SDL_RWops*)datasource, ptr, size, nmemb); } -static Sint64 sdl_seek_func(void *datasource, ogg_int64_t offset, int whence) +static int sdl_seek_func(void *datasource, ogg_int64_t offset, int whence) { - return SDL_RWseek((SDL_RWops*)datasource, offset, whence); + return (int)SDL_RWseek((SDL_RWops*)datasource, offset, whence); } -static Sint64 sdl_close_func_freesrc(void *datasource) +static int sdl_close_func_freesrc(void *datasource) { return SDL_RWclose((SDL_RWops*)datasource); } -static Sint64 sdl_close_func_nofreesrc(void *datasource) +static int sdl_close_func_nofreesrc(void *datasource) { - return SDL_RWseek((SDL_RWops*)datasource, 0, RW_SEEK_SET); + SDL_RWseek((SDL_RWops*)datasource, 0, RW_SEEK_SET); + return 0; } -static Sint64 sdl_tell_func(void *datasource) +static long sdl_tell_func(void *datasource) { - return SDL_RWtell((SDL_RWops*)datasource); + return (long)SDL_RWtell((SDL_RWops*)datasource); } diff --git a/load_ogg.h b/load_ogg.h index 1f05909..a13ef6c 100644 --- a/load_ogg.h +++ b/load_ogg.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/load_voc.c b/load_voc.c index 03b3417..cc495f7 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-2013 Sam Lantinga + 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 diff --git a/load_voc.h b/load_voc.h index d82d76e..6afd2f6 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-2013 Sam Lantinga + 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 diff --git a/mixer.c b/mixer.c index 94b1bec..bebb6c0 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-2013 Sam Lantinga + 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 @@ -32,9 +32,11 @@ #include "SDL_mixer.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" @@ -182,7 +184,7 @@ result |= MIX_INIT_MOD; } #else - Mix_SetError("Mixer not built with MOD timidity support"); + Mix_SetError("Mixer not built with MOD mikmod support"); #endif } if (flags & MIX_INIT_MP3) { @@ -190,6 +192,8 @@ if ((initialized & MIX_INIT_MP3) || Mix_InitMP3() == 0) { result |= MIX_INIT_MP3; } +#elif defined(MP3_MAD_MUSIC) + result |= MIX_INIT_MP3; #else Mix_SetError("Mixer not built with MP3 support"); #endif @@ -318,7 +322,7 @@ /* Mix any playing channels... */ sdl_ticks = SDL_GetTicks(); for ( i=0; i 0 && mix_channel[i].expire < sdl_ticks ) { /* Expiration delay for that channel is reached */ mix_channel[i].playing = 0; @@ -328,7 +332,7 @@ _Mix_channel_done_playing(i); } 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 ) { mix_channel[i].playing = 0; @@ -338,7 +342,7 @@ } 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 ); } else { @@ -492,6 +496,9 @@ #endif #ifdef FLAC_MUSIC add_chunk_decoder("FLAC"); +#endif +#if defined(MP3_MUSIC) || defined(MP3_MAD_MUSIC) + add_chunk_decoder("MP3"); #endif audio_opened = 1; @@ -557,11 +564,23 @@ return(audio_opened); } - -/* - * !!! FIXME: Ideally, we want a Mix_LoadSample_RW(), which will handle the - * generic setup, then call the correct file format loader. - */ +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; +} /* Load a wave file */ Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc) @@ -629,6 +648,16 @@ (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); @@ -1067,7 +1096,7 @@ (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 = ms; + mix_channel[which].fade_length = (Uint32)ms; mix_channel[which].ticks_fade = SDL_GetTicks(); /* only change fade_volume_reset if we're not fading. */ diff --git a/music.c b/music.c index 76d967d..bbaf4a3 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-2013 Sam Lantinga + 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 @@ -574,7 +574,7 @@ /* We need to know if a specific error occurs; if not, we'll set a * generic one, so we clear the current one. */ - Mix_SetError(""); + SDL_ClearError(); music = Mix_LoadMUSType_RW(src, type, SDL_TRUE); if ( music == NULL && Mix_GetError()[0] == '\0' ) { Mix_SetError("Unrecognized music format"); diff --git a/music_cmd.c b/music_cmd.c index e58b3e1..0989ac0 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-2013 Sam Lantinga + 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 diff --git a/music_cmd.h b/music_cmd.h index 5b5b077..976fd72 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-2013 Sam Lantinga + 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 diff --git a/music_flac.c b/music_flac.c index ea81ceb..4d56283 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-2013 Sam Lantinga + 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 diff --git a/music_flac.h b/music_flac.h index a514923..5c877ec 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-2013 Sam Lantinga + 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 diff --git a/music_mad.c b/music_mad.c index 054a2d9..e66dfc2 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-2013 Sam Lantinga + 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 diff --git a/music_mad.h b/music_mad.h index 297826b..16a0875 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-2013 Sam Lantinga + 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 diff --git a/music_mod.c b/music_mod.c index 87b9ac8..4b04d25 100644 --- a/music_mod.c +++ b/music_mod.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/music_mod.h b/music_mod.h index f142268..a4055ae 100644 --- a/music_mod.h +++ b/music_mod.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/music_modplug.c b/music_modplug.c index a51bc91..04c42a3 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-2013 Sam Lantinga + 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 diff --git a/music_modplug.h b/music_modplug.h index d9cfb04..952dc86 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-2013 Sam Lantinga + 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 @@ -21,7 +21,11 @@ #ifdef MODPLUG_MUSIC -#include "modplug.h" +#ifdef MODPLUG_HEADER +#include MODPLUG_HEADER +#else +#include +#endif #include "SDL_rwops.h" #include "SDL_audio.h" #include "SDL_mixer.h" diff --git a/music_ogg.c b/music_ogg.c index 5997cc7..788f891 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-2013 Sam Lantinga + 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 @@ -56,14 +56,14 @@ return SDL_RWread((SDL_RWops*)datasource, ptr, size, nmemb); } -static Sint64 sdl_seek_func(void *datasource, ogg_int64_t offset, int whence) -{ - return SDL_RWseek((SDL_RWops*)datasource, offset, whence); -} - -static Sint64 sdl_tell_func(void *datasource) -{ - return SDL_RWtell((SDL_RWops*)datasource); +static int sdl_seek_func(void *datasource, ogg_int64_t offset, int whence) +{ + return (int)SDL_RWseek((SDL_RWops*)datasource, offset, whence); +} + +static long sdl_tell_func(void *datasource) +{ + return (long)SDL_RWtell((SDL_RWops*)datasource); } /* Load an OGG stream from an SDL_RWops object */ diff --git a/music_ogg.h b/music_ogg.h index 5510064..c04798d 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-2013 Sam Lantinga + 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 @@ -25,8 +25,10 @@ /* This file supports Ogg Vorbis music streams */ -#ifdef OGG_USE_TREMOR -#include +#if defined(OGG_HEADER) +#include OGG_HEADER +#elif defined(OGG_USE_TREMOR) +#include #else #include #endif diff --git a/native_midi/native_midi_common.c b/native_midi/native_midi_common.c index a81c014..7726349 100644 --- a/native_midi/native_midi_common.c +++ b/native_midi/native_midi_common.c @@ -230,7 +230,8 @@ return NULL; track = (MIDIEvent**) calloc(1, sizeof(MIDIEvent*) * mididata->nTracks); - if (NULL == head) + + if (NULL == track) return NULL; /* First, convert all tracks to MIDIEvent lists */ diff --git a/playmus.c b/playmus.c index 9562786..ccf1fb0 100644 --- a/playmus.c +++ b/playmus.c @@ -1,6 +1,6 @@ /* PLAYMUS: A test application for the SDL mixer library. - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/playwave.c b/playwave.c index 9b652d4..a35c63e 100644 --- a/playwave.c +++ b/playwave.c @@ -1,6 +1,6 @@ /* PLAYWAVE: A test application for the SDL mixer library. - Copyright (C) 1997-2013 Sam Lantinga + 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 diff --git a/timidity/playmidi.c b/timidity/playmidi.c index 2463341..dd12804 100644 --- a/timidity/playmidi.c +++ b/timidity/playmidi.c @@ -326,7 +326,7 @@ { 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 = 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]; diff --git a/timidity/readmidi.c b/timidity/readmidi.c index e3d162f..afa79b9 100644 --- a/timidity/readmidi.c +++ b/timidity/readmidi.c @@ -673,15 +673,15 @@ meep->event.time, meep->event.channel + 1, meep->event.type, meep->event.a, meep->event.b); - if (meep->event.channel >= MAXCHAN) - skip_this_event=1; - else if (meep->event.type==ME_TEMPO) + 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; else switch (meep->event.type) diff --git a/timidity/timidity.c b/timidity/timidity.c index 2004cc0..5b96800 100644 --- a/timidity/timidity.c +++ b/timidity/timidity.c @@ -56,7 +56,7 @@ line++; w[words=0]=strtok(tmp, " \t\r\n\240"); if (!w[0] || (*w[0]=='#')) continue; - while (w[words] && (words < MAXWORDS)) + while (w[words] && (words < (MAXWORDS-1))) { w[++words]=strtok(0," \t\r\n\240"); if (w[words] && w[words][0]=='#') break; @@ -68,6 +68,7 @@ { ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: line %d: No directory given\n", name, line); + close_file(fp); return -2; } 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); @@ -107,6 +110,7 @@ ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: line %d: No drum set number given\n", name, line); + close_file(fp); return -2; } i=atoi(w[1]); @@ -115,6 +119,7 @@ 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]) @@ -131,6 +136,7 @@ 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]); @@ -139,6 +145,7 @@ 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]) @@ -161,6 +168,7 @@ 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) @@ -169,6 +177,7 @@ "%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) @@ -184,6 +193,7 @@ { ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: line %d: bad patch option %s\n", name, line, w[j]); + close_file(fp); return -2; } *cp++=0; @@ -195,6 +205,7 @@ 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; @@ -207,6 +218,7 @@ 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; @@ -228,6 +240,7 @@ "%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; @@ -242,6 +255,7 @@ { ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: line %d: keep must be env or loop\n", name, line); + close_file(fp); return -2; } } @@ -258,6 +272,7 @@ ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: line %d: strip must be env, loop, or tail\n", name, line); + close_file(fp); return -2; } } @@ -265,6 +280,7 @@ { ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: line %d: bad patch option %s\n", name, line, w[j]); + close_file(fp); return -2; } } diff --git a/version.rc b/version.rc index a876096..d624e96 100644 --- a/version.rc +++ b/version.rc @@ -9,8 +9,8 @@ // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,0,0,0 - PRODUCTVERSION 2,0,0,0 + FILEVERSION 2,0,1,0 + PRODUCTVERSION 2,0,1,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS 0x40004L @@ -23,12 +23,12 @@ BEGIN VALUE "CompanyName", "\0" VALUE "FileDescription", "SDL_mixer\0" - VALUE "FileVersion", "2, 0, 0, 0\0" + VALUE "FileVersion", "2, 0, 1, 0\0" VALUE "InternalName", "SDL_mixer\0" - VALUE "LegalCopyright", "Copyright © 2013 Sam Lantinga\0" + VALUE "LegalCopyright", "Copyright © 2016 Sam Lantinga\0" VALUE "OriginalFilename", "SDL_mixer.dll\0" VALUE "ProductName", "Simple DirectMedia Layer\0" - VALUE "ProductVersion", "2, 0, 0, 0\0" + VALUE "ProductVersion", "2, 0, 1, 0\0" END END BLOCK "VarFileInfo" diff --git a/wavestream.c b/wavestream.c index 0934be2..8dc1683 100644 --- a/wavestream.c +++ b/wavestream.c @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 @@ -47,20 +47,18 @@ /*******************************************/ #define RIFF 0x46464952 /* "RIFF" */ #define WAVE 0x45564157 /* "WAVE" */ -#define FACT 0x74636166 /* "fact" */ -#define LIST 0x5453494c /* "LIST" */ -#define FMT 0x20746D66 /* "fmt " */ +#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 -/* Normally, these three chunks come consecutively in a WAVE file */ -typedef struct WaveFMT { +typedef struct { /* Not saved in the chunk we read: - Uint32 FMTchunk; - Uint32 fmtlen; + Uint32 chunkID; + Uint32 chunkLen; */ Uint16 encoding; Uint16 channels; /* 1 = mono, 2 = stereo */ @@ -70,12 +68,31 @@ Uint16 bitspersample; /* One of 8, 12, 16, or 4 for ADPCM */ } WaveFMT; -/* The general chunk found in the WAVE file */ -typedef struct Chunk { - Uint32 magic; - Uint32 length; - Uint8 *data; /* Data includes magic and length */ -} Chunk; +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 */ @@ -94,10 +111,8 @@ static int wavestream_volume = MIX_MAX_VOLUME; /* Function to load the WAV/AIFF stream */ -static SDL_RWops *LoadWAVStream (SDL_RWops *rw, SDL_AudioSpec *spec, - long *start, long *stop); -static SDL_RWops *LoadAIFFStream (SDL_RWops *rw, SDL_AudioSpec *spec, - long *start, long *stop); +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. @@ -117,33 +132,35 @@ WAVStream *WAVStream_LoadSong_RW(SDL_RWops *src, int freesrc) { WAVStream *wave; - SDL_AudioSpec wavespec; - - if ( ! mixer.format ) { + 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 ) { + if (wave) { Uint32 magic; SDL_zerop(wave); + wave->src = src; wave->freesrc = freesrc; magic = SDL_ReadLE32(src); - if ( magic == RIFF || magic == WAVE ) { - wave->src = LoadWAVStream(src, &wavespec, &wave->start, &wave->stop); - } else if ( magic == FORM ) { - wave->src = LoadAIFFStream(src, &wavespec, &wave->start, &wave->stop); + if (magic == RIFF || magic == WAVE) { + loaded = LoadWAVStream(wave); + } else if (magic == FORM) { + loaded = LoadAIFFStream(wave); } else { Mix_SetError("Unknown WAVE format"); } - if ( wave->src == NULL ) { - SDL_free(wave); + if (!loaded) { + WAVStream_FreeSong(wave); return(NULL); } SDL_BuildAudioCVT(&wave->cvt, - wavespec.format, wavespec.channels, wavespec.freq, + wave->spec.format, wave->spec.channels, wave->spec.freq, mixer.format, mixer.channels, mixer.freq); } else { SDL_OutOfMemory(); @@ -155,67 +172,118 @@ /* Start playback of a given WAV stream */ void WAVStream_Start(WAVStream *wave) { - SDL_RWseek (wave->src, wave->start, RW_SEEK_SET); + 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() */ -int WAVStream_PlaySome(Uint8 *stream, int len) -{ - Sint64 pos; - Sint64 left = 0; - - if ( music && ((pos=SDL_RWtell(music->src)) < music->stop) ) { - 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; +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; } - if ( (music->stop - pos) < original_len ) { - left = (original_len - (music->stop - pos)); - original_len -= (int)left; - left = (int)((double)left*music->cvt.len_ratio); + } + 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); } - 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--; + 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; - SDL_ConvertAudio(&music->cvt); - SDL_MixAudio(stream, music->cvt.buf, music->cvt.len_cvt, wavestream_volume); + } + 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 { - Uint8 *data; - if ( (music->stop - pos) < len ) { - left = (len - (music->stop - pos)); - len -= (int)left; + if (loop->current_play_count > 0) { + --loop->current_play_count; } - data = SDL_stack_alloc(Uint8, len); - if (data) - { - SDL_RWread(music->src, data, len, 1); - SDL_MixAudio(stream, data, len, wavestream_volume); - SDL_stack_free(data); - } - } - } - return (int)left; + 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() */ @@ -227,12 +295,15 @@ /* Close the given WAV stream */ void WAVStream_FreeSong(WAVStream *wave) { - if ( wave ) { + if (wave) { /* Clean up associated data */ - if ( wave->cvt.buf ) { + if (wave->loops) { + SDL_free(wave->loops); + } + if (wave->cvt.buf) { SDL_free(wave->cvt.buf); } - if ( wave->freesrc ) { + if (wave->freesrc) { SDL_RWclose(wave->src); } SDL_free(wave); @@ -245,85 +316,45 @@ int active; active = 0; - if ( music && (SDL_RWtell(music->src) < music->stop) ) { + if (music && (SDL_RWtell(music->src) < music->stop)) { active = 1; } return(active); } -static int ReadChunk(SDL_RWops *src, Chunk *chunk, int read_data) -{ - chunk->magic = SDL_ReadLE32(src); - chunk->length = SDL_ReadLE32(src); - if ( read_data ) { - chunk->data = (Uint8 *)SDL_malloc(chunk->length); - if ( chunk->data == NULL ) { - Mix_SetError("Out of memory"); - return(-1); - } - if ( SDL_RWread(src, chunk->data, chunk->length, 1) != 1 ) { - Mix_SetError("Couldn't read chunk"); - SDL_free(chunk->data); - return(-1); - } - } else { - SDL_RWseek(src, chunk->length, RW_SEEK_CUR); - } - return(chunk->length); -} - -static SDL_RWops *LoadWAVStream (SDL_RWops *src, SDL_AudioSpec *spec, - long *start, long *stop) -{ - int was_error; - Chunk chunk; - int lenread; - - /* WAV magic header */ - Uint32 wavelen; - Uint32 WAVEmagic; - - /* FMT chunk */ - WaveFMT *format = NULL; - - was_error = 0; - - /* Check the magic header */ - wavelen = SDL_ReadLE32(src); - WAVEmagic = SDL_ReadLE32(src); - - /* Read the audio data format chunk */ - chunk.data = NULL; - do { - /* FIXME! Add this logic to SDL_LoadWAV_RW() */ - if ( chunk.data ) { - SDL_free(chunk.data); - } - lenread = ReadChunk(src, &chunk, 1); - if ( lenread < 0 ) { - was_error = 1; - goto done; - } - } while ( (chunk.magic == FACT) || (chunk.magic == LIST) ); +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 */ - format = (WaveFMT *)chunk.data; - if ( chunk.magic != FMT ) { - SDL_free(chunk.data); - Mix_SetError("Complex WAVE files not supported"); - was_error = 1; - goto done; - } switch (SDL_SwapLE16(format->encoding)) { case PCM_CODE: /* We can understand this */ break; default: Mix_SetError("Unknown WAVE data format"); - was_error = 1; goto done; } - SDL_memset(spec, 0, (sizeof *spec)); spec->freq = SDL_SwapLE32(format->frequency); switch (SDL_SwapLE16(format->bitspersample)) { case 8: @@ -334,32 +365,136 @@ break; default: Mix_SetError("Unknown PCM data format"); - was_error = 1; goto done; } spec->channels = (Uint8) SDL_SwapLE16(format->channels); spec->samples = 4096; /* Good default buffer size */ - /* Set the file offset to the DATA chunk data */ - chunk.data = NULL; - do { - *start = (long)SDL_RWtell(src) + 2*sizeof(Uint32); - lenread = ReadChunk(src, &chunk, 0); - if ( lenread < 0 ) { - was_error = 1; - goto done; - } - } while ( chunk.magic != DATA ); - *stop = (long)SDL_RWtell(src); + loaded = SDL_TRUE; done: - if ( format != NULL ) { - SDL_free(format); - } - if ( was_error ) { - return NULL; - } - return(src); + 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. @@ -384,16 +519,16 @@ 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_RWops *LoadAIFFStream (SDL_RWops *src, SDL_AudioSpec *spec, - long *start, long *stop) -{ - int was_error; - int found_SSND; - int found_COMM; + 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; @@ -411,27 +546,20 @@ Uint8 sane_freq[10]; Uint32 frequency = 0; - was_error = 0; - /* Check the magic header */ - chunk_length = SDL_ReadBE32(src); - AIFFmagic = SDL_ReadLE32(src); - if ( AIFFmagic != AIFF ) { + chunk_length = SDL_ReadBE32(src); + AIFFmagic = SDL_ReadLE32(src); + if (AIFFmagic != AIFF) { Mix_SetError("Unrecognized file type (not AIFF)"); - was_error = 1; - goto done; + return SDL_FALSE; } /* From what I understand of the specification, chunks may appear in - * any order, and we should just ignore unknown ones. + * 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? */ - - found_SSND = 0; - found_COMM = 0; - do { chunk_type = SDL_ReadLE32(src); chunk_length = SDL_ReadBE32(src); @@ -439,25 +567,25 @@ /* Paranoia to avoid infinite loops */ if (chunk_length == 0) - break; + break; switch (chunk_type) { case SSND: - found_SSND = 1; - offset = SDL_ReadBE32(src); - blocksize = SDL_ReadBE32(src); - *start = (long)SDL_RWtell(src) + offset; + found_SSND = SDL_TRUE; + offset = SDL_ReadBE32(src); + blocksize = SDL_ReadBE32(src); + wave->start = SDL_RWtell(src) + offset; break; case COMM: - found_COMM = 1; + found_COMM = SDL_TRUE; /* Read the audio data format chunk */ - channels = SDL_ReadBE16(src); - numsamples = SDL_ReadBE32(src); - samplesize = SDL_ReadBE16(src); + 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); + frequency = SANE_to_Uint32(sane_freq); break; default: @@ -468,17 +596,15 @@ if (!found_SSND) { Mix_SetError("Bad AIFF file (no SSND chunk)"); - was_error = 1; - goto done; + return SDL_FALSE; } if (!found_COMM) { Mix_SetError("Bad AIFF file (no COMM chunk)"); - was_error = 1; - goto done; - } - - *stop = *start + channels * numsamples * (samplesize / 8); + return SDL_FALSE; + } + + wave->stop = wave->start + channels * numsamples * (samplesize / 8); /* Decode the audio data format */ SDL_memset(spec, 0, (sizeof *spec)); @@ -492,16 +618,11 @@ break; default: Mix_SetError("Unknown samplesize in data format"); - was_error = 1; - goto done; + return SDL_FALSE; } spec->channels = (Uint8) channels; spec->samples = 4096; /* Good default buffer size */ -done: - if ( was_error ) { - return NULL; - } - return(src); -} - + return SDL_TRUE; +} + diff --git a/wavestream.h b/wavestream.h index fb0c702..adb4dbb 100644 --- a/wavestream.h +++ b/wavestream.h @@ -1,6 +1,6 @@ /* SDL_mixer: An audio mixer library based on the SDL library - Copyright (C) 1997-2013 Sam Lantinga + 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 @@ -21,16 +21,25 @@ /* $Id$ */ -/* This file supports streaming WAV files, without volume adjustment */ +/* This file supports streaming WAV files */ -#include +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; - long start; - long stop; + SDL_AudioSpec spec; + Sint64 start; + Sint64 stop; SDL_AudioCVT cvt; + int numloops; + WAVLoopPoint *loops; } WAVStream; /* Initialize the WAVStream player, with the given mixer settings