From fded925e71391888a7c00bd477a82f0acdec0ff3 Mon Sep 17 00:00:00 2001 From: Tristan Stenner Date: Fri, 14 Dec 2018 10:21:29 +0100 Subject: [PATCH] Add timeouts so missing/idle streams can't prevent LabRecorder from shutting down. Thanks to Jason Kowaleski (@kowalej) --- recording.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/recording.cpp b/recording.cpp index fcb88e6..b8765ca 100644 --- a/recording.cpp +++ b/recording.cpp @@ -373,14 +373,16 @@ void recording::typed_transfer_loop(streamid_t streamid, double srate, const inl std::vector timestamps; // Pull the first sample - first_timestamp = last_timestamp = in->pull_sample(chunk); + first_timestamp = 0.0; + while(first_timestamp == 0.0) + first_timestamp = last_timestamp = in->pull_sample(chunk, 4.0); timestamps.push_back(first_timestamp); file_.write_data_chunk(streamid, timestamps, chunk, in->get_channel_count()); auto next_pull = Clock::now(); while (!shutdown_) { // get a chunk from the stream - in->pull_chunk_multiplexed(chunk, ×tamps); + in->pull_chunk_multiplexed(chunk, ×tamps, 4.0); // for each sample... for (double &ts : timestamps) { // if the time stamp can be deduced from the previous one...