]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Use better locking and set channel icon
authorAndreas Öman <andreas@lonelycoder.com>
Sun, 27 Apr 2008 13:43:50 +0000 (13:43 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Sun, 27 Apr 2008 13:43:50 +0000 (13:43 +0000)
channels.c
epg.c
epg_xmltv.c

index 394b4ab340179a35f02d5b2425f912c9d83fd062..83996220b3c3f93bdf37ab9700d264044cb88c66 100644 (file)
@@ -308,6 +308,9 @@ channels_load(void)
        if(v > 1)
          ch->ch_commercial_detection = v;
       }
+
+      if((x = config_get_str_sub(&cl, "icon", NULL)) != NULL)
+       ch->ch_icon = strdup(x);
     }
     config_free0(&cl);
   }
@@ -421,7 +424,7 @@ channel_settings_write(th_channel_t *ch)
 
   fprintf(fp, "name = %s\n", ch->ch_name);
   fprintf(fp, "channel-group = %s\n", ch->ch_group->tcg_name);
-
+  fprintf(fp, "icon = %s\n", ch->ch_icon);
   fprintf(fp, "commercial-detect = %s\n", 
          val2str(ch->ch_commercial_detection, commercial_detect_tab) ?: "?");
   fclose(fp);
diff --git a/epg.c b/epg.c
index 50ae86c25d9c22ff43b8cefc62f29e096845669e..d3e6a10c6d4a15eb708ba106e7ac1186d9d79b6e 100644 (file)
--- a/epg.c
+++ b/epg.c
@@ -477,8 +477,12 @@ epg_transfer_events(th_channel_t *ch, struct event_queue *src,
 
   epg_lock();
 
-  free(ch->ch_icon);
-  ch->ch_icon = icon ? strdup(icon) : NULL;
+
+  if(strcmp(icon ?: "", ch->ch_icon ?: "")) {
+    free(ch->ch_icon);
+    ch->ch_icon = icon ? strdup(icon) : NULL;
+    channel_settings_write(ch);
+  }
 
   TAILQ_FOREACH(e, src, e_link) {
 
index 52142b3c974d0a67df3a42839653d5af51b26e1c..de43f2031c1b88be035b8735c3d8d6cc19e3e8c0 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 #define _GNU_SOURCE
+#include <errno.h>
 #include <string.h>
 
 #include <sys/types.h>
@@ -548,7 +549,6 @@ static void
 regrab(void *aux, int64_t now)
 {
   xmltv_grabber_t *xg = aux;
-
   xmltv_grabber_enqueue(xg);
 }
 
@@ -559,10 +559,21 @@ static void
 xmltv_xfer(void *aux, int64_t now)
 {
   xmltv_grabber_t *xg = aux;
+  int t;
+
+  /* We don't want to stall waiting for the xml decoding which
+     can take quite some time, instead retry in a second if we fail
+     to obtain mutex */
+
+  if(pthread_mutex_trylock(&xg->xg_mutex) == EBUSY) {
+    t = 1;
+  } else {
+    xmltv_transfer_events(xg);
+    pthread_mutex_unlock(&xg->xg_mutex);
+    t = 60;
+  }
 
-  xmltv_transfer_events(xg);
-
-  dtimer_arm(&xg->xg_xfer_timer, xmltv_xfer, xg, 60);
+  dtimer_arm(&xg->xg_xfer_timer, xmltv_xfer, xg, t);
 }
 
 /**