]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
mpegts: Add extra weight for inputs with more subscribers
authorJaroslav Kysela <perex@perex.cz>
Mon, 26 May 2014 12:43:22 +0000 (14:43 +0200)
committerJaroslav Kysela <perex@perex.cz>
Tue, 10 Jun 2014 12:14:46 +0000 (14:14 +0200)
This simple code assures that the inputs having more subscribers
will be selected after ones with less subscribers.

src/input/mpegts/mpegts_input.c

index f325680bb0420acbe3680a2768f6b6ba93a96a25..04dd9b6b17d8144632c5e0bd9ee16205f6fb1fec 100644 (file)
@@ -192,12 +192,13 @@ mpegts_input_get_weight ( mpegts_input_t *mi )
   const mpegts_mux_instance_t *mmi;
   const service_t *s;
   const th_subscription_t *ths;
-  int w = 0;
+  int w = 0, count = 0;
 
   /* Direct subs */
   LIST_FOREACH(mmi, &mi->mi_mux_active, mmi_active_link) {
     LIST_FOREACH(ths, &mmi->mmi_subs, ths_mmi_link) {
       w = MAX(w, ths->ths_weight);
+      count++;
     }
   }
 
@@ -206,10 +207,11 @@ mpegts_input_get_weight ( mpegts_input_t *mi )
   LIST_FOREACH(s, &mi->mi_transports, s_active_link) {
     LIST_FOREACH(ths, &s->s_subscriptions, ths_service_link) {
       w = MAX(w, ths->ths_weight);
+      count++;
     }
   }
   pthread_mutex_unlock(&mi->mi_output_lock);
-  return w;
+  return w > 0 ? w + count - 1 : 0;
 }
 
 int