From 924412d3fa0bc1f33d6dd40a99dd0f3b60477691 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Wed, 12 Dec 2012 14:45:27 +0100 Subject: [PATCH] perex: Fix the autorec init issue (duplicate entries) With the last change, the scheduled events may be duplicated. Split the dvr_autorec_init() to two phases: 1) load the autorec list 2) update the scheduled events after dvr db is initialized --- src/dvr/dvr.h | 2 ++ src/dvr/dvr_autorec.c | 16 +++++++++++++++- src/dvr/dvr_db.c | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/dvr/dvr.h b/src/dvr/dvr.h index 23075f4..b9bd2bc 100644 --- a/src/dvr/dvr.h +++ b/src/dvr/dvr.h @@ -280,6 +280,8 @@ void dvr_init(void); void dvr_autorec_init(void); +void dvr_autorec_update(void); + void dvr_destroy_by_channel(channel_t *ch); void dvr_rec_subscribe(dvr_entry_t *de); diff --git a/src/dvr/dvr_autorec.c b/src/dvr/dvr_autorec.c index fb1fcba..ecd2737 100644 --- a/src/dvr/dvr_autorec.c +++ b/src/dvr/dvr_autorec.c @@ -38,6 +38,8 @@ dtable_t *autorec_dt; TAILQ_HEAD(dvr_autorec_entry_queue, dvr_autorec_entry); +static int dvr_autorec_in_init = 0; + struct dvr_autorec_entry_queue autorec_entries; static void dvr_autorec_changed(dvr_autorec_entry_t *dae); @@ -496,7 +498,8 @@ autorec_record_update(void *opaque, const char *id, htsmsg_t *values, if (dae->dae_serieslink) dae->dae_serieslink->getref(dae->dae_serieslink); } - dvr_autorec_changed(dae); + if (!dvr_autorec_in_init) + dvr_autorec_changed(dae); return autorec_record_build(dae); } @@ -539,7 +542,18 @@ dvr_autorec_init(void) { TAILQ_INIT(&autorec_entries); autorec_dt = dtable_create(&autorec_dtc, "autorec", NULL); + dvr_autorec_in_init = 1; dtable_load(autorec_dt); + dvr_autorec_in_init = 0; +} + +void +dvr_autorec_update(void) +{ + dvr_autorec_entry_t *dae; + TAILQ_FOREACH(dae, &autorec_entries, dae_link) { + dvr_autorec_changed(dae); + } } static void diff --git a/src/dvr/dvr_db.c b/src/dvr/dvr_db.c index 707b85c..b219705 100644 --- a/src/dvr/dvr_db.c +++ b/src/dvr/dvr_db.c @@ -1104,6 +1104,7 @@ dvr_init(void) dvr_autorec_init(); dvr_db_load(); + dvr_autorec_update(); } /** -- 1.7.11.7