Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LARN
PRRT
Commits
6e194ebf
Commit
6e194ebf
authored
Apr 08, 2016
by
Andreas Schmidt
Browse files
Default target delay set to 1s.
parent
bb457216
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/prrt/applicationConstraints.c
View file @
6e194ebf
...
@@ -10,6 +10,8 @@ PrrtApplicationConstraints *PrrtApplicationConstraints_create()
...
@@ -10,6 +10,8 @@ PrrtApplicationConstraints *PrrtApplicationConstraints_create()
pthread_mutex_init
(
&
constraints
->
lock
,
NULL
);
pthread_mutex_init
(
&
constraints
->
lock
,
NULL
);
constraints
->
targetDelay_us
=
1000
*
1000
;
return
constraints
;
return
constraints
;
error:
error:
...
@@ -27,7 +29,7 @@ bool PrrtApplicationConstraints_destroy(PrrtApplicationConstraints *applicationC
...
@@ -27,7 +29,7 @@ bool PrrtApplicationConstraints_destroy(PrrtApplicationConstraints *applicationC
prrtTimedelta_t
PrrtApplicationConstraints_get_target_delay
(
PrrtApplicationConstraints
*
applicationConstraints
)
prrtTimedelta_t
PrrtApplicationConstraints_get_target_delay
(
PrrtApplicationConstraints
*
applicationConstraints
)
{
{
pthread_mutex_lock
(
&
applicationConstraints
->
lock
);
pthread_mutex_lock
(
&
applicationConstraints
->
lock
);
prrtTimedelta_t
targetDelay
=
applicationConstraints
->
targetDelay
;
prrtTimedelta_t
targetDelay
=
applicationConstraints
->
targetDelay
_us
;
pthread_mutex_unlock
(
&
applicationConstraints
->
lock
);
pthread_mutex_unlock
(
&
applicationConstraints
->
lock
);
return
targetDelay
;
return
targetDelay
;
}
}
...
@@ -35,7 +37,7 @@ prrtTimedelta_t PrrtApplicationConstraints_get_target_delay(PrrtApplicationConst
...
@@ -35,7 +37,7 @@ prrtTimedelta_t PrrtApplicationConstraints_get_target_delay(PrrtApplicationConst
bool
PrrtApplicationConstraints_set_target_delay
(
PrrtApplicationConstraints
*
applicationConstraints
,
prrtTimedelta_t
targetDelay
)
bool
PrrtApplicationConstraints_set_target_delay
(
PrrtApplicationConstraints
*
applicationConstraints
,
prrtTimedelta_t
targetDelay
)
{
{
pthread_mutex_lock
(
&
applicationConstraints
->
lock
);
pthread_mutex_lock
(
&
applicationConstraints
->
lock
);
applicationConstraints
->
targetDelay
=
targetDelay
;
applicationConstraints
->
targetDelay
_us
=
targetDelay
;
pthread_mutex_unlock
(
&
applicationConstraints
->
lock
);
pthread_mutex_unlock
(
&
applicationConstraints
->
lock
);
return
true
;
return
true
;
}
}
src/prrt/applicationConstraints.h
View file @
6e194ebf
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
#include "packet.h"
#include "packet.h"
typedef
struct
applicationConstraints
{
typedef
struct
applicationConstraints
{
prrtTimedelta_t
targetDelay
;
prrtTimedelta_t
targetDelay
_us
;
pthread_mutex_t
lock
;
pthread_mutex_t
lock
;
}
PrrtApplicationConstraints
;
}
PrrtApplicationConstraints
;
...
...
src/prrt/clock.c
View file @
6e194ebf
...
@@ -13,13 +13,6 @@ prrtTimestamp_t PrrtClock_get_current_time_us()
...
@@ -13,13 +13,6 @@ prrtTimestamp_t PrrtClock_get_current_time_us()
return
(
prrtTimestamp_t
)
(
1000000
*
tv
.
tv_sec
+
tv
.
tv_usec
);
return
(
prrtTimestamp_t
)
(
1000000
*
tv
.
tv_sec
+
tv
.
tv_usec
);
}
}
prrtTimestamp_t
PrrtClock_get_current_time_ms
()
{
struct
timeval
tv
;
gettimeofday
(
&
tv
,
NULL
);
return
(
uint32_t
)
(
1000
*
tv
.
tv_sec
+
tv
.
tv_usec
/
1000
);
}
prrtTimestamp_t
PrrtClock_get_prrt_time_us
(
PrrtClock
*
clock
)
prrtTimestamp_t
PrrtClock_get_prrt_time_us
(
PrrtClock
*
clock
)
{
{
prrtTimestamp_t
currentTime
=
PrrtClock_get_current_time_us
();
prrtTimestamp_t
currentTime
=
PrrtClock_get_current_time_us
();
...
@@ -41,7 +34,7 @@ bool PrrtClock_update(PrrtClock *clock, uint32_t referenceTime, uint32_t rtt)
...
@@ -41,7 +34,7 @@ bool PrrtClock_update(PrrtClock *clock, uint32_t referenceTime, uint32_t rtt)
prrtTimestamp_t
currentTime
=
PrrtClock_get_current_time_us
();
prrtTimestamp_t
currentTime
=
PrrtClock_get_current_time_us
();
prrtTimestamp_t
virtualTime
=
clock
->
virtualTime
;
prrtTimestamp_t
virtualTime
=
clock
->
virtualTime
;
int32_t
clockSkew
=
clock
->
skew
;
int32_t
clockSkew
=
clock
->
skew
;
prrtTimedelta_t
delay
=
rtt
/
2
;
// half the rtt
prrtTimedelta_t
delay
=
rtt
/
2
;
// half the rtt
int32_t
phaseError
=
(
int32_t
)
diff_ts
(
referenceTime
,
virtualTime
)
+
delay
;
int32_t
phaseError
=
(
int32_t
)
diff_ts
(
referenceTime
,
virtualTime
)
+
delay
;
//debug("Virtual Time: %u, Current Time: %u, Phase Error: %d, Delay: %u, Skew: %d", virtualTime, currentTime, phaseError, delay, clockSkew);
//debug("Virtual Time: %u, Current Time: %u, Phase Error: %d, Delay: %u, Skew: %d", virtualTime, currentTime, phaseError, delay, clockSkew);
...
...
src/prrt/clock.h
View file @
6e194ebf
...
@@ -20,7 +20,7 @@ PrrtClock* PrrtClock_create(void);
...
@@ -20,7 +20,7 @@ PrrtClock* PrrtClock_create(void);
bool
PrrtClock_destroy
(
PrrtClock
*
clock
);
bool
PrrtClock_destroy
(
PrrtClock
*
clock
);
prrtTimestamp_t
PrrtClock_get_current_time_us
(
void
);
prrtTimestamp_t
PrrtClock_get_current_time_us
(
void
);
prrtTimestamp_t
PrrtClock_get_current_time_ms
(
void
);
prrtTimestamp_t
PrrtClock_get_prrt_time_us
(
PrrtClock
*
clock
);
prrtTimestamp_t
PrrtClock_get_prrt_time_us
(
PrrtClock
*
clock
);
bool
PrrtClock_update
(
PrrtClock
*
clock
,
prrtTimestamp_t
referenceTime
,
prrtTimedelta_t
rtt
);
bool
PrrtClock_update
(
PrrtClock
*
clock
,
prrtTimestamp_t
referenceTime
,
prrtTimedelta_t
rtt
);
...
...
src/prrt/socket.c
View file @
6e194ebf
...
@@ -100,8 +100,7 @@ bool PrrtSocket_bind(PrrtSocket *sock_ptr, const char* ipAddress, const uint16_t
...
@@ -100,8 +100,7 @@ bool PrrtSocket_bind(PrrtSocket *sock_ptr, const char* ipAddress, const uint16_t
"Cannot create data receiving thread."
);
"Cannot create data receiving thread."
);
}
}
check
(
pthread_create
(
&
sock_ptr
->
cleanupThread
,
NULL
,
cleanup
,
(
void
*
)
sock_ptr
)
==
check
(
pthread_create
(
&
sock_ptr
->
cleanupThread
,
NULL
,
cleanup
,
(
void
*
)
sock_ptr
)
==
EXIT_SUCCESS
,
"Cannot create cleanup thread."
);
EXIT_SUCCESS
,
"Cannot create cleanup thread."
);
return
true
;
return
true
;
error:
error:
...
...
Write
Preview
Supports
Markdown
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