From: Jaroslav Kysela Date: Tue, 5 May 2015 15:02:21 +0000 (+0200) Subject: DVR: cleanup EPG event assignment, add notification for EPG grid view X-Git-Tag: v4.1~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0d7107283aa62859f18641de7cdacaa5207c022;p=thirdparty%2Ftvheadend.git DVR: cleanup EPG event assignment, add notification for EPG grid view --- diff --git a/src/dvr/dvr_db.c b/src/dvr/dvr_db.c index 048c966e1..df34385fb 100644 --- a/src/dvr/dvr_db.c +++ b/src/dvr/dvr_db.c @@ -32,6 +32,7 @@ #include "dbus.h" #include "imagecache.h" #include "access.h" +#include "notify.h" struct dvr_entry_list dvrentries; @@ -46,6 +47,31 @@ static void dvr_timer_stop_recording(void *aux); static int dvr_entry_class_disp_title_set(void *o, const void *v); static int dvr_entry_class_disp_subtitle_set(void *o, const void *v); +/* + * + */ +static int +dvr_entry_assign_broadcast(dvr_entry_t *de, epg_broadcast_t *bcast) +{ + char id[16]; + if (bcast != de->de_bcast) { + if (de->de_bcast) { + de->de_bcast->putref((epg_object_t*)de->de_bcast); + snprintf(id, sizeof(id), "%u", de->de_bcast->id); + notify_delayed(id, "epg", "dvr_delete"); + de->de_bcast = NULL; + } + if (bcast) { + bcast->getref((epg_object_t*)bcast); + de->de_bcast = bcast; + snprintf(id, sizeof(id), "%u", bcast->id); + notify_delayed(id, "epg", "dvr_update"); + } + return 1; + } + return 0; +} + /* * Start / stop time calculators */ @@ -917,10 +943,7 @@ static dvr_entry_t *_dvr_entry_update /* Broadcast */ if (e && (de->de_bcast != e)) { - if (de->de_bcast) - de->de_bcast->putref(de->de_bcast); - de->de_bcast = e; - e->getref(e); + dvr_entry_assign_broadcast(de, e); save = 1; } @@ -987,12 +1010,10 @@ dvr_event_replaced(epg_broadcast_t *e, epg_broadcast_t *new_e) if (de->de_sched_state != DVR_SCHEDULED) return; - /* Unlink the broadcast */ - e->putref(e); - de->de_bcast = NULL; - /* If this was created by autorec - just remove it, it'll get recreated */ if (de->de_autorec) { + + dvr_entry_assign_broadcast(de, NULL); dvr_entry_destroy(de, 1); /* Find match */ @@ -1005,12 +1026,12 @@ dvr_event_replaced(epg_broadcast_t *e, epg_broadcast_t *new_e) epg_broadcast_get_title(e, NULL), channel_get_name(e->channel), e->start, e->stop); - e->getref(e); - de->de_bcast = e; + dvr_entry_assign_broadcast(de, e); _dvr_entry_update(de, e, NULL, NULL, NULL, NULL, 0, 0, 0, 0, DVR_PRIO_NOTSET, 0); - break; + return; } } + dvr_entry_assign_broadcast(de, NULL); } } } @@ -1034,8 +1055,7 @@ void dvr_event_updated ( epg_broadcast_t *e ) epg_broadcast_get_title(e, NULL), channel_get_name(e->channel), e->start, e->stop); - e->getref(e); - de->de_bcast = e; + dvr_entry_assign_broadcast(de, e); _dvr_entry_update(de, e, NULL, NULL, NULL, NULL, 0, 0, 0, 0, DVR_PRIO_NOTSET, 0); break; } @@ -1567,20 +1587,7 @@ dvr_entry_class_broadcast_set(void *o, const void *v) if (!dvr_entry_is_editable(de)) return 0; bcast = epg_broadcast_find_by_id(id); - if (bcast == NULL) { - if (de->de_bcast) { - de->de_bcast->putref((epg_object_t*)de->de_bcast); - de->de_bcast = NULL; - return 1; - } - } else if (de->de_bcast != bcast) { - if (de->de_bcast) - de->de_bcast->putref((epg_object_t*)de->de_bcast); - de->de_bcast = bcast; - de->de_bcast->getref((epg_object_t*)bcast); - return 1; - } - return 0; + return dvr_entry_assign_broadcast(de, bcast); } static const void * diff --git a/src/webui/static/app/epg.js b/src/webui/static/app/epg.js index a8c67d9bd..22035c666 100644 --- a/src/webui/static/app/epg.js +++ b/src/webui/static/app/epg.js @@ -864,9 +864,10 @@ tvheadend.epg = function() { * Only do this when the tab is visible, otherwise it won't work as * expected. */ - tvheadend.comet.on('dvrentry', function() { - if (panel.isVisible()) - epgStore.reload(); + tvheadend.comet.on('epg', function(m) { + if (m.dvr_update || m.dvr_change) + if (panel.isVisible()) + epgStore.reload(); }); // Always reload the store when the tab is activated