1 <chapter><title>Threading with VLC</title>
3 <para>VLC is a multi-thread application. We chose against a single-thread
4 approach because decoder preemptibility and scheduling would be a
5 mastermind (for instance decoders and outputs have to be separated,
6 otherwise it cannot be warrantied that a frame will be played at the
7 exact presentation time), and we currently have no plan to support a
8 single-threaded client. Multi-process decoders usually imply more overhead
9 (problems of shared memory) and communication between processes is harder.
13 <sect1><title>VLC's threading API</title>
15 <para>For portability, VLC provides a wrapper for native threading API.
16 It is modelled on the pthread library.</para>
18 <para>Our wrapper consists of the following functions:</para>
21 <listitem><para><function>vlc_thread_create</function></para></listitem>
22 <listitem><para> <function>vlc_thread_exit</function></para></listitem>
23 <listitem><para> <function>vlc_thread_join</function></para></listitem>
24 <listitem><para> <function>vlc_mutex_init</function></para></listitem>
25 <listitem><para> <function>vlc_mutex_lock</function></para></listitem>
26 <listitem><para> <function>vlc_mutex_unlock</function></para></listitem>
27 <listitem><para> <function>vlc_mutex_destroy</function></para></listitem>
28 <listitem><para> <function>vlc_cond_init</function></para></listitem>
29 <listitem><para> <function>vlc_cond_signal</function></para></listitem>
30 <listitem><para> <function>vlc_cond_broadcast</function></para></listitem>
31 <listitem><para> <function>vlc_cond_wait</function></para></listitem>
32 <listitem><para> <function>vlc_cond_destroy</function></para></listitem>
35 <para>Corresponding data structures are <type>vlc_thread_t</type>,
36 <type>vlc_mutex_t</type>, and <type>vlc_cond_t</type>. </para>