Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
DVR: autorec - remember disabled events during reschedule, fixes #3104
  • Loading branch information
perexg committed Sep 26, 2015
1 parent d664503 commit d09aaca
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/dvr/dvr.h
Expand Up @@ -419,7 +419,7 @@ const char *dvr_entry_status(dvr_entry_t *de);

const char *dvr_entry_schedstatus(dvr_entry_t *de);

void dvr_entry_create_by_autorec(epg_broadcast_t *e, dvr_autorec_entry_t *dae);
void dvr_entry_create_by_autorec(int enabled, epg_broadcast_t *e, dvr_autorec_entry_t *dae);

void dvr_entry_created(dvr_entry_t *de);

Expand Down
46 changes: 36 additions & 10 deletions src/dvr/dvr_autorec.c
Expand Up @@ -39,20 +39,37 @@ struct dvr_autorec_entry_queue autorec_entries;
/**
* Unlink - and remove any unstarted
*/
static void
dvr_autorec_purge_spawns(dvr_autorec_entry_t *dae, int del)
static epg_broadcast_t **
dvr_autorec_purge_spawns(dvr_autorec_entry_t *dae, int del, int disabled)
{
dvr_entry_t *de;
epg_broadcast_t **bcast = NULL, **nbcast;
int i = 0, size = 0;

while((de = LIST_FIRST(&dae->dae_spawns)) != NULL) {
LIST_REMOVE(de, de_autorec_link);
de->de_autorec = NULL;
if (!del) continue;
if (de->de_sched_state == DVR_SCHEDULED)
if (de->de_sched_state == DVR_SCHEDULED) {
if (disabled && !de->de_enabled && de->de_bcast) {
if (i >= size - 1) {
nbcast = realloc(bcast, (size + 16) * sizeof(epg_broadcast_t *));
if (nbcast != NULL) {
bcast = nbcast;
size += 16;
bcast[i++] = de->de_bcast;
}
} else {
bcast[i++] = de->de_bcast;
}
}
dvr_entry_cancel(de);
else
} else
dvr_entry_save(de);
}
if (bcast)
bcast[i] = NULL;
return bcast;
}

/**
Expand Down Expand Up @@ -315,7 +332,7 @@ dvr_autorec_add_series_link(const char *dvr_config_name,
static void
autorec_entry_destroy(dvr_autorec_entry_t *dae, int delconf)
{
dvr_autorec_purge_spawns(dae, delconf);
dvr_autorec_purge_spawns(dae, delconf, 0);

if (delconf)
hts_settings_remove("dvr/autorec/%s", idnode_uuid_as_sstr(&dae->dae_id));
Expand Down Expand Up @@ -1154,7 +1171,7 @@ dvr_autorec_check_event(epg_broadcast_t *e)
return;
TAILQ_FOREACH(dae, &autorec_entries, dae_link)
if(autorec_cmp(dae, e))
dvr_entry_create_by_autorec(e, dae);
dvr_entry_create_by_autorec(1, e, dae);
// Note: no longer updating event here as it will be done from EPG
// anyway
}
Expand Down Expand Up @@ -1184,19 +1201,28 @@ void
dvr_autorec_changed(dvr_autorec_entry_t *dae, int purge)
{
channel_t *ch;
epg_broadcast_t *e;
epg_broadcast_t *e, **disabled = NULL, **p;
int enabled;

if (purge)
dvr_autorec_purge_spawns(dae, 1);
disabled = dvr_autorec_purge_spawns(dae, 1, 1);

CHANNEL_FOREACH(ch) {
if (!ch->ch_enabled) continue;
RB_FOREACH(e, &ch->ch_epg_schedule, sched_link) {
if(autorec_cmp(dae, e))
dvr_entry_create_by_autorec(e, dae);
if(autorec_cmp(dae, e)) {
enabled = 1;
if (disabled) {
for (p = disabled; *p && *p != e; p++);
enabled = *p != NULL;
}
dvr_entry_create_by_autorec(enabled, e, dae);
}
}
}

free(disabled);

htsp_autorec_entry_update(dae);
}

Expand Down
4 changes: 2 additions & 2 deletions src/dvr/dvr_db.c
Expand Up @@ -796,7 +796,7 @@ static dvr_entry_t *_dvr_duplicate_event(dvr_entry_t* de)
*
*/
void
dvr_entry_create_by_autorec(epg_broadcast_t *e, dvr_autorec_entry_t *dae)
dvr_entry_create_by_autorec(int enabled, epg_broadcast_t *e, dvr_autorec_entry_t *dae)
{
char buf[200];
char ubuf[UUID_HEX_SIZE];
Expand All @@ -813,7 +813,7 @@ dvr_entry_create_by_autorec(epg_broadcast_t *e, dvr_autorec_entry_t *dae)
dae->dae_comment ? ": " : "",
dae->dae_comment ?: "");

dvr_entry_create_by_event(1, idnode_uuid_as_str(&dae->dae_config->dvr_id, ubuf),
dvr_entry_create_by_event(enabled, idnode_uuid_as_str(&dae->dae_config->dvr_id, ubuf),
e, dae->dae_start_extra, dae->dae_stop_extra,
dae->dae_owner, dae->dae_creator,
dae, dae->dae_pri, dae->dae_retention, buf);
Expand Down

2 comments on commit d09aaca

@ksooo
Copy link
Contributor

@ksooo ksooo commented on d09aaca Sep 26, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this also make sense for timerecs?

@ksooo
Copy link
Contributor

@ksooo ksooo commented on d09aaca Oct 1, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And could you merge this into 4.0.x, please?

Please sign in to comment.