Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulseaudio: Termination stream before operation release can lead locking #969

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 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 );
illuusio marked this conversation as resolved.
Show resolved Hide resolved

// 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 );
philburk marked this conversation as resolved.
Show resolved Hide resolved
RossBencina marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
// Result is DONE or CANCEL
PaPulseAudio_UnLock( hostapi->mainloop );
break;
}
PaPulseAudio_UnLock( hostapi->mainloop );
RossBencina marked this conversation as resolved.
Show resolved Hide resolved

waitOperation --;

usleep( 1000 );
}

// No wait if operation have been DONE or CANCELLED
Expand All @@ -156,6 +158,12 @@ void PaPulseAudio_Lock( pa_threaded_mainloop *mainloop )
if( !pa_threaded_mainloop_in_thread( mainloop ) ) {
pa_threaded_mainloop_lock( mainloop );
}
else
{
PA_DEBUG( ("Portaudio %s: Called from event loop thread as value is: %d (not locked)\n",
__FUNCTION__,
pa_threaded_mainloop_in_thread( mainloop )) );
}
}

/* unlocks the Pulse Main loop when not called from it */
Expand All @@ -164,6 +172,12 @@ void PaPulseAudio_UnLock( pa_threaded_mainloop *mainloop )
if( !pa_threaded_mainloop_in_thread( mainloop ) ) {
pa_threaded_mainloop_unlock( mainloop );
}
else
{
PA_DEBUG( ("Portaudio %s: Called from event loop thread as value is: %d (not unlocked)\n",
__FUNCTION__,
pa_threaded_mainloop_in_thread( mainloop )) );
}
}

void _PaPulseAudio_WriteRingBuffer( PaUtilRingBuffer *ringbuffer,
Expand Down
Loading