[pulseaudio-discuss] Packagers: Xlib vs XCB

Colin Guthrie gmane at colin.guthr.ie
Tue Aug 17 07:32:47 PDT 2010

'Twas brillig, and Rémi Denis-Courmont at 17/08/10 09:00 did gyre and
> On Mon, 16 Aug 2010 14:51:48 +0100, Colin Guthrie <gmane at colin.guthr.ie>
> wrote:
>> 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
> main() function.
> * 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.

Thanks Rémi for the detailed description :)



Colin Guthrie

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]

More information about the pulseaudio-discuss mailing list