Removed /dev/dsp DMA audio target.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 24 Jul 2011 03:37:13 -0700
changeset 55867fe92c1dc1d9
parent 5585 223345a23d0b
child 5587 9c554d44ea66
Removed /dev/dsp DMA audio target.
Makefile.pandora
Makefile.wiz
configure.in
src/audio/SDL_audio.c
src/audio/bsd/SDL_bsdaudio.c
src/audio/dma/SDL_dmaaudio.c
src/audio/dma/SDL_dmaaudio.h
src/audio/paudio/SDL_paudio.c
     1.1 --- a/Makefile.pandora	Sat Jul 23 00:22:19 2011 -0700
     1.2 +++ b/Makefile.pandora	Sun Jul 24 03:37:13 2011 -0700
     1.3 @@ -15,7 +15,7 @@
     1.4  SOURCES = ./src/*.c ./src/audio/*.c ./src/cpuinfo/*.c ./src/events/*.c \
     1.5  	./src/file/*.c ./src/stdlib/*.c ./src/thread/*.c ./src/timer/*.c ./src/video/*.c \
     1.6  	./src/joystick/*.c ./src/haptic/*.c ./src/power/*.c ./src/video/dummy/*.c ./src/audio/disk/*.c \
     1.7 -	./src/audio/dummy/*.c ./src/loadso/dlopen/*.c ./src/audio/dsp/*.c ./src/audio/dma/*.c \
     1.8 +	./src/audio/dummy/*.c ./src/loadso/dlopen/*.c ./src/audio/dsp/*.c \
     1.9  	./src/thread/pthread/SDL_systhread.c ./src/thread/pthread/SDL_syssem.c \
    1.10  	./src/thread/pthread/SDL_sysmutex.c ./src/thread/pthread/SDL_syscond.c \
    1.11  	./src/joystick/linux/*.c ./src/haptic/linux/*.c ./src/timer/unix/*.c \
     2.1 --- a/Makefile.wiz	Sat Jul 23 00:22:19 2011 -0700
     2.2 +++ b/Makefile.wiz	Sun Jul 24 03:37:13 2011 -0700
     2.3 @@ -15,7 +15,7 @@
     2.4  SOURCES = ./src/*.c ./src/audio/*.c ./src/cdrom/*.c ./src/cpuinfo/*.c ./src/events/*.c \
     2.5  	./src/file/*.c ./src/stdlib/*.c ./src/thread/*.c ./src/timer/*.c ./src/video/*.c \
     2.6  	./src/joystick/*.c ./src/haptic/*.c ./src/video/dummy/*.c ./src/audio/disk/*.c \
     2.7 -	./src/audio/dummy/*.c ./src/loadso/dlopen/*.c ./src/audio/dsp/*.c ./src/audio/dma/*.c \
     2.8 +	./src/audio/dummy/*.c ./src/loadso/dlopen/*.c ./src/audio/dsp/*.c \
     2.9  	./src/thread/pthread/SDL_systhread.c ./src/thread/pthread/SDL_syssem.c \
    2.10  	./src/thread/pthread/SDL_sysmutex.c ./src/thread/pthread/SDL_syscond.c \
    2.11  	./src/joystick/linux/*.c ./src/haptic/linux/*.c ./src/timer/unix/*.c ./src/cdrom/dummy/*.c \
     3.1 --- a/configure.in	Sat Jul 23 00:22:19 2011 -0700
     3.2 +++ b/configure.in	Sun Jul 24 03:37:13 2011 -0700
     3.3 @@ -682,7 +682,6 @@
     3.4          if test x$have_oss = xyes; then
     3.5              AC_DEFINE(SDL_AUDIO_DRIVER_OSS, 1, [ ])
     3.6              SOURCES="$SOURCES $srcdir/src/audio/dsp/*.c"
     3.7 -            SOURCES="$SOURCES $srcdir/src/audio/dma/*.c"
     3.8              have_audio=yes
     3.9  
    3.10              # We may need to link with ossaudio emulation library
     4.1 --- a/src/audio/SDL_audio.c	Sat Jul 23 00:22:19 2011 -0700
     4.2 +++ b/src/audio/SDL_audio.c	Sun Jul 24 03:37:13 2011 -0700
     4.3 @@ -45,7 +45,6 @@
     4.4   */
     4.5  extern AudioBootStrap BSD_AUDIO_bootstrap;
     4.6  extern AudioBootStrap DSP_bootstrap;
     4.7 -extern AudioBootStrap DMA_bootstrap;
     4.8  extern AudioBootStrap ALSA_bootstrap;
     4.9  extern AudioBootStrap PULSEAUDIO_bootstrap;
    4.10  extern AudioBootStrap QSAAUDIO_bootstrap;
    4.11 @@ -82,7 +81,6 @@
    4.12  #endif
    4.13  #if SDL_AUDIO_DRIVER_OSS
    4.14      &DSP_bootstrap,
    4.15 -    &DMA_bootstrap,
    4.16  #endif
    4.17  #if SDL_AUDIO_DRIVER_QSA
    4.18      &QSAAUDIO_bootstrap,
     5.1 --- a/src/audio/bsd/SDL_bsdaudio.c	Sat Jul 23 00:22:19 2011 -0700
     5.2 +++ b/src/audio/bsd/SDL_bsdaudio.c	Sun Jul 24 03:37:13 2011 -0700
     5.3 @@ -67,7 +67,7 @@
     5.4  #define OPEN_FLAGS_INPUT (O_RDONLY|O_NONBLOCK)
     5.5  #endif
     5.6  
     5.7 -/* !!! FIXME: so much cut and paste with dsp/dma drivers... */
     5.8 +/* !!! FIXME: so much cut and paste with dsp target... */
     5.9  static char **outputDevices = NULL;
    5.10  static int outputDeviceCount = 0;
    5.11  static char **inputDevices = NULL;
     6.1 --- a/src/audio/dma/SDL_dmaaudio.c	Sat Jul 23 00:22:19 2011 -0700
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,534 +0,0 @@
     6.4 -/*
     6.5 -  Simple DirectMedia Layer
     6.6 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
     6.7 -
     6.8 -  This software is provided 'as-is', without any express or implied
     6.9 -  warranty.  In no event will the authors be held liable for any damages
    6.10 -  arising from the use of this software.
    6.11 -
    6.12 -  Permission is granted to anyone to use this software for any purpose,
    6.13 -  including commercial applications, and to alter it and redistribute it
    6.14 -  freely, subject to the following restrictions:
    6.15 -
    6.16 -  1. The origin of this software must not be misrepresented; you must not
    6.17 -     claim that you wrote the original software. If you use this software
    6.18 -     in a product, an acknowledgment in the product documentation would be
    6.19 -     appreciated but is not required.
    6.20 -  2. Altered source versions must be plainly marked as such, and must not be
    6.21 -     misrepresented as being the original software.
    6.22 -  3. This notice may not be removed or altered from any source distribution.
    6.23 -*/
    6.24 -#include "SDL_config.h"
    6.25 -
    6.26 -/* !!! FIXME: merge this driver with "dsp". */
    6.27 -
    6.28 -/* Allow access to a raw mixing buffer */
    6.29 -
    6.30 -#include <stdio.h>
    6.31 -#include <string.h>             /* For strerror() */
    6.32 -#include <errno.h>
    6.33 -#include <unistd.h>
    6.34 -#include <fcntl.h>
    6.35 -#include <signal.h>
    6.36 -#include <sys/types.h>
    6.37 -#include <sys/time.h>
    6.38 -#include <sys/ioctl.h>
    6.39 -#include <sys/stat.h>
    6.40 -#include <sys/mman.h>
    6.41 -
    6.42 -#if SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H
    6.43 -/* This is installed on some systems */
    6.44 -#include <soundcard.h>
    6.45 -#else
    6.46 -/* This is recommended by OSS */
    6.47 -#include <sys/soundcard.h>
    6.48 -#endif
    6.49 -
    6.50 -#ifndef MAP_FAILED
    6.51 -#define MAP_FAILED	((Uint8 *)-1)
    6.52 -#endif
    6.53 -
    6.54 -#include "SDL_timer.h"
    6.55 -#include "SDL_audio.h"
    6.56 -#include "../SDL_audio_c.h"
    6.57 -#include "../SDL_audiodev_c.h"
    6.58 -#include "SDL_dmaaudio.h"
    6.59 -
    6.60 -/* The tag name used by DMA audio */
    6.61 -#define DMA_DRIVER_NAME         "dma"
    6.62 -
    6.63 -/* Open the audio device for playback, and don't block if busy */
    6.64 -#define OPEN_FLAGS_INPUT    (O_RDWR|O_NONBLOCK)
    6.65 -#define OPEN_FLAGS_OUTPUT   (O_RDWR|O_NONBLOCK)
    6.66 -
    6.67 -static char **outputDevices = NULL;
    6.68 -static int outputDeviceCount = 0;
    6.69 -static char **inputDevices = NULL;
    6.70 -static int inputDeviceCount = 0;
    6.71 -
    6.72 -static int
    6.73 -test_for_mmap(int fd)
    6.74 -{
    6.75 -    int caps = 0;
    6.76 -    struct audio_buf_info info;
    6.77 -    if ((ioctl(fd, SNDCTL_DSP_GETCAPS, &caps) == 0) &&
    6.78 -        (caps & DSP_CAP_TRIGGER) && (caps & DSP_CAP_MMAP) &&
    6.79 -        (ioctl(fd, SNDCTL_DSP_GETOSPACE, &info) == 0)) {
    6.80 -        size_t len = info.fragstotal * info.fragsize;
    6.81 -        Uint8 *buf = (Uint8 *) mmap(NULL, len, PROT_WRITE, MAP_SHARED, fd, 0);
    6.82 -        if (buf != MAP_FAILED) {
    6.83 -            munmap(buf, len);
    6.84 -            return 1;
    6.85 -        }
    6.86 -    }
    6.87 -    return 0;
    6.88 -}
    6.89 -
    6.90 -
    6.91 -static inline void
    6.92 -free_device_list(char ***devs, int *count)
    6.93 -{
    6.94 -    SDL_FreeUnixAudioDevices(devs, count);
    6.95 -}
    6.96 -
    6.97 -static inline void
    6.98 -build_device_list(int iscapture, char ***devs, int *count)
    6.99 -{
   6.100 -    const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT);
   6.101 -    free_device_list(devs, count);
   6.102 -    SDL_EnumUnixAudioDevices(flags, 0, test_for_mmap, devs, count);
   6.103 -}
   6.104 -
   6.105 -static inline void
   6.106 -build_device_lists(void)
   6.107 -{
   6.108 -    build_device_list(0, &outputDevices, &outputDeviceCount);
   6.109 -    build_device_list(1, &inputDevices, &inputDeviceCount);
   6.110 -}
   6.111 -
   6.112 -
   6.113 -static inline void
   6.114 -free_device_lists(void)
   6.115 -{
   6.116 -    free_device_list(&outputDevices, &outputDeviceCount);
   6.117 -    free_device_list(&inputDevices, &inputDeviceCount);
   6.118 -}
   6.119 -
   6.120 -
   6.121 -static void
   6.122 -DMA_Deinitialize(void)
   6.123 -{
   6.124 -    free_device_lists();
   6.125 -}
   6.126 -
   6.127 -static int
   6.128 -DMA_DetectDevices(int iscapture)
   6.129 -{
   6.130 -    if (iscapture) {
   6.131 -        build_device_list(1, &inputDevices, &inputDeviceCount);
   6.132 -        return inputDeviceCount;
   6.133 -    } else {
   6.134 -        build_device_list(0, &outputDevices, &outputDeviceCount);
   6.135 -        return outputDeviceCount;
   6.136 -    }
   6.137 -
   6.138 -    return 0;                   /* shouldn't ever hit this. */
   6.139 -}
   6.140 -
   6.141 -
   6.142 -static const char *
   6.143 -DMA_GetDeviceName(int index, int iscapture)
   6.144 -{
   6.145 -    if ((iscapture) && (index < inputDeviceCount)) {
   6.146 -        return inputDevices[index];
   6.147 -    } else if ((!iscapture) && (index < outputDeviceCount)) {
   6.148 -        return outputDevices[index];
   6.149 -    }
   6.150 -
   6.151 -    SDL_SetError("No such device");
   6.152 -    return NULL;
   6.153 -}
   6.154 -
   6.155 -
   6.156 -static int
   6.157 -DMA_ReopenAudio(_THIS, const char *audiodev, int format, int stereo)
   6.158 -{
   6.159 -    int frag_spec;
   6.160 -    int value;
   6.161 -
   6.162 -    /* Close and then reopen the audio device */
   6.163 -    close(audio_fd);
   6.164 -    audio_fd = open(audiodev, O_RDWR, 0);
   6.165 -    if (audio_fd < 0) {
   6.166 -        SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno));
   6.167 -        return (-1);
   6.168 -    }
   6.169 -
   6.170 -    /* Calculate the final parameters for this audio specification */
   6.171 -    SDL_CalculateAudioSpec(&this->spec);
   6.172 -
   6.173 -    /* Determine the power of two of the fragment size */
   6.174 -    for (frag_spec = 0; (0x01 << frag_spec) < this->spec.size; ++frag_spec);
   6.175 -    if ((0x01 << frag_spec) != this->spec.size) {
   6.176 -        SDL_SetError("Fragment size must be a power of two");
   6.177 -        return (-1);
   6.178 -    }
   6.179 -
   6.180 -    /* Set the audio buffering parameters */
   6.181 -    if (ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_spec) < 0) {
   6.182 -        SDL_SetError("Couldn't set audio fragment spec");
   6.183 -        return (-1);
   6.184 -    }
   6.185 -
   6.186 -    /* Set the audio format */
   6.187 -    value = format;
   6.188 -    if ((ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || (value != format)) {
   6.189 -        SDL_SetError("Couldn't set audio format");
   6.190 -        return (-1);
   6.191 -    }
   6.192 -
   6.193 -    /* Set mono or stereo audio */
   6.194 -    value = (this->spec.channels > 1);
   6.195 -    if ((ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo) < 0) ||
   6.196 -        (value != stereo)) {
   6.197 -        SDL_SetError("Couldn't set audio channels");
   6.198 -        return (-1);
   6.199 -    }
   6.200 -
   6.201 -    /* Set the DSP frequency */
   6.202 -    value = this->spec.freq;
   6.203 -    if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &value) < 0) {
   6.204 -        SDL_SetError("Couldn't set audio frequency");
   6.205 -        return (-1);
   6.206 -    }
   6.207 -    this->spec.freq = value;
   6.208 -
   6.209 -    /* We successfully re-opened the audio */
   6.210 -    return (0);
   6.211 -}
   6.212 -
   6.213 -
   6.214 -static void
   6.215 -DMA_CloseDevice(_THIS)
   6.216 -{
   6.217 -    if (this->hidden != NULL) {
   6.218 -        if (dma_buf != NULL) {
   6.219 -            munmap(dma_buf, dma_len);
   6.220 -            dma_buf = NULL;
   6.221 -        }
   6.222 -        if (audio_fd >= 0) {
   6.223 -            close(audio_fd);
   6.224 -            audio_fd = -1;
   6.225 -        }
   6.226 -        SDL_free(this->hidden);
   6.227 -        this->hidden = NULL;
   6.228 -    }
   6.229 -}
   6.230 -
   6.231 -
   6.232 -static int
   6.233 -DMA_OpenDevice(_THIS, const char *devname, int iscapture)
   6.234 -{
   6.235 -    const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT);
   6.236 -    int format;
   6.237 -    int stereo;
   6.238 -    int value;
   6.239 -    SDL_AudioFormat test_format;
   6.240 -    struct audio_buf_info info;
   6.241 -
   6.242 -    /* We don't care what the devname is...we'll try to open anything. */
   6.243 -    /*  ...but default to first name in the list... */
   6.244 -    if (devname == NULL) {
   6.245 -        if (((iscapture) && (inputDeviceCount == 0)) ||
   6.246 -            ((!iscapture) && (outputDeviceCount == 0))) {
   6.247 -            SDL_SetError("No such audio device");
   6.248 -            return 0;
   6.249 -        }
   6.250 -        devname = ((iscapture) ? inputDevices[0] : outputDevices[0]);
   6.251 -    }
   6.252 -
   6.253 -    /* Initialize all variables that we clean on shutdown */
   6.254 -    this->hidden = (struct SDL_PrivateAudioData *)
   6.255 -        SDL_malloc((sizeof *this->hidden));
   6.256 -    if (this->hidden == NULL) {
   6.257 -        SDL_OutOfMemory();
   6.258 -        return 0;
   6.259 -    }
   6.260 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   6.261 -
   6.262 -    /* Open the audio device */
   6.263 -    audio_fd = open(devname, flags, 0);
   6.264 -    if (audio_fd < 0) {
   6.265 -        DMA_CloseDevice(this);
   6.266 -        SDL_SetError("Couldn't open %s: %s", devname, strerror(errno));
   6.267 -        return 0;
   6.268 -    }
   6.269 -    dma_buf = NULL;
   6.270 -    ioctl(audio_fd, SNDCTL_DSP_RESET, 0);
   6.271 -
   6.272 -    /* Get a list of supported hardware formats */
   6.273 -    if (ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0) {
   6.274 -        DMA_CloseDevice(this);
   6.275 -        SDL_SetError("Couldn't get audio format list");
   6.276 -        return 0;
   6.277 -    }
   6.278 -
   6.279 -    /* Try for a closest match on audio format */
   6.280 -    format = 0;
   6.281 -    for (test_format = SDL_FirstAudioFormat(this->spec.format);
   6.282 -         !format && test_format;) {
   6.283 -#ifdef DEBUG_AUDIO
   6.284 -        fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
   6.285 -#endif
   6.286 -        switch (test_format) {
   6.287 -        case AUDIO_U8:
   6.288 -            if (value & AFMT_U8) {
   6.289 -                format = AFMT_U8;
   6.290 -            }
   6.291 -            break;
   6.292 -        case AUDIO_S8:
   6.293 -            if (value & AFMT_S8) {
   6.294 -                format = AFMT_S8;
   6.295 -            }
   6.296 -            break;
   6.297 -        case AUDIO_S16LSB:
   6.298 -            if (value & AFMT_S16_LE) {
   6.299 -                format = AFMT_S16_LE;
   6.300 -            }
   6.301 -            break;
   6.302 -        case AUDIO_S16MSB:
   6.303 -            if (value & AFMT_S16_BE) {
   6.304 -                format = AFMT_S16_BE;
   6.305 -            }
   6.306 -            break;
   6.307 -        case AUDIO_U16LSB:
   6.308 -            if (value & AFMT_U16_LE) {
   6.309 -                format = AFMT_U16_LE;
   6.310 -            }
   6.311 -            break;
   6.312 -        case AUDIO_U16MSB:
   6.313 -            if (value & AFMT_U16_BE) {
   6.314 -                format = AFMT_U16_BE;
   6.315 -            }
   6.316 -            break;
   6.317 -        default:
   6.318 -            format = 0;
   6.319 -            break;
   6.320 -        }
   6.321 -        if (!format) {
   6.322 -            test_format = SDL_NextAudioFormat();
   6.323 -        }
   6.324 -    }
   6.325 -    if (format == 0) {
   6.326 -        DMA_CloseDevice(this);
   6.327 -        SDL_SetError("Couldn't find any hardware audio formats");
   6.328 -        return 0;
   6.329 -    }
   6.330 -    this->spec.format = test_format;
   6.331 -
   6.332 -    /* Set the audio format */
   6.333 -    value = format;
   6.334 -    if ((ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || (value != format)) {
   6.335 -        DMA_CloseDevice(this);
   6.336 -        SDL_SetError("Couldn't set audio format");
   6.337 -        return 0;
   6.338 -    }
   6.339 -
   6.340 -    /* Set mono or stereo audio (currently only two channels supported) */
   6.341 -    stereo = (this->spec.channels > 1);
   6.342 -    ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo);
   6.343 -    if (stereo) {
   6.344 -        this->spec.channels = 2;
   6.345 -    } else {
   6.346 -        this->spec.channels = 1;
   6.347 -    }
   6.348 -
   6.349 -    /* Because some drivers don't allow setting the buffer size
   6.350 -       after setting the format, we must re-open the audio device
   6.351 -       once we know what format and channels are supported
   6.352 -     */
   6.353 -    if (DMA_ReopenAudio(this, devname, format, stereo) < 0) {
   6.354 -        DMA_CloseDevice(this);
   6.355 -        /* Error is set by DMA_ReopenAudio() */
   6.356 -        return 0;
   6.357 -    }
   6.358 -
   6.359 -    /* Memory map the audio buffer */
   6.360 -    if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info) < 0) {
   6.361 -        DMA_CloseDevice(this);
   6.362 -        SDL_SetError("Couldn't get OSPACE parameters");
   6.363 -        return 0;
   6.364 -    }
   6.365 -    this->spec.size = info.fragsize;
   6.366 -    this->spec.samples = this->spec.size / ((this->spec.format & 0xFF) / 8);
   6.367 -    this->spec.samples /= this->spec.channels;
   6.368 -    num_buffers = info.fragstotal;
   6.369 -    dma_len = num_buffers * this->spec.size;
   6.370 -    dma_buf = (Uint8 *) mmap(NULL, dma_len, PROT_WRITE, MAP_SHARED,
   6.371 -                             audio_fd, 0);
   6.372 -    if (dma_buf == MAP_FAILED) {
   6.373 -        DMA_CloseDevice(this);
   6.374 -        SDL_SetError("DMA memory map failed");
   6.375 -        dma_buf = NULL;
   6.376 -        return 0;
   6.377 -    }
   6.378 -    SDL_memset(dma_buf, this->spec.silence, dma_len);
   6.379 -
   6.380 -    /* Check to see if we need to use select() workaround */
   6.381 -    {
   6.382 -        char *workaround;
   6.383 -        workaround = SDL_getenv("SDL_DSP_NOSELECT");
   6.384 -        if (workaround) {
   6.385 -            frame_ticks =
   6.386 -                (float) (this->spec.samples * 1000) / this->spec.freq;
   6.387 -            next_frame = SDL_GetTicks() + frame_ticks;
   6.388 -        }
   6.389 -    }
   6.390 -
   6.391 -    /* Trigger audio playback */
   6.392 -    value = 0;
   6.393 -    ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &value);
   6.394 -    value = PCM_ENABLE_OUTPUT;
   6.395 -    if (ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &value) < 0) {
   6.396 -        DMA_CloseDevice(this);
   6.397 -        SDL_SetError("Couldn't trigger audio output");
   6.398 -        return 0;
   6.399 -    }
   6.400 -
   6.401 -    /* Get the parent process id (we're the parent of the audio thread) */
   6.402 -    parent = getpid();
   6.403 -
   6.404 -    /* We're ready to rock and roll. :-) */
   6.405 -    return 1;
   6.406 -}
   6.407 -
   6.408 -
   6.409 -/* This function waits until it is possible to write a full sound buffer */
   6.410 -static void
   6.411 -DMA_WaitDevice(_THIS)
   6.412 -{
   6.413 -    fd_set fdset;
   6.414 -
   6.415 -    /* Check to see if the thread-parent process is still alive */
   6.416 -    {
   6.417 -        static int cnt = 0;
   6.418 -        /* Note that this only works with thread implementations 
   6.419 -           that use a different process id for each thread.
   6.420 -         */
   6.421 -        if (parent && (((++cnt) % 10) == 0)) {  /* Check every 10 loops */
   6.422 -            if (kill(parent, 0) < 0 && errno == ESRCH) {
   6.423 -                this->enabled = 0;
   6.424 -            }
   6.425 -        }
   6.426 -    }
   6.427 -
   6.428 -    /* See if we need to use timed audio synchronization */
   6.429 -    if (frame_ticks) {
   6.430 -        /* Use timer for general audio synchronization */
   6.431 -        Sint32 ticks;
   6.432 -
   6.433 -        ticks = ((Sint32) (next_frame - SDL_GetTicks())) - FUDGE_TICKS;
   6.434 -        if (ticks > 0) {
   6.435 -            SDL_Delay(ticks);
   6.436 -        }
   6.437 -    } else {
   6.438 -        /* Use select() for audio synchronization */
   6.439 -        struct timeval timeout;
   6.440 -        FD_ZERO(&fdset);
   6.441 -        FD_SET(audio_fd, &fdset);
   6.442 -        timeout.tv_sec = 10;
   6.443 -        timeout.tv_usec = 0;
   6.444 -#ifdef DEBUG_AUDIO
   6.445 -        fprintf(stderr, "Waiting for audio to get ready\n");
   6.446 -#endif
   6.447 -        if (select(audio_fd + 1, NULL, &fdset, NULL, &timeout) <= 0) {
   6.448 -            const char *message =
   6.449 -#ifdef AUDIO_OSPACE_HACK
   6.450 -                "Audio timeout - buggy audio driver? (trying ospace)";
   6.451 -#else
   6.452 -                "Audio timeout - buggy audio driver? (disabled)";
   6.453 -#endif
   6.454 -            /* In general we should never print to the screen,
   6.455 -               but in this case we have no other way of letting
   6.456 -               the user know what happened.
   6.457 -             */
   6.458 -            fprintf(stderr, "SDL: %s\n", message);
   6.459 -#ifdef AUDIO_OSPACE_HACK
   6.460 -            /* We may be able to use GET_OSPACE trick */
   6.461 -            frame_ticks = (float) (this->spec.samples * 1000) /
   6.462 -                this->spec.freq;
   6.463 -            next_frame = SDL_GetTicks() + frame_ticks;
   6.464 -#else
   6.465 -            this->enabled = 0;
   6.466 -            /* Don't try to close - may hang */
   6.467 -            audio_fd = -1;
   6.468 -#ifdef DEBUG_AUDIO
   6.469 -            fprintf(stderr, "Done disabling audio\n");
   6.470 -#endif
   6.471 -#endif /* AUDIO_OSPACE_HACK */
   6.472 -        }
   6.473 -#ifdef DEBUG_AUDIO
   6.474 -        fprintf(stderr, "Ready!\n");
   6.475 -#endif
   6.476 -    }
   6.477 -}
   6.478 -
   6.479 -static void
   6.480 -DMA_PlayDevice(_THIS)
   6.481 -{
   6.482 -    /* If timer synchronization is enabled, set the next write frame */
   6.483 -    if (frame_ticks) {
   6.484 -        next_frame += frame_ticks;
   6.485 -    }
   6.486 -    return;
   6.487 -}
   6.488 -
   6.489 -static Uint8 *
   6.490 -DMA_GetDeviceBuf(_THIS)
   6.491 -{
   6.492 -    count_info info;
   6.493 -    int playing;
   6.494 -    int filling;
   6.495 -
   6.496 -    /* Get number of blocks, looping if we're not using select() */
   6.497 -    do {
   6.498 -        if (ioctl(audio_fd, SNDCTL_DSP_GETOPTR, &info) < 0) {
   6.499 -            /* Uh oh... */
   6.500 -            this->enabled = 0;
   6.501 -            return (NULL);
   6.502 -        }
   6.503 -    } while (frame_ticks && (info.blocks < 1));
   6.504 -#ifdef DEBUG_AUDIO
   6.505 -    if (info.blocks > 1) {
   6.506 -        printf("Warning: audio underflow (%d frags)\n", info.blocks - 1);
   6.507 -    }
   6.508 -#endif
   6.509 -    playing = info.ptr / this->spec.size;
   6.510 -    filling = (playing + 1) % num_buffers;
   6.511 -    return (dma_buf + (filling * this->spec.size));
   6.512 -}
   6.513 -
   6.514 -
   6.515 -static int
   6.516 -DMA_Init(SDL_AudioDriverImpl * impl)
   6.517 -{
   6.518 -    /* Set the function pointers */
   6.519 -    impl->DetectDevices = DMA_DetectDevices;
   6.520 -    impl->GetDeviceName = DMA_GetDeviceName;
   6.521 -    impl->OpenDevice = DMA_OpenDevice;
   6.522 -    impl->WaitDevice = DMA_WaitDevice;
   6.523 -    impl->PlayDevice = DMA_PlayDevice;
   6.524 -    impl->GetDeviceBuf = DMA_GetDeviceBuf;
   6.525 -    impl->CloseDevice = DMA_CloseDevice;
   6.526 -    impl->Deinitialize = DMA_Deinitialize;
   6.527 -
   6.528 -    build_device_lists();
   6.529 -
   6.530 -    return 1;   /* this audio target is available. */
   6.531 -}
   6.532 -
   6.533 -AudioBootStrap DMA_bootstrap = {
   6.534 -    DMA_DRIVER_NAME, "OSS /dev/dsp DMA audio", DMA_Init, 0
   6.535 -};
   6.536 -
   6.537 -/* vi: set ts=4 sw=4 expandtab: */
     7.1 --- a/src/audio/dma/SDL_dmaaudio.h	Sat Jul 23 00:22:19 2011 -0700
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,62 +0,0 @@
     7.4 -/*
     7.5 -  Simple DirectMedia Layer
     7.6 -  Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
     7.7 -
     7.8 -  This software is provided 'as-is', without any express or implied
     7.9 -  warranty.  In no event will the authors be held liable for any damages
    7.10 -  arising from the use of this software.
    7.11 -
    7.12 -  Permission is granted to anyone to use this software for any purpose,
    7.13 -  including commercial applications, and to alter it and redistribute it
    7.14 -  freely, subject to the following restrictions:
    7.15 -
    7.16 -  1. The origin of this software must not be misrepresented; you must not
    7.17 -     claim that you wrote the original software. If you use this software
    7.18 -     in a product, an acknowledgment in the product documentation would be
    7.19 -     appreciated but is not required.
    7.20 -  2. Altered source versions must be plainly marked as such, and must not be
    7.21 -     misrepresented as being the original software.
    7.22 -  3. This notice may not be removed or altered from any source distribution.
    7.23 -*/
    7.24 -#include "SDL_config.h"
    7.25 -
    7.26 -#ifndef _SDL_dmaaudio_h
    7.27 -#define _SDL_dmaaudio_h
    7.28 -
    7.29 -#include "../SDL_sysaudio.h"
    7.30 -
    7.31 -/* Hidden "this" pointer for the audio functions */
    7.32 -#define _THIS	SDL_AudioDevice *this
    7.33 -
    7.34 -struct SDL_PrivateAudioData
    7.35 -{
    7.36 -    /* The file descriptor for the audio device */
    7.37 -    int audio_fd;
    7.38 -
    7.39 -    /* The parent process id, to detect when application quits */
    7.40 -    pid_t parent;
    7.41 -
    7.42 -    /* Raw mixing buffer */
    7.43 -    Uint8 *dma_buf;
    7.44 -    int dma_len;
    7.45 -    int num_buffers;
    7.46 -
    7.47 -    /* Support for audio timing using a timer, in addition to select() */
    7.48 -    float frame_ticks;
    7.49 -    float next_frame;
    7.50 -};
    7.51 -#define FUDGE_TICKS	10      /* The scheduler overhead ticks per frame */
    7.52 -
    7.53 -/* Old variable names */
    7.54 -/* !!! FIXME: remove these. */
    7.55 -#define audio_fd		(this->hidden->audio_fd)
    7.56 -#define parent			(this->hidden->parent)
    7.57 -#define dma_buf			(this->hidden->dma_buf)
    7.58 -#define dma_len			(this->hidden->dma_len)
    7.59 -#define num_buffers		(this->hidden->num_buffers)
    7.60 -#define frame_ticks		(this->hidden->frame_ticks)
    7.61 -#define next_frame		(this->hidden->next_frame)
    7.62 -
    7.63 -#endif /* _SDL_dmaaudio_h */
    7.64 -
    7.65 -/* vi: set ts=4 sw=4 expandtab: */
     8.1 --- a/src/audio/paudio/SDL_paudio.c	Sat Jul 23 00:22:19 2011 -0700
     8.2 +++ b/src/audio/paudio/SDL_paudio.c	Sun Jul 24 03:37:13 2011 -0700
     8.3 @@ -429,7 +429,7 @@
     8.4      /*
     8.5       * The AIX paud device init can't modify the values of the audio_init
     8.6       * structure that we pass to it. So we don't need any recalculation
     8.7 -     * of this stuff and no reinit call as in linux dsp and dma code.
     8.8 +     * of this stuff and no reinit call as in linux dsp code.
     8.9       *
    8.10       * /dev/paud supports all of the encoding formats, so we don't need
    8.11       * to do anything like reopening the device, either.