diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2023-10-02 17:48:03 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2023-10-02 17:48:03 +0200 |
commit | c573d3e3cfa9afe42bb3aafae17d527a7f608d55 (patch) | |
tree | e39bd707429efb9e893df31bcc49194bf6ef6c52 /src/odr-audioenc.cpp | |
parent | 13f2b370eff48e1deb06edbe5a9f9560e622c9e2 (diff) | |
download | ODR-AudioEnc-c573d3e3cfa9afe42bb3aafae17d527a7f608d55.tar.gz ODR-AudioEnc-c573d3e3cfa9afe42bb3aafae17d527a7f608d55.tar.bz2 ODR-AudioEnc-c573d3e3cfa9afe42bb3aafae17d527a7f608d55.zip |
Drift compensation: abort after 60s of missing data
Diffstat (limited to 'src/odr-audioenc.cpp')
-rw-r--r-- | src/odr-audioenc.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
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<chrono::seconds>( + 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) { |