user avatar
PulseAudio: fix a pthread_mutex crash in error path
Bartosz Golaszewski authored
QSoundEffect (pulseaudio) uses a workaround for stability issues:
although the pulseaudio mainloop mutex is recursive, it utilizes a
separate lock counting. This is not the best solution, but it is a
part of a larger set of changes which improved the stability in CI
under heavy load.

QSoundEffect always calls pa_threaded_mainloop_lock/unlock() from the
same thread so the additional lock counting works in normal situation
even though it doesn't use atomic types.

However if pa_context_connect() fails, pa_threaded_mainloop_unlock()
is called without regard to current lock count. This leads to random
double-unlock aborts if pa_context_connect() fails more than once
(e.g. after the reconnect scheduled from onContextFailed()).

Fix this by always using the PulseDaemon wrappers around
pa_threaded_mainloop_lock/unlock().

Task-number: QTBUG-61725
Change-Id: I41eb9a76892a6646fd5620ef8f686473b339464f
Reviewed-by: default avatarChristian Stromme <christian.stromme@qt.io>
53538ff9