From c573d3e3cfa9afe42bb3aafae17d527a7f608d55 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 2 Oct 2023 17:48:03 +0200 Subject: Drift compensation: abort after 60s of missing data --- src/odr-audioenc.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/odr-audioenc.cpp') diff --git a/src/odr-audioenc.cpp b/src/odr-audioenc.cpp index d759c6f..6a2afbe 100644 --- a/src/odr-audioenc.cpp +++ b/src/odr-audioenc.cpp @@ -811,6 +811,7 @@ int AudioEnc::run() int retval = 0; int send_error_count = 0; timepoint_last_compensation = chrono::steady_clock::now(); + auto timepoint_last_received_sample = chrono::steady_clock::now(); int calls = 0; // for checking ssize_t read_bytes = 0; @@ -919,6 +920,17 @@ int AudioEnc::run() if (stats_publisher) { stats_publisher->notify_underrun(); } + + const auto now = chrono::steady_clock::now(); + const auto elapsed = chrono::duration_cast( + now - timepoint_last_received_sample); + if (elapsed.count() > 60) { + fprintf(stderr, "Underruns for 60s, aborting!\n"); + return 1; + } + } + else { + timepoint_last_received_sample = chrono::steady_clock::now(); } if (overruns) { -- cgit v1.2.3