Cleaning out SDL_audiodev.c and related references ... SDL-ryan-multiple-audio-device
authorRyan C. Gordon <icculus@icculus.org>
Thu, 05 Oct 2006 01:13:47 +0000
branchSDL-ryan-multiple-audio-device
changeset 38097852b5b78af5
parent 3808 e630f5fe29d8
child 3810 2c5387c0a642
Cleaning out SDL_audiodev.c and related references ...
src/audio/SDL_audiodev.c
src/audio/arts/SDL_artsaudio.c
src/audio/disk/SDL_diskaudio.c
src/audio/dummy/SDL_dummyaudio.c
src/audio/esd/SDL_esdaudio.c
src/audio/nas/SDL_nasaudio.c
src/audio/paudio/SDL_paudio.c
src/audio/ums/SDL_umsaudio.c
     1.1 --- a/src/audio/SDL_audiodev.c	Thu Oct 05 01:06:06 2006 +0000
     1.2 +++ b/src/audio/SDL_audiodev.c	Thu Oct 05 01:13:47 2006 +0000
     1.3 @@ -99,85 +99,5 @@
     1.4      return (audio_fd);
     1.5  }
     1.6  
     1.7 -#elif SDL_AUDIO_DRIVER_PAUD
     1.8 -
     1.9 -/* Get the name of the audio device we use for output */
    1.10 -
    1.11 -#include <sys/types.h>
    1.12 -#include <sys/stat.h>
    1.13 -
    1.14 -#include "SDL_stdinc.h"
    1.15 -#include "SDL_audiodev_c.h"
    1.16 -
    1.17 -#ifndef _PATH_DEV_DSP
    1.18 -#define _PATH_DEV_DSP	"/dev/%caud%c/%c"
    1.19 -#endif
    1.20 -
    1.21 -char devsettings[][3] = {
    1.22 -    {'p', '0', '1'}, {'p', '0', '2'}, {'p', '0', '3'}, {'p', '0', '4'},
    1.23 -    {'p', '1', '1'}, {'p', '1', '2'}, {'p', '1', '3'}, {'p', '1', '4'},
    1.24 -    {'p', '2', '1'}, {'p', '2', '2'}, {'p', '2', '3'}, {'p', '2', '4'},
    1.25 -    {'p', '3', '1'}, {'p', '3', '2'}, {'p', '3', '3'}, {'p', '3', '4'},
    1.26 -    {'b', '0', '1'}, {'b', '0', '2'}, {'b', '0', '3'}, {'b', '0', '4'},
    1.27 -    {'b', '1', '1'}, {'b', '1', '2'}, {'b', '1', '3'}, {'b', '1', '4'},
    1.28 -    {'b', '2', '1'}, {'b', '2', '2'}, {'b', '2', '3'}, {'b', '2', '4'},
    1.29 -    {'b', '3', '1'}, {'b', '3', '2'}, {'b', '3', '3'}, {'b', '3', '4'},
    1.30 -    {'\0', '\0', '\0'}
    1.31 -};
    1.32 -
    1.33 -static int
    1.34 -OpenUserDefinedDevice(char *path, int maxlen, int flags)
    1.35 -{
    1.36 -    const char *audiodev;
    1.37 -    int audio_fd;
    1.38 -
    1.39 -    /* Figure out what our audio device is */
    1.40 -    if ((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) {
    1.41 -        audiodev = SDL_getenv("AUDIODEV");
    1.42 -    }
    1.43 -    if (audiodev == NULL) {
    1.44 -        return -1;
    1.45 -    }
    1.46 -    audio_fd = open(audiodev, flags, 0);
    1.47 -    if (path != NULL) {
    1.48 -        SDL_strlcpy(path, audiodev, maxlen);
    1.49 -        path[maxlen - 1] = '\0';
    1.50 -    }
    1.51 -    return audio_fd;
    1.52 -}
    1.53 -
    1.54 -int
    1.55 -SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
    1.56 -{
    1.57 -    struct stat sb;
    1.58 -    int audio_fd;
    1.59 -    char audiopath[1024];
    1.60 -    int cycle;
    1.61 -
    1.62 -    audio_fd = OpenUserDefinedDevice(path, maxlen, flags);
    1.63 -    if (audio_fd != -1) {
    1.64 -        return audio_fd;
    1.65 -    }
    1.66 -
    1.67 -    cycle = 0;
    1.68 -    while (devsettings[cycle][0] != '\0') {
    1.69 -        SDL_snprintf(audiopath, SDL_arraysize(audiopath),
    1.70 -                     _PATH_DEV_DSP,
    1.71 -                     devsettings[cycle][0],
    1.72 -                     devsettings[cycle][1], devsettings[cycle][2]);
    1.73 -
    1.74 -        if (stat(audiopath, &sb) == 0) {
    1.75 -            audio_fd = open(audiopath, flags, 0);
    1.76 -            if (audio_fd > 0) {
    1.77 -                if (path != NULL) {
    1.78 -                    SDL_strlcpy(path, audiopath, maxlen);
    1.79 -                }
    1.80 -                return audio_fd;
    1.81 -            }
    1.82 -        }
    1.83 -    }
    1.84 -    return -1;
    1.85 -}
    1.86 -
    1.87  #endif /* Audio driver selection */
    1.88  /* vi: set ts=4 sw=4 expandtab: */
     2.1 --- a/src/audio/arts/SDL_artsaudio.c	Thu Oct 05 01:06:06 2006 +0000
     2.2 +++ b/src/audio/arts/SDL_artsaudio.c	Thu Oct 05 01:13:47 2006 +0000
     2.3 @@ -27,7 +27,6 @@
     2.4  #include "SDL_audio.h"
     2.5  #include "../SDL_audiomem.h"
     2.6  #include "../SDL_audio_c.h"
     2.7 -#include "../SDL_audiodev_c.h"
     2.8  #include "SDL_artsaudio.h"
     2.9  
    2.10  #ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
     3.1 --- a/src/audio/disk/SDL_diskaudio.c	Thu Oct 05 01:06:06 2006 +0000
     3.2 +++ b/src/audio/disk/SDL_diskaudio.c	Thu Oct 05 01:13:47 2006 +0000
     3.3 @@ -34,7 +34,6 @@
     3.4  #include "SDL_audio.h"
     3.5  #include "../SDL_audiomem.h"
     3.6  #include "../SDL_audio_c.h"
     3.7 -#include "../SDL_audiodev_c.h"
     3.8  #include "SDL_diskaudio.h"
     3.9  
    3.10  /* The tag name used by DISK audio */
     4.1 --- a/src/audio/dummy/SDL_dummyaudio.c	Thu Oct 05 01:06:06 2006 +0000
     4.2 +++ b/src/audio/dummy/SDL_dummyaudio.c	Thu Oct 05 01:13:47 2006 +0000
     4.3 @@ -30,7 +30,6 @@
     4.4  #include "SDL_audio.h"
     4.5  #include "../SDL_audiomem.h"
     4.6  #include "../SDL_audio_c.h"
     4.7 -#include "../SDL_audiodev_c.h"
     4.8  #include "SDL_dummyaudio.h"
     4.9  
    4.10  /* The tag name used by DUMMY audio */
     5.1 --- a/src/audio/esd/SDL_esdaudio.c	Thu Oct 05 01:06:06 2006 +0000
     5.2 +++ b/src/audio/esd/SDL_esdaudio.c	Thu Oct 05 01:13:47 2006 +0000
     5.3 @@ -33,7 +33,6 @@
     5.4  #include "SDL_audio.h"
     5.5  #include "../SDL_audiomem.h"
     5.6  #include "../SDL_audio_c.h"
     5.7 -#include "../SDL_audiodev_c.h"
     5.8  #include "SDL_esdaudio.h"
     5.9  
    5.10  #ifdef SDL_AUDIO_DRIVER_ESD_DYNAMIC
     6.1 --- a/src/audio/nas/SDL_nasaudio.c	Thu Oct 05 01:06:06 2006 +0000
     6.2 +++ b/src/audio/nas/SDL_nasaudio.c	Thu Oct 05 01:13:47 2006 +0000
     6.3 @@ -34,7 +34,6 @@
     6.4  #include "SDL_audio.h"
     6.5  #include "../SDL_audiomem.h"
     6.6  #include "../SDL_audio_c.h"
     6.7 -#include "../SDL_audiodev_c.h"
     6.8  #include "SDL_nasaudio.h"
     6.9  
    6.10  /* The tag name used by artsc audio */
     7.1 --- a/src/audio/paudio/SDL_paudio.c	Thu Oct 05 01:06:06 2006 +0000
     7.2 +++ b/src/audio/paudio/SDL_paudio.c	Thu Oct 05 01:13:47 2006 +0000
     7.3 @@ -30,13 +30,14 @@
     7.4  #include <fcntl.h>
     7.5  #include <sys/time.h>
     7.6  #include <sys/ioctl.h>
     7.7 +#include <sys/types.h>
     7.8  #include <sys/stat.h>
     7.9  
    7.10  #include "SDL_timer.h"
    7.11  #include "SDL_audio.h"
    7.12 +#include "SDL_stdinc.h"
    7.13  #include "../SDL_audiomem.h"
    7.14  #include "../SDL_audio_c.h"
    7.15 -#include "../SDL_audiodev_c.h"
    7.16  #include "SDL_paudio.h"
    7.17  
    7.18  #define DEBUG_AUDIO 1
    7.19 @@ -61,6 +62,81 @@
    7.20  static Uint8 *Paud_GetAudioBuf(_THIS);
    7.21  static void Paud_CloseAudio(_THIS);
    7.22  
    7.23 +
    7.24 +/* Get the name of the audio device we use for output */
    7.25 +
    7.26 +#ifndef _PATH_DEV_DSP
    7.27 +#define _PATH_DEV_DSP	"/dev/%caud%c/%c"
    7.28 +#endif
    7.29 +
    7.30 +static char devsettings[][3] = {
    7.31 +    {'p', '0', '1'}, {'p', '0', '2'}, {'p', '0', '3'}, {'p', '0', '4'},
    7.32 +    {'p', '1', '1'}, {'p', '1', '2'}, {'p', '1', '3'}, {'p', '1', '4'},
    7.33 +    {'p', '2', '1'}, {'p', '2', '2'}, {'p', '2', '3'}, {'p', '2', '4'},
    7.34 +    {'p', '3', '1'}, {'p', '3', '2'}, {'p', '3', '3'}, {'p', '3', '4'},
    7.35 +    {'b', '0', '1'}, {'b', '0', '2'}, {'b', '0', '3'}, {'b', '0', '4'},
    7.36 +    {'b', '1', '1'}, {'b', '1', '2'}, {'b', '1', '3'}, {'b', '1', '4'},
    7.37 +    {'b', '2', '1'}, {'b', '2', '2'}, {'b', '2', '3'}, {'b', '2', '4'},
    7.38 +    {'b', '3', '1'}, {'b', '3', '2'}, {'b', '3', '3'}, {'b', '3', '4'},
    7.39 +    {'\0', '\0', '\0'}
    7.40 +};
    7.41 +
    7.42 +static int
    7.43 +OpenUserDefinedDevice(char *path, int maxlen, int flags)
    7.44 +{
    7.45 +    const char *audiodev;
    7.46 +    int audio_fd;
    7.47 +
    7.48 +    /* Figure out what our audio device is */
    7.49 +    if ((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) {
    7.50 +        audiodev = SDL_getenv("AUDIODEV");
    7.51 +    }
    7.52 +    if (audiodev == NULL) {
    7.53 +        return -1;
    7.54 +    }
    7.55 +    audio_fd = open(audiodev, flags, 0);
    7.56 +    if (path != NULL) {
    7.57 +        SDL_strlcpy(path, audiodev, maxlen);
    7.58 +        path[maxlen - 1] = '\0';
    7.59 +    }
    7.60 +    return audio_fd;
    7.61 +}
    7.62 +
    7.63 +int
    7.64 +OpenAudioPath(char *path, int maxlen, int flags, int classic)
    7.65 +{
    7.66 +    struct stat sb;
    7.67 +    int audio_fd;
    7.68 +    char audiopath[1024];
    7.69 +    int cycle;
    7.70 +
    7.71 +    audio_fd = OpenUserDefinedDevice(path, maxlen, flags);
    7.72 +    if (audio_fd != -1) {
    7.73 +        return audio_fd;
    7.74 +    }
    7.75 +
    7.76 +    cycle = 0;
    7.77 +    /* !!! FIXME: do we really need a table here? */
    7.78 +    while (devsettings[cycle][0] != '\0') {
    7.79 +        SDL_snprintf(audiopath, SDL_arraysize(audiopath),
    7.80 +                     _PATH_DEV_DSP,
    7.81 +                     devsettings[cycle][0],
    7.82 +                     devsettings[cycle][1], devsettings[cycle][2]);
    7.83 +
    7.84 +        if (stat(audiopath, &sb) == 0) {
    7.85 +            audio_fd = open(audiopath, flags, 0);
    7.86 +            if (audio_fd > 0) {
    7.87 +                if (path != NULL) {
    7.88 +                    SDL_strlcpy(path, audiopath, maxlen);
    7.89 +                }
    7.90 +                return audio_fd;
    7.91 +            }
    7.92 +        }
    7.93 +    }
    7.94 +    return -1;
    7.95 +}
    7.96 +
    7.97 +
    7.98  /* Audio driver bootstrap functions */
    7.99  
   7.100  static int
   7.101 @@ -70,7 +146,7 @@
   7.102      int available;
   7.103  
   7.104      available = 0;
   7.105 -    fd = SDL_OpenAudioPath(NULL, 0, OPEN_FLAGS, 0);
   7.106 +    fd = OpenAudioPath(NULL, 0, OPEN_FLAGS, 0);
   7.107      if (fd >= 0) {
   7.108          available = 1;
   7.109          close(fd);
   7.110 @@ -255,7 +331,7 @@
   7.111      frame_ticks = 0.0;
   7.112  
   7.113      /* Open the audio device */
   7.114 -    audio_fd = SDL_OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 0);
   7.115 +    audio_fd = OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 0);
   7.116      if (audio_fd < 0) {
   7.117          SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno));
   7.118          return -1;
     8.1 --- a/src/audio/ums/SDL_umsaudio.c	Thu Oct 05 01:06:06 2006 +0000
     8.2 +++ b/src/audio/ums/SDL_umsaudio.c	Thu Oct 05 01:13:47 2006 +0000
     8.3 @@ -36,7 +36,6 @@
     8.4  
     8.5  #include "SDL_audio.h"
     8.6  #include "../SDL_audio_c.h"
     8.7 -#include "../SDL_audiodev_c.h"
     8.8  #include "SDL_umsaudio.h"
     8.9  
    8.10  /* The tag name used by UMS audio */