Skip to content

Commit

Permalink
Pulseaudio: Termination stream before operation release can lead locking
Browse files Browse the repository at this point in the history
Cases when Pulseaudio server releases stream before operation releasing
can be lead locking in pa_threaded_mainloop_wait forever.

Test if operation is running before running pa_threaded_mainloop_wait
which should prevent forever waiting releasing lock.
  • Loading branch information
illuusio committed Oct 19, 2024
1 parent 57aa393 commit 56025bb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/hostapi/pulseaudio/pa_linux_pulseaudio_cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,15 @@ void PaPulseAudio_ReleaseOperation(PaPulseAudio_HostApiRepresentation *hostapi,

while( waitOperation > 0 )
{
PaPulseAudio_Lock( hostapi->mainloop );
pa_threaded_mainloop_wait( hostapi->mainloop );
PaPulseAudio_UnLock( hostapi->mainloop );

localOperationState = pa_operation_get_state( localOperation );

if( localOperationState == PA_OPERATION_RUNNING )
{
PaPulseAudio_Lock( hostapi->mainloop );
pa_threaded_mainloop_wait( hostapi->mainloop );
PaPulseAudio_UnLock( hostapi->mainloop );
}

// No wait if operation have been DONE or CANCELLED
if( localOperationState != PA_OPERATION_RUNNING)
{
Expand Down

0 comments on commit 56025bb

Please sign in to comment.