From: Jaroslav Kysela Date: Mon, 5 Dec 2016 10:00:43 +0000 (+0100) Subject: mi_is_enabled cleanup and fixes - add three states (RETRY,NEVER,OK) X-Git-Tag: v4.2.1~197 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=821ebf5fff73072d7bcf20947b725b1812fd4532;p=thirdparty%2Ftvheadend.git mi_is_enabled cleanup and fixes - add three states (RETRY,NEVER,OK) --- diff --git a/src/input/mpegts.h b/src/input/mpegts.h index b1412decf..d7fb16130 100644 --- a/src/input/mpegts.h +++ b/src/input/mpegts.h @@ -655,6 +655,12 @@ struct mpegts_mux_sub int mms_weight; }; +enum mpegts_input_is_enabled { + MI_IS_ENABLED_RETRY = -1, + MI_IS_ENABLED_NEVER = 0, + MI_IS_ENABLED_OK = 1, +}; + /* Input source */ struct mpegts_input { diff --git a/src/input/mpegts/iptv/iptv.c b/src/input/mpegts/iptv/iptv.c index e932c2b05..7bd046bea 100644 --- a/src/input/mpegts/iptv/iptv.c +++ b/src/input/mpegts/iptv/iptv.c @@ -192,8 +192,10 @@ static int iptv_input_is_enabled ( mpegts_input_t *mi, mpegts_mux_t *mm, int flags, int weight ) { - if (!mpegts_input_is_enabled(mi, mm, flags, weight)) return 0; - return iptv_input_is_free(mi, mm, 0, weight, NULL) == NULL ? 1 : -1; + if (mpegts_input_is_enabled(mi, mm, flags, weight) == MI_IS_ENABLED_NEVER) + return MI_IS_ENABLED_NEVER; + return iptv_input_is_free(mi, mm, 0, weight, NULL) == NULL ? + MI_IS_ENABLED_OK : MI_IS_ENABLED_RETRY; } static int diff --git a/src/input/mpegts/linuxdvb/linuxdvb_adapter.c b/src/input/mpegts/linuxdvb/linuxdvb_adapter.c index 5183fe307..5b037322e 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_adapter.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_adapter.c @@ -133,7 +133,7 @@ linuxdvb_adapter_is_enabled ( linuxdvb_adapter_t *la ) { linuxdvb_frontend_t *lfe; LIST_FOREACH(lfe, &la->la_frontends, lfe_link) { - if (lfe->mi_is_enabled((mpegts_input_t*)lfe, NULL, 0, -1)) + if (lfe->mi_is_enabled((mpegts_input_t*)lfe, NULL, 0, -1) != MI_IS_ENABLED_NEVER) return 1; } return 0; diff --git a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c index 3e3b1ad86..c48e936a3 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c @@ -483,11 +483,16 @@ linuxdvb_frontend_is_enabled tvh_hardware_t *th; char ubuf[UUID_HEX_SIZE]; - if (lfe->lfe_fe_path == NULL) return 0; - if (!mpegts_input_is_enabled(mi, mm, flags, weight)) return 0; - if (access(lfe->lfe_fe_path, R_OK | W_OK)) return 0; - if (lfe->lfe_in_setup) return 0; - if (lfe->lfe_type != DVB_TYPE_S) return 1; + if (lfe->lfe_fe_path == NULL) + return MI_IS_ENABLED_NEVER; + if (!mpegts_input_is_enabled(mi, mm, flags, weight)) + return MI_IS_ENABLED_NEVER; + if (access(lfe->lfe_fe_path, R_OK | W_OK)) + return MI_IS_ENABLED_NEVER; + if (lfe->lfe_in_setup) + return MI_IS_ENABLED_RETRY; + if (lfe->lfe_type != DVB_TYPE_S) + return MI_IS_ENABLED_OK; /* check if any "blocking" tuner is running */ LIST_FOREACH(th, &tvh_hardware, th_link) { @@ -498,21 +503,23 @@ linuxdvb_frontend_is_enabled if (lfe2->lfe_type != DVB_TYPE_S) continue; if (lfe->lfe_master && !strcmp(lfe->lfe_master, idnode_uuid_as_str(&lfe2->ti_id, ubuf))) { if (lfe2->lfe_satconf == NULL) - return 0; /* invalid master */ + return MI_IS_ENABLED_NEVER; /* invalid master */ if (lfe2->lfe_refcount <= 0) - return 0; /* prefer master */ - return linuxdvb_satconf_match_mux(lfe2->lfe_satconf, mm); + return MI_IS_ENABLED_RETRY; /* prefer master */ + return linuxdvb_satconf_match_mux(lfe2->lfe_satconf, mm) ? + MI_IS_ENABLED_OK : MI_IS_ENABLED_RETRY; } if (lfe2->lfe_master && !strcmp(lfe2->lfe_master, idnode_uuid_as_str(&lfe->ti_id, ubuf)) && lfe2->lfe_refcount > 0) { if (lfe->lfe_satconf == NULL) - return 0; - return linuxdvb_satconf_match_mux(lfe->lfe_satconf, mm); + return MI_IS_ENABLED_NEVER; + return linuxdvb_satconf_match_mux(lfe->lfe_satconf, mm) ? + MI_IS_ENABLED_OK : MI_IS_ENABLED_RETRY; } } } - return 1; + return MI_IS_ENABLED_OK; } static void diff --git a/src/input/mpegts/mpegts_input.c b/src/input/mpegts/mpegts_input.c index d8447d106..5f1b15ddb 100644 --- a/src/input/mpegts/mpegts_input.c +++ b/src/input/mpegts/mpegts_input.c @@ -347,12 +347,12 @@ mpegts_input_is_enabled ( mpegts_input_t *mi, mpegts_mux_t *mm, int flags, int weight ) { if ((flags & SUBSCRIPTION_EPG) != 0 && !mi->mi_ota_epg) - return 0; + return MI_IS_ENABLED_NEVER; if ((flags & SUBSCRIPTION_INITSCAN) != 0 && !mi->mi_initscan) - return 0; + return MI_IS_ENABLED_NEVER; if ((flags & SUBSCRIPTION_IDLESCAN) != 0 && !mi->mi_idlescan) - return 0; - return mi->mi_enabled; + return MI_IS_ENABLED_NEVER; + return mi->mi_enabled ? MI_IS_ENABLED_OK : MI_IS_ENABLED_NEVER; } void diff --git a/src/input/mpegts/mpegts_mux_dvb.c b/src/input/mpegts/mpegts_mux_dvb.c index c2255a116..35bc57a17 100644 --- a/src/input/mpegts/mpegts_mux_dvb.c +++ b/src/input/mpegts/mpegts_mux_dvb.c @@ -943,7 +943,7 @@ dvb_mux_create_instances ( mpegts_mux_t *mm ) mpegts_network_link_t *mnl; LIST_FOREACH(mnl, &mm->mm_network->mn_inputs, mnl_mn_link) { mpegts_input_t *mi = mnl->mnl_input; - if (mi->mi_is_enabled(mi, mm, 0, -1)) + if (mi->mi_is_enabled(mi, mm, 0, -1) != MI_IS_ENABLED_NEVER) mi->mi_create_mux_instance(mi, mm); } } diff --git a/src/input/mpegts/mpegts_service.c b/src/input/mpegts/mpegts_service.c index 7bc7e5b75..b7381e51b 100644 --- a/src/input/mpegts/mpegts_service.c +++ b/src/input/mpegts/mpegts_service.c @@ -310,9 +310,9 @@ mpegts_service_enlist_raw continue; r = mi->mi_is_enabled(mi, mmi->mmi_mux, flags, weight); - if (!r) + if (r == MI_IS_ENABLED_NEVER) continue; - if (r < 0) { + if (r == MI_IS_ENABLED_RETRY) { /* temporary error - retry later */ errcnt++; continue; diff --git a/src/input/mpegts/satip/satip_frontend.c b/src/input/mpegts/satip/satip_frontend.c index ad5117b35..75f993389 100644 --- a/src/input/mpegts/satip/satip_frontend.c +++ b/src/input/mpegts/satip/satip_frontend.c @@ -524,28 +524,32 @@ satip_frontend_is_enabled lock_assert(&global_lock); - if (!mpegts_input_is_enabled(mi, mm, flags, weight)) return 0; - if (lfe->sf_device->sd_dbus_allow <= 0) return 0; - if (lfe->sf_type != DVB_TYPE_S) return 1; + if (!mpegts_input_is_enabled(mi, mm, flags, weight)) + return MI_IS_EMABLED_NEVER; + if (lfe->sf_device->sd_dbus_allow <= 0) + return MI_IS_ENABLED_NEVER; + if (lfe->sf_type != DVB_TYPE_S) + return MI_IS_ENABLED_OK; /* check if the position is enabled */ sfc = satip_satconf_get_position(lfe, mm, NULL, 1, flags, weight); - if (!sfc) - return 0; + if (!sfc) return MI_IS_ENABLED_NEVER; /* check if any "blocking" tuner is running */ TAILQ_FOREACH(lfe2, &lfe->sf_device->sd_frontends, sf_link) { if (lfe2 == lfe) continue; if (lfe2->sf_type != DVB_TYPE_S) continue; if (lfe->sf_master == lfe2->sf_number) { if (!lfe2->sf_running) - return 0; /* master must be running */ - return satip_frontend_match_satcfg(lfe2, mm, flags, weight); + return MI_IS_ENABLED_RETRY; /* master must be running */ + return satip_frontend_match_satcfg(lfe2, mm, flags, weight) ? + MI_IS_ENABLED_OK : MI_IS_ENABLED_RETRY; } if (lfe2->sf_master == lfe->sf_number) { if (lfe2->sf_running) - return satip_frontend_match_satcfg(lfe2, mm, flags, weight); + return satip_frontend_match_satcfg(lfe2, mm, flags, weight) ? + MI_IS_ENABLED_OK : MI_IS_ENABLED_RETRY; } } - return 1; + return MI_IS_ENABLED_OK; } static void