diff --git a/dvb.c b/dvb.c index 6b078939..36714cb4 100644 Binary files a/dvb.c and b/dvb.c differ diff --git a/transports.c b/transports.c index f3dc3f85..4842e25b 100644 --- a/transports.c +++ b/transports.c @@ -235,6 +235,22 @@ transport_get_prio(th_transport_t *t) } } +/** + * Return quality index for given transport + * + * We invert the result (providers say that negative numbers are worse) + * + * But for sorting, we want low numbers first + * + */ +static int +transport_get_quality(th_transport_t *t) +{ + return t->tht_quality_index ? -(t->tht_quality_index(t)) : 0; +} + + + /** * a - b -> lowest number first @@ -245,6 +261,11 @@ transportcmp(const void *A, const void *B) th_transport_t *a = *(th_transport_t **)A; th_transport_t *b = *(th_transport_t **)B; + int q = transport_get_quality(a) - transport_get_quality(b); + + if(q != 0) + return q; /* Quality precedes priority */ + return transport_get_prio(a) - transport_get_prio(b); } diff --git a/tvhead.h b/tvhead.h index 08fa8f95..2c19ec76 100644 --- a/tvhead.h +++ b/tvhead.h @@ -431,6 +431,8 @@ typedef struct th_transport { const char *(*tht_sourcename)(struct th_transport *t); + int (*tht_quality_index)(struct th_transport *t); + struct th_muxer_list tht_muxers; /* muxers */ /*