This reduces the dependency on unistd.h which is not available on all systems. Signed-off-by: Mans Rullgard <mans@mansr.com>tags/n1.0
| @@ -27,7 +27,6 @@ | |||||
| #include <errno.h> | #include <errno.h> | ||||
| #include <signal.h> | #include <signal.h> | ||||
| #include <limits.h> | #include <limits.h> | ||||
| #include <unistd.h> | |||||
| #include "libavformat/avformat.h" | #include "libavformat/avformat.h" | ||||
| #include "libavdevice/avdevice.h" | #include "libavdevice/avdevice.h" | ||||
| #include "libswscale/swscale.h" | #include "libswscale/swscale.h" | ||||
| @@ -45,6 +44,7 @@ | |||||
| #include "libavutil/avstring.h" | #include "libavutil/avstring.h" | ||||
| #include "libavutil/libm.h" | #include "libavutil/libm.h" | ||||
| #include "libavutil/imgutils.h" | #include "libavutil/imgutils.h" | ||||
| #include "libavutil/time.h" | |||||
| #include "libavformat/os_support.h" | #include "libavformat/os_support.h" | ||||
| # include "libavfilter/avfilter.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 pts = av_rescale(ist->last_dts, 1000000, AV_TIME_BASE); | ||||
| int64_t now = av_gettime() - ist->start; | int64_t now = av_gettime() - ist->start; | ||||
| if (pts > now) | 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); | ret = av_read_frame(f->ctx, &pkt); | ||||
| if (ret == AVERROR(EAGAIN)) { | if (ret == AVERROR(EAGAIN)) { | ||||
| usleep(10000); | |||||
| av_usleep(10000); | |||||
| ret = 0; | ret = 0; | ||||
| continue; | continue; | ||||
| } else if (ret < 0) | } else if (ret < 0) | ||||
| @@ -2948,7 +2948,7 @@ static int transcode(void) | |||||
| if (no_packet_count) { | if (no_packet_count) { | ||||
| no_packet_count = 0; | no_packet_count = 0; | ||||
| memset(no_packet, 0, nb_input_files); | memset(no_packet, 0, nb_input_files); | ||||
| usleep(10000); | |||||
| av_usleep(10000); | |||||
| continue; | continue; | ||||
| } | } | ||||
| av_log(NULL, AV_LOG_VERBOSE, "No more inputs to read from, finishing.\n"); | av_log(NULL, AV_LOG_VERBOSE, "No more inputs to read from, finishing.\n"); | ||||
| @@ -31,6 +31,7 @@ | |||||
| #include "libavutil/dict.h" | #include "libavutil/dict.h" | ||||
| #include "libavutil/parseutils.h" | #include "libavutil/parseutils.h" | ||||
| #include "libavutil/samplefmt.h" | #include "libavutil/samplefmt.h" | ||||
| #include "libavutil/time.h" | |||||
| #include "libavformat/avformat.h" | #include "libavformat/avformat.h" | ||||
| #include "libavdevice/avdevice.h" | #include "libavdevice/avdevice.h" | ||||
| #include "libswscale/swscale.h" | #include "libswscale/swscale.h" | ||||
| @@ -54,7 +55,6 @@ | |||||
| #undef main /* We don't want SDL to override our main() */ | #undef main /* We don't want SDL to override our main() */ | ||||
| #endif | #endif | ||||
| #include <unistd.h> | |||||
| #include <assert.h> | #include <assert.h> | ||||
| const char program_name[] = "avplay"; | const char program_name[] = "avplay"; | ||||
| @@ -952,7 +952,7 @@ static int refresh_thread(void *opaque) | |||||
| is->refresh = 1; | is->refresh = 1; | ||||
| SDL_PushEvent(&event); | 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; | return 0; | ||||
| } | } | ||||
| @@ -19,11 +19,10 @@ | |||||
| * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||||
| */ | */ | ||||
| #include <unistd.h> | |||||
| #include "libavutil/avstring.h" | #include "libavutil/avstring.h" | ||||
| #include "libavutil/dict.h" | #include "libavutil/dict.h" | ||||
| #include "libavutil/opt.h" | #include "libavutil/opt.h" | ||||
| #include "libavutil/time.h" | |||||
| #include "os_support.h" | #include "os_support.h" | ||||
| #include "avformat.h" | #include "avformat.h" | ||||
| #if CONFIG_NETWORK | #if CONFIG_NETWORK | ||||
| @@ -237,7 +236,7 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int | |||||
| if (fast_retries) | if (fast_retries) | ||||
| fast_retries--; | fast_retries--; | ||||
| else | else | ||||
| usleep(1000); | |||||
| av_usleep(1000); | |||||
| } else if (ret < 1) | } else if (ret < 1) | ||||
| return ret < 0 ? ret : len; | return ret < 0 ? ret : len; | ||||
| if (ret) | if (ret) | ||||
| @@ -30,9 +30,9 @@ | |||||
| #include "libavutil/mathematics.h" | #include "libavutil/mathematics.h" | ||||
| #include "libavutil/opt.h" | #include "libavutil/opt.h" | ||||
| #include "libavutil/dict.h" | #include "libavutil/dict.h" | ||||
| #include "libavutil/time.h" | |||||
| #include "avformat.h" | #include "avformat.h" | ||||
| #include "internal.h" | #include "internal.h" | ||||
| #include <unistd.h> | |||||
| #include "avio_internal.h" | #include "avio_internal.h" | ||||
| #include "url.h" | #include "url.h" | ||||
| @@ -407,7 +407,7 @@ reload: | |||||
| while (av_gettime() - v->last_load_time < reload_interval) { | while (av_gettime() - v->last_load_time < reload_interval) { | ||||
| if (ff_check_interrupt(c->interrupt_callback)) | if (ff_check_interrupt(c->interrupt_callback)) | ||||
| return AVERROR_EXIT; | return AVERROR_EXIT; | ||||
| usleep(100*1000); | |||||
| av_usleep(100*1000); | |||||
| } | } | ||||
| /* Enough time has elapsed since the last reload */ | /* Enough time has elapsed since the last reload */ | ||||
| goto reload; | goto reload; | ||||
| @@ -26,11 +26,11 @@ | |||||
| */ | */ | ||||
| #include "libavutil/avstring.h" | #include "libavutil/avstring.h" | ||||
| #include "libavutil/time.h" | |||||
| #include "avformat.h" | #include "avformat.h" | ||||
| #include "internal.h" | #include "internal.h" | ||||
| #include "url.h" | #include "url.h" | ||||
| #include "version.h" | #include "version.h" | ||||
| #include <unistd.h> | |||||
| /* | /* | ||||
| * An apple http stream consists of a playlist with media segment files, | * 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) { | while (av_gettime() - s->last_load_time < reload_interval) { | ||||
| if (ff_check_interrupt(&h->interrupt_callback)) | if (ff_check_interrupt(&h->interrupt_callback)) | ||||
| return AVERROR_EXIT; | return AVERROR_EXIT; | ||||
| usleep(100*1000); | |||||
| av_usleep(100*1000); | |||||
| } | } | ||||
| goto retry; | goto retry; | ||||
| } | } | ||||
| @@ -24,11 +24,10 @@ | |||||
| * RTMP HTTP protocol | * RTMP HTTP protocol | ||||
| */ | */ | ||||
| #include <unistd.h> | |||||
| #include "libavutil/avstring.h" | #include "libavutil/avstring.h" | ||||
| #include "libavutil/intfloat.h" | #include "libavutil/intfloat.h" | ||||
| #include "libavutil/opt.h" | #include "libavutil/opt.h" | ||||
| #include "libavutil/time.h" | |||||
| #include "internal.h" | #include "internal.h" | ||||
| #include "http.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) { | if (rt->nb_bytes_read == 0) { | ||||
| /* Wait 50ms before retrying to read a server reply in | /* Wait 50ms before retrying to read a server reply in | ||||
| * order to reduce the number of idle requets. */ | * order to reduce the number of idle requets. */ | ||||
| usleep(50000); | |||||
| av_usleep(50000); | |||||
| } | } | ||||
| if ((ret = rtmp_http_write(h, "", 1)) < 0) | if ((ret = rtmp_http_write(h, "", 1)) < 0) | ||||
| @@ -20,8 +20,8 @@ | |||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| #include <unistd.h> | |||||
| #include "libavutil/time.h" | |||||
| #include "libavformat/avformat.h" | #include "libavformat/avformat.h" | ||||
| static int usage(const char *argv0, int ret) | static int usage(const char *argv0, int ret) | ||||
| @@ -82,7 +82,7 @@ int main(int argc, char **argv) | |||||
| if (bps) { | if (bps) { | ||||
| avio_flush(output); | avio_flush(output); | ||||
| while ((av_gettime() - start_time) * bps / AV_TIME_BASE < stream_pos) | while ((av_gettime() - start_time) * bps / AV_TIME_BASE < stream_pos) | ||||
| usleep(50 * 1000); | |||||
| av_usleep(50 * 1000); | |||||
| } | } | ||||
| } | } | ||||
| @@ -25,6 +25,7 @@ | |||||
| #include <string.h> | #include <string.h> | ||||
| #include <unistd.h> | #include <unistd.h> | ||||
| #include "libavutil/time.h" | |||||
| #include "libavformat/avformat.h" | #include "libavformat/avformat.h" | ||||
| #define PKTFILESUFF "_%08" PRId64 "_%02d_%010" PRId64 "_%06d_%c.bin" | #define PKTFILESUFF "_%08" PRId64 "_%02d_%010" PRId64 "_%06d_%c.bin" | ||||
| @@ -122,7 +123,7 @@ int main(int argc, char **argv) | |||||
| avformat_close_input(&fctx); | avformat_close_input(&fctx); | ||||
| while (donotquit) | while (donotquit) | ||||
| usleep(60 * 1000000); | |||||
| av_usleep(60 * 1000000); | |||||
| return 0; | return 0; | ||||
| } | } | ||||