mpegts: fix issues surrounding service startup on proxied input

I.e. DVB-S where satconf is acting as a proxy for the frontend.
This commit is contained in:
Adam Sutton 2013-06-16 10:48:29 +01:00
parent f69bc70665
commit fa8222a573
5 changed files with 34 additions and 20 deletions

View file

@ -424,6 +424,9 @@ mpegts_input_t *mpegts_input_create0
&mpegts_input_class, u, c)
void mpegts_input_set_network ( mpegts_input_t *mi, mpegts_network_t *mn );
void mpegts_input_open_service ( mpegts_input_t *mi, mpegts_service_t *s );
void mpegts_input_close_service ( mpegts_input_t *mi, mpegts_service_t *s );
mpegts_network_t *mpegts_network_create0
( mpegts_network_t *mn, const idclass_t *idc, const char *uuid,

View file

@ -363,8 +363,7 @@ linuxdvb_frontend_open_service
linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)mi;
/* Ignore in full rx mode OR if not yet locked */
if (lfe->lfe_fullmux || !lfe->lfe_locked)
return;
if (!lfe->lfe_locked || lfe->lfe_fullmux) goto exit;
mi->mi_display_name(mi, buf, sizeof(buf));
/* Install PES filters */
@ -379,6 +378,9 @@ linuxdvb_frontend_open_service
st->es_demuxer_fd
= linuxdvb_frontend_open_pid((linuxdvb_frontend_t*)mi, st->es_pid, buf);
}
exit:
mpegts_input_open_service(mi, s);
}
static void
@ -388,8 +390,10 @@ linuxdvb_frontend_close_service
linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)mi;
/* Ignore in full rx mode OR if not yet locked */
if (lfe->lfe_fullmux || !lfe->lfe_locked)
return;
if (!lfe->lfe_locked || lfe->lfe_fullmux) goto exit;
exit:
mpegts_input_close_service(mi, s);
}
/* **************************************************************************
@ -441,9 +445,10 @@ static void
linuxdvb_frontend_open_services ( linuxdvb_frontend_t *lfe )
{
service_t *s;
LIST_FOREACH(s, &lfe->mi_transports, s_active_link)
LIST_FOREACH(s, &lfe->mi_transports, s_active_link) {
linuxdvb_frontend_open_service((mpegts_input_t*)lfe,
(mpegts_service_t*)s);
}
}
static void

View file

@ -142,14 +142,28 @@ mpegts_input_stop_mux ( mpegts_input_t *mi, mpegts_mux_instance_t *mmi )
{
}
static void
void
mpegts_input_open_service ( mpegts_input_t *mi, mpegts_service_t *s )
{
pthread_mutex_lock(&mi->mi_delivery_mutex);
if (s->s_dvb_active_input == NULL) {
LIST_INSERT_HEAD(&mi->mi_transports, ((service_t*)s), s_active_link);
s->s_dvb_active_input = mi;
} else {
assert(mi == s->s_dvb_active_input);
}
pthread_mutex_unlock(&mi->mi_delivery_mutex);
}
static void
void
mpegts_input_close_service ( mpegts_input_t *mi, mpegts_service_t *s )
{
pthread_mutex_lock(&mi->mi_delivery_mutex);
if (s->s_dvb_active_input != NULL) {
LIST_REMOVE(((service_t*)s), s_active_link);
s->s_dvb_active_input = NULL;
}
pthread_mutex_unlock(&mi->mi_delivery_mutex);
}
static void

View file

@ -121,6 +121,10 @@ mpegts_service_enlist(service_t *t, struct service_instance_list *sil)
assert(s->s_source_type == S_MPEG_TS);
/* Create instances */
m->mm_create_instances(m);
/* Enlist available */
LIST_FOREACH(mmi, &m->mm_instances, mmi_mux_link) {
if (mmi->mmi_tune_failed)
continue;
@ -163,12 +167,6 @@ mpegts_service_start(service_t *t, int instance)
/* Start */
if (!r) {
/* Add to active set */
pthread_mutex_lock(&mmi->mmi_input->mi_delivery_mutex);
LIST_INSERT_HEAD(&mmi->mmi_input->mi_transports, t, s_active_link);
s->s_dvb_active_input = mmi->mmi_input;
pthread_mutex_unlock(&mmi->mmi_input->mi_delivery_mutex);
/* Open service */
mmi->mmi_input->mi_open_service(mmi->mmi_input, s);
}
@ -190,12 +188,6 @@ mpegts_service_stop(service_t *t)
assert(i != NULL);
lock_assert(&global_lock);
/* Remove */
pthread_mutex_lock(&i->mi_delivery_mutex);
LIST_REMOVE(t, s_active_link);
s->s_dvb_active_input = NULL;
pthread_mutex_unlock(&i->mi_delivery_mutex);
/* Stop */
i->mi_close_service(i, s);
s->s_status = SERVICE_IDLE;

View file

@ -226,7 +226,7 @@ int
service_start(service_t *t, int instance)
{
elementary_stream_t *st;
int r, timeout = 2;
int r, timeout = 10;
lock_assert(&global_lock);