# default stuff goes here, so that config can override
TARGET = pcsx
CFLAGS += -Wall -ggdb -Ifrontend -ffast-math
-LDLIBS += -lpthread -ldl -lpng -lz -lm
+LDLIBS += -lpthread -lm
ifndef DEBUG
CFLAGS += -O2 -DNDEBUG
endif
-include Makefile.local
CC_LINK = $(CC)
+LDLIBS += $(MAIN_LDLIBS)
# core
OBJS += libpcsxcore/cdriso.o libpcsxcore/cdrom.o libpcsxcore/cheat.o libpcsxcore/debug.o \
# spu
OBJS += plugins/dfsound/dma.o plugins/dfsound/freeze.o \
- plugins/dfsound/registers.o plugins/dfsound/spu.o
+ plugins/dfsound/registers.o plugins/dfsound/spu.o \
+ plugins/dfsound/out.o plugins/dfsound/nullsnd.o
plugins/dfsound/spu.o: plugins/dfsound/adsr.c plugins/dfsound/reverb.c \
plugins/dfsound/xa.c
ifeq "$(ARCH)" "arm"
OBJS += plugins/dfsound/arm_utils.o
endif
-ifeq "$(SOUND_DRIVER)" "oss"
-plugins/dfsound/%.o: CFLAGS += -DUSEOSS
+ifneq ($(findstring oss,$(SOUND_DRIVERS)),)
+plugins/dfsound/out.o: CFLAGS += -DHAVE_OSS
OBJS += plugins/dfsound/oss.o
endif
-ifeq "$(SOUND_DRIVER)" "alsa"
-plugins/dfsound/%.o: CFLAGS += -DUSEALSA
+ifneq ($(findstring alsa,$(SOUND_DRIVERS)),)
+plugins/dfsound/out.o: CFLAGS += -DHAVE_ALSA
OBJS += plugins/dfsound/alsa.o
LDLIBS += -lasound
endif
-ifeq "$(SOUND_DRIVER)" "sdl"
+ifneq ($(findstring sdl,$(SOUND_DRIVERS)),)
+plugins/dfsound/out.o: CFLAGS += -DHAVE_SDL
OBJS += plugins/dfsound/sdl.o
endif
-ifeq "$(SOUND_DRIVER)" "none"
-OBJS += plugins/dfsound/nullsnd.o
+ifneq ($(findstring pulseaudio,$(SOUND_DRIVERS)),)
+plugins/dfsound/out.o: CFLAGS += -DHAVE_PULSE
+OBJS += plugins/dfsound/pulseaudio.o
+endif
+ifneq ($(findstring libretro,$(SOUND_DRIVERS)),)
+plugins/dfsound/out.o: CFLAGS += -DHAVE_LIBRETRO
endif
# builtin gpu
TMPC="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}.c"
TMPO="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}.o"
-trap "rm -f $TMPC $TMPO" EXIT INT QUIT TERM
+TMPB="/tmp/pcsx-conf-${RANDOM}-$$-${RANDOM}"
+trap "rm -f $TMPC $TMPO $TMPB" EXIT INT QUIT TERM
rm -f config.log
compile_object()
{
- c="$CC $CFLAGS -c $TMPC -o $TMPO $1"
+ c="$CC $CFLAGS -c $TMPC -o $TMPO $@"
+ echo $c >> config.log
+ $c >> config.log 2>&1
+}
+
+compile_binary()
+{
+ c="$CC $CFLAGS $TMPC -o $TMPB $LDFLAGS $MAIN_LDLIBS $@"
echo $c >> config.log
$c >> config.log 2>&1
}
platform="generic"
builtin_gpu_list="peops unai neon"
builtin_gpu=""
-sound_driver_list="oss alsa sdl libretro none"
-sound_driver="alsa"
+sound_driver_list="oss alsa sdl pulseaudio libretro"
+sound_drivers=""
plugins="plugins/spunull/spunull.so \
plugins/dfxvideo/gpu_peops.so plugins/gpu_unai/gpu_unai.so"
ram_fixed="no"
CXX="${CXX-${CROSS_COMPILE}g++}"
AS="${AS-${CROSS_COMPILE}as}"
AR="${AS-${CROSS_COMPILE}ar}"
+MAIN_LDLIBS="$LDLIBS -ldl -lpng -lz"
config_mak="config.mak"
+fail()
+{
+ echo "$@"
+ exit 1
+}
+
# call during arg parsing, so that cmd line can override platform defaults
set_platform()
{
generic)
;;
pandora)
- sound_driver="oss"
+ sound_drivers="oss alsa"
ram_fixed="yes"
drc_cache_base="yes"
optimize_cortexa8="yes"
have_arm_neon="yes"
;;
caanoo)
- sound_driver="oss"
+ sound_drivers="oss"
ram_fixed="yes"
drc_cache_base="yes"
optimize_arm926ej="yes"
;;
libretro)
- sound_driver="libretro"
+ sound_drivers="libretro"
;;
*)
- echo "unsupported platform: $platform"
- exit 1
+ fail "unsupported platform: $platform"
;;
esac
}
;;
--gpu=*) builtin_gpu="$optarg"
;;
- --sound-driver=*) sound_driver="$optarg"
+ --sound-drivers=*) sound_drivers="$optarg"
;;
--enable-neon) have_arm_neon="yes"
;;
echo " available: $platform_list"
echo " --gpu=NAME builtin gpu plugin [guessed]"
echo " available: $builtin_gpu_list"
- echo " --sound-driver=NAME sound output driver [$sound_driver]"
+ echo " --sound-drivers=LIST sound output drivers [guessed]"
echo " available: $sound_driver_list"
echo " --enable-neon"
echo " --disable-neon enable/disable ARM NEON optimizations [guessed]"
exit 1
fi
+# validate selections
if [ "x$builtin_gpu" != "x" ]; then
- case "$builtin_gpu" in
- peops|unai|neon)
- ;;
- *)
- echo "unsupported builtin gpu plugin: $builtin_gpu"
- exit 1
- ;;
- esac
+ if ! echo $builtin_gpu_list | grep -q "\<$builtin_gpu\>"; then
+ fail "unsupported builtin gpu plugin: $builtin_gpu"
+ fi
fi
-case "$sound_driver" in
-oss|alsa|sdl|libretro|none)
- ;;
-*)
- echo "unsupported sound driver: $sound_driver"
- exit 1
- ;;
-esac
+if [ "x$sound_drivers" != "x" ]; then
+ for d in $sound_drivers; do
+ if ! echo $sound_driver_list | grep -q "\<$d\>"; then
+ fail "unsupported sound driver: $sound_driver"
+ fi
+ done
+fi
if [ -z "$ARCH" ]; then
ARCH=`$CC -v 2>&1 | grep -i 'target:' | awk '{print $2}' \
generic_cflags=`sdl-config --cflags`
generic_ldlibs=`sdl-config --libs`
CFLAGS="$CFLAGS $generic_cflags"
- LDFLAGS="$LDFLAGS $generic_ldlibs"
+ MAIN_LDLIBS="$MAIN_LDLIBS $generic_ldlibs"
;;
maemo)
maemo_cflags=`pkg-config --cflags hildon-1`
maemo_ldlibs=`pkg-config --libs hildon-1`
CFLAGS="$CFLAGS -DMAEMO -DMAEMO_CHANGES $maemo_cflags"
- LDFLAGS="$LDFLAGS $maemo_ldlibs"
+ MAIN_LDLIBS="$MAIN_LDLIBS $maemo_ldlibs"
;;
libretro)
CFLAGS="$CFLAGS -fPIC"
;;
esac
+# header/library presence tests
+check_zlib()
+{
+ cat > $TMPC <<EOF
+ #include <zlib.h>
+ void main() { uncompress(0, 0, 0, 0); }
+EOF
+ compile_binary
+}
+
+check_bzlib()
+{
+ cat > $TMPC <<EOF
+ #include <bzlib.h>
+ void main() { BZ2_bzBuffToBuffDecompress(0, 0, 0, 0, 0, 0); }
+EOF
+ compile_object
+}
+
+check_libpng()
+{
+ cat > $TMPC <<EOF
+ #include <png.h>
+ void main() { png_init_io(0, 0); }
+EOF
+ compile_binary
+}
+
+check_oss()
+{
+ cat > $TMPC <<EOF
+ #include <sys/soundcard.h>
+ #include <sys/ioctl.h>
+ void main() { int a=0; ioctl(0, SNDCTL_DSP_SETFMT, &a); }
+EOF
+ compile_binary
+}
+
+check_alsa()
+{
+ cat > $TMPC <<EOF
+ #include <alsa/asoundlib.h>
+ void main() { snd_pcm_open(0, 0, 0, 0); }
+EOF
+ compile_binary "$@"
+}
+
+check_sdl()
+{
+ cat > $TMPC <<EOF
+ #include <SDL.h>
+ void main() { SDL_OpenAudio(0, 0); }
+EOF
+ compile_binary "$@"
+}
+
+check_zlib || fail "please install libz-dev"
+check_bzlib || fail "please install libbz2-dev"
+check_libpng || fail "please install libpng-dev"
+
+# find what audio support we can compile
+if [ "x$sound_drivers" = "x" ]; then
+ if check_oss; then sound_drivers="$sound_drivers oss"; fi
+ if check_alsa -lasound; then sound_drivers="$sound_drivers alsa"; fi
+ if check_sdl; then sound_drivers="$sound_drivers sdl"; fi
+fi
+
+if echo $sound_drivers | grep -q "\<oss\>"; then
+ check_oss || fail "oss support missing"
+fi
+if echo $sound_drivers | grep -q "\<alsa\>"; then
+ MAIN_LDLIBS="$MAIN_LDLIBS -lasound"
+ check_alsa || fail "please install libasound2-dev"
+fi
+if echo $sound_drivers | grep -q "\<sdl\>"; then
+ echo $MAIN_LDLIBS | grep -qi SDL || CFLAGS="$CFLAGS `sdl-config --cflags`"
+ echo $MAIN_LDLIBS | grep -qi SDL || MAIN_LDLIBS="$MAIN_LDLIBS `sdl-config --libs`"
+ check_sdl || fail "please install libsdl1.2-dev"
+fi
+
# check for tslib (only headers needed)
if [ "x$have_tslib" = "x" ]; then
cat > $TMPC <<EOF
echo "architecture $ARCH"
echo "platform $platform"
echo "built-in GPU $builtin_gpu"
-echo "sound driver $sound_driver"
+echo "sound drivers $sound_drivers"
echo "plugins $plugins_short"
echo "C compiler $CC"
echo "C compiler flags $CFLAGS"
+echo "libraries $MAIN_LDLIBS"
echo "linker flags $LDFLAGS"
echo "enable dynarec $enable_dynarec"
echo "ARMv7 optimizations $have_armv7"
echo "CFLAGS += $CFLAGS" >> $config_mak
echo "ASFLAGS += $ASFLAGS" >> $config_mak
echo "LDFLAGS += $LDFLAGS" >> $config_mak
-echo "LDLIBS += $LDLIBS" >> $config_mak
+echo "MAIN_LDLIBS += $MAIN_LDLIBS" >> $config_mak
echo "PLUGIN_CFLAGS += $PLUGIN_CFLAGS" >> $config_mak
echo >> $config_mak
echo "ARCH = $ARCH" >> $config_mak
echo "PLATFORM = $platform" >> $config_mak
echo "BUILTIN_GPU = $builtin_gpu" >> $config_mak
-echo "SOUND_DRIVER = $sound_driver" >> $config_mak
+echo "SOUND_DRIVERS = $sound_drivers" >> $config_mak
if [ "$ARCH" = "arm" ]; then
echo "PLUGINS = $plugins" >> $config_mak
else
#include "../libpcsxcore/misc.h"
#include "../libpcsxcore/psxcounters.h"
#include "../libpcsxcore/new_dynarec/new_dynarec.h"
+#include "../plugins/dfsound/out.h"
#include "main.h"
#include "plugin.h"
#include "plugin_lib.h"
}
/* sound calls */
-void SetupSound(void)
+static int snd_init(void)
{
+ return 0;
}
-void RemoveSound(void)
+static void snd_finish(void)
{
}
-unsigned long SoundGetBytesBuffered(void)
+static int snd_busy(void)
{
if (samples_to_send > samples_sent)
return 0; /* give more samples */
return 1;
}
-void SoundFeedStreamData(void *buf, long bytes)
+static void snd_feed(void *buf, int bytes)
{
audio_batch_cb(buf, bytes / 4);
samples_sent += bytes / 4;
}
+void out_register_libretro(struct out_driver *drv)
+{
+ drv->name = "libretro";
+ drv->init = snd_init;
+ drv->finish = snd_finish;
+ drv->busy = snd_busy;
+ drv->feed = snd_feed;
+}
+
/* libretro */
void retro_set_environment(retro_environment_t cb) { environ_cb = cb; }
void retro_set_video_refresh(retro_video_refresh_t cb) { video_cb = cb; }
* *
***************************************************************************/
-#include "stdafx.h"
-
-#define _IN_OSS
-
-#include "externals.h"
-
+#include <stdio.h>
#define ALSA_PCM_NEW_HW_PARAMS_API
#define ALSA_PCM_NEW_SW_PARAMS_API
#include <alsa/asoundlib.h>
+#include "out.h"
static snd_pcm_t *handle = NULL;
static snd_pcm_uframes_t buffer_size;
// SETUP SOUND
-void SetupSound(void)
+static int alsa_init(void)
{
snd_pcm_hw_params_t *hwparams;
snd_pcm_status_t *status;
SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0)
{
printf("Audio open error: %s\n", snd_strerror(err));
- return;
+ return -1;
}
if((err = snd_pcm_nonblock(handle, 0))<0)
{
printf("Can't set blocking moded: %s\n", snd_strerror(err));
- return;
+ return -1;
}
snd_pcm_hw_params_alloca(&hwparams);
if((err=snd_pcm_hw_params_any(handle, hwparams))<0)
{
printf("Broken configuration for this PCM: %s\n", snd_strerror(err));
- return;
+ return -1;
}
if((err=snd_pcm_hw_params_set_access(handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED))<0)
{
printf("Access type not available: %s\n", snd_strerror(err));
- return;
+ return -1;
}
if((err=snd_pcm_hw_params_set_format(handle, hwparams, format))<0)
{
printf("Sample format not available: %s\n", snd_strerror(err));
- return;
+ return -1;
}
if((err=snd_pcm_hw_params_set_channels(handle, hwparams, pchannels))<0)
{
printf("Channels count not available: %s\n", snd_strerror(err));
- return;
+ return -1;
}
if((err=snd_pcm_hw_params_set_rate_near(handle, hwparams, &pspeed, 0))<0)
{
printf("Rate not available: %s\n", snd_strerror(err));
- return;
+ return -1;
}
if((err=snd_pcm_hw_params_set_buffer_time_near(handle, hwparams, &buffer_time, 0))<0)
{
printf("Buffer time error: %s\n", snd_strerror(err));
- return;
+ return -1;
}
if((err=snd_pcm_hw_params_set_period_time_near(handle, hwparams, &period_time, 0))<0)
{
printf("Period time error: %s\n", snd_strerror(err));
- return;
+ return -1;
}
if((err=snd_pcm_hw_params(handle, hwparams))<0)
{
printf("Unable to install hw params: %s\n", snd_strerror(err));
- return;
+ return -1;
}
snd_pcm_status_alloca(&status);
if((err=snd_pcm_status(handle, status))<0)
{
printf("Unable to get status: %s\n", snd_strerror(err));
- return;
+ return -1;
}
buffer_size = snd_pcm_status_get_avail(status);
+ return 0;
}
// REMOVE SOUND
-void RemoveSound(void)
+static void alsa_finish(void)
{
if(handle != NULL)
{
}
// GET BYTES BUFFERED
-unsigned long SoundGetBytesBuffered(void)
+static int alsa_busy(void)
{
- unsigned long l;
+ int l;
if (handle == NULL) // failed to open?
return 1;
}
// FEED SOUND DATA
-void SoundFeedStreamData(unsigned char* pSound,long lBytes)
+static void alsa_feed(void *pSound, int lBytes)
{
if (handle == NULL) return;
snd_pcm_prepare(handle);
snd_pcm_writei(handle,pSound, lBytes / 4);
}
+
+void out_register_alsa(struct out_driver *drv)
+{
+ drv->name = "alsa";
+ drv->init = alsa_init;
+ drv->finish = alsa_finish;
+ drv->busy = alsa_busy;
+ drv->feed = alsa_feed;
+}
+++ /dev/null
-/***************************************************************************
- dsoundoss.h - description
- -------------------
- begin : Wed May 15 2002
- copyright : (C) 2002 by Pete Bernert
- email : BlackDove@addcom.de
- ***************************************************************************/
-/***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. See also the license.txt file for *
- * additional informations. *
- * *
- ***************************************************************************/
-
-void SetupSound(void);
-void RemoveSound(void);
-unsigned long SoundGetBytesBuffered(void);
-void SoundFeedStreamData(unsigned char* pSound,long lBytes);
-#include "stdafx.h"
-#define _IN_OSS
-#include "externals.h"
+#include "out.h"
// SETUP SOUND
-void SetupSound(void)
+static int none_init(void)
{
+ return 0;
}
// REMOVE SOUND
-void RemoveSound(void)
+static void none_finish(void)
{
}
// GET BYTES BUFFERED
-unsigned long SoundGetBytesBuffered(void)
+static int none_busy(void)
{
- return 0;
+ return 1;
}
// FEED SOUND DATA
-void SoundFeedStreamData(unsigned char* pSound,long lBytes)
+static void none_feed(void *buf, int bytes)
+{
+}
+
+void out_register_none(struct out_driver *drv)
{
+ drv->name = "none";
+ drv->init = none_init;
+ drv->finish = none_finish;
+ drv->busy = none_busy;
+ drv->feed = none_feed;
}
* *
***************************************************************************/
-#include "stdafx.h"
-
-#define _IN_OSS
-
-#include "externals.h"
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <sys/soundcard.h>
+#include "out.h"
////////////////////////////////////////////////////////////////////////
// oss globals
// SETUP SOUND
////////////////////////////////////////////////////////////////////////
-void SetupSound(void)
+static int oss_init(void)
{
int pspeed=44100;
int pstereo;
if((oss_audio_fd=open("/dev/dsp",O_WRONLY,0))==-1)
{
- printf("Sound device not available!\n");
- return;
+ printf("OSS device not available\n");
+ return -1;
}
if(ioctl(oss_audio_fd,SNDCTL_DSP_RESET,0)==-1)
{
printf("Sound reset failed\n");
- return;
+ return -1;
}
// we use 64 fragments with 1024 bytes each
if(ioctl(oss_audio_fd,SNDCTL_DSP_SETFRAGMENT,&myfrag)==-1)
{
printf("Sound set fragment failed!\n");
- return;
+ return -1;
}
format = AFMT_S16_NE;
if(ioctl(oss_audio_fd,SNDCTL_DSP_SETFMT,&format) == -1)
{
printf("Sound format not supported!\n");
- return;
+ return -1;
}
if(format!=AFMT_S16_NE)
{
printf("Sound format not supported!\n");
- return;
+ return -1;
}
if(ioctl(oss_audio_fd,SNDCTL_DSP_STEREO,&oss_stereo)==-1 || !oss_stereo)
{
printf("Stereo mode not supported!\n");
- return;
+ return -1;
}
if(ioctl(oss_audio_fd,SNDCTL_DSP_SPEED,&oss_speed)==-1)
{
printf("Sound frequency not supported\n");
- return;
+ return -1;
}
if(oss_speed!=pspeed)
{
printf("Sound frequency not supported\n");
- return;
+ return -1;
}
+
+ return 0;
}
////////////////////////////////////////////////////////////////////////
// REMOVE SOUND
////////////////////////////////////////////////////////////////////////
-void RemoveSound(void)
+static void oss_finish(void)
{
if(oss_audio_fd != -1 )
{
}
////////////////////////////////////////////////////////////////////////
-// GET BYTES BUFFERED
+// GET BUFFERED STATUS
////////////////////////////////////////////////////////////////////////
-unsigned long SoundGetBytesBuffered(void)
+static int oss_busy(void)
{
audio_buf_info info;
unsigned long l;
// FEED SOUND DATA
////////////////////////////////////////////////////////////////////////
-void SoundFeedStreamData(unsigned char* pSound,long lBytes)
+static void oss_feed(void *buf, int bytes)
{
if(oss_audio_fd == -1) return;
- write(oss_audio_fd,pSound,lBytes);
+ write(oss_audio_fd, buf, bytes);
+}
+
+void out_register_oss(struct out_driver *drv)
+{
+ drv->name = "oss";
+ drv->init = oss_init;
+ drv->finish = oss_finish;
+ drv->busy = oss_busy;
+ drv->feed = oss_feed;
}
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include "out.h"
+
+#define MAX_OUT_DRIVERS 5
+
+static struct out_driver out_drivers[MAX_OUT_DRIVERS];
+struct out_driver *out_current;
+static int driver_count;
+
+#define REGISTER_DRIVER(d) { \
+ extern void out_register_##d(struct out_driver *drv); \
+ out_register_##d(&out_drivers[driver_count++]); \
+}
+
+void SetupSound(void)
+{
+ int i;
+
+ if (driver_count == 0) {
+#ifdef HAVE_OSS
+ REGISTER_DRIVER(oss);
+#endif
+#ifdef HAVE_ALSA
+ REGISTER_DRIVER(alsa);
+#endif
+#ifdef HAVE_SDL
+ REGISTER_DRIVER(sdl);
+#endif
+#ifdef HAVE_PULSE
+ REGISTER_DRIVER(pulse);
+#endif
+#ifdef HAVE_LIBRETRO
+ REGISTER_DRIVER(libretro);
+#endif
+ REGISTER_DRIVER(none);
+ }
+
+ for (i = 0; i < driver_count; i++)
+ if (out_drivers[i].init() == 0)
+ break;
+
+ if (i < 0 || i >= driver_count) {
+ printf("the impossible happened\n");
+ abort();
+ }
+
+ out_current = &out_drivers[i];
+ printf("selected sound output driver: %s\n", out_current->name);
+}
+
--- /dev/null
+
+struct out_driver {
+ const char *name;
+ int (*init)(void);
+ void (*finish)(void);
+ int (*busy)(void);
+ void (*feed)(void *data, int bytes);
+};
+
+extern struct out_driver *out_current;
+
+void SetupSound(void);
#include "stdafx.h"
-#ifdef USEPULSEAUDIO
-
#define _IN_OSS
#include "externals.h"
// SETUP SOUND
////////////////////////////////////////////////////////////////////////
-void SetupSound (void)
+static void pulse_init(void)
{
int error_number;
if (device.mainloop == NULL)
{
fprintf (stderr, "Could not acquire PulseAudio main loop\n");
- return;
+ return -1;
}
// Acquire context ////////////////////////////////////////////////////////
if (device.context == NULL)
{
fprintf (stderr, "Could not acquire PulseAudio device context\n");
- return;
+ return -1;
}
// Connect to PulseAudio server ///////////////////////////////////////////
{
error_number = pa_context_errno (device.context);
fprintf (stderr, "Could not connect to PulseAudio server: %s\n", pa_strerror(error_number));
- return;
+ return -1;
}
// Run mainloop until sever context is ready //////////////////////////////
if (pa_threaded_mainloop_start (device.mainloop) < 0)
{
fprintf (stderr, "Could not start mainloop\n");
- return;
+ return -1;
}
pa_context_state_t context_state;
{
error_number = pa_context_errno (device.context);
fprintf (stderr, "Context state is not good: %s\n", pa_strerror (error_number));
- return;
+ return -1;
}
else if (context_state == PA_CONTEXT_READY)
break;
{
error_number = pa_context_errno (device.context);
fprintf (stderr, "Could not acquire new PulseAudio stream: %s\n", pa_strerror (error_number));
- return;
+ return -1;
}
// Set callbacks for server events ////////////////////////////////////////
{
pa_context_errno (device.context);
fprintf (stderr, "Could not connect for playback: %s\n", pa_strerror (error_number));
- return;
+ return -1;
}
// Run mainloop until stream is ready /////////////////////////////////////
{
error_number = pa_context_errno (device.context);
fprintf (stderr, "Stream state is not good: %s\n", pa_strerror (error_number));
- return;
+ return -1;
}
else
fprintf (stderr, "PulseAudio stream state is %d\n", stream_state);
pa_threaded_mainloop_unlock (device.mainloop);
fprintf (stderr, "PulseAudio should be connected\n");
- return;
+ return 0;
}
////////////////////////////////////////////////////////////////////////
// REMOVE SOUND
////////////////////////////////////////////////////////////////////////
-void RemoveSound (void)
+static void pulse_finish(void)
{
if (device.mainloop != NULL)
pa_threaded_mainloop_stop (device.mainloop);
// GET BYTES BUFFERED
////////////////////////////////////////////////////////////////////////
-unsigned long SoundGetBytesBuffered (void)
+static int pulse_busy(void)
{
int free_space;
int error_code;
// FEED SOUND DATA
////////////////////////////////////////////////////////////////////////
-void SoundFeedStreamData (unsigned char *pSound, long lBytes)
+static void pulse_feed(void *pSound, int lBytes)
{
int error_code;
int size;
}
}
}
-#endif
+
+void out_register_pulse(struct out_driver *drv)
+{
+ drv->name = "pulseaudio";
+ drv->init = pulse_init;
+ drv->finish = pulse_finish;
+ drv->busy = pulse_busy;
+ drv->feed = pulse_feed;
+}
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
-#include "stdafx.h"
-
-#include "externals.h"
+#include <stdlib.h>
#include <SDL.h>
+#include "out.h"
#define BUFFER_SIZE 22050
}
}
-void SetupSound(void) {
+static int sdl_init(void) {
SDL_AudioSpec spec;
- if (pSndBuffer != NULL) return;
+ if (pSndBuffer != NULL) return -1;
InitSDL();
if (SDL_OpenAudio(&spec, NULL) < 0) {
DestroySDL();
- return;
+ return -1;
}
iBufSize = BUFFER_SIZE;
pSndBuffer = (short *)malloc(iBufSize * sizeof(short));
if (pSndBuffer == NULL) {
SDL_CloseAudio();
- return;
+ return -1;
}
iReadPos = 0;
iWritePos = 0;
SDL_PauseAudio(0);
+ return 0;
}
-void RemoveSound(void) {
+static void sdl_finish(void) {
if (pSndBuffer == NULL) return;
SDL_CloseAudio();
pSndBuffer = NULL;
}
-unsigned long SoundGetBytesBuffered(void) {
+static int sdl_busy(void) {
int size;
if (pSndBuffer == NULL) return 1;
return 0;
}
-void SoundFeedStreamData(unsigned char *pSound, long lBytes) {
+static void sdl_feed(void *pSound, int lBytes) {
short *p = (short *)pSound;
if (pSndBuffer == NULL) return;
lBytes -= sizeof(short);
}
}
+
+void out_register_sdl(struct out_driver *drv)
+{
+ drv->name = "sdl";
+ drv->init = sdl_init;
+ drv->finish = sdl_finish;
+ drv->busy = sdl_busy;
+ drv->feed = sdl_feed;
+}
#include "externals.h"
#include "registers.h"
-#include "dsoundoss.h"
+#include "out.h"
#ifdef ENABLE_NLS
#include <libintl.h>
// until enuff free place is available/a new channel gets
// started
- if(!forced_updates && SoundGetBytesBuffered()) // still enuff data in sound buffer?
+ if(!forced_updates && out_current->busy()) // still enuff data in sound buffer?
{
return 0;
}
// wanna have around 1/60 sec (16.666 ms) updates
if (iCycle++ > 16/FRAG_MSECS)
{
- SoundFeedStreamData((unsigned char *)pSpuBuffer,
+ out_current->feed(pSpuBuffer,
((unsigned char *)pS) - ((unsigned char *)pSpuBuffer));
pS = (short *)pSpuBuffer;
iCycle = 0;
bSPUIsOpen = 0; // no more open
- RemoveSound(); // no more sound handling
+ out_current->finish(); // no more sound handling
return 0;
}
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
-#ifdef USEOSS
-#include <sys/soundcard.h>
-#endif
#include <unistd.h>
#include <pthread.h>
#define RRand(range) (random()%range)