Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dvblast
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
dvblast
Commits
134778fc
Commit
134778fc
authored
Dec 22, 2009
by
Christophe Massiot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* util.c: Use a monotonic clock for mdate() and msleep().
parent
6a5904e3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
7 deletions
+33
-7
Makefile
Makefile
+2
-1
util.c
util.c
+31
-6
No files found.
Makefile
View file @
134778fc
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
CFLAGS
+=
-Wall
-O3
-fomit-frame-pointer
CFLAGS
+=
-Wall
-O3
-fomit-frame-pointer
CFLAGS
+=
-g
CFLAGS
+=
-g
CFLAGS
+=
-I
/usr/src/kernel/linux-2.6.29.1/include
CFLAGS
+=
-I
/usr/src/kernel/linux-2.6.29.1/include
LDFLAGS
+=
-lrt
LDFLAGS_DVBLAST
+=
-ldvbpsi
-lpthread
LDFLAGS_DVBLAST
+=
-ldvbpsi
-lpthread
OBJ_DVBLAST
=
dvblast.o util.o dvb.o udp.o demux.o output.o en50221.o comm.o
OBJ_DVBLAST
=
dvblast.o util.o dvb.o udp.o demux.o output.o en50221.o comm.o
...
@@ -14,7 +15,7 @@ all: dvblast dvblastctl
...
@@ -14,7 +15,7 @@ all: dvblast dvblastctl
$(OBJ_DVBLAST) $(OBJ_DVBLASTCTL)
:
Makefile dvblast.h en50221.h comm.h version.h
$(OBJ_DVBLAST) $(OBJ_DVBLASTCTL)
:
Makefile dvblast.h en50221.h comm.h version.h
dvblast
:
$(OBJ_DVBLAST)
dvblast
:
$(OBJ_DVBLAST)
$(CC)
-o
$@
$(OBJ_DVBLAST)
$(LDFLAGS_DVBLAST)
$(CC)
-o
$@
$(OBJ_DVBLAST)
$(LDFLAGS_DVBLAST)
$(LDFLAGS)
dvblastctl
:
$(OBJ_DVBLASTCTL)
dvblastctl
:
$(OBJ_DVBLASTCTL)
...
...
util.c
View file @
134778fc
...
@@ -31,9 +31,12 @@
...
@@ -31,9 +31,12 @@
#include <sys/socket.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/inet.h>
#include <errno.h>
#include "dvblast.h"
#include "dvblast.h"
#define HAVE_CLOCK_NANOSLEEP
/*****************************************************************************
/*****************************************************************************
* Local declarations
* Local declarations
*****************************************************************************/
*****************************************************************************/
...
@@ -121,6 +124,17 @@ void msg_Raw( void *_unused, const char *psz_format, ... )
...
@@ -121,6 +124,17 @@ void msg_Raw( void *_unused, const char *psz_format, ... )
*****************************************************************************/
*****************************************************************************/
mtime_t
mdate
(
void
)
mtime_t
mdate
(
void
)
{
{
#if defined (HAVE_CLOCK_NANOSLEEP)
struct
timespec
ts
;
/* Try to use POSIX monotonic clock if available */
if
(
clock_gettime
(
CLOCK_MONOTONIC
,
&
ts
)
==
EINVAL
)
/* Run-time fallback to real-time clock (always available) */
(
void
)
clock_gettime
(
CLOCK_REALTIME
,
&
ts
);
return
((
mtime_t
)
ts
.
tv_sec
*
(
mtime_t
)
1000000
)
+
(
mtime_t
)(
ts
.
tv_nsec
/
1000
);
#else
struct
timeval
tv_date
;
struct
timeval
tv_date
;
/* gettimeofday() could return an error, and should be tested. However, the
/* gettimeofday() could return an error, and should be tested. However, the
...
@@ -128,6 +142,7 @@ mtime_t mdate( void )
...
@@ -128,6 +142,7 @@ mtime_t mdate( void )
* here, since tv is a local variable. */
* here, since tv is a local variable. */
gettimeofday
(
&
tv_date
,
NULL
);
gettimeofday
(
&
tv_date
,
NULL
);
return
(
(
mtime_t
)
tv_date
.
tv_sec
*
1000000
+
(
mtime_t
)
tv_date
.
tv_usec
);
return
(
(
mtime_t
)
tv_date
.
tv_sec
*
1000000
+
(
mtime_t
)
tv_date
.
tv_usec
);
#endif
}
}
/*****************************************************************************
/*****************************************************************************
...
@@ -135,12 +150,22 @@ mtime_t mdate( void )
...
@@ -135,12 +150,22 @@ mtime_t mdate( void )
*****************************************************************************/
*****************************************************************************/
void
msleep
(
mtime_t
delay
)
void
msleep
(
mtime_t
delay
)
{
{
struct
timespec
ts_delay
;
struct
timespec
ts
;
ts
.
tv_sec
=
delay
/
1000000
;
ts_delay
.
tv_sec
=
delay
/
1000000
;
ts
.
tv_nsec
=
(
delay
%
1000000
)
*
1000
;
ts_delay
.
tv_nsec
=
(
delay
%
1000000
)
*
1000
;
#if defined( HAVE_CLOCK_NANOSLEEP )
nanosleep
(
&
ts_delay
,
NULL
);
int
val
;
while
(
(
val
=
clock_nanosleep
(
CLOCK_MONOTONIC
,
0
,
&
ts
,
&
ts
)
)
==
EINTR
);
if
(
val
==
EINVAL
)
{
ts
.
tv_sec
=
delay
/
1000000
;
ts
.
tv_nsec
=
(
delay
%
1000000
)
*
1000
;
while
(
clock_nanosleep
(
CLOCK_REALTIME
,
0
,
&
ts
,
&
ts
)
==
EINTR
);
}
#else
while
(
nanosleep
(
&
ts
,
&
ts
)
&&
errno
==
EINTR
);
#endif
}
}
/*****************************************************************************
/*****************************************************************************
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment