From 14461fcad98a868a744b1e8dc9178bb951cfb7b9 Mon Sep 17 00:00:00 2001 From: Scott Lamb Date: Fri, 30 Dec 2016 06:39:09 -0800 Subject: [PATCH] bugfix: only double length of first recording --- src/streamer.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/streamer.rs b/src/streamer.rs index dc01afe..88d0925 100644 --- a/src/streamer.rs +++ b/src/streamer.rs @@ -147,14 +147,15 @@ impl<'a, C, S> Streamer<'a, C, S> where C: 'a + Clocks, S: 'a + stream::Stream { let mut s = match state { Some(s) => s, None => { - // Set rotate time to not the next rotate offset, but the one after. - // The first recording interval is longer than usual rather than shorter - // than usual so that there's plenty of frame times to use when calculating the - // start time. let sec = frame_realtime.sec; let r = sec - (sec % self.rotate_interval_sec) + self.rotate_offset_sec; - let r = r + if r <= sec { 2*self.rotate_interval_sec } - else { self.rotate_interval_sec }; + let r = r + if r <= sec { self.rotate_interval_sec } else { 0 }; + + // On the first recording, set rotate time to not the next rotate offset, but + // the one after, so that it's longer than usual rather than shorter than + // usual. This ensures there's plenty of frame times to use when calculating + // the start time. + let r = r + if prev.is_none() { self.rotate_interval_sec } else { 0 }; let w = self.dir.create_writer(&self.syncer_channel, prev, self.camera_id, video_sample_entry_id)?;