Skip to content

Commit

Permalink
DVR: add default priority settings to DVR config, too
Browse files Browse the repository at this point in the history
  • Loading branch information
perexg committed May 18, 2017
1 parent f22d943 commit 33cc05b
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 45 deletions.
9 changes: 2 additions & 7 deletions src/dvr/dvr.h
Expand Up @@ -57,6 +57,7 @@ typedef struct dvr_config {
char *dvr_comment;
profile_t *dvr_profile;
char *dvr_storage;
int dvr_pri;
int dvr_clone;
uint32_t dvr_rerecord_errors;
uint32_t dvr_retention_days;
Expand Down Expand Up @@ -111,6 +112,7 @@ typedef enum {
DVR_PRIO_LOW = 3,
DVR_PRIO_UNIMPORTANT = 4,
DVR_PRIO_NOTSET = 5,
DVR_PRIO_DEFAULT = 6,
} dvr_prio_t;

typedef enum {
Expand Down Expand Up @@ -764,13 +766,6 @@ uint32_t dvr_timerec_get_retention_days( dvr_timerec_entry_t *dte );

uint32_t dvr_timerec_get_removal_days( dvr_timerec_entry_t *dte );

/**
*
*/
dvr_prio_t dvr_pri2val(const char *s);

const char *dvr_val2pri(dvr_prio_t v);

/**
* Inotify support
*/
Expand Down
11 changes: 6 additions & 5 deletions src/dvr/dvr_autorec.c
Expand Up @@ -300,7 +300,7 @@ dvr_autorec_create(const char *uuid, htsmsg_t *conf)
}

dae->dae_weekdays = 0x7f;
dae->dae_pri = DVR_PRIO_NORMAL;
dae->dae_pri = DVR_PRIO_DEFAULT;
dae->dae_start = -1;
dae->dae_start_window = -1;
dae->dae_enabled = 1;
Expand Down Expand Up @@ -1185,11 +1185,12 @@ const idclass_t dvr_autorec_entry_class = {
.type = PT_U32,
.id = "pri",
.name = N_("Priority"),
.desc = N_("The priority of any recordings set because of this "
"rule will take precedence and "
"cancel lower-priority events."),
.desc = N_("Priority of the recording. Higher priority entries "
"will take precedence and cancel lower-priority events. "
"The 'Not Set' value inherits the settings from "
"the assigned DVR configuration."),
.list = dvr_entry_class_pri_list,
.def.i = DVR_PRIO_NORMAL,
.def.i = DVR_PRIO_DEFAULT,
.off = offsetof(dvr_autorec_entry_t, dae_pri),
.opts = PO_ADVANCED | PO_DOC_NLIST,
},
Expand Down
11 changes: 11 additions & 0 deletions src/dvr/dvr_config.c
Expand Up @@ -883,6 +883,17 @@ const idclass_t dvr_config_class = {
.opts = PO_ADVANCED,
.group = 1,
},
{
.type = PT_U32,
.id = "pri",
.name = N_("Priority"),
.desc = N_("Priority of the entry, higher-priority entries will "
"take precedence and cancel lower-priority events."),
.list = dvr_entry_class_pri_list,
.def.i = DVR_PRIO_NORMAL,
.off = offsetof(dvr_config_t, dvr_pri),
.opts = PO_SORTKEY | PO_ADVANCED | PO_DOC_NLIST,
},
{
.type = PT_INT,
.id = "cache",
Expand Down
38 changes: 11 additions & 27 deletions src/dvr/dvr_db.c
Expand Up @@ -891,6 +891,7 @@ dvr_entry_create(const char *uuid, htsmsg_t *conf, int clone)
de->de_config = dvr_config_find_by_name_default(NULL);
if (de->de_config)
LIST_INSERT_HEAD(&de->de_config->dvr_entries, de, de_config_link);
de->de_pri = DVR_PRIO_DEFAULT;

idnode_load(&de->de_id, conf);

Expand Down Expand Up @@ -2565,14 +2566,17 @@ static int
dvr_entry_class_pri_set(void *o, const void *v)
{
dvr_entry_t *de = (dvr_entry_t *)o;
return dvr_entry_class_int_set(de, &de->de_pri, *(int *)v);
int pri = *(int *)v;
if (pri == DVR_PRIO_NOTSET || pri < 0 || pri > DVR_PRIO_DEFAULT)
pri = DVR_PRIO_DEFAULT;
return dvr_entry_class_int_set(de, &de->de_pri, pri);
}

htsmsg_t *
dvr_entry_class_pri_list ( void *o, const char *lang )
{
static const struct strtab tab[] = {
{ N_("Not set"), DVR_PRIO_NOTSET },
{ N_("Default"), DVR_PRIO_DEFAULT },
{ N_("Important"), DVR_PRIO_IMPORTANT },
{ N_("High"), DVR_PRIO_HIGH, },
{ N_("Normal"), DVR_PRIO_NORMAL },
Expand Down Expand Up @@ -3206,9 +3210,12 @@ const idclass_t dvr_entry_class = {
.type = PT_INT,
.id = "pri",
.name = N_("Priority"),
.desc = N_("Priority of the recording. Higher priority entries will take precedence and cancel lower-priority events."),
.desc = N_("Priority of the recording. Higher priority entries "
"will take precedence and cancel lower-priority events. "
"The 'Not Set' value inherits the settings from "
"the assigned DVR configuration."),
.off = offsetof(dvr_entry_t, de_pri),
.def.i = DVR_PRIO_NORMAL,
.def.i = DVR_PRIO_DEFAULT,
.set = dvr_entry_class_pri_set,
.list = dvr_entry_class_pri_list,
.opts = PO_SORTKEY | PO_DOC_NLIST | PO_ADVANCED,
Expand Down Expand Up @@ -3551,29 +3558,6 @@ dvr_get_filesize(dvr_entry_t *de, int flags)
return first ? -1 : res;
}

/**
*
*/
static struct strtab priotab[] = {
{ "important", DVR_PRIO_IMPORTANT },
{ "high", DVR_PRIO_HIGH },
{ "normal", DVR_PRIO_NORMAL },
{ "low", DVR_PRIO_LOW },
{ "unimportant", DVR_PRIO_UNIMPORTANT }
};

dvr_prio_t
dvr_pri2val(const char *s)
{
return str2val_def(s, priotab, DVR_PRIO_NORMAL);
}

const char *
dvr_val2pri(dvr_prio_t v)
{
return val2str(v, priotab) ?: "invalid";
}

/**
*
*/
Expand Down
9 changes: 6 additions & 3 deletions src/dvr/dvr_rec.c
Expand Up @@ -69,15 +69,18 @@ dvr_rec_subscribe(dvr_entry_t *de)
struct sockaddr_storage sa;
access_t *aa;
uint32_t rec_count, net_count;
int c1, c2;
int pri, c1, c2;

assert(de->de_s == NULL);
assert(de->de_chain == NULL);

if(de->de_pri >= 0 && de->de_pri < ARRAY_SIZE(prio2weight))
pri = de->de_pri;
if(pri == DVR_PRIO_NOTSET)
pri = de->de_config->dvr_pri;
if(pri >= 0 && pri < ARRAY_SIZE(prio2weight))
weight = prio2weight[de->de_pri];
else
weight = 300;
weight = prio2weight[DVR_PRIO_NORMAL];

snprintf(buf, sizeof(buf), "DVR: %s", lang_str_get(de->de_title, NULL));

Expand Down
9 changes: 6 additions & 3 deletions src/dvr/dvr_timerec.c
Expand Up @@ -185,7 +185,7 @@ dvr_timerec_create(const char *uuid, htsmsg_t *conf)

dte->dte_title = strdup("Time-%F_%R");
dte->dte_weekdays = 0x7f;
dte->dte_pri = DVR_PRIO_NORMAL;
dte->dte_pri = DVR_PRIO_DEFAULT;
dte->dte_start = -1;
dte->dte_stop = -1;
dte->dte_enabled = 1;
Expand Down Expand Up @@ -617,9 +617,12 @@ const idclass_t dvr_timerec_entry_class = {
.type = PT_U32,
.id = "pri",
.name = N_("Priority"),
.desc = N_("Priority of the entry, higher-priority entries will take precedence and cancel lower-priority events."),
.desc = N_("Priority of the recording. Higher priority entries "
"will take precedence and cancel lower-priority events. "
"The 'Not Set' value inherits the settings from "
"the assigned DVR configuration."),
.list = dvr_entry_class_pri_list,
.def.i = DVR_PRIO_NORMAL,
.def.i = DVR_PRIO_DEFAULT,
.off = offsetof(dvr_timerec_entry_t, dte_pri),
.opts = PO_SORTKEY | PO_ADVANCED | PO_DOC_NLIST,
},
Expand Down

0 comments on commit 33cc05b

Please sign in to comment.