case TRANSPORT_NOSTART_TUNING_FAILED: return "Tuning failed";
case TRANSPORT_NOSTART_SVC_NOT_ENABLED: return "No service enabled";
case TRANSPORT_NOSTART_BAD_SIGNAL: return "Too bad signal quality";
+ case TRANSPORT_NOSTART_NO_ACCESS: return "No access";
+ case TRANSPORT_NOSTART_NO_DESCRAMBLER: return "No descrambler available";
+ case TRANSPORT_NOSTART_NO_INPUT: return "No input detected";
+ case TRANSPORT_NOSTART_NO_SIGNAL: return "No signal";
+
}
return "Unknown error";
}
*
*/
int
-transport_start(th_transport_t *t, unsigned int weight, int force_start)
+transport_start(th_transport_t *t, unsigned int weight, int force_start,
+ int wait_for_ok)
{
th_stream_t *st;
- int r;
+ int r, err;
lock_assert(&global_lock);
cwc_transport_start(t);
capmt_transport_start(t);
- gtimer_arm(&t->tht_receive_timer, transport_data_timeout, t, 10);
- return 0;
+ int timeout = 10;
+
+ gtimer_arm(&t->tht_receive_timer, transport_data_timeout, t, timeout);
+
+ if(!wait_for_ok)
+ return 0;
+
+ tvhlog(LOG_DEBUG, "Transport", "%s: Waiting for input before start",
+ transport_nicename(t));
+
+ pthread_mutex_lock(&t->tht_stream_mutex);
+
+ struct timespec to;
+
+ to.tv_sec = time(NULL) + timeout;
+ to.tv_nsec = 0;
+
+ do {
+ if(t->tht_streaming_status & TSS_MUX_PACKETS) {
+ tvhlog(LOG_DEBUG, "Transport", "%s: Got demultiplexable packets",
+ transport_nicename(t));
+ pthread_mutex_unlock(&t->tht_stream_mutex);
+ return 0;
+ }
+
+ } while(pthread_cond_timedwait(&t->tht_tss_cond, &t->tht_stream_mutex,
+ &to) != ETIMEDOUT);
+
+ err = t->tht_streaming_status;
+
+ // Startup timed out
+
+ pthread_mutex_unlock(&t->tht_stream_mutex);
+
+ transport_stop(t);
+
+ // Translate streaming status flags to NOSTART errorcode
+ if(err & TSS_NO_DESCRAMBLER)
+ return TRANSPORT_NOSTART_NO_DESCRAMBLER;
+
+ if(err & TSS_NO_ACCESS)
+ return TRANSPORT_NOSTART_NO_ACCESS;
+
+ if(err & TSS_NO_ACCESS)
+ return TRANSPORT_NOSTART_NO_ACCESS;
+
+ if(err & TSS_INPUT_SERVICE)
+ return TRANSPORT_NOSTART_NO_INPUT;
+
+ return TRANSPORT_NOSTART_NO_SIGNAL;
}
if(t->tht_status == TRANSPORT_RUNNING)
return t;
- if(!transport_start(t, 0, 0))
+ if(!transport_start(t, 0, 0, 1))
return t;
}
for(i = 0; i < cnt; i++) {
t = vec[i];
- if((r = transport_start(t, weight, 0)) == 0)
+ if((r = transport_start(t, weight, 0, 1)) == 0)
return t;
error = r;
if(loginfo != NULL)
lock_assert(&global_lock);
pthread_mutex_init(&t->tht_stream_mutex, NULL);
+ pthread_cond_init(&t->tht_tss_cond, NULL);
t->tht_identifier = strdup(identifier);
t->tht_type = type;
t->tht_source_type = source_type;
t->tht_streaming_status);
streaming_pad_deliver(&t->tht_streaming_pad, sm);
streaming_msg_free(sm);
+
+ pthread_cond_broadcast(&t->tht_tss_cond);
}
#define TRANSPORT_NOSTART_TUNING_FAILED 4
#define TRANSPORT_NOSTART_SVC_NOT_ENABLED 5
#define TRANSPORT_NOSTART_BAD_SIGNAL 6
+#define TRANSPORT_NOSTART_NO_ACCESS 7
+#define TRANSPORT_NOSTART_NO_DESCRAMBLER 8
+#define TRANSPORT_NOSTART_NO_INPUT 9
+#define TRANSPORT_NOSTART_NO_SIGNAL 10
void transport_init(void);
unsigned int transport_compute_weight(struct th_transport_list *head);
-int transport_start(th_transport_t *t, unsigned int weight, int force_start);
+int transport_start(th_transport_t *t, unsigned int weight, int force_start,
+ int wait_for_ok);
th_transport_t *transport_create(const char *identifier, int type,
int source_type);