summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMans Rullgard <mans@mansr.com>2012-06-21 20:31:44 +0100
committerMans Rullgard <mans@mansr.com>2012-06-22 17:15:36 +0100
commit896bb0d742a513b1bb5b9a770dbffd2cd436bed6 (patch)
treebc133c53f4cd418c8b42c6d12958e719900ebb6e
parentd3d3a32c9d389cc0d6a91b389988a225ae01c948 (diff)
Replace usleep() calls with av_usleep()
This reduces the dependency on unistd.h which is not available on all systems. Signed-off-by: Mans Rullgard <mans@mansr.com>
-rw-r--r--avconv.c8
-rw-r--r--avplay.c4
-rw-r--r--libavformat/avio.c5
-rw-r--r--libavformat/hls.c4
-rw-r--r--libavformat/hlsproto.c4
-rw-r--r--libavformat/rtmphttp.c5
-rw-r--r--tools/aviocat.c4
-rw-r--r--tools/pktdumper.c3
8 files changed, 18 insertions, 19 deletions
diff --git a/avconv.c b/avconv.c
index 7abf10d7b0..bc6a8fbe06 100644
--- a/avconv.c
+++ b/avconv.c
@@ -27,7 +27,6 @@
#include <errno.h>
#include <signal.h>
#include <limits.h>
-#include <unistd.h>
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
@@ -45,6 +44,7 @@
#include "libavutil/avstring.h"
#include "libavutil/libm.h"
#include "libavutil/imgutils.h"
+#include "libavutil/time.h"
#include "libavformat/os_support.h"
# include "libavfilter/avfilter.h"
@@ -1876,7 +1876,7 @@ static void rate_emu_sleep(InputStream *ist)
int64_t pts = av_rescale(ist->last_dts, 1000000, AV_TIME_BASE);
int64_t now = av_gettime() - ist->start;
if (pts > now)
- usleep(pts - now);
+ av_usleep(pts - now);
}
}
@@ -2793,7 +2793,7 @@ static void *input_thread(void *arg)
ret = av_read_frame(f->ctx, &pkt);
if (ret == AVERROR(EAGAIN)) {
- usleep(10000);
+ av_usleep(10000);
ret = 0;
continue;
} else if (ret < 0)
@@ -2948,7 +2948,7 @@ static int transcode(void)
if (no_packet_count) {
no_packet_count = 0;
memset(no_packet, 0, nb_input_files);
- usleep(10000);
+ av_usleep(10000);
continue;
}
av_log(NULL, AV_LOG_VERBOSE, "No more inputs to read from, finishing.\n");
diff --git a/avplay.c b/avplay.c
index e9389ffe65..6acb6c10e8 100644
--- a/avplay.c
+++ b/avplay.c
@@ -31,6 +31,7 @@
#include "libavutil/dict.h"
#include "libavutil/parseutils.h"
#include "libavutil/samplefmt.h"
+#include "libavutil/time.h"
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
@@ -54,7 +55,6 @@
#undef main /* We don't want SDL to override our main() */
#endif
-#include <unistd.h>
#include <assert.h>
const char program_name[] = "avplay";
@@ -952,7 +952,7 @@ static int refresh_thread(void *opaque)
is->refresh = 1;
SDL_PushEvent(&event);
}
- usleep(is->audio_st && is->show_audio ? rdftspeed * 1000 : 5000); // FIXME ideally we should wait the correct time but SDLs event passing is so slow it would be silly
+ av_usleep(is->audio_st && is->show_audio ? rdftspeed * 1000 : 5000); // FIXME ideally we should wait the correct time but SDLs event passing is so slow it would be silly
}
return 0;
}
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 371500e8a6..5acaf30e90 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -19,11 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <unistd.h>
-
#include "libavutil/avstring.h"
#include "libavutil/dict.h"
#include "libavutil/opt.h"
+#include "libavutil/time.h"
#include "os_support.h"
#include "avformat.h"
#if CONFIG_NETWORK
@@ -237,7 +236,7 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int
if (fast_retries)
fast_retries--;
else
- usleep(1000);
+ av_usleep(1000);
} else if (ret < 1)
return ret < 0 ? ret : len;
if (ret)
diff --git a/libavformat/hls.c b/libavformat/hls.c
index e876735468..253463edf6 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -30,9 +30,9 @@
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/dict.h"
+#include "libavutil/time.h"
#include "avformat.h"
#include "internal.h"
-#include <unistd.h>
#include "avio_internal.h"
#include "url.h"
@@ -407,7 +407,7 @@ reload:
while (av_gettime() - v->last_load_time < reload_interval) {
if (ff_check_interrupt(c->interrupt_callback))
return AVERROR_EXIT;
- usleep(100*1000);
+ av_usleep(100*1000);
}
/* Enough time has elapsed since the last reload */
goto reload;
diff --git a/libavformat/hlsproto.c b/libavformat/hlsproto.c
index 044b7ffe98..179bdf1967 100644
--- a/libavformat/hlsproto.c
+++ b/libavformat/hlsproto.c
@@ -26,11 +26,11 @@
*/
#include "libavutil/avstring.h"
+#include "libavutil/time.h"
#include "avformat.h"
#include "internal.h"
#include "url.h"
#include "version.h"
-#include <unistd.h>
/*
* An apple http stream consists of a playlist with media segment files,
@@ -308,7 +308,7 @@ retry:
while (av_gettime() - s->last_load_time < reload_interval) {
if (ff_check_interrupt(&h->interrupt_callback))
return AVERROR_EXIT;
- usleep(100*1000);
+ av_usleep(100*1000);
}
goto retry;
}
diff --git a/libavformat/rtmphttp.c b/libavformat/rtmphttp.c
index 544b493500..499341a173 100644
--- a/libavformat/rtmphttp.c
+++ b/libavformat/rtmphttp.c
@@ -24,11 +24,10 @@
* RTMP HTTP protocol
*/
-#include <unistd.h>
-
#include "libavutil/avstring.h"
#include "libavutil/intfloat.h"
#include "libavutil/opt.h"
+#include "libavutil/time.h"
#include "internal.h"
#include "http.h"
@@ -126,7 +125,7 @@ static int rtmp_http_read(URLContext *h, uint8_t *buf, int size)
if (rt->nb_bytes_read == 0) {
/* Wait 50ms before retrying to read a server reply in
* order to reduce the number of idle requets. */
- usleep(50000);
+ av_usleep(50000);
}
if ((ret = rtmp_http_write(h, "", 1)) < 0)
diff --git a/tools/aviocat.c b/tools/aviocat.c
index f5da526ba9..52a96bde2f 100644
--- a/tools/aviocat.c
+++ b/tools/aviocat.c
@@ -20,8 +20,8 @@
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
+#include "libavutil/time.h"
#include "libavformat/avformat.h"
static int usage(const char *argv0, int ret)
@@ -82,7 +82,7 @@ int main(int argc, char **argv)
if (bps) {
avio_flush(output);
while ((av_gettime() - start_time) * bps / AV_TIME_BASE < stream_pos)
- usleep(50 * 1000);
+ av_usleep(50 * 1000);
}
}
diff --git a/tools/pktdumper.c b/tools/pktdumper.c
index c3a3a218ef..d23cd9674f 100644
--- a/tools/pktdumper.c
+++ b/tools/pktdumper.c
@@ -25,6 +25,7 @@
#include <string.h>
#include <unistd.h>
+#include "libavutil/time.h"
#include "libavformat/avformat.h"
#define PKTFILESUFF "_%08" PRId64 "_%02d_%010" PRId64 "_%06d_%c.bin"
@@ -122,7 +123,7 @@ int main(int argc, char **argv)
avformat_close_input(&fctx);
while (donotquit)
- usleep(60 * 1000000);
+ av_usleep(60 * 1000000);
return 0;
}