mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-02-18 02:55:46 +00:00
fixed time rounding
This commit is contained in:
parent
bc107d2870
commit
c71df1bb25
@ -430,7 +430,7 @@ static void _http_exposed_refresh(UNUSED int fd, UNUSED short what, void *v_serv
|
||||
}
|
||||
|
||||
if (queue_send) {
|
||||
if ((now = (long long)now_monotonic_ms()) != eps_second) {
|
||||
if ((now = ms_to_s(now_monotonic_ms())) != eps_second) {
|
||||
server->run->exposed->eps = eps;
|
||||
eps = 0;
|
||||
eps_second = now;
|
||||
|
||||
@ -163,6 +163,7 @@ void stream_loop(struct stream_t *stream) {
|
||||
|
||||
struct v4l2_buffer buf_info;
|
||||
long double now = now_monotonic_ms();
|
||||
long long now_second = ms_to_s(now);
|
||||
|
||||
if (_stream_grab_buffer(stream->dev, &buf_info) < 0) {
|
||||
break;
|
||||
@ -196,11 +197,11 @@ void stream_loop(struct stream_t *stream) {
|
||||
}
|
||||
fluency_passed = 0;
|
||||
|
||||
if ((long long)now != fps_second) {
|
||||
if (now_second != fps_second) {
|
||||
LOG_PERF("Oldest worker complete, encoding FPS = %u", fps);
|
||||
stream->fps = fps;
|
||||
fps = 0;
|
||||
fps_second = (long long)now;
|
||||
fps_second = now_second;
|
||||
}
|
||||
fps += 1;
|
||||
|
||||
|
||||
@ -61,6 +61,10 @@ INLINE unsigned max_u(unsigned a, unsigned b) {
|
||||
return (a > b ? a : b);
|
||||
}
|
||||
|
||||
INLINE long long ms_to_s(long double now) {
|
||||
return (long long) now - (now < (long long) now); // floor()
|
||||
}
|
||||
|
||||
INLINE void now_ms(clockid_t clk_id, time_t *sec, long *msec) {
|
||||
struct timespec spec;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user