Jindřich Makovička <[email protected]> writes:

> From dd438f5fc92c5b8eb14830b1a81aa9f55d4d11f3 Mon Sep 17 00:00:00 2001
> From: Jindrich Makovicka <[email protected]>
> Date: Fri, 27 May 2011 20:59:20 +0200
> Subject: [PATCH] replace usleep() with nanosleep()
>
> According to usleep() manpage:
>
> POSIX.1-2001 declares this function obsolete; use nanosleep(2) instead.
> POSIX.1-2008 removes the specification of usleep().
>
> Signed-off-by: Jindrich Makovicka <[email protected]>
> ---
>  ffmpeg.c                     |   13 ++++++++++---
>  ffplay.c                     |    8 +++++++-
>  libavdevice/bktr.c           |    7 ++++++-
>  libavformat/applehttp.c      |    7 +++++--
>  libavformat/applehttpproto.c |    5 ++++-
>  libavformat/avio.c           |   10 +++++++---
>  6 files changed, 39 insertions(+), 11 deletions(-)
>
> diff --git a/ffmpeg.c b/ffmpeg.c
> index f27513d..e944b6b 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -1640,8 +1640,12 @@ static int output_packet(AVInputStream *ist, int 
> ist_index,
>          if (rate_emu) {
>              int64_t pts = av_rescale(ist->pts, 1000000, AV_TIME_BASE);
>              int64_t now = av_gettime() - ist->start;
> -            if (pts > now)
> -                usleep(pts - now);
> +            if (pts > now) {
> +                struct timespec ts;
> +                ts.tv_sec = (pts - now) / AV_TIME_BASE;
> +                ts.tv_nsec = ((pts - now) % AV_TIME_BASE) * 1000;
> +                nanosleep(&ts, NULL);
> +            }
>          }

Maybe it's worthwhile putting this in an av_usleep() or similar function.

-- 
Måns Rullgård
[email protected]
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to