revision 697:479b8c213f61
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 697:479b8c213f61 |
parent | 696:3b224db916e3 |
child | 698:6d9fd7f54609 |
author | nkeynes |
date | Sun Jun 22 04:01:27 2008 +0000 (15 years ago) |
Commit work-in-progress CoreAudio driver
(along with various changes to the audio subsystem)
(along with various changes to the audio subsystem)
1.1 --- a/config.h.in Sun Jun 22 03:59:56 2008 +00001.2 +++ b/config.h.in Sun Jun 22 04:01:27 2008 +00001.3 @@ -34,6 +34,9 @@1.4 /* Have Cocoa framework */1.5 #undef HAVE_COCOA1.7 +/* Have Apple CoreAudio support */1.8 +#undef HAVE_CORE_AUDIO1.9 +1.10 /* Define to 1 if you have the `dcgettext' function. */1.11 #undef HAVE_DCGETTEXT
2.1 --- a/configure Sun Jun 22 03:59:56 2008 +00002.2 +++ b/configure Sun Jun 22 04:01:27 2008 +00002.3 @@ -746,6 +746,8 @@2.4 BUILD_SH4X86_FALSE2.5 BUILD_X86_64_TRUE2.6 BUILD_X86_64_FALSE2.7 +AUDIO_OSX_TRUE2.8 +AUDIO_OSX_FALSE2.9 PULSE_CFLAGS2.10 PULSE_LIBS2.11 AUDIO_PULSE_TRUE2.12 @@ -8562,6 +8564,158 @@2.13 fi2.16 +if test "${ac_cv_header_AudioToolbox_AudioToolbox_h+set}" = set; then2.17 + { $as_echo "$as_me:$LINENO: checking for AudioToolbox/AudioToolbox.h" >&52.18 +$as_echo_n "checking for AudioToolbox/AudioToolbox.h... " >&6; }2.19 +if test "${ac_cv_header_AudioToolbox_AudioToolbox_h+set}" = set; then2.20 + $as_echo_n "(cached) " >&62.21 +fi2.22 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_AudioToolbox_AudioToolbox_h" >&52.23 +$as_echo "$ac_cv_header_AudioToolbox_AudioToolbox_h" >&6; }2.24 +else2.25 + # Is the header compilable?2.26 +{ $as_echo "$as_me:$LINENO: checking AudioToolbox/AudioToolbox.h usability" >&52.27 +$as_echo_n "checking AudioToolbox/AudioToolbox.h usability... " >&6; }2.28 +cat >conftest.$ac_ext <<_ACEOF2.29 +/* confdefs.h. */2.30 +_ACEOF2.31 +cat confdefs.h >>conftest.$ac_ext2.32 +cat >>conftest.$ac_ext <<_ACEOF2.33 +/* end confdefs.h. */2.34 +$ac_includes_default2.35 +#include <AudioToolbox/AudioToolbox.h>2.36 +_ACEOF2.37 +rm -f conftest.$ac_objext2.38 +if { (ac_try="$ac_compile"2.39 +case "(($ac_try" in2.40 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;2.41 + *) ac_try_echo=$ac_try;;2.42 +esac2.43 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""2.44 +$as_echo "$ac_try_echo") >&52.45 + (eval "$ac_compile") 2>conftest.er12.46 + ac_status=$?2.47 + grep -v '^ *+' conftest.er1 >conftest.err2.48 + rm -f conftest.er12.49 + cat conftest.err >&52.50 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&52.51 + (exit $ac_status); } && {2.52 + test -z "$ac_c_werror_flag" ||2.53 + test ! -s conftest.err2.54 + } && test -s conftest.$ac_objext; then2.55 + ac_header_compiler=yes2.56 +else2.57 + $as_echo "$as_me: failed program was:" >&52.58 +sed 's/^/| /' conftest.$ac_ext >&52.59 +2.60 + ac_header_compiler=no2.61 +fi2.62 +2.63 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext2.64 +{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&52.65 +$as_echo "$ac_header_compiler" >&6; }2.66 +2.67 +# Is the header present?2.68 +{ $as_echo "$as_me:$LINENO: checking AudioToolbox/AudioToolbox.h presence" >&52.69 +$as_echo_n "checking AudioToolbox/AudioToolbox.h presence... " >&6; }2.70 +cat >conftest.$ac_ext <<_ACEOF2.71 +/* confdefs.h. */2.72 +_ACEOF2.73 +cat confdefs.h >>conftest.$ac_ext2.74 +cat >>conftest.$ac_ext <<_ACEOF2.75 +/* end confdefs.h. */2.76 +#include <AudioToolbox/AudioToolbox.h>2.77 +_ACEOF2.78 +if { (ac_try="$ac_cpp conftest.$ac_ext"2.79 +case "(($ac_try" in2.80 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;2.81 + *) ac_try_echo=$ac_try;;2.82 +esac2.83 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""2.84 +$as_echo "$ac_try_echo") >&52.85 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er12.86 + ac_status=$?2.87 + grep -v '^ *+' conftest.er1 >conftest.err2.88 + rm -f conftest.er12.89 + cat conftest.err >&52.90 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&52.91 + (exit $ac_status); } >/dev/null && {2.92 + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||2.93 + test ! -s conftest.err2.94 + }; then2.95 + ac_header_preproc=yes2.96 +else2.97 + $as_echo "$as_me: failed program was:" >&52.98 +sed 's/^/| /' conftest.$ac_ext >&52.99 +2.100 + ac_header_preproc=no2.101 +fi2.102 +2.103 +rm -f conftest.err conftest.$ac_ext2.104 +{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&52.105 +$as_echo "$ac_header_preproc" >&6; }2.106 +2.107 +# So? What about this header?2.108 +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in2.109 + yes:no: )2.110 + { $as_echo "$as_me:$LINENO: WARNING: AudioToolbox/AudioToolbox.h: accepted by the compiler, rejected by the preprocessor!" >&52.111 +$as_echo "$as_me: WARNING: AudioToolbox/AudioToolbox.h: accepted by the compiler, rejected by the preprocessor!" >&2;}2.112 + { $as_echo "$as_me:$LINENO: WARNING: AudioToolbox/AudioToolbox.h: proceeding with the compiler's result" >&52.113 +$as_echo "$as_me: WARNING: AudioToolbox/AudioToolbox.h: proceeding with the compiler's result" >&2;}2.114 + ac_header_preproc=yes2.115 + ;;2.116 + no:yes:* )2.117 + { $as_echo "$as_me:$LINENO: WARNING: AudioToolbox/AudioToolbox.h: present but cannot be compiled" >&52.118 +$as_echo "$as_me: WARNING: AudioToolbox/AudioToolbox.h: present but cannot be compiled" >&2;}2.119 + { $as_echo "$as_me:$LINENO: WARNING: AudioToolbox/AudioToolbox.h: check for missing prerequisite headers?" >&52.120 +$as_echo "$as_me: WARNING: AudioToolbox/AudioToolbox.h: check for missing prerequisite headers?" >&2;}2.121 + { $as_echo "$as_me:$LINENO: WARNING: AudioToolbox/AudioToolbox.h: see the Autoconf documentation" >&52.122 +$as_echo "$as_me: WARNING: AudioToolbox/AudioToolbox.h: see the Autoconf documentation" >&2;}2.123 + { $as_echo "$as_me:$LINENO: WARNING: AudioToolbox/AudioToolbox.h: section \"Present But Cannot Be Compiled\"" >&52.124 +$as_echo "$as_me: WARNING: AudioToolbox/AudioToolbox.h: section \"Present But Cannot Be Compiled\"" >&2;}2.125 + { $as_echo "$as_me:$LINENO: WARNING: AudioToolbox/AudioToolbox.h: proceeding with the preprocessor's result" >&52.126 +$as_echo "$as_me: WARNING: AudioToolbox/AudioToolbox.h: proceeding with the preprocessor's result" >&2;}2.127 + { $as_echo "$as_me:$LINENO: WARNING: AudioToolbox/AudioToolbox.h: in the future, the compiler will take precedence" >&52.128 +$as_echo "$as_me: WARNING: AudioToolbox/AudioToolbox.h: in the future, the compiler will take precedence" >&2;}2.129 +2.130 + ;;2.131 +esac2.132 +{ $as_echo "$as_me:$LINENO: checking for AudioToolbox/AudioToolbox.h" >&52.133 +$as_echo_n "checking for AudioToolbox/AudioToolbox.h... " >&6; }2.134 +if test "${ac_cv_header_AudioToolbox_AudioToolbox_h+set}" = set; then2.135 + $as_echo_n "(cached) " >&62.136 +else2.137 + ac_cv_header_AudioToolbox_AudioToolbox_h=$ac_header_preproc2.138 +fi2.139 +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_AudioToolbox_AudioToolbox_h" >&52.140 +$as_echo "$ac_cv_header_AudioToolbox_AudioToolbox_h" >&6; }2.141 +2.142 +fi2.143 +if test $ac_cv_header_AudioToolbox_AudioToolbox_h = yes; then2.144 +2.145 + HAVE_CORE_AUDIO=yes2.146 + LIBS="$LIBS -framework AudioToolbox -framework AudioUnit"2.147 +2.148 +cat >>confdefs.h <<\_ACEOF2.149 +#define HAVE_CORE_AUDIO 12.150 +_ACEOF2.151 +2.152 +else2.153 + true2.154 +fi2.155 +2.156 +2.157 +2.158 +2.159 +if test "$HAVE_CORE_AUDIO" = 'yes' ; then2.160 + AUDIO_OSX_TRUE=2.161 + AUDIO_OSX_FALSE='#'2.162 +else2.163 + AUDIO_OSX_TRUE='#'2.164 + AUDIO_OSX_FALSE=2.165 +fi2.166 +2.167 +2.169 pkg_failed=no2.170 { $as_echo "$as_me:$LINENO: checking for PULSE" >&52.171 @@ -11176,6 +11330,13 @@2.172 Usually this means the macro was only invoked conditionally." >&2;}2.173 { (exit 1); exit 1; }; }2.174 fi2.175 +if test -z "${AUDIO_OSX_TRUE}" && test -z "${AUDIO_OSX_FALSE}"; then2.176 + { { $as_echo "$as_me:$LINENO: error: conditional \"AUDIO_OSX\" was never defined.2.177 +Usually this means the macro was only invoked conditionally." >&52.178 +$as_echo "$as_me: error: conditional \"AUDIO_OSX\" was never defined.2.179 +Usually this means the macro was only invoked conditionally." >&2;}2.180 + { (exit 1); exit 1; }; }2.181 +fi2.182 if test -z "${AUDIO_PULSE_TRUE}" && test -z "${AUDIO_PULSE_FALSE}"; then2.183 { { $as_echo "$as_me:$LINENO: error: conditional \"AUDIO_PULSE\" was never defined.2.184 Usually this means the macro was only invoked conditionally." >&5
3.1 --- a/configure.in Sun Jun 22 03:59:56 2008 +00003.2 +++ b/configure.in Sun Jun 22 04:01:27 2008 +00003.3 @@ -154,6 +154,13 @@3.4 AM_CONDITIONAL(BUILD_X86_64, [test "$SH4_TRANSLATOR" = "x86_64"])3.6 dnl ------------------ Optional driver support -------------------3.7 +dnl Check for Apple CoreAudio3.8 +AC_CHECK_HEADER([AudioToolbox/AudioToolbox.h], [3.9 + HAVE_CORE_AUDIO=yes3.10 + LIBS="$LIBS -framework AudioToolbox -framework AudioUnit"3.11 + AC_DEFINE([HAVE_CORE_AUDIO], 1, [Have Apple CoreAudio support]) ],[true ])3.12 +AM_CONDITIONAL( AUDIO_OSX, [test "$HAVE_CORE_AUDIO" = 'yes'] )3.13 +3.14 dnl Check for pulseaudio3.15 PKG_CHECK_MODULES(PULSE, [libpulse-simple], [3.16 HAVE_PULSE='yes'
4.1 --- a/src/Makefile.am Sun Jun 22 03:59:56 2008 +00004.2 +++ b/src/Makefile.am Sun Jun 22 04:01:27 2008 +00004.3 @@ -87,6 +87,10 @@4.4 lxdream_SOURCES += drivers/video_nsgl.c drivers/video_nsgl.h4.5 endif4.7 +if AUDIO_OSX4.8 +lxdream_SOURCES += drivers/audio_osx.c4.9 +endif4.10 +4.11 if AUDIO_PULSE4.12 lxdream_SOURCES += drivers/audio_pulse.c4.13 endif
5.1 --- a/src/Makefile.in Sun Jun 22 03:59:56 2008 +00005.2 +++ b/src/Makefile.in Sun Jun 22 04:01:27 2008 +00005.3 @@ -58,12 +58,13 @@5.4 @VIDEO_OSMESA_TRUE@am__append_5 = drivers/video_gdk.c drivers/video_gdk.h5.5 @VIDEO_GLX_TRUE@am__append_6 = drivers/video_glx.c drivers/video_glx.h5.6 @VIDEO_NSGL_TRUE@am__append_7 = drivers/video_nsgl.c drivers/video_nsgl.h5.7 -@AUDIO_PULSE_TRUE@am__append_8 = drivers/audio_pulse.c5.8 -@AUDIO_ESOUND_TRUE@am__append_9 = drivers/audio_esd.c5.9 -@AUDIO_ALSA_TRUE@am__append_10 = drivers/audio_alsa.c5.10 -@CDROM_LINUX_TRUE@am__append_11 = drivers/cd_linux.c5.11 -@CDROM_LINUX_FALSE@am__append_12 = drivers/cd_none.c5.12 -@JOY_LINUX_TRUE@am__append_13 = drivers/joy_linux.c5.13 +@AUDIO_OSX_TRUE@am__append_8 = drivers/audio_osx.c5.14 +@AUDIO_PULSE_TRUE@am__append_9 = drivers/audio_pulse.c5.15 +@AUDIO_ESOUND_TRUE@am__append_10 = drivers/audio_esd.c5.16 +@AUDIO_ALSA_TRUE@am__append_11 = drivers/audio_alsa.c5.17 +@CDROM_LINUX_TRUE@am__append_12 = drivers/cd_linux.c5.18 +@CDROM_LINUX_FALSE@am__append_13 = drivers/cd_none.c5.19 +@JOY_LINUX_TRUE@am__append_14 = drivers/joy_linux.c5.20 subdir = src5.21 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in5.22 ACLOCAL_M4 = $(top_srcdir)/aclocal.m45.23 @@ -117,9 +118,9 @@5.24 cocoaui/cocoa_win.c cocoaui/cocoa_gd.c drivers/video_osx.c \5.25 drivers/mac_keymap.h drivers/video_gdk.c drivers/video_gdk.h \5.26 drivers/video_glx.c drivers/video_glx.h drivers/video_nsgl.c \5.27 - drivers/video_nsgl.h drivers/audio_pulse.c drivers/audio_esd.c \5.28 - drivers/audio_alsa.c drivers/cd_linux.c drivers/cd_none.c \5.29 - drivers/joy_linux.c5.30 + drivers/video_nsgl.h drivers/audio_osx.c drivers/audio_pulse.c \5.31 + drivers/audio_esd.c drivers/audio_alsa.c drivers/cd_linux.c \5.32 + drivers/cd_none.c drivers/joy_linux.c5.33 @BUILD_SH4X86_TRUE@am__objects_1 = sh4x86.$(OBJEXT) sh4trans.$(OBJEXT) \5.34 @BUILD_SH4X86_TRUE@ x86dasm.$(OBJEXT) i386-dis.$(OBJEXT) \5.35 @BUILD_SH4X86_TRUE@ dis-init.$(OBJEXT) dis-buf.$(OBJEXT)5.36 @@ -133,12 +134,13 @@5.37 @VIDEO_OSMESA_TRUE@am__objects_4 = video_gdk.$(OBJEXT)5.38 @VIDEO_GLX_TRUE@am__objects_5 = video_glx.$(OBJEXT)5.39 @VIDEO_NSGL_TRUE@am__objects_6 = video_nsgl.$(OBJEXT)5.40 -@AUDIO_PULSE_TRUE@am__objects_7 = audio_pulse.$(OBJEXT)5.41 -@AUDIO_ESOUND_TRUE@am__objects_8 = audio_esd.$(OBJEXT)5.42 -@AUDIO_ALSA_TRUE@am__objects_9 = audio_alsa.$(OBJEXT)5.43 -@CDROM_LINUX_TRUE@am__objects_10 = cd_linux.$(OBJEXT)5.44 -@CDROM_LINUX_FALSE@am__objects_11 = cd_none.$(OBJEXT)5.45 -@JOY_LINUX_TRUE@am__objects_12 = joy_linux.$(OBJEXT)5.46 +@AUDIO_OSX_TRUE@am__objects_7 = audio_osx.$(OBJEXT)5.47 +@AUDIO_PULSE_TRUE@am__objects_8 = audio_pulse.$(OBJEXT)5.48 +@AUDIO_ESOUND_TRUE@am__objects_9 = audio_esd.$(OBJEXT)5.49 +@AUDIO_ALSA_TRUE@am__objects_10 = audio_alsa.$(OBJEXT)5.50 +@CDROM_LINUX_TRUE@am__objects_11 = cd_linux.$(OBJEXT)5.51 +@CDROM_LINUX_FALSE@am__objects_12 = cd_none.$(OBJEXT)5.52 +@JOY_LINUX_TRUE@am__objects_13 = joy_linux.$(OBJEXT)5.53 am_lxdream_OBJECTS = main.$(OBJEXT) config.$(OBJEXT) mem.$(OBJEXT) \5.54 watch.$(OBJEXT) asic.$(OBJEXT) syscall.$(OBJEXT) \5.55 bios.$(OBJEXT) dcload.$(OBJEXT) ide.$(OBJEXT) \5.56 @@ -161,7 +163,7 @@5.57 $(am__objects_2) $(am__objects_3) $(am__objects_4) \5.58 $(am__objects_5) $(am__objects_6) $(am__objects_7) \5.59 $(am__objects_8) $(am__objects_9) $(am__objects_10) \5.60 - $(am__objects_11) $(am__objects_12)5.61 + $(am__objects_11) $(am__objects_12) $(am__objects_13)5.62 lxdream_OBJECTS = $(am_lxdream_OBJECTS)5.63 lxdream_DEPENDENCIES = $(am__DEPENDENCIES_1)5.64 am__test_testsh4x86_SOURCES_DIST = test/testsh4x86.c x86dasm/x86dasm.c \5.65 @@ -208,6 +210,8 @@5.66 AUDIO_ALSA_TRUE = @AUDIO_ALSA_TRUE@5.67 AUDIO_ESOUND_FALSE = @AUDIO_ESOUND_FALSE@5.68 AUDIO_ESOUND_TRUE = @AUDIO_ESOUND_TRUE@5.69 +AUDIO_OSX_FALSE = @AUDIO_OSX_FALSE@5.70 +AUDIO_OSX_TRUE = @AUDIO_OSX_TRUE@5.71 AUDIO_PULSE_FALSE = @AUDIO_PULSE_FALSE@5.72 AUDIO_PULSE_TRUE = @AUDIO_PULSE_TRUE@5.73 AUTOCONF = @AUTOCONF@5.74 @@ -387,7 +391,7 @@5.75 $(am__append_4) $(am__append_5) $(am__append_6) \5.76 $(am__append_7) $(am__append_8) $(am__append_9) \5.77 $(am__append_10) $(am__append_11) $(am__append_12) \5.78 - $(am__append_13)5.79 + $(am__append_13) $(am__append_14)5.80 @BUILD_SH4X86_TRUE@test_testsh4x86_LDADD = @GLIB_LIBS@ @GTK_LIBS@ @LIBPNG_LIBS@5.81 @BUILD_SH4X86_TRUE@test_testsh4x86_SOURCES = test/testsh4x86.c x86dasm/x86dasm.c \5.82 @BUILD_SH4X86_TRUE@ x86dasm/x86dasm.h x86dasm/i386-dis.c x86dasm/dis-init.c \5.83 @@ -497,6 +501,7 @@5.84 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio_alsa.Po@am__quote@5.85 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio_esd.Po@am__quote@5.86 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio_null.Po@am__quote@5.87 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio_osx.Po@am__quote@5.88 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio_pulse.Po@am__quote@5.89 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bios.Po@am__quote@5.90 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bootstrap.Po@am__quote@5.91 @@ -1590,6 +1595,20 @@5.92 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@5.93 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o video_nsgl.obj `if test -f 'drivers/video_nsgl.c'; then $(CYGPATH_W) 'drivers/video_nsgl.c'; else $(CYGPATH_W) '$(srcdir)/drivers/video_nsgl.c'; fi`5.95 +audio_osx.o: drivers/audio_osx.c5.96 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT audio_osx.o -MD -MP -MF "$(DEPDIR)/audio_osx.Tpo" -c -o audio_osx.o `test -f 'drivers/audio_osx.c' || echo '$(srcdir)/'`drivers/audio_osx.c; \5.97 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/audio_osx.Tpo" "$(DEPDIR)/audio_osx.Po"; else rm -f "$(DEPDIR)/audio_osx.Tpo"; exit 1; fi5.98 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/audio_osx.c' object='audio_osx.o' libtool=no @AMDEPBACKSLASH@5.99 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@5.100 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o audio_osx.o `test -f 'drivers/audio_osx.c' || echo '$(srcdir)/'`drivers/audio_osx.c5.101 +5.102 +audio_osx.obj: drivers/audio_osx.c5.103 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT audio_osx.obj -MD -MP -MF "$(DEPDIR)/audio_osx.Tpo" -c -o audio_osx.obj `if test -f 'drivers/audio_osx.c'; then $(CYGPATH_W) 'drivers/audio_osx.c'; else $(CYGPATH_W) '$(srcdir)/drivers/audio_osx.c'; fi`; \5.104 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/audio_osx.Tpo" "$(DEPDIR)/audio_osx.Po"; else rm -f "$(DEPDIR)/audio_osx.Tpo"; exit 1; fi5.105 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/audio_osx.c' object='audio_osx.obj' libtool=no @AMDEPBACKSLASH@5.106 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@5.107 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o audio_osx.obj `if test -f 'drivers/audio_osx.c'; then $(CYGPATH_W) 'drivers/audio_osx.c'; else $(CYGPATH_W) '$(srcdir)/drivers/audio_osx.c'; fi`5.108 +5.109 audio_pulse.o: drivers/audio_pulse.c5.110 @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT audio_pulse.o -MD -MP -MF "$(DEPDIR)/audio_pulse.Tpo" -c -o audio_pulse.o `test -f 'drivers/audio_pulse.c' || echo '$(srcdir)/'`drivers/audio_pulse.c; \5.111 @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/audio_pulse.Tpo" "$(DEPDIR)/audio_pulse.Po"; else rm -f "$(DEPDIR)/audio_pulse.Tpo"; exit 1; fi
6.1 --- a/src/aica/audio.c Sun Jun 22 03:59:56 2008 +00006.2 +++ b/src/aica/audio.c Sun Jun 22 04:01:27 2008 +00006.3 @@ -24,21 +24,31 @@6.4 #include <assert.h>6.5 #include <string.h>6.7 -audio_driver_t audio_driver_list[] = {6.8 +6.9 +extern struct audio_driver audio_null_driver;6.10 +extern struct audio_driver audio_osx_driver;6.11 +extern struct audio_driver audio_pulse_driver;6.12 +extern struct audio_driver audio_esd_driver;6.13 +extern struct audio_driver audio_alsa_driver;6.14 +6.15 +audio_driver_t audio_driver_list[] = {6.16 +#ifdef HAVE_CORE_AUDIO6.17 + &audio_osx_driver,6.18 +#endif6.19 #ifdef HAVE_PULSE6.20 - &audio_pulse_driver,6.21 + &audio_pulse_driver,6.22 #endif6.23 #ifdef HAVE_ESOUND6.24 - &audio_esd_driver,6.25 + &audio_esd_driver,6.26 #endif6.27 #ifdef HAVE_ALSA6.28 - &audio_alsa_driver,6.29 + &audio_alsa_driver,6.30 #endif6.31 - &audio_null_driver,6.32 - NULL };6.33 + &audio_null_driver,6.34 + NULL };6.36 #define NUM_BUFFERS 36.37 -#define MS_PER_BUFFER 1006.38 +#define MS_PER_BUFFER 10006.40 #define BUFFER_EMPTY 06.41 #define BUFFER_WRITING 16.42 @@ -78,57 +88,79 @@6.43 {6.44 int i;6.45 if( name == NULL ) {6.46 - return audio_driver_list[0];6.47 + return audio_driver_list[0];6.48 }6.49 for( i=0; audio_driver_list[i] != NULL; i++ ) {6.50 - if( strcasecmp( audio_driver_list[i]->name, name ) == 0 ) {6.51 - return audio_driver_list[i];6.52 - }6.53 + if( strcasecmp( audio_driver_list[i]->name, name ) == 0 ) {6.54 + return audio_driver_list[i];6.55 + }6.56 }6.58 return NULL;6.59 }6.61 +audio_driver_t audio_init_driver( const char *preferred_driver )6.62 +{6.63 + audio_driver_t audio_driver = get_audio_driver_by_name(preferred_driver);6.64 + if( audio_driver == NULL ) {6.65 + ERROR( "Audio driver '%s' not found, aborting.", preferred_driver );6.66 + exit(2);6.67 + } else if( audio_set_driver( audio_driver ) == FALSE ) {6.68 + ERROR( "Failed to initialize audio driver '%s', using null driver",6.69 + audio_driver->name );6.70 + audio_set_driver( &audio_null_driver );6.71 + }6.72 +}6.73 +6.74 /**6.75 * Set the output driver, sample rate and format. Also initializes the6.76 * output buffers, flushing any current data and reallocating as6.77 * necessary.6.78 */6.79 -gboolean audio_set_driver( audio_driver_t driver,6.80 - uint32_t samplerate, int format )6.81 +gboolean audio_set_driver( audio_driver_t driver )6.82 {6.83 uint32_t bytes_per_sample = 1;6.84 uint32_t samples_per_buffer;6.85 int i;6.87 if( audio_driver == NULL || driver != NULL ) {6.88 - if( driver == NULL )6.89 - driver = &audio_null_driver;6.90 - if( driver != audio_driver ) {6.91 - if( !driver->set_output_format( samplerate, format ) )6.92 - return FALSE;6.93 - audio_driver = driver;6.94 - }6.95 + if( driver == NULL )6.96 + driver = &audio_null_driver;6.97 + if( driver != audio_driver ) {6.98 + if( !driver->init() )6.99 + return FALSE;6.100 + audio_driver = driver;6.101 + }6.102 }6.104 - if( format & AUDIO_FMT_16BIT )6.105 - bytes_per_sample = 2;6.106 - if( format & AUDIO_FMT_STEREO )6.107 - bytes_per_sample <<= 1;6.108 - if( samplerate == audio.output_rate &&6.109 - bytes_per_sample == audio.output_sample_size )6.110 - return TRUE;6.111 - samples_per_buffer = (samplerate * MS_PER_BUFFER / 1000);6.112 + switch( driver->sample_format & AUDIO_FMT_SAMPLE_MASK ) {6.113 + case AUDIO_FMT_8BIT:6.114 + bytes_per_sample = 1;6.115 + break;6.116 + case AUDIO_FMT_16BIT:6.117 + bytes_per_sample = 2;6.118 + break;6.119 + case AUDIO_FMT_FLOAT:6.120 + bytes_per_sample = 4;6.121 + break;6.122 + }6.123 +6.124 + if( driver->sample_format & AUDIO_FMT_STEREO )6.125 + bytes_per_sample <<= 1;6.126 + if( driver->sample_rate == audio.output_rate &&6.127 + bytes_per_sample == audio.output_sample_size )6.128 + return TRUE;6.129 + samples_per_buffer = (driver->sample_rate * MS_PER_BUFFER / 1000);6.130 for( i=0; i<NUM_BUFFERS; i++ ) {6.131 - if( audio.output_buffers[i] != NULL )6.132 - free(audio.output_buffers[i]);6.133 - audio.output_buffers[i] = g_malloc0( sizeof(struct audio_buffer) + samples_per_buffer * bytes_per_sample );6.134 - audio.output_buffers[i]->length = samples_per_buffer * bytes_per_sample;6.135 - audio.output_buffers[i]->posn = 0;6.136 - audio.output_buffers[i]->status = BUFFER_EMPTY;6.137 + if( audio.output_buffers[i] != NULL )6.138 + free(audio.output_buffers[i]);6.139 + audio.output_buffers[i] = g_malloc0( sizeof(struct audio_buffer) + samples_per_buffer * bytes_per_sample );6.140 + audio.output_buffers[i]->length = samples_per_buffer * bytes_per_sample;6.141 + audio.output_buffers[i]->posn = 0;6.142 + audio.output_buffers[i]->status = BUFFER_EMPTY;6.143 }6.144 - audio.output_format = format;6.145 - audio.output_rate = samplerate;6.146 + audio.output_format = driver->sample_format;6.147 + audio.output_rate = driver->sample_rate;6.148 audio.output_sample_size = bytes_per_sample;6.149 audio.write_buffer = 0;6.150 audio.read_buffer = 0;6.151 @@ -147,16 +179,17 @@6.152 audio_buffer_t current = audio.output_buffers[audio.write_buffer];6.153 current->status = BUFFER_FULL;6.154 if( audio.read_buffer == audio.write_buffer &&6.155 - audio_driver->process_buffer( current ) ) {6.156 - audio_next_read_buffer();6.157 + audio_driver->process_buffer( current ) ) {6.158 + audio_next_read_buffer();6.159 }6.160 - audio.write_buffer = NEXT_BUFFER();6.161 - result = audio.output_buffers[audio.write_buffer];6.162 + int next_buffer = NEXT_BUFFER();6.163 + result = audio.output_buffers[next_buffer];6.164 if( result->status == BUFFER_FULL )6.165 - return NULL;6.166 + return NULL;6.167 else {6.168 - result->status = BUFFER_WRITING;6.169 - return result;6.170 + audio.write_buffer = next_buffer;6.171 + result->status = BUFFER_WRITING;6.172 + return result;6.173 }6.174 }6.176 @@ -167,17 +200,24 @@6.177 audio_buffer_t audio_next_read_buffer( )6.178 {6.179 audio_buffer_t current = audio.output_buffers[audio.read_buffer];6.180 - assert( current->status == BUFFER_FULL );6.181 - current->status = BUFFER_EMPTY;6.182 - current->posn = 0;6.183 - audio.read_buffer++;6.184 - if( audio.read_buffer == NUM_BUFFERS )6.185 - audio.read_buffer = 0;6.186 -6.187 - current = audio.output_buffers[audio.read_buffer];6.188 - if( current->status == BUFFER_FULL )6.189 - return current;6.190 - else return NULL;6.191 + if( current->status == BUFFER_FULL ) {6.192 + // Current read buffer has data, which we've just emptied6.193 + current->status = BUFFER_EMPTY;6.194 + current->posn = 0;6.195 + audio.read_buffer++;6.196 + if( audio.read_buffer == NUM_BUFFERS )6.197 + audio.read_buffer = 0;6.198 +6.199 + current = audio.output_buffers[audio.read_buffer];6.200 + if( current->status == BUFFER_FULL ) {6.201 + current->posn = 0;6.202 + return current;6.203 + }6.204 + else return NULL;6.205 + } else {6.206 + return NULL;6.207 + }6.208 +6.209 }6.211 /*************************** ADPCM ***********************************/6.212 @@ -232,124 +272,158 @@6.213 memset( &result_buf, 0, sizeof(result_buf) );6.215 for( i=0; i < AUDIO_CHANNEL_COUNT; i++ ) {6.216 - audio_channel_t channel = &audio.channels[i];6.217 - if( channel->active ) {6.218 - int32_t sample;6.219 - int vol_left = (channel->vol * (32 - channel->pan)) >> 5;6.220 - int vol_right = (channel->vol * (channel->pan + 1)) >> 5;6.221 - switch( channel->sample_format ) {6.222 - case AUDIO_FMT_16BIT:6.223 - for( j=0; j<num_samples; j++ ) {6.224 - sample = ((int16_t *)(arm_mem + channel->start))[channel->posn];6.225 - result_buf[j][0] += sample * vol_left;6.226 - result_buf[j][1] += sample * vol_right;6.227 -6.228 - channel->posn_left += channel->sample_rate;6.229 - while( channel->posn_left > audio.output_rate ) {6.230 - channel->posn_left -= audio.output_rate;6.231 - channel->posn++;6.232 -6.233 - if( channel->posn == channel->end ) {6.234 - if( channel->loop ) {6.235 - channel->posn = channel->loop_start;6.236 - channel->loop = LOOP_LOOPED;6.237 - } else {6.238 - audio_stop_channel(i);6.239 - j = num_samples;6.240 - break;6.241 - }6.242 - }6.243 - }6.244 - }6.245 - break;6.246 - case AUDIO_FMT_8BIT:6.247 - for( j=0; j<num_samples; j++ ) {6.248 - sample = ((int8_t *)(arm_mem + channel->start))[channel->posn] << 8;6.249 - result_buf[j][0] += sample * vol_left;6.250 - result_buf[j][1] += sample * vol_right;6.251 -6.252 - channel->posn_left += channel->sample_rate;6.253 - while( channel->posn_left > audio.output_rate ) {6.254 - channel->posn_left -= audio.output_rate;6.255 - channel->posn++;6.256 -6.257 - if( channel->posn == channel->end ) {6.258 - if( channel->loop ) {6.259 - channel->posn = channel->loop_start;6.260 - channel->loop = LOOP_LOOPED;6.261 - } else {6.262 - audio_stop_channel(i);6.263 - j = num_samples;6.264 - break;6.265 - }6.266 - }6.267 - }6.268 - }6.269 - break;6.270 - case AUDIO_FMT_ADPCM:6.271 - for( j=0; j<num_samples; j++ ) {6.272 - sample = (int16_t)channel->adpcm_predict;6.273 - result_buf[j][0] += sample * vol_left;6.274 - result_buf[j][1] += sample * vol_right;6.275 - channel->posn_left += channel->sample_rate;6.276 - while( channel->posn_left > audio.output_rate ) {6.277 - channel->posn_left -= audio.output_rate;6.278 - channel->posn++;6.279 - if( channel->posn == channel->end ) {6.280 - if( channel->loop ) {6.281 - channel->posn = channel->loop_start;6.282 - channel->loop = LOOP_LOOPED;6.283 - channel->adpcm_predict = 0;6.284 - channel->adpcm_step = 0;6.285 - } else {6.286 - audio_stop_channel(i);6.287 - j = num_samples;6.288 - break;6.289 - }6.290 - }6.291 - uint8_t data = ((uint8_t *)(arm_mem + channel->start))[channel->posn>>1];6.292 - if( channel->posn&1 ) {6.293 - adpcm_yamaha_decode_nibble( channel, (data >> 4) & 0x0F );6.294 - } else {6.295 - adpcm_yamaha_decode_nibble( channel, data & 0x0F );6.296 - }6.297 - }6.298 - }6.299 - break;6.300 - default:6.301 - break;6.302 - }6.303 - }6.304 + audio_channel_t channel = &audio.channels[i];6.305 + if( channel->active ) {6.306 + int32_t sample;6.307 + int vol_left = (channel->vol * (32 - channel->pan)) >> 5;6.308 + int vol_right = (channel->vol * (channel->pan + 1)) >> 5;6.309 + switch( channel->sample_format ) {6.310 + case AUDIO_FMT_16BIT:6.311 + for( j=0; j<num_samples; j++ ) {6.312 + sample = ((int16_t *)(arm_mem + channel->start))[channel->posn];6.313 + result_buf[j][0] += sample * vol_left;6.314 + result_buf[j][1] += sample * vol_right;6.315 +6.316 + channel->posn_left += channel->sample_rate;6.317 + while( channel->posn_left > audio.output_rate ) {6.318 + channel->posn_left -= audio.output_rate;6.319 + channel->posn++;6.320 +6.321 + if( channel->posn == channel->end ) {6.322 + if( channel->loop ) {6.323 + channel->posn = channel->loop_start;6.324 + channel->loop = LOOP_LOOPED;6.325 + } else {6.326 + audio_stop_channel(i);6.327 + j = num_samples;6.328 + break;6.329 + }6.330 + }6.331 + }6.332 + }6.333 + break;6.334 + case AUDIO_FMT_8BIT:6.335 + for( j=0; j<num_samples; j++ ) {6.336 + sample = ((int8_t *)(arm_mem + channel->start))[channel->posn] << 8;6.337 + result_buf[j][0] += sample * vol_left;6.338 + result_buf[j][1] += sample * vol_right;6.339 +6.340 + channel->posn_left += channel->sample_rate;6.341 + while( channel->posn_left > audio.output_rate ) {6.342 + channel->posn_left -= audio.output_rate;6.343 + channel->posn++;6.344 +6.345 + if( channel->posn == channel->end ) {6.346 + if( channel->loop ) {6.347 + channel->posn = channel->loop_start;6.348 + channel->loop = LOOP_LOOPED;6.349 + } else {6.350 + audio_stop_channel(i);6.351 + j = num_samples;6.352 + break;6.353 + }6.354 + }6.355 + }6.356 + }6.357 + break;6.358 + case AUDIO_FMT_ADPCM:6.359 + for( j=0; j<num_samples; j++ ) {6.360 + sample = (int16_t)channel->adpcm_predict;6.361 + result_buf[j][0] += sample * vol_left;6.362 + result_buf[j][1] += sample * vol_right;6.363 + channel->posn_left += channel->sample_rate;6.364 + while( channel->posn_left > audio.output_rate ) {6.365 + channel->posn_left -= audio.output_rate;6.366 + channel->posn++;6.367 + if( channel->posn == channel->end ) {6.368 + if( channel->loop ) {6.369 + channel->posn = channel->loop_start;6.370 + channel->loop = LOOP_LOOPED;6.371 + channel->adpcm_predict = 0;6.372 + channel->adpcm_step = 0;6.373 + } else {6.374 + audio_stop_channel(i);6.375 + j = num_samples;6.376 + break;6.377 + }6.378 + }6.379 + uint8_t data = ((uint8_t *)(arm_mem + channel->start))[channel->posn>>1];6.380 + if( channel->posn&1 ) {6.381 + adpcm_yamaha_decode_nibble( channel, (data >> 4) & 0x0F );6.382 + } else {6.383 + adpcm_yamaha_decode_nibble( channel, data & 0x0F );6.384 + }6.385 + }6.386 + }6.387 + break;6.388 + default:6.389 + break;6.390 + }6.391 + }6.392 }6.394 /* Down-render to the final output format */6.395 + audio_buffer_t buf = audio.output_buffers[audio.write_buffer];6.396 + if( buf->status == BUFFER_FULL ) {6.397 + buf = audio_next_write_buffer();6.398 + if( buf == NULL ) { // no available space6.399 + return;6.400 + }6.401 + }6.403 - if( audio.output_format & AUDIO_FMT_16BIT ) {6.404 - audio_buffer_t buf = audio.output_buffers[audio.write_buffer];6.405 - uint16_t *data = (uint16_t *)&buf->data[buf->posn];6.406 - for( j=0; j < num_samples; j++ ) {6.407 - *data++ = (int16_t)(result_buf[j][0] >> 6);6.408 - *data++ = (int16_t)(result_buf[j][1] >> 6);6.409 - buf->posn += 4;6.410 - if( buf->posn == buf->length ) {6.411 - audio_next_write_buffer();6.412 - buf = audio.output_buffers[audio.write_buffer];6.413 - data = (uint16_t *)&buf->data[0];6.414 - }6.415 - }6.416 - } else {6.417 - audio_buffer_t buf = audio.output_buffers[audio.write_buffer];6.418 - uint8_t *data = (uint8_t *)&buf->data[buf->posn];6.419 - for( j=0; j < num_samples; j++ ) {6.420 - *data++ = (uint8_t)(result_buf[j][0] >> 16);6.421 - *data++ = (uint8_t)(result_buf[j][1] >> 16);6.422 - buf->posn += 2;6.423 - if( buf->posn == buf->length ) {6.424 - audio_next_write_buffer();6.425 - buf = audio.output_buffers[audio.write_buffer];6.426 - data = (uint8_t *)&buf->data[0];6.427 - }6.428 - }6.429 + switch( audio.output_format & AUDIO_FMT_SAMPLE_MASK ) {6.430 + case AUDIO_FMT_FLOAT: {6.431 + float scale = 1.0/SHRT_MAX;6.432 + float *data = (float *)&buf->data[buf->posn];6.433 + for( j=0; j<num_samples; j++ ) {6.434 + *data++ = scale * (result_buf[j][0] >> 6);6.435 + *data++ = scale * (result_buf[j][1] >> 6);6.436 + buf->posn += 8;6.437 + if( buf->posn == buf->length ) {6.438 + buf = audio_next_write_buffer();6.439 + if( buf == NULL ) {6.440 + break;6.441 + }6.442 + data = (float *)&buf->data[0];6.443 + }6.444 + }6.445 + break;6.446 + }6.447 + case AUDIO_FMT_16BIT: {6.448 + int16_t *data = (int16_t *)&buf->data[buf->posn];6.449 + for( j=0; j < num_samples; j++ ) {6.450 + *data++ = (int16_t)(result_buf[j][0] >> 6);6.451 + *data++ = (int16_t)(result_buf[j][1] >> 6);6.452 + buf->posn += 4;6.453 + if( buf->posn == buf->length ) {6.454 + buf = audio_next_write_buffer();6.455 + if( buf == NULL ) {6.456 + // All buffers are full6.457 + break;6.458 + }6.459 + data = (int16_t *)&buf->data[0];6.460 + }6.461 + }6.462 + break;6.463 + }6.464 + case AUDIO_FMT_8BIT: {6.465 + int8_t *data = (uint8_t *)&buf->data[buf->posn];6.466 + for( j=0; j < num_samples; j++ ) {6.467 + *data++ = (int8_t)(result_buf[j][0] >> 16);6.468 + *data++ = (int8_t)(result_buf[j][1] >> 16);6.469 + buf->posn += 2;6.470 + if( buf->posn == buf->length ) {6.471 + buf = audio_next_write_buffer();6.472 + if( buf == NULL ) {6.473 + // All buffers are full6.474 + break;6.475 + }6.476 + buf = audio.output_buffers[audio.write_buffer];6.477 + data = (uint8_t *)&buf->data[0];6.478 + }6.479 + }6.480 + break;6.481 + }6.482 }6.483 }
7.1 --- a/src/aica/audio.h Sun Jun 22 03:59:56 2008 +00007.2 +++ b/src/aica/audio.h Sun Jun 22 04:01:27 2008 +00007.3 @@ -31,13 +31,20 @@7.4 #define AUDIO_FMT_8BIT 07.5 #define AUDIO_FMT_16BIT 17.6 #define AUDIO_FMT_ADPCM 27.7 +#define AUDIO_FMT_FLOAT 3 // 32-bit -1.0 to 1.07.8 #define AUDIO_FMT_MONO 07.9 #define AUDIO_FMT_STEREO 47.10 #define AUDIO_FMT_SIGNED 07.11 #define AUDIO_FMT_UNSIGNED 87.12 +7.13 +#define AUDIO_FMT_SAMPLE_MASK 37.15 #define AUDIO_FMT_16ST (AUDIO_FMT_16BIT|AUDIO_FMT_STEREO)7.16 +#define AUDIO_FMT_FLOATST (AUDIO_FMT_FLOAT|AUDIO_FMT_STEREO)7.18 +#define DEFAULT_SAMPLE_RATE 441007.19 +#define DEFAULT_SAMPLE_FORMAT AUDIO_FMT_16ST7.20 +7.21 typedef enum { LOOP_OFF = 0, LOOP_ON = 1, LOOP_LOOPED = 2 } loop_t;7.23 typedef struct audio_channel {7.24 @@ -68,17 +75,15 @@7.26 typedef struct audio_driver {7.27 char *name;7.28 - gboolean (*init)( );7.29 - gboolean (*set_output_format)( uint32_t sample_rate, uint32_t format );7.30 + uint32_t sample_rate;7.31 + uint32_t sample_format;7.32 + gboolean (*init)( );7.33 + void (*start)( );7.34 gboolean (*process_buffer)( audio_buffer_t buffer );7.35 - gboolean (*close)( );7.36 + void (*stop)( );7.37 + gboolean (*shutdown)( );7.38 } *audio_driver_t;7.40 -extern struct audio_driver audio_null_driver;7.41 -extern struct audio_driver audio_pulse_driver;7.42 -extern struct audio_driver audio_esd_driver;7.43 -extern struct audio_driver audio_alsa_driver;7.44 -7.45 audio_driver_t get_audio_driver_by_name( const char *name );7.47 /**7.48 @@ -86,8 +91,7 @@7.49 * output buffers, flushing any current data and reallocating as7.50 * necessary. Must be called before attempting to generate any audio.7.51 */7.52 -gboolean audio_set_driver( audio_driver_t driver, uint32_t samplerate,7.53 - int format );7.54 +gboolean audio_set_driver( audio_driver_t driver );7.56 /**7.57 * Mark the current write buffer as full and prepare the next buffer for7.58 @@ -122,4 +126,4 @@7.59 #ifdef __cplusplus7.60 }7.61 #endif7.62 -#endif7.63 +#endif7.64 \ No newline at end of file
8.1 --- a/src/drivers/audio_alsa.c Sun Jun 22 03:59:56 2008 +00008.2 +++ b/src/drivers/audio_alsa.c Sun Jun 22 04:01:27 2008 +00008.3 @@ -39,17 +39,13 @@8.5 gboolean audio_alsa_init( )8.6 {8.7 - return TRUE;8.8 -}8.9 -8.10 -8.11 -gboolean audio_alsa_set_format( uint32_t rate, uint32_t format )8.12 -{8.13 int err;8.14 snd_pcm_hw_params_t *hw_params;8.15 snd_pcm_sw_params_t *sw_params;8.16 snd_pcm_uframes_t frames;8.17 snd_pcm_uframes_t bufferSize;8.18 + int rate = DEFAULT_SAMPLE_RATE;8.19 + int format = DEFAULT_SAMPLE_FORMAT;8.20 int dir;8.23 @@ -179,7 +175,7 @@8.24 }8.27 -gboolean audio_alsa_close( )8.28 +gboolean audio_alsa_shutdown( )8.29 {8.30 return TRUE;8.31 }8.32 @@ -188,8 +184,11 @@8.34 struct audio_driver audio_alsa_driver = {8.35 "alsa",8.36 + DEFAULT_SAMPLE_RATE,8.37 + DEFAULT_SAMPLE_FORMAT,8.38 audio_alsa_init,8.39 - audio_alsa_set_format,8.40 + NULL,8.41 audio_alsa_process_buffer,8.42 - audio_alsa_close8.43 + NULL,8.44 + audio_alsa_shutdown8.45 };
9.1 --- a/src/drivers/audio_esd.c Sun Jun 22 03:59:56 2008 +00009.2 +++ b/src/drivers/audio_esd.c Sun Jun 22 04:01:27 2008 +00009.3 @@ -27,28 +27,26 @@9.5 gboolean audio_esd_init()9.6 {9.7 - return TRUE;9.8 -}9.9 -9.10 -gboolean audio_esd_set_format( uint32_t rate, uint32_t format )9.11 -{9.12 + int format = DEFAULT_SAMPLE_FORMAT;9.13 + int rate = DEFAULT_SAMPLE_RATE;9.14 +9.15 if( esd_handle != -1 ) {9.16 - esd_close(esd_handle);9.17 + esd_close(esd_handle);9.18 }9.19 esd_format_t esd_format = 0;9.20 esd_sample_size = 1;9.21 if( format & AUDIO_FMT_16BIT ) {9.22 - esd_format |= ESD_BITS16;9.23 + esd_format |= ESD_BITS16;9.24 } else esd_format |= ESD_BITS8;9.25 if( format & AUDIO_FMT_STEREO ) {9.26 - esd_format |= ESD_STEREO;9.27 + esd_format |= ESD_STEREO;9.28 }9.29 else esd_format |= ESD_MONO;9.30 -9.31 +9.32 esd_handle = esd_play_stream( esd_format, rate, "localhost", "lxdream" );9.33 if( esd_handle == -1 ) {9.34 - ERROR( "Unable to open audio output (ESD)" );9.35 - return FALSE;9.36 + ERROR( "Unable to open audio output (ESD)" );9.37 + return FALSE;9.38 }9.39 return TRUE;9.40 }9.41 @@ -56,22 +54,27 @@9.42 gboolean audio_esd_process_buffer( audio_buffer_t buffer )9.43 {9.44 if( esd_handle != -1 ) {9.45 - write( esd_handle, buffer->data, buffer->length );9.46 - return TRUE;9.47 + write( esd_handle, buffer->data, buffer->length );9.48 + return TRUE;9.49 } else {9.50 - ERROR( "ESD not initialized" );9.51 - return FALSE;9.52 + ERROR( "ESD not initialized" );9.53 + return FALSE;9.54 }9.55 }9.57 -gboolean audio_esd_close()9.58 +gboolean audio_esd_shutdown()9.59 {9.60 - return TRUE;9.61 + close(esd_handle);9.62 + esd_handle = -1;9.63 + return TRUE;9.64 }9.66 struct audio_driver audio_esd_driver = { "esd",9.67 - audio_esd_init,9.68 - audio_esd_set_format,9.69 - audio_esd_process_buffer,9.70 - audio_esd_close};9.71 + DEFAULT_SAMPLE_RATE,9.72 + DEFAULT_SAMPLE_FORMAT,9.73 + audio_esd_init,9.74 + NULL,9.75 + audio_esd_process_buffer,9.76 + NULL,9.77 + audio_esd_shutdown};
10.1 --- a/src/drivers/audio_null.c Sun Jun 22 03:59:56 2008 +000010.2 +++ b/src/drivers/audio_null.c Sun Jun 22 04:01:27 2008 +000010.3 @@ -23,23 +23,21 @@10.4 return TRUE;10.5 }10.7 -gboolean audio_null_set_format( uint32_t rate, uint32_t format )10.8 -{10.9 - return TRUE;10.10 -}10.11 -10.12 gboolean audio_null_process_buffer( audio_buffer_t buffer )10.13 {10.14 return TRUE;10.15 }10.17 -gboolean audio_null_close()10.18 +gboolean audio_null_shutdown()10.19 {10.20 return TRUE;10.21 }10.23 -struct audio_driver audio_null_driver = { "null",10.24 - audio_null_init,10.25 - audio_null_set_format,10.26 - audio_null_process_buffer,10.27 - audio_null_close};10.28 +struct audio_driver audio_null_driver = { "null",10.29 + DEFAULT_SAMPLE_RATE,10.30 + DEFAULT_SAMPLE_FORMAT,10.31 + audio_null_init,10.32 + NULL,10.33 + audio_null_process_buffer,10.34 + NULL,10.35 + audio_null_shutdown};
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +000011.2 +++ b/src/drivers/audio_osx.c Sun Jun 22 04:01:27 2008 +000011.3 @@ -0,0 +1,142 @@11.4 +/**11.5 + * $Id$11.6 + *11.7 + * The darwin core-audio audio driver11.8 + *11.9 + * Copyright (c) 2008 Nathan Keynes.11.10 + *11.11 + * This program is free software; you can redistribute it and/or modify11.12 + * it under the terms of the GNU General Public License as published by11.13 + * the Free Software Foundation; either version 2 of the License, or11.14 + * (at your option) any later version.11.15 + *11.16 + * This program is distributed in the hope that it will be useful,11.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of11.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11.19 + * GNU General Public License for more details.11.20 + */11.21 +#include <stdio.h>11.22 +#include <unistd.h>11.23 +#include <AudioToolbox/AudioToolbox.h>11.24 +#include <AudioUnit/AudioUnitProperties.h>11.25 +#include "aica/audio.h"11.26 +#include "lxdream.h"11.27 +11.28 +static AudioUnit output_au;11.29 +static volatile audio_buffer_t output_buffer = NULL;11.30 +static int sample_size;11.31 +11.32 +OSStatus audio_osx_callback( void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags,11.33 + const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber,11.34 + UInt32 inNumberFrames, AudioBufferList *ioData )11.35 +{11.36 + char *output = ioData->mBuffers[0].mData;11.37 + int data_requested = inNumberFrames * sample_size;11.38 +11.39 + while( output_buffer != NULL && data_requested > 0 ) {11.40 + int copysize = output_buffer->length - output_buffer->posn;11.41 + if( copysize > data_requested ) {11.42 + copysize = data_requested;11.43 + }11.44 + memcpy( output, &output_buffer->data[output_buffer->posn], copysize );11.45 + output += copysize;11.46 + data_requested -= copysize;11.47 + output_buffer->posn += copysize;11.48 + if( output_buffer->posn >= output_buffer->length ) {11.49 + output_buffer = audio_next_read_buffer();11.50 + }11.51 + }11.52 + if( data_requested > 0 ) {11.53 + memset( output, 0, data_requested );11.54 + }11.55 + return noErr;11.56 +}11.57 +11.58 +static gboolean audio_osx_shutdown()11.59 +{11.60 + AudioUnitUninitialize( output_au );11.61 + CloseComponent( output_au );11.62 + return TRUE;11.63 +}11.64 +11.65 +static gboolean audio_osx_init()11.66 +{11.67 + AURenderCallbackStruct callbackData;11.68 + AudioStreamBasicDescription outputDesc;11.69 + UInt32 outputDescSize = sizeof(outputDesc);11.70 + ComponentDescription cd;11.71 + Component c;11.72 +11.73 + cd.componentType = kAudioUnitType_Output;11.74 + cd.componentSubType = kAudioUnitSubType_DefaultOutput;11.75 + cd.componentManufacturer = kAudioUnitManufacturer_Apple;11.76 + cd.componentFlags = 0;11.77 + cd.componentFlagsMask = 0;11.78 +11.79 + c = FindNextComponent( NULL, &cd );11.80 + if( c == NULL ) {11.81 + return FALSE;11.82 + }11.83 +11.84 + if( OpenAComponent( c, &output_au ) != noErr ) {11.85 + return FALSE;11.86 + }11.87 +11.88 + if( AudioUnitGetProperty( output_au, kAudioUnitProperty_StreamFormat,11.89 + kAudioUnitScope_Global, 0, &outputDesc, &outputDescSize ) != noErr ) {11.90 + CloseComponent( output_au );11.91 + return FALSE;11.92 + }11.93 +11.94 + outputDesc.mSampleRate = DEFAULT_SAMPLE_RATE;11.95 + sample_size = outputDesc.mBytesPerFrame;11.96 +11.97 + if( AudioUnitSetProperty( output_au, kAudioUnitProperty_StreamFormat,11.98 + kAudioUnitScope_Global, 0, &outputDesc, sizeof(outputDesc) ) != noErr ) {11.99 + CloseComponent( output_au );11.100 + return FALSE;11.101 + }11.102 +11.103 + if( AudioUnitInitialize( output_au ) != noErr ) {11.104 + CloseComponent( output_au );11.105 + return FALSE;11.106 + }11.107 +11.108 + callbackData.inputProc = audio_osx_callback;11.109 + callbackData.inputProcRefCon = NULL;11.110 + if( AudioUnitSetProperty( output_au, kAudioUnitProperty_SetRenderCallback,11.111 + kAudioUnitScope_Global, 0, &callbackData, sizeof(callbackData)) != noErr ) {11.112 + audio_osx_shutdown();11.113 + return FALSE;11.114 + }11.115 +11.116 + return TRUE;11.117 +}11.118 +static gboolean audio_osx_process_buffer( audio_buffer_t buffer )11.119 +{11.120 + if( output_buffer == NULL ) {11.121 + output_buffer = buffer;11.122 + output_buffer->posn = 0;11.123 + AudioOutputUnitStart(output_au);11.124 + return FALSE;11.125 + }11.126 +}11.127 +11.128 +void audio_osx_start()11.129 +{11.130 +}11.131 +11.132 +void audio_osx_stop()11.133 +{11.134 +}11.135 +11.136 +11.137 +struct audio_driver audio_osx_driver = { "osx",11.138 + DEFAULT_SAMPLE_RATE,11.139 + AUDIO_FMT_FLOATST,11.140 + audio_osx_init,11.141 + audio_osx_start,11.142 + audio_osx_process_buffer,11.143 + audio_osx_stop,11.144 + audio_osx_shutdown};11.145 +
12.1 --- a/src/drivers/audio_pulse.c Sun Jun 22 03:59:56 2008 +000012.2 +++ b/src/drivers/audio_pulse.c Sun Jun 22 04:01:27 2008 +000012.3 @@ -23,13 +23,10 @@12.5 static pa_simple *pulse_server = NULL;12.7 -gboolean audio_pulse_init()12.8 +gboolean audio_init( )12.9 {12.10 - return TRUE;12.11 -}12.12 -12.13 -gboolean audio_pulse_set_format( uint32_t rate, uint32_t format )12.14 -{12.15 + int rate = DEFAULT_SAMPLE_RATE;12.16 + int format = DEFAULT_SAMPLE_FORMAT;12.17 pa_sample_spec ss;12.19 if( pulse_server != NULL ) {12.20 @@ -70,16 +67,19 @@12.21 }12.22 }12.24 -gboolean audio_pulse_close()12.25 +gboolean audio_pulse_shutdown()12.26 {12.27 pa_simple_free(pulse_server);12.28 pulse_server = NULL;12.29 return TRUE;12.30 }12.32 -struct audio_driver audio_pulse_driver = { "pulse",12.33 - audio_pulse_init,12.34 - audio_pulse_set_format,12.35 - audio_pulse_process_buffer,12.36 - audio_pulse_close};12.37 +struct audio_driver audio_pulse_driver = { "pulse",12.38 + DEFAULT_SAMPLE_RATE,12.39 + DEFAULT_SAMPLE_FORMAT,12.40 + audio_pulse_init,12.41 + NULL,12.42 + audio_pulse_process_buffer,12.43 + NULL,12.44 + audio_pulse_shutdown};
13.1 --- a/src/main.c Sun Jun 22 03:59:56 2008 +000013.2 +++ b/src/main.c Sun Jun 22 04:01:27 2008 +000013.3 @@ -148,19 +148,11 @@13.5 if( without_bios ) {13.6 bios_install();13.7 - dcload_install();13.8 + dcload_install();13.9 }13.11 - audio_driver_t audio_driver = get_audio_driver_by_name(audio_driver_name);13.12 - if( audio_driver == NULL ) {13.13 - ERROR( "Audio driver '%s' not found, aborting.", audio_driver_name );13.14 - exit(2);13.15 - } else if( audio_set_driver( audio_driver, 44100, AUDIO_FMT_16ST ) == FALSE ) {13.16 - ERROR( "Failed to initialize audio driver '%s', using null driver",13.17 - audio_driver->name );13.18 - audio_set_driver( &audio_null_driver, 44100, AUDIO_FMT_16ST );13.19 - }13.20 -13.21 + audio_init_driver( audio_driver_name, 44100, AUDIO_FMT_16ST );13.22 +13.23 if( headless ) {13.24 display_set_driver( &display_null_driver );13.25 } else {
.