From 290f67735db3d310b3f60cef7dccb14693310661 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 2 May 2021 00:06:50 +0200 Subject: [PATCH] improve decoding file switchover --- owrx/audio/wav.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/owrx/audio/wav.py b/owrx/audio/wav.py index 253e905..4843c25 100644 --- a/owrx/audio/wav.py +++ b/owrx/audio/wav.py @@ -56,7 +56,9 @@ class AudioWriter(object): return WaveFile(filename) def getNextDecodingTime(self): - t = datetime.utcnow() + # add one second to have the intervals tick over one second earlier + # this avoids filename collisions, but also avoids decoding wave files with less than one second of audio + t = datetime.utcnow() + timedelta(seconds=1) zeroed = t.replace(minute=0, second=0, microsecond=0) delta = t - zeroed seconds = (int(delta.total_seconds() / self.interval) + 1) * self.interval