BeOS audio now works in 1.3 branch. SDL-ryan-multiple-audio-device
authorRyan C. Gordon <icculus@icculus.org>
Sun, 08 Oct 2006 01:39:01 +0000
branchSDL-ryan-multiple-audio-device
changeset 38377c9663fb0860
parent 3836 7dc7327cd626
child 3838 45e566003276
BeOS audio now works in 1.3 branch.
configure.in
include/SDL_config.h.in
src/audio/SDL_audio.c
src/audio/baudio/SDL_beaudio.cc
     1.1 --- a/configure.in	Sun Oct 08 00:55:30 2006 +0000
     1.2 +++ b/configure.in	Sun Oct 08 01:39:01 2006 +0000
     1.3 @@ -2242,7 +2242,7 @@
     1.4          CheckBeGL
     1.5          # Set up files for the audio library
     1.6          if test x$enable_audio = xyes; then
     1.7 -            AC_DEFINE(SDL_AUDIO_DRIVER_BAUDIO)
     1.8 +            AC_DEFINE(SDL_AUDIO_DRIVER_BEOSAUDIO)
     1.9              SOURCES="$SOURCES $srcdir/src/audio/baudio/*.cc"
    1.10              have_audio=yes
    1.11          fi
     2.1 --- a/include/SDL_config.h.in	Sun Oct 08 00:55:30 2006 +0000
     2.2 +++ b/include/SDL_config.h.in	Sun Oct 08 01:39:01 2006 +0000
     2.3 @@ -154,7 +154,7 @@
     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_BAUDIO
     2.8 +#undef SDL_AUDIO_DRIVER_BEOSAUDIO
     2.9  #undef SDL_AUDIO_DRIVER_BSD
    2.10  #undef SDL_AUDIO_DRIVER_COREAUDIO
    2.11  #undef SDL_AUDIO_DRIVER_DART
     3.1 --- a/src/audio/SDL_audio.c	Sun Oct 08 00:55:30 2006 +0000
     3.2 +++ b/src/audio/SDL_audio.c	Sun Oct 08 01:39:01 2006 +0000
     3.3 @@ -56,7 +56,7 @@
     3.4  extern AudioBootStrap DSOUND_bootstrap;
     3.5  extern AudioBootStrap WAVEOUT_bootstrap;
     3.6  extern AudioBootStrap PAUDIO_bootstrap;
     3.7 -extern AudioBootStrap BAUDIO_bootstrap;
     3.8 +extern AudioBootStrap BEOSAUDIO_bootstrap;
     3.9  extern AudioBootStrap COREAUDIO_bootstrap;
    3.10  extern AudioBootStrap SNDMGR_bootstrap;
    3.11  extern AudioBootStrap MINTAUDIO_GSXB_bootstrap;
    3.12 @@ -110,8 +110,8 @@
    3.13  #if SDL_AUDIO_DRIVER_PAUDIO
    3.14      &PAUDIO_bootstrap,
    3.15  #endif
    3.16 -#if SDL_AUDIO_DRIVER_BAUDIO
    3.17 -    &BAUDIO_bootstrap,
    3.18 +#if SDL_AUDIO_DRIVER_BEOSAUDIO
    3.19 +    &BEOSAUDIO_bootstrap,
    3.20  #endif
    3.21  #if SDL_AUDIO_DRIVER_COREAUDIO
    3.22      &COREAUDIO_bootstrap,
     4.1 --- a/src/audio/baudio/SDL_beaudio.cc	Sun Oct 08 00:55:30 2006 +0000
     4.2 +++ b/src/audio/baudio/SDL_beaudio.cc	Sun Oct 08 01:39:01 2006 +0000
     4.3 @@ -39,7 +39,7 @@
     4.4  }
     4.5  
     4.6  
     4.7 -static int BEAUDIO_Available(void)
     4.8 +static int BEOSAUDIO_Available(void)
     4.9  {
    4.10      return 1;  /* Always available on BeOS. */
    4.11  }
    4.12 @@ -79,7 +79,7 @@
    4.13  }
    4.14  
    4.15  static void
    4.16 -BEAUDIO_CloseDevice(_THIS)
    4.17 +BEOSAUDIO_CloseDevice(_THIS)
    4.18  {
    4.19      if (_this->hidden != NULL) {
    4.20          if (_this->hidden->audio_obj) {
    4.21 @@ -90,18 +90,15 @@
    4.22  
    4.23          delete _this->hidden;
    4.24          _this->hidden = NULL;
    4.25 -
    4.26 -        /* Quit the Be Application, if there's nothing left to do */
    4.27 -        SDL_QuitBeApp();
    4.28      }
    4.29  }
    4.30  
    4.31  static int
    4.32 -BEAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
    4.33 +BEOSAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
    4.34  {
    4.35      int valid_datatype = 0;
    4.36      media_raw_audio_format format;
    4.37 -    SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
    4.38 +    SDL_AudioFormat test_format = SDL_FirstAudioFormat(_this->spec.format);
    4.39  
    4.40      /* Initialize all variables that we clean on shutdown */
    4.41      _this->hidden = new SDL_PrivateAudioData;
    4.42 @@ -111,19 +108,14 @@
    4.43      }
    4.44      SDL_memset(_this->hidden, 0, (sizeof *_this->hidden));
    4.45  
    4.46 -    /* Initialize the Be Application, if it's not already started */
    4.47 -    if (SDL_InitBeApp() < 0) {
    4.48 -        return 0;
    4.49 -    }
    4.50 -
    4.51      /* Parse the audio format and fill the Be raw audio format */
    4.52      SDL_memset(&format, '\0', sizeof(media_raw_audio_format));
    4.53      format.byte_order = B_MEDIA_LITTLE_ENDIAN;
    4.54 -    format.frame_rate = (float) this->spec.freq;
    4.55 -    format.channel_count = this->spec.channels;  /* !!! FIXME: support > 2? */
    4.56 +    format.frame_rate = (float) _this->spec.freq;
    4.57 +    format.channel_count = _this->spec.channels;  /* !!! FIXME: support > 2? */
    4.58      while ((!valid_datatype) && (test_format)) {
    4.59          valid_datatype = 1;
    4.60 -        this->spec.format = test_format;
    4.61 +        _this->spec.format = test_format;
    4.62          switch (test_format) {
    4.63              case AUDIO_S8:
    4.64                  format.format = media_raw_audio_format::B_AUDIO_CHAR;
    4.65 @@ -167,15 +159,16 @@
    4.66          }
    4.67      }
    4.68  
    4.69 -    format.buffer_size = this->spec.samples;
    4.70 +    format.buffer_size = _this->spec.samples;
    4.71  
    4.72      if (!valid_datatype) {  /* shouldn't happen, but just in case... */
    4.73 +        BEOSAUDIO_CloseDevice(_this);
    4.74          SDL_SetError("Unsupported audio format");
    4.75          return 0;
    4.76      }
    4.77  
    4.78      /* Calculate the final parameters for this audio specification */
    4.79 -    SDL_CalculateAudioSpec(&this->spec);
    4.80 +    SDL_CalculateAudioSpec(&_this->spec);
    4.81  
    4.82      /* Subscribe to the audio stream (creates a new thread) */
    4.83      sigset_t omask;
    4.84 @@ -187,6 +180,7 @@
    4.85      if (_this->hidden->audio_obj->Start() == B_NO_ERROR) {
    4.86          _this->hidden->audio_obj->SetHasData(true);
    4.87      } else {
    4.88 +        BEOSAUDIO_CloseDevice(_this);
    4.89          SDL_SetError("Unable to start Be audio");
    4.90          return 0;
    4.91      }
    4.92 @@ -195,22 +189,35 @@
    4.93      return 1;
    4.94  }
    4.95  
    4.96 +static void
    4.97 +BEOSAUDIO_Deinitialize(void)
    4.98 +{
    4.99 +    SDL_QuitBeApp();
   4.100 +}
   4.101 +
   4.102  static int
   4.103 -BEAUDIO_Init(SDL_AudioDriverImpl *impl)
   4.104 +BEOSAUDIO_Init(SDL_AudioDriverImpl *impl)
   4.105  {
   4.106 +    /* Initialize the Be Application, if it's not already started */
   4.107 +    if (SDL_InitBeApp() < 0) {
   4.108 +        return 0;
   4.109 +    }
   4.110 +
   4.111      /* Set the function pointers */
   4.112 -    impl->OpenDevice = DSP_OpenDevice;
   4.113 -    impl->CloseDevice = DSP_CloseDevice;
   4.114 +    impl->OpenDevice = BEOSAUDIO_OpenDevice;
   4.115 +    impl->CloseDevice = BEOSAUDIO_CloseDevice;
   4.116 +    impl->Deinitialize = BEOSAUDIO_Deinitialize;
   4.117      impl->ProvidesOwnCallbackThread = 1;
   4.118      impl->OnlyHasDefaultOutputDevice = 1;
   4.119  
   4.120      return 1;
   4.121  }
   4.122  
   4.123 -
   4.124 -AudioBootStrap BEAUDIO_bootstrap = {
   4.125 +extern "C" { extern AudioBootStrap BEOSAUDIO_bootstrap; }
   4.126 +AudioBootStrap BEOSAUDIO_bootstrap = {
   4.127      "baudio", "BeOS BSoundPlayer",
   4.128 -    BEAUDIO_Available, BEAUDIO_Init, 0
   4.129 +    BEOSAUDIO_Available, BEOSAUDIO_Init, 0
   4.130  };
   4.131  
   4.132  /* vi: set ts=4 sw=4 expandtab: */
   4.133 +