Committed PulseAudio driver. Thanks, Stephan! SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Sun, 13 May 2007 23:12:46 +0000
branchSDL-1.2
changeset 393942e83d81224b
parent 3938 345908fb5442
child 3940 cb04355ffec4
Committed PulseAudio driver. Thanks, Stephan!
configure.in
include/SDL_config.h.in
src/audio/SDL_audio.c
src/audio/SDL_sysaudio.h
src/audio/pulse/SDL_pulseaudio.c
src/audio/pulse/SDL_pulseaudio.h
     1.1 --- a/configure.in	Tue Apr 17 09:09:48 2007 +0000
     1.2 +++ b/configure.in	Sun May 13 23:12:46 2007 +0000
     1.3 @@ -459,6 +459,63 @@
     1.4      fi
     1.5  }
     1.6  
     1.7 +dnl Find PulseAudio
     1.8 +CheckPulseAudio()
     1.9 +{
    1.10 +    AC_ARG_ENABLE(pulseaudio,
    1.11 +AC_HELP_STRING([--enable-pulseaudio], [use PulseAudio [[default=yes]]]),
    1.12 +                  , enable_pulse=yes)
    1.13 +    if test x$enable_audio = xyes -a x$enable_pulse = xyes; then
    1.14 +        audio_pulse=no
    1.15 +
    1.16 +        PULSE_REQUIRED_VERSION=0.9
    1.17 +
    1.18 +        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
    1.19 +        AC_MSG_CHECKING(for PulseAudio $PULSE_REQUIRED_VERSION support)
    1.20 +        if test x$PKG_CONFIG != xno; then
    1.21 +        if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $PULSE_REQUIRED_VERSION libpulse-simple; then
    1.22 +                PULSE_CFLAGS=`$PKG_CONFIG --cflags libpulse-simple`
    1.23 +                PULSE_LIBS=`$PKG_CONFIG --libs libpulse-simple`
    1.24 +                audio_pulse=yes
    1.25 +        fi
    1.26 +        fi
    1.27 +        AC_MSG_RESULT($audio_pulse)
    1.28 +
    1.29 +        if test x$audio_pulse = xyes; then
    1.30 +            AC_ARG_ENABLE(pulseaudio-shared,
    1.31 +AC_HELP_STRING([--enable-pulseaudio-shared], [dynamically load PulseAudio support [[default=yes]]]),
    1.32 +                          , enable_pulse_shared=yes)
    1.33 +            if test "x`echo $PULSE_LIBS | grep -- -L`" = "x"; then
    1.34 +                if test "x`ls /lib/libpulse-simple.so.* 2> /dev/null`" != "x"; then
    1.35 +                    PULSE_LIBS="-L/lib $PULSE_LIBS"
    1.36 +                elif test "x`ls /usr/lib/libpulse-simple.so.* 2> /dev/null`" != "x"; then
    1.37 +                    PULSE_LIBS="-L/usr/lib $PULSE_LIBS"
    1.38 +                elif test "x`ls /usr/local/lib/libpulse-simple.so.* 2> /dev/null`" != "x"; then
    1.39 +                    PULSE_LIBS="-L/usr/local/lib $PULSE_LIBS"
    1.40 +                fi
    1.41 +            fi
    1.42 +            pulse_lib_spec=`echo $PULSE_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libpulse-simple.so.*/'`
    1.43 +            pulse_lib=`ls -- $pulse_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
    1.44 +            echo "-- $pulse_lib_spec -> $pulse_lib"
    1.45 +
    1.46 +            AC_DEFINE(SDL_AUDIO_DRIVER_PULSE)
    1.47 +            SOURCES="$SOURCES $srcdir/src/audio/pulse/*.c"
    1.48 +            EXTRA_CFLAGS="$EXTRA_CFLAGS $PULSE_CFLAGS"
    1.49 +            if test x$have_loadso != xyes && \
    1.50 +               test x$enable_pulse_shared = xyes; then
    1.51 +                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic PulseAudio loading])
    1.52 +            fi
    1.53 +            if test x$have_loadso = xyes && \
    1.54 +               test x$enable_pulse_shared = xyes && test x$pulse_lib != x; then
    1.55 +                AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_PULSE_DYNAMIC, "$pulse_lib")
    1.56 +            else
    1.57 +                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PULSE_LIBS"
    1.58 +            fi
    1.59 +            have_audio=yes
    1.60 +        fi
    1.61 +    fi
    1.62 +}
    1.63 +
    1.64  CheckARTSC()
    1.65  {
    1.66      AC_ARG_ENABLE(arts,
    1.67 @@ -2150,6 +2207,7 @@
    1.68          CheckALSA
    1.69          CheckARTSC
    1.70          CheckESD
    1.71 +        CheckPulseAudio
    1.72          CheckNAS
    1.73          CheckX11
    1.74          CheckNANOX
     2.1 --- a/include/SDL_config.h.in	Tue Apr 17 09:09:48 2007 +0000
     2.2 +++ b/include/SDL_config.h.in	Sun May 13 23:12:46 2007 +0000
     2.3 @@ -163,6 +163,8 @@
     2.4  #undef SDL_AUDIO_DRIVER_DUMMY
     2.5  #undef SDL_AUDIO_DRIVER_DMEDIA
     2.6  #undef SDL_AUDIO_DRIVER_DSOUND
     2.7 +#undef SDL_AUDIO_DRIVER_PULSE
     2.8 +#undef SDL_AUDIO_DRIVER_PULSE_DYNAMIC
     2.9  #undef SDL_AUDIO_DRIVER_ESD
    2.10  #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC
    2.11  #undef SDL_AUDIO_DRIVER_MINT
     3.1 --- a/src/audio/SDL_audio.c	Tue Apr 17 09:09:48 2007 +0000
     3.2 +++ b/src/audio/SDL_audio.c	Sun May 13 23:12:46 2007 +0000
     3.3 @@ -46,6 +46,9 @@
     3.4  #if SDL_AUDIO_DRIVER_ALSA
     3.5  	&ALSA_bootstrap,
     3.6  #endif
     3.7 +#if SDL_AUDIO_DRIVER_PULSE
     3.8 +	&PULSE_bootstrap,
     3.9 +#endif
    3.10  #if SDL_AUDIO_DRIVER_QNXNTO
    3.11  	&QNXNTOAUDIO_bootstrap,
    3.12  #endif
     4.1 --- a/src/audio/SDL_sysaudio.h	Tue Apr 17 09:09:48 2007 +0000
     4.2 +++ b/src/audio/SDL_sysaudio.h	Sun May 13 23:12:46 2007 +0000
     4.3 @@ -103,6 +103,9 @@
     4.4  #if SDL_AUDIO_DRIVER_BSD
     4.5  extern AudioBootStrap BSD_AUDIO_bootstrap;
     4.6  #endif
     4.7 +#if SDL_AUDIO_DRIVER_PULSE
     4.8 +extern AudioBootStrap PULSE_bootstrap;
     4.9 +#endif
    4.10  #if SDL_AUDIO_DRIVER_OSS
    4.11  extern AudioBootStrap DSP_bootstrap;
    4.12  extern AudioBootStrap DMA_bootstrap;
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/audio/pulse/SDL_pulseaudio.c	Sun May 13 23:12:46 2007 +0000
     5.3 @@ -0,0 +1,377 @@
     5.4 +/*
     5.5 +    SDL - Simple DirectMedia Layer
     5.6 +    Copyright (C) 1997-2007 Sam Lantinga
     5.7 +
     5.8 +    This library is free software; you can redistribute it and/or
     5.9 +    modify it under the terms of the GNU Lesser General Public
    5.10 +    License as published by the Free Software Foundation; either
    5.11 +    version 2.1 of the License, or (at your option) any later version.
    5.12 +
    5.13 +    This library is distributed in the hope that it will be useful,
    5.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.16 +    Lesser General Public License for more details.
    5.17 +
    5.18 +    You should have received a copy of the GNU Lesser General Public
    5.19 +    License along with this library; if not, write to the Free Software
    5.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    5.21 +
    5.22 +    Stéphan Kochen
    5.23 +    stephan@kochen.nl
    5.24 +    
    5.25 +    Based on parts of the ALSA and ESounD output drivers.
    5.26 +*/
    5.27 +#include "SDL_config.h"
    5.28 +
    5.29 +/* Allow access to an PulseAudio network stream mixing buffer */
    5.30 +
    5.31 +#include <sys/types.h>
    5.32 +#include <unistd.h>
    5.33 +#include <signal.h>
    5.34 +#include <errno.h>
    5.35 +#include <pulse/simple.h>
    5.36 +
    5.37 +#include "SDL_timer.h"
    5.38 +#include "SDL_audio.h"
    5.39 +#include "../SDL_audiomem.h"
    5.40 +#include "../SDL_audio_c.h"
    5.41 +#include "../SDL_audiodev_c.h"
    5.42 +#include "SDL_pulseaudio.h"
    5.43 +
    5.44 +#ifdef SDL_AUDIO_DRIVER_PULSE_DYNAMIC
    5.45 +#include "SDL_name.h"
    5.46 +#include "SDL_loadso.h"
    5.47 +#else
    5.48 +#define SDL_NAME(X)	X
    5.49 +#endif
    5.50 +
    5.51 +/* The tag name used by the driver */
    5.52 +#define PULSE_DRIVER_NAME	"pulse"
    5.53 +
    5.54 +/* Audio driver functions */
    5.55 +static int PULSE_OpenAudio(_THIS, SDL_AudioSpec *spec);
    5.56 +static void PULSE_WaitAudio(_THIS);
    5.57 +static void PULSE_PlayAudio(_THIS);
    5.58 +static Uint8 *PULSE_GetAudioBuf(_THIS);
    5.59 +static void PULSE_CloseAudio(_THIS);
    5.60 +
    5.61 +#ifdef SDL_AUDIO_DRIVER_PULSE_DYNAMIC
    5.62 +
    5.63 +static const char *pulse_library = SDL_AUDIO_DRIVER_PULSE_DYNAMIC;
    5.64 +static void *pulse_handle = NULL;
    5.65 +static int pulse_loaded = 0;
    5.66 +
    5.67 +static pa_simple* (*SDL_NAME(pa_simple_new))(
    5.68 +	const char *server,
    5.69 +	const char *name,
    5.70 +	pa_stream_direction_t dir,
    5.71 +	const char *dev,
    5.72 +	const char *stream_name,
    5.73 +	const pa_sample_spec *ss,
    5.74 +	const pa_channel_map *map,
    5.75 +	const pa_buffer_attr *attr,
    5.76 +	int *error
    5.77 +);
    5.78 +static void (*SDL_NAME(pa_simple_free))(pa_simple *s);
    5.79 +static int (*SDL_NAME(pa_simple_drain))(pa_simple *s, int *error);
    5.80 +static int (*SDL_NAME(pa_simple_write))(
    5.81 +	pa_simple *s,
    5.82 +	const void *data,
    5.83 +	size_t length,
    5.84 +	int *error 
    5.85 +);
    5.86 +static pa_channel_map* (*SDL_NAME(pa_channel_map_init_auto))(
    5.87 +	pa_channel_map *m,
    5.88 +	unsigned channels,
    5.89 +	pa_channel_map_def_t def
    5.90 +);
    5.91 +	
    5.92 +
    5.93 +static struct {
    5.94 +	const char *name;
    5.95 +	void **func;
    5.96 +} pulse_functions[] = {
    5.97 +	{ "pa_simple_new",
    5.98 +		(void **)&SDL_NAME(pa_simple_new)		},
    5.99 +	{ "pa_simple_free",
   5.100 +		(void **)&SDL_NAME(pa_simple_free)		},
   5.101 +	{ "pa_simple_drain",
   5.102 +		(void **)&SDL_NAME(pa_simple_drain)		},
   5.103 +	{ "pa_simple_write",
   5.104 +		(void **)&SDL_NAME(pa_simple_write)		},
   5.105 +	{ "pa_channel_map_init_auto",
   5.106 +		(void **)&SDL_NAME(pa_channel_map_init_auto)	},
   5.107 +};
   5.108 +
   5.109 +static void UnloadPulseLibrary()
   5.110 +{
   5.111 +	if ( pulse_loaded ) {
   5.112 +		SDL_UnloadObject(pulse_handle);
   5.113 +		pulse_handle = NULL;
   5.114 +		pulse_loaded = 0;
   5.115 +	}
   5.116 +}
   5.117 +
   5.118 +static int LoadPulseLibrary(void)
   5.119 +{
   5.120 +	int i, retval = -1;
   5.121 +
   5.122 +	pulse_handle = SDL_LoadObject(pulse_library);
   5.123 +	if ( pulse_handle ) {
   5.124 +		pulse_loaded = 1;
   5.125 +		retval = 0;
   5.126 +		for ( i=0; i<SDL_arraysize(pulse_functions); ++i ) {
   5.127 +			*pulse_functions[i].func = SDL_LoadFunction(pulse_handle, pulse_functions[i].name);
   5.128 +			if ( !*pulse_functions[i].func ) {
   5.129 +				retval = -1;
   5.130 +				UnloadPulseLibrary();
   5.131 +				break;
   5.132 +			}
   5.133 +		}
   5.134 +	}
   5.135 +	return retval;
   5.136 +}
   5.137 +
   5.138 +#else
   5.139 +
   5.140 +static void UnloadPulseLibrary()
   5.141 +{
   5.142 +	return;
   5.143 +}
   5.144 +
   5.145 +static int LoadPulseLibrary(void)
   5.146 +{
   5.147 +	return 0;
   5.148 +}
   5.149 +
   5.150 +#endif /* SDL_AUDIO_DRIVER_PULSE_DYNAMIC */
   5.151 +
   5.152 +/* Audio driver bootstrap functions */
   5.153 +
   5.154 +static int Audio_Available(void)
   5.155 +{
   5.156 +	pa_sample_spec paspec;
   5.157 +	pa_simple *connection;
   5.158 +	int available;
   5.159 +
   5.160 +	available = 0;
   5.161 +	if ( LoadPulseLibrary() < 0 ) {
   5.162 +		return available;
   5.163 +	}
   5.164 +	
   5.165 +	/* Connect with a dummy format. */
   5.166 +	paspec.format = PA_SAMPLE_U8;
   5.167 +	paspec.rate = 11025;
   5.168 +	paspec.channels = 1;
   5.169 +	connection = SDL_NAME(pa_simple_new)(
   5.170 +		SDL_getenv("PASERVER"),      /* server */
   5.171 +		"Test stream",               /* application name */
   5.172 +		PA_STREAM_PLAYBACK,          /* playback mode */
   5.173 +		SDL_getenv("PADEVICE"),      /* device on the server */
   5.174 +		"Simple DirectMedia Layer",  /* stream description */
   5.175 +		&paspec,                     /* sample format spec */
   5.176 +		NULL,                        /* channel map */
   5.177 +		NULL,                        /* buffering attributes */
   5.178 +		NULL                         /* error code */
   5.179 +	);
   5.180 +	if ( connection != NULL ) {
   5.181 +		available = 1;
   5.182 +		SDL_NAME(pa_simple_free)(connection);
   5.183 +	}
   5.184 +	
   5.185 +	UnloadPulseLibrary();
   5.186 +	return(available);
   5.187 +}
   5.188 +
   5.189 +static void Audio_DeleteDevice(SDL_AudioDevice *device)
   5.190 +{
   5.191 +	SDL_free(device->hidden);
   5.192 +	SDL_free(device);
   5.193 +	UnloadPulseLibrary();
   5.194 +}
   5.195 +
   5.196 +static SDL_AudioDevice *Audio_CreateDevice(int devindex)
   5.197 +{
   5.198 +	SDL_AudioDevice *this;
   5.199 +
   5.200 +	/* Initialize all variables that we clean on shutdown */
   5.201 +	LoadPulseLibrary();
   5.202 +	this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
   5.203 +	if ( this ) {
   5.204 +		SDL_memset(this, 0, (sizeof *this));
   5.205 +		this->hidden = (struct SDL_PrivateAudioData *)
   5.206 +				SDL_malloc((sizeof *this->hidden));
   5.207 +	}
   5.208 +	if ( (this == NULL) || (this->hidden == NULL) ) {
   5.209 +		SDL_OutOfMemory();
   5.210 +		if ( this ) {
   5.211 +			SDL_free(this);
   5.212 +		}
   5.213 +		return(0);
   5.214 +	}
   5.215 +	SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   5.216 +
   5.217 +	/* Set the function pointers */
   5.218 +	this->OpenAudio = PULSE_OpenAudio;
   5.219 +	this->WaitAudio = PULSE_WaitAudio;
   5.220 +	this->PlayAudio = PULSE_PlayAudio;
   5.221 +	this->GetAudioBuf = PULSE_GetAudioBuf;
   5.222 +	this->CloseAudio = PULSE_CloseAudio;
   5.223 +
   5.224 +	this->free = Audio_DeleteDevice;
   5.225 +
   5.226 +	return this;
   5.227 +}
   5.228 +
   5.229 +AudioBootStrap PULSE_bootstrap = {
   5.230 +	PULSE_DRIVER_NAME, "PulseAudio",
   5.231 +	Audio_Available, Audio_CreateDevice
   5.232 +};
   5.233 +
   5.234 +/* This function waits until it is possible to write a full sound buffer */
   5.235 +static void PULSE_WaitAudio(_THIS)
   5.236 +{
   5.237 +	/* Check to see if the thread-parent process is still alive */
   5.238 +	{ static int cnt = 0;
   5.239 +		/* Note that this only works with thread implementations 
   5.240 +		   that use a different process id for each thread.
   5.241 +		*/
   5.242 +		if (parent && (((++cnt)%10) == 0)) { /* Check every 10 loops */
   5.243 +			if ( kill(parent, 0) < 0 ) {
   5.244 +				this->enabled = 0;
   5.245 +			}
   5.246 +		}
   5.247 +	}
   5.248 +}
   5.249 +
   5.250 +static void PULSE_PlayAudio(_THIS)
   5.251 +{
   5.252 +	/* Write the audio data */
   5.253 +	if ( SDL_NAME(pa_simple_write)(stream, mixbuf, mixlen, NULL) != 0 )
   5.254 +	{
   5.255 +		this->enabled = 0;
   5.256 +	}
   5.257 +}
   5.258 +
   5.259 +static Uint8 *PULSE_GetAudioBuf(_THIS)
   5.260 +{
   5.261 +	return(mixbuf);
   5.262 +}
   5.263 +
   5.264 +static void PULSE_CloseAudio(_THIS)
   5.265 +{
   5.266 +	if ( mixbuf != NULL ) {
   5.267 +		SDL_FreeAudioMem(mixbuf);
   5.268 +		mixbuf = NULL;
   5.269 +	}
   5.270 +	if ( stream != NULL ) {
   5.271 +		SDL_NAME(pa_simple_drain)(stream, NULL);
   5.272 +		SDL_NAME(pa_simple_free)(stream);
   5.273 +		stream = NULL;
   5.274 +	}
   5.275 +}
   5.276 +
   5.277 +/* Try to get the name of the program */
   5.278 +static char *get_progname(void)
   5.279 +{
   5.280 +	char *progname = NULL;
   5.281 +#ifdef __LINUX__
   5.282 +	FILE *fp;
   5.283 +	static char temp[BUFSIZ];
   5.284 +
   5.285 +	SDL_snprintf(temp, SDL_arraysize(temp), "/proc/%d/cmdline", getpid());
   5.286 +	fp = fopen(temp, "r");
   5.287 +	if ( fp != NULL ) {
   5.288 +		if ( fgets(temp, sizeof(temp)-1, fp) ) {
   5.289 +			progname = SDL_strrchr(temp, '/');
   5.290 +			if ( progname == NULL ) {
   5.291 +				progname = temp;
   5.292 +			} else {
   5.293 +				progname = progname+1;
   5.294 +			}
   5.295 +		}
   5.296 +		fclose(fp);
   5.297 +	}
   5.298 +#endif
   5.299 +	return(progname);
   5.300 +}
   5.301 +
   5.302 +static int PULSE_OpenAudio(_THIS, SDL_AudioSpec *spec)
   5.303 +{
   5.304 +	Uint16          test_format;
   5.305 +	pa_sample_spec  paspec;
   5.306 +	pa_buffer_attr  paattr;
   5.307 +	pa_channel_map  pacmap;
   5.308 +	
   5.309 +	paspec.format = PA_SAMPLE_INVALID;
   5.310 +	for ( test_format = SDL_FirstAudioFormat(spec->format); test_format; ) {
   5.311 +		switch ( test_format ) {
   5.312 +			case AUDIO_U8:
   5.313 +				paspec.format = PA_SAMPLE_U8;
   5.314 +				break;
   5.315 +			case AUDIO_S16LSB:
   5.316 +				paspec.format = PA_SAMPLE_S16LE;
   5.317 +				break;
   5.318 +			case AUDIO_S16MSB:
   5.319 +				paspec.format = PA_SAMPLE_S16BE;
   5.320 +				break;
   5.321 +		}
   5.322 +		if ( paspec.format != PA_SAMPLE_INVALID )
   5.323 +			break;
   5.324 +	}
   5.325 +	if (paspec.format == PA_SAMPLE_INVALID ) {
   5.326 +		SDL_SetError("Couldn't find any suitable audio formats");
   5.327 +		return(-1);
   5.328 +	}
   5.329 +	spec->format = test_format;
   5.330 +	
   5.331 +	paspec.channels = spec->channels;
   5.332 +	paspec.rate = spec->freq;
   5.333 +
   5.334 +	/* Calculate the final parameters for this audio specification */
   5.335 +	SDL_CalculateAudioSpec(spec);
   5.336 +
   5.337 +	/* Allocate mixing buffer */
   5.338 +	mixlen = spec->size;
   5.339 +	mixbuf = (Uint8 *)SDL_AllocAudioMem(mixlen);
   5.340 +	if ( mixbuf == NULL ) {
   5.341 +		return(-1);
   5.342 +	}
   5.343 +	SDL_memset(mixbuf, spec->silence, spec->size);
   5.344 +	
   5.345 +	/* Reduced prebuffering compared to the defaults. */
   5.346 +	paattr.tlength = mixlen;
   5.347 +	paattr.minreq = mixlen;
   5.348 +	paattr.fragsize = mixlen;
   5.349 +	paattr.prebuf = mixlen;
   5.350 +	paattr.maxlength = mixlen * 4;
   5.351 +	
   5.352 +	/* The SDL ALSA output hints us that we use Windows' channel mapping */
   5.353 +	/* http://bugzilla.libsdl.org/show_bug.cgi?id=110 */
   5.354 +	SDL_NAME(pa_channel_map_init_auto)(
   5.355 +		&pacmap, spec->channels, PA_CHANNEL_MAP_WAVEEX);
   5.356 +	
   5.357 +	/* Connect to the PulseAudio server */
   5.358 +	stream = SDL_NAME(pa_simple_new)(
   5.359 +		SDL_getenv("PASERVER"),      /* server */
   5.360 +		get_progname(),              /* application name */
   5.361 +		PA_STREAM_PLAYBACK,          /* playback mode */
   5.362 +		SDL_getenv("PADEVICE"),      /* device on the server */
   5.363 +		"Simple DirectMedia Layer",  /* stream description */
   5.364 +		&paspec,                     /* sample format spec */
   5.365 +		&pacmap,                     /* channel map */
   5.366 +		&paattr,                     /* buffering attributes */
   5.367 +		NULL                         /* error code */
   5.368 +	);
   5.369 +	if ( stream == NULL ) {
   5.370 +		PULSE_CloseAudio(this);
   5.371 +		SDL_SetError("Could not connect to PulseAudio");
   5.372 +		return(-1);
   5.373 +	}
   5.374 +
   5.375 +	/* Get the parent process id (we're the parent of the audio thread) */
   5.376 +	parent = getpid();
   5.377 +	
   5.378 +	return(0);
   5.379 +}
   5.380 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/audio/pulse/SDL_pulseaudio.h	Sun May 13 23:12:46 2007 +0000
     6.3 @@ -0,0 +1,53 @@
     6.4 +/*
     6.5 +    SDL - Simple DirectMedia Layer
     6.6 +    Copyright (C) 1997-2007 Sam Lantinga
     6.7 +
     6.8 +    This library is free software; you can redistribute it and/or
     6.9 +    modify it under the terms of the GNU Lesser General Public
    6.10 +    License as published by the Free Software Foundation; either
    6.11 +    version 2.1 of the License, or (at your option) any later version.
    6.12 +
    6.13 +    This library is distributed in the hope that it will be useful,
    6.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    6.16 +    Lesser General Public License for more details.
    6.17 +
    6.18 +    You should have received a copy of the GNU Lesser General Public
    6.19 +    License along with this library; if not, write to the Free Software
    6.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    6.21 +
    6.22 +    Stéphan Kochen
    6.23 +    stephan@kochen.nl
    6.24 +    
    6.25 +    Based on parts of the ALSA and ESounD output drivers.
    6.26 +*/
    6.27 +#include "SDL_config.h"
    6.28 +
    6.29 +#ifndef _SDL_pulseaudio_h
    6.30 +#define _SDL_pulseaudio_h
    6.31 +
    6.32 +#include "../SDL_sysaudio.h"
    6.33 +
    6.34 +/* Hidden "this" pointer for the video functions */
    6.35 +#define _THIS	SDL_AudioDevice *this
    6.36 +
    6.37 +struct SDL_PrivateAudioData {
    6.38 +	/* The audio stream handle */
    6.39 +	pa_simple * stream;
    6.40 +
    6.41 +	/* The parent process id, to detect when application quits */
    6.42 +	pid_t parent;
    6.43 +
    6.44 +	/* Raw mixing buffer */
    6.45 +	Uint8 *mixbuf;
    6.46 +	int    mixlen;
    6.47 +};
    6.48 +
    6.49 +/* Old variable names */
    6.50 +#define stream			(this->hidden->stream)
    6.51 +#define parent			(this->hidden->parent)
    6.52 +#define mixbuf			(this->hidden->mixbuf)
    6.53 +#define mixlen			(this->hidden->mixlen)
    6.54 +
    6.55 +#endif /* _SDL_pulseaudio_h */
    6.56 +