audio: changed some SDL_memset() calls to SDL_zero(), other minor corrections.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c
index 99daac6..d173b4a 100644
--- a/src/audio/SDL_wave.c
+++ b/src/audio/SDL_wave.c
@@ -504,7 +504,7 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
was_error = 1;
goto done;
}
- SDL_memset(spec, 0, (sizeof *spec));
+ SDL_zerop(spec);
spec->freq = SDL_SwapLE32(format->frequency);
if (IEEE_float_encoded) {
diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c
index 833c5ce..b029b66 100644
--- a/src/audio/alsa/SDL_alsa_audio.c
+++ b/src/audio/alsa/SDL_alsa_audio.c
@@ -539,7 +539,7 @@ ALSA_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, (sizeof *this->hidden));
+ SDL_zerop(this->hidden);
/* Open the audio device */
/* Name of device should depend on # channels in spec */
diff --git a/src/audio/arts/SDL_artsaudio.c b/src/audio/arts/SDL_artsaudio.c
index 91d1d04..a7e4aa6 100644
--- a/src/audio/arts/SDL_artsaudio.c
+++ b/src/audio/arts/SDL_artsaudio.c
@@ -235,7 +235,7 @@ ARTS_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, (sizeof *this->hidden));
+ SDL_zerop(this->hidden);
/* Try for a closest match on audio format */
for (test_format = SDL_FirstAudioFormat(this->spec.format);
diff --git a/src/audio/bsd/SDL_bsdaudio.c b/src/audio/bsd/SDL_bsdaudio.c
index 1d9da4e..6a970b9 100644
--- a/src/audio/bsd/SDL_bsdaudio.c
+++ b/src/audio/bsd/SDL_bsdaudio.c
@@ -297,7 +297,7 @@ BSDAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, (sizeof *this->hidden));
+ SDL_zerop(this->hidden);
/* Open the audio device */
this->hidden->audio_fd = open(devname, flags, 0);
diff --git a/src/audio/directsound/SDL_directsound.c b/src/audio/directsound/SDL_directsound.c
index 5450a43..0f17362 100644
--- a/src/audio/directsound/SDL_directsound.c
+++ b/src/audio/directsound/SDL_directsound.c
@@ -431,7 +431,7 @@ DSOUND_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, (sizeof *this->hidden));
+ SDL_zerop(this->hidden);
/* Open the audio device */
result = pDirectSoundCreate8(guid, &this->hidden->sound, NULL);
diff --git a/src/audio/disk/SDL_diskaudio.c b/src/audio/disk/SDL_diskaudio.c
index fb684d2..97f979b 100644
--- a/src/audio/disk/SDL_diskaudio.c
+++ b/src/audio/disk/SDL_diskaudio.c
@@ -105,7 +105,7 @@ DISKAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, sizeof(*this->hidden));
+ SDL_zerop(this->hidden);
this->hidden->mixlen = this->spec.size;
this->hidden->write_delay =
diff --git a/src/audio/dsp/SDL_dspaudio.c b/src/audio/dsp/SDL_dspaudio.c
index 3bfdb98..f267f84 100644
--- a/src/audio/dsp/SDL_dspaudio.c
+++ b/src/audio/dsp/SDL_dspaudio.c
@@ -100,7 +100,7 @@ DSP_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, (sizeof *this->hidden));
+ SDL_zerop(this->hidden);
/* Open the audio device */
this->hidden->audio_fd = open(devname, flags, 0);
diff --git a/src/audio/emscripten/SDL_emscriptenaudio.c b/src/audio/emscripten/SDL_emscriptenaudio.c
index a354aaf..e3251db 100644
--- a/src/audio/emscripten/SDL_emscriptenaudio.c
+++ b/src/audio/emscripten/SDL_emscriptenaudio.c
@@ -171,7 +171,7 @@ Emscripten_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, (sizeof *this->hidden));
+ SDL_zerop(this->hidden);
/* based on parts of library_sdl.js */
diff --git a/src/audio/esd/SDL_esdaudio.c b/src/audio/esd/SDL_esdaudio.c
index f80f3dd..3eb7197 100644
--- a/src/audio/esd/SDL_esdaudio.c
+++ b/src/audio/esd/SDL_esdaudio.c
@@ -220,7 +220,7 @@ ESD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, (sizeof *this->hidden));
+ SDL_zerop(this->hidden);
this->hidden->audio_fd = -1;
/* Convert audio spec to the ESD audio format */
diff --git a/src/audio/fusionsound/SDL_fsaudio.c b/src/audio/fusionsound/SDL_fsaudio.c
index 72c8309..00f015b 100644
--- a/src/audio/fusionsound/SDL_fsaudio.c
+++ b/src/audio/fusionsound/SDL_fsaudio.c
@@ -195,7 +195,7 @@ SDL_FS_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, (sizeof *this->hidden));
+ SDL_zerop(this->hidden);
/* Try for a closest match on audio format */
for (test_format = SDL_FirstAudioFormat(this->spec.format);
diff --git a/src/audio/haiku/SDL_haikuaudio.cc b/src/audio/haiku/SDL_haikuaudio.cc
index 31543f3..e4a3307 100644
--- a/src/audio/haiku/SDL_haikuaudio.cc
+++ b/src/audio/haiku/SDL_haikuaudio.cc
@@ -118,10 +118,10 @@ HAIKUAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (_this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(_this->hidden, 0, (sizeof *_this->hidden));
+ SDL_zerop(this->hidden);
/* Parse the audio format and fill the Be raw audio format */
- SDL_memset(&format, '\0', sizeof(media_raw_audio_format));
+ SDL_zero(format);
format.byte_order = B_MEDIA_LITTLE_ENDIAN;
format.frame_rate = (float) _this->spec.freq;
format.channel_count = _this->spec.channels; /* !!! FIXME: support > 2? */
diff --git a/src/audio/nacl/SDL_naclaudio.c b/src/audio/nacl/SDL_naclaudio.c
index 5b8c2dd..b85eab2 100644
--- a/src/audio/nacl/SDL_naclaudio.c
+++ b/src/audio/nacl/SDL_naclaudio.c
@@ -65,7 +65,7 @@ static void nacl_audio_callback(void* samples, uint32_t buffer_size, PP_TimeDelt
SDL_UnlockMutex(_this->mixer_lock);
}
} else {
- SDL_memset(samples, 0, buffer_size);
+ SDL_memset(samples, _this->spec.silence, buffer_size);
}
SDL_UnlockMutex(private->mutex);
diff --git a/src/audio/nas/SDL_nasaudio.c b/src/audio/nas/SDL_nasaudio.c
index c9b39c6..a4236ae 100644
--- a/src/audio/nas/SDL_nasaudio.c
+++ b/src/audio/nas/SDL_nasaudio.c
@@ -282,7 +282,7 @@ NAS_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, (sizeof *this->hidden));
+ SDL_zerop(this->hidden);
/* Try for a closest match on audio format */
format = 0;
diff --git a/src/audio/paudio/SDL_paudio.c b/src/audio/paudio/SDL_paudio.c
index 9191a3e..5720224 100644
--- a/src/audio/paudio/SDL_paudio.c
+++ b/src/audio/paudio/SDL_paudio.c
@@ -256,7 +256,7 @@ PAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, (sizeof *this->hidden));
+ SDL_zerop(this->hidden);
/* Open the audio device */
fd = OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 0);
diff --git a/src/audio/psp/SDL_pspaudio.c b/src/audio/psp/SDL_pspaudio.c
index f29f85a..176aed4 100644
--- a/src/audio/psp/SDL_pspaudio.c
+++ b/src/audio/psp/SDL_pspaudio.c
@@ -50,7 +50,7 @@ PSPAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, sizeof(*this->hidden));
+ SDL_zerop(this->hidden);
switch (this->spec.format & 0xff) {
case 8:
case 16:
diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c
index 1ac772c..64fc5d3 100644
--- a/src/audio/pulseaudio/SDL_pulseaudio.c
+++ b/src/audio/pulseaudio/SDL_pulseaudio.c
@@ -529,13 +529,12 @@ PULSEAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
int rc = 0;
/* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
+ h = this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc((sizeof *this->hidden));
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, (sizeof *this->hidden));
- h = this->hidden;
+ SDL_zerop(this->hidden);
paspec.format = PA_SAMPLE_INVALID;
diff --git a/src/audio/qsa/SDL_qsa_audio.c b/src/audio/qsa/SDL_qsa_audio.c
index a4384e7..4ca7a12 100644
--- a/src/audio/qsa/SDL_qsa_audio.c
+++ b/src/audio/qsa/SDL_qsa_audio.c
@@ -137,8 +137,7 @@ QSA_ThreadInit(_THIS)
static void
QSA_InitAudioParams(snd_pcm_channel_params_t * cpars)
{
- SDL_memset(cpars, 0, sizeof(snd_pcm_channel_params_t));
-
+ SDL_zerop(cpars);
cpars->channel = SND_PCM_CHANNEL_PLAYBACK;
cpars->mode = SND_PCM_MODE_BLOCK;
cpars->start_mode = SND_PCM_START_DATA;
@@ -261,7 +260,7 @@ QSA_PlayDevice(_THIS)
continue;
} else {
if ((errno == EINVAL) || (errno == EIO)) {
- SDL_memset(&cstatus, 0, sizeof(cstatus));
+ SDL_zero(cstatus);
if (!this->hidden->iscapture) {
cstatus.channel = SND_PCM_CHANNEL_PLAYBACK;
} else {
@@ -358,7 +357,7 @@ QSA_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, sizeof(struct SDL_PrivateAudioData));
+ SDL_zerop(this->hidden);
/* Initialize channel transfer parameters to default */
QSA_InitAudioParams(&cparams);
@@ -499,7 +498,7 @@ QSA_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
}
/* Make sure channel is setup right one last time */
- SDL_memset(&csetup, 0, sizeof(csetup));
+ SDL_zero(csetup);
if (!this->hidden->iscapture) {
csetup.channel = SND_PCM_CHANNEL_PLAYBACK;
} else {
@@ -731,10 +730,9 @@ static void
QSA_Deinitialize(void)
{
/* Clear devices array on shutdown */
- SDL_memset(qsa_playback_device, 0x00,
- sizeof(QSA_Device) * QSA_MAX_DEVICES);
- SDL_memset(qsa_capture_device, 0x00,
- sizeof(QSA_Device) * QSA_MAX_DEVICES);
+ /* !!! FIXME: we zero these on init...any reason to do it here? */
+ SDL_zero(qsa_playback_device);
+ SDL_zero(qsa_capture_device);
qsa_playback_devices = 0;
qsa_capture_devices = 0;
}
@@ -746,10 +744,8 @@ QSA_Init(SDL_AudioDriverImpl * impl)
int32_t status = 0;
/* Clear devices array */
- SDL_memset(qsa_playback_device, 0x00,
- sizeof(QSA_Device) * QSA_MAX_DEVICES);
- SDL_memset(qsa_capture_device, 0x00,
- sizeof(QSA_Device) * QSA_MAX_DEVICES);
+ SDL_zero(qsa_playback_device);
+ SDL_zero(qsa_capture_device);
qsa_playback_devices = 0;
qsa_capture_devices = 0;
diff --git a/src/audio/sndio/SDL_sndioaudio.c b/src/audio/sndio/SDL_sndioaudio.c
index 309e503..797204f 100644
--- a/src/audio/sndio/SDL_sndioaudio.c
+++ b/src/audio/sndio/SDL_sndioaudio.c
@@ -198,7 +198,7 @@ SNDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, sizeof(*this->hidden));
+ SDL_zerop(this->hidden);
this->hidden->mixlen = this->spec.size;
diff --git a/src/audio/sun/SDL_sunaudio.c b/src/audio/sun/SDL_sunaudio.c
index fb90146..b994c12 100644
--- a/src/audio/sun/SDL_sunaudio.c
+++ b/src/audio/sun/SDL_sunaudio.c
@@ -212,7 +212,7 @@ SUNAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, (sizeof *this->hidden));
+ SDL_zerop(this->hidden);
/* Open the audio device */
this->hidden->audio_fd = open(devname, flags, 0);
diff --git a/src/audio/winmm/SDL_winmm.c b/src/audio/winmm/SDL_winmm.c
index 6ef8932..da9312d 100644
--- a/src/audio/winmm/SDL_winmm.c
+++ b/src/audio/winmm/SDL_winmm.c
@@ -228,7 +228,7 @@ WINMM_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (this->hidden == NULL) {
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, (sizeof *this->hidden));
+ SDL_zerop(this->hidden);
/* Initialize the wavebuf structures for closing */
for (i = 0; i < NUM_BUFFERS; ++i)
@@ -305,9 +305,9 @@ WINMM_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
if (this->hidden->mixbuf == NULL) {
return SDL_OutOfMemory();
}
+
+ SDL_zero(this->hidden->wavebuf);
for (i = 0; i < NUM_BUFFERS; ++i) {
- SDL_memset(&this->hidden->wavebuf[i], 0,
- sizeof(this->hidden->wavebuf[i]));
this->hidden->wavebuf[i].dwBufferLength = this->spec.size;
this->hidden->wavebuf[i].dwFlags = WHDR_DONE;
this->hidden->wavebuf[i].lpData =
diff --git a/src/audio/xaudio2/SDL_xaudio2.c b/src/audio/xaudio2/SDL_xaudio2.c
index b300bcd..1724e31 100644
--- a/src/audio/xaudio2/SDL_xaudio2.c
+++ b/src/audio/xaudio2/SDL_xaudio2.c
@@ -342,7 +342,7 @@ XAUDIO2_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
IXAudio2_Release(ixa2);
return SDL_OutOfMemory();
}
- SDL_memset(this->hidden, 0, (sizeof *this->hidden));
+ SDL_zerop(this->hidden);
this->hidden->ixa2 = ixa2;
this->hidden->semaphore = SDL_CreateSemaphore(1);
@@ -377,7 +377,7 @@ XAUDIO2_OpenDevice(_THIS, void *handle, const char *devname, int iscapture)
return SDL_OutOfMemory();
}
this->hidden->nextbuf = this->hidden->mixbuf;
- SDL_memset(this->hidden->mixbuf, 0, 2 * this->hidden->mixlen);
+ SDL_memset(this->hidden->mixbuf, this->spec.silence, 2 * this->hidden->mixlen);
/* We use XAUDIO2_DEFAULT_CHANNELS instead of this->spec.channels. On
Xbox360, this means 5.1 output, but on Windows, it means "figure out