Skip to content

clock: expose lock

Romain Vimont requested to merge rom1v/vlc:clock_lock into master

Currently, the vout thread waits between prepare() and display() using vlc_clock_Wait().

The caller (the vout thread) provides the steam timestamp and the max duration/deadline, and vlc_clock_Wait() uses the clock state to compute the target system time and wait (in a loop), with internal clock mutex locked.

Since the lock is internal, this prevents the caller to do the following without race conditions:

  1. compute an arbitrary deadline (based on vlc_cond_ConvertToSystem()), then wait using the computed deadline
  2. wake up the wait under its own custom condition (on user interaction for example)

To wait correctly without the display_lock, !324 needs to:

  • compute a custom deadline (substract the estimated prepare() duration expressed in system time)
  • wake up the wait on render invalidation (caused by a resize request from the user for example)

For now, !324 replaced vlc_clock_Wait() by vlc_cond_timedwait() to achieve these goals. However, this temporary solution was incorrect: if the clock coeffs or rate (for example) change, the wait must be interrupted and the deadline must be recomputed.

This MR aims to make this possible, by exposing the clock lock, and directly passing the target deadline (expressed in system time) to vlc_clock_Wait().

Merge request reports