]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
channel: get number - select the lowest service number, fixes #5441
authorJaroslav Kysela <perex@perex.cz>
Mon, 11 Feb 2019 07:38:08 +0000 (08:38 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 11 Feb 2019 07:38:08 +0000 (08:38 +0100)
src/channels.c

index cff8fe24272d72102f21db2eb5fb4b0ad4a8164a..aa811d76a3c229d04aef014f30899aadf55329d2 100644 (file)
@@ -904,21 +904,23 @@ channel_rename_and_save ( const char *from, const char *to )
 int64_t
 channel_get_number ( const channel_t *ch )
 {
-  int64_t n = 0;
+  int64_t n = 0, v;
   idnode_list_mapping_t *ilm;
   if (ch->ch_number) {
     n = ch->ch_number;
   } else {
     if (ch->ch_bouquet) {
       LIST_FOREACH(ilm, &ch->ch_services, ilm_in2_link) {
-        if ((n = bouquet_get_channel_number(ch->ch_bouquet, (service_t *)ilm->ilm_in1)))
-          break;
+        v = bouquet_get_channel_number(ch->ch_bouquet, (service_t *)ilm->ilm_in1);
+        if (v > 0 && (n == 0 || v < n))
+          n = v;
       }
     }
     if (n == 0) {
       LIST_FOREACH(ilm, &ch->ch_services, ilm_in2_link) {
-        if ((n = service_get_channel_number((service_t *)ilm->ilm_in1)))
-          break;
+        v = service_get_channel_number((service_t *)ilm->ilm_in1);
+        if (v > 0 && (n == 0 || v < n))
+          n = v;
       }
     }
   }