Remove unused channels (temp hack) and include epg save stats. Also remove some printfs from htsp code.

This commit is contained in:
Adam Sutton 2012-05-25 12:27:58 +01:00
parent fef7afdacb
commit 5329a9959e
2 changed files with 28 additions and 10 deletions

View file

@ -130,32 +130,47 @@ void epg_save ( void )
{ {
int fd; int fd;
epg_object_t *eo, *ec; epg_object_t *eo, *ec;
epggrab_stats_t stats;
fd = hts_settings_open_file(1, "epgdb"); fd = hts_settings_open_file(1, "epgdb");
/* Channels */ /* Channels */
memset(&stats, 0, sizeof(stats));
if ( _epg_write_sect(fd, "channels") ) return; if ( _epg_write_sect(fd, "channels") ) return;
RB_FOREACH(eo, &epg_channels, glink) { RB_FOREACH(eo, &epg_channels, glink) {
if (_epg_write(fd, epg_channel_serialize((epg_channel_t*)eo))) return; if (_epg_write(fd, epg_channel_serialize((epg_channel_t*)eo))) return;
stats.channels.total++;
} }
if ( _epg_write_sect(fd, "brands") ) return; if ( _epg_write_sect(fd, "brands") ) return;
RB_FOREACH(eo, &epg_brands, glink) { RB_FOREACH(eo, &epg_brands, glink) {
if (_epg_write(fd, epg_brand_serialize((epg_brand_t*)eo))) return; if (_epg_write(fd, epg_brand_serialize((epg_brand_t*)eo))) return;
stats.brands.total++;
} }
if ( _epg_write_sect(fd, "seasons") ) return; if ( _epg_write_sect(fd, "seasons") ) return;
RB_FOREACH(eo, &epg_seasons, glink) { RB_FOREACH(eo, &epg_seasons, glink) {
if (_epg_write(fd, epg_season_serialize((epg_season_t*)eo))) return; if (_epg_write(fd, epg_season_serialize((epg_season_t*)eo))) return;
stats.seasons.total++;
} }
if ( _epg_write_sect(fd, "episodes") ) return; if ( _epg_write_sect(fd, "episodes") ) return;
RB_FOREACH(eo, &epg_episodes, glink) { RB_FOREACH(eo, &epg_episodes, glink) {
if (_epg_write(fd, epg_episode_serialize((epg_episode_t*)eo))) return; if (_epg_write(fd, epg_episode_serialize((epg_episode_t*)eo))) return;
stats.episodes.total++;
} }
if ( _epg_write_sect(fd, "broadcasts") ) return; if ( _epg_write_sect(fd, "broadcasts") ) return;
RB_FOREACH(ec, &epg_channels, glink) { RB_FOREACH(ec, &epg_channels, glink) {
RB_FOREACH(eo, &((epg_channel_t*)ec)->schedule, glink) { RB_FOREACH(eo, &((epg_channel_t*)ec)->schedule, glink) {
if (_epg_write(fd, epg_broadcast_serialize((epg_broadcast_t*)eo))) return; if (_epg_write(fd, epg_broadcast_serialize((epg_broadcast_t*)eo))) return;
stats.broadcasts.total++;
} }
} }
/* Stats */
tvhlog(LOG_DEBUG, "epg", "database saved");
tvhlog(LOG_DEBUG, "epg", " channels %d", stats.channels.total);
tvhlog(LOG_DEBUG, "epg", " brands %d", stats.brands.total);
tvhlog(LOG_DEBUG, "epg", " seasons %d", stats.seasons.total);
tvhlog(LOG_DEBUG, "epg", " episodes %d", stats.episodes.total);
tvhlog(LOG_DEBUG, "epg", " broadcasts %d", stats.broadcasts.total);
} }
void epg_init ( void ) void epg_init ( void )
@ -249,11 +264,11 @@ void epg_init ( void )
/* Stats */ /* Stats */
tvhlog(LOG_DEBUG, "epg", "database loaded"); tvhlog(LOG_DEBUG, "epg", "database loaded");
tvhlog(LOG_DEBUG, "epg", "channels %d", stats.channels.total); tvhlog(LOG_DEBUG, "epg", " channels %d", stats.channels.total);
tvhlog(LOG_DEBUG, "epg", "brands %d", stats.brands.total); tvhlog(LOG_DEBUG, "epg", " brands %d", stats.brands.total);
tvhlog(LOG_DEBUG, "epg", "seasons %d", stats.seasons.total); tvhlog(LOG_DEBUG, "epg", " seasons %d", stats.seasons.total);
tvhlog(LOG_DEBUG, "epg", "episodes %d", stats.episodes.total); tvhlog(LOG_DEBUG, "epg", " episodes %d", stats.episodes.total);
tvhlog(LOG_DEBUG, "epg", "broadcasts %d", stats.broadcasts.total); tvhlog(LOG_DEBUG, "epg", " broadcasts %d", stats.broadcasts.total);
/* Close file */ /* Close file */
munmap(mem, st.st_size); munmap(mem, st.st_size);
@ -1058,16 +1073,24 @@ static void _epg_channel_timer_callback ( void *p )
static void _epg_channel_destroy ( epg_object_t *eo ) static void _epg_channel_destroy ( epg_object_t *eo )
{ {
epg_object_t *ebc;
epg_channel_t *ec = (epg_channel_t*)eo; epg_channel_t *ec = (epg_channel_t*)eo;
if (ec->channel) { if (ec->channel) {
tvhlog(LOG_CRIT, "epg", "attempt to destroy mapped channel"); tvhlog(LOG_CRIT, "epg", "attempt to destroy mapped channel");
assert(0); assert(0);
} }
#if TODO_WHAT_SHOULD_BE_DONE
if (RB_FIRST(&ec->schedule)) { if (RB_FIRST(&ec->schedule)) {
tvhlog(LOG_CRIT, "epg", "attempt to destroy channel with schedule"); tvhlog(LOG_CRIT, "epg", "attempt to destroy channel with schedule");
assert(0); assert(0);
} }
#endif
_epg_object_destroy(eo, &epg_channels); _epg_object_destroy(eo, &epg_channels);
// TODO: should we be doing this?
while ((ebc = RB_FIRST(&ec->schedule))) {
RB_REMOVE(&ec->schedule, ebc, glink);
ebc->putref(ebc);
}
gtimer_disarm(&ec->expire); gtimer_disarm(&ec->expire);
if (ec->name) free(ec->name); if (ec->name) free(ec->name);
#if TODO_NOT_IMPLEMENTED #if TODO_NOT_IMPLEMENTED

View file

@ -298,7 +298,6 @@ htsp_build_channel(channel_t *ch, const char *method)
channel_tag_t *ct; channel_tag_t *ct;
service_t *t; service_t *t;
epg_broadcast_t *now, *next = NULL; epg_broadcast_t *now, *next = NULL;
printf("htsp_build_channel(%s)\n", ch->ch_name);
htsmsg_t *out = htsmsg_create_map(); htsmsg_t *out = htsmsg_create_map();
htsmsg_t *tags = htsmsg_create_list(); htsmsg_t *tags = htsmsg_create_list();
@ -314,7 +313,6 @@ htsp_build_channel(channel_t *ch, const char *method)
if (ch->ch_epg_channel) { if (ch->ch_epg_channel) {
now = ch->ch_epg_channel->now; now = ch->ch_epg_channel->now;
next = ch->ch_epg_channel->next; next = ch->ch_epg_channel->next;
printf(" now = %p, next = %p\n", now, next);
htsmsg_add_u32(out, "eventId", now ? now->_.id : 0); htsmsg_add_u32(out, "eventId", now ? now->_.id : 0);
htsmsg_add_u32(out, "nextEventId", next ? next->_.id : 0); htsmsg_add_u32(out, "nextEventId", next ? next->_.id : 0);
} }
@ -755,7 +753,6 @@ htsp_build_event(epg_broadcast_t *e)
#if TODO_DVR #if TODO_DVR
dvr_entry_t *de; dvr_entry_t *de;
#endif #endif
printf("htsp_build_event(%p, %lu)\n", e, e->_.id);
out = htsmsg_create_map(); out = htsmsg_create_map();
@ -810,7 +807,6 @@ htsp_method_getEvents(htsp_connection_t *htsp, htsmsg_t *in)
if(htsmsg_get_u32(in, "numFollowing", &numFollowing)) if(htsmsg_get_u32(in, "numFollowing", &numFollowing))
return htsp_error("Missing argument 'numFollowing'"); return htsp_error("Missing argument 'numFollowing'");
printf("htsp_method_getEvents(%d, %d)\n", eventid, numFollowing);
if((e = epg_broadcast_find_by_id(eventid, NULL)) == NULL) { if((e = epg_broadcast_find_by_id(eventid, NULL)) == NULL) {
return htsp_error("Event does not exist"); return htsp_error("Event does not exist");
@ -844,7 +840,6 @@ htsp_method_getEvent(htsp_connection_t *htsp, htsmsg_t *in)
if(htsmsg_get_u32(in, "eventId", &eventid)) if(htsmsg_get_u32(in, "eventId", &eventid))
return htsp_error("Missing argument 'eventId'"); return htsp_error("Missing argument 'eventId'");
printf("htsp_method_getEvent(%d)", eventid);
if((e = epg_broadcast_find_by_id(eventid, NULL)) == NULL) if((e = epg_broadcast_find_by_id(eventid, NULL)) == NULL)
return htsp_error("Event does not exist"); return htsp_error("Event does not exist");