OS/2 audio code works in 1.3 now. SDL-ryan-multiple-audio-device
authorRyan C. Gordon <icculus@icculus.org>
Sun, 08 Oct 2006 08:57:28 +0000
branchSDL-ryan-multiple-audio-device
changeset 3839506fc6ca82cb
parent 3838 45e566003276
child 3840 be9bd1067c6c
OS/2 audio code works in 1.3 now.
src/audio/dart/SDL_dart.c
     1.1 --- a/src/audio/dart/SDL_dart.c	Sun Oct 08 08:55:14 2006 +0000
     1.2 +++ b/src/audio/dart/SDL_dart.c	Sun Oct 08 08:57:28 2006 +0000
     1.3 @@ -74,10 +74,9 @@
     1.4  static int
     1.5  DART_OpenDevice(_THIS, const char *devname, int iscapture)
     1.6  {
     1.7 -    SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
     1.8 +    SDL_AudioFormat test_format = SDL_FirstAudioFormat(_this->spec.format);
     1.9      int valid_datatype = 0;
    1.10      MCI_AMP_OPEN_PARMS AmpOpenParms;
    1.11 -    MCI_GENERIC_PARMS GenericParms;
    1.12      int iDeviceOrd = 0;         // Default device to be used
    1.13      int bOpenShared = 1;        // Try opening it shared
    1.14      int iBits = 16;             // Default is 16 bits signed
    1.15 @@ -90,13 +89,13 @@
    1.16      int rc;
    1.17  
    1.18      /* Initialize all variables that we clean on shutdown */
    1.19 -    this->hidden = (struct SDL_PrivateAudioData *)
    1.20 -                        SDL_malloc((sizeof *this->hidden));
    1.21 -    if (this->hidden == NULL) {
    1.22 +    _this->hidden = (struct SDL_PrivateAudioData *)
    1.23 +                        SDL_malloc((sizeof *_this->hidden));
    1.24 +    if (_this->hidden == NULL) {
    1.25          SDL_OutOfMemory();
    1.26          return 0;
    1.27      }
    1.28 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
    1.29 +    SDL_memset(_this->hidden, 0, (sizeof *_this->hidden));
    1.30  
    1.31      // First thing is to try to open a given DART device!
    1.32      SDL_memset(&AmpOpenParms, 0, sizeof(MCI_AMP_OPEN_PARMS));
    1.33 @@ -110,7 +109,8 @@
    1.34  
    1.35      rc = mciSendCommand(0, MCI_OPEN, iOpenMode, (PVOID) & AmpOpenParms, 0);
    1.36      if (rc != MCIERR_SUCCESS) {  // No audio available??
    1.37 -        DART_CloseDevice(this);
    1.38 +        DART_CloseDevice(_this);
    1.39 +        SDL_SetError("DART: Couldn't open audio device.");
    1.40          return 0;
    1.41      }
    1.42  
    1.43 @@ -119,11 +119,11 @@
    1.44      _this->hidden->iCurrDeviceOrd = iDeviceOrd = AmpOpenParms.usDeviceID;
    1.45  
    1.46      // Determine the audio parameters from the AudioSpec
    1.47 -    if (this->spec.channels > 4)
    1.48 -        this->spec.channels = 4;
    1.49 +    if (_this->spec.channels > 4)
    1.50 +        _this->spec.channels = 4;
    1.51  
    1.52      while ((!valid_datatype) && (test_format)) {
    1.53 -        this->spec.format = test_format;
    1.54 +        _this->spec.format = test_format;
    1.55          valid_datatype = 1;
    1.56          switch (test_format) {
    1.57          case AUDIO_U8:
    1.58 @@ -149,16 +149,16 @@
    1.59  
    1.60      if (!valid_datatype) {      // shouldn't happen, but just in case...
    1.61          // Close DART, and exit with error code!
    1.62 -        DART_CloseDevice(this);
    1.63 +        DART_CloseDevice(_this);
    1.64          SDL_SetError("Unsupported audio format");
    1.65          return 0;
    1.66      }
    1.67  
    1.68 -    _this->hidden->iCurrFreq = iFreq = this->spec.freq;
    1.69 -    _this->hidden->iCurrChannels = iChannels = this->spec.channels;
    1.70 +    _this->hidden->iCurrFreq = iFreq = _this->spec.freq;
    1.71 +    _this->hidden->iCurrChannels = iChannels = _this->spec.channels;
    1.72      /* Update the fragment size as size in bytes */
    1.73 -    SDL_CalculateAudioSpec(&this->spec);
    1.74 -    _this->hidden->iCurrBufSize = iBufSize = this->spec.size;
    1.75 +    SDL_CalculateAudioSpec(&_this->spec);
    1.76 +    _this->hidden->iCurrBufSize = iBufSize = _this->spec.size;
    1.77  
    1.78      // Now query this device if it supports the given freq/bits/channels!
    1.79      SDL_memset(&(_this->hidden->MixSetupParms), 0,
    1.80 @@ -175,7 +175,7 @@
    1.81                          &(_this->hidden->MixSetupParms), 0);
    1.82      if (rc != MCIERR_SUCCESS) { // The device cannot handle this format!
    1.83          // Close DART, and exit with error code!
    1.84 -        DART_CloseDevice(this);
    1.85 +        DART_CloseDevice(_this);
    1.86          SDL_SetError("Audio device doesn't support requested audio format");
    1.87          return 0;
    1.88      }
    1.89 @@ -185,7 +185,7 @@
    1.90                          &(_this->hidden->MixSetupParms), 0);
    1.91      if (rc != MCIERR_SUCCESS) { // The device could not be opened!
    1.92          // Close DART, and exit with error code!
    1.93 -        DART_CloseDevice(this);
    1.94 +        DART_CloseDevice(_this);
    1.95          SDL_SetError("Audio device could not be set up");
    1.96          return 0;
    1.97      }
    1.98 @@ -196,7 +196,7 @@
    1.99          (MCI_MIX_BUFFER *) SDL_malloc(sizeof(MCI_MIX_BUFFER) * iNumBufs);
   1.100      if (!(_this->hidden->pMixBuffers)) {        // Not enough memory!
   1.101          // Close DART, and exit with error code!
   1.102 -        DART_CloseDevice(this);
   1.103 +        DART_CloseDevice(_this);
   1.104          SDL_OutOfMemory();
   1.105          return 0;
   1.106      }
   1.107 @@ -213,7 +213,7 @@
   1.108          || (iNumBufs != _this->hidden->BufferParms.ulNumBuffers)
   1.109          || (_this->hidden->BufferParms.ulBufferSize == 0)) {    // Could not allocate memory!
   1.110          // Close DART, and exit with error code!
   1.111 -        DART_CloseDevice(this);
   1.112 +        DART_CloseDevice(_this);
   1.113          SDL_SetError("DART could not allocate buffers");
   1.114          return 0;
   1.115      }
   1.116 @@ -228,7 +228,7 @@
   1.117              // Check if this buffer was really allocated by DART
   1.118              if ((!(_this->hidden->pMixBuffers[i].pBuffer))
   1.119                  || (!pBufferDesc)) {    // Wrong buffer!
   1.120 -                DART_CloseDevice(this);
   1.121 +                DART_CloseDevice(_this);
   1.122                  SDL_SetError("Error at internal buffer check");
   1.123                  return 0;
   1.124              }
   1.125 @@ -251,7 +251,7 @@
   1.126      if (DosCreateEventSem
   1.127          (NULL, &(_this->hidden->hevAudioBufferPlayed), 0, FALSE) != NO_ERROR)
   1.128      {
   1.129 -        DART_CloseDevice(this);
   1.130 +        DART_CloseDevice(_this);
   1.131          SDL_SetError("Could not create event semaphore");
   1.132          return 0;
   1.133      }