diff --git a/src/ustreamer/stream.c b/src/ustreamer/stream.c index 36663d8..5cd14b1 100644 --- a/src/ustreamer/stream.c +++ b/src/ustreamer/stream.c @@ -89,7 +89,7 @@ void us_stream_loop(us_stream_s *stream) { ldf grab_after = 0; uint fluency_passed = 0; uint captured_fps_accum = 0; - sll captured_fps_second = 0; + sll captured_fps_ts = 0; US_LOG_INFO("Capturing ..."); @@ -134,29 +134,29 @@ void us_stream_loop(us_stream_s *stream) { us_gpio_set_stream_online(true); # endif - const ldf now = us_get_now_monotonic(); + const ldf now_ts = us_get_now_monotonic(); - if (now < grab_after) { + if (now_ts < grab_after) { fluency_passed += 1; US_LOG_VERBOSE("Passed %u frames for fluency: now=%.03Lf, grab_after=%.03Lf", - fluency_passed, now, grab_after); + fluency_passed, now_ts, grab_after); if (us_device_release_buffer(stream->dev, hw) < 0) { goto close; } } else { fluency_passed = 0; - const sll now_second = us_floor_ms(now); - if (now_second != captured_fps_second) { + const sll now_sec_ts = us_floor_ms(now_ts); + if (now_sec_ts != captured_fps_ts) { US_LOG_PERF_FPS("A new second has come; captured_fps=%u", captured_fps_accum); atomic_store(&run->captured_fps, captured_fps_accum); captured_fps_accum = 0; - captured_fps_second = now_second; + captured_fps_ts = now_sec_ts; } captured_fps_accum += 1; const ldf fluency_delay = us_workers_pool_get_fluency_delay(stream->enc->run->pool, ready_wr); - grab_after = now + fluency_delay; + grab_after = now_ts + fluency_delay; US_LOG_VERBOSE("Fluency: delay=%.03Lf, grab_after=%.03Lf", fluency_delay, grab_after); ready_job->hw = hw; @@ -191,15 +191,15 @@ static bool _stream_is_stopped(us_stream_s *stream) { return true; } if (stream->exit_on_no_clients > 0) { - const ldf now = us_get_now_monotonic(); - const u64 http_last_request_ts = atomic_load(&run->http_last_request_ts); // Seconds + const ldf now_ts = us_get_now_monotonic(); + const ull http_last_request_ts = atomic_load(&run->http_last_request_ts); // Seconds if (_stream_has_any_clients(stream)) { - atomic_store(&run->http_last_request_ts, now); - } else if (http_last_request_ts + stream->exit_on_no_clients < now) { + atomic_store(&run->http_last_request_ts, now_ts); + } else if (http_last_request_ts + stream->exit_on_no_clients < now_ts) { US_LOG_INFO("No requests or HTTP/sink clients found in last %u seconds, exiting ...", stream->exit_on_no_clients); us_process_suicide(); - atomic_store(&run->http_last_request_ts, now); + atomic_store(&run->http_last_request_ts, now_ts); } } return false; diff --git a/src/ustreamer/stream.h b/src/ustreamer/stream.h index 09f0283..e39bff2 100644 --- a/src/ustreamer/stream.h +++ b/src/ustreamer/stream.h @@ -53,7 +53,7 @@ typedef struct { us_ring_s *http_jpeg_ring; atomic_bool http_has_clients; - atomic_uint_least64_t http_last_request_ts; // Seconds + atomic_ullong http_last_request_ts; // Seconds atomic_uint captured_fps; bool last_online;