diff --git a/ajaxui/ajaxui_config_dvb.c b/ajaxui/ajaxui_config_dvb.c index d1ad877b..a1a8344b 100644 --- a/ajaxui/ajaxui_config_dvb.c +++ b/ajaxui/ajaxui_config_dvb.c @@ -59,7 +59,7 @@ tdmi_displayname(th_dvb_mux_instance_t *tdmi, char *buf, size_t len) { int f = tdmi->tdmi_fe_params->frequency; - if(tdmi->tdmi_adapter->tda_fe_info->type == FE_QPSK) { + if(tdmi->tdmi_adapter->tda_type == FE_QPSK) { snprintf(buf, len, "%d kHz %s", f, dvb_polarisation_to_str(tdmi->tdmi_polarisation)); } else { @@ -88,10 +88,10 @@ ajax_adaptersummary(http_connection_t *hc, http_reply_t *hr, tcp_qprintf(tq, "
Device:
" "
%s
", - tda->tda_rootpath); + tda->tda_rootpath ?: "Not present"); tcp_qprintf(tq, "
Type:
" "
%s
", - dvb_adaptertype_to_str(tda->tda_fe_info->type)); + dvb_adaptertype_to_str(tda->tda_type)); tcp_qprintf(tq, "
" ""); - LIST_FOREACH(tda, &dvb_adapters, tda_global_link) { + TAILQ_FOREACH(tda, &dvb_adapters, tda_global_link) { tcp_qprintf(tq, "
", @@ -135,18 +135,20 @@ ajax_config_dvb_tab(http_connection_t *hc, http_reply_t *hr) } /** - * Generate the 'add new...' mux link + * Generate the 'add new...' mux link if the adapter has backing hardware * * if result is set we add a fade out of a result from a previous op */ static void dvb_make_add_link(tcp_queue_t *tq, th_dvb_adapter_t *tda, const char *result) { - tcp_qprintf(tq, - "

Add new...

", tda->tda_identifier); + if(tda->tda_fe_info != NULL) { + tcp_qprintf(tq, + "

Add new...

", tda->tda_identifier); + } if(result) { tcp_qprintf(tq, "
%s
", result); @@ -181,42 +183,41 @@ ajax_adaptereditor(http_connection_t *hc, http_reply_t *hr, tcp_qprintf(tq, "
Model:
" "
%s (%s)
", - tda->tda_fe_info->name, - dvb_adaptertype_to_str(tda->tda_fe_info->type)); + tda->tda_fe_info ? tda->tda_fe_info->name : "", + dvb_adaptertype_to_str(tda->tda_type)); - switch(tda->tda_fe_info->type) { - case FE_QPSK: - a = tda->tda_fe_info->frequency_min; - b = tda->tda_fe_info->frequency_max; - c = tda->tda_fe_info->frequency_stepsize; - break; + if(tda->tda_fe_info != NULL) { + switch(tda->tda_type) { + case FE_QPSK: + a = tda->tda_fe_info->frequency_min; + b = tda->tda_fe_info->frequency_max; + c = tda->tda_fe_info->frequency_stepsize; + break; - default: - a = tda->tda_fe_info->frequency_min / 1000.0f; - b = tda->tda_fe_info->frequency_max / 1000.0f; - c = tda->tda_fe_info->frequency_stepsize / 1000.0f; - break; - } + default: + a = tda->tda_fe_info->frequency_min / 1000.0f; + b = tda->tda_fe_info->frequency_max / 1000.0f; + c = tda->tda_fe_info->frequency_stepsize / 1000.0f; + break; + } - tcp_qprintf(tq, "
Freq. Range:
" - "
%.2f - %.2f kHz, in steps of %.2f kHz
", - a, b, c); + tcp_qprintf(tq, "
Freq. Range:
" + "
%.2f - %.2f kHz, in steps of %.2f kHz
", + a, b, c); - if(tda->tda_fe_info->symbol_rate_min) { - tcp_qprintf(tq, "
Symbolrate:
" - "
%d - %d BAUD
", - tda->tda_fe_info->symbol_rate_min, - tda->tda_fe_info->symbol_rate_max); + if(tda->tda_fe_info->symbol_rate_min) { + tcp_qprintf(tq, "
Symbolrate:
" + "
%d - %d BAUD
", + tda->tda_fe_info->symbol_rate_min, + tda->tda_fe_info->symbol_rate_max); + } + /* Capabilities */ + // tcp_qprintf(tq, "
Capabilities:
"); } - /* Capabilities */ - - - // tcp_qprintf(tq, "
Capabilities:
"); - tcp_qprintf(tq, "
"); ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, "Multiplexes"); @@ -263,6 +264,9 @@ ajax_adapteraddmux(http_connection_t *hc, http_reply_t *hr, if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL) return HTTP_STATUS_NOT_FOUND; + if(tda->tda_fe_info == NULL) + return HTTP_STATUS_BAD_REQUEST; + caps = tda->tda_fe_info->caps; fetype = tda->tda_fe_info->type; @@ -554,7 +558,7 @@ ajax_adaptermuxlist(http_connection_t *hc, http_reply_t *hr, if(remain == NULL || (tda = dvb_adapter_find_by_identifier(remain)) == NULL) return HTTP_STATUS_NOT_FOUND; - fetype = tda->tda_fe_info->type; + fetype = tda->tda_type; /* List of muxes */ diff --git a/dvb.c b/dvb.c index 16c1f7dd..cb2daf27 100644 Binary files a/dvb.c and b/dvb.c differ diff --git a/dvb.h b/dvb.h index dc773015..fab485a1 100644 --- a/dvb.h +++ b/dvb.h @@ -28,7 +28,7 @@ enum polarisation { #define DVB_FEC_ERROR_LIMIT 20 -extern struct th_dvb_adapter_list dvb_adapters; +extern struct th_dvb_adapter_queue dvb_adapters; extern struct th_dvb_mux_instance_list dvb_muxes; void dvb_init(void); diff --git a/dvb_dvr.c b/dvb_dvr.c index dd5baff9..c91ad6df 100644 --- a/dvb_dvr.c +++ b/dvb_dvr.c @@ -145,6 +145,9 @@ dvb_start_feed(th_transport_t *t, unsigned int weight, int status) th_dvb_adapter_t *tda = t->tht_dvb_mux_instance->tdmi_adapter; th_dvb_mux_instance_t *tdmi = tda->tda_mux_current; + if(tda->tda_rootpath == NULL) + return 1; /* hardware not present */ + /* Check if adapter is idle, or already tuned */ if(tdmi != NULL && tdmi != t->tht_dvb_mux_instance) { diff --git a/dvb_fe.c b/dvb_fe.c index 1c3e4d0d..f600eb80 100644 --- a/dvb_fe.c +++ b/dvb_fe.c @@ -85,7 +85,7 @@ dvb_fe_manager(void *aux) p = *tdmi->tdmi_fe_params; - if(tda->tda_fe_info->type == FE_QPSK) { + if(tda->tda_type == FE_QPSK) { /* DVB-S */ int lowfreq, hifreq, switchfreq, hiband; diff --git a/dvb_muxconfig.c b/dvb_muxconfig.c index 20ab97ad..05bb9c2d 100644 --- a/dvb_muxconfig.c +++ b/dvb_muxconfig.c @@ -104,7 +104,7 @@ dvb_mux_store(FILE *fp, th_dvb_mux_instance_t *tdmi) fprintf(fp, "\tfrequency = %d\n", f->frequency); - switch(tdmi->tdmi_adapter->tda_fe_info->type) { + switch(tdmi->tdmi_adapter->tda_type) { case FE_OFDM: fprintf(fp, "\tbandwidth = %s\n", val2str(f->u.ofdm.bandwidth, bwtab)); @@ -188,7 +188,7 @@ dvb_mux_create_str(th_dvb_adapter_t *tda, if(f.frequency == 0) return "Invalid frequency"; - switch(tda->tda_fe_info->type) { + switch(tda->tda_type) { case FE_OFDM: if(bwstr == NULL || (r = str2val(bwstr, bwtab)) < 0) return "Invalid bandwidth"; diff --git a/dvb_support.c b/dvb_support.c index 2c70b767..66aa4b40 100644 --- a/dvb_support.c +++ b/dvb_support.c @@ -219,6 +219,13 @@ static struct strtab adaptertype[] = { { "ATSC", FE_ATSC }, }; + +int +dvb_str_to_adaptertype(const char *str) +{ + return str2val(str, adaptertype); +} + const char * dvb_adaptertype_to_str(int type) { @@ -264,7 +271,7 @@ dvb_adapter_find_by_identifier(const char *identifier) { th_dvb_adapter_t *tda; - LIST_FOREACH(tda, &dvb_adapters, tda_global_link) + TAILQ_FOREACH(tda, &dvb_adapters, tda_global_link) if(!strcmp(identifier, tda->tda_identifier)) return tda; return NULL; @@ -304,7 +311,7 @@ dvb_mux_status(th_dvb_mux_instance_t *tdmi) void dvb_mux_nicename(char *buf, size_t size, th_dvb_mux_instance_t *tdmi) { - if(tdmi->tdmi_adapter->tda_fe_info->type == FE_QPSK) + if(tdmi->tdmi_adapter->tda_type == FE_QPSK) snprintf(buf, size, "%dkHz %s port %d", tdmi->tdmi_fe_params->frequency, dvb_polarisation_to_str_long(tdmi->tdmi_polarisation), tdmi->tdmi_switchport); diff --git a/dvb_support.h b/dvb_support.h index d6fe2552..30bdda23 100644 --- a/dvb_support.h +++ b/dvb_support.h @@ -55,6 +55,7 @@ int dvb_get_string_with_len(char *dst, size_t dstlen, time_t dvb_convert_date(uint8_t *dvb_buf); const char *dvb_adaptertype_to_str(int type); +int dvb_str_to_adaptertype(const char *str); const char *dvb_polarisation_to_str(int pol); th_dvb_adapter_t *dvb_adapter_find_by_identifier(const char *identifier); th_dvb_mux_instance_t *dvb_mux_find_by_identifier(const char *identifier); diff --git a/tvhead.h b/tvhead.h index 9cba2e24..a0f15a34 100644 --- a/tvhead.h +++ b/tvhead.h @@ -73,7 +73,7 @@ LIST_HEAD(th_subscription_list, th_subscription); LIST_HEAD(th_channel_list, th_channel); TAILQ_HEAD(th_channel_queue, th_channel); TAILQ_HEAD(th_channel_group_queue, th_channel_group); -LIST_HEAD(th_dvb_adapter_list, th_dvb_adapter); +TAILQ_HEAD(th_dvb_adapter_queue, th_dvb_adapter); LIST_HEAD(th_v4l_adapter_list, th_v4l_adapter); LIST_HEAD(event_list, event); TAILQ_HEAD(event_queue, event); @@ -209,12 +209,7 @@ typedef struct th_dvb_table { */ typedef struct th_dvb_adapter { - LIST_ENTRY(th_dvb_adapter) tda_global_link; - - enum { - TDA_STATE_RUNNING, /* Running */ - TDA_STATE_ZOMBIE, /* Configured but not found */ - } tda_state; + TAILQ_ENTRY(th_dvb_adapter) tda_global_link; struct th_dvb_mux_instance_list tda_muxes; th_dvb_mux_instance_t *tda_mux_current; @@ -230,6 +225,7 @@ typedef struct th_dvb_adapter { int tda_fe_errors; int tda_fe_fd; + int tda_type; struct dvb_frontend_info *tda_fe_info; char *tda_demux_path;