[pulseaudio-discuss] [PATCH] Fix crash on jack server shutdown

Lennart Poettering lennart at poettering.net
Tue Mar 23 10:05:37 PDT 2010


On Tue, 23.03.10 00:36, David Henningsson (launchpad.web at epost.diwic.se) wrote:

> > What is missing is that the jack loop does not depend on the PA sink to
> > be around resp. the PA IO loop doesn't call into jack when it is
> > dead. If either of that is implemented (and then destruction order
> > matches this) the problem is fixed.
> > 
> > Also, what applies to m-jack-sink needs fixing in m-jack-source, too.
> 
> Good points. I admit to not having checked properly whether
> pa_sink_unlink and pa_sink_render_full can be called in parallell, I see
> now that they shouldn't.

Calling _unlink() and _render_full() at the same time is actually
fine. _unlink() will send a msg to the IO thread to shut down the sink
and will synchronously wait for it. _render_full() is called from the IO
thread. Since the msg dispatching and the _render_full() are run from
the same thread and hence are serialized there is no problem here.

> Since appropriate stream moving is good, and stream moving (apparently)
> needs to do a get-latency call to do its job properly, I would say that
> this was a step in the right direction.

Yes, you definitely found the problem. Only the fix is a bit harder than
anticipated.

> So, let us also send a message to the thread to stop rendering (i e stop
> calling pa_sink_xxx), before the pa_sink_unlink call? If this sounds
> like a good idea to you, I'll prepare a git patch.

Yes, that sounds like a workable solution:

1) first send a synchronous msg from the main thread to the PA IO thread
   to tell it that PA_SINK_MESSAGE_GET_LATENCY shall no longer call into
   libjack. This can be implemented by a simple bool flag that is set on the
   PA IO thread side and which is checked on each _GET_LATENCY that is
   received. Because this msg is synchronous we can guarantee that
   after the msg was fully dispatched the PA IO thread won't hang inside
   a libjack call anymore.

2) We destroy the jack object.

3) We unlink and destroy the PA sink.

AFAICS a logic like that would fix all issues.

Lennart

-- 
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/           GnuPG 0x1A015CC4



More information about the pulseaudio-discuss mailing list