Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mi_is_enabled cleanup and fixes - add three states (RETRY,NEVER,OK)
  • Loading branch information
perexg committed Dec 5, 2016
1 parent b93b557 commit 821ebf5
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 30 deletions.
6 changes: 6 additions & 0 deletions src/input/mpegts.h
Expand Up @@ -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
{
Expand Down
6 changes: 4 additions & 2 deletions src/input/mpegts/iptv/iptv.c
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/linuxdvb/linuxdvb_adapter.c
Expand Up @@ -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;
Expand Down
29 changes: 18 additions & 11 deletions src/input/mpegts/linuxdvb/linuxdvb_frontend.c
Expand Up @@ -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) {
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/input/mpegts/mpegts_input.c
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/mpegts_mux_dvb.c
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/input/mpegts/mpegts_service.c
Expand Up @@ -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;
Expand Down
22 changes: 13 additions & 9 deletions src/input/mpegts/satip/satip_frontend.c
Expand Up @@ -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
Expand Down

0 comments on commit 821ebf5

Please sign in to comment.