diff --git a/src/dvb/dvb_transport.c b/src/dvb/dvb_transport.c index 4492791f..f5e5fc8f 100644 --- a/src/dvb/dvb_transport.c +++ b/src/dvb/dvb_transport.c @@ -325,6 +325,16 @@ dvb_transport_setsourceinfo(th_transport_t *t, struct source_info *si) } +/** + * + */ +static int +dvb_grace_period(th_transport_t *t) +{ + return 10; +} + + /** * Find a transport based on 'serviceid' on the given mux * @@ -361,14 +371,15 @@ dvb_transport_find(th_dvb_mux_instance_t *tdmi, uint16_t sid, int pmt_pid, t->tht_dvb_service_id = sid; t->tht_pmt_pid = pmt_pid; - t->tht_start_feed = dvb_transport_start; - t->tht_refresh_feed = dvb_transport_refresh; - t->tht_stop_feed = dvb_transport_stop; - t->tht_config_save = dvb_transport_save; + t->tht_start_feed = dvb_transport_start; + t->tht_refresh_feed = dvb_transport_refresh; + t->tht_stop_feed = dvb_transport_stop; + t->tht_config_save = dvb_transport_save; t->tht_setsourceinfo = dvb_transport_setsourceinfo; - t->tht_dvb_mux_instance = tdmi; t->tht_quality_index = dvb_transport_quality; + t->tht_grace_period = dvb_grace_period; + t->tht_dvb_mux_instance = tdmi; LIST_INSERT_HEAD(&tdmi->tdmi_transports, t, tht_group_link); pthread_mutex_lock(&t->tht_stream_mutex); diff --git a/src/iptv_input.c b/src/iptv_input.c index 75c9db14..adc10e7c 100644 --- a/src/iptv_input.c +++ b/src/iptv_input.c @@ -363,6 +363,16 @@ iptv_transport_setsourceinfo(th_transport_t *t, struct source_info *si) } +/** + * + */ +static int +iptv_grace_period(th_transport_t *t) +{ + return 3; +} + + /** * */ @@ -402,6 +412,7 @@ iptv_transport_find(const char *id, int create) t->tht_config_save = iptv_transport_save; t->tht_setsourceinfo = iptv_transport_setsourceinfo; t->tht_quality_index = iptv_transport_quality; + t->tht_grace_period = iptv_grace_period; t->tht_iptv_fd = -1; LIST_INSERT_HEAD(&iptv_all_transports, t, tht_group_link); diff --git a/src/transports.c b/src/transports.c index 049ee0f7..5da375d0 100644 --- a/src/transports.c +++ b/src/transports.c @@ -267,6 +267,8 @@ transport_start(th_transport_t *t, unsigned int weight, int force_start, { th_stream_t *st; int r, err; + int timeout = 2; + struct timespec to; lock_assert(&global_lock); @@ -293,7 +295,9 @@ transport_start(th_transport_t *t, unsigned int weight, int force_start, cwc_transport_start(t); capmt_transport_start(t); - int timeout = 10; + if(t->tht_grace_period != NULL) + timeout = t->tht_grace_period(t); + gtimer_arm(&t->tht_receive_timer, transport_data_timeout, t, timeout); @@ -305,8 +309,6 @@ transport_start(th_transport_t *t, unsigned int weight, int force_start, pthread_mutex_lock(&t->tht_stream_mutex); - struct timespec to; - to.tv_sec = time(NULL) + timeout; to.tv_nsec = 0; diff --git a/src/tvhead.h b/src/tvhead.h index 3d9cc3c6..5da459f5 100644 --- a/src/tvhead.h +++ b/src/tvhead.h @@ -475,6 +475,7 @@ typedef struct th_transport { int (*tht_quality_index)(struct th_transport *t); + int (*tht_grace_period)(struct th_transport *t); /* * Per source type structs diff --git a/src/v4l.c b/src/v4l.c index 4b5ac648..2d76d305 100644 --- a/src/v4l.c +++ b/src/v4l.c @@ -303,6 +303,16 @@ v4l_transport_quality(th_transport_t *t) } +/** + * + */ +static int +v4l_grace_period(th_transport_t *t) +{ + return 2; +} + + /** * Generate a descriptive name for the source */ @@ -359,6 +369,7 @@ v4l_transport_find(v4l_adapter_t *va, const char *id, int create) t->tht_config_save = v4l_transport_save; t->tht_setsourceinfo = v4l_transport_setsourceinfo; t->tht_quality_index = v4l_transport_quality; + t->tht_grace_period = v4l_grace_period; t->tht_iptv_fd = -1; pthread_mutex_lock(&t->tht_stream_mutex);