From: E.Smith <31170571+azlm8t@users.noreply.github.com> Date: Thu, 20 Sep 2018 22:08:06 +0000 (+0100) Subject: dvr: Ensure non-scheduled dvr_entry is always "best". X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b40e46b510be0d4d67d47715709fdf537ef500e;p=thirdparty%2Ftvheadend.git dvr: Ensure non-scheduled dvr_entry is always "best". Previously in dvr_is_better_recording_timeslot we would sanity check that the old channel and broadcast exists before further checks. However, it probably makes sense to ensure that a non-scheduled dvr_entry (such as already recorded) is always the better match even though it might not be linked to any broadcasts. --- diff --git a/src/dvr/dvr_db.c b/src/dvr/dvr_db.c index 7de212fb9..4c91620bc 100644 --- a/src/dvr/dvr_db.c +++ b/src/dvr/dvr_db.c @@ -1702,6 +1702,12 @@ static dvr_entry_t *_dvr_duplicate_event(dvr_entry_t *de) static int dvr_is_better_recording_timeslot(const epg_broadcast_t *new_bcast, const dvr_entry_t *old_de) { + /* If programme is recording (or completed) then it is the "best", + * even if a better schedule is found after recording starts. + */ + if (old_de->de_sched_state != DVR_SCHEDULED) + return 0; + if (!old_de || !old_de->de_bcast) return 1; /* Old broadcast should always exist */ int old_services = 0; int new_services = 0; @@ -1715,12 +1721,6 @@ dvr_is_better_recording_timeslot(const epg_broadcast_t *new_bcast, const dvr_ent if (!new_channel) return 0; if (!old_channel) return 1; - /* If programme is recording then it is the "best", even if a better - * schedule is found after recording starts. - */ - if (old_de->de_sched_state != DVR_SCHEDULED) - return 0; - /* Always prefer a recording that has the correct service profile * (UHD, HD, SD). Someone mentioned (#1846) that some channels can * show a recording earlier in the week in SD then later in the week