This reduces the dependency on unistd.h which is not available on all systems.
Unified · Split
| @@ -27,7 +27,6 @@ · 26 unmodified lines | ||
| 27 | 27 | #include <errno.h> |
| 28 | 28 | #include <signal.h> |
| 29 | 29 | #include <limits.h> |
| 30 | −#include <unistd.h> | |
| 31 | 30 | #include "libavformat/avformat.h" |
| 32 | 31 | #include "libavdevice/avdevice.h" |
| 33 | 32 | #include "libswscale/swscale.h" |
| @@ -45,6 +44,7 @@ · 11 unmodified lines | ||
| 45 | 44 | #include "libavutil/avstring.h" |
| 46 | 45 | #include "libavutil/libm.h" |
| 47 | 46 | #include "libavutil/imgutils.h" |
| 47 | +#include "libavutil/time.h" | |
| 48 | 48 | #include "libavformat/os_support.h" |
| 49 | 49 | |
| 50 | 50 | # include "libavfilter/avfilter.h" |
| @@ -1876,7 +1876,7 @@ static void rate_emu_sleep(InputStream *ist) · 1825 unmodified lines | ||
| 1876 | 1876 | int64_t pts = av_rescale(ist->last_dts, 1000000, AV_TIME_BASE); |
| 1877 | 1877 | int64_t now = av_gettime() - ist->start; |
| 1878 | 1878 | if (pts > now) |
| 1879 | − usleep(pts - now); | |
| 1879 | + av_usleep(pts - now); | |
| 1880 | 1880 | } |
| 1881 | 1881 | } |
| 1882 | 1882 | |
| @@ -2793,7 +2793,7 @@ static void *input_thread(void *arg) · 910 unmodified lines | ||
| 2793 | 2793 | ret = av_read_frame(f->ctx, &pkt); |
| 2794 | 2794 | |
| 2795 | 2795 | if (ret == AVERROR(EAGAIN)) { |
| 2796 | − usleep(10000); | |
| 2796 | + av_usleep(10000); | |
| 2797 | 2797 | ret = 0; |
| 2798 | 2798 | continue; |
| 2799 | 2799 | } else if (ret < 0) |
| @@ -2948,7 +2948,7 @@ static int transcode(void) · 148 unmodified lines | ||
| 2948 | 2948 | if (no_packet_count) { |
| 2949 | 2949 | no_packet_count = 0; |
| 2950 | 2950 | memset(no_packet, 0, nb_input_files); |
| 2951 | − usleep(10000); | |
| 2951 | + av_usleep(10000); | |
| 2952 | 2952 | continue; |
| 2953 | 2953 | } |
| 2954 | 2954 | av_log(NULL, AV_LOG_VERBOSE, "No more inputs to read from, finishing.\n"); |
| @@ -31,6 +31,7 @@ · 30 unmodified lines | ||
| 31 | 31 | #include "libavutil/dict.h" |
| 32 | 32 | #include "libavutil/parseutils.h" |
| 33 | 33 | #include "libavutil/samplefmt.h" |
| 34 | +#include "libavutil/time.h" | |
| 34 | 35 | #include "libavformat/avformat.h" |
| 35 | 36 | #include "libavdevice/avdevice.h" |
| 36 | 37 | #include "libswscale/swscale.h" |
| @@ -54,7 +55,6 @@ · 17 unmodified lines | ||
| 54 | 55 | #undef main /* We don't want SDL to override our main() */ |
| 55 | 56 | #endif |
| 56 | 57 | |
| 57 | −#include <unistd.h> | |
| 58 | 58 | #include <assert.h> |
| 59 | 59 | |
| 60 | 60 | const char program_name[] = "avplay"; |
| @@ -952,7 +952,7 @@ static int refresh_thread(void *opaque) · 891 unmodified lines | ||
| 952 | 952 | is->refresh = 1; |
| 953 | 953 | SDL_PushEvent(&event); |
| 954 | 954 | } |
| 955 | − 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 | |
| 955 | + 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 | |
| 956 | 956 | } |
| 957 | 957 | return 0; |
| 958 | 958 | } |
| @@ -19,11 +19,10 @@ · 18 unmodified lines | ||
| 19 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | −#include <unistd.h> | |
| 23 | − | |
| 24 | 22 | #include "libavutil/avstring.h" |
| 25 | 23 | #include "libavutil/dict.h" |
| 26 | 24 | #include "libavutil/opt.h" |
| 25 | +#include "libavutil/time.h" | |
| 27 | 26 | #include "os_support.h" |
| 28 | 27 | #include "avformat.h" |
| 29 | 28 | #if CONFIG_NETWORK |
| @@ -237,7 +236,7 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int · 207 unmodified lines | ||
| 237 | 236 | if (fast_retries) |
| 238 | 237 | fast_retries--; |
| 239 | 238 | else |
| 240 | − usleep(1000); | |
| 239 | + av_usleep(1000); | |
| 241 | 240 | } else if (ret < 1) |
| 242 | 241 | return ret < 0 ? ret : len; |
| 243 | 242 | if (ret) |
| @@ -30,9 +30,9 @@ · 29 unmodified lines | ||
| 30 | 30 | #include "libavutil/mathematics.h" |
| 31 | 31 | #include "libavutil/opt.h" |
| 32 | 32 | #include "libavutil/dict.h" |
| 33 | +#include "libavutil/time.h" | |
| 33 | 34 | #include "avformat.h" |
| 34 | 35 | #include "internal.h" |
| 35 | −#include <unistd.h> | |
| 36 | 36 | #include "avio_internal.h" |
| 37 | 37 | #include "url.h" |
| 38 | 38 | |
| @@ -407,7 +407,7 @@ reload: · 368 unmodified lines | ||
| 407 | 407 | while (av_gettime() - v->last_load_time < reload_interval) { |
| 408 | 408 | if (ff_check_interrupt(c->interrupt_callback)) |
| 409 | 409 | return AVERROR_EXIT; |
| 410 | − usleep(100*1000); | |
| 410 | + av_usleep(100*1000); | |
| 411 | 411 | } |
| 412 | 412 | /* Enough time has elapsed since the last reload */ |
| 413 | 413 | goto reload; |
| @@ -26,11 +26,11 @@ · 25 unmodified lines | ||
| 26 | 26 | */ |
| 27 | 27 | |
| 28 | 28 | #include "libavutil/avstring.h" |
| 29 | +#include "libavutil/time.h" | |
| 29 | 30 | #include "avformat.h" |
| 30 | 31 | #include "internal.h" |
| 31 | 32 | #include "url.h" |
| 32 | 33 | #include "version.h" |
| 33 | −#include <unistd.h> | |
| 34 | 34 | |
| 35 | 35 | /* |
| 36 | 36 | * An apple http stream consists of a playlist with media segment files, |
| @@ -308,7 +308,7 @@ retry: · 271 unmodified lines | ||
| 308 | 308 | while (av_gettime() - s->last_load_time < reload_interval) { |
| 309 | 309 | if (ff_check_interrupt(&h->interrupt_callback)) |
| 310 | 310 | return AVERROR_EXIT; |
| 311 | − usleep(100*1000); | |
| 311 | + av_usleep(100*1000); | |
| 312 | 312 | } |
| 313 | 313 | goto retry; |
| 314 | 314 | } |
| @@ -24,11 +24,10 @@ · 23 unmodified lines | ||
| 24 | 24 | * RTMP HTTP protocol |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | −#include <unistd.h> | |
| 28 | − | |
| 29 | 27 | #include "libavutil/avstring.h" |
| 30 | 28 | #include "libavutil/intfloat.h" |
| 31 | 29 | #include "libavutil/opt.h" |
| 30 | +#include "libavutil/time.h" | |
| 32 | 31 | #include "internal.h" |
| 33 | 32 | #include "http.h" |
| 34 | 33 | |
| @@ -126,7 +125,7 @@ static int rtmp_http_read(URLContext *h, uint8_t *buf, int size) · 91 unmodified lines | ||
| 126 | 125 | if (rt->nb_bytes_read == 0) { |
| 127 | 126 | /* Wait 50ms before retrying to read a server reply in |
| 128 | 127 | * order to reduce the number of idle requets. */ |
| 129 | − usleep(50000); | |
| 128 | + av_usleep(50000); | |
| 130 | 129 | } |
| 131 | 130 | |
| 132 | 131 | if ((ret = rtmp_http_write(h, "", 1)) < 0) |
| @@ -20,8 +20,8 @@ · 19 unmodified lines | ||
| 20 | 20 | |
| 21 | 21 | #include <stdio.h> |
| 22 | 22 | #include <stdlib.h> |
| 23 | −#include <unistd.h> | |
| 24 | 23 | |
| 24 | +#include "libavutil/time.h" | |
| 25 | 25 | #include "libavformat/avformat.h" |
| 26 | 26 | |
| 27 | 27 | static int usage(const char *argv0, int ret) |
| @@ -82,7 +82,7 @@ int main(int argc, char **argv) · 54 unmodified lines | ||
| 82 | 82 | if (bps) { |
| 83 | 83 | avio_flush(output); |
| 84 | 84 | while ((av_gettime() - start_time) * bps / AV_TIME_BASE < stream_pos) |
| 85 | − usleep(50 * 1000); | |
| 85 | + av_usleep(50 * 1000); | |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| @@ -25,6 +25,7 @@ · 24 unmodified lines | ||
| 25 | 25 | #include <string.h> |
| 26 | 26 | #include <unistd.h> |
| 27 | 27 | |
| 28 | +#include "libavutil/time.h" | |
| 28 | 29 | #include "libavformat/avformat.h" |
| 29 | 30 | |
| 30 | 31 | #define PKTFILESUFF "_%08" PRId64 "_%02d_%010" PRId64 "_%06d_%c.bin" |
| @@ -122,7 +123,7 @@ int main(int argc, char **argv) · 91 unmodified lines | ||
| 122 | 123 | avformat_close_input(&fctx); |
| 123 | 124 | |
| 124 | 125 | while (donotquit) |
| 125 | − usleep(60 * 1000000); | |
| 126 | + av_usleep(60 * 1000000); | |
| 126 | 127 | |
| 127 | 128 | return 0; |
| 128 | 129 | } |