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 5256

Summary: [PATCH] Don't assign context variables until pulse audio has connected.
Product: SDL Reporter: Alistair Leslie-Hughes <leslie_alistair>
Component: audioAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: sezeroz, vwcjtblat
Version: HG 2.1   
Hardware: x86_64   
OS: Linux   
Attachments: Dont assign the context patch.

Description Alistair Leslie-Hughes 2020-08-14 03:26:12 UTC
Created attachment 4436 [details]
Dont assign the context patch.

When pulse audio fails to connect to the sever we have two variables that have been initialized which cause asserts in pa when the CloseDevice is called.

SDL correct detects that we have failed to connect, when the it attempts to die the close_device, we get the follow error

Assertion 'pa_atomic_load(&(c)->_ref) >= 1' failed at pulse/context.c:1055, function pa_context_disconnect(). Aborting.

This then crashes the application.

Attached is a patch, which only assigns the passed in variables once a successfully connection to Pulse Audio server has been made.
Comment 1 Sam Lantinga 2020-12-09 14:49:16 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/48bfca44e385