Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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
vlc-2-2
Commits
0c677da7
Commit
0c677da7
authored
Jul 14, 2011
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factor mtime_to to struct timespec conversion
parent
e06e611f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
src/posix/thread.c
src/posix/thread.c
+13
-10
No files found.
src/posix/thread.c
View file @
0c677da7
...
...
@@ -137,6 +137,14 @@ int nanosleep (struct timespec *, struct timespec *);
# define vlc_clock_setup() (void)0
#endif
/* _POSIX_TIMERS */
static
struct
timespec
mtime_to_ts
(
mtime_t
date
)
{
lldiv_t
d
=
lldiv
(
date
,
CLOCK_FREQ
);
struct
timespec
ts
=
{
d
.
quot
,
d
.
rem
*
(
1000000000
/
CLOCK_FREQ
)
};
return
ts
;
}
/**
* Print a backtrace to the standard error for debugging purpose.
*/
...
...
@@ -466,13 +474,11 @@ int vlc_cond_timedwait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex,
deadline
-=
base
;
if
(
deadline
<
0
)
deadline
=
0
;
lldiv_t
d
=
lldiv
(
deadline
,
CLOCK_FREQ
);
struct
timespec
ts
=
{
d
.
quot
,
d
.
rem
*
(
1000000000
/
CLOCK_FREQ
)
};
struct
timespec
ts
=
mtime_to_ts
(
deadline
);
int
val
=
pthread_cond_timedwait_relative_np
(
p_condvar
,
p_mutex
,
&
ts
);
#else
lldiv_t
d
=
lldiv
(
deadline
,
CLOCK_FREQ
);
struct
timespec
ts
=
{
d
.
quot
,
d
.
rem
*
(
1000000000
/
CLOCK_FREQ
)
};
struct
timespec
ts
=
mtime_to_ts
(
deadline
);
int
val
=
pthread_cond_timedwait
(
p_condvar
,
p_mutex
,
&
ts
);
#endif
if
(
val
!=
ETIMEDOUT
)
...
...
@@ -976,8 +982,7 @@ void mwait (mtime_t deadline)
* do not even bother the system timer. */
deadline
-=
vlc_clock_prec
;
lldiv_t
d
=
lldiv
(
deadline
,
1000000
);
struct
timespec
ts
=
{
d
.
quot
,
d
.
rem
*
1000
};
struct
timespec
ts
=
mtime_to_ts
(
deadline
);
while
(
clock_nanosleep
(
vlc_clock_id
,
TIMER_ABSTIME
,
&
ts
,
NULL
)
==
EINTR
);
...
...
@@ -996,11 +1001,9 @@ void mwait (mtime_t deadline)
*/
void
msleep
(
mtime_t
delay
)
{
vlc_clock_setup
();
lldiv_t
d
=
lldiv
(
delay
,
1000000
);
struct
timespec
ts
=
{
d
.
quot
,
d
.
rem
*
1000
};
struct
timespec
ts
=
mtime_to_ts
(
delay
);
vlc_clock_setup
();
#if (_POSIX_TIMERS > 0)
while
(
clock_nanosleep
(
vlc_clock_id
,
0
,
&
ts
,
&
ts
)
==
EINTR
);
...
...
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