Fix race conditions and inadequate locking during transport start
This commit is contained in:
parent
56a234cf70
commit
219b3af532
6 changed files with 18 additions and 21 deletions
|
@ -101,8 +101,7 @@ dvb_transport_open_demuxers(th_dvb_adapter_t *tda, th_transport_t *t)
|
|||
* transports that is subscribing to the adapter
|
||||
*/
|
||||
static int
|
||||
dvb_transport_start(th_transport_t *t, unsigned int weight, int status,
|
||||
int force_start)
|
||||
dvb_transport_start(th_transport_t *t, unsigned int weight, int force_start)
|
||||
{
|
||||
int w;
|
||||
th_dvb_adapter_t *tda = t->tht_dvb_mux_instance->tdmi_adapter;
|
||||
|
@ -132,7 +131,6 @@ dvb_transport_start(th_transport_t *t, unsigned int weight, int status,
|
|||
pthread_mutex_lock(&tda->tda_delivery_mutex);
|
||||
|
||||
LIST_INSERT_HEAD(&tda->tda_transports, t, tht_active_link);
|
||||
t->tht_status = status;
|
||||
dvb_fe_tune(t->tht_dvb_mux_instance, "Transport start");
|
||||
|
||||
pthread_mutex_unlock(&tda->tda_delivery_mutex);
|
||||
|
|
|
@ -166,8 +166,7 @@ iptv_thread(void *aux)
|
|||
*
|
||||
*/
|
||||
static int
|
||||
iptv_transport_start(th_transport_t *t, unsigned int weight, int status,
|
||||
int force_start)
|
||||
iptv_transport_start(th_transport_t *t, unsigned int weight, int force_start)
|
||||
{
|
||||
pthread_t tid;
|
||||
int fd;
|
||||
|
@ -242,7 +241,6 @@ iptv_transport_start(th_transport_t *t, unsigned int weight, int status,
|
|||
}
|
||||
|
||||
t->tht_iptv_fd = fd;
|
||||
t->tht_status = status;
|
||||
|
||||
pthread_mutex_lock(&iptv_recvmutex);
|
||||
LIST_INSERT_HEAD(&iptv_active_transports, t, tht_active_link);
|
||||
|
@ -267,7 +265,6 @@ iptv_transport_refresh(th_transport_t *t)
|
|||
static void
|
||||
iptv_transport_stop(th_transport_t *t)
|
||||
{
|
||||
t->tht_status = TRANSPORT_IDLE;
|
||||
pthread_mutex_lock(&iptv_recvmutex);
|
||||
LIST_REMOVE(t, tht_active_link);
|
||||
pthread_mutex_unlock(&iptv_recvmutex);
|
||||
|
|
|
@ -47,10 +47,8 @@ typedef struct rawts {
|
|||
*
|
||||
*/
|
||||
static int
|
||||
rawts_transport_start(th_transport_t *t, unsigned int weight, int status,
|
||||
int force_start)
|
||||
rawts_transport_start(th_transport_t *t, unsigned int weight, int force_start)
|
||||
{
|
||||
t->tht_status = TRANSPORT_RUNNING;
|
||||
return 0; // Always ok
|
||||
}
|
||||
|
||||
|
@ -60,7 +58,6 @@ rawts_transport_start(th_transport_t *t, unsigned int weight, int status,
|
|||
static void
|
||||
rawts_transport_stop(th_transport_t *t)
|
||||
{
|
||||
t->tht_status = TRANSPORT_IDLE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -204,6 +204,8 @@ transport_stop(th_transport_t *t)
|
|||
LIST_FOREACH(st, &t->tht_components, st_link)
|
||||
stream_clean(st);
|
||||
|
||||
t->tht_status = TRANSPORT_IDLE;
|
||||
|
||||
pthread_mutex_unlock(&t->tht_stream_mutex);
|
||||
}
|
||||
|
||||
|
@ -245,24 +247,30 @@ transport_start(th_transport_t *t, unsigned int weight, int force_start)
|
|||
|
||||
assert(t->tht_status != TRANSPORT_RUNNING);
|
||||
|
||||
if(t->tht_start_feed(t, weight, TRANSPORT_RUNNING, force_start))
|
||||
return -1;
|
||||
|
||||
t->tht_feed_status = TRANSPORT_FEED_UNKNOWN;
|
||||
t->tht_input_status = TRANSPORT_FEED_NO_INPUT;
|
||||
t->tht_dts_start = AV_NOPTS_VALUE;
|
||||
t->tht_pcr_drift = 0;
|
||||
|
||||
if(t->tht_start_feed(t, weight, force_start))
|
||||
return -1;
|
||||
|
||||
pthread_mutex_lock(&t->tht_stream_mutex);
|
||||
|
||||
t->tht_status = TRANSPORT_RUNNING;
|
||||
|
||||
/**
|
||||
* Initialize stream
|
||||
*/
|
||||
LIST_FOREACH(st, &t->tht_components, st_link)
|
||||
stream_init(st);
|
||||
|
||||
pthread_mutex_unlock(&t->tht_stream_mutex);
|
||||
|
||||
cwc_transport_start(t);
|
||||
capmt_transport_start(t);
|
||||
|
||||
gtimer_arm(&t->tht_receive_timer, transport_data_timeout, t, 10);
|
||||
t->tht_feed_status = TRANSPORT_FEED_UNKNOWN;
|
||||
t->tht_input_status = TRANSPORT_FEED_NO_INPUT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -470,7 +470,7 @@ typedef struct th_transport {
|
|||
LIST_HEAD(, th_subscription) tht_subscriptions;
|
||||
|
||||
int (*tht_start_feed)(struct th_transport *t, unsigned int weight,
|
||||
int status, int force_start);
|
||||
int force_start);
|
||||
|
||||
void (*tht_refresh_feed)(struct th_transport *t);
|
||||
|
||||
|
|
|
@ -164,8 +164,7 @@ v4l_thread(void *aux)
|
|||
*
|
||||
*/
|
||||
static int
|
||||
v4l_transport_start(th_transport_t *t, unsigned int weight, int status,
|
||||
int force_start)
|
||||
v4l_transport_start(th_transport_t *t, unsigned int weight, int force_start)
|
||||
{
|
||||
v4l_adapter_t *va = t->tht_v4l_adapter;
|
||||
int frequency = t->tht_v4l_frequency;
|
||||
|
@ -219,7 +218,6 @@ v4l_transport_start(th_transport_t *t, unsigned int weight, int status,
|
|||
|
||||
va->va_fd = fd;
|
||||
va->va_current_transport = t;
|
||||
t->tht_status = status;
|
||||
pthread_create(&va->va_thread, NULL, v4l_thread, va);
|
||||
v4l_adapter_notify(va);
|
||||
return 0;
|
||||
|
@ -257,7 +255,6 @@ v4l_transport_stop(th_transport_t *t)
|
|||
close(va->va_fd);
|
||||
|
||||
va->va_current_transport = NULL;
|
||||
t->tht_status = TRANSPORT_IDLE;
|
||||
v4l_adapter_notify(va);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue