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 4155

Summary: On iOS, audio skips when suspending and resuming
Product: SDL Reporter: philhassey <phil>
Component: audioAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: phil
Version: 2.0.8   
Hardware: iPhone/iPod touch   
OS: iOS 11   
Attachments: audio thread priority patch

Description philhassey 2018-05-04 17:48:12 UTC
Created attachment 3236 [details]
audio thread priority patch

I've noticed that the audio skips really badly during suspending and resuming on iOS.  Sometimes it skips other times as well.

This issue is new to versions of SDL2 that use core audio.

I'm using these settings:

want.freq = 44100;
want.format = AUDIO_F32SYS;
want.channels = 2;
want.samples = 1024;

I've attached a patch that sets the audio thread priority to HIGH which largely resolves the issue.
Comment 1 Sam Lantinga 2018-05-05 17:37:05 UTC
The iOS audio code has been changed, can you check the latest version and see if the issue still happens, and if so, can you provide an updated patch?
http://www.libsdl.org/tmp/SDL-2.0.zip

Thanks!
Comment 2 philhassey 2018-05-05 18:30:35 UTC
The coreaudio code contained in SDL-2.0.8-11956 appears to resolve the issue.  Thanks!
Comment 3 Sam Lantinga 2018-05-06 02:11:32 UTC
You're welcome!
Comment 4 Ryan C. Gordon 2019-03-25 17:00:33 UTC
Just backed out the code that solved this previously, so this commit should _also_ fix this for 2.0.10, if you find yourself in a position to verify the latest in revision control: https://hg.libsdl.org/SDL/rev/a7b99312d9f3

--ryan.