fix incorrect prev_media_duration_90k calculation

I spotted this by inspection: adding a media time and wall time didn't
look right. I also confirmed the brokenness on my primary NVR:

```
sqlite> .mode column
sqlite> select
   ...>   r1.composite_id,
   ...>   r1.prev_media_duration_90k,
   ...>   r1.wall_duration_90k,
   ...>   r1.media_duration_delta_90k,
   ...>   r2.composite_id,
   ...>   r2.prev_media_duration_90k
   ...> from
   ...>   recording r1 join recording r2 on (r1.composite_id = r2.composite_id - 1)
   ...> where
   ...>   r1.prev_media_duration_90k + r1.wall_duration_90k + r1.media_duration_delta_90k !=
   ...>     r2.prev_media_duration_90k
   ...> limit 5;
4296791095    2232623913716            5398956            154                       4296791096    2232629312672
4296791096    2232629312672            5400016            38                        4296791097    2232634712688
4296791097    2232634712688            5400729            105                       4296791098    2232640113417
4296791098    2232640113417            5399024            80                        4296791099    2232645512441
4296791099    2232645512441            5400770            124                       4296791100    2232650913211
```

In the first row, the second recording's prev_media_duration_90k is the
first's prev_media_duration_90k plus its wall time, not its media time.
This commit is contained in:
Scott Lamb 2021-03-25 22:09:29 -07:00
parent 6fd4f8975b
commit f9c46dca89
3 changed files with 7 additions and 2 deletions

View File

@ -9,6 +9,10 @@ Each release is tagged in Git and on the Docker repository
## `v0.6.3` (in progress)
* Compile fix for nightly rust 2021-03-14 and beyond.
* Fix incorrect `prev_media_duration_90k` calculation. No current impact.
This field is intended to be used in an upcoming scrub bar UI, and when
not calculated properly there might be unexpected gaps or overlaps in
playback.
## `v0.6.2`

View File

@ -826,7 +826,7 @@ impl LockedDatabase {
Some(s) => {
let l = s.lock();
r.prev_media_duration =
l.prev_media_duration + recording::Duration(l.wall_duration_90k.into());
l.prev_media_duration + recording::Duration(l.media_duration_90k.into());
r.prev_runs = l.prev_runs + if l.run_offset == 0 { 1 } else { 0 };
}
None => {

View File

@ -192,7 +192,8 @@ create table recording (
wall_duration_90k integer not null
check (wall_duration_90k >= 0 and wall_duration_90k < 5*60*90000),
-- TODO: comment.
-- The media-time duration of the recording, relative to wall_duration_90k.
-- That is, media_duration_90k = wall_duration_90k + media_duration_delta_90k.
media_duration_delta_90k integer not null,
video_samples integer not null check (video_samples > 0),