lavu: add av_usleep() function
This function implements a delay using the first available of the following functions: - nanosleep() - usleep() - Sleep() (Windows) The conditional #includes in time.c are simplified by including unistd.h and windows.h whenever they are available rather than having these lines triggered by specific functions. Signed-off-by: Mans Rullgard <mans@mansr.com>
This commit is contained in:
7
configure
vendored
7
configure
vendored
@@ -1113,6 +1113,7 @@ HAVE_LIST="
|
|||||||
memalign
|
memalign
|
||||||
mkstemp
|
mkstemp
|
||||||
mmap
|
mmap
|
||||||
|
nanosleep
|
||||||
netinet_sctp_h
|
netinet_sctp_h
|
||||||
poll_h
|
poll_h
|
||||||
posix_memalign
|
posix_memalign
|
||||||
@@ -1123,6 +1124,7 @@ HAVE_LIST="
|
|||||||
sdl_video_size
|
sdl_video_size
|
||||||
setmode
|
setmode
|
||||||
setrlimit
|
setrlimit
|
||||||
|
Sleep
|
||||||
sndio_h
|
sndio_h
|
||||||
socklen_t
|
socklen_t
|
||||||
soundcard_h
|
soundcard_h
|
||||||
@@ -1151,8 +1153,10 @@ HAVE_LIST="
|
|||||||
trunc
|
trunc
|
||||||
truncf
|
truncf
|
||||||
unistd_h
|
unistd_h
|
||||||
|
usleep
|
||||||
vfp_args
|
vfp_args
|
||||||
VirtualAlloc
|
VirtualAlloc
|
||||||
|
windows_h
|
||||||
winsock2_h
|
winsock2_h
|
||||||
xform_asm
|
xform_asm
|
||||||
xmm_clobbers
|
xmm_clobbers
|
||||||
@@ -2851,12 +2855,14 @@ check_func strtok_r
|
|||||||
check_func sched_getaffinity
|
check_func sched_getaffinity
|
||||||
check_func sysconf
|
check_func sysconf
|
||||||
check_func sysctl
|
check_func sysctl
|
||||||
|
check_func usleep
|
||||||
check_func_headers io.h setmode
|
check_func_headers io.h setmode
|
||||||
check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
|
check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
|
||||||
check_func_headers windows.h GetProcessAffinityMask
|
check_func_headers windows.h GetProcessAffinityMask
|
||||||
check_func_headers windows.h GetProcessTimes
|
check_func_headers windows.h GetProcessTimes
|
||||||
check_func_headers windows.h GetSystemTimeAsFileTime
|
check_func_headers windows.h GetSystemTimeAsFileTime
|
||||||
check_func_headers windows.h MapViewOfFile
|
check_func_headers windows.h MapViewOfFile
|
||||||
|
check_func_headers windows.h Sleep
|
||||||
check_func_headers windows.h VirtualAlloc
|
check_func_headers windows.h VirtualAlloc
|
||||||
|
|
||||||
check_header dlfcn.h
|
check_header dlfcn.h
|
||||||
@@ -2870,6 +2876,7 @@ check_header sys/select.h
|
|||||||
check_header unistd.h
|
check_header unistd.h
|
||||||
check_header vdpau/vdpau.h
|
check_header vdpau/vdpau.h
|
||||||
check_header vdpau/vdpau_x11.h
|
check_header vdpau/vdpau_x11.h
|
||||||
|
check_header windows.h
|
||||||
check_header X11/extensions/XvMClib.h
|
check_header X11/extensions/XvMClib.h
|
||||||
|
|
||||||
disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
|
disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib
|
||||||
|
@@ -13,6 +13,9 @@ libavutil: 2011-04-18
|
|||||||
|
|
||||||
API changes, most recent first:
|
API changes, most recent first:
|
||||||
|
|
||||||
|
2012-06-22 - xxxxxxx - lavu 51.34.0
|
||||||
|
Add av_usleep()
|
||||||
|
|
||||||
2012-06-20 - ae0a301 - lavu 51.33.0
|
2012-06-20 - ae0a301 - lavu 51.33.0
|
||||||
Move av_gettime() to libavutil, add libavutil/time.h
|
Move av_gettime() to libavutil, add libavutil/time.h
|
||||||
|
|
||||||
|
@@ -152,7 +152,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define LIBAVUTIL_VERSION_MAJOR 51
|
#define LIBAVUTIL_VERSION_MAJOR 51
|
||||||
#define LIBAVUTIL_VERSION_MINOR 33
|
#define LIBAVUTIL_VERSION_MINOR 34
|
||||||
#define LIBAVUTIL_VERSION_MICRO 0
|
#define LIBAVUTIL_VERSION_MICRO 0
|
||||||
|
|
||||||
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
|
||||||
|
@@ -20,13 +20,19 @@
|
|||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <time.h>
|
||||||
#if HAVE_GETTIMEOFDAY
|
#if HAVE_GETTIMEOFDAY
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#elif HAVE_GETSYSTEMTIMEASFILETIME
|
#endif
|
||||||
|
#if HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#if HAVE_WINDOWS_H
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libavutil/time.h"
|
#include "libavutil/time.h"
|
||||||
|
#include "error.h"
|
||||||
|
|
||||||
int64_t av_gettime(void)
|
int64_t av_gettime(void)
|
||||||
{
|
{
|
||||||
@@ -44,3 +50,19 @@ int64_t av_gettime(void)
|
|||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int av_usleep(unsigned usec)
|
||||||
|
{
|
||||||
|
#if HAVE_NANOSLEEP
|
||||||
|
struct timespec ts = { usec / 1000000, usec % 1000000 * 1000 };
|
||||||
|
while (nanosleep(&ts, &ts) < 0 && errno == EINTR);
|
||||||
|
return 0;
|
||||||
|
#elif HAVE_USLEEP
|
||||||
|
return usleep(usec);
|
||||||
|
#elif HAVE_SLEEP
|
||||||
|
Sleep(usec / 1000);
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
return AVERROR(ENOSYS);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@@ -26,4 +26,14 @@
|
|||||||
*/
|
*/
|
||||||
int64_t av_gettime(void);
|
int64_t av_gettime(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sleep for a period of time. Although the duration is expressed in
|
||||||
|
* microseconds, the actual delay may be rounded to the precision of the
|
||||||
|
* system timer.
|
||||||
|
*
|
||||||
|
* @param usec Number of microseconds to sleep.
|
||||||
|
* @return zero on success or (negative) error code.
|
||||||
|
*/
|
||||||
|
int av_usleep(unsigned usec);
|
||||||
|
|
||||||
#endif /* AVUTIL_TIME_H */
|
#endif /* AVUTIL_TIME_H */
|
||||||
|
Reference in New Issue
Block a user