More 1.3 audio work...moved dsp and dma drivers over to new model. Untested! SDL-ryan-multiple-audio-device
authorRyan C. Gordon <icculus@icculus.org>
Wed, 04 Oct 2006 06:00:10 +0000
branchSDL-ryan-multiple-audio-device
changeset 3795589bc3d060cd
parent 3794 db24e43972ac
child 3796 b19680c84cdf
More 1.3 audio work...moved dsp and dma drivers over to new model. Untested!
src/audio/SDL_audio.c
src/audio/SDL_sysaudio.h
src/audio/dma/SDL_dmaaudio.c
src/audio/dsp/SDL_dspaudio.c
src/audio/dsp/SDL_dspaudio.h
src/audio/macosx/SDL_coreaudio.c
test/testaudioinfo.c
     1.1 --- a/src/audio/SDL_audio.c	Tue Oct 03 23:45:36 2006 +0000
     1.2 +++ b/src/audio/SDL_audio.c	Wed Oct 04 06:00:10 2006 +0000
     1.3 @@ -132,6 +132,16 @@
     1.4  }
     1.5  
     1.6  
     1.7 +/* stubs for audio drivers that don't need a specific entry point... */
     1.8 +/* !!! FIXME: fill in more of these. */
     1.9 +
    1.10 +static void SDL_DeinitializeAudio_Default(void)
    1.11 +{
    1.12 +    /* no-op. */
    1.13 +}
    1.14 +
    1.15 +
    1.16 +
    1.17  /* The general mixing thread function */
    1.18  int SDLCALL
    1.19  SDL_RunAudio(void *devicep)
    1.20 @@ -443,6 +453,10 @@
    1.21          current_audio.impl.UnlockDevice = SDL_UnlockDevice_Default;
    1.22      }
    1.23  
    1.24 +    if (!current_audio.impl.Deinitialize) {
    1.25 +        current_audio.impl.Deinitialize = SDL_DeinitializeAudio_Default;
    1.26 +    }
    1.27 +
    1.28      return (0);
    1.29  }
    1.30  
     2.1 --- a/src/audio/SDL_sysaudio.h	Tue Oct 03 23:45:36 2006 +0000
     2.2 +++ b/src/audio/SDL_sysaudio.h	Wed Oct 04 06:00:10 2006 +0000
     2.3 @@ -47,6 +47,7 @@
     2.4      void (*Deinitialize) (void);
     2.5  } SDL_AudioDriverImpl;
     2.6  
     2.7 +
     2.8  typedef struct SDL_AudioDriver
     2.9  {
    2.10      /* * * */
     3.1 --- a/src/audio/dma/SDL_dmaaudio.c	Tue Oct 03 23:45:36 2006 +0000
     3.2 +++ b/src/audio/dma/SDL_dmaaudio.c	Wed Oct 04 06:00:10 2006 +0000
     3.3 @@ -21,6 +21,8 @@
     3.4  */
     3.5  #include "SDL_config.h"
     3.6  
     3.7 +/* !!! FIXME: merge this driver with "dsp". */
     3.8 +
     3.9  /* Allow access to a raw mixing buffer */
    3.10  
    3.11  #include <stdio.h>
    3.12 @@ -60,17 +62,23 @@
    3.13  #define OPEN_FLAGS	(O_RDWR|O_NONBLOCK)
    3.14  
    3.15  /* Audio driver functions */
    3.16 -static int DMA_OpenAudio(_THIS, SDL_AudioSpec * spec);
    3.17 -static void DMA_WaitAudio(_THIS);
    3.18 -static void DMA_PlayAudio(_THIS);
    3.19 -static Uint8 *DMA_GetAudioBuf(_THIS);
    3.20 -static void DMA_CloseAudio(_THIS);
    3.21 +static int DMA_DetectDevices(int iscapture);
    3.22 +static const char *DMA_GetDeviceName(int index, int iscapture);
    3.23 +static int DMA_OpenDevice(_THIS, const char *devname, int iscapture);
    3.24 +static void DMA_WaitDevice(_THIS);
    3.25 +static void DMA_PlayDevice(_THIS);
    3.26 +static Uint8 *DMA_GetDeviceBuf(_THIS);
    3.27 +static void DMA_CloseDevice(_THIS);
    3.28  
    3.29  /* Audio driver bootstrap functions */
    3.30  
    3.31  static int
    3.32 -Audio_Available(void)
    3.33 +DMA_Available(void)
    3.34  {
    3.35 +    /*
    3.36 +     * !!! FIXME: maybe change this to always available, and move this to
    3.37 +     * !!! FIXME:  to device enumeration and opening?
    3.38 +     */
    3.39      int available;
    3.40      int fd;
    3.41  
    3.42 @@ -91,55 +99,276 @@
    3.43      return (available);
    3.44  }
    3.45  
    3.46 -static void
    3.47 -Audio_DeleteDevice(SDL_AudioDevice * device)
    3.48 -{
    3.49 -    SDL_free(device->hidden);
    3.50 -    SDL_free(device);
    3.51 -}
    3.52 -
    3.53 -static SDL_AudioDevice *
    3.54 -Audio_CreateDevice(int devindex)
    3.55 -{
    3.56 -    SDL_AudioDevice *this;
    3.57  
    3.58 -    /* Initialize all variables that we clean on shutdown */
    3.59 -    this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice));
    3.60 -    if (this) {
    3.61 -        SDL_memset(this, 0, (sizeof *this));
    3.62 -        this->hidden = (struct SDL_PrivateAudioData *)
    3.63 -            SDL_malloc((sizeof *this->hidden));
    3.64 -    }
    3.65 -    if ((this == NULL) || (this->hidden == NULL)) {
    3.66 -        SDL_OutOfMemory();
    3.67 -        if (this) {
    3.68 -            SDL_free(this);
    3.69 -        }
    3.70 -        return (0);
    3.71 -    }
    3.72 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
    3.73 -    audio_fd = -1;
    3.74 +static int
    3.75 +DMA_Init(SDL_AudioDriverImpl *impl)
    3.76 +{
    3.77 +    /* Set the function pointers */
    3.78 +    impl->DetectDevices = DMA_DetectDevices;
    3.79 +    impl->GetDeviceName = DMA_GetDeviceName;
    3.80 +    impl->OpenDevice = DMA_OpenDevice;
    3.81 +    impl->WaitDevice = DMA_WaitDevice;
    3.82 +    impl->PlayDevice = DMA_PlayDevice;
    3.83 +    impl->GetDeviceBuf = DMA_GetDeviceBuf;
    3.84 +    impl->CloseDevice = DMA_CloseDevice;
    3.85  
    3.86 -    /* Set the function pointers */
    3.87 -    this->OpenAudio = DMA_OpenAudio;
    3.88 -    this->WaitAudio = DMA_WaitAudio;
    3.89 -    this->PlayAudio = DMA_PlayAudio;
    3.90 -    this->GetAudioBuf = DMA_GetAudioBuf;
    3.91 -    this->CloseAudio = DMA_CloseAudio;
    3.92 -
    3.93 -    this->free = Audio_DeleteDevice;
    3.94 -
    3.95 -    return this;
    3.96 +    return 1;
    3.97  }
    3.98  
    3.99  AudioBootStrap DMA_bootstrap = {
   3.100      DMA_DRIVER_NAME, "OSS /dev/dsp DMA audio",
   3.101 -    Audio_Available, Audio_CreateDevice
   3.102 +    DMA_Available, DMA_Init
   3.103  };
   3.104  
   3.105 +
   3.106 +static int
   3.107 +DMA_DetectDevices(int iscapture)
   3.108 +{
   3.109 +    return -1;  /* !!! FIXME */
   3.110 +}
   3.111 +
   3.112 +
   3.113 +static const char *
   3.114 +DMA_GetDeviceName(int index, int iscapture)
   3.115 +{
   3.116 +    SDL_SetError("No such device");  /* !!! FIXME */
   3.117 +    return NULL;
   3.118 +}
   3.119 +
   3.120 +
   3.121 +static int
   3.122 +DMA_ReopenAudio(_THIS, const char *audiodev, int format, int stereo)
   3.123 +{
   3.124 +    int frag_spec;
   3.125 +    int value;
   3.126 +
   3.127 +    /* Close and then reopen the audio device */
   3.128 +    close(audio_fd);
   3.129 +    audio_fd = open(audiodev, O_RDWR, 0);
   3.130 +    if (audio_fd < 0) {
   3.131 +        SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno));
   3.132 +        return (-1);
   3.133 +    }
   3.134 +
   3.135 +    /* Calculate the final parameters for this audio specification */
   3.136 +    SDL_CalculateAudioSpec(&this->spec);
   3.137 +
   3.138 +    /* Determine the power of two of the fragment size */
   3.139 +    for (frag_spec = 0; (0x01 << frag_spec) < this->spec.size; ++frag_spec);
   3.140 +    if ((0x01 << frag_spec) != this->spec.size) {
   3.141 +        SDL_SetError("Fragment size must be a power of two");
   3.142 +        return (-1);
   3.143 +    }
   3.144 +
   3.145 +    /* Set the audio buffering parameters */
   3.146 +    if (ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_spec) < 0) {
   3.147 +        SDL_SetError("Couldn't set audio fragment spec");
   3.148 +        return (-1);
   3.149 +    }
   3.150 +
   3.151 +    /* Set the audio format */
   3.152 +    value = format;
   3.153 +    if ((ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || (value != format)) {
   3.154 +        SDL_SetError("Couldn't set audio format");
   3.155 +        return (-1);
   3.156 +    }
   3.157 +
   3.158 +    /* Set mono or stereo audio */
   3.159 +    value = (this->spec.channels > 1);
   3.160 +    if ((ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo) < 0) ||
   3.161 +        (value != stereo)) {
   3.162 +        SDL_SetError("Couldn't set audio channels");
   3.163 +        return (-1);
   3.164 +    }
   3.165 +
   3.166 +    /* Set the DSP frequency */
   3.167 +    value = this->spec.freq;
   3.168 +    if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &value) < 0) {
   3.169 +        SDL_SetError("Couldn't set audio frequency");
   3.170 +        return (-1);
   3.171 +    }
   3.172 +    this->spec.freq = value;
   3.173 +
   3.174 +    /* We successfully re-opened the audio */
   3.175 +    return (0);
   3.176 +}
   3.177 +
   3.178 +
   3.179 +
   3.180 +static int
   3.181 +open_device_internal(_THIS, const char *devname, int iscapture)
   3.182 +{
   3.183 +    char audiodev[1024];
   3.184 +    int format;
   3.185 +    int stereo;
   3.186 +    int value;
   3.187 +    SDL_AudioFormat test_format;
   3.188 +    struct audio_buf_info info;
   3.189 +
   3.190 +    /* Initialize all variables that we clean on shutdown */
   3.191 +    this->hidden = (struct SDL_PrivateAudioData *)
   3.192 +                        SDL_malloc((sizeof *this->hidden));
   3.193 +    if (this->hidden == NULL) {
   3.194 +        SDL_OutOfMemory();
   3.195 +        return 0;
   3.196 +    }
   3.197 +    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   3.198 +
   3.199 +    /* !!! FIXME: handle devname */
   3.200 +    /* !!! FIXME: handle iscapture */
   3.201 +
   3.202 +    /* Open the audio device */
   3.203 +    audio_fd = SDL_OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 0);
   3.204 +    if (audio_fd < 0) {
   3.205 +        SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno));
   3.206 +        return 0;
   3.207 +    }
   3.208 +    dma_buf = NULL;
   3.209 +    ioctl(audio_fd, SNDCTL_DSP_RESET, 0);
   3.210 +
   3.211 +    /* Get a list of supported hardware formats */
   3.212 +    if (ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0) {
   3.213 +        SDL_SetError("Couldn't get audio format list");
   3.214 +        return 0;
   3.215 +    }
   3.216 +
   3.217 +    /* Try for a closest match on audio format */
   3.218 +    format = 0;
   3.219 +    for (test_format = SDL_FirstAudioFormat(this->spec.format);
   3.220 +         !format && test_format;) {
   3.221 +#ifdef DEBUG_AUDIO
   3.222 +        fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
   3.223 +#endif
   3.224 +        switch (test_format) {
   3.225 +        case AUDIO_U8:
   3.226 +            if (value & AFMT_U8) {
   3.227 +                format = AFMT_U8;
   3.228 +            }
   3.229 +            break;
   3.230 +        case AUDIO_S8:
   3.231 +            if (value & AFMT_S8) {
   3.232 +                format = AFMT_S8;
   3.233 +            }
   3.234 +            break;
   3.235 +        case AUDIO_S16LSB:
   3.236 +            if (value & AFMT_S16_LE) {
   3.237 +                format = AFMT_S16_LE;
   3.238 +            }
   3.239 +            break;
   3.240 +        case AUDIO_S16MSB:
   3.241 +            if (value & AFMT_S16_BE) {
   3.242 +                format = AFMT_S16_BE;
   3.243 +            }
   3.244 +            break;
   3.245 +        case AUDIO_U16LSB:
   3.246 +            if (value & AFMT_U16_LE) {
   3.247 +                format = AFMT_U16_LE;
   3.248 +            }
   3.249 +            break;
   3.250 +        case AUDIO_U16MSB:
   3.251 +            if (value & AFMT_U16_BE) {
   3.252 +                format = AFMT_U16_BE;
   3.253 +            }
   3.254 +            break;
   3.255 +        default:
   3.256 +            format = 0;
   3.257 +            break;
   3.258 +        }
   3.259 +        if (!format) {
   3.260 +            test_format = SDL_NextAudioFormat();
   3.261 +        }
   3.262 +    }
   3.263 +    if (format == 0) {
   3.264 +        SDL_SetError("Couldn't find any hardware audio formats");
   3.265 +        return 0;
   3.266 +    }
   3.267 +    this->spec.format = test_format;
   3.268 +
   3.269 +    /* Set the audio format */
   3.270 +    value = format;
   3.271 +    if ((ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || (value != format)) {
   3.272 +        SDL_SetError("Couldn't set audio format");
   3.273 +        return 0;
   3.274 +    }
   3.275 +
   3.276 +    /* Set mono or stereo audio (currently only two channels supported) */
   3.277 +    stereo = (this->spec.channels > 1);
   3.278 +    ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo);
   3.279 +    if (stereo) {
   3.280 +        this->spec.channels = 2;
   3.281 +    } else {
   3.282 +        this->spec.channels = 1;
   3.283 +    }
   3.284 +
   3.285 +    /* Because some drivers don't allow setting the buffer size
   3.286 +       after setting the format, we must re-open the audio device
   3.287 +       once we know what format and channels are supported
   3.288 +     */
   3.289 +    if (DMA_ReopenAudio(this, audiodev, format, stereo) < 0) {
   3.290 +        /* Error is set by DMA_ReopenAudio() */
   3.291 +        return 0;
   3.292 +    }
   3.293 +
   3.294 +    /* Memory map the audio buffer */
   3.295 +    if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info) < 0) {
   3.296 +        SDL_SetError("Couldn't get OSPACE parameters");
   3.297 +        return 0;
   3.298 +    }
   3.299 +    this->spec.size = info.fragsize;
   3.300 +    this->spec.samples = this->spec.size / ((this->spec.format & 0xFF) / 8);
   3.301 +    this->spec.samples /= this->spec.channels;
   3.302 +    num_buffers = info.fragstotal;
   3.303 +    dma_len = num_buffers * this->spec.size;
   3.304 +    dma_buf = (Uint8 *) mmap(NULL, dma_len, PROT_WRITE, MAP_SHARED,
   3.305 +                             audio_fd, 0);
   3.306 +    if (dma_buf == MAP_FAILED) {
   3.307 +        SDL_SetError("DMA memory map failed");
   3.308 +        dma_buf = NULL;
   3.309 +        return 0;
   3.310 +    }
   3.311 +    SDL_memset(dma_buf, this->spec.silence, dma_len);
   3.312 +
   3.313 +    /* Check to see if we need to use select() workaround */
   3.314 +    {
   3.315 +        char *workaround;
   3.316 +        workaround = SDL_getenv("SDL_DSP_NOSELECT");
   3.317 +        if (workaround) {
   3.318 +            frame_ticks = (float) (this->spec.samples*1000) / this->spec.freq;
   3.319 +            next_frame = SDL_GetTicks() + frame_ticks;
   3.320 +        }
   3.321 +    }
   3.322 +
   3.323 +    /* Trigger audio playback */
   3.324 +    value = 0;
   3.325 +    ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &value);
   3.326 +    value = PCM_ENABLE_OUTPUT;
   3.327 +    if (ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &value) < 0) {
   3.328 +        SDL_SetError("Couldn't trigger audio output");
   3.329 +        return 0;
   3.330 +    }
   3.331 +
   3.332 +    /* Get the parent process id (we're the parent of the audio thread) */
   3.333 +    parent = getpid();
   3.334 +
   3.335 +    /* We're ready to rock and roll. :-) */
   3.336 +    return 1;
   3.337 +}
   3.338 +
   3.339 +static int
   3.340 +DMA_OpenDevice(_THIS, const char *devname, int iscapture)
   3.341 +{
   3.342 +    int retval = open_device_internal(this, devname, iscapture);
   3.343 +    if (!retval)
   3.344 +        DMA_CloseDevice(this);  /* !!! FIXME: do this at higher level. */
   3.345 +    return retval;
   3.346 +}
   3.347 +
   3.348 +
   3.349 +
   3.350 +
   3.351  /* This function waits until it is possible to write a full sound buffer */
   3.352  static void
   3.353 -DMA_WaitAudio(_THIS)
   3.354 +DMA_WaitDevice(_THIS)
   3.355  {
   3.356      fd_set fdset;
   3.357  
   3.358 @@ -189,8 +418,8 @@
   3.359              fprintf(stderr, "SDL: %s\n", message);
   3.360  #ifdef AUDIO_OSPACE_HACK
   3.361              /* We may be able to use GET_OSPACE trick */
   3.362 -            frame_ticks = (float) (this->spec->samples * 1000) /
   3.363 -                this->spec->freq;
   3.364 +            frame_ticks = (float) (this->spec.samples * 1000) /
   3.365 +                this->spec.freq;
   3.366              next_frame = SDL_GetTicks() + frame_ticks;
   3.367  #else
   3.368              this->enabled = 0;
   3.369 @@ -208,7 +437,7 @@
   3.370  }
   3.371  
   3.372  static void
   3.373 -DMA_PlayAudio(_THIS)
   3.374 +DMA_PlayDevice(_THIS)
   3.375  {
   3.376      /* If timer synchronization is enabled, set the next write frame */
   3.377      if (frame_ticks) {
   3.378 @@ -218,7 +447,7 @@
   3.379  }
   3.380  
   3.381  static Uint8 *
   3.382 -DMA_GetAudioBuf(_THIS)
   3.383 +DMA_GetDeviceBuf(_THIS)
   3.384  {
   3.385      count_info info;
   3.386      int playing;
   3.387 @@ -244,224 +473,20 @@
   3.388  }
   3.389  
   3.390  static void
   3.391 -DMA_CloseAudio(_THIS)
   3.392 +DMA_CloseDevice(_THIS)
   3.393  {
   3.394 -    if (dma_buf != NULL) {
   3.395 -        munmap(dma_buf, dma_len);
   3.396 -        dma_buf = NULL;
   3.397 -    }
   3.398 -    if (audio_fd >= 0) {
   3.399 -        close(audio_fd);
   3.400 -        audio_fd = -1;
   3.401 +    if (this->hidden != NULL) {
   3.402 +        if (dma_buf != NULL) {
   3.403 +            munmap(dma_buf, dma_len);
   3.404 +            dma_buf = NULL;
   3.405 +        }
   3.406 +        if (audio_fd >= 0) {
   3.407 +            close(audio_fd);
   3.408 +            audio_fd = -1;
   3.409 +        }
   3.410 +        SDL_free(this->hidden);
   3.411 +        this->hidden = NULL;
   3.412      }
   3.413  }
   3.414  
   3.415 -static int
   3.416 -DMA_ReopenAudio(_THIS, const char *audiodev, int format, int stereo,
   3.417 -                SDL_AudioSpec * spec)
   3.418 -{
   3.419 -    int frag_spec;
   3.420 -    int value;
   3.421 -
   3.422 -    /* Close and then reopen the audio device */
   3.423 -    close(audio_fd);
   3.424 -    audio_fd = open(audiodev, O_RDWR, 0);
   3.425 -    if (audio_fd < 0) {
   3.426 -        SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno));
   3.427 -        return (-1);
   3.428 -    }
   3.429 -
   3.430 -    /* Calculate the final parameters for this audio specification */
   3.431 -    SDL_CalculateAudioSpec(spec);
   3.432 -
   3.433 -    /* Determine the power of two of the fragment size */
   3.434 -    for (frag_spec = 0; (0x01 << frag_spec) < spec->size; ++frag_spec);
   3.435 -    if ((0x01 << frag_spec) != spec->size) {
   3.436 -        SDL_SetError("Fragment size must be a power of two");
   3.437 -        return (-1);
   3.438 -    }
   3.439 -
   3.440 -    /* Set the audio buffering parameters */
   3.441 -    if (ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_spec) < 0) {
   3.442 -        SDL_SetError("Couldn't set audio fragment spec");
   3.443 -        return (-1);
   3.444 -    }
   3.445 -
   3.446 -    /* Set the audio format */
   3.447 -    value = format;
   3.448 -    if ((ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || (value != format)) {
   3.449 -        SDL_SetError("Couldn't set audio format");
   3.450 -        return (-1);
   3.451 -    }
   3.452 -
   3.453 -    /* Set mono or stereo audio */
   3.454 -    value = (spec->channels > 1);
   3.455 -    if ((ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo) < 0) ||
   3.456 -        (value != stereo)) {
   3.457 -        SDL_SetError("Couldn't set audio channels");
   3.458 -        return (-1);
   3.459 -    }
   3.460 -
   3.461 -    /* Set the DSP frequency */
   3.462 -    value = spec->freq;
   3.463 -    if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &value) < 0) {
   3.464 -        SDL_SetError("Couldn't set audio frequency");
   3.465 -        return (-1);
   3.466 -    }
   3.467 -    spec->freq = value;
   3.468 -
   3.469 -    /* We successfully re-opened the audio */
   3.470 -    return (0);
   3.471 -}
   3.472 -
   3.473 -static int
   3.474 -DMA_OpenAudio(_THIS, SDL_AudioSpec * spec)
   3.475 -{
   3.476 -    char audiodev[1024];
   3.477 -    int format;
   3.478 -    int stereo;
   3.479 -    int value;
   3.480 -    SDL_AudioFormat test_format;
   3.481 -    struct audio_buf_info info;
   3.482 -
   3.483 -    /* Reset the timer synchronization flag */
   3.484 -    frame_ticks = 0.0;
   3.485 -
   3.486 -    /* Open the audio device */
   3.487 -    audio_fd = SDL_OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 0);
   3.488 -    if (audio_fd < 0) {
   3.489 -        SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno));
   3.490 -        return (-1);
   3.491 -    }
   3.492 -    dma_buf = NULL;
   3.493 -    ioctl(audio_fd, SNDCTL_DSP_RESET, 0);
   3.494 -
   3.495 -    /* Get a list of supported hardware formats */
   3.496 -    if (ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0) {
   3.497 -        SDL_SetError("Couldn't get audio format list");
   3.498 -        return (-1);
   3.499 -    }
   3.500 -
   3.501 -    /* Try for a closest match on audio format */
   3.502 -    format = 0;
   3.503 -    for (test_format = SDL_FirstAudioFormat(spec->format);
   3.504 -         !format && test_format;) {
   3.505 -#ifdef DEBUG_AUDIO
   3.506 -        fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
   3.507 -#endif
   3.508 -        switch (test_format) {
   3.509 -        case AUDIO_U8:
   3.510 -            if (value & AFMT_U8) {
   3.511 -                format = AFMT_U8;
   3.512 -            }
   3.513 -            break;
   3.514 -        case AUDIO_S8:
   3.515 -            if (value & AFMT_S8) {
   3.516 -                format = AFMT_S8;
   3.517 -            }
   3.518 -            break;
   3.519 -        case AUDIO_S16LSB:
   3.520 -            if (value & AFMT_S16_LE) {
   3.521 -                format = AFMT_S16_LE;
   3.522 -            }
   3.523 -            break;
   3.524 -        case AUDIO_S16MSB:
   3.525 -            if (value & AFMT_S16_BE) {
   3.526 -                format = AFMT_S16_BE;
   3.527 -            }
   3.528 -            break;
   3.529 -        case AUDIO_U16LSB:
   3.530 -            if (value & AFMT_U16_LE) {
   3.531 -                format = AFMT_U16_LE;
   3.532 -            }
   3.533 -            break;
   3.534 -        case AUDIO_U16MSB:
   3.535 -            if (value & AFMT_U16_BE) {
   3.536 -                format = AFMT_U16_BE;
   3.537 -            }
   3.538 -            break;
   3.539 -        default:
   3.540 -            format = 0;
   3.541 -            break;
   3.542 -        }
   3.543 -        if (!format) {
   3.544 -            test_format = SDL_NextAudioFormat();
   3.545 -        }
   3.546 -    }
   3.547 -    if (format == 0) {
   3.548 -        SDL_SetError("Couldn't find any hardware audio formats");
   3.549 -        return (-1);
   3.550 -    }
   3.551 -    spec->format = test_format;
   3.552 -
   3.553 -    /* Set the audio format */
   3.554 -    value = format;
   3.555 -    if ((ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || (value != format)) {
   3.556 -        SDL_SetError("Couldn't set audio format");
   3.557 -        return (-1);
   3.558 -    }
   3.559 -
   3.560 -    /* Set mono or stereo audio (currently only two channels supported) */
   3.561 -    stereo = (spec->channels > 1);
   3.562 -    ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo);
   3.563 -    if (stereo) {
   3.564 -        spec->channels = 2;
   3.565 -    } else {
   3.566 -        spec->channels = 1;
   3.567 -    }
   3.568 -
   3.569 -    /* Because some drivers don't allow setting the buffer size
   3.570 -       after setting the format, we must re-open the audio device
   3.571 -       once we know what format and channels are supported
   3.572 -     */
   3.573 -    if (DMA_ReopenAudio(this, audiodev, format, stereo, spec) < 0) {
   3.574 -        /* Error is set by DMA_ReopenAudio() */
   3.575 -        return (-1);
   3.576 -    }
   3.577 -
   3.578 -    /* Memory map the audio buffer */
   3.579 -    if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info) < 0) {
   3.580 -        SDL_SetError("Couldn't get OSPACE parameters");
   3.581 -        return (-1);
   3.582 -    }
   3.583 -    spec->size = info.fragsize;
   3.584 -    spec->samples = spec->size / ((spec->format & 0xFF) / 8);
   3.585 -    spec->samples /= spec->channels;
   3.586 -    num_buffers = info.fragstotal;
   3.587 -    dma_len = num_buffers * spec->size;
   3.588 -    dma_buf = (Uint8 *) mmap(NULL, dma_len, PROT_WRITE, MAP_SHARED,
   3.589 -                             audio_fd, 0);
   3.590 -    if (dma_buf == MAP_FAILED) {
   3.591 -        SDL_SetError("DMA memory map failed");
   3.592 -        dma_buf = NULL;
   3.593 -        return (-1);
   3.594 -    }
   3.595 -    SDL_memset(dma_buf, spec->silence, dma_len);
   3.596 -
   3.597 -    /* Check to see if we need to use select() workaround */
   3.598 -    {
   3.599 -        char *workaround;
   3.600 -        workaround = SDL_getenv("SDL_DSP_NOSELECT");
   3.601 -        if (workaround) {
   3.602 -            frame_ticks = (float) (spec->samples * 1000) / spec->freq;
   3.603 -            next_frame = SDL_GetTicks() + frame_ticks;
   3.604 -        }
   3.605 -    }
   3.606 -
   3.607 -    /* Trigger audio playback */
   3.608 -    value = 0;
   3.609 -    ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &value);
   3.610 -    value = PCM_ENABLE_OUTPUT;
   3.611 -    if (ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &value) < 0) {
   3.612 -        SDL_SetError("Couldn't trigger audio output");
   3.613 -        return (-1);
   3.614 -    }
   3.615 -
   3.616 -    /* Get the parent process id (we're the parent of the audio thread) */
   3.617 -    parent = getpid();
   3.618 -
   3.619 -    /* We're ready to rock and roll. :-) */
   3.620 -    return (0);
   3.621 -}
   3.622 -
   3.623  /* vi: set ts=4 sw=4 expandtab: */
     4.1 --- a/src/audio/dsp/SDL_dspaudio.c	Tue Oct 03 23:45:36 2006 +0000
     4.2 +++ b/src/audio/dsp/SDL_dspaudio.c	Wed Oct 04 06:00:10 2006 +0000
     4.3 @@ -58,22 +58,25 @@
     4.4  #define OPEN_FLAGS	(O_WRONLY|O_NONBLOCK)
     4.5  
     4.6  /* Audio driver functions */
     4.7 -static int DSP_OpenAudio(_THIS, SDL_AudioSpec * spec);
     4.8 -static void DSP_WaitAudio(_THIS);
     4.9 -static void DSP_PlayAudio(_THIS);
    4.10 -static Uint8 *DSP_GetAudioBuf(_THIS);
    4.11 -static void DSP_CloseAudio(_THIS);
    4.12 +static int DSP_DetectDevices(int iscapture);
    4.13 +static const char *DSP_GetDeviceName(int index, int iscapture);
    4.14 +static int DSP_OpenDevice(_THIS, const char *devname, int iscapture);
    4.15 +static void DSP_WaitDevice(_THIS);
    4.16 +static void DSP_PlayDevice(_THIS);
    4.17 +static Uint8 *DSP_GetDeviceBuf(_THIS);
    4.18 +static void DSP_CloseDevice(_THIS);
    4.19  
    4.20  /* Audio driver bootstrap functions */
    4.21  
    4.22  static int
    4.23 -Audio_Available(void)
    4.24 +DSP_Available(void)
    4.25  {
    4.26 -    int fd;
    4.27 -    int available;
    4.28 -
    4.29 -    available = 0;
    4.30 -    fd = SDL_OpenAudioPath(NULL, 0, OPEN_FLAGS, 0);
    4.31 +    /*
    4.32 +     * !!! FIXME: maybe change this to always available, and move this to
    4.33 +     * !!! FIXME:  to device enumeration and opening?
    4.34 +     */
    4.35 +    int fd = SDL_OpenAudioPath(NULL, 0, OPEN_FLAGS, 0);
    4.36 +    int available = 0;
    4.37      if (fd >= 0) {
    4.38          available = 1;
    4.39          close(fd);
    4.40 @@ -81,130 +84,97 @@
    4.41      return (available);
    4.42  }
    4.43  
    4.44 -static void
    4.45 -Audio_DeleteDevice(SDL_AudioDevice * device)
    4.46 +
    4.47 +static int
    4.48 +DSP_Init(SDL_AudioDriverImpl *impl)
    4.49  {
    4.50 -    SDL_free(device->hidden);
    4.51 -    SDL_free(device);
    4.52 +    /* Set the function pointers */
    4.53 +    impl->DetectDevices = DSP_DetectDevices;
    4.54 +    impl->GetDeviceName = DSP_GetDeviceName;
    4.55 +    impl->OpenDevice = DSP_OpenDevice;
    4.56 +    impl->WaitDevice = DSP_WaitDevice;
    4.57 +    impl->PlayDevice = DSP_PlayDevice;
    4.58 +    impl->GetDeviceBuf = DSP_GetDeviceBuf;
    4.59 +    impl->CloseDevice = DSP_CloseDevice;
    4.60 +
    4.61 +    return 1;
    4.62  }
    4.63  
    4.64 -static SDL_AudioDevice *
    4.65 -Audio_CreateDevice(int devindex)
    4.66 -{
    4.67 -    SDL_AudioDevice *this;
    4.68 -
    4.69 -    /* Initialize all variables that we clean on shutdown */
    4.70 -    this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice));
    4.71 -    if (this) {
    4.72 -        SDL_memset(this, 0, (sizeof *this));
    4.73 -        this->hidden = (struct SDL_PrivateAudioData *)
    4.74 -            SDL_malloc((sizeof *this->hidden));
    4.75 -    }
    4.76 -    if ((this == NULL) || (this->hidden == NULL)) {
    4.77 -        SDL_OutOfMemory();
    4.78 -        if (this) {
    4.79 -            SDL_free(this);
    4.80 -        }
    4.81 -        return (0);
    4.82 -    }
    4.83 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
    4.84 -    audio_fd = -1;
    4.85 -
    4.86 -    /* Set the function pointers */
    4.87 -    this->OpenAudio = DSP_OpenAudio;
    4.88 -    this->WaitAudio = DSP_WaitAudio;
    4.89 -    this->PlayAudio = DSP_PlayAudio;
    4.90 -    this->GetAudioBuf = DSP_GetAudioBuf;
    4.91 -    this->CloseAudio = DSP_CloseAudio;
    4.92 -
    4.93 -    this->free = Audio_DeleteDevice;
    4.94 -
    4.95 -    return this;
    4.96 -}
    4.97  
    4.98  AudioBootStrap DSP_bootstrap = {
    4.99      DSP_DRIVER_NAME, "OSS /dev/dsp standard audio",
   4.100 -    Audio_Available, Audio_CreateDevice
   4.101 +    DSP_Available, DSP_Init
   4.102  };
   4.103  
   4.104 -/* This function waits until it is possible to write a full sound buffer */
   4.105 -static void
   4.106 -DSP_WaitAudio(_THIS)
   4.107 +
   4.108 +static int
   4.109 +DSP_DetectDevices(int iscapture)
   4.110  {
   4.111 -    /* Not needed at all since OSS handles waiting automagically */
   4.112 -}
   4.113 -
   4.114 -static void
   4.115 -DSP_PlayAudio(_THIS)
   4.116 -{
   4.117 -    if (write(audio_fd, mixbuf, mixlen) == -1) {
   4.118 -        perror("Audio write");
   4.119 -        this->enabled = 0;
   4.120 -    }
   4.121 -#ifdef DEBUG_AUDIO
   4.122 -    fprintf(stderr, "Wrote %d bytes of audio data\n", mixlen);
   4.123 -#endif
   4.124 +    return -1;  /* !!! FIXME */
   4.125  }
   4.126  
   4.127 -static Uint8 *
   4.128 -DSP_GetAudioBuf(_THIS)
   4.129 +
   4.130 +static const char *
   4.131 +DSP_GetDeviceName(int index, int iscapture)
   4.132  {
   4.133 -    return (mixbuf);
   4.134 +    SDL_SetError("No such device");  /* !!! FIXME */
   4.135 +    return NULL;
   4.136  }
   4.137  
   4.138 -static void
   4.139 -DSP_CloseAudio(_THIS)
   4.140 -{
   4.141 -    if (mixbuf != NULL) {
   4.142 -        SDL_FreeAudioMem(mixbuf);
   4.143 -        mixbuf = NULL;
   4.144 -    }
   4.145 -    if (audio_fd >= 0) {
   4.146 -        close(audio_fd);
   4.147 -        audio_fd = -1;
   4.148 -    }
   4.149 -}
   4.150  
   4.151  static int
   4.152 -DSP_OpenAudio(_THIS, SDL_AudioSpec * spec)
   4.153 +DSP_OpenDevice(_THIS, const char *devname, int iscapture)
   4.154  {
   4.155 -    char audiodev[1024];
   4.156 +    char dev[1024];
   4.157      int format;
   4.158      int value;
   4.159      int frag_spec;
   4.160      SDL_AudioFormat test_format;
   4.161  
   4.162 +    /* Initialize all variables that we clean on shutdown */
   4.163 +    this->hidden = (struct SDL_PrivateAudioData *)
   4.164 +                        SDL_malloc((sizeof *this->hidden));
   4.165 +    if (this->hidden == NULL) {
   4.166 +        SDL_OutOfMemory();
   4.167 +        return 0;
   4.168 +    }
   4.169 +    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   4.170 +    this->hidden->audio_fd = -1;
   4.171 +
   4.172 +    /* !!! FIXME: handle devname */
   4.173 +    /* !!! FIXME: handle iscapture */
   4.174 +
   4.175      /* Open the audio device */
   4.176 -    audio_fd = SDL_OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 0);
   4.177 -    if (audio_fd < 0) {
   4.178 -        SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno));
   4.179 -        return (-1);
   4.180 +    this->hidden->audio_fd = SDL_OpenAudioPath(dev, sizeof(dev), OPEN_FLAGS, 0);
   4.181 +    if (this->hidden->audio_fd < 0) {
   4.182 +        SDL_SetError("Couldn't open %s: %s", dev, strerror(errno));
   4.183 +        return 0;
   4.184      }
   4.185 -    mixbuf = NULL;
   4.186 +    this->hidden->mixbuf = NULL;
   4.187  
   4.188      /* Make the file descriptor use blocking writes with fcntl() */
   4.189      {
   4.190          long flags;
   4.191 -        flags = fcntl(audio_fd, F_GETFL);
   4.192 +        flags = fcntl(this->hidden->audio_fd, F_GETFL);
   4.193          flags &= ~O_NONBLOCK;
   4.194 -        if (fcntl(audio_fd, F_SETFL, flags) < 0) {
   4.195 +        if (fcntl(this->hidden->audio_fd, F_SETFL, flags) < 0) {
   4.196              SDL_SetError("Couldn't set audio blocking mode");
   4.197 -            DSP_CloseAudio(this);
   4.198 -            return (-1);
   4.199 +            DSP_CloseDevice(this);
   4.200 +            return 0;
   4.201          }
   4.202      }
   4.203  
   4.204      /* Get a list of supported hardware formats */
   4.205 -    if (ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0) {
   4.206 +    if (ioctl(this->hidden->audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0) {
   4.207          perror("SNDCTL_DSP_GETFMTS");
   4.208          SDL_SetError("Couldn't get audio format list");
   4.209 -        DSP_CloseAudio(this);
   4.210 -        return (-1);
   4.211 +        DSP_CloseDevice(this);
   4.212 +        return 0;
   4.213      }
   4.214  
   4.215      /* Try for a closest match on audio format */
   4.216      format = 0;
   4.217 -    for (test_format = SDL_FirstAudioFormat(spec->format);
   4.218 +    for (test_format = SDL_FirstAudioFormat(this->spec.format);
   4.219           !format && test_format;) {
   4.220  #ifdef DEBUG_AUDIO
   4.221          fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
   4.222 @@ -256,49 +226,50 @@
   4.223      }
   4.224      if (format == 0) {
   4.225          SDL_SetError("Couldn't find any hardware audio formats");
   4.226 -        DSP_CloseAudio(this);
   4.227 -        return (-1);
   4.228 +        DSP_CloseDevice(this);
   4.229 +        return 0;
   4.230      }
   4.231 -    spec->format = test_format;
   4.232 +    this->spec.format = test_format;
   4.233  
   4.234      /* Set the audio format */
   4.235      value = format;
   4.236 -    if ((ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || (value != format)) {
   4.237 +    if ( (ioctl(this->hidden->audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) ||
   4.238 +         (value != format) ) {
   4.239          perror("SNDCTL_DSP_SETFMT");
   4.240          SDL_SetError("Couldn't set audio format");
   4.241 -        DSP_CloseAudio(this);
   4.242 -        return (-1);
   4.243 +        DSP_CloseDevice(this);
   4.244 +        return 0;
   4.245      }
   4.246  
   4.247      /* Set the number of channels of output */
   4.248 -    value = spec->channels;
   4.249 -    if (ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &value) < 0) {
   4.250 +    value = this->spec.channels;
   4.251 +    if (ioctl(this->hidden->audio_fd, SNDCTL_DSP_CHANNELS, &value) < 0) {
   4.252          perror("SNDCTL_DSP_CHANNELS");
   4.253          SDL_SetError("Cannot set the number of channels");
   4.254 -        DSP_CloseAudio(this);
   4.255 -        return (-1);
   4.256 +        DSP_CloseDevice(this);
   4.257 +        return 0;
   4.258      }
   4.259 -    spec->channels = value;
   4.260 +    this->spec.channels = value;
   4.261  
   4.262      /* Set the DSP frequency */
   4.263 -    value = spec->freq;
   4.264 -    if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &value) < 0) {
   4.265 +    value = this->spec.freq;
   4.266 +    if (ioctl(this->hidden->audio_fd, SNDCTL_DSP_SPEED, &value) < 0) {
   4.267          perror("SNDCTL_DSP_SPEED");
   4.268          SDL_SetError("Couldn't set audio frequency");
   4.269 -        DSP_CloseAudio(this);
   4.270 -        return (-1);
   4.271 +        DSP_CloseDevice(this);
   4.272 +        return 0;
   4.273      }
   4.274 -    spec->freq = value;
   4.275 +    this->spec.freq = value;
   4.276  
   4.277      /* Calculate the final parameters for this audio specification */
   4.278 -    SDL_CalculateAudioSpec(spec);
   4.279 +    SDL_CalculateAudioSpec(&this->spec);
   4.280  
   4.281      /* Determine the power of two of the fragment size */
   4.282 -    for (frag_spec = 0; (0x01U << frag_spec) < spec->size; ++frag_spec);
   4.283 -    if ((0x01U << frag_spec) != spec->size) {
   4.284 +    for (frag_spec = 0; (0x01U << frag_spec) < this->spec.size; ++frag_spec);
   4.285 +    if ((0x01U << frag_spec) != this->spec.size) {
   4.286          SDL_SetError("Fragment size must be a power of two");
   4.287 -        DSP_CloseAudio(this);
   4.288 -        return (-1);
   4.289 +        DSP_CloseDevice(this);
   4.290 +        return 0;
   4.291      }
   4.292      frag_spec |= 0x00020000;    /* two fragments, for low latency */
   4.293  
   4.294 @@ -307,13 +278,13 @@
   4.295      fprintf(stderr, "Requesting %d fragments of size %d\n",
   4.296              (frag_spec >> 16), 1 << (frag_spec & 0xFFFF));
   4.297  #endif
   4.298 -    if (ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_spec) < 0) {
   4.299 +    if (ioctl(this->hidden->audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_spec) < 0) {
   4.300          perror("SNDCTL_DSP_SETFRAGMENT");
   4.301      }
   4.302  #ifdef DEBUG_AUDIO
   4.303      {
   4.304          audio_buf_info info;
   4.305 -        ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info);
   4.306 +        ioctl(this->hidden->audio_fd, SNDCTL_DSP_GETOSPACE, &info);
   4.307          fprintf(stderr, "fragments = %d\n", info.fragments);
   4.308          fprintf(stderr, "fragstotal = %d\n", info.fragstotal);
   4.309          fprintf(stderr, "fragsize = %d\n", info.fragsize);
   4.310 @@ -322,19 +293,62 @@
   4.311  #endif
   4.312  
   4.313      /* Allocate mixing buffer */
   4.314 -    mixlen = spec->size;
   4.315 -    mixbuf = (Uint8 *) SDL_AllocAudioMem(mixlen);
   4.316 -    if (mixbuf == NULL) {
   4.317 -        DSP_CloseAudio(this);
   4.318 -        return (-1);
   4.319 +    this->hidden->mixlen = this->spec.size;
   4.320 +    this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
   4.321 +    if (this->hidden->mixbuf == NULL) {
   4.322 +        DSP_CloseDevice(this);
   4.323 +        return 0;
   4.324      }
   4.325 -    SDL_memset(mixbuf, spec->silence, spec->size);
   4.326 -
   4.327 -    /* Get the parent process id (we're the parent of the audio thread) */
   4.328 -    parent = getpid();
   4.329 +    SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
   4.330  
   4.331      /* We're ready to rock and roll. :-) */
   4.332 -    return (0);
   4.333 +    return 1;
   4.334 +}
   4.335 +
   4.336 +
   4.337 +/* This function waits until it is possible to write a full sound buffer */
   4.338 +static void
   4.339 +DSP_WaitDevice(_THIS)
   4.340 +{
   4.341 +    /* Not needed at all since OSS handles waiting automagically */
   4.342 +}
   4.343 +
   4.344 +
   4.345 +static void
   4.346 +DSP_PlayDevice(_THIS)
   4.347 +{
   4.348 +    const Uint8 *mixbuf = this->hidden->mixbuf;
   4.349 +    const int mixlen = this->hidden->mixlen;
   4.350 +    if (write(this->hidden->audio_fd, mixbuf, mixlen) == -1) {
   4.351 +        perror("Audio write");
   4.352 +        this->enabled = 0;
   4.353 +    }
   4.354 +#ifdef DEBUG_AUDIO
   4.355 +    fprintf(stderr, "Wrote %d bytes of audio data\n", mixlen);
   4.356 +#endif
   4.357 +}
   4.358 +
   4.359 +static Uint8 *
   4.360 +DSP_GetDeviceBuf(_THIS)
   4.361 +{
   4.362 +    return (this->hidden->mixbuf);
   4.363 +}
   4.364 +
   4.365 +static void
   4.366 +DSP_CloseDevice(_THIS)
   4.367 +{
   4.368 +    if (this->hidden != NULL) {
   4.369 +        if (this->hidden->mixbuf != NULL) {
   4.370 +            SDL_FreeAudioMem(this->hidden->mixbuf);
   4.371 +            this->hidden->mixbuf = NULL;
   4.372 +        }
   4.373 +        if (this->hidden->audio_fd >= 0) {
   4.374 +            close(this->hidden->audio_fd);
   4.375 +            this->hidden->audio_fd = -1;
   4.376 +        }
   4.377 +        SDL_free(this->hidden);
   4.378 +        this->hidden = NULL;
   4.379 +    }
   4.380  }
   4.381  
   4.382  /* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/audio/dsp/SDL_dspaudio.h	Tue Oct 03 23:45:36 2006 +0000
     5.2 +++ b/src/audio/dsp/SDL_dspaudio.h	Wed Oct 04 06:00:10 2006 +0000
     5.3 @@ -34,22 +34,11 @@
     5.4      /* The file descriptor for the audio device */
     5.5      int audio_fd;
     5.6  
     5.7 -    /* The parent process id, to detect when application quits */
     5.8 -    pid_t parent;
     5.9 -
    5.10      /* Raw mixing buffer */
    5.11      Uint8 *mixbuf;
    5.12      int mixlen;
    5.13  };
    5.14  #define FUDGE_TICKS	10      /* The scheduler overhead ticks per frame */
    5.15  
    5.16 -/* Old variable names */
    5.17 -#define audio_fd		(this->hidden->audio_fd)
    5.18 -#define parent			(this->hidden->parent)
    5.19 -#define mixbuf			(this->hidden->mixbuf)
    5.20 -#define mixlen			(this->hidden->mixlen)
    5.21 -#define frame_ticks		(this->hidden->frame_ticks)
    5.22 -#define next_frame		(this->hidden->next_frame)
    5.23 -
    5.24  #endif /* _SDL_dspaudio_h */
    5.25  /* vi: set ts=4 sw=4 expandtab: */
     6.1 --- a/src/audio/macosx/SDL_coreaudio.c	Tue Oct 03 23:45:36 2006 +0000
     6.2 +++ b/src/audio/macosx/SDL_coreaudio.c	Wed Oct 04 06:00:10 2006 +0000
     6.3 @@ -356,25 +356,25 @@
     6.4  
     6.5  
     6.6  /* Dummy functions -- we don't use thread-based audio */
     6.7 -void
     6.8 +static void
     6.9  COREAUDIO_WaitDevice(_THIS)
    6.10  {
    6.11      return;
    6.12  }
    6.13  
    6.14 -void
    6.15 +static void
    6.16  COREAUDIO_PlayDevice(_THIS)
    6.17  {
    6.18      return;
    6.19  }
    6.20  
    6.21 -Uint8 *
    6.22 +static Uint8 *
    6.23  COREAUDIO_GetDeviceBuf(_THIS)
    6.24  {
    6.25      return (NULL);
    6.26  }
    6.27  
    6.28 -void
    6.29 +static void
    6.30  COREAUDIO_CloseDevice(_THIS)
    6.31  {
    6.32      if (this->hidden != NULL) {
    6.33 @@ -555,7 +555,7 @@
    6.34  }
    6.35  
    6.36  
    6.37 -int
    6.38 +static int
    6.39  COREAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
    6.40  {
    6.41      AudioStreamBasicDescription strdesc;
     7.1 --- a/test/testaudioinfo.c	Tue Oct 03 23:45:36 2006 +0000
     7.2 +++ b/test/testaudioinfo.c	Wed Oct 04 06:00:10 2006 +0000
     7.3 @@ -5,12 +5,15 @@
     7.4      const char *typestr = ((iscapture) ? "capture" : "output");
     7.5      int n = SDL_GetNumAudioDevices(iscapture);
     7.6  
     7.7 -    if (n == 0)
     7.8 -        printf("No %s devices.\n\n", typestr);
     7.9 +    printf("%s devices:\n", typestr);
    7.10 +
    7.11 +    if (n == -1)
    7.12 +        printf("  Driver can't detect specific devices.\n\n", typestr);
    7.13 +    else if (n == 0)
    7.14 +        printf("  No %s devices found.\n\n", typestr);
    7.15      else
    7.16      {
    7.17          int i;
    7.18 -        printf("%s devices:\n", typestr);
    7.19          for (i = 0; i < n; i++) {
    7.20              printf("  %s\n", SDL_GetAudioDeviceName(i, iscapture));
    7.21          }