From: Adam Sutton Date: Tue, 22 Apr 2014 09:01:09 +0000 (+0100) Subject: mpegts: some minor changes to init / shutdown to avoid pointless errors X-Git-Tag: v4.1~2128 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=34ab2929d2e33a8f2feee7ee6aeff6ac0dbb3e00;p=thirdparty%2Ftvheadend.git mpegts: some minor changes to init / shutdown to avoid pointless errors --- diff --git a/Makefile b/Makefile index d93c70bb2..466d64057 100644 --- a/Makefile +++ b/Makefile @@ -169,6 +169,7 @@ SRCS += src/muxer.c \ # MPEGTS core SRCS-$(CONFIG_MPEGTS) += \ + src/input/mpegts.c \ src/input/mpegts/mpegts_input.c \ src/input/mpegts/mpegts_network.c \ src/input/mpegts/mpegts_mux.c \ diff --git a/src/api/api_idnode.c b/src/api/api_idnode.c index e8452ac43..3e951ea1b 100644 --- a/src/api/api_idnode.c +++ b/src/api/api_idnode.c @@ -17,9 +17,6 @@ * along with this program. If not, see . */ -#ifndef __TVH_API_IDNODE_H__ -#define __TVH_API_IDNODE_H__ - #include "tvheadend.h" #include "access.h" #include "idnode.h" @@ -433,6 +430,3 @@ void api_idnode_init ( void ) api_register_all(ah); } - - -#endif /* __TVH_API_IDNODE_H__ */ diff --git a/src/idnode.c b/src/idnode.c index 15ad9095a..f068dba9a 100644 --- a/src/idnode.c +++ b/src/idnode.c @@ -45,9 +45,6 @@ static void* idnode_thread(void* p); SKEL_DECLARE(idclasses_skel, idclass_link_t); -static void -idclass_register(const idclass_t *idc); - /* ************************************************************************** * Utilities * *************************************************************************/ @@ -787,7 +784,7 @@ ic_cmp ( const idclass_link_t *a, const idclass_link_t *b ) return strcmp(a->idc->ic_class, b->idc->ic_class); } -static void +void idclass_register(const idclass_t *idc) { while (idc) { diff --git a/src/idnode.h b/src/idnode.h index 20d419015..4bab5b9c2 100644 --- a/src/idnode.h +++ b/src/idnode.h @@ -130,6 +130,7 @@ void idnode_notify void idnode_notify_simple (void *in); void idnode_notify_title_changed (void *in); +void idclass_register ( const idclass_t *idc ); const idclass_t *idclass_find ( const char *name ); htsmsg_t *idclass_serialize0 (const idclass_t *idc, int optmask); htsmsg_t *idnode_serialize0 (idnode_t *self, int optmask); diff --git a/src/input/mpegts.c b/src/input/mpegts.c new file mode 100644 index 000000000..8f2a0a5cc --- /dev/null +++ b/src/input/mpegts.c @@ -0,0 +1,83 @@ +/* + * TVheadend + * Copyright (C) 2013 Adam Sutton + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "input.h" + +void +mpegts_init ( int linuxdvb_mask, str_list_t *tsfiles, int tstuners ) +{ + /* Register classes (avoid API 400 errors due to not yet defined) */ + idclass_register(&mpegts_network_class); + idclass_register(&mpegts_mux_class); + idclass_register(&mpegts_service_class); + + /* Setup DVB networks */ +#if ENABLE_MPEGTS_DVB + dvb_network_init(); +#endif + + /* TS files */ +#if ENABLE_TSFILE + if(tsfiles->num) { + int i; + tsfile_init(tstuners ?: tsfiles->num); + for (i = 0; i < tsfiles->num; i++) + tsfile_add_file(tsfiles->str[i]); + } +#endif + + /* IPTV */ +#if ENABLE_IPTV + iptv_init(); +#endif + + /* Linux DVB */ +#if ENABLE_LINUXDVB + linuxdvb_init(linuxdvb_mask); +#endif + + /* Mux schedulers */ +#if ENABLE_MPEGTS + mpegts_mux_sched_init(); +#endif + +} + +void +mpegts_done ( void ) +{ + tvhftrace("main", mpegts_mux_sched_done); +#if ENABLE_MPEGTS_DVB + tvhftrace("main", dvb_network_done); +#endif +#if ENABLE_IPTV + tvhftrace("main", iptv_done); +#endif +#if ENABLE_LINUXDVB + tvhftrace("main", linuxdvb_done); +#endif +#if ENABLE_TSFILE + tvhftrace("main", tsfile_done); +#endif +} + +/****************************************************************************** + * Editor Configuration + * + * vim:sts=2:ts=2:sw=2:et + *****************************************************************************/ diff --git a/src/input/mpegts.h b/src/input/mpegts.h index 321c22ae8..a919f8807 100644 --- a/src/input/mpegts.h +++ b/src/input/mpegts.h @@ -64,6 +64,13 @@ extern const idclass_t mpegts_mux_class; extern const idclass_t mpegts_service_class; extern const idclass_t mpegts_input_class; +/* ************************************************************************** + * Setup / Tear down + * *************************************************************************/ + +void mpegts_init ( int linuxdvb_mask, str_list_t *tsfiles, int tstuners ); +void mpegts_done ( void ); + /* ************************************************************************** * Data / SI processing * *************************************************************************/ diff --git a/src/main.c b/src/main.c index f23bec0e2..6f818d186 100644 --- a/src/main.c +++ b/src/main.c @@ -72,12 +72,6 @@ pthread_t main_tid; /* Command line option struct */ -typedef struct str_list -{ - int max; - int num; - char **str; -} str_list_t; typedef struct { const char sopt; const char *lopt; @@ -755,24 +749,8 @@ main(int argc, char **argv) service_init(); -#if ENABLE_TSFILE - if(opt_tsfile.num) { - tsfile_init(opt_tsfile_tuner ?: opt_tsfile.num); - for (i = 0; i < opt_tsfile.num; i++) - tsfile_add_file(opt_tsfile.str[i]); - } -#endif -#if ENABLE_MPEGTS_DVB - dvb_network_init(); -#endif -#if ENABLE_IPTV - iptv_init(); -#endif -#if ENABLE_LINUXDVB - linuxdvb_init(adapter_mask); -#endif #if ENABLE_MPEGTS - mpegts_mux_sched_init(); + mpegts_init(adapter_mask, &opt_tsfile, opt_tsfile_tuner); #endif channel_init(); @@ -841,19 +819,7 @@ main(int argc, char **argv) tvhftrace("main", http_client_done); tvhftrace("main", fsmonitor_done); #if ENABLE_MPEGTS - tvhftrace("main", mpegts_mux_sched_done); -#endif -#if ENABLE_MPEGTS_DVB - tvhftrace("main", dvb_network_done); -#endif -#if ENABLE_IPTV - tvhftrace("main", iptv_done); -#endif -#if ENABLE_LINUXDVB - tvhftrace("main", linuxdvb_done); -#endif -#if ENABLE_TSFILE - tvhftrace("main", tsfile_done); + tvhftrace("main", mpegts_done); #endif // Note: the locking is obviously a bit redundant, but without diff --git a/src/tvheadend.h b/src/tvheadend.h index 858c10c9e..15031f455 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -68,6 +68,13 @@ static inline htsmsg_t *tvheadend_capabilities_list(int check) return r; } +typedef struct str_list +{ + int max; + int num; + char **str; +} str_list_t; + #define PTS_UNSET INT64_C(0x8000000000000000) extern int tvheadend_running;