diff options
| author | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2010-02-07 10:33:30 +0000 |
|---|---|---|
| committer | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2010-02-07 10:33:30 +0000 |
| commit | 7cf18befaa6309a60c5950b5f349204f267f88f4 (patch) | |
| tree | 045b389bb8924dbf3c5fb28bb1be2e870f6cf241 /plugins | |
| parent | 9bf85f976ca1c539788e6d1d60995434eb856812 (diff) | |
| download | pcsxr-7cf18befaa6309a60c5950b5f349204f267f88f4.tar.gz | |
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@41219 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/dfcdrom/Makefile.in | 3 | ||||
| -rw-r--r-- | plugins/dfinput/Makefile.in | 3 | ||||
| -rw-r--r-- | plugins/dfsound/Makefile.am | 12 | ||||
| -rw-r--r-- | plugins/dfsound/Makefile.in | 31 | ||||
| -rw-r--r-- | plugins/dfsound/alsa.c | 2 | ||||
| -rw-r--r-- | plugins/dfsound/nullsnd.c | 2 | ||||
| -rw-r--r-- | plugins/dfsound/pulseaudio.c | 242 | ||||
| -rw-r--r-- | plugins/dfsound/pulseaudiosimple.c | 111 | ||||
| -rw-r--r-- | plugins/dfsound/spu.c | 6 | ||||
| -rw-r--r-- | plugins/dfxvideo/Makefile.in | 3 | ||||
| -rw-r--r-- | plugins/peopsxgl/Makefile.in | 3 |
11 files changed, 411 insertions, 7 deletions
diff --git a/plugins/dfcdrom/Makefile.in b/plugins/dfcdrom/Makefile.in index 7bde668c..dff6d84e 100644 --- a/plugins/dfcdrom/Makefile.in +++ b/plugins/dfcdrom/Makefile.in @@ -87,6 +87,7 @@ ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ +ALSA_CFLAGS = @ALSA_CFLAGS@ ALSA_LIBS = @ALSA_LIBS@ AMTAR = @AMTAR@ AR = @AR@ @@ -166,6 +167,8 @@ PATH_SEPARATOR = @PATH_SEPARATOR@ PEOPSXGL = @PEOPSXGL@ PKG_CONFIG = @PKG_CONFIG@ POSUB = @POSUB@ +PULSEAUDIO_CFLAGS = @PULSEAUDIO_CFLAGS@ +PULSEAUDIO_LIBS = @PULSEAUDIO_LIBS@ RANLIB = @RANLIB@ SDL_CFLAGS = @SDL_CFLAGS@ SDL_CONFIG = @SDL_CONFIG@ diff --git a/plugins/dfinput/Makefile.in b/plugins/dfinput/Makefile.in index 83615d69..64c54ae1 100644 --- a/plugins/dfinput/Makefile.in +++ b/plugins/dfinput/Makefile.in @@ -90,6 +90,7 @@ ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ +ALSA_CFLAGS = @ALSA_CFLAGS@ ALSA_LIBS = @ALSA_LIBS@ AMTAR = @AMTAR@ AR = @AR@ @@ -169,6 +170,8 @@ PATH_SEPARATOR = @PATH_SEPARATOR@ PEOPSXGL = @PEOPSXGL@ PKG_CONFIG = @PKG_CONFIG@ POSUB = @POSUB@ +PULSEAUDIO_CFLAGS = @PULSEAUDIO_CFLAGS@ +PULSEAUDIO_LIBS = @PULSEAUDIO_LIBS@ RANLIB = @RANLIB@ SDL_CFLAGS = @SDL_CFLAGS@ SDL_CONFIG = @SDL_CONFIG@ diff --git a/plugins/dfsound/Makefile.am b/plugins/dfsound/Makefile.am index 70f3d650..91788212 100644 --- a/plugins/dfsound/Makefile.am +++ b/plugins/dfsound/Makefile.am @@ -10,7 +10,7 @@ libdir = @libdir@/games/psemu/ lib_LTLIBRARIES = libDFSound.la libDFSound_la_SOURCES = spu.c cfg.c dma.c freeze.c psemu.c registers.c \ - alsa.c oss.c nullsnd.c + alsa.c oss.c pulseaudio.c pulseaudiosimple.c nullsnd.c libDFSound_la_CFLAGS = libDFSound_la_LDFLAGS = -module -avoid-version -lpthread -lm @@ -24,6 +24,16 @@ if HAVE_OSS libDFSound_la_CFLAGS += -DUSEOSS=1 endif +if HAVE_PULSEAUDIOSIMPLE +libDFSound_la_CFLAGS += $(PULSEAUDIO_CFLAGS) -DUSEPULSEAUDIOSIMPLE=1 +libDFSound_la_LDFLAGS += $(PULSEAUDIO_LIBS) +endif + +if HAVE_PULSEAUDIO +libDFSound_la_CFLAGS += $(PULSEAUDIO_CFLAGS) -DUSEPULSEAUDIO=1 +libDFSound_la_LDFLAGS += $(PULSEAUDIO_LIBS) +endif + bin_PROGRAMS = cfgDFSound cfgDFSound_SOURCES = spucfg-0.1df/main.c cfgDFSound_LDADD = $(GTK2_LIBS) $(GLADE2_LIBS) diff --git a/plugins/dfsound/Makefile.in b/plugins/dfsound/Makefile.in index d13c1dbe..b304dfe0 100644 --- a/plugins/dfsound/Makefile.in +++ b/plugins/dfsound/Makefile.in @@ -38,6 +38,10 @@ target_triplet = @target@ @HAVE_ALSA_TRUE@am__append_1 = -DUSEALSA=1 @HAVE_ALSA_TRUE@am__append_2 = $(ALSA_LIBS) @HAVE_OSS_TRUE@am__append_3 = -DUSEOSS=1 +@HAVE_PULSEAUDIOSIMPLE_TRUE@am__append_4 = $(PULSEAUDIO_CFLAGS) -DUSEPULSEAUDIOSIMPLE=1 +@HAVE_PULSEAUDIOSIMPLE_TRUE@am__append_5 = $(PULSEAUDIO_LIBS) +@HAVE_PULSEAUDIO_TRUE@am__append_6 = $(PULSEAUDIO_CFLAGS) -DUSEPULSEAUDIO=1 +@HAVE_PULSEAUDIO_TRUE@am__append_7 = $(PULSEAUDIO_LIBS) bin_PROGRAMS = cfgDFSound$(EXEEXT) subdir = plugins/dfsound DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in @@ -63,6 +67,7 @@ am_libDFSound_la_OBJECTS = libDFSound_la-spu.lo libDFSound_la-cfg.lo \ libDFSound_la-dma.lo libDFSound_la-freeze.lo \ libDFSound_la-psemu.lo libDFSound_la-registers.lo \ libDFSound_la-alsa.lo libDFSound_la-oss.lo \ + libDFSound_la-pulseaudio.lo libDFSound_la-pulseaudiosimple.lo \ libDFSound_la-nullsnd.lo libDFSound_la_OBJECTS = $(am_libDFSound_la_OBJECTS) libDFSound_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ @@ -94,6 +99,7 @@ ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ +ALSA_CFLAGS = @ALSA_CFLAGS@ ALSA_LIBS = @ALSA_LIBS@ AMTAR = @AMTAR@ AR = @AR@ @@ -173,6 +179,8 @@ PATH_SEPARATOR = @PATH_SEPARATOR@ PEOPSXGL = @PEOPSXGL@ PKG_CONFIG = @PKG_CONFIG@ POSUB = @POSUB@ +PULSEAUDIO_CFLAGS = @PULSEAUDIO_CFLAGS@ +PULSEAUDIO_LIBS = @PULSEAUDIO_LIBS@ RANLIB = @RANLIB@ SDL_CFLAGS = @SDL_CFLAGS@ SDL_CONFIG = @SDL_CONFIG@ @@ -250,11 +258,12 @@ INCLUDES = -DPIXMAPDIR=\"${datadir}/pixmaps/\" \ lib_LTLIBRARIES = libDFSound.la libDFSound_la_SOURCES = spu.c cfg.c dma.c freeze.c psemu.c registers.c \ - alsa.c oss.c nullsnd.c + alsa.c oss.c pulseaudio.c pulseaudiosimple.c nullsnd.c -libDFSound_la_CFLAGS = $(am__append_1) $(am__append_3) +libDFSound_la_CFLAGS = $(am__append_1) $(am__append_3) $(am__append_4) \ + $(am__append_6) libDFSound_la_LDFLAGS = -module -avoid-version -lpthread -lm \ - $(am__append_2) + $(am__append_2) $(am__append_5) $(am__append_7) cfgDFSound_SOURCES = spucfg-0.1df/main.c cfgDFSound_LDADD = $(GTK2_LIBS) $(GLADE2_LIBS) glade_DATA = spucfg-0.1df/dfsound.glade2 @@ -367,6 +376,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libDFSound_la-nullsnd.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libDFSound_la-oss.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libDFSound_la-psemu.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libDFSound_la-pulseaudio.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libDFSound_la-pulseaudiosimple.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libDFSound_la-registers.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libDFSound_la-spu.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @@ -448,6 +459,20 @@ libDFSound_la-oss.lo: oss.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libDFSound_la_CFLAGS) $(CFLAGS) -c -o libDFSound_la-oss.lo `test -f 'oss.c' || echo '$(srcdir)/'`oss.c +libDFSound_la-pulseaudio.lo: pulseaudio.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libDFSound_la_CFLAGS) $(CFLAGS) -MT libDFSound_la-pulseaudio.lo -MD -MP -MF $(DEPDIR)/libDFSound_la-pulseaudio.Tpo -c -o libDFSound_la-pulseaudio.lo `test -f 'pulseaudio.c' || echo '$(srcdir)/'`pulseaudio.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libDFSound_la-pulseaudio.Tpo $(DEPDIR)/libDFSound_la-pulseaudio.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pulseaudio.c' object='libDFSound_la-pulseaudio.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libDFSound_la_CFLAGS) $(CFLAGS) -c -o libDFSound_la-pulseaudio.lo `test -f 'pulseaudio.c' || echo '$(srcdir)/'`pulseaudio.c + +libDFSound_la-pulseaudiosimple.lo: pulseaudiosimple.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libDFSound_la_CFLAGS) $(CFLAGS) -MT libDFSound_la-pulseaudiosimple.lo -MD -MP -MF $(DEPDIR)/libDFSound_la-pulseaudiosimple.Tpo -c -o libDFSound_la-pulseaudiosimple.lo `test -f 'pulseaudiosimple.c' || echo '$(srcdir)/'`pulseaudiosimple.c +@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libDFSound_la-pulseaudiosimple.Tpo $(DEPDIR)/libDFSound_la-pulseaudiosimple.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='pulseaudiosimple.c' object='libDFSound_la-pulseaudiosimple.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libDFSound_la_CFLAGS) $(CFLAGS) -c -o libDFSound_la-pulseaudiosimple.lo `test -f 'pulseaudiosimple.c' || echo '$(srcdir)/'`pulseaudiosimple.c + libDFSound_la-nullsnd.lo: nullsnd.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libDFSound_la_CFLAGS) $(CFLAGS) -MT libDFSound_la-nullsnd.lo -MD -MP -MF $(DEPDIR)/libDFSound_la-nullsnd.Tpo -c -o libDFSound_la-nullsnd.lo `test -f 'nullsnd.c' || echo '$(srcdir)/'`nullsnd.c @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/libDFSound_la-nullsnd.Tpo $(DEPDIR)/libDFSound_la-nullsnd.Plo diff --git a/plugins/dfsound/alsa.c b/plugins/dfsound/alsa.c index 67b10396..d771cfaa 100644 --- a/plugins/dfsound/alsa.c +++ b/plugins/dfsound/alsa.c @@ -139,7 +139,7 @@ unsigned long SoundGetBytesBuffered(void) if (handle == NULL) // failed to open? return SOUNDSIZE; - l = snd_pcm_avail_update(handle); + l = snd_pcm_avail(handle); if (l < 0) return 0; if (l < buffer_size / 2) // can we write in at least the half of fragments? l = SOUNDSIZE; // -> no? wait diff --git a/plugins/dfsound/nullsnd.c b/plugins/dfsound/nullsnd.c index ebbefa2e..d417136b 100644 --- a/plugins/dfsound/nullsnd.c +++ b/plugins/dfsound/nullsnd.c @@ -2,7 +2,7 @@ #define _IN_OSS #include "externals.h" -#if !defined (USEALSA) && !defined (USEOSS) +#if !defined (USEALSA) && !defined (USEOSS) && !defined (USEPULSEAUDIO) && !defined(USEPULSEAUDIOSIMPLE) #warning "Using NULL sound output..." diff --git a/plugins/dfsound/pulseaudio.c b/plugins/dfsound/pulseaudio.c new file mode 100644 index 00000000..513af91c --- /dev/null +++ b/plugins/dfsound/pulseaudio.c @@ -0,0 +1,242 @@ +/*************************************************************************** + pulseaudio.c - description + ------------------- +begin : Thu Feb 04 2010 +copyright : (C) 2010 by Tristin Celestin +email : cetris1@umbc.edu +comment : Much of this was taken from pulseaudio.cpp (authored + by RedDwarf) in bsnes (http://byuu.org/bsnes/) +***************************************************************************/ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "stdafx.h" + +#ifdef USEPULSEAUDIO + +#define _IN_OSS + +#include "externals.h" +#include <pulse/pulseaudio.h> + +//////////////////////////////////////////////////////////////////////// +// declarations for pulseaudio callbacks +//////////////////////////////////////////////////////////////////////// +void announce_connection_success (pa_context *context, const char *name, pa_proplist *property_list, void *user_data); + + +//////////////////////////////////////////////////////////////////////// +// pulseaudio structs +//////////////////////////////////////////////////////////////////////// + +typedef struct { + pa_mainloop *mainloop; + pa_context *context; + pa_mainloop_api *api; + pa_stream *stream; + pa_sample_spec spec; + pa_buffer_attr buffer_attr; + int first; +} Device; + +typedef struct { + unsigned int frequency; + unsigned int latency; +} Settings; + +//////////////////////////////////////////////////////////////////////// +// pulseaudio globals +//////////////////////////////////////////////////////////////////////// + +static Device device = { + .mainloop = NULL, + .api = NULL, + .context = NULL, + .stream = NULL +}; + +static Settings settings = { + .frequency = 44100, + .latency = 80 +}; + +//////////////////////////////////////////////////////////////////////// +// SETUP SOUND +//////////////////////////////////////////////////////////////////////// + +void SetupSound (void) +{ + int error_number; + + // Acquire mainloop /////////////////////////////////////////////////////// + device.mainloop = pa_mainloop_new (); + if (device.mainloop == NULL) + { + fprintf (stderr, "Could not acquire PulseAudio main loop\n"); + return; + } + + // Acquire context //////////////////////////////////////////////////////// + device.api = pa_mainloop_get_api (device.mainloop); + device.context = pa_context_new (device.api, "PCSX"); + if (device.context == NULL) + { + fprintf (stderr, "Could not acquire PulseAudio device context\n"); + return; + } + + // Connect to PulseAudio server /////////////////////////////////////////// + error_number = pa_context_connect (device.context, NULL, 0, NULL); + if (error_number < 0) { + fprintf (stderr, "Could not connect to PulseAudio server: %s\n", pa_strerror(error_number)); + return; + } + else + { + fprintf (stderr, "Connected to PulseAudio synchronously.\n"); + } + + // Run mainloop until sever is ready ////////////////////////////////////// + pa_context_state_t context_state; + do + { + error_number = pa_mainloop_iterate (device.mainloop, 1, NULL); + if (error_number < 0) { + fprintf (stderr, "Could not run pa_mainloop_iterate ():%s\n", pa_strerror (error_number)); + return; + } + + context_state = pa_context_get_state (device.context); + if (! PA_CONTEXT_IS_GOOD (context_state)) + { + fprintf (stderr, "Context state is not good.\n"); + return; + } + else + { + fprintf (stderr, "PulseAudio context state is %d\n", context_state); + } + } while (context_state != PA_CONTEXT_READY); + + // Set sample spec //////////////////////////////////////////////////////// + device.spec.format = PA_SAMPLE_S16LE; + if (iDisStereo) + device.spec.channels = 1; + else + device.spec.channels = 2; + device.spec.rate = settings.frequency; + + // Set buffer attributes ////////////////////////////////////////////////// + int mixlen = pa_usec_to_bytes (settings.latency * PA_USEC_PER_MSEC, &device.spec); + device.buffer_attr.maxlength = -1; + device.buffer_attr.tlength = 2 * mixlen; + device.buffer_attr.prebuf = -1; + device.buffer_attr.minreq = mixlen; + + // Acquire new stream using spec and buffer attributes //////////////////// + device.stream = pa_stream_new (device.context, "PCSX", &device.spec, NULL); + if (device.stream == NULL) + { + fprintf (stderr, "Could not get new PulseAudio stream.\n"); + return; + } + + pa_stream_flags_t flags = (pa_stream_flags_t) (PA_STREAM_ADJUST_LATENCY | PA_STREAM_VARIABLE_RATE); + error_number = pa_stream_connect_playback (device.stream, NULL, &device.buffer_attr, flags, NULL, NULL); + if (error_number < 0) { + fprintf (stderr, "Could not connect for playback successfully :%s\n", pa_strerror (error_number)); + return; + } + + // Run mainloop until stream is ready ///////////////////////////////////// + pa_stream_state_t stream_state; + do { + error_number = pa_mainloop_iterate (device.mainloop, 1, NULL); + if (error_number < 0) { + fprintf (stderr, "Could not run pa_mainloop_iterate ():%s\n", pa_strerror (error_number)); + return; + } + + stream_state = pa_stream_get_state (device.stream); + if (! PA_STREAM_IS_GOOD (stream_state)) + { + fprintf (stderr, "Could not acquire PulseAudio stream.\n"); + return; + } + else + { + fprintf (stderr, "PulseAudio stream state is %d.\n", stream_state); + } + } while (stream_state != PA_STREAM_READY); + + return; +} + +//////////////////////////////////////////////////////////////////////// +// REMOVE SOUND +//////////////////////////////////////////////////////////////////////// + +void RemoveSound (void) +{ + + if (device.stream != NULL) + { + pa_stream_disconnect (device.stream); + pa_stream_unref (device.stream); + device.stream = NULL; + } + + if (device.context != NULL) + { + pa_context_disconnect (device.context); + pa_context_unref (device.context); + device.context = NULL; + } + + if (device.mainloop != NULL) + { + pa_mainloop_free (device.mainloop); + device.mainloop = NULL; + } +} + +//////////////////////////////////////////////////////////////////////// +// GET BYTES BUFFERED +//////////////////////////////////////////////////////////////////////// + +unsigned long SoundGetBytesBuffered (void) +{ + int size; + + fprintf (stderr, "In SoundGetBytesBuffered\n"); + + size = pa_stream_writable_size (device.stream); + fprintf (stderr, "Writable size: %d\n", size); + + // need to figure out length of buffer + if (size > TESTSIZE) + return size; + else + return 0; +} + +//////////////////////////////////////////////////////////////////////// +// FEED SOUND DATA +//////////////////////////////////////////////////////////////////////// + +void SoundFeedStreamData (unsigned char *pSound, long lBytes) +{ + fprintf (stderr, "In SoundFeedStreamData\n"); + + if (pa_stream_write (device.stream, pSound, lBytes, NULL, 0LL, PA_SEEK_RELATIVE) < 0) + fprintf (stderr, "Error: Could not perform write with PulseAudio\n"); +} + +#endif diff --git a/plugins/dfsound/pulseaudiosimple.c b/plugins/dfsound/pulseaudiosimple.c new file mode 100644 index 00000000..0ca92a4b --- /dev/null +++ b/plugins/dfsound/pulseaudiosimple.c @@ -0,0 +1,111 @@ +/*************************************************************************** + pulseaudiosimple.c - description + ------------------- +begin : Thu Feb 04 2010 +copyright : (C) 2010 by Tristin Celestin +email : cetris1@umbc.edu +***************************************************************************/ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "stdafx.h" + +#ifdef USEPULSEAUDIOSIMPLE + +#define _IN_OSS + +#include "externals.h" +#include <pulse/simple.h> +#include <pulse/error.h> +#include <pulse/timeval.h> + +//////////////////////////////////////////////////////////////////////// +// pulseaudio globals +//////////////////////////////////////////////////////////////////////// + +#define PLAYBACK_RATE 44100 +#define LATENCY_IN_MS 20 + +static pa_simple *playback_stream; +static pa_sample_spec sample_specification; + +//////////////////////////////////////////////////////////////////////// +// SETUP SOUND +//////////////////////////////////////////////////////////////////////// + +void SetupSound(void) +{ + int error_number = 0; + int buffer_length; + pa_buffer_attr buffer_attributes; + + // Set sample specification /////////////////////////////////////////////// + sample_specification.format = PA_SAMPLE_S16LE; + sample_specification.rate = PLAYBACK_RATE; + if (iDisStereo) + sample_specification.channels = 1; + else + sample_specification.channels = 2; + + // Set buffer attributes ////////////////////////////////////////////////// + // See http://0pointer.de/lennart/projects/pulseaudio/doxygen/streams.html + // for parameter explanations + /////////////////////////////////////////////////////////////////////////// + int mixlen = pa_usec_to_bytes(LATENCY_IN_MS * PA_USEC_PER_MSEC, &sample_specification); + buffer_attributes.maxlength = -1; + buffer_attributes.tlength = mixlen; + buffer_attributes.prebuf = -1; + buffer_attributes.minreq = -1; + + // Get connection from PulseAudio server + playback_stream = pa_simple_new(NULL, "PCSX", PA_STREAM_PLAYBACK, NULL, "PCSX", &sample_specification, NULL, &buffer_attributes, &error_number); + if (playback_stream == NULL) + { + fprintf(stderr, "Failed to connect to Pulseaudio server with pa_simple_new(): %s\n", pa_strerror(error_number)); + return; + } +} + +//////////////////////////////////////////////////////////////////////// +// REMOVE SOUND +//////////////////////////////////////////////////////////////////////// + +void RemoveSound(void) +{ + int error_number = 0; + + if (pa_simple_drain(playback_stream, &error_number) < 0) + fprintf(stderr, "Unable to drain audio: %s\n", pa_strerror (error_number)); + if (playback_stream) + pa_simple_free(playback_stream); +} + +//////////////////////////////////////////////////////////////////////// +// GET BYTES BUFFERED +//////////////////////////////////////////////////////////////////////// + +unsigned long SoundGetBytesBuffered(void) +{ + return 0; +} + +//////////////////////////////////////////////////////////////////////// +// FEED SOUND DATA +//////////////////////////////////////////////////////////////////////// + +void SoundFeedStreamData(unsigned char *pSound, long lBytes) +{ + int error_number = 0; + + if (pa_simple_write(playback_stream, pSound, (ssize_t)lBytes, &error_number) < 0) + fprintf(stderr, "Could not write - pa_simple_write() failed: %s\n", pa_strerror(error_number)); +} + +#endif diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index fe44b323..1a14c839 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -34,12 +34,16 @@ #define N_(x) (x) #endif -#if defined(USEALSA) +#if defined (USEALSA) static char * libraryName = N_("ALSA Sound"); #elif defined (USEMACOSX) static char * libraryName = N_("Mac OS X Sound"); #elif defined (USEOSS) static char * libraryName = N_("OSS Sound"); +#elif defined (USEPULSEAUDIOSIMPLE) +static char * libraryName = N_("PulseAudio Simple Sound"); +#elif defined (USEPULSEAUDIO) +static char * libraryName = N_("PulseAudio Sound"); #else static char * libraryName = N_("NULL Sound"); #endif diff --git a/plugins/dfxvideo/Makefile.in b/plugins/dfxvideo/Makefile.in index b5491783..5fb8285a 100644 --- a/plugins/dfxvideo/Makefile.in +++ b/plugins/dfxvideo/Makefile.in @@ -94,6 +94,7 @@ ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ +ALSA_CFLAGS = @ALSA_CFLAGS@ ALSA_LIBS = @ALSA_LIBS@ AMTAR = @AMTAR@ AR = @AR@ @@ -173,6 +174,8 @@ PATH_SEPARATOR = @PATH_SEPARATOR@ PEOPSXGL = @PEOPSXGL@ PKG_CONFIG = @PKG_CONFIG@ POSUB = @POSUB@ +PULSEAUDIO_CFLAGS = @PULSEAUDIO_CFLAGS@ +PULSEAUDIO_LIBS = @PULSEAUDIO_LIBS@ RANLIB = @RANLIB@ SDL_CFLAGS = @SDL_CFLAGS@ SDL_CONFIG = @SDL_CONFIG@ diff --git a/plugins/peopsxgl/Makefile.in b/plugins/peopsxgl/Makefile.in index 296fe747..2c77dacd 100644 --- a/plugins/peopsxgl/Makefile.in +++ b/plugins/peopsxgl/Makefile.in @@ -85,6 +85,7 @@ ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ +ALSA_CFLAGS = @ALSA_CFLAGS@ ALSA_LIBS = @ALSA_LIBS@ AMTAR = @AMTAR@ AR = @AR@ @@ -164,6 +165,8 @@ PATH_SEPARATOR = @PATH_SEPARATOR@ PEOPSXGL = @PEOPSXGL@ PKG_CONFIG = @PKG_CONFIG@ POSUB = @POSUB@ +PULSEAUDIO_CFLAGS = @PULSEAUDIO_CFLAGS@ +PULSEAUDIO_LIBS = @PULSEAUDIO_LIBS@ RANLIB = @RANLIB@ SDL_CFLAGS = @SDL_CFLAGS@ SDL_CONFIG = @SDL_CONFIG@ |
