We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5301

Summary: [patch] audio: fix popping sounds caused by signed/unsigned conversion
Product: SDL Reporter: Manuel Vögele <develop>
Component: audioAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: develop, sezeroz
Version: HG 2.0Keywords: target-2.0.14
Hardware: x86_64   
OS: Linux   
Attachments: Patch that fixes the popping sounds caused by signed/unsigned conversion

Description Manuel Vögele 2020-09-26 11:13:44 UTC
Created attachment 4473 [details]
Patch that fixes the popping sounds caused by signed/unsigned conversion

Currently when SDL needs to convert audio for playback from an signed to an unsigned value (or vice versa) it outputs an either very high or very low silence value, leading to a popping sound and distortion in the audio playback of other applications (due to clipping) whenever a device requiring such a conversion plays back silence (because of being paused or having an empty audio queue). This happens because the silence value written into the stream (for later conversion to the audio devices format) isn't chosen based on the spec of that stream but based on the spec of the audio device. This leads to a wrong, extreme silence value which causes the described behavior.

This patch addresses that issue by taking the silence value that's put into the stream from the stream's spec.

This patch might be related to this bug: https://bugzilla.libsdl.org/show_bug.cgi?id=4805
Comment 1 Ryan C. Gordon 2020-10-20 14:47:06 UTC
Good catch! This patch is now https://hg.libsdl.org/SDL/rev/828db31f6a57, thanks!

--ryan.