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 Nov 24, 2024
1 parent cf218ed commit 758d5a4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/hostapi/pulseaudio/pa_linux_pulseaudio_cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,23 @@ void PaPulseAudio_ReleaseOperation(PaPulseAudio_HostApiRepresentation *hostapi,

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

PaPulseAudio_Lock( hostapi->mainloop );
localOperationState = pa_operation_get_state( localOperation );

// No wait if operation have been DONE or CANCELLED
if( localOperationState != PA_OPERATION_RUNNING)
if( localOperationState == PA_OPERATION_RUNNING )
{
pa_threaded_mainloop_wait( hostapi->mainloop );
}
else
{
// Result is DONE or CANCEL
PaPulseAudio_UnLock( hostapi->mainloop );
break;
}
PaPulseAudio_UnLock( hostapi->mainloop );

waitOperation --;

usleep( 1000 );
}

// No wait if operation have been DONE or CANCELLED
Expand Down

0 comments on commit 758d5a4

Please sign in to comment.