Skip to content

Commit

Permalink
audio: fix popping sounds caused by signed/unsigned conversion
Browse files Browse the repository at this point in the history
When converting audio from signed to unsigned values of vice-versa
the silence value chosen by SDL was the value of the device, not
of the stream that the data was being put into. After conversion
this would lead to a very high or low value, making the speaker
jump to a extreme positon, leading to an audible noise whenever
creating, destroying or playing scilence on a device that reqired
such conversion.
  • Loading branch information
manuelVo committed Sep 26, 2020
1 parent f311e0a commit 554037a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/audio/SDL_audio.c
Expand Up @@ -577,7 +577,7 @@ SDL_BufferQueueDrainCallback(void *userdata, Uint8 *stream, int len)

if (len > 0) { /* fill any remaining space in the stream with silence. */
SDL_assert(SDL_CountDataQueue(device->buffer_queue) == 0);
SDL_memset(stream, device->spec.silence, len);
SDL_memset(stream, device->callbackspec.silence, len);
}
}

Expand Down Expand Up @@ -733,7 +733,7 @@ SDL_RunAudio(void *devicep)
/* !!! FIXME: this should be LockDevice. */
SDL_LockMutex(device->mixer_lock);
if (SDL_AtomicGet(&device->paused)) {
SDL_memset(data, device->spec.silence, data_len);
SDL_memset(data, device->callbackspec.silence, data_len);
} else {
callback(udata, data, data_len);
}
Expand Down

0 comments on commit 554037a

Please sign in to comment.