[pulseaudio-discuss] Packagers: Xlib vs XCB
remi at remlab.net
Tue Aug 17 01:00:57 PDT 2010
On Mon, 16 Aug 2010 14:51:48 +0100, Colin Guthrie <gmane at colin.guthr.ie>
> As some of you will have found out, there are some applications that
> have problems relating to Xlib usage (XCloseDisplay() IIRC) when
> combined with PA client libs (notably I've seen reports from VLC
> relating to this).
VLC media player proper works fine with Xlib and PulseAudio (although it
wouldn't to have a PulseAudio expert look at the PulseAudio support).
The Xlib problem can manifest itself in two different ways:
* If a process calls XInitThreads() _after_ XOpenDisplay(), then
XCloseDisplay() will crash trying to acquire a non-existent mutex. This is
typical if you use LibVLC but fail to call XInitThreads() early in your
* If a multi-thread process uses Xlib from more than one thread but never
calls XInitThreads(), then depending on the phase of the moon, then race
conditions might trigger crashes (typically in the form of heap corruption
in my experience) depending on the phase of the moon.
As regards PulseAudio, the issue comes up if libpulse is used from a
different thread than Xlib. Calling XInitThreads() from main is the
"official" solution. Unfortunately, there are many scenarii where this does
not work. You might not have control over the main() function (e.g. the VLC
plugin for Mozilla). Also Xlib might be hidden deep beneath frameworks that
do not call XInitThreads, such as GTK or Qt.
Since libpulse does not really need any Xlib feature not found in XCB, I
humbly think switching to XCB is the best choice. XCB is thread-safe by
default. Thank you for that.
More information about the pulseaudio-discuss