Skip to content

Commit

Permalink
fix a few glitches for playback of recordings with t_start=0 when oth…
Browse files Browse the repository at this point in the history
…er timestamps are large.
  • Loading branch information
cwiede committed Mar 21, 2024
1 parent 82d7018 commit ce142f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions nexxT/filters/GenericReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,14 +382,21 @@ def onSuggestDynamicPorts(self):

def _timeSpan(self):
tmin = math.inf
tminNonZero = math.inf
tmax = -math.inf
for p in self._portToIdx:
t = self._file.getRcvTimestamp(p, 0)
tmin = min(t, tmin)
for i in range(self._file.getNumberOfSamples(p)):
t = self._file.getRcvTimestamp(p, i)
tmin = min(t, tmin)
if t != 0:
tminNonZero = min(tminNonZero, t)
break
t = self._file.getRcvTimestamp(p, self._file.getNumberOfSamples(p)-1)
tmax = max(t, tmax)
if tmin > tmax:
raise RuntimeError("It seems that the input file doesn't have any usable samples.")
if tmin == 0 and tminNonZero > 60*24*self._file.getTimestampResolution():
tmin = tminNonZero
return (tmin*(1000000000//self._file.getTimestampResolution()),
tmax*(1000000000//self._file.getTimestampResolution()))

Expand Down Expand Up @@ -431,7 +438,8 @@ def _transmitNextSample(self):
while time.perf_counter_ns() - nowTime < deltaT_ns:
pass
else:
self._timer.start(deltaT_ns//1000000)
if deltaT_ns < 10e9:
self._timer.start(deltaT_ns//1000000)
break
else:
self.pausePlayback()
Expand Down
2 changes: 1 addition & 1 deletion nexxT/services/gui/PlaybackControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def _currentTimestampChanged(self, currentTime):
if self.beginTime is None:
self.currentLabel.setText("")
else:
sliderVal = (currentTime - self.beginTime) // 1000000 # nanoseconds to milliseconds
sliderVal = max(0, currentTime - self.beginTime) // 1000000 # nanoseconds to milliseconds
self.preventSeek = True
self.positionSlider.setValue(sliderVal)
self.preventSeek = False
Expand Down

0 comments on commit ce142f2

Please sign in to comment.