Package list libsdl2-mixer / b1f9647
Imported Upstream version 2.0.1+dfsg1 Manuel A. Fernandez Montecelo 5 years ago
61 changed file(s) with 1166 addition(s) and 553 deletion(s). Raw diff Collapse all Expand all
55
66 # Enable this if you want to support loading MOD music via modplug
77 # The library path should be a relative path to this directory.
8 SUPPORT_MOD_MODPLUG := true
8 SUPPORT_MOD_MODPLUG ?= true
99 MODPLUG_LIBRARY_PATH := external/libmodplug-0.8.8.4
1010
1111 # Enable this if you want to support loading MOD music via mikmod
1212 # The library path should be a relative path to this directory.
13 SUPPORT_MOD_MIKMOD := true
13 SUPPORT_MOD_MIKMOD ?= true
1414 MIKMOD_LIBRARY_PATH := external/libmikmod-3.1.12
1515
1616 # Enable this if you want to support loading MP3 music via SMPEG
1717 # The library path should be a relative path to this directory.
18 SUPPORT_MP3_SMPEG := true
18 SUPPORT_MP3_SMPEG ?= true
1919 SMPEG_LIBRARY_PATH := external/smpeg2-2.0.0
2020
2121 # Enable this if you want to support loading OGG Vorbis music via Tremor
2222 # The library path should be a relative path to this directory.
23 SUPPORT_OGG := true
23 SUPPORT_OGG ?= true
2424 OGG_LIBRARY_PATH := external/libogg-1.3.1
2525 VORBIS_LIBRARY_PATH := external/libvorbisidec-1.2.1
2626
2727
28 LOCAL_C_INCLUDES := $(LOCAL_PATH)
29 LOCAL_CFLAGS := -DWAV_MUSIC
28 # Enable this if you want to support TiMidity
29 SUPPORT_TIMIDITY ?= true
3030
31 LOCAL_SRC_FILES := $(notdir $(filter-out %/playmus.c %/playwave.c, $(wildcard $(LOCAL_PATH)/*.c)))
31 LOCAL_C_INCLUDES := $(LOCAL_PATH)
32 LOCAL_CFLAGS := -DWAV_MUSIC
33
34 LOCAL_SRC_FILES := $(notdir $(filter-out %/playmus.c %/playwave.c, $(wildcard $(LOCAL_PATH)/*.c))) \
35
3236
3337 LOCAL_LDLIBS :=
3438 LOCAL_STATIC_LIBRARIES :=
3539 LOCAL_SHARED_LIBRARIES := SDL2
3640
41 ifeq ($(SUPPORT_TIMIDITY),true)
42 LOCAL_C_INCLUDES += $(LOCAL_PATH)/timidity
43 LOCAL_CFLAGS += -DMID_MUSIC -DUSE_TIMIDITY_MIDI
44 LOCAL_SRC_FILES += $(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/timidity/*.c))
45 endif
46
3747 ifeq ($(SUPPORT_MOD_MODPLUG),true)
3848 LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(MODPLUG_LIBRARY_PATH)/src $(LOCAL_PATH)/$(MODPLUG_LIBRARY_PATH)/src/libmodplug
39 LOCAL_CFLAGS += -DMODPLUG_MUSIC -DHAVE_SETENV -DHAVE_SINF
49 LOCAL_CFLAGS += -DMODPLUG_MUSIC -DMODPLUG_HEADER="<modplug.h>" -DHAVE_SETENV -DHAVE_SINF
4050 LOCAL_SRC_FILES += \
4151 $(MODPLUG_LIBRARY_PATH)/src/fastmix.cpp \
4252 $(MODPLUG_LIBRARY_PATH)/src/load_669.cpp \
8898
8999 ifeq ($(SUPPORT_OGG),true)
90100 LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(OGG_LIBRARY_PATH)/include $(LOCAL_PATH)/$(VORBIS_LIBRARY_PATH)
91 LOCAL_CFLAGS += -DOGG_MUSIC -DOGG_USE_TREMOR
101 LOCAL_CFLAGS += -DOGG_MUSIC -DOGG_USE_TREMOR -DOGG_HEADER="<ivorbisfile.h>"
102 ifeq ($(TARGET_ARCH_ABI),armeabi)
103 LOCAL_CFLAGS += -D_ARM_ASSEM_
104 endif
105 ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
106 LOCAL_CFLAGS += -D_ARM_ASSEM_
107 endif
92108 LOCAL_SRC_FILES += \
93109 $(VORBIS_LIBRARY_PATH)/mdct.c \
94110 $(VORBIS_LIBRARY_PATH)/block.c \
109125
110126 LOCAL_EXPORT_C_INCLUDES += $(LOCAL_C_INCLUDES)
111127
128 LOCAL_ARM_MODE := arm
129
112130 include $(BUILD_SHARED_LIBRARY)
0 2.0.1:
1 Sam Lantinga - Tue Jul 7 11:40:33 PDT 2015
2 * Added support for 'smpl' format loop points in music WAV files
3 Sam Lantinga - Sat Aug 23 10:57:26 2014
4 * Fixed floating point exception in Mix_Volume()
5 David Ludwig - Mon Apr 14 22:15:36 2014
6 * Added support for building for Windows RT and Windows Phone
7 Isaac Burns - Sun Sep 15 21:50:27 PDT 2013
8 * Added support for loading MP3 files as sound chunks
9
010 2.0.0:
111 Sam Lantinga - Sun Jun 9 14:45:30 PDT 2013
212 * Made libmodplug the default MOD player as it is now in the public domain
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
3838 PLAYWAVE_OBJECTS = @PLAYWAVE_OBJECTS@
3939 PLAYMUS_OBJECTS = @PLAYMUS_OBJECTS@
4040
41 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
41 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
4242
4343 LT_AGE = @LT_AGE@
4444 LT_CURRENT = @LT_CURRENT@
00 %define name SDL2_mixer
1 %define version 2.0.0
1 %define version 2.0.1
22 %define release 1
33
44 Summary: Simple DirectMedia Layer - Sample Mixer Library
4444
4545 %files
4646 %defattr(-,root,root)
47 %doc README CHANGES COPYING
47 %doc README.txt CHANGES.txt COPYING.txt
4848 %{prefix}/lib/lib*.so.*
4949
5050 %files devel
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
3939 */
4040 #define SDL_MIXER_MAJOR_VERSION 2
4141 #define SDL_MIXER_MINOR_VERSION 0
42 #define SDL_MIXER_PATCHLEVEL 0
42 #define SDL_MIXER_PATCHLEVEL 1
4343
4444 /* This macro can be used to fill a version structure with the compile-time
4545 * version of the SDL_mixer library.
206206 */
207207 extern DECLSPEC void SDLCALL Mix_HookMusic(void (*mix_func)(void *udata, Uint8 *stream, int len), void *arg);
208208
209 /* Add your own callback when the music has finished playing.
210 This callback is only called if the music finishes naturally.
209 /* Add your own callback for when the music has finished playing or when it is
210 * stopped from a call to Mix_HaltMusic.
211211 */
212212 extern DECLSPEC void SDLCALL Mix_HookMusicFinished(void (*music_finished)(void));
213213
00 #! /bin/sh
11 # Attempt to guess a canonical system name.
22 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
4 # Free Software Foundation, Inc.
5
6 timestamp='2009-09-18'
3 # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
4 # 2011, 2012 Free Software Foundation, Inc.
5
6 timestamp='2012-08-14'
77
88 # This file is free software; you can redistribute it and/or modify it
99 # under the terms of the GNU General Public License as published by
1616 # General Public License for more details.
1717 #
1818 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
21 # 02110-1301, USA.
19 # along with this program; if not, see <http://www.gnu.org/licenses/>.
2220 #
2321 # As a special exception to the GNU General Public License, if you
2422 # distribute this file as part of a program that contains a
5553 GNU config.guess ($timestamp)
5654
5755 Originally written by Per Bothner.
58 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
59 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
56 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
57 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
58 Free Software Foundation, Inc.
6059
6160 This is free software; see the source for copying conditions. There is NO
6261 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
143142 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
144143 *:NetBSD:*:*)
145144 # NetBSD (nbsd) targets should (where applicable) match one or
146 # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
145 # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
147146 # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
148147 # switched to ELF, *-*-netbsd* would select the old
149148 # object file format. This provides both forward
179178 fi
180179 ;;
181180 *)
182 os=netbsd
181 os=netbsd
183182 ;;
184183 esac
185184 # The OS release
200199 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
201200 echo "${machine}-${os}${release}"
202201 exit ;;
202 *:Bitrig:*:*)
203 UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
204 echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
205 exit ;;
203206 *:OpenBSD:*:*)
204207 UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
205208 echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
222225 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
223226 ;;
224227 *5.*)
225 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
228 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
226229 ;;
227230 esac
228231 # According to Compaq, /usr/sbin/psrinfo has been available on
268271 # A Xn.n version is an unreleased experimental baselevel.
269272 # 1.2 uses "1.2" for uname -r.
270273 echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
271 exit ;;
274 # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
275 exitcode=$?
276 trap '' 0
277 exit $exitcode ;;
272278 Alpha\ *:Windows_NT*:*)
273279 # How do we know it's Interix rather than the generic POSIX subsystem?
274280 # Should we change UNAME_MACHINE based on the output of uname instead
294300 echo s390-ibm-zvmoe
295301 exit ;;
296302 *:OS400:*:*)
297 echo powerpc-ibm-os400
303 echo powerpc-ibm-os400
298304 exit ;;
299305 arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
300306 echo arm-acorn-riscix${UNAME_RELEASE}
331337 exit ;;
332338 sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
333339 echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
340 exit ;;
341 i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
342 echo i386-pc-auroraux${UNAME_RELEASE}
334343 exit ;;
335344 i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
336345 eval $set_cc_for_build
390399 # MiNT. But MiNT is downward compatible to TOS, so this should
391400 # be no problem.
392401 atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
393 echo m68k-atari-mint${UNAME_RELEASE}
402 echo m68k-atari-mint${UNAME_RELEASE}
394403 exit ;;
395404 atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
396405 echo m68k-atari-mint${UNAME_RELEASE}
397 exit ;;
406 exit ;;
398407 *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
399 echo m68k-atari-mint${UNAME_RELEASE}
408 echo m68k-atari-mint${UNAME_RELEASE}
400409 exit ;;
401410 milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
402 echo m68k-milan-mint${UNAME_RELEASE}
403 exit ;;
411 echo m68k-milan-mint${UNAME_RELEASE}
412 exit ;;
404413 hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
405 echo m68k-hades-mint${UNAME_RELEASE}
406 exit ;;
414 echo m68k-hades-mint${UNAME_RELEASE}
415 exit ;;
407416 *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
408 echo m68k-unknown-mint${UNAME_RELEASE}
409 exit ;;
417 echo m68k-unknown-mint${UNAME_RELEASE}
418 exit ;;
410419 m68k:machten:*:*)
411420 echo m68k-apple-machten${UNAME_RELEASE}
412421 exit ;;
476485 echo m88k-motorola-sysv3
477486 exit ;;
478487 AViiON:dgux:*:*)
479 # DG/UX returns AViiON for all architectures
480 UNAME_PROCESSOR=`/usr/bin/uname -p`
488 # DG/UX returns AViiON for all architectures
489 UNAME_PROCESSOR=`/usr/bin/uname -p`
481490 if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
482491 then
483492 if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
490499 else
491500 echo i586-dg-dgux${UNAME_RELEASE}
492501 fi
493 exit ;;
502 exit ;;
494503 M88*:DolphinOS:*:*) # DolphinOS (SVR3)
495504 echo m88k-dolphin-sysv3
496505 exit ;;
547556 echo rs6000-ibm-aix3.2
548557 fi
549558 exit ;;
550 *:AIX:*:[456])
559 *:AIX:*:[4567])
551560 IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
552561 if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
553562 IBM_ARCH=rs6000
590599 9000/[678][0-9][0-9])
591600 if [ -x /usr/bin/getconf ]; then
592601 sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
593 sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
594 case "${sc_cpu_version}" in
595 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
596 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
597 532) # CPU_PA_RISC2_0
598 case "${sc_kernel_bits}" in
599 32) HP_ARCH="hppa2.0n" ;;
600 64) HP_ARCH="hppa2.0w" ;;
602 sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
603 case "${sc_cpu_version}" in
604 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
605 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
606 532) # CPU_PA_RISC2_0
607 case "${sc_kernel_bits}" in
608 32) HP_ARCH="hppa2.0n" ;;
609 64) HP_ARCH="hppa2.0w" ;;
601610 '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
602 esac ;;
603 esac
611 esac ;;
612 esac
604613 fi
605614 if [ "${HP_ARCH}" = "" ]; then
606615 eval $set_cc_for_build
607 sed 's/^ //' << EOF >$dummy.c
608
609 #define _HPUX_SOURCE
610 #include <stdlib.h>
611 #include <unistd.h>
612
613 int main ()
614 {
615 #if defined(_SC_KERNEL_BITS)
616 long bits = sysconf(_SC_KERNEL_BITS);
617 #endif
618 long cpu = sysconf (_SC_CPU_VERSION);
619
620 switch (cpu)
621 {
622 case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
623 case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
624 case CPU_PA_RISC2_0:
625 #if defined(_SC_KERNEL_BITS)
626 switch (bits)
627 {
628 case 64: puts ("hppa2.0w"); break;
629 case 32: puts ("hppa2.0n"); break;
630 default: puts ("hppa2.0"); break;
631 } break;
632 #else /* !defined(_SC_KERNEL_BITS) */
633 puts ("hppa2.0"); break;
634 #endif
635 default: puts ("hppa1.0"); break;
636 }
637 exit (0);
638 }
616 sed 's/^ //' << EOF >$dummy.c
617
618 #define _HPUX_SOURCE
619 #include <stdlib.h>
620 #include <unistd.h>
621
622 int main ()
623 {
624 #if defined(_SC_KERNEL_BITS)
625 long bits = sysconf(_SC_KERNEL_BITS);
626 #endif
627 long cpu = sysconf (_SC_CPU_VERSION);
628
629 switch (cpu)
630 {
631 case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
632 case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
633 case CPU_PA_RISC2_0:
634 #if defined(_SC_KERNEL_BITS)
635 switch (bits)
636 {
637 case 64: puts ("hppa2.0w"); break;
638 case 32: puts ("hppa2.0n"); break;
639 default: puts ("hppa2.0"); break;
640 } break;
641 #else /* !defined(_SC_KERNEL_BITS) */
642 puts ("hppa2.0"); break;
643 #endif
644 default: puts ("hppa1.0"); break;
645 }
646 exit (0);
647 }
639648 EOF
640649 (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
641650 test -z "$HP_ARCH" && HP_ARCH=hppa
726735 exit ;;
727736 C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
728737 echo c1-convex-bsd
729 exit ;;
738 exit ;;
730739 C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
731740 if getsysinfo -f scalar_acc
732741 then echo c32-convex-bsd
733742 else echo c2-convex-bsd
734743 fi
735 exit ;;
744 exit ;;
736745 C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
737746 echo c34-convex-bsd
738 exit ;;
747 exit ;;
739748 C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
740749 echo c38-convex-bsd
741 exit ;;
750 exit ;;
742751 C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
743752 echo c4-convex-bsd
744 exit ;;
753 exit ;;
745754 CRAY*Y-MP:*:*:*)
746755 echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
747756 exit ;;
765774 exit ;;
766775 F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
767776 FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
768 FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
769 FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
770 echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
771 exit ;;
777 FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
778 FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
779 echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
780 exit ;;
772781 5000:UNIX_System_V:4.*:*)
773 FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
774 FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
775 echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
782 FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
783 FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
784 echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
776785 exit ;;
777786 i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
778787 echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
784793 echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
785794 exit ;;
786795 *:FreeBSD:*:*)
787 case ${UNAME_MACHINE} in
788 pc98)
789 echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
796 UNAME_PROCESSOR=`/usr/bin/uname -p`
797 case ${UNAME_PROCESSOR} in
790798 amd64)
791799 echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
792800 *)
793 echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
801 echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
794802 esac
795803 exit ;;
796804 i*:CYGWIN*:*)
797805 echo ${UNAME_MACHINE}-pc-cygwin
798806 exit ;;
807 *:MINGW64*:*)
808 echo ${UNAME_MACHINE}-pc-mingw64
809 exit ;;
799810 *:MINGW*:*)
800811 echo ${UNAME_MACHINE}-pc-mingw32
801812 exit ;;
813 i*:MSYS*:*)
814 echo ${UNAME_MACHINE}-pc-msys
815 exit ;;
802816 i*:windows32*:*)
803 # uname -m includes "-pc" on this system.
804 echo ${UNAME_MACHINE}-mingw32
817 # uname -m includes "-pc" on this system.
818 echo ${UNAME_MACHINE}-mingw32
805819 exit ;;
806820 i*:PW*:*)
807821 echo ${UNAME_MACHINE}-pc-pw32
808822 exit ;;
809 *:Interix*:[3456]*)
810 case ${UNAME_MACHINE} in
823 *:Interix*:*)
824 case ${UNAME_MACHINE} in
811825 x86)
812826 echo i586-pc-interix${UNAME_RELEASE}
813827 exit ;;
814 EM64T | authenticamd | genuineintel)
828 authenticamd | genuineintel | EM64T)
815829 echo x86_64-unknown-interix${UNAME_RELEASE}
816830 exit ;;
817831 IA64)
852866 exit ;;
853867 i*86:Minix:*:*)
854868 echo ${UNAME_MACHINE}-pc-minix
869 exit ;;
870 aarch64:Linux:*:*)
871 echo ${UNAME_MACHINE}-unknown-linux-gnu
872 exit ;;
873 aarch64_be:Linux:*:*)
874 UNAME_MACHINE=aarch64_be
875 echo ${UNAME_MACHINE}-unknown-linux-gnu
855876 exit ;;
856877 alpha:Linux:*:*)
857878 case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
862883 EV6) UNAME_MACHINE=alphaev6 ;;
863884 EV67) UNAME_MACHINE=alphaev67 ;;
864885 EV68*) UNAME_MACHINE=alphaev68 ;;
865 esac
886 esac
866887 objdump --private-headers /bin/sh | grep -q ld.so.1
867888 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
868889 echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
874895 then
875896 echo ${UNAME_MACHINE}-unknown-linux-gnu
876897 else
877 echo ${UNAME_MACHINE}-unknown-linux-gnueabi
898 case `sed -n '/^Hardware/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
899 BCM2708) MANUFACTURER=raspberry;;
900 *) MANUFACTURER=unknown;;
901 esac
902 if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
903 | grep -q __ARM_PCS_VFP
904 then
905 echo ${UNAME_MACHINE}-${MANUFACTURER}-linux-gnueabi
906 else
907 echo ${UNAME_MACHINE}-${MANUFACTURER}-linux-gnueabihf
908 fi
878909 fi
879910 exit ;;
880911 avr32*:Linux:*:*)
881912 echo ${UNAME_MACHINE}-unknown-linux-gnu
882913 exit ;;
883914 cris:Linux:*:*)
884 echo cris-axis-linux-gnu
915 echo ${UNAME_MACHINE}-axis-linux-gnu
885916 exit ;;
886917 crisv32:Linux:*:*)
887 echo crisv32-axis-linux-gnu
918 echo ${UNAME_MACHINE}-axis-linux-gnu
888919 exit ;;
889920 frv:Linux:*:*)
890 echo frv-unknown-linux-gnu
921 echo ${UNAME_MACHINE}-unknown-linux-gnu
922 exit ;;
923 hexagon:Linux:*:*)
924 echo ${UNAME_MACHINE}-unknown-linux-gnu
891925 exit ;;
892926 i*86:Linux:*:*)
893 echo ${UNAME_MACHINE}-pc-linux-gnu
927 LIBC=gnu
928 eval $set_cc_for_build
929 sed 's/^ //' << EOF >$dummy.c
930 #ifdef __dietlibc__
931 LIBC=dietlibc
932 #endif
933 EOF
934 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
935 echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
894936 exit ;;
895937 ia64:Linux:*:*)
896938 echo ${UNAME_MACHINE}-unknown-linux-gnu
917959 #endif
918960 #endif
919961 EOF
920 eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
921 /^CPU/{
922 s: ::g
923 p
924 }'`"
962 eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
925963 test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
926964 ;;
927965 or32:Linux:*:*)
928 echo or32-unknown-linux-gnu
966 echo ${UNAME_MACHINE}-unknown-linux-gnu
929967 exit ;;
930968 padre:Linux:*:*)
931969 echo sparc-unknown-linux-gnu
951989 echo ${UNAME_MACHINE}-ibm-linux
952990 exit ;;
953991 sh64*:Linux:*:*)
954 echo ${UNAME_MACHINE}-unknown-linux-gnu
992 echo ${UNAME_MACHINE}-unknown-linux-gnu
955993 exit ;;
956994 sh*:Linux:*:*)
957995 echo ${UNAME_MACHINE}-unknown-linux-gnu
959997 sparc:Linux:*:* | sparc64:Linux:*:*)
960998 echo ${UNAME_MACHINE}-unknown-linux-gnu
961999 exit ;;
1000 tile*:Linux:*:*)
1001 echo ${UNAME_MACHINE}-unknown-linux-gnu
1002 exit ;;
9621003 vax:Linux:*:*)
9631004 echo ${UNAME_MACHINE}-dec-linux-gnu
9641005 exit ;;
9651006 x86_64:Linux:*:*)
966 echo x86_64-unknown-linux-gnu
1007 echo ${UNAME_MACHINE}-unknown-linux-gnu
9671008 exit ;;
9681009 xtensa*:Linux:*:*)
969 echo ${UNAME_MACHINE}-unknown-linux-gnu
1010 echo ${UNAME_MACHINE}-unknown-linux-gnu
9701011 exit ;;
9711012 i*86:DYNIX/ptx:4*:*)
9721013 # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
9751016 echo i386-sequent-sysv4
9761017 exit ;;
9771018 i*86:UNIX_SV:4.2MP:2.*)
978 # Unixware is an offshoot of SVR4, but it has its own version
979 # number series starting with 2...
980 # I am not positive that other SVR4 systems won't match this,
1019 # Unixware is an offshoot of SVR4, but it has its own version
1020 # number series starting with 2...
1021 # I am not positive that other SVR4 systems won't match this,
9811022 # I just have to hope. -- rms.
982 # Use sysv4.2uw... so that sysv4* matches it.
1023 # Use sysv4.2uw... so that sysv4* matches it.
9831024 echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
9841025 exit ;;
9851026 i*86:OS/2:*:*)
10111052 fi
10121053 exit ;;
10131054 i*86:*:5:[678]*)
1014 # UnixWare 7.x, OpenUNIX and OpenServer 6.
1055 # UnixWare 7.x, OpenUNIX and OpenServer 6.
10151056 case `/bin/uname -X | grep "^Machine"` in
10161057 *486*) UNAME_MACHINE=i486 ;;
10171058 *Pentium) UNAME_MACHINE=i586 ;;
10391080 exit ;;
10401081 pc:*:*:*)
10411082 # Left here for compatibility:
1042 # uname -m prints for DJGPP always 'pc', but it prints nothing about
1043 # the processor, so we play safe by assuming i586.
1083 # uname -m prints for DJGPP always 'pc', but it prints nothing about
1084 # the processor, so we play safe by assuming i586.
10441085 # Note: whatever this is, it MUST be the same as what config.sub
10451086 # prints for the "djgpp" host, or else GDB configury will decide that
10461087 # this is a cross-build.
10471088 echo i586-pc-msdosdjgpp
1048 exit ;;
1089 exit ;;
10491090 Intel:Mach:3*:*)
10501091 echo i386-pc-mach3
10511092 exit ;;
10801121 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
10811122 && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
10821123 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
1083 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1084 && { echo i486-ncr-sysv4; exit; } ;;
1124 /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1125 && { echo i486-ncr-sysv4; exit; } ;;
10851126 NCR*:*:4.2:* | MPRAS*:*:4.2:*)
10861127 OS_REL='.3'
10871128 test -r /etc/.relid \
11241165 echo ns32k-sni-sysv
11251166 fi
11261167 exit ;;
1127 PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
1128 # says <Richard.M.Bartel@ccMail.Census.GOV>
1129 echo i586-unisys-sysv4
1130 exit ;;
1168 PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
1169 # says <Richard.M.Bartel@ccMail.Census.GOV>
1170 echo i586-unisys-sysv4
1171 exit ;;
11311172 *:UNIX_System_V:4*:FTX*)
11321173 # From Gerald Hewes <hewes@openmarket.com>.
11331174 # How about differentiating between stratus architectures? -djm
11531194 exit ;;
11541195 R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
11551196 if [ -d /usr/nec ]; then
1156 echo mips-nec-sysv${UNAME_RELEASE}
1197 echo mips-nec-sysv${UNAME_RELEASE}
11571198 else
1158 echo mips-unknown-sysv${UNAME_RELEASE}
1159 fi
1160 exit ;;
1199 echo mips-unknown-sysv${UNAME_RELEASE}
1200 fi
1201 exit ;;
11611202 BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
11621203 echo powerpc-be-beos
11631204 exit ;;
11691210 exit ;;
11701211 BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
11711212 echo i586-pc-haiku
1213 exit ;;
1214 x86_64:Haiku:*:*)
1215 echo x86_64-unknown-haiku
11721216 exit ;;
11731217 SX-4:SUPER-UX:*:*)
11741218 echo sx4-nec-superux${UNAME_RELEASE}
12221266 *:QNX:*:4*)
12231267 echo i386-pc-qnx
12241268 exit ;;
1225 NSE-?:NONSTOP_KERNEL:*:*)
1269 NEO-?:NONSTOP_KERNEL:*:*)
1270 echo neo-tandem-nsk${UNAME_RELEASE}
1271 exit ;;
1272 NSE-*:NONSTOP_KERNEL:*:*)
12261273 echo nse-tandem-nsk${UNAME_RELEASE}
12271274 exit ;;
12281275 NSR-?:NONSTOP_KERNEL:*:*)
12671314 echo pdp10-unknown-its
12681315 exit ;;
12691316 SEI:*:*:SEIUX)
1270 echo mips-sei-seiux${UNAME_RELEASE}
1317 echo mips-sei-seiux${UNAME_RELEASE}
12711318 exit ;;
12721319 *:DragonFly:*:*)
12731320 echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
12741321 exit ;;
12751322 *:*VMS:*:*)
1276 UNAME_MACHINE=`(uname -p) 2>/dev/null`
1323 UNAME_MACHINE=`(uname -p) 2>/dev/null`
12771324 case "${UNAME_MACHINE}" in
12781325 A*) echo alpha-dec-vms ; exit ;;
12791326 I*) echo ia64-dec-vms ; exit ;;
12911338 i*86:AROS:*:*)
12921339 echo ${UNAME_MACHINE}-pc-aros
12931340 exit ;;
1341 x86_64:VMkernel:*:*)
1342 echo ${UNAME_MACHINE}-unknown-esx
1343 exit ;;
12941344 esac
1295
1296 #echo '(No uname command or uname output not recognized.)' 1>&2
1297 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
12981345
12991346 eval $set_cc_for_build
13001347 cat >$dummy.c <<EOF
13131360 #include <sys/param.h>
13141361 printf ("m68k-sony-newsos%s\n",
13151362 #ifdef NEWSOS4
1316 "4"
1363 "4"
13171364 #else
1318 ""
1319 #endif
1320 ); exit (0);
1365 ""
1366 #endif
1367 ); exit (0);
13211368 #endif
13221369 #endif
13231370
00 #! /bin/sh
11 # Configuration validation subroutine script.
22 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
4 # Free Software Foundation, Inc.
5
6 timestamp='2009-10-07'
3 # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
4 # 2011, 2012 Free Software Foundation, Inc.
5
6 timestamp='2012-08-18'
77
88 # This file is (in principle) common to ALL GNU software.
99 # The presence of a machine in this file suggests that SOME GNU software
2020 # GNU General Public License for more details.
2121 #
2222 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
25 # 02110-1301, USA.
23 # along with this program; if not, see <http://www.gnu.org/licenses/>.
2624 #
2725 # As a special exception to the GNU General Public License, if you
2826 # distribute this file as part of a program that contains a
7472 version="\
7573 GNU config.sub ($timestamp)
7674
77 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
78 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
75 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
76 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
77 Free Software Foundation, Inc.
7978
8079 This is free software; see the source for copying conditions. There is NO
8180 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
122121 # Here we must recognize all the valid KERNEL-OS combinations.
123122 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
124123 case $maybe_os in
125 nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
126 uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
124 nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
125 linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
126 knetbsd*-gnu* | netbsd*-gnu* | \
127127 kopensolaris*-gnu* | \
128128 storm-chaos* | os2-emx* | rtmk-nova*)
129129 os=-$maybe_os
130130 basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
131 ;;
132 android-linux)
133 os=-linux-android
134 basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
131135 ;;
132136 *)
133137 basic_machine=`echo $1 | sed 's/-[^-]*$//'`
155159 os=
156160 basic_machine=$1
157161 ;;
158 -bluegene*)
159 os=-cnk
162 -bluegene*)
163 os=-cnk
160164 ;;
161165 -sim | -cisco | -oki | -wec | -winbond)
162166 os=
172176 os=-chorusos
173177 basic_machine=$1
174178 ;;
175 -chorusrdb)
176 os=-chorusrdb
179 -chorusrdb)
180 os=-chorusrdb
177181 basic_machine=$1
178 ;;
182 ;;
179183 -hiux*)
180184 os=-hiuxwe2
181185 ;;
219223 ;;
220224 -isc*)
221225 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
226 ;;
227 -lynx*178)
228 os=-lynxos178
229 ;;
230 -lynx*5)
231 os=-lynxos5
222232 ;;
223233 -lynx*)
224234 os=-lynxos
244254 # Some are omitted here because they have special meanings below.
245255 1750a | 580 \
246256 | a29k \
257 | aarch64 | aarch64_be \
247258 | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
248259 | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
249260 | am33_2.0 \
250261 | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
262 | be32 | be64 \
251263 | bfin \
252264 | c4x | clipper \
253265 | d10v | d30v | dlx | dsp16xx \
266 | epiphany \
254267 | fido | fr30 | frv \
255268 | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
269 | hexagon \
256270 | i370 | i860 | i960 | ia64 \
257271 | ip2k | iq2000 \
272 | le32 | le64 \
258273 | lm32 \
259274 | m32c | m32r | m32rle | m68000 | m68k | m88k \
260275 | maxq | mb | microblaze | mcore | mep | metag \
280295 | moxie \
281296 | mt \
282297 | msp430 \
298 | nds32 | nds32le | nds32be \
283299 | nios | nios2 \
284300 | ns16k | ns32k \
301 | open8 \
285302 | or32 \
286303 | pdp10 | pdp11 | pj | pjl \
287 | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
304 | powerpc | powerpc64 | powerpc64le | powerpcle \
288305 | pyramid \
289 | rx \
306 | rl78 | rx \
290307 | score \
291308 | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
292309 | sh64 | sh64le \
293310 | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
294311 | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
295 | spu | strongarm \
296 | tahoe | thumb | tic4x | tic80 | tron \
297 | v850 | v850e \
312 | spu \
313 | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
314 | ubicom32 \
315 | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
298316 | we32k \
299 | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
317 | x86 | xc16x | xstormy16 | xtensa \
300318 | z8k | z80)
301319 basic_machine=$basic_machine-unknown
302320 ;;
303 m6811 | m68hc11 | m6812 | m68hc12 | picochip)
304 # Motorola 68HC11/12.
321 c54x)
322 basic_machine=tic54x-unknown
323 ;;
324 c55x)
325 basic_machine=tic55x-unknown
326 ;;
327 c6x)
328 basic_machine=tic6x-unknown
329 ;;
330 m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
305331 basic_machine=$basic_machine-unknown
306332 os=-none
307333 ;;
309335 ;;
310336 ms1)
311337 basic_machine=mt-unknown
338 ;;
339
340 strongarm | thumb | xscale)
341 basic_machine=arm-unknown
342 ;;
343 xgate)
344 basic_machine=$basic_machine-unknown
345 os=-none
346 ;;
347 xscaleeb)
348 basic_machine=armeb-unknown
349 ;;
350
351 xscaleel)
352 basic_machine=armel-unknown
312353 ;;
313354
314355 # We use `pc' rather than `unknown'
317358 i*86 | x86_64)
318359 basic_machine=$basic_machine-pc
319360 ;;
361 nacl64*)
362 basic_machine=x86_64-pc
363 os=-nacl
364 ;;
365 nacl*)
366 basic_machine=i686-pc
367 os=-nacl
368 ;;
369 pnacl*)
370 # le32-unknown-pnacl comes from http://www.chromium.org/nativeclient/pnacl/stability-of-the-pnacl-bitcode-abi
371 basic_machine=le32-unknown
372 os=-pnacl
373 ;;
320374 # Object if more than one company name word.
321375 *-*-*)
322376 echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
325379 # Recognize the basic CPU types with company name.
326380 580-* \
327381 | a29k-* \
382 | aarch64-* | aarch64_be-* \
328383 | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
329384 | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
330385 | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
331386 | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
332387 | avr-* | avr32-* \
388 | be32-* | be64-* \
333389 | bfin-* | bs2000-* \
334 | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
390 | c[123]* | c30-* | [cjt]90-* | c4x-* \
335391 | clipper-* | craynv-* | cydra-* \
336392 | d10v-* | d30v-* | dlx-* \
337393 | elxsi-* \
338394 | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
339395 | h8300-* | h8500-* \
340396 | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
397 | hexagon-* \
341398 | i*86-* | i860-* | i960-* | ia64-* \
342399 | ip2k-* | iq2000-* \
400 | le32-* | le64-* \
343401 | lm32-* \
344402 | m32c-* | m32r-* | m32rle-* \
345403 | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
365423 | mmix-* \
366424 | mt-* \
367425 | msp430-* \
426 | nds32-* | nds32le-* | nds32be-* \
368427 | nios-* | nios2-* \
369428 | none-* | np1-* | ns16k-* | ns32k-* \
429 | open8-* \
370430 | orion-* \
371431 | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
372 | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
432 | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
373433 | pyramid-* \
374 | romp-* | rs6000-* | rx-* \
434 | rl78-* | romp-* | rs6000-* | rx-* \
375435 | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
376436 | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
377437 | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
378438 | sparclite-* \
379 | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
380 | tahoe-* | thumb-* \
381 | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
439 | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
440 | tahoe-* \
441 | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
442 | tile*-* \
382443 | tron-* \
383 | v850-* | v850e-* | vax-* \
444 | ubicom32-* \
445 | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
446 | vax-* \
384447 | we32k-* \
385 | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
448 | x86-* | x86_64-* | xc16x-* | xps100-* \
386449 | xstormy16-* | xtensa*-* \
387450 | ymp-* \
388451 | z8k-* | z80-*)
407470 basic_machine=a29k-amd
408471 os=-udi
409472 ;;
410 abacus)
473 abacus)
411474 basic_machine=abacus-unknown
412475 ;;
413476 adobe68k)
477540 basic_machine=powerpc-ibm
478541 os=-cnk
479542 ;;
543 c54x-*)
544 basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
545 ;;
546 c55x-*)
547 basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
548 ;;
549 c6x-*)
550 basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
551 ;;
480552 c90)
481553 basic_machine=c90-cray
482554 os=-unicos
483555 ;;
484 cegcc)
556 cegcc)
485557 basic_machine=arm-unknown
486558 os=-cegcc
487559 ;;
513585 basic_machine=craynv-cray
514586 os=-unicosmp
515587 ;;
516 cr16)
588 cr16 | cr16-*)
517589 basic_machine=cr16-unknown
518590 os=-elf
519591 ;;
671743 i370-ibm* | ibm*)
672744 basic_machine=i370-ibm
673745 ;;
674 # I'm not sure what "Sysv32" means. Should this be sysv3.2?
675746 i*86v32)
676747 basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
677748 os=-sysv32
729800 basic_machine=ns32k-utek
730801 os=-sysv
731802 ;;
732 microblaze)
803 microblaze)
733804 basic_machine=microblaze-xilinx
805 ;;
806 mingw64)
807 basic_machine=x86_64-pc
808 os=-mingw64
734809 ;;
735810 mingw32)
736811 basic_machine=i386-pc
768843 ms1-*)
769844 basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
770845 ;;
846 msys)
847 basic_machine=i386-pc
848 os=-msys
849 ;;
771850 mvs)
772851 basic_machine=i370-ibm
773852 os=-mvs
853 ;;
854 nacl)
855 basic_machine=le32-unknown
856 os=-nacl
857 ;;
858 pnacl)
859 basic_machine=le32-unknown
860 os=-pnacl
774861 ;;
775862 ncr3000)
776863 basic_machine=i486-ncr
836923 np1)
837924 basic_machine=np1-gould
838925 ;;
926 neo-tandem)
927 basic_machine=neo-tandem
928 ;;
929 nse-tandem)
930 basic_machine=nse-tandem
931 ;;
839932 nsr-tandem)
840933 basic_machine=nsr-tandem
841934 ;;
9181011 ;;
9191012 power) basic_machine=power-ibm
9201013 ;;
921 ppc) basic_machine=powerpc-unknown
922 ;;
923 ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
1014 ppc | ppcbe) basic_machine=powerpc-unknown
1015 ;;
1016 ppc-* | ppcbe-*)
1017 basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
9241018 ;;
9251019 ppcle | powerpclittle | ppc-le | powerpc-little)
9261020 basic_machine=powerpcle-unknown
10141108 basic_machine=i860-stratus
10151109 os=-sysv4
10161110 ;;
1111 strongarm-* | thumb-*)
1112 basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
1113 ;;
10171114 sun2)
10181115 basic_machine=m68000-sun
10191116 ;;
10701167 basic_machine=t90-cray
10711168 os=-unicos
10721169 ;;
1073 tic54x | c54x*)
1074 basic_machine=tic54x-unknown
1075 os=-coff
1076 ;;
1077 tic55x | c55x*)
1078 basic_machine=tic55x-unknown
1079 os=-coff
1080 ;;
1081 tic6x | c6x*)
1082 basic_machine=tic6x-unknown
1083 os=-coff
1084 ;;
10851170 tile*)
1086 basic_machine=tile-unknown
1171 basic_machine=$basic_machine-unknown
10871172 os=-linux-gnu
10881173 ;;
10891174 tx39)
11521237 ;;
11531238 xps | xps100)
11541239 basic_machine=xps100-honeywell
1240 ;;
1241 xscale-* | xscalee[bl]-*)
1242 basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
11551243 ;;
11561244 ymp)
11571245 basic_machine=ymp-cray
12501338 if [ x"$os" != x"" ]
12511339 then
12521340 case $os in
1253 # First match some system type aliases
1254 # that might get confused with valid system types.
1341 # First match some system type aliases
1342 # that might get confused with valid system types.
12551343 # -solaris* is a basic system type, with this one exception.
1344 -auroraux)
1345 os=-auroraux
1346 ;;
12561347 -solaris1 | -solaris1.*)
12571348 os=`echo $os | sed -e 's|solaris1|sunos4|'`
12581349 ;;
12741365 # -sysv* is not here because it comes later, after sysvr4.
12751366 -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
12761367 | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
1277 | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
1278 | -kopensolaris* \
1368 | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
1369 | -sym* | -kopensolaris* \
12791370 | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
12801371 | -aos* | -aros* \
12811372 | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
12821373 | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
12831374 | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
1284 | -openbsd* | -solidbsd* \
1375 | -bitrig* | -openbsd* | -solidbsd* \
12851376 | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
12861377 | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
12871378 | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
12881379 | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
12891380 | -chorusos* | -chorusrdb* | -cegcc* \
1290 | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
1291 | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
1381 | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
1382 | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
1383 | -linux-newlib* | -linux-musl* | -linux-uclibc* \
12921384 | -uxpv* | -beos* | -mpeix* | -udk* \
12931385 | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
12941386 | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
13081400 ;;
13091401 esac
13101402 ;;
1403 -nacl*)
1404 os=-nacl
1405 ;;
1406 -pnacl*)
1407 os=-pnacl
1408 ;;
13111409 -nto-qnx*)
13121410 ;;
13131411 -nto*)
13351433 -opened*)
13361434 os=-openedition
13371435 ;;
1338 -os400*)
1436 -os400*)
13391437 os=-os400
13401438 ;;
13411439 -wince*)
13841482 -sinix*)
13851483 os=-sysv4
13861484 ;;
1387 -tpf*)
1485 -tpf*)
13881486 os=-tpf
13891487 ;;
13901488 -triton*)
14281526 ;;
14291527 -dicos*)
14301528 os=-dicos
1529 ;;
1530 -nacl*)
1531 os=-nacl
1532 ;;
1533 -pnacl*)
1534 os=-pnacl
14311535 ;;
14321536 -none)
14331537 ;;
14511555 # system, and we'll never get to this point.
14521556
14531557 case $basic_machine in
1454 score-*)
1558 score-*)
14551559 os=-elf
14561560 ;;
1457 spu-*)
1561 spu-*)
14581562 os=-elf
14591563 ;;
14601564 *-acorn)
14661570 arm*-semi)
14671571 os=-aout
14681572 ;;
1469 c4x-* | tic4x-*)
1470 os=-coff
1573 c4x-* | tic4x-*)
1574 os=-coff
1575 ;;
1576 hexagon-*)
1577 os=-elf
1578 ;;
1579 tic54x-*)
1580 os=-coff
1581 ;;
1582 tic55x-*)
1583 os=-coff
1584 ;;
1585 tic6x-*)
1586 os=-coff
14711587 ;;
14721588 # This must come before the *-dec entry.
14731589 pdp10-*)
14871603 ;;
14881604 m68000-sun)
14891605 os=-sunos3
1490 # This also exists in the configure program, but was not the
1491 # default.
1492 # os=-sunos4
14931606 ;;
14941607 m68*-cisco)
14951608 os=-aout
14961609 ;;
1497 mep-*)
1610 mep-*)
14981611 os=-elf
14991612 ;;
15001613 mips*-cisco)
15211634 *-ibm)
15221635 os=-aix
15231636 ;;
1524 *-knuth)
1637 *-knuth)
15251638 os=-mmixware
15261639 ;;
15271640 *-wec)
905905 enable_music_midi_timidity
906906 enable_music_midi_native
907907 enable_music_midi_fluidsynth
908 enable_music_fluidsynth_shared
908 enable_music_midi_fluidsynth_shared
909909 enable_music_ogg
910910 enable_music_ogg_tremor
911911 enable_music_ogg_shared
24382438 #
24392439 MAJOR_VERSION=2
24402440 MINOR_VERSION=0
2441 MICRO_VERSION=0
2442 INTERFACE_AGE=0
2443 BINARY_AGE=0
2441 MICRO_VERSION=1
2442 INTERFACE_AGE=1
2443 BINARY_AGE=1
24442444 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
24452445
24462446
1106411064 *mingw32ce*)
1106511065 #VERSION_SOURCES="$srcdir/version.rc"
1106611066 EXE=".exe"
11067 ;;
11067 ;;
1106811068 *-*-cygwin* | *-*-mingw32*)
1106911069 VERSION_SOURCES="$srcdir/version.rc"
1107011070 EXE=".exe"
1107111071 if test "$build" != "$host"; then # cross-compiling
1107211072 # Default cross-compile location
11073 ac_default_prefix=/usr/local/cross-tools/i386-mingw32
11073 ac_default_prefix=/usr/local/cross-tools/$host
1107411074 else
1107511075 # Look for the location of the tools and install there
1107611076 if test "$BUILD_PREFIX" != ""; then
1114711147 else
1114811148 host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
1114911149 fi
11150 for path in $gcc_bin_path $gcc_lib_path $env_lib_path $host_lib_path; do
11150 for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
1115111151 lib=`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1`
1115211152 if test x$lib != x; then
1115311153 echo $lib
1181611816
1181711817 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
1181811818 $as_echo "no" >&6; }
11819 ac_fn_c_check_header_mongrel "$LINENO" "modplug.h" "ac_cv_header_modplug_h" "$ac_includes_default"
11820 if test "x$ac_cv_header_modplug_h" = xyes; then :
11819 ac_fn_c_check_header_mongrel "$LINENO" "libmodplug/modplug.h" "ac_cv_header_libmodplug_modplug_h" "$ac_includes_default"
11820 if test "x$ac_cv_header_libmodplug_modplug_h" = xyes; then :
1182111821 have_libmodplug_hdr=yes
1182211822 fi
1182311823
1186911869
1187011870
1187111871 elif test $pkg_failed = untried; then
11872 ac_fn_c_check_header_mongrel "$LINENO" "modplug.h" "ac_cv_header_modplug_h" "$ac_includes_default"
11873 if test "x$ac_cv_header_modplug_h" = xyes; then :
11872 ac_fn_c_check_header_mongrel "$LINENO" "libmodplug/modplug.h" "ac_cv_header_libmodplug_modplug_h" "$ac_includes_default"
11873 if test "x$ac_cv_header_libmodplug_modplug_h" = xyes; then :
1187411874 have_libmodplug_hdr=yes
1187511875 fi
1187611876
1195311953 echo "-- dynamic libmodplug -> $modplug_lib"
1195411954 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_DYNAMIC=\\\"$modplug_lib\\\""
1195511955 else
11956 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS"
11956 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS"
1195711957 fi
1195811958 else
1195911959 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)" >&5
1209412094 fi
1209512095
1209612096 if test x$have_libmodplug != xyes -a x$have_libmikmod != xyes ; then
12097 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MOD support disabled" >&5
12097 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MOD support disabled" >&5
1209812098 $as_echo "$as_me: WARNING: MOD support disabled" >&2;}
1209912099 fi
1210012100
1216012160 enable_music_midi_fluidsynth=yes
1216112161 fi
1216212162
12163 # Check whether --enable-music-fluidsynth-shared was given.
12164 if test "${enable_music_fluidsynth_shared+set}" = set; then :
12165 enableval=$enable_music_fluidsynth_shared;
12163 # Check whether --enable-music-midi-fluidsynth-shared was given.
12164 if test "${enable_music_midi_fluidsynth_shared+set}" = set; then :
12165 enableval=$enable_music_midi_fluidsynth_shared;
1216612166 else
1216712167 enable_music_midi_fluidsynth_shared=yes
1216812168 fi
1225012250 if test x$enable_music_midi_timidity != xyes -a \
1225112251 x$use_music_midi_native != xyes -a x$use_music_midi_native != xyes_cpp -a \
1225212252 x$have_fluidsynth != xyes; then
12253 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MIDI support disabled" >&5
12253 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MIDI support disabled" >&5
1225412254 $as_echo "$as_me: WARNING: MIDI support disabled" >&2;}
1225512255 fi
1225612256
1289612896 $as_echo "$have_libmad" >&6; }
1289712897 if test x$have_libmad = xyes; then
1289812898 SOURCES="$SOURCES $srcdir/music_mad.c"
12899 if echo "$SOURCES" | grep "load_mp3.c" >/dev/null; then
12900 :
12901 else
12902 SOURCES="$SOURCES $srcdir/load_mp3.c"
12903 fi
1289912904 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MAD_MUSIC"
1290012905 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad"
1290112906 else
1313 #
1414 MAJOR_VERSION=2
1515 MINOR_VERSION=0
16 MICRO_VERSION=0
17 INTERFACE_AGE=0
18 BINARY_AGE=0
16 MICRO_VERSION=1
17 INTERFACE_AGE=1
18 BINARY_AGE=1
1919 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
2020
2121 AC_SUBST(MAJOR_VERSION)
114114 *mingw32ce*)
115115 #VERSION_SOURCES="$srcdir/version.rc"
116116 EXE=".exe"
117 ;;
117 ;;
118118 *-*-cygwin* | *-*-mingw32*)
119119 VERSION_SOURCES="$srcdir/version.rc"
120120 EXE=".exe"
121121 if test "$build" != "$host"; then # cross-compiling
122122 # Default cross-compile location
123 ac_default_prefix=/usr/local/cross-tools/i386-mingw32
123 ac_default_prefix=/usr/local/cross-tools/$host
124124 else
125125 # Look for the location of the tools and install there
126126 if test "$BUILD_PREFIX" != ""; then
185185 else
186186 host_lib_path="/usr/$base_libdir /usr/local/$base_libdir"
187187 fi
188 for path in $gcc_bin_path $gcc_lib_path $env_lib_path $host_lib_path; do
188 for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do
189189 lib=[`ls -- $path/$1 2>/dev/null | sed -e '/\.so\..*\./d' -e 's,.*/,,' | sort | tail -1`]
190190 if test x$lib != x; then
191191 echo $lib
256256 have_libmodplug_hdr=yes
257257 have_libmodplug_lib=yes
258258 ], [dnl
259 AC_CHECK_HEADER([modplug.h], [have_libmodplug_hdr=yes])
259 AC_CHECK_HEADER([libmodplug/modplug.h], [have_libmodplug_hdr=yes])
260260 AC_CHECK_LIB([modplug], [have_libmodplug_lib=yes])
261261 ])
262262
282282 echo "-- dynamic libmodplug -> $modplug_lib"
283283 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMODPLUG_DYNAMIC=\\\"$modplug_lib\\\""
284284 else
285 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS"
285 EXTRA_LDFLAGS="$EXTRA_LDFLAGS $MODPLUG_LIBS"
286286 fi
287287 else
288288 AC_MSG_WARN([*** Unable to find ModPlug library (http://modplug-xmms.sourceforge.net/)])
358358 fi
359359
360360 if test x$have_libmodplug != xyes -a x$have_libmikmod != xyes ; then
361 AC_MSG_WARN([MOD support disabled])
361 AC_MSG_WARN([MOD support disabled])
362362 fi
363363
364364 AC_ARG_ENABLE([music-midi],
407407 AC_ARG_ENABLE([music-midi-fluidsynth],
408408 AC_HELP_STRING([--enable-music-midi-fluidsynth], [enable FluidSynth MIDI output [[default=yes]]]),
409409 [], [enable_music_midi_fluidsynth=yes])
410 AC_ARG_ENABLE([music-fluidsynth-shared],
410 AC_ARG_ENABLE([music-midi-fluidsynth-shared],
411411 AC_HELP_STRING([--enable-music-midi-fluidsynth-shared], [dynamically load FluidSynth library [[default=yes]]]),
412412 [], [enable_music_midi_fluidsynth_shared=yes])
413413 if test x$enable_music_midi_fluidsynth = xyes; then
447447 if test x$enable_music_midi_timidity != xyes -a \
448448 x$use_music_midi_native != xyes -a x$use_music_midi_native != xyes_cpp -a \
449449 x$have_fluidsynth != xyes; then
450 AC_MSG_WARN([MIDI support disabled])
450 AC_MSG_WARN([MIDI support disabled])
451451 fi
452452
453453 AC_ARG_ENABLE([music-ogg],
636636 AC_MSG_RESULT($have_libmad)
637637 if test x$have_libmad = xyes; then
638638 SOURCES="$SOURCES $srcdir/music_mad.c"
639 if echo "$SOURCES" | grep "load_mp3.c" >/dev/null; then
640 :
641 else
642 SOURCES="$SOURCES $srcdir/load_mp3.c"
643 fi
639644 EXTRA_CFLAGS="$EXTRA_CFLAGS -DMP3_MAD_MUSIC"
640645 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lmad"
641646 else
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
2020
2121 #ifdef MODPLUG_MUSIC
2222
23 #include "modplug.h"
23 #ifdef MODPLUG_HEADER
24 #include MODPLUG_HEADER
25 #else
26 #include <libmodplug/modplug.h>
27 #endif
2428
2529 typedef struct {
2630 int loaded;
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
1919 */
2020
2121 #ifdef OGG_MUSIC
22 #ifdef OGG_USE_TREMOR
23 #include <ivorbisfile.h>
22 #if defined(OGG_HEADER)
23 #include OGG_HEADER
24 #elif defined(OGG_USE_TREMOR)
25 #include <tremor/ivorbisfile.h>
2426 #else
2527 #include <vorbis/vorbisfile.h>
2628 #endif
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
123123 if ((buffer = (char*) SDL_malloc(size))) {
124124 if(SDL_RWread(src, buffer, size, 1) == 1) {
125125 if (fluidsynth.fluid_player_add_mem(song->player, buffer, size) == FLUID_OK) {
126 SDL_free(buffer);
126127 return 1;
127128 } else {
128129 Mix_SetError("FluidSynth failed to load in-memory song");
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This is the source needed to decode an MP3 into a waveform.
21 */
22
23 /* $Id$ */
24
25 #if defined(MP3_MUSIC) || defined(MP3_MAD_MUSIC)
26
27 #include "SDL_mixer.h"
28
29 #include "load_mp3.h"
30
31 #if defined(MP3_MUSIC)
32 #include "dynamic_mp3.h"
33 #elif defined(MP3_MAD_MUSIC)
34 #include "music_mad.h"
35 #endif
36
37 SDL_AudioSpec *Mix_LoadMP3_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
38 {
39 /* note: spec is initialized to mixer spec */
40
41 #if defined(MP3_MUSIC)
42 SMPEG* mp3;
43 SMPEG_Info info;
44 #elif defined(MP3_MAD_MUSIC)
45 mad_data *mp3_mad;
46 #endif
47 long samplesize;
48 int read_len;
49 const Uint32 chunk_len = 4096;
50 int err = 0;
51
52 if ((!src) || (!spec) || (!audio_buf) || (!audio_len))
53 {
54 return NULL;
55 }
56
57 if (!err)
58 {
59 *audio_len = 0;
60 *audio_buf = (Uint8*) SDL_malloc(chunk_len);
61 err = (*audio_buf == NULL);
62 }
63
64 if (!err)
65 {
66 err = ((Mix_Init(MIX_INIT_MP3) & MIX_INIT_MP3) == 0);
67 }
68
69 if (!err)
70 {
71 #if defined(MP3_MUSIC)
72 mp3 = smpeg.SMPEG_new_rwops(src, &info, freesrc, 0);
73 err = (mp3 == NULL);
74 #elif defined(MP3_MAD_MUSIC)
75 mp3_mad = mad_openFileRW(src, spec, freesrc);
76 err = (mp3_mad == NULL);
77 #endif
78 }
79
80 #if defined(MP3_MUSIC)
81 if (!err)
82 {
83 err = !info.has_audio;
84 }
85 #endif
86
87 if (!err)
88 {
89 #if defined(MP3_MUSIC)
90
91 smpeg.SMPEG_actualSpec(mp3, spec);
92
93 smpeg.SMPEG_enableaudio(mp3, 1);
94 smpeg.SMPEG_enablevideo(mp3, 0);
95
96 smpeg.SMPEG_play(mp3);
97
98 /* read once for audio length */
99 while ((read_len = smpeg.SMPEG_playAudio(mp3, *audio_buf, chunk_len)) > 0)
100 {
101 *audio_len += read_len;
102 }
103
104 smpeg.SMPEG_stop(mp3);
105
106 #elif defined(MP3_MAD_MUSIC)
107
108 mad_start(mp3_mad);
109
110 /* read once for audio length */
111 while ((read_len = mad_getSamples(mp3_mad, *audio_buf, chunk_len)) > 0)
112 {
113 *audio_len += read_len;
114 }
115
116 mad_stop(mp3_mad);
117
118 #endif
119
120 err = (read_len < 0);
121 }
122
123 if (!err)
124 {
125 /* reallocate, if needed */
126 if ((*audio_len > 0) && (*audio_len != chunk_len))
127 {
128 *audio_buf = (Uint8*) SDL_realloc(*audio_buf, *audio_len);
129 err = (*audio_buf == NULL);
130 }
131 }
132
133 if (!err)
134 {
135 /* read again for audio buffer, if needed */
136 if (*audio_len > chunk_len)
137 {
138 #if defined(MP3_MUSIC)
139 smpeg.SMPEG_rewind(mp3);
140 smpeg.SMPEG_play(mp3);
141 err = (*audio_len != smpeg.SMPEG_playAudio(mp3, *audio_buf, *audio_len));
142 smpeg.SMPEG_stop(mp3);
143 #elif defined(MP3_MAD_MUSIC)
144 mad_seek(mp3_mad, 0);
145 mad_start(mp3_mad);
146 err = (*audio_len != mad_getSamples(mp3_mad, *audio_buf, *audio_len));
147 mad_stop(mp3_mad);
148 #endif
149 }
150 }
151
152 if (!err)
153 {
154 /* Don't return a buffer that isn't a multiple of samplesize */
155 samplesize = ((spec->format & 0xFF)/8)*spec->channels;
156 *audio_len &= ~(samplesize-1);
157 }
158
159 #if defined(MP3_MUSIC)
160 if (mp3)
161 {
162 smpeg.SMPEG_delete(mp3); mp3 = NULL;
163 /* Deleting the MP3 closed the source if desired */
164 freesrc = SDL_FALSE;
165 }
166 #elif defined(MP3_MAD_MUSIC)
167 if (mp3_mad)
168 {
169 mad_closeFile(mp3_mad); mp3_mad = NULL;
170 /* Deleting the MP3 closed the source if desired */
171 freesrc = SDL_FALSE;
172 }
173 #endif
174
175 if (freesrc)
176 {
177 SDL_RWclose(src); src = NULL;
178 }
179
180 /* handle error */
181 if (err)
182 {
183 if (*audio_buf != NULL)
184 {
185 SDL_free(*audio_buf); *audio_buf = NULL;
186 }
187 *audio_len = 0;
188 spec = NULL;
189 }
190
191 return spec;
192 }
193
194 #endif
0 /*
1 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 This is the source needed to decode an MP3 into a waveform.
21 */
22
23 /* $Id$ */
24
25 #if defined(MP3_MUSIC) || defined(MP3_MAD_MUSIC)
26 /* Don't call this directly; use Mix_LoadWAV_RW() for now. */
27 SDL_AudioSpec *Mix_LoadMP3_RW (SDL_RWops *src, int freesrc,
28 SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
29 #endif
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
4242 return SDL_RWread((SDL_RWops*)datasource, ptr, size, nmemb);
4343 }
4444
45 static Sint64 sdl_seek_func(void *datasource, ogg_int64_t offset, int whence)
45 static int sdl_seek_func(void *datasource, ogg_int64_t offset, int whence)
4646 {
47 return SDL_RWseek((SDL_RWops*)datasource, offset, whence);
47 return (int)SDL_RWseek((SDL_RWops*)datasource, offset, whence);
4848 }
4949
50 static Sint64 sdl_close_func_freesrc(void *datasource)
50 static int sdl_close_func_freesrc(void *datasource)
5151 {
5252 return SDL_RWclose((SDL_RWops*)datasource);
5353 }
5454
55 static Sint64 sdl_close_func_nofreesrc(void *datasource)
55 static int sdl_close_func_nofreesrc(void *datasource)
5656 {
57 return SDL_RWseek((SDL_RWops*)datasource, 0, RW_SEEK_SET);
57 SDL_RWseek((SDL_RWops*)datasource, 0, RW_SEEK_SET);
58 return 0;
5859 }
5960
60 static Sint64 sdl_tell_func(void *datasource)
61 static long sdl_tell_func(void *datasource)
6162 {
62 return SDL_RWtell((SDL_RWops*)datasource);
63 return (long)SDL_RWtell((SDL_RWops*)datasource);
6364 }
6465
6566
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
3131 #include "SDL_mixer.h"
3232 #include "load_aiff.h"
3333 #include "load_voc.h"
34 #include "load_mp3.h"
3435 #include "load_ogg.h"
3536 #include "load_flac.h"
3637 #include "dynamic_flac.h"
38 #include "dynamic_fluidsynth.h"
3739 #include "dynamic_modplug.h"
3840 #include "dynamic_mod.h"
3941 #include "dynamic_mp3.h"
181183 result |= MIX_INIT_MOD;
182184 }
183185 #else
184 Mix_SetError("Mixer not built with MOD timidity support");
186 Mix_SetError("Mixer not built with MOD mikmod support");
185187 #endif
186188 }
187189 if (flags & MIX_INIT_MP3) {
189191 if ((initialized & MIX_INIT_MP3) || Mix_InitMP3() == 0) {
190192 result |= MIX_INIT_MP3;
191193 }
194 #elif defined(MP3_MAD_MUSIC)
195 result |= MIX_INIT_MP3;
192196 #else
193197 Mix_SetError("Mixer not built with MP3 support");
194198 #endif
317321 /* Mix any playing channels... */
318322 sdl_ticks = SDL_GetTicks();
319323 for ( i=0; i<num_channels; ++i ) {
320 if( ! mix_channel[i].paused ) {
324 if ( !mix_channel[i].paused ) {
321325 if ( mix_channel[i].expire > 0 && mix_channel[i].expire < sdl_ticks ) {
322326 /* Expiration delay for that channel is reached */
323327 mix_channel[i].playing = 0;
327331 _Mix_channel_done_playing(i);
328332 } else if ( mix_channel[i].fading != MIX_NO_FADING ) {
329333 Uint32 ticks = sdl_ticks - mix_channel[i].ticks_fade;
330 if( ticks > mix_channel[i].fade_length ) {
334 if ( ticks >= mix_channel[i].fade_length ) {
331335 Mix_Volume(i, mix_channel[i].fade_volume_reset); /* Restore the volume */
332336 if( mix_channel[i].fading == MIX_FADING_OUT ) {
333337 mix_channel[i].playing = 0;
337341 }
338342 mix_channel[i].fading = MIX_NO_FADING;
339343 } else {
340 if( mix_channel[i].fading == MIX_FADING_OUT ) {
344 if ( mix_channel[i].fading == MIX_FADING_OUT ) {
341345 Mix_Volume(i, (mix_channel[i].fade_volume * (mix_channel[i].fade_length-ticks))
342346 / mix_channel[i].fade_length );
343347 } else {
491495 #endif
492496 #ifdef FLAC_MUSIC
493497 add_chunk_decoder("FLAC");
498 #endif
499 #if defined(MP3_MUSIC) || defined(MP3_MAD_MUSIC)
500 add_chunk_decoder("MP3");
494501 #endif
495502
496503 audio_opened = 1;
556563 return(audio_opened);
557564 }
558565
559
560 /*
561 * !!! FIXME: Ideally, we want a Mix_LoadSample_RW(), which will handle the
562 * generic setup, then call the correct file format loader.
563 */
566 static int detect_mp3(Uint8 *magic)
567 {
568 if ( strncmp((char *)magic, "ID3", 3) == 0 ) {
569 return 1;
570 }
571
572 /* Detection code lifted from SMPEG */
573 if(((magic[0] & 0xff) != 0xff) || // No sync bits
574 ((magic[1] & 0xf0) != 0xf0) || //
575 ((magic[2] & 0xf0) == 0x00) || // Bitrate is 0
576 ((magic[2] & 0xf0) == 0xf0) || // Bitrate is 15
577 ((magic[2] & 0x0c) == 0x0c) || // Frequency is 3
578 ((magic[1] & 0x06) == 0x00)) { // Layer is 4
579 return(0);
580 }
581 return 1;
582 }
564583
565584 /* Load a wave file */
566585 Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc)
628647 (Uint8 **)&chunk->abuf, &chunk->alen);
629648 break;
630649 default:
650 #if defined(MP3_MUSIC) || defined(MP3_MAD_MUSIC)
651 if (detect_mp3((Uint8*)&magic))
652 {
653 /* note: send a copy of the mixer spec */
654 wavespec = mixer;
655 loaded = Mix_LoadMP3_RW(src, freesrc, &wavespec,
656 (Uint8 **)&chunk->abuf, &chunk->alen);
657 break;
658 }
659 #endif
631660 SDL_SetError("Unrecognized sound file type");
632661 if ( freesrc ) {
633662 SDL_RWclose(src);
10661095 (mix_channel[which].fading != MIX_FADING_OUT) ) {
10671096 mix_channel[which].fade_volume = mix_channel[which].volume;
10681097 mix_channel[which].fading = MIX_FADING_OUT;
1069 mix_channel[which].fade_length = ms;
1098 mix_channel[which].fade_length = (Uint32)ms;
10701099 mix_channel[which].ticks_fade = SDL_GetTicks();
10711100
10721101 /* only change fade_volume_reset if we're not fading. */
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
573573
574574 /* We need to know if a specific error occurs; if not, we'll set a
575575 * generic one, so we clear the current one. */
576 Mix_SetError("");
576 SDL_ClearError();
577577 music = Mix_LoadMUSType_RW(src, type, SDL_TRUE);
578578 if ( music == NULL && Mix_GetError()[0] == '\0' ) {
579579 Mix_SetError("Unrecognized music format");
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
2020
2121 #ifdef MODPLUG_MUSIC
2222
23 #include "modplug.h"
23 #ifdef MODPLUG_HEADER
24 #include MODPLUG_HEADER
25 #else
26 #include <libmodplug/modplug.h>
27 #endif
2428 #include "SDL_rwops.h"
2529 #include "SDL_audio.h"
2630 #include "SDL_mixer.h"
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
5555 return SDL_RWread((SDL_RWops*)datasource, ptr, size, nmemb);
5656 }
5757
58 static Sint64 sdl_seek_func(void *datasource, ogg_int64_t offset, int whence)
59 {
60 return SDL_RWseek((SDL_RWops*)datasource, offset, whence);
61 }
62
63 static Sint64 sdl_tell_func(void *datasource)
64 {
65 return SDL_RWtell((SDL_RWops*)datasource);
58 static int sdl_seek_func(void *datasource, ogg_int64_t offset, int whence)
59 {
60 return (int)SDL_RWseek((SDL_RWops*)datasource, offset, whence);
61 }
62
63 static long sdl_tell_func(void *datasource)
64 {
65 return (long)SDL_RWtell((SDL_RWops*)datasource);
6666 }
6767
6868 /* Load an OGG stream from an SDL_RWops object */
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
2424
2525 /* This file supports Ogg Vorbis music streams */
2626
27 #ifdef OGG_USE_TREMOR
28 #include <ivorbisfile.h>
27 #if defined(OGG_HEADER)
28 #include OGG_HEADER
29 #elif defined(OGG_USE_TREMOR)
30 #include <tremor/ivorbisfile.h>
2931 #else
3032 #include <vorbis/vorbisfile.h>
3133 #endif
229229 return NULL;
230230
231231 track = (MIDIEvent**) calloc(1, sizeof(MIDIEvent*) * mididata->nTracks);
232 if (NULL == head)
232
233 if (NULL == track)
233234 return NULL;
234235
235236 /* First, convert all tracks to MIDIEvent lists */
00 /*
11 PLAYMUS: A test application for the SDL mixer library.
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
00 /*
11 PLAYWAVE: A test application for the SDL mixer library.
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
325325 {
326326 int note = voice[v].sample->note_to_use;
327327 if (note>0 && drumvolume[chan][note]>=0) vol = drumvolume[chan][note];
328 if (note>0 && drumpanpot[chan][note]>=0) panning = drumvolume[chan][note];
328 if (note>0 && drumpanpot[chan][note]>=0) panning = drumpanpot[chan][note];
329329 }
330330
331331 if (opt_expression_curve == 2) curved_expression = 127.0 * vol_table[expr];
672672 meep->event.time, meep->event.channel + 1,
673673 meep->event.type, meep->event.a, meep->event.b);
674674
675 if (meep->event.channel >= MAXCHAN)
676 skip_this_event=1;
677 else if (meep->event.type==ME_TEMPO)
675 if (meep->event.type==ME_TEMPO)
678676 {
679677 tempo=
680678 meep->event.channel + meep->event.b * 256 + meep->event.a * 65536;
681679 compute_sample_increment(tempo, divisions);
682680 skip_this_event=1;
683681 }
682 else if (meep->event.channel >= MAXCHAN)
683 skip_this_event=1;
684684 else if ((quietchannels & (1<<meep->event.channel)))
685685 skip_this_event=1;
686686 else switch (meep->event.type)
5555 line++;
5656 w[words=0]=strtok(tmp, " \t\r\n\240");
5757 if (!w[0] || (*w[0]=='#')) continue;
58 while (w[words] && (words < MAXWORDS))
58 while (w[words] && (words < (MAXWORDS-1)))
5959 {
6060 w[++words]=strtok(0," \t\r\n\240");
6161 if (w[words] && w[words][0]=='#') break;
6767 {
6868 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
6969 "%s: line %d: No directory given\n", name, line);
70 close_file(fp);
7071 return -2;
7172 }
7273 for (i=1; i<words; i++)
7879 {
7980 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
8081 "%s: line %d: No file name given\n", name, line);
82 close_file(fp);
8183 return -2;
8284 }
8385 for (i=1; i<words; i++)
9496 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
9597 "%s: line %d: Must specify exactly one patch name\n",
9698 name, line);
99 close_file(fp);
97100 return -2;
98101 }
99102 strncpy(def_instr_name, w[1], 255);
106109 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
107110 "%s: line %d: No drum set number given\n",
108111 name, line);
112 close_file(fp);
109113 return -2;
110114 }
111115 i=atoi(w[1]);
114118 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
115119 "%s: line %d: Drum set must be between 0 and 127\n",
116120 name, line);
121 close_file(fp);
117122 return -2;
118123 }
119124 if (!drumset[i])
130135 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
131136 "%s: line %d: No bank number given\n",
132137 name, line);
138 close_file(fp);
133139 return -2;
134140 }
135141 i=atoi(w[1]);
138144 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
139145 "%s: line %d: Tone bank must be between 0 and 127\n",
140146 name, line);
147 close_file(fp);
141148 return -2;
142149 }
143150 if (!tonebank[i])
160167 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
161168 "%s: line %d: Program must be between 0 and 127\n",
162169 name, line);
170 close_file(fp);
163171 return -2;
164172 }
165173 if (!bank)
168176 "%s: line %d: Must specify tone bank or drum set "
169177 "before assignment\n",
170178 name, line);
179 close_file(fp);
171180 return -2;
172181 }
173182 if (bank->tone[i].name)
183192 {
184193 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: line %d: bad patch option %s\n",
185194 name, line, w[j]);
195 close_file(fp);
186196 return -2;
187197 }
188198 *cp++=0;
194204 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
195205 "%s: line %d: amplification must be between "
196206 "0 and %d\n", name, line, MAX_AMPLIFICATION);
207 close_file(fp);
197208 return -2;
198209 }
199210 bank->tone[i].amp=k;
206217 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
207218 "%s: line %d: note must be between 0 and 127\n",
208219 name, line);
220 close_file(fp);
209221 return -2;
210222 }
211223 bank->tone[i].note=k;
227239 "%s: line %d: panning must be left, right, "
228240 "center, or between -100 and 100\n",
229241 name, line);
242 close_file(fp);
230243 return -2;
231244 }
232245 bank->tone[i].pan=k;
241254 {
242255 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
243256 "%s: line %d: keep must be env or loop\n", name, line);
257 close_file(fp);
244258 return -2;
245259 }
246260 }
257271 ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
258272 "%s: line %d: strip must be env, loop, or tail\n",
259273 name, line);
274 close_file(fp);
260275 return -2;
261276 }
262277 }
264279 {
265280 ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: line %d: bad patch option %s\n",
266281 name, line, w[j]);
282 close_file(fp);
267283 return -2;
268284 }
269285 }
88 //
99
1010 VS_VERSION_INFO VERSIONINFO
11 FILEVERSION 2,0,0,0
12 PRODUCTVERSION 2,0,0,0
11 FILEVERSION 2,0,1,0
12 PRODUCTVERSION 2,0,1,0
1313 FILEFLAGSMASK 0x3fL
1414 FILEFLAGS 0x0L
1515 FILEOS 0x40004L
2222 BEGIN
2323 VALUE "CompanyName", "\0"
2424 VALUE "FileDescription", "SDL_mixer\0"
25 VALUE "FileVersion", "2, 0, 0, 0\0"
25 VALUE "FileVersion", "2, 0, 1, 0\0"
2626 VALUE "InternalName", "SDL_mixer\0"
27 VALUE "LegalCopyright", "Copyright © 2013 Sam Lantinga\0"
27 VALUE "LegalCopyright", "Copyright © 2016 Sam Lantinga\0"
2828 VALUE "OriginalFilename", "SDL_mixer.dll\0"
2929 VALUE "ProductName", "Simple DirectMedia Layer\0"
30 VALUE "ProductVersion", "2, 0, 0, 0\0"
30 VALUE "ProductVersion", "2, 0, 1, 0\0"
3131 END
3232 END
3333 BLOCK "VarFileInfo"
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
4646 /*******************************************/
4747 #define RIFF 0x46464952 /* "RIFF" */
4848 #define WAVE 0x45564157 /* "WAVE" */
49 #define FACT 0x74636166 /* "fact" */
50 #define LIST 0x5453494c /* "LIST" */
51 #define FMT 0x20746D66 /* "fmt " */
49 #define FMT 0x20746D66 /* "fmt " */
5250 #define DATA 0x61746164 /* "data" */
51 #define SMPL 0x6c706d73 /* "smpl" */
5352 #define PCM_CODE 1
5453 #define ADPCM_CODE 2
5554 #define WAVE_MONO 1
5655 #define WAVE_STEREO 2
5756
58 /* Normally, these three chunks come consecutively in a WAVE file */
59 typedef struct WaveFMT {
57 typedef struct {
6058 /* Not saved in the chunk we read:
61 Uint32 FMTchunk;
62 Uint32 fmtlen;
59 Uint32 chunkID;
60 Uint32 chunkLen;
6361 */
6462 Uint16 encoding;
6563 Uint16 channels; /* 1 = mono, 2 = stereo */
6967 Uint16 bitspersample; /* One of 8, 12, 16, or 4 for ADPCM */
7068 } WaveFMT;
7169
72 /* The general chunk found in the WAVE file */
73 typedef struct Chunk {
74 Uint32 magic;
75 Uint32 length;
76 Uint8 *data; /* Data includes magic and length */
77 } Chunk;
70 typedef struct {
71 Uint32 identifier;
72 Uint32 type;
73 Uint32 start;
74 Uint32 end;
75 Uint32 fraction;
76 Uint32 play_count;
77 } SampleLoop;
78
79 typedef struct {
80 /* Not saved in the chunk we read:
81 Uint32 chunkID;
82 Uint32 chunkLen;
83 */
84 Uint32 manufacturer;
85 Uint32 product;
86 Uint32 sample_period;
87 Uint32 MIDI_unity_note;
88 Uint32 MIDI_pitch_fraction;
89 Uint32 SMTPE_format;
90 Uint32 SMTPE_offset;
91 Uint32 sample_loops;
92 Uint32 sampler_data;
93 SampleLoop loops[];
94 } SamplerChunk;
7895
7996 /*********************************************/
8097 /* Define values for AIFF (IFF audio) format */
93110 static int wavestream_volume = MIX_MAX_VOLUME;
94111
95112 /* Function to load the WAV/AIFF stream */
96 static SDL_RWops *LoadWAVStream (SDL_RWops *rw, SDL_AudioSpec *spec,
97 long *start, long *stop);
98 static SDL_RWops *LoadAIFFStream (SDL_RWops *rw, SDL_AudioSpec *spec,
99 long *start, long *stop);
113 static SDL_bool LoadWAVStream(WAVStream *wave);
114 static SDL_bool LoadAIFFStream(WAVStream *wave);
100115
101116 /* Initialize the WAVStream player, with the given mixer settings
102117 This function returns 0, or -1 if there was an error.
116131 WAVStream *WAVStream_LoadSong_RW(SDL_RWops *src, int freesrc)
117132 {
118133 WAVStream *wave;
119 SDL_AudioSpec wavespec;
120
121 if ( ! mixer.format ) {
134 SDL_bool loaded = SDL_FALSE;
135
136 if (!mixer.format) {
122137 Mix_SetError("WAV music output not started");
123138 return(NULL);
124139 }
140
125141 wave = (WAVStream *)SDL_malloc(sizeof *wave);
126 if ( wave ) {
142 if (wave) {
127143 Uint32 magic;
128144
129145 SDL_zerop(wave);
146 wave->src = src;
130147 wave->freesrc = freesrc;
131148
132149 magic = SDL_ReadLE32(src);
133 if ( magic == RIFF || magic == WAVE ) {
134 wave->src = LoadWAVStream(src, &wavespec, &wave->start, &wave->stop);
135 } else if ( magic == FORM ) {
136 wave->src = LoadAIFFStream(src, &wavespec, &wave->start, &wave->stop);
150 if (magic == RIFF || magic == WAVE) {
151 loaded = LoadWAVStream(wave);
152 } else if (magic == FORM) {
153 loaded = LoadAIFFStream(wave);
137154 } else {
138155 Mix_SetError("Unknown WAVE format");
139156 }
140 if ( wave->src == NULL ) {
141 SDL_free(wave);
157 if (!loaded) {
158 WAVStream_FreeSong(wave);
142159 return(NULL);
143160 }
144161 SDL_BuildAudioCVT(&wave->cvt,
145 wavespec.format, wavespec.channels, wavespec.freq,
162 wave->spec.format, wave->spec.channels, wave->spec.freq,
146163 mixer.format, mixer.channels, mixer.freq);
147164 } else {
148165 SDL_OutOfMemory();
154171 /* Start playback of a given WAV stream */
155172 void WAVStream_Start(WAVStream *wave)
156173 {
157 SDL_RWseek (wave->src, wave->start, RW_SEEK_SET);
174 int i;
175 for (i = 0; i < wave->numloops; ++i) {
176 WAVLoopPoint *loop = &wave->loops[i];
177 loop->active = SDL_TRUE;
178 loop->current_play_count = loop->initial_play_count;
179 }
180 SDL_RWseek(wave->src, wave->start, RW_SEEK_SET);
158181 music = wave;
159182 }
160183
161184 /* Play some of a stream previously started with WAVStream_Start() */
162 int WAVStream_PlaySome(Uint8 *stream, int len)
163 {
164 Sint64 pos;
165 Sint64 left = 0;
166
167 if ( music && ((pos=SDL_RWtell(music->src)) < music->stop) ) {
168 if ( music->cvt.needed ) {
169 int original_len;
170
171 original_len=(int)((double)len/music->cvt.len_ratio);
172 if ( music->cvt.len != original_len ) {
173 int worksize;
174 if ( music->cvt.buf != NULL ) {
175 SDL_free(music->cvt.buf);
176 }
177 worksize = original_len*music->cvt.len_mult;
178 music->cvt.buf=(Uint8 *)SDL_malloc(worksize);
179 if ( music->cvt.buf == NULL ) {
180 return 0;
181 }
182 music->cvt.len = original_len;
185 static int PlaySome(Uint8 *stream, int len)
186 {
187 Sint64 pos, stop;
188 WAVLoopPoint *loop;
189 Sint64 loop_start;
190 Sint64 loop_stop;
191 int i;
192 int consumed;
193
194 pos = SDL_RWtell(music->src);
195 stop = music->stop;
196 loop = NULL;
197 for (i = 0; i < music->numloops; ++i) {
198 loop = &music->loops[i];
199 if (loop->active) {
200 const int bytes_per_sample = (SDL_AUDIO_BITSIZE(music->spec.format) / 8) * music->spec.channels;
201 loop_start = music->start + loop->start * bytes_per_sample;
202 loop_stop = music->start + (loop->stop + 1) * bytes_per_sample;
203 if (pos >= loop_start && pos < loop_stop)
204 {
205 stop = loop_stop;
206 break;
183207 }
184 if ( (music->stop - pos) < original_len ) {
185 left = (original_len - (music->stop - pos));
186 original_len -= (int)left;
187 left = (int)((double)left*music->cvt.len_ratio);
208 }
209 loop = NULL;
210 }
211
212 if (music->cvt.needed) {
213 int original_len;
214
215 original_len = (int)((double)len/music->cvt.len_ratio);
216 if (music->cvt.len != original_len) {
217 int worksize;
218 if (music->cvt.buf != NULL) {
219 SDL_free(music->cvt.buf);
188220 }
189 original_len = SDL_RWread(music->src, music->cvt.buf,1,original_len);
190 /* At least at the time of writing, SDL_ConvertAudio()
191 does byte-order swapping starting at the end of the
192 buffer. Thus, if we are reading 16-bit samples, we
193 had better make damn sure that we get an even
194 number of bytes, or we'll get garbage.
195 */
196 if ( (music->cvt.src_format & 0x0010) && (original_len & 1) ) {
197 original_len--;
221 worksize = original_len*music->cvt.len_mult;
222 music->cvt.buf=(Uint8 *)SDL_malloc(worksize);
223 if (music->cvt.buf == NULL) {
224 return 0;
198225 }
199226 music->cvt.len = original_len;
200 SDL_ConvertAudio(&music->cvt);
201 SDL_MixAudio(stream, music->cvt.buf, music->cvt.len_cvt, wavestream_volume);
227 }
228 if ((stop - pos) < original_len) {
229 original_len = (int)(stop - pos);
230 }
231 original_len = SDL_RWread(music->src, music->cvt.buf, 1, original_len);
232 /* At least at the time of writing, SDL_ConvertAudio()
233 does byte-order swapping starting at the end of the
234 buffer. Thus, if we are reading 16-bit samples, we
235 had better make damn sure that we get an even
236 number of bytes, or we'll get garbage.
237 */
238 if ((music->cvt.src_format & 0x0010) && (original_len & 1)) {
239 original_len--;
240 }
241 music->cvt.len = original_len;
242 SDL_ConvertAudio(&music->cvt);
243 SDL_MixAudio(stream, music->cvt.buf, music->cvt.len_cvt, wavestream_volume);
244 consumed = music->cvt.len_cvt;
245 } else {
246 Uint8 *data;
247 if ((stop - pos) < len) {
248 len = (int)(stop - pos);
249 }
250 data = SDL_stack_alloc(Uint8, len);
251 if (data) {
252 len = SDL_RWread(music->src, data, 1, len);
253 SDL_MixAudio(stream, data, len, wavestream_volume);
254 SDL_stack_free(data);
255 }
256 consumed = len;
257 }
258
259 if (loop && SDL_RWtell(music->src) >= stop) {
260 if (loop->current_play_count == 1) {
261 loop->active = SDL_FALSE;
202262 } else {
203 Uint8 *data;
204 if ( (music->stop - pos) < len ) {
205 left = (len - (music->stop - pos));
206 len -= (int)left;
263 if (loop->current_play_count > 0) {
264 --loop->current_play_count;
207265 }
208 data = SDL_stack_alloc(Uint8, len);
209 if (data)
210 {
211 SDL_RWread(music->src, data, len, 1);
212 SDL_MixAudio(stream, data, len, wavestream_volume);
213 SDL_stack_free(data);
214 }
215 }
216 }
217 return (int)left;
266 SDL_RWseek(music->src, loop_start, RW_SEEK_SET);
267 }
268 }
269 return consumed;
270 }
271
272 int WAVStream_PlaySome(Uint8 *stream, int len)
273 {
274 if (!music)
275 return 0;
276
277 while ((SDL_RWtell(music->src) < music->stop) && (len > 0)) {
278 int consumed = PlaySome(stream, len);
279 if (!consumed)
280 break;
281
282 stream += consumed;
283 len -= consumed;
284 }
285 return len;
218286 }
219287
220288 /* Stop playback of a stream previously started with WAVStream_Start() */
226294 /* Close the given WAV stream */
227295 void WAVStream_FreeSong(WAVStream *wave)
228296 {
229 if ( wave ) {
297 if (wave) {
230298 /* Clean up associated data */
231 if ( wave->cvt.buf ) {
299 if (wave->loops) {
300 SDL_free(wave->loops);
301 }
302 if (wave->cvt.buf) {
232303 SDL_free(wave->cvt.buf);
233304 }
234 if ( wave->freesrc ) {
305 if (wave->freesrc) {
235306 SDL_RWclose(wave->src);
236307 }
237308 SDL_free(wave);
244315 int active;
245316
246317 active = 0;
247 if ( music && (SDL_RWtell(music->src) < music->stop) ) {
318 if (music && (SDL_RWtell(music->src) < music->stop)) {
248319 active = 1;
249320 }
250321 return(active);
251322 }
252323
253 static int ReadChunk(SDL_RWops *src, Chunk *chunk, int read_data)
254 {
255 chunk->magic = SDL_ReadLE32(src);
256 chunk->length = SDL_ReadLE32(src);
257 if ( read_data ) {
258 chunk->data = (Uint8 *)SDL_malloc(chunk->length);
259 if ( chunk->data == NULL ) {
260 Mix_SetError("Out of memory");
261 return(-1);
262 }
263 if ( SDL_RWread(src, chunk->data, chunk->length, 1) != 1 ) {
264 Mix_SetError("Couldn't read chunk");
265 SDL_free(chunk->data);
266 return(-1);
267 }
268 } else {
269 SDL_RWseek(src, chunk->length, RW_SEEK_CUR);
270 }
271 return(chunk->length);
272 }
273
274 static SDL_RWops *LoadWAVStream (SDL_RWops *src, SDL_AudioSpec *spec,
275 long *start, long *stop)
276 {
277 int was_error;
278 Chunk chunk;
279 int lenread;
280
281 /* WAV magic header */
282 Uint32 wavelen;
283 Uint32 WAVEmagic;
284
285 /* FMT chunk */
286 WaveFMT *format = NULL;
287
288 was_error = 0;
289
290 /* Check the magic header */
291 wavelen = SDL_ReadLE32(src);
292 WAVEmagic = SDL_ReadLE32(src);
293
294 /* Read the audio data format chunk */
295 chunk.data = NULL;
296 do {
297 /* FIXME! Add this logic to SDL_LoadWAV_RW() */
298 if ( chunk.data ) {
299 SDL_free(chunk.data);
300 }
301 lenread = ReadChunk(src, &chunk, 1);
302 if ( lenread < 0 ) {
303 was_error = 1;
304 goto done;
305 }
306 } while ( (chunk.magic == FACT) || (chunk.magic == LIST) );
324 static SDL_bool ParseFMT(WAVStream *wave, Uint32 chunk_length)
325 {
326 SDL_RWops *src = wave->src;
327 SDL_AudioSpec *spec = &wave->spec;
328 WaveFMT *format;
329 Uint8 *data;
330 SDL_bool loaded = SDL_FALSE;
331
332 if (chunk_length < sizeof(*format)) {
333 Mix_SetError("Wave format chunk too small");
334 return SDL_FALSE;
335 }
336
337 data = (Uint8 *)SDL_malloc(chunk_length);
338 if (!data) {
339 Mix_SetError("Out of memory");
340 return SDL_FALSE;
341 }
342 if (!SDL_RWread(wave->src, data, chunk_length, 1)) {
343 Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length);
344 return SDL_FALSE;
345 }
346 format = (WaveFMT *)data;
307347
308348 /* Decode the audio data format */
309 format = (WaveFMT *)chunk.data;
310 if ( chunk.magic != FMT ) {
311 SDL_free(chunk.data);
312 Mix_SetError("Complex WAVE files not supported");
313 was_error = 1;
314 goto done;
315 }
316349 switch (SDL_SwapLE16(format->encoding)) {
317350 case PCM_CODE:
318351 /* We can understand this */
319352 break;
320353 default:
321354 Mix_SetError("Unknown WAVE data format");
322 was_error = 1;
323355 goto done;
324356 }
325 SDL_memset(spec, 0, (sizeof *spec));
326357 spec->freq = SDL_SwapLE32(format->frequency);
327358 switch (SDL_SwapLE16(format->bitspersample)) {
328359 case 8:
333364 break;
334365 default:
335366 Mix_SetError("Unknown PCM data format");
336 was_error = 1;
337367 goto done;
338368 }
339369 spec->channels = (Uint8) SDL_SwapLE16(format->channels);
340370 spec->samples = 4096; /* Good default buffer size */
341371
342 /* Set the file offset to the DATA chunk data */
343 chunk.data = NULL;
344 do {
345 *start = (long)SDL_RWtell(src) + 2*sizeof(Uint32);
346 lenread = ReadChunk(src, &chunk, 0);
347 if ( lenread < 0 ) {
348 was_error = 1;
349 goto done;
350 }
351 } while ( chunk.magic != DATA );
352 *stop = (long)SDL_RWtell(src);
372 loaded = SDL_TRUE;
353373
354374 done:
355 if ( format != NULL ) {
356 SDL_free(format);
357 }
358 if ( was_error ) {
359 return NULL;
360 }
361 return(src);
375 SDL_free(data);
376 return loaded;
377 }
378
379 static SDL_bool ParseDATA(WAVStream *wave, Uint32 chunk_length)
380 {
381 wave->start = SDL_RWtell(wave->src);
382 wave->stop = wave->start + chunk_length;
383 SDL_RWseek(wave->src, chunk_length, RW_SEEK_CUR);
384 return SDL_TRUE;
385 }
386
387 static SDL_bool AddLoopPoint(WAVStream *wave, Uint32 play_count, Uint32 start, Uint32 stop)
388 {
389 WAVLoopPoint *loop;
390 WAVLoopPoint *loops = SDL_realloc(wave->loops, (wave->numloops + 1)*sizeof(*wave->loops));
391 if (!loops) {
392 Mix_SetError("Out of memory");
393 return SDL_FALSE;
394 }
395
396 loop = &loops[ wave->numloops ];
397 loop->start = start;
398 loop->stop = stop;
399 loop->initial_play_count = play_count;
400 loop->current_play_count = play_count;
401
402 wave->loops = loops;
403 ++wave->numloops;
404 return SDL_TRUE;
405 }
406
407 static SDL_bool ParseSMPL(WAVStream *wave, Uint32 chunk_length)
408 {
409 SamplerChunk *chunk;
410 Uint8 *data;
411 int i;
412 SDL_bool loaded = SDL_FALSE;
413
414 data = (Uint8 *)SDL_malloc(chunk_length);
415 if (!data) {
416 Mix_SetError("Out of memory");
417 return SDL_FALSE;
418 }
419 if (!SDL_RWread(wave->src, data, chunk_length, 1)) {
420 Mix_SetError("Couldn't read %d bytes from WAV file", chunk_length);
421 return SDL_FALSE;
422 }
423 chunk = (SamplerChunk *)data;
424
425 for (i = 0; i < SDL_SwapLE32(chunk->sample_loops); ++i) {
426 const Uint32 LOOP_TYPE_FORWARD = 0;
427 Uint32 loop_type = SDL_SwapLE32(chunk->loops[i].type);
428 if (loop_type == LOOP_TYPE_FORWARD) {
429 AddLoopPoint(wave, SDL_SwapLE32(chunk->loops[i].play_count), SDL_SwapLE32(chunk->loops[i].start), SDL_SwapLE32(chunk->loops[i].end));
430 }
431 }
432
433 loaded = SDL_TRUE;
434
435 done:
436 SDL_free(data);
437 return loaded;
438 }
439
440 static SDL_bool LoadWAVStream(WAVStream *wave)
441 {
442 SDL_RWops *src = wave->src;
443 Uint32 chunk_type;
444 Uint32 chunk_length;
445 SDL_bool found_FMT = SDL_FALSE;
446 SDL_bool found_DATA = SDL_FALSE;
447
448 /* WAV magic header */
449 Uint32 wavelen;
450 Uint32 WAVEmagic;
451
452 /* Check the magic header */
453 wavelen = SDL_ReadLE32(src);
454 WAVEmagic = SDL_ReadLE32(src);
455
456 /* Read the chunks */
457 for (; ;) {
458 chunk_type = SDL_ReadLE32(src);
459 chunk_length = SDL_ReadLE32(src);
460
461 if (chunk_length == 0)
462 break;
463
464 switch (chunk_type)
465 {
466 case FMT:
467 found_FMT = SDL_TRUE;
468 if (!ParseFMT(wave, chunk_length))
469 return SDL_FALSE;
470 break;
471 case DATA:
472 found_DATA = SDL_TRUE;
473 if (!ParseDATA(wave, chunk_length))
474 return SDL_FALSE;
475 break;
476 case SMPL:
477 if (!ParseSMPL(wave, chunk_length))
478 return SDL_FALSE;
479 break;
480 default:
481 SDL_RWseek(src, chunk_length, RW_SEEK_CUR);
482 break;
483 }
484 }
485
486 if (!found_FMT) {
487 Mix_SetError("Bad WAV file (no FMT chunk)");
488 return SDL_FALSE;
489 }
490
491 if (!found_DATA) {
492 Mix_SetError("Bad WAV file (no DATA chunk)");
493 return SDL_FALSE;
494 }
495
496 return SDL_TRUE;
362497 }
363498
364499 /* I couldn't get SANE_to_double() to work, so I stole this from libsndfile.
383518 if (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C)
384519 return 800000000;
385520
386 return ((sanebuf[2] << 23) | (sanebuf[3] << 15) | (sanebuf[4] << 7)
387 | (sanebuf[5] >> 1)) >> (29 - sanebuf[1]);
388 }
389
390 static SDL_RWops *LoadAIFFStream (SDL_RWops *src, SDL_AudioSpec *spec,
391 long *start, long *stop)
392 {
393 int was_error;
394 int found_SSND;
395 int found_COMM;
521 return ((sanebuf[2] << 23) | (sanebuf[3] << 15) | (sanebuf[4] << 7) |
522 (sanebuf[5] >> 1)) >> (29 - sanebuf[1]);
523 }
524
525 static SDL_bool LoadAIFFStream(WAVStream *wave)
526 {
527 SDL_RWops *src = wave->src;
528 SDL_AudioSpec *spec = &wave->spec;
529 SDL_bool found_SSND = SDL_FALSE;
530 SDL_bool found_COMM = SDL_FALSE;
396531
397532 Uint32 chunk_type;
398533 Uint32 chunk_length;
410545 Uint8 sane_freq[10];
411546 Uint32 frequency = 0;
412547
413 was_error = 0;
414
415548 /* Check the magic header */
416 chunk_length = SDL_ReadBE32(src);
417 AIFFmagic = SDL_ReadLE32(src);
418 if ( AIFFmagic != AIFF ) {
549 chunk_length = SDL_ReadBE32(src);
550 AIFFmagic = SDL_ReadLE32(src);
551 if (AIFFmagic != AIFF) {
419552 Mix_SetError("Unrecognized file type (not AIFF)");
420 was_error = 1;
421 goto done;
553 return SDL_FALSE;
422554 }
423555
424556 /* From what I understand of the specification, chunks may appear in
425 * any order, and we should just ignore unknown ones.
557 * any order, and we should just ignore unknown ones.
426558 *
427559 * TODO: Better sanity-checking. E.g. what happens if the AIFF file
428560 * contains compressed sound data?
429561 */
430
431 found_SSND = 0;
432 found_COMM = 0;
433
434562 do {
435563 chunk_type = SDL_ReadLE32(src);
436564 chunk_length = SDL_ReadBE32(src);
438566
439567 /* Paranoia to avoid infinite loops */
440568 if (chunk_length == 0)
441 break;
569 break;
442570
443571 switch (chunk_type) {
444572 case SSND:
445 found_SSND = 1;
446 offset = SDL_ReadBE32(src);
447 blocksize = SDL_ReadBE32(src);
448 *start = (long)SDL_RWtell(src) + offset;
573 found_SSND = SDL_TRUE;
574 offset = SDL_ReadBE32(src);
575 blocksize = SDL_ReadBE32(src);
576 wave->start = SDL_RWtell(src) + offset;
449577 break;
450578
451579 case COMM:
452 found_COMM = 1;
580 found_COMM = SDL_TRUE;
453581
454582 /* Read the audio data format chunk */
455 channels = SDL_ReadBE16(src);
456 numsamples = SDL_ReadBE32(src);
457 samplesize = SDL_ReadBE16(src);
583 channels = SDL_ReadBE16(src);
584 numsamples = SDL_ReadBE32(src);
585 samplesize = SDL_ReadBE16(src);
458586 SDL_RWread(src, sane_freq, sizeof(sane_freq), 1);
459 frequency = SANE_to_Uint32(sane_freq);
587 frequency = SANE_to_Uint32(sane_freq);
460588 break;
461589
462590 default:
467595
468596 if (!found_SSND) {
469597 Mix_SetError("Bad AIFF file (no SSND chunk)");
470 was_error = 1;
471 goto done;
598 return SDL_FALSE;
472599 }
473600
474601 if (!found_COMM) {
475602 Mix_SetError("Bad AIFF file (no COMM chunk)");
476 was_error = 1;
477 goto done;
478 }
479
480 *stop = *start + channels * numsamples * (samplesize / 8);
603 return SDL_FALSE;
604 }
605
606 wave->stop = wave->start + channels * numsamples * (samplesize / 8);
481607
482608 /* Decode the audio data format */
483609 SDL_memset(spec, 0, (sizeof *spec));
491617 break;
492618 default:
493619 Mix_SetError("Unknown samplesize in data format");
494 was_error = 1;
495 goto done;
620 return SDL_FALSE;
496621 }
497622 spec->channels = (Uint8) channels;
498623 spec->samples = 4096; /* Good default buffer size */
499624
500 done:
501 if ( was_error ) {
502 return NULL;
503 }
504 return(src);
505 }
506
625 return SDL_TRUE;
626 }
627
00 /*
11 SDL_mixer: An audio mixer library based on the SDL library
2 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
2 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
33
44 This software is provided 'as-is', without any express or implied
55 warranty. In no event will the authors be held liable for any damages
2020
2121