audio: changed some SDL_memset() calls to SDL_zero(), other minor corrections.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 05 Aug 2016 01:59:06 -0400
changeset 10257f17581d00c26
parent 10256 620329de23d4
child 10258 0ba7106e9a6d
audio: changed some SDL_memset() calls to SDL_zero(), other minor corrections.
src/audio/SDL_wave.c
src/audio/alsa/SDL_alsa_audio.c
src/audio/arts/SDL_artsaudio.c
src/audio/bsd/SDL_bsdaudio.c
src/audio/directsound/SDL_directsound.c
src/audio/disk/SDL_diskaudio.c
src/audio/dsp/SDL_dspaudio.c
src/audio/emscripten/SDL_emscriptenaudio.c
src/audio/esd/SDL_esdaudio.c
src/audio/fusionsound/SDL_fsaudio.c
src/audio/haiku/SDL_haikuaudio.cc
src/audio/nacl/SDL_naclaudio.c
src/audio/nas/SDL_nasaudio.c
src/audio/paudio/SDL_paudio.c
src/audio/psp/SDL_pspaudio.c
src/audio/pulseaudio/SDL_pulseaudio.c
src/audio/qsa/SDL_qsa_audio.c
src/audio/sndio/SDL_sndioaudio.c
src/audio/sun/SDL_sunaudio.c
src/audio/winmm/SDL_winmm.c
src/audio/xaudio2/SDL_xaudio2.c
     1.1 --- a/src/audio/SDL_wave.c	Fri Aug 05 01:44:15 2016 -0400
     1.2 +++ b/src/audio/SDL_wave.c	Fri Aug 05 01:59:06 2016 -0400
     1.3 @@ -504,7 +504,7 @@
     1.4          was_error = 1;
     1.5          goto done;
     1.6      }
     1.7 -    SDL_memset(spec, 0, (sizeof *spec));
     1.8 +    SDL_zerop(spec);
     1.9      spec->freq = SDL_SwapLE32(format->frequency);
    1.10  
    1.11      if (IEEE_float_encoded) {
     2.1 --- a/src/audio/alsa/SDL_alsa_audio.c	Fri Aug 05 01:44:15 2016 -0400
     2.2 +++ b/src/audio/alsa/SDL_alsa_audio.c	Fri Aug 05 01:59:06 2016 -0400
     2.3 @@ -539,7 +539,7 @@
     2.4      if (this->hidden == NULL) {
     2.5          return SDL_OutOfMemory();
     2.6      }
     2.7 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
     2.8 +    SDL_zerop(this->hidden);
     2.9  
    2.10      /* Open the audio device */
    2.11      /* Name of device should depend on # channels in spec */
     3.1 --- a/src/audio/arts/SDL_artsaudio.c	Fri Aug 05 01:44:15 2016 -0400
     3.2 +++ b/src/audio/arts/SDL_artsaudio.c	Fri Aug 05 01:59:06 2016 -0400
     3.3 @@ -235,7 +235,7 @@
     3.4      if (this->hidden == NULL) {
     3.5          return SDL_OutOfMemory();
     3.6      }
     3.7 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
     3.8 +    SDL_zerop(this->hidden);
     3.9  
    3.10      /* Try for a closest match on audio format */
    3.11      for (test_format = SDL_FirstAudioFormat(this->spec.format);
     4.1 --- a/src/audio/bsd/SDL_bsdaudio.c	Fri Aug 05 01:44:15 2016 -0400
     4.2 +++ b/src/audio/bsd/SDL_bsdaudio.c	Fri Aug 05 01:59:06 2016 -0400
     4.3 @@ -297,7 +297,7 @@
     4.4      if (this->hidden == NULL) {
     4.5          return SDL_OutOfMemory();
     4.6      }
     4.7 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
     4.8 +    SDL_zerop(this->hidden);
     4.9  
    4.10      /* Open the audio device */
    4.11      this->hidden->audio_fd = open(devname, flags, 0);
     5.1 --- a/src/audio/directsound/SDL_directsound.c	Fri Aug 05 01:44:15 2016 -0400
     5.2 +++ b/src/audio/directsound/SDL_directsound.c	Fri Aug 05 01:59:06 2016 -0400
     5.3 @@ -431,7 +431,7 @@
     5.4      if (this->hidden == NULL) {
     5.5          return SDL_OutOfMemory();
     5.6      }
     5.7 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
     5.8 +    SDL_zerop(this->hidden);
     5.9  
    5.10      /* Open the audio device */
    5.11      result = pDirectSoundCreate8(guid, &this->hidden->sound, NULL);
     6.1 --- a/src/audio/disk/SDL_diskaudio.c	Fri Aug 05 01:44:15 2016 -0400
     6.2 +++ b/src/audio/disk/SDL_diskaudio.c	Fri Aug 05 01:59:06 2016 -0400
     6.3 @@ -105,7 +105,7 @@
     6.4      if (this->hidden == NULL) {
     6.5          return SDL_OutOfMemory();
     6.6      }
     6.7 -    SDL_memset(this->hidden, 0, sizeof(*this->hidden));
     6.8 +    SDL_zerop(this->hidden);
     6.9  
    6.10      this->hidden->mixlen = this->spec.size;
    6.11      this->hidden->write_delay =
     7.1 --- a/src/audio/dsp/SDL_dspaudio.c	Fri Aug 05 01:44:15 2016 -0400
     7.2 +++ b/src/audio/dsp/SDL_dspaudio.c	Fri Aug 05 01:59:06 2016 -0400
     7.3 @@ -100,7 +100,7 @@
     7.4      if (this->hidden == NULL) {
     7.5          return SDL_OutOfMemory();
     7.6      }
     7.7 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
     7.8 +    SDL_zerop(this->hidden);
     7.9  
    7.10      /* Open the audio device */
    7.11      this->hidden->audio_fd = open(devname, flags, 0);
     8.1 --- a/src/audio/emscripten/SDL_emscriptenaudio.c	Fri Aug 05 01:44:15 2016 -0400
     8.2 +++ b/src/audio/emscripten/SDL_emscriptenaudio.c	Fri Aug 05 01:59:06 2016 -0400
     8.3 @@ -171,7 +171,7 @@
     8.4      if (this->hidden == NULL) {
     8.5          return SDL_OutOfMemory();
     8.6      }
     8.7 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
     8.8 +    SDL_zerop(this->hidden);
     8.9  
    8.10      /* based on parts of library_sdl.js */
    8.11  
     9.1 --- a/src/audio/esd/SDL_esdaudio.c	Fri Aug 05 01:44:15 2016 -0400
     9.2 +++ b/src/audio/esd/SDL_esdaudio.c	Fri Aug 05 01:59:06 2016 -0400
     9.3 @@ -220,7 +220,7 @@
     9.4      if (this->hidden == NULL) {
     9.5          return SDL_OutOfMemory();
     9.6      }
     9.7 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
     9.8 +    SDL_zerop(this->hidden);
     9.9      this->hidden->audio_fd = -1;
    9.10  
    9.11      /* Convert audio spec to the ESD audio format */
    10.1 --- a/src/audio/fusionsound/SDL_fsaudio.c	Fri Aug 05 01:44:15 2016 -0400
    10.2 +++ b/src/audio/fusionsound/SDL_fsaudio.c	Fri Aug 05 01:59:06 2016 -0400
    10.3 @@ -195,7 +195,7 @@
    10.4      if (this->hidden == NULL) {
    10.5          return SDL_OutOfMemory();
    10.6      }
    10.7 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
    10.8 +    SDL_zerop(this->hidden);
    10.9  
   10.10      /* Try for a closest match on audio format */
   10.11      for (test_format = SDL_FirstAudioFormat(this->spec.format);
    11.1 --- a/src/audio/haiku/SDL_haikuaudio.cc	Fri Aug 05 01:44:15 2016 -0400
    11.2 +++ b/src/audio/haiku/SDL_haikuaudio.cc	Fri Aug 05 01:59:06 2016 -0400
    11.3 @@ -118,10 +118,10 @@
    11.4      if (_this->hidden == NULL) {
    11.5          return SDL_OutOfMemory();
    11.6      }
    11.7 -    SDL_memset(_this->hidden, 0, (sizeof *_this->hidden));
    11.8 +    SDL_zerop(this->hidden);
    11.9  
   11.10      /* Parse the audio format and fill the Be raw audio format */
   11.11 -    SDL_memset(&format, '\0', sizeof(media_raw_audio_format));
   11.12 +    SDL_zero(format);
   11.13      format.byte_order = B_MEDIA_LITTLE_ENDIAN;
   11.14      format.frame_rate = (float) _this->spec.freq;
   11.15      format.channel_count = _this->spec.channels;        /* !!! FIXME: support > 2? */
    12.1 --- a/src/audio/nacl/SDL_naclaudio.c	Fri Aug 05 01:44:15 2016 -0400
    12.2 +++ b/src/audio/nacl/SDL_naclaudio.c	Fri Aug 05 01:59:06 2016 -0400
    12.3 @@ -65,7 +65,7 @@
    12.4              SDL_UnlockMutex(_this->mixer_lock);
    12.5          }
    12.6      } else {
    12.7 -        SDL_memset(samples, 0, buffer_size);
    12.8 +        SDL_memset(samples, _this->spec.silence, buffer_size);
    12.9      }
   12.10      
   12.11      SDL_UnlockMutex(private->mutex);
    13.1 --- a/src/audio/nas/SDL_nasaudio.c	Fri Aug 05 01:44:15 2016 -0400
    13.2 +++ b/src/audio/nas/SDL_nasaudio.c	Fri Aug 05 01:59:06 2016 -0400
    13.3 @@ -282,7 +282,7 @@
    13.4      if (this->hidden == NULL) {
    13.5          return SDL_OutOfMemory();
    13.6      }
    13.7 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
    13.8 +    SDL_zerop(this->hidden);
    13.9  
   13.10      /* Try for a closest match on audio format */
   13.11      format = 0;
    14.1 --- a/src/audio/paudio/SDL_paudio.c	Fri Aug 05 01:44:15 2016 -0400
    14.2 +++ b/src/audio/paudio/SDL_paudio.c	Fri Aug 05 01:59:06 2016 -0400
    14.3 @@ -256,7 +256,7 @@
    14.4      if (this->hidden == NULL) {
    14.5          return SDL_OutOfMemory();
    14.6      }
    14.7 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
    14.8 +    SDL_zerop(this->hidden);
    14.9  
   14.10      /* Open the audio device */
   14.11      fd = OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 0);
    15.1 --- a/src/audio/psp/SDL_pspaudio.c	Fri Aug 05 01:44:15 2016 -0400
    15.2 +++ b/src/audio/psp/SDL_pspaudio.c	Fri Aug 05 01:59:06 2016 -0400
    15.3 @@ -50,7 +50,7 @@
    15.4      if (this->hidden == NULL) {
    15.5          return SDL_OutOfMemory();
    15.6      }
    15.7 -    SDL_memset(this->hidden, 0, sizeof(*this->hidden));
    15.8 +    SDL_zerop(this->hidden);
    15.9      switch (this->spec.format & 0xff) {
   15.10          case 8:
   15.11          case 16:
    16.1 --- a/src/audio/pulseaudio/SDL_pulseaudio.c	Fri Aug 05 01:44:15 2016 -0400
    16.2 +++ b/src/audio/pulseaudio/SDL_pulseaudio.c	Fri Aug 05 01:59:06 2016 -0400
    16.3 @@ -529,13 +529,12 @@
    16.4      int rc = 0;
    16.5  
    16.6      /* Initialize all variables that we clean on shutdown */
    16.7 -    this->hidden = (struct SDL_PrivateAudioData *)
    16.8 +    h = this->hidden = (struct SDL_PrivateAudioData *)
    16.9          SDL_malloc((sizeof *this->hidden));
   16.10      if (this->hidden == NULL) {
   16.11          return SDL_OutOfMemory();
   16.12      }
   16.13 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
   16.14 -    h = this->hidden;
   16.15 +    SDL_zerop(this->hidden);
   16.16  
   16.17      paspec.format = PA_SAMPLE_INVALID;
   16.18  
    17.1 --- a/src/audio/qsa/SDL_qsa_audio.c	Fri Aug 05 01:44:15 2016 -0400
    17.2 +++ b/src/audio/qsa/SDL_qsa_audio.c	Fri Aug 05 01:59:06 2016 -0400
    17.3 @@ -137,8 +137,7 @@
    17.4  static void
    17.5  QSA_InitAudioParams(snd_pcm_channel_params_t * cpars)
    17.6  {
    17.7 -    SDL_memset(cpars, 0, sizeof(snd_pcm_channel_params_t));
    17.8 -
    17.9 +    SDL_zerop(cpars);
   17.10      cpars->channel = SND_PCM_CHANNEL_PLAYBACK;
   17.11      cpars->mode = SND_PCM_MODE_BLOCK;
   17.12      cpars->start_mode = SND_PCM_START_DATA;
   17.13 @@ -261,7 +260,7 @@
   17.14                  continue;
   17.15              } else {
   17.16                  if ((errno == EINVAL) || (errno == EIO)) {
   17.17 -                    SDL_memset(&cstatus, 0, sizeof(cstatus));
   17.18 +                    SDL_zero(cstatus);
   17.19                      if (!this->hidden->iscapture) {
   17.20                          cstatus.channel = SND_PCM_CHANNEL_PLAYBACK;
   17.21                      } else {
   17.22 @@ -358,7 +357,7 @@
   17.23      if (this->hidden == NULL) {
   17.24          return SDL_OutOfMemory();
   17.25      }
   17.26 -    SDL_memset(this->hidden, 0, sizeof(struct SDL_PrivateAudioData));
   17.27 +    SDL_zerop(this->hidden);
   17.28  
   17.29      /* Initialize channel transfer parameters to default */
   17.30      QSA_InitAudioParams(&cparams);
   17.31 @@ -499,7 +498,7 @@
   17.32      }
   17.33  
   17.34      /* Make sure channel is setup right one last time */
   17.35 -    SDL_memset(&csetup, 0, sizeof(csetup));
   17.36 +    SDL_zero(csetup);
   17.37      if (!this->hidden->iscapture) {
   17.38          csetup.channel = SND_PCM_CHANNEL_PLAYBACK;
   17.39      } else {
   17.40 @@ -731,10 +730,9 @@
   17.41  QSA_Deinitialize(void)
   17.42  {
   17.43      /* Clear devices array on shutdown */
   17.44 -    SDL_memset(qsa_playback_device, 0x00,
   17.45 -               sizeof(QSA_Device) * QSA_MAX_DEVICES);
   17.46 -    SDL_memset(qsa_capture_device, 0x00,
   17.47 -               sizeof(QSA_Device) * QSA_MAX_DEVICES);
   17.48 +    /* !!! FIXME: we zero these on init...any reason to do it here? */
   17.49 +    SDL_zero(qsa_playback_device);
   17.50 +    SDL_zero(qsa_capture_device);
   17.51      qsa_playback_devices = 0;
   17.52      qsa_capture_devices = 0;
   17.53  }
   17.54 @@ -746,10 +744,8 @@
   17.55      int32_t status = 0;
   17.56  
   17.57      /* Clear devices array */
   17.58 -    SDL_memset(qsa_playback_device, 0x00,
   17.59 -               sizeof(QSA_Device) * QSA_MAX_DEVICES);
   17.60 -    SDL_memset(qsa_capture_device, 0x00,
   17.61 -               sizeof(QSA_Device) * QSA_MAX_DEVICES);
   17.62 +    SDL_zero(qsa_playback_device);
   17.63 +    SDL_zero(qsa_capture_device);
   17.64      qsa_playback_devices = 0;
   17.65      qsa_capture_devices = 0;
   17.66  
    18.1 --- a/src/audio/sndio/SDL_sndioaudio.c	Fri Aug 05 01:44:15 2016 -0400
    18.2 +++ b/src/audio/sndio/SDL_sndioaudio.c	Fri Aug 05 01:59:06 2016 -0400
    18.3 @@ -198,7 +198,7 @@
    18.4      if (this->hidden == NULL) {
    18.5          return SDL_OutOfMemory();
    18.6      }
    18.7 -    SDL_memset(this->hidden, 0, sizeof(*this->hidden));
    18.8 +    SDL_zerop(this->hidden);
    18.9  
   18.10      this->hidden->mixlen = this->spec.size;
   18.11  
    19.1 --- a/src/audio/sun/SDL_sunaudio.c	Fri Aug 05 01:44:15 2016 -0400
    19.2 +++ b/src/audio/sun/SDL_sunaudio.c	Fri Aug 05 01:59:06 2016 -0400
    19.3 @@ -212,7 +212,7 @@
    19.4      if (this->hidden == NULL) {
    19.5          return SDL_OutOfMemory();
    19.6      }
    19.7 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
    19.8 +    SDL_zerop(this->hidden);
    19.9  
   19.10      /* Open the audio device */
   19.11      this->hidden->audio_fd = open(devname, flags, 0);
    20.1 --- a/src/audio/winmm/SDL_winmm.c	Fri Aug 05 01:44:15 2016 -0400
    20.2 +++ b/src/audio/winmm/SDL_winmm.c	Fri Aug 05 01:59:06 2016 -0400
    20.3 @@ -228,7 +228,7 @@
    20.4      if (this->hidden == NULL) {
    20.5          return SDL_OutOfMemory();
    20.6      }
    20.7 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
    20.8 +    SDL_zerop(this->hidden);
    20.9  
   20.10      /* Initialize the wavebuf structures for closing */
   20.11      for (i = 0; i < NUM_BUFFERS; ++i)
   20.12 @@ -305,9 +305,9 @@
   20.13      if (this->hidden->mixbuf == NULL) {
   20.14          return SDL_OutOfMemory();
   20.15      }
   20.16 +
   20.17 +    SDL_zero(this->hidden->wavebuf);
   20.18      for (i = 0; i < NUM_BUFFERS; ++i) {
   20.19 -        SDL_memset(&this->hidden->wavebuf[i], 0,
   20.20 -                   sizeof(this->hidden->wavebuf[i]));
   20.21          this->hidden->wavebuf[i].dwBufferLength = this->spec.size;
   20.22          this->hidden->wavebuf[i].dwFlags = WHDR_DONE;
   20.23          this->hidden->wavebuf[i].lpData =
    21.1 --- a/src/audio/xaudio2/SDL_xaudio2.c	Fri Aug 05 01:44:15 2016 -0400
    21.2 +++ b/src/audio/xaudio2/SDL_xaudio2.c	Fri Aug 05 01:59:06 2016 -0400
    21.3 @@ -342,7 +342,7 @@
    21.4          IXAudio2_Release(ixa2);
    21.5          return SDL_OutOfMemory();
    21.6      }
    21.7 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
    21.8 +    SDL_zerop(this->hidden);
    21.9  
   21.10      this->hidden->ixa2 = ixa2;
   21.11      this->hidden->semaphore = SDL_CreateSemaphore(1);
   21.12 @@ -377,7 +377,7 @@
   21.13          return SDL_OutOfMemory();
   21.14      }
   21.15      this->hidden->nextbuf = this->hidden->mixbuf;
   21.16 -    SDL_memset(this->hidden->mixbuf, 0, 2 * this->hidden->mixlen);
   21.17 +    SDL_memset(this->hidden->mixbuf, this->spec.silence, 2 * this->hidden->mixlen);
   21.18  
   21.19      /* We use XAUDIO2_DEFAULT_CHANNELS instead of this->spec.channels. On
   21.20         Xbox360, this means 5.1 output, but on Windows, it means "figure out