[vlc-devel] [PATCH] vout: set the thread in sleep state when a deadline is provided

Rémi Denis-Courmont remi at remlab.net
Tue Feb 18 19:15:44 CET 2014


Le mardi 18 février 2014, 19:04:53 Felix Abecassis a écrit :
> Previously, the is_sleeping flag was not set to true if a deadline was
> passed to vout_control_Pop. Consequently, the condition variable would
> not be signalled by function vout_control_Wake, called by
> vout_PutPicture to give a vout a picture to display. Thus, the vout
> would not wake up even when receiving several pictures, instead the
> vout waits until the end of the deadline. If the deadline was computed
> as the "refresh" deadline from ThreadDisplayPicture, the sleep time
> can be as high as 60-70 ms.
> ---
>  src/video_output/control.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/src/video_output/control.c b/src/video_output/control.c
> index 930e09b..c880775 100644
> --- a/src/video_output/control.c
> +++ b/src/video_output/control.c
> @@ -189,14 +189,14 @@ int vout_control_Pop(vout_control_t *ctrl,
> vout_control_cmd_t *cmd, const mtime_t max_deadline = mdate() + timeout;
> 
>          /* Supurious wake up are perfectly fine */
> -        if (deadline <= VLC_TS_INVALID) {
> -            ctrl->is_sleeping = true;
> -            if (ctrl->can_sleep)
> +        ctrl->is_sleeping = true;
> +        if (ctrl->can_sleep) {
> +            if (deadline <= VLC_TS_INVALID)
>                  vlc_cond_timedwait(&ctrl->wait_request, &ctrl->lock,
> max_deadline); -            ctrl->is_sleeping = false;
> -        } else {
> -            vlc_cond_timedwait(&ctrl->wait_request, &ctrl->lock,
> __MIN(deadline, max_deadline)); +            else
> +                vlc_cond_timedwait(&ctrl->wait_request, &ctrl->lock,
> __MIN(deadline, max_deadline)); }
> +        ctrl->is_sleeping = false;

It looks OK. Though the timedwait call could be factored and the comment typo 
fixed too. In fact, is_sleeping could probably be removed altogether.

>      }
> 
>      bool has_cmd;

-- 
Реми Денис-Курмон
http://www.remlab.net/




More information about the vlc-devel mailing list