Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.
authorRyan C. Gordon <icculus@icculus.org>
Mon, 20 Aug 2007 01:02:37 +0000
changeset 227160b4c52a7906
parent 2270 d5a11262f067
child 2272 25a87553a59d
Ported PulseAudio target from 1.2 to 1.3 interfaces, and added it to the trunk.

Fixes Bugzilla #439.
configure.in
include/SDL_config.h.in
src/audio/SDL_audio.c
src/audio/pulseaudio/SDL_pulseaudio.c
src/audio/pulseaudio/SDL_pulseaudio.h
     1.1 --- a/configure.in	Sun Aug 19 16:36:51 2007 +0000
     1.2 +++ b/configure.in	Mon Aug 20 01:02:37 2007 +0000
     1.3 @@ -644,6 +644,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_pulseaudio=yes)
    1.13 +    if test x$enable_audio = xyes -a x$enable_pulseaudio = xyes; then
    1.14 +        audio_pulseaudio=no
    1.15 +
    1.16 +        PULSEAUDIO_REQUIRED_VERSION=0.9
    1.17 +
    1.18 +        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
    1.19 +        AC_MSG_CHECKING(for PulseAudio $PULSEAUDIO_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 $PULSEAUDIO_REQUIRED_VERSION libpulse-simple; then
    1.22 +                PULSEAUDIO_CFLAGS=`$PKG_CONFIG --cflags libpulse-simple`
    1.23 +                PULSEAUDIO_LIBS=`$PKG_CONFIG --libs libpulse-simple`
    1.24 +                audio_pulseaudio=yes
    1.25 +        fi
    1.26 +        fi
    1.27 +        AC_MSG_RESULT($audio_pulseaudio)
    1.28 +
    1.29 +        if test x$audio_pulseaudio = 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_pulseaudio_shared=yes)
    1.33 +            if test "x`echo $PULSEAUDIO_LIBS | grep -- -L`" = "x"; then
    1.34 +                if test "x`ls /lib/libpulse-simple.so.* 2> /dev/null`" != "x"; then
    1.35 +                    PULSEAUDIO_LIBS="-L/lib $PULSEAUDIO_LIBS"
    1.36 +                elif test "x`ls /usr/lib/libpulse-simple.so.* 2> /dev/null`" != "x"; then
    1.37 +                    PULSEAUDIO_LIBS="-L/usr/lib $PULSEAUDIO_LIBS"
    1.38 +                elif test "x`ls /usr/local/lib/libpulse-simple.so.* 2> /dev/null`" != "x"; then
    1.39 +                    PULSEAUDIO_LIBS="-L/usr/local/lib $PULSEAUDIO_LIBS"
    1.40 +                fi
    1.41 +            fi
    1.42 +            pulseaudio_lib_spec=`echo $PULSEAUDIO_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libpulse-simple.so.*/'`
    1.43 +            pulseaudio_lib=`ls -- $pulseaudio_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
    1.44 +            echo "-- $pulseaudio_lib_spec -> $pulseaudio_lib"
    1.45 +
    1.46 +            AC_DEFINE(SDL_AUDIO_DRIVER_PULSEAUDIO)
    1.47 +            SOURCES="$SOURCES $srcdir/src/audio/pulseaudio/*.c"
    1.48 +            EXTRA_CFLAGS="$EXTRA_CFLAGS $PULSEAUDIO_CFLAGS"
    1.49 +            if test x$have_loadso != xyes && \
    1.50 +               test x$enable_pulseaudio_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_pulseaudio_shared = xyes && test x$pulseaudio_lib != x; then
    1.55 +                AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC, "$pulseaudio_lib")
    1.56 +            else
    1.57 +                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PULSEAUDIO_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 @@ -2065,6 +2122,7 @@
    1.68          CheckDMEDIA
    1.69          CheckMME
    1.70          CheckALSA
    1.71 +        CheckPulseAudio
    1.72          CheckARTSC
    1.73          CheckESD
    1.74          CheckNAS
     2.1 --- a/include/SDL_config.h.in	Sun Aug 19 16:36:51 2007 +0000
     2.2 +++ b/include/SDL_config.h.in	Mon Aug 20 01:02:37 2007 +0000
     2.3 @@ -159,6 +159,8 @@
     2.4  #undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
     2.5  #undef SDL_AUDIO_DRIVER_ARTS
     2.6  #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
     2.7 +#undef SDL_AUDIO_DRIVER_PULSEAUDIO
     2.8 +#undef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC
     2.9  #undef SDL_AUDIO_DRIVER_BEOSAUDIO
    2.10  #undef SDL_AUDIO_DRIVER_BSD
    2.11  #undef SDL_AUDIO_DRIVER_COREAUDIO
     3.1 --- a/src/audio/SDL_audio.c	Sun Aug 19 16:36:51 2007 +0000
     3.2 +++ b/src/audio/SDL_audio.c	Mon Aug 20 01:02:37 2007 +0000
     3.3 @@ -47,6 +47,7 @@
     3.4  extern AudioBootStrap DSP_bootstrap;
     3.5  extern AudioBootStrap DMA_bootstrap;
     3.6  extern AudioBootStrap ALSA_bootstrap;
     3.7 +extern AudioBootStrap PULSEAUDIO_bootstrap;
     3.8  extern AudioBootStrap QNXNTOAUDIO_bootstrap;
     3.9  extern AudioBootStrap SUNAUDIO_bootstrap;
    3.10  extern AudioBootStrap DMEDIA_bootstrap;
    3.11 @@ -83,6 +84,9 @@
    3.12  #if SDL_AUDIO_DRIVER_ALSA
    3.13      &ALSA_bootstrap,
    3.14  #endif
    3.15 +#if SDL_AUDIO_DRIVER_PULSEAUDIO
    3.16 +	&PULSEAUDIO_bootstrap,
    3.17 +#endif
    3.18  #if SDL_AUDIO_DRIVER_QNXNTO
    3.19      &QNXNTOAUDIO_bootstrap,
    3.20  #endif
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/audio/pulseaudio/SDL_pulseaudio.c	Mon Aug 20 01:02:37 2007 +0000
     4.3 @@ -0,0 +1,389 @@
     4.4 +/*
     4.5 +    SDL - Simple DirectMedia Layer
     4.6 +    Copyright (C) 1997-2006 Sam Lantinga
     4.7 +
     4.8 +    This library is free software; you can redistribute it and/or
     4.9 +    modify it under the terms of the GNU Lesser General Public
    4.10 +    License as published by the Free Software Foundation; either
    4.11 +    version 2.1 of the License, or (at your option) any later version.
    4.12 +
    4.13 +    This library is distributed in the hope that it will be useful,
    4.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.16 +    Lesser General Public License for more details.
    4.17 +
    4.18 +    You should have received a copy of the GNU Lesser General Public
    4.19 +    License along with this library; if not, write to the Free Software
    4.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.21 +
    4.22 +    Sam Lantinga
    4.23 +    slouken@libsdl.org
    4.24 +*/
    4.25 +
    4.26 +/*
    4.27 +  The PulseAudio target for SDL 1.3 is based on the 1.3 arts target, with
    4.28 +   the appropriate parts replaced with the 1.2 PulseAudio target code. This
    4.29 +   was the cleanest way to move it to 1.3. The 1.2 target was written by
    4.30 +   St├ęphan Kochen: stephan .a.t. kochen.nl
    4.31 +*/
    4.32 +
    4.33 +#include "SDL_config.h"
    4.34 +
    4.35 +/* Allow access to a raw mixing buffer */
    4.36 +
    4.37 +#ifdef HAVE_SIGNAL_H
    4.38 +#include <signal.h>
    4.39 +#endif
    4.40 +#include <unistd.h>
    4.41 +#include <sys/types.h>
    4.42 +#include <errno.h>
    4.43 +#include <pulse/simple.h>
    4.44 +
    4.45 +#include "SDL_timer.h"
    4.46 +#include "SDL_audio.h"
    4.47 +#include "../SDL_audiomem.h"
    4.48 +#include "../SDL_audio_c.h"
    4.49 +#include "SDL_pulseaudio.h"
    4.50 +
    4.51 +#ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC
    4.52 +#include "SDL_name.h"
    4.53 +#include "SDL_loadso.h"
    4.54 +#else
    4.55 +#define SDL_NAME(X)	X
    4.56 +#endif
    4.57 +
    4.58 +/* The tag name used by pulse audio */
    4.59 +#define PULSEAUDIO_DRIVER_NAME         "pulseaudio"
    4.60 +
    4.61 +#ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC
    4.62 +
    4.63 +static const char *pulse_library = SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC;
    4.64 +static void *pulse_handle = NULL;
    4.65 +
    4.66 +/* !!! FIXME: I hate this SDL_NAME clutter...it makes everything so messy! */
    4.67 +static pa_simple* (*SDL_NAME(pa_simple_new))(
    4.68 +    const char *server,
    4.69 +    const char *name,
    4.70 +    pa_stream_direction_t dir,
    4.71 +    const char *dev,
    4.72 +    const char *stream_name,
    4.73 +    const pa_sample_spec *ss,
    4.74 +    const pa_channel_map *map,
    4.75 +    const pa_buffer_attr *attr,
    4.76 +    int *error
    4.77 +);
    4.78 +static void (*SDL_NAME(pa_simple_free))(pa_simple *s);
    4.79 +static int (*SDL_NAME(pa_simple_drain))(pa_simple *s, int *error);
    4.80 +static int (*SDL_NAME(pa_simple_write))(
    4.81 +    pa_simple *s,
    4.82 +    const void *data,
    4.83 +    size_t length,
    4.84 +    int *error
    4.85 +);
    4.86 +static pa_channel_map* (*SDL_NAME(pa_channel_map_init_auto))(
    4.87 +    pa_channel_map *m,
    4.88 +    unsigned channels,
    4.89 +    pa_channel_map_def_t def
    4.90 +);
    4.91 +
    4.92 +
    4.93 +#define SDL_PULSEAUDIO_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) }
    4.94 +static struct {
    4.95 +    const char *name;
    4.96 +    void **func;
    4.97 +} pulse_functions[] = {
    4.98 +/* *INDENT-OFF* */
    4.99 +    SDL_PULSEAUDIO_SYM(pa_simple_new),
   4.100 +    SDL_PULSEAUDIO_SYM(pa_simple_free),
   4.101 +    SDL_PULSEAUDIO_SYM(pa_simple_drain),
   4.102 +    SDL_PULSEAUDIO_SYM(pa_simple_write),
   4.103 +    SDL_PULSEAUDIO_SYM(pa_channel_map_init_auto),
   4.104 +/* *INDENT-ON* */
   4.105 +};
   4.106 +#undef SDL_PULSEAUDIO_SYM
   4.107 +
   4.108 +static void
   4.109 +UnloadPulseLibrary()
   4.110 +{
   4.111 +    if (pulse_handle != NULL) {
   4.112 +        SDL_UnloadObject(pulse_handle);
   4.113 +        pulse_handle = NULL;
   4.114 +    }
   4.115 +}
   4.116 +
   4.117 +static int
   4.118 +LoadPulseLibrary(void)
   4.119 +{
   4.120 +    int i, retval = -1;
   4.121 +
   4.122 +    if (pulse_handle == NULL) {
   4.123 +        pulse_handle = SDL_LoadObject(pulse_library);
   4.124 +        if (pulse_handle != NULL) {
   4.125 +            retval = 0;
   4.126 +            for (i = 0; i < SDL_arraysize(pulse_functions); ++i) {
   4.127 +                *pulse_functions[i].func =
   4.128 +                    SDL_LoadFunction(pulse_handle, pulse_functions[i].name);
   4.129 +                if (!*pulse_functions[i].func) {
   4.130 +                    retval = -1;
   4.131 +                    UnloadPulseLibrary();
   4.132 +                    break;
   4.133 +                }
   4.134 +            }
   4.135 +        }
   4.136 +    }
   4.137 +
   4.138 +    return retval;
   4.139 +}
   4.140 +
   4.141 +#else
   4.142 +
   4.143 +static void
   4.144 +UnloadPulseLibrary()
   4.145 +{
   4.146 +    return;
   4.147 +}
   4.148 +
   4.149 +static int
   4.150 +LoadPulseLibrary(void)
   4.151 +{
   4.152 +    return 0;
   4.153 +}
   4.154 +
   4.155 +#endif /* SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC */
   4.156 +
   4.157 +/* This function waits until it is possible to write a full sound buffer */
   4.158 +static void
   4.159 +PULSEAUDIO_WaitDevice(_THIS)
   4.160 +{
   4.161 +    Sint32 ticks;
   4.162 +
   4.163 +    /* Check to see if the thread-parent process is still alive */
   4.164 +    {
   4.165 +        static int cnt = 0;
   4.166 +        /* Note that this only works with thread implementations
   4.167 +           that use a different process id for each thread.
   4.168 +         */
   4.169 +        /* Check every 10 loops */
   4.170 +        if (this->hidden->parent && (((++cnt) % 10) == 0)) {
   4.171 +            if (kill(this->hidden->parent, 0) < 0) {
   4.172 +                this->enabled = 0;
   4.173 +            }
   4.174 +        }
   4.175 +    }
   4.176 +
   4.177 +    /* Use timer for general audio synchronization */
   4.178 +    ticks =
   4.179 +        ((Sint32) (this->hidden->next_frame - SDL_GetTicks())) - FUDGE_TICKS;
   4.180 +    if (ticks > 0) {
   4.181 +        SDL_Delay(ticks);
   4.182 +    }
   4.183 +}
   4.184 +
   4.185 +static void
   4.186 +PULSEAUDIO_PlayDevice(_THIS)
   4.187 +{
   4.188 +    /* Write the audio data */
   4.189 +    if ( SDL_NAME(pa_simple_write)(this->hidden->stream, this->hidden->mixbuf,
   4.190 +                                   this->hidden->mixlen, NULL) != 0 )
   4.191 +    {
   4.192 +        this->enabled = 0;
   4.193 +    }
   4.194 +}
   4.195 +
   4.196 +static void
   4.197 +PULSEAUDIO_WaitDone(_THIS)
   4.198 +{
   4.199 +    SDL_NAME(pa_simple_drain)(this->hidden->stream, NULL);
   4.200 +}
   4.201 +
   4.202 +
   4.203 +static Uint8 *
   4.204 +PULSEAUDIO_GetDeviceBuf(_THIS)
   4.205 +{
   4.206 +    return (this->hidden->mixbuf);
   4.207 +}
   4.208 +
   4.209 +
   4.210 +static void
   4.211 +PULSEAUDIO_CloseDevice(_THIS)
   4.212 +{
   4.213 +    if (this->hidden != NULL) {
   4.214 +        if (this->hidden->mixbuf != NULL) {
   4.215 +            SDL_FreeAudioMem(this->hidden->mixbuf);
   4.216 +            this->hidden->mixbuf = NULL;
   4.217 +        }
   4.218 +        if (this->hidden->stream) {
   4.219 +            SDL_NAME(pa_simple_drain)(this->hidden->stream, NULL);
   4.220 +            SDL_NAME(pa_simple_free)(this->hidden->stream);
   4.221 +            this->hidden->stream = NULL;
   4.222 +        }
   4.223 +        SDL_free(this->hidden);
   4.224 +        this->hidden = NULL;
   4.225 +    }
   4.226 +}
   4.227 +
   4.228 +
   4.229 +/* !!! FIXME: this could probably be expanded. */
   4.230 +/* Try to get the name of the program */
   4.231 +static char *get_progname(void)
   4.232 +{
   4.233 +    char *progname = NULL;
   4.234 +#ifdef __LINUX__
   4.235 +    FILE *fp;
   4.236 +    static char temp[BUFSIZ];
   4.237 +
   4.238 +    SDL_snprintf(temp, SDL_arraysize(temp), "/proc/%d/cmdline", getpid());
   4.239 +    fp = fopen(temp, "r");
   4.240 +    if ( fp != NULL ) {
   4.241 +        if ( fgets(temp, sizeof(temp)-1, fp) ) {
   4.242 +            progname = SDL_strrchr(temp, '/');
   4.243 +            if ( progname == NULL ) {
   4.244 +                progname = temp;
   4.245 +            } else {
   4.246 +                progname = progname+1;
   4.247 +            }
   4.248 +        }
   4.249 +        fclose(fp);
   4.250 +    }
   4.251 +#endif
   4.252 +    return(progname);
   4.253 +}
   4.254 +
   4.255 +
   4.256 +static int
   4.257 +PULSEAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
   4.258 +{
   4.259 +    Uint16          test_format;
   4.260 +    pa_sample_spec  paspec;
   4.261 +    pa_buffer_attr  paattr;
   4.262 +    pa_channel_map  pacmap;
   4.263 +
   4.264 +    /* Initialize all variables that we clean on shutdown */
   4.265 +    this->hidden = (struct SDL_PrivateAudioData *)
   4.266 +        SDL_malloc((sizeof *this->hidden));
   4.267 +    if (this->hidden == NULL) {
   4.268 +        SDL_OutOfMemory();
   4.269 +        return 0;
   4.270 +    }
   4.271 +    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   4.272 +
   4.273 +    paspec.format = PA_SAMPLE_INVALID;
   4.274 +
   4.275 +    /* Try for a closest match on audio format */
   4.276 +    for (test_format = SDL_FirstAudioFormat(this->spec.format);
   4.277 +         (paspec.format == PA_SAMPLE_INVALID) && test_format;) {
   4.278 +#ifdef DEBUG_AUDIO
   4.279 +        fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
   4.280 +#endif
   4.281 +        switch ( test_format ) {
   4.282 +            case AUDIO_U8:
   4.283 +                paspec.format = PA_SAMPLE_U8;
   4.284 +                break;
   4.285 +            case AUDIO_S16LSB:
   4.286 +                paspec.format = PA_SAMPLE_S16LE;
   4.287 +                break;
   4.288 +            case AUDIO_S16MSB:
   4.289 +                paspec.format = PA_SAMPLE_S16BE;
   4.290 +                break;
   4.291 +            default:
   4.292 +                paspec.format = PA_SAMPLE_INVALID;
   4.293 +                break;
   4.294 +        }
   4.295 +        if (paspec.format == PA_SAMPLE_INVALID) {
   4.296 +            test_format = SDL_NextAudioFormat();
   4.297 +        }
   4.298 +    }
   4.299 +    if (paspec.format == PA_SAMPLE_INVALID) {
   4.300 +        PULSEAUDIO_CloseDevice(this);
   4.301 +        SDL_SetError("Couldn't find any hardware audio formats");
   4.302 +        return 0;
   4.303 +    }
   4.304 +    this->spec.format = test_format;
   4.305 +
   4.306 +    /* Calculate the final parameters for this audio specification */
   4.307 +    SDL_CalculateAudioSpec(&this->spec);
   4.308 +
   4.309 +    /* Allocate mixing buffer */
   4.310 +    this->hidden->mixlen = this->spec.size;
   4.311 +    this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
   4.312 +    if (this->hidden->mixbuf == NULL) {
   4.313 +        PULSEAUDIO_CloseDevice(this);
   4.314 +        SDL_OutOfMemory();
   4.315 +        return 0;
   4.316 +    }
   4.317 +    SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
   4.318 +
   4.319 +    paspec.channels = this->spec.channels;
   4.320 +    paspec.rate = this->spec.freq;
   4.321 +
   4.322 +    /* Reduced prebuffering compared to the defaults. */
   4.323 +    paattr.tlength = this->hidden->mixlen;
   4.324 +    paattr.minreq = this->hidden->mixlen;
   4.325 +    paattr.fragsize = this->hidden->mixlen;
   4.326 +    paattr.prebuf = this->hidden->mixlen;
   4.327 +    paattr.maxlength = this->hidden->mixlen * 4;
   4.328 +
   4.329 +    /* The SDL ALSA output hints us that we use Windows' channel mapping */
   4.330 +    /* http://bugzilla.libsdl.org/show_bug.cgi?id=110 */
   4.331 +    SDL_NAME(pa_channel_map_init_auto)(
   4.332 +        &pacmap, this->spec.channels, PA_CHANNEL_MAP_WAVEEX);
   4.333 +
   4.334 +    /* Connect to the PulseAudio server */
   4.335 +    this->hidden->stream = SDL_NAME(pa_simple_new)(
   4.336 +        SDL_getenv("PASERVER"),      /* server */
   4.337 +        get_progname(),              /* application name */
   4.338 +        PA_STREAM_PLAYBACK,          /* playback mode */
   4.339 +        SDL_getenv("PADEVICE"),      /* device on the server */
   4.340 +        "Simple DirectMedia Layer",  /* stream description */
   4.341 +        &paspec,                     /* sample format spec */
   4.342 +        &pacmap,                     /* channel map */
   4.343 +        &paattr,                     /* buffering attributes */
   4.344 +        NULL                         /* error code */
   4.345 +    );
   4.346 +    if ( this->hidden->stream == NULL ) {
   4.347 +        PULSEAUDIO_CloseDevice(this);
   4.348 +        SDL_SetError("Could not connect to PulseAudio");
   4.349 +        return(-1);
   4.350 +    }
   4.351 +
   4.352 +    /* Get the parent process id (we're the parent of the audio thread) */
   4.353 +    this->hidden->parent = getpid();
   4.354 +
   4.355 +    /* We're ready to rock and roll. :-) */
   4.356 +    return 1;
   4.357 +}
   4.358 +
   4.359 +
   4.360 +static void
   4.361 +PULSEAUDIO_Deinitialize(void)
   4.362 +{
   4.363 +    UnloadPulseLibrary();
   4.364 +}
   4.365 +
   4.366 +
   4.367 +static int
   4.368 +PULSEAUDIO_Init(SDL_AudioDriverImpl * impl)
   4.369 +{
   4.370 +    if (LoadPulseLibrary() < 0) {
   4.371 +        return 0;
   4.372 +    }
   4.373 +
   4.374 +    /* Set the function pointers */
   4.375 +    impl->OpenDevice = PULSEAUDIO_OpenDevice;
   4.376 +    impl->PlayDevice = PULSEAUDIO_PlayDevice;
   4.377 +    impl->WaitDevice = PULSEAUDIO_WaitDevice;
   4.378 +    impl->GetDeviceBuf = PULSEAUDIO_GetDeviceBuf;
   4.379 +    impl->CloseDevice = PULSEAUDIO_CloseDevice;
   4.380 +    impl->WaitDone = PULSEAUDIO_WaitDone;
   4.381 +    impl->Deinitialize = PULSEAUDIO_Deinitialize;
   4.382 +    impl->OnlyHasDefaultOutputDevice = 1;
   4.383 +
   4.384 +    return 1;
   4.385 +}
   4.386 +
   4.387 +
   4.388 +AudioBootStrap PULSEAUDIO_bootstrap = {
   4.389 +    PULSEAUDIO_DRIVER_NAME, "PulseAudio", PULSEAUDIO_Init, 0
   4.390 +};
   4.391 +
   4.392 +/* vi: set ts=4 sw=4 expandtab: */
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/audio/pulseaudio/SDL_pulseaudio.h	Mon Aug 20 01:02:37 2007 +0000
     5.3 @@ -0,0 +1,54 @@
     5.4 +/*
     5.5 +    SDL - Simple DirectMedia Layer
     5.6 +    Copyright (C) 1997-2006 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 +    Sam Lantinga
    5.23 +    slouken@libsdl.org
    5.24 +*/
    5.25 +#include "SDL_config.h"
    5.26 +
    5.27 +#ifndef _SDL_pulseaudio_h
    5.28 +#define _SDL_pulseaudio_h
    5.29 +
    5.30 +#include <pulse/simple.h>
    5.31 +
    5.32 +#include "../SDL_sysaudio.h"
    5.33 +
    5.34 +/* Hidden "this" pointer for the audio functions */
    5.35 +#define _THIS	SDL_AudioDevice *this
    5.36 +
    5.37 +struct SDL_PrivateAudioData
    5.38 +{
    5.39 +	/* The audio stream handle */
    5.40 +	pa_simple *stream;
    5.41 +
    5.42 +    /* The parent process id, to detect when application quits */
    5.43 +    pid_t parent;
    5.44 +
    5.45 +    /* Raw mixing buffer */
    5.46 +    Uint8 *mixbuf;
    5.47 +    int mixlen;
    5.48 +
    5.49 +    /* Support for audio timing using a timer, in addition to select() */
    5.50 +    float frame_ticks;
    5.51 +    float next_frame;
    5.52 +};
    5.53 +#define FUDGE_TICKS	10      /* The scheduler overhead ticks per frame */
    5.54 +
    5.55 +#endif /* _SDL_pulseaudio_h */
    5.56 +
    5.57 +/* vi: set ts=4 sw=4 expandtab: */