linuxdvb: remove the satconf mpegts_input_t proxy to cleanup input handlers
This commit is contained in:
parent
f228fe45c3
commit
c36c733519
11 changed files with 493 additions and 398 deletions
22
src/idnode.c
22
src/idnode.c
|
@ -683,6 +683,17 @@ idnode_set_add
|
|||
is->is_array[is->is_count++] = in;
|
||||
}
|
||||
|
||||
int
|
||||
idnode_set_exists
|
||||
( idnode_set_t *is, idnode_t * in )
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < is->is_count; i++)
|
||||
if (memcmp(is->is_array[i]->in_uuid, in->in_uuid, sizeof(in->in_uuid)) == 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
idnode_set_sort
|
||||
( idnode_set_t *is, idnode_sort_t *sort )
|
||||
|
@ -697,6 +708,17 @@ idnode_set_sort_by_title
|
|||
qsort(is->is_array, is->is_count, sizeof(idnode_t*), idnode_cmp_title);
|
||||
}
|
||||
|
||||
htsmsg_t *
|
||||
idnode_set_as_htsmsg
|
||||
( idnode_set_t *is )
|
||||
{
|
||||
htsmsg_t *l = htsmsg_create_list();
|
||||
int i;
|
||||
for (i = 0; i < is->is_count; i++)
|
||||
htsmsg_add_str(l, NULL, idnode_uuid_as_str(is->is_array[i]));
|
||||
return l;
|
||||
}
|
||||
|
||||
void
|
||||
idnode_set_free ( idnode_set_t *is )
|
||||
{
|
||||
|
|
|
@ -162,8 +162,10 @@ int idnode_filter
|
|||
#define idnode_set_create() calloc(1, sizeof(idnode_set_t))
|
||||
void idnode_set_add
|
||||
( idnode_set_t *is, idnode_t *in, idnode_filter_t *filt );
|
||||
int idnode_set_exists ( idnode_set_t *is, idnode_t *in );
|
||||
void idnode_set_sort ( idnode_set_t *is, idnode_sort_t *s );
|
||||
void idnode_set_sort_by_title ( idnode_set_t *is );
|
||||
htsmsg_t *idnode_set_as_htsmsg ( idnode_set_t *is );
|
||||
void idnode_set_free ( idnode_set_t *is );
|
||||
|
||||
#endif /* __TVH_IDNODE_H__ */
|
||||
|
|
|
@ -468,7 +468,7 @@ struct mpegts_input
|
|||
void (*mi_display_name) (mpegts_input_t*, char *buf, size_t len);
|
||||
int (*mi_is_free) (mpegts_input_t*);
|
||||
int (*mi_get_weight) (mpegts_input_t*);
|
||||
int (*mi_get_priority) (mpegts_input_t*);
|
||||
int (*mi_get_priority) (mpegts_input_t*, mpegts_mux_t *mm);
|
||||
int (*mi_get_grace) (mpegts_input_t*, mpegts_mux_t *mm);
|
||||
int (*mi_start_mux) (mpegts_input_t*,mpegts_mux_instance_t*);
|
||||
void (*mi_stop_mux) (mpegts_input_t*,mpegts_mux_instance_t*);
|
||||
|
@ -644,7 +644,7 @@ void mpegts_input_table_thread_stop( mpegts_input_t *mi );
|
|||
int mpegts_input_is_free ( mpegts_input_t *mi );
|
||||
|
||||
int mpegts_input_get_weight ( mpegts_input_t *mi );
|
||||
int mpegts_input_get_priority ( mpegts_input_t *mi );
|
||||
int mpegts_input_get_priority ( mpegts_input_t *mi, mpegts_mux_t *mm );
|
||||
int mpegts_input_get_grace ( mpegts_input_t *mi, mpegts_mux_t *mm );
|
||||
|
||||
void mpegts_input_save ( mpegts_input_t *mi, htsmsg_t *c );
|
||||
|
|
|
@ -148,7 +148,7 @@ linuxdvb_en50494_tune
|
|||
int ret = 0;
|
||||
int i;
|
||||
linuxdvb_en50494_t *le = (linuxdvb_en50494_t*) ld;
|
||||
linuxdvb_lnb_t *lnb = sc->ls_lnb;
|
||||
linuxdvb_lnb_t *lnb = sc->lse_lnb;
|
||||
|
||||
/* band & polarisation */
|
||||
uint8_t pol = lnb->lnb_pol(lnb, lm);
|
||||
|
@ -179,7 +179,7 @@ linuxdvb_en50494_tune
|
|||
band, freq, data1, data2);
|
||||
|
||||
pthread_mutex_lock(&linuxdvb_en50494_lock);
|
||||
for (i = 0; i <= sc->ls_parent->ls_diseqc_repeats; i++) {
|
||||
for (i = 0; i <= sc->lse_parent->ls_diseqc_repeats; i++) {
|
||||
/* to avoid repeated collision, wait a random time (5-25ms) */
|
||||
if (i != 0) {
|
||||
int ms = rand()%20 + 5;
|
||||
|
|
|
@ -214,6 +214,26 @@ linuxdvb_frontend_get_weight ( mpegts_input_t *mi )
|
|||
return weight;
|
||||
}
|
||||
|
||||
static int
|
||||
linuxdvb_frontend_get_priority ( mpegts_input_t *mi, mpegts_mux_t *mm )
|
||||
{
|
||||
linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)mi;
|
||||
int r = mpegts_input_get_priority(mi, mm);
|
||||
if (lfe->lfe_satconf)
|
||||
r += linuxdvb_satconf_get_priority(lfe->lfe_satconf, mm);
|
||||
return r;
|
||||
}
|
||||
|
||||
static int
|
||||
linuxdvb_frontend_get_grace ( mpegts_input_t *mi, mpegts_mux_t *mm )
|
||||
{
|
||||
linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)mi;
|
||||
int r = 5;
|
||||
if (lfe->lfe_satconf)
|
||||
r = linuxdvb_satconf_get_grace(lfe->lfe_satconf, mm);
|
||||
return r;
|
||||
}
|
||||
|
||||
static int
|
||||
linuxdvb_frontend_is_enabled ( mpegts_input_t *mi )
|
||||
{
|
||||
|
@ -250,12 +270,18 @@ linuxdvb_frontend_stop_mux
|
|||
|
||||
/* Ensure it won't happen immediately */
|
||||
gtimer_arm(&lfe->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, 2);
|
||||
|
||||
if (lfe->lfe_satconf)
|
||||
linuxdvb_satconf_post_stop_mux(lfe->lfe_satconf);
|
||||
}
|
||||
|
||||
static int
|
||||
linuxdvb_frontend_start_mux
|
||||
( mpegts_input_t *mi, mpegts_mux_instance_t *mmi )
|
||||
{
|
||||
linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)mi;
|
||||
if (lfe->lfe_satconf)
|
||||
return linuxdvb_satconf_start_mux(lfe->lfe_satconf, mmi);
|
||||
return linuxdvb_frontend_tune1((linuxdvb_frontend_t*)mi, mmi, -1);
|
||||
}
|
||||
|
||||
|
@ -1100,8 +1126,10 @@ linuxdvb_frontend_create
|
|||
if (!lfe) return NULL;
|
||||
|
||||
/* Callbacks */
|
||||
lfe->mi_is_free = linuxdvb_frontend_is_free;
|
||||
lfe->mi_get_weight = linuxdvb_frontend_get_weight;
|
||||
lfe->mi_is_free = linuxdvb_frontend_is_free;
|
||||
lfe->mi_get_weight = linuxdvb_frontend_get_weight;
|
||||
lfe->mi_get_priority = linuxdvb_frontend_get_priority;
|
||||
lfe->mi_get_grace = linuxdvb_frontend_get_grace;
|
||||
|
||||
/* Default name */
|
||||
if (!lfe->mi_name) {
|
||||
|
|
|
@ -147,31 +147,36 @@ struct linuxdvb_satconf
|
|||
};
|
||||
|
||||
/*
|
||||
* Internal wrapper for a satconf entry
|
||||
*
|
||||
* Note: this is a bit cumbersome, it comes from how I first did the satconf
|
||||
* and was subsequently bullied (by amet) into changing it (probably
|
||||
* for the better, just don't tell him, no danger he'll read this!)
|
||||
*
|
||||
* maybe one day I'll do it again properly
|
||||
* Elementary satconf entry
|
||||
*/
|
||||
struct linuxdvb_satconf_ele
|
||||
{
|
||||
mpegts_input_t; // This acts as proxy for the frontend
|
||||
|
||||
idnode_t lse_id;
|
||||
/*
|
||||
* Parent
|
||||
*/
|
||||
linuxdvb_satconf_t *ls_parent;
|
||||
TAILQ_ENTRY(linuxdvb_satconf_ele) ls_link;
|
||||
linuxdvb_satconf_t *lse_parent;
|
||||
TAILQ_ENTRY(linuxdvb_satconf_ele) lse_link;
|
||||
|
||||
/*
|
||||
* Config
|
||||
*/
|
||||
int lse_enabled;
|
||||
int lse_priority;
|
||||
char *lse_name;
|
||||
|
||||
/*
|
||||
* Assigned networks to this SAT configuration
|
||||
*/
|
||||
idnode_set_t *lse_networks;
|
||||
|
||||
/*
|
||||
* Diseqc kit
|
||||
*/
|
||||
linuxdvb_lnb_t *ls_lnb;
|
||||
linuxdvb_diseqc_t *ls_switch;
|
||||
linuxdvb_diseqc_t *ls_rotor;
|
||||
linuxdvb_diseqc_t *ls_en50494;
|
||||
linuxdvb_lnb_t *lse_lnb;
|
||||
linuxdvb_diseqc_t *lse_switch;
|
||||
linuxdvb_diseqc_t *lse_rotor;
|
||||
linuxdvb_diseqc_t *lse_en50494;
|
||||
};
|
||||
|
||||
struct linuxdvb_diseqc
|
||||
|
@ -346,4 +351,15 @@ linuxdvb_satconf_t *linuxdvb_satconf_create
|
|||
|
||||
void linuxdvb_satconf_delete ( linuxdvb_satconf_t *ls, int delconf );
|
||||
|
||||
int linuxdvb_satconf_get_priority
|
||||
( linuxdvb_satconf_t *ls, mpegts_mux_t *mm );
|
||||
|
||||
int linuxdvb_satconf_get_grace
|
||||
( linuxdvb_satconf_t *ls, mpegts_mux_t *mm );
|
||||
|
||||
void linuxdvb_satconf_post_stop_mux( linuxdvb_satconf_t *ls );
|
||||
|
||||
int linuxdvb_satconf_start_mux
|
||||
( linuxdvb_satconf_t *ls, mpegts_mux_instance_t *mmi );
|
||||
|
||||
#endif /* __TVH_LINUXDVB_PRIVATE_H__ */
|
||||
|
|
|
@ -135,7 +135,7 @@ linuxdvb_rotor_gotox_tune
|
|||
( linuxdvb_rotor_t *lr, linuxdvb_mux_t *lm, linuxdvb_satconf_ele_t *ls, int fd )
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i <= ls->ls_parent->ls_diseqc_repeats; i++) {
|
||||
for (i = 0; i <= ls->lse_parent->ls_diseqc_repeats; i++) {
|
||||
if (linuxdvb_diseqc_send(fd, 0xE0, 0x31, 0x6B, 1, (int)lr->lr_position)) {
|
||||
tvherror("diseqc", "failed to set GOTOX pos %d", lr->lr_position);
|
||||
return -1;
|
||||
|
@ -203,7 +203,7 @@ linuxdvb_rotor_usals_tune
|
|||
fabs(pos), (pos > 0.0) ? 'E' : 'W',
|
||||
motor_angle, (motor_angle > 0.0) ? "counter-" : "");
|
||||
|
||||
for (i = 0; i <= ls->ls_parent->ls_diseqc_repeats; i++) {
|
||||
for (i = 0; i <= ls->lse_parent->ls_diseqc_repeats; i++) {
|
||||
if (linuxdvb_diseqc_send(fd, 0xE0, 0x31, 0x6E, 2, angle_1, angle_2)) {
|
||||
tvherror("diseqc", "failed to send USALS command");
|
||||
return -1;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -120,8 +120,8 @@ linuxdvb_switch_tune
|
|||
linuxdvb_switch_t *ls = (linuxdvb_switch_t*)ld;
|
||||
|
||||
/* LNB settings */
|
||||
pol = (sc->ls_lnb) ? sc->ls_lnb->lnb_pol (sc->ls_lnb, lm) & 0x1 : 0;
|
||||
band = (sc->ls_lnb) ? sc->ls_lnb->lnb_band(sc->ls_lnb, lm) & 0x1 : 0;
|
||||
pol = (sc->lse_lnb) ? sc->lse_lnb->lnb_pol (sc->lse_lnb, lm) & 0x1 : 0;
|
||||
band = (sc->lse_lnb) ? sc->lse_lnb->lnb_band(sc->lse_lnb, lm) & 0x1 : 0;
|
||||
|
||||
/* Set the voltage */
|
||||
if (linuxdvb_diseqc_set_volt(fd, pol))
|
||||
|
@ -131,7 +131,7 @@ linuxdvb_switch_tune
|
|||
com = 0xF0 | (ls->ls_committed << 2) | (pol << 1) | band;
|
||||
|
||||
/* Single committed (before repeats) */
|
||||
if (sc->ls_parent->ls_diseqc_repeats > 0) {
|
||||
if (sc->lse_parent->ls_diseqc_repeats > 0) {
|
||||
r2 = 1;
|
||||
if (linuxdvb_diseqc_send(fd, 0xE0, 0x10, 0x38, 1, com))
|
||||
return -1;
|
||||
|
@ -139,7 +139,7 @@ linuxdvb_switch_tune
|
|||
}
|
||||
|
||||
/* Repeats */
|
||||
for (i = 0; i <= sc->ls_parent->ls_diseqc_repeats; i++) {
|
||||
for (i = 0; i <= sc->lse_parent->ls_diseqc_repeats; i++) {
|
||||
|
||||
/* Uncommitted */
|
||||
if (linuxdvb_diseqc_send(fd, 0xE0 | r1, 0x10, 0x39, 1,
|
||||
|
|
|
@ -197,7 +197,7 @@ mpegts_input_get_weight ( mpegts_input_t *mi )
|
|||
}
|
||||
|
||||
int
|
||||
mpegts_input_get_priority ( mpegts_input_t *mi )
|
||||
mpegts_input_get_priority ( mpegts_input_t *mi, mpegts_mux_t *mm )
|
||||
{
|
||||
return mi->mi_priority;
|
||||
}
|
||||
|
@ -839,7 +839,7 @@ mpegts_input_set_networks ( mpegts_input_t *mi, htsmsg_t *msg )
|
|||
htsmsg_field_t *f;
|
||||
mpegts_network_t *mn;
|
||||
mpegts_network_link_t *mnl, *nxt;
|
||||
|
||||
|
||||
/* Mark for deletion */
|
||||
LIST_FOREACH(mnl, &mi->mi_networks, mnl_mi_link)
|
||||
mnl->mnl_mark = 1;
|
||||
|
|
|
@ -181,7 +181,7 @@ mpegts_service_enlist(service_t *t, struct service_instance_list *sil)
|
|||
p = -1;
|
||||
} else {
|
||||
w = mmi->mmi_input->mi_get_weight(mmi->mmi_input);
|
||||
p = mmi->mmi_input->mi_get_priority(mmi->mmi_input);
|
||||
p = mmi->mmi_input->mi_get_priority(mmi->mmi_input, mmi->mmi_mux);
|
||||
}
|
||||
|
||||
service_instance_add(sil, t, mmi->mmi_input->mi_instance, p, w);
|
||||
|
|
Loading…
Add table
Reference in a new issue