lavf: Use av_gettime_relative()

Whenever av_gettime() is used to measure relative period of time,
av_gettime_relative() is prefered as it guarantee monotonic time
on supported platforms.

Signed-off-by: Olivier Langlois <olivier@trillion01.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/68/head
Olivier Langlois 11 years ago committed by Michael Niedermayer
parent 9986e50a6e
commit f78bc96b7c
  1. 4
      libavformat/avio.c
  2. 4
      libavformat/network.c
  3. 2
      libavformat/sapenc.c

@ -312,8 +312,8 @@ static inline int retry_transfer_wrapper(URLContext *h, uint8_t *buf,
} else { } else {
if (h->rw_timeout) { if (h->rw_timeout) {
if (!wait_since) if (!wait_since)
wait_since = av_gettime(); wait_since = av_gettime_relative();
else if (av_gettime() > wait_since + h->rw_timeout) else if (av_gettime_relative() > wait_since + h->rw_timeout)
return AVERROR(EIO); return AVERROR(EIO);
} }
av_usleep(1000); av_usleep(1000);

@ -163,8 +163,8 @@ int ff_network_wait_fd_timeout(int fd, int write, int64_t timeout, AVIOInterrupt
return ret; return ret;
if (timeout > 0) { if (timeout > 0) {
if (!wait_start) if (!wait_start)
wait_start = av_gettime(); wait_start = av_gettime_relative();
else if (av_gettime() - wait_start > timeout) else if (av_gettime_relative() - wait_start > timeout)
return AVERROR(ETIMEDOUT); return AVERROR(ETIMEDOUT);
} }
} }

@ -245,7 +245,7 @@ static int sap_write_packet(AVFormatContext *s, AVPacket *pkt)
{ {
AVFormatContext *rtpctx; AVFormatContext *rtpctx;
struct SAPState *sap = s->priv_data; struct SAPState *sap = s->priv_data;
int64_t now = av_gettime(); int64_t now = av_gettime_relative();
if (!sap->last_time || now - sap->last_time > 5000000) { if (!sap->last_time || now - sap->last_time > 5000000) {
int ret = ffurl_write(sap->ann_fd, sap->ann, sap->ann_size); int ret = ffurl_write(sap->ann_fd, sap->ann, sap->ann_size);

Loading…
Cancel
Save