# Threading with VLC

VLC is a multi-thread application. We chose against a single-thread approach because decoder preemptibility and scheduling would be a mastermind (for instance decoders and outputs have to be separated, otherwise it cannot be warrantied that a frame will be played at the exact presentation time), and we currently have no plan to support a single-threaded client. Multi-process decoders usually imply more overhead (problems of shared memory) and communication between processes is harder.

## VLC's threading API

For portability, VLC provides a wrapper for native threading API. It is modelled on the pthread library.

Our wrapper consists of the following functions:

- `vlc_thread_create`

- `vlc_thread_exit`

- `vlc_thread_join`

- `vlc_mutex_init`

- `vlc_mutex_lock`

- `vlc_mutex_unlock`

- `vlc_mutex_destroy`

- `vlc_cond_init`

- `vlc_cond_signal`

- `vlc_cond_broadcast`

- `vlc_cond_wait`

- `vlc_cond_destroy`

Corresponding data structures are vlc_thread_t, vlc_mutex_t, and vlc_cond_t.