Fix #1521 - dvr: some minor corrections to PR code

ensure that recordings are properly loaded in the event no channel
exists and that the internal channel name is preferred not the DE
on.
This commit is contained in:
Adam Sutton 2013-01-31 10:48:15 +00:00
parent ef5ab4bae2
commit 4335797e53
3 changed files with 22 additions and 12 deletions

View file

@ -346,6 +346,7 @@ channel_save(channel_t *ch)
int
channel_rename(channel_t *ch, const char *newname)
{
dvr_entry_t *de;
service_t *t;
lock_assert(&global_lock);
@ -364,6 +365,11 @@ channel_rename(channel_t *ch, const char *newname)
LIST_FOREACH(t, &ch->ch_services, s_ch_link)
t->s_config_save(t);
LIST_FOREACH(de, &ch->ch_dvrs, de_channel_link) {
dvr_entry_save(de);
dvr_entry_notify(de);
}
channel_save(ch);
htsp_channel_update(ch);

View file

@ -200,8 +200,7 @@ typedef struct dvr_entry {
} dvr_entry_t;
#define DVR_CH_NAME(e) ((e)->de_channel_name == NULL ? (e)-> de_channel->ch_name : (e)->de_channel_name)
#define DVR_CH_NAME(e) ((e)->de_channel == NULL ? (e)->de_channel_name : (e)-> de_channel->ch_name)
/**
* Autorec entry

View file

@ -240,10 +240,12 @@ dvr_entry_link(dvr_entry_t *de)
gtimer_arm_abs(&de->de_timer, dvr_timer_expire, de,
de->de_stop + cfg->dvr_retention_days * 86400);
} else {
} else if (de->de_channel) {
de->de_sched_state = DVR_SCHEDULED;
gtimer_arm_abs(&de->de_timer, dvr_timer_start_recording, de, preamble);
} else {
de->de_sched_state = DVR_NOSTATE;
}
htsp_dvr_entry_add(de);
}
@ -473,7 +475,7 @@ static void
dvr_db_load_one(htsmsg_t *c, int id)
{
dvr_entry_t *de;
const char *s, *creator;
const char *chname, *s, *creator;
channel_t *ch;
uint32_t start, stop, bcid;
int d;
@ -485,11 +487,10 @@ dvr_db_load_one(htsmsg_t *c, int id)
if(htsmsg_get_u32(c, "stop", &stop))
return;
if((s = htsmsg_get_str(c, "channel")) == NULL)
if((chname = htsmsg_get_str(c, "channel")) == NULL)
return;
if((ch = channel_find_by_name(s, 0, 1)) == NULL)
return;
ch = channel_find_by_name(chname, 0, 0);
s = htsmsg_get_str(c, "config_name");
cfg = dvr_config_find_by_name_default(s);
@ -504,8 +505,12 @@ dvr_db_load_one(htsmsg_t *c, int id)
de_tally = MAX(id, de_tally);
de->de_channel = ch;
LIST_INSERT_HEAD(&de->de_channel->ch_dvrs, de, de_channel_link);
if (ch) {
de->de_channel = ch;
LIST_INSERT_HEAD(&de->de_channel->ch_dvrs, de, de_channel_link);
} else {
de->de_channel_name = strdup(chname);
}
de->de_start = start;
de->de_stop = stop;
@ -515,7 +520,7 @@ dvr_db_load_one(htsmsg_t *c, int id)
de->de_pri = dvr_pri2val(htsmsg_get_str(c, "pri"));
if(htsmsg_get_s32(c, "start_extra", &d))
if (ch->ch_dvr_extra_time_pre)
if (ch && ch->ch_dvr_extra_time_pre)
de->de_start_extra = ch->ch_dvr_extra_time_pre;
else
de->de_start_extra = cfg->dvr_extra_time_pre;
@ -523,7 +528,7 @@ dvr_db_load_one(htsmsg_t *c, int id)
de->de_start_extra = d;
if(htsmsg_get_s32(c, "stop_extra", &d))
if (ch->ch_dvr_extra_time_post)
if (ch && ch->ch_dvr_extra_time_post)
de->de_stop_extra = ch->ch_dvr_extra_time_post;
else
de->de_stop_extra = cfg->dvr_extra_time_post;