]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
epggrab, eit: fixes for the last changes, it's working now
authorJaroslav Kysela <perex@perex.cz>
Sun, 17 Dec 2017 18:14:17 +0000 (19:14 +0100)
committerJaroslav Kysela <perex@perex.cz>
Mon, 18 Dec 2017 08:39:10 +0000 (09:39 +0100)
src/epggrab.c
src/epggrab/module/eit.c

index 3d3276e0afb2db61a356671727249dde2f641eea..d6b0cbb03c0ff5db02dcf2c7acf0bdd6b55e6791 100644 (file)
@@ -158,7 +158,6 @@ static void *_epggrab_data_thread( void *aux )
   epggrab_module_t *mod;
   epggrab_queued_data_t *eq;
 
-  /* Time for other jobs */
   while (atomic_get(&epggrab_running)) {
     pthread_mutex_lock(&epggrab_data_mutex);
     do {
@@ -172,10 +171,8 @@ static void *_epggrab_data_thread( void *aux )
             TAILQ_REMOVE(&epggrab_data_modules, mod, qlink);
         }
       }
-      if (eq == NULL) {
-        while (atomic_get(&epggrab_running))
-          pthread_cond_wait(&epggrab_data_cond, &epggrab_data_mutex);
-      }
+      if (eq == NULL)
+        pthread_cond_wait(&epggrab_data_cond, &epggrab_data_mutex);
     } while (eq == NULL && atomic_get(&epggrab_running));
     pthread_mutex_unlock(&epggrab_data_mutex);
     if (eq) {
@@ -217,11 +214,11 @@ void epggrab_queue_data(epggrab_module_t *mod,
     memcpy(eq->eq_data + len1, data2, len2);
   memoryinfo_alloc(&epggrab_data_memoryinfo, len);
   pthread_mutex_lock(&epggrab_data_mutex);
-  TAILQ_INSERT_TAIL(&mod->data_queue, eq, eq_link);
   if (TAILQ_EMPTY(&mod->data_queue)) {
     pthread_cond_signal(&epggrab_data_cond);
     TAILQ_INSERT_TAIL(&epggrab_data_modules, mod, qlink);
   }
+  TAILQ_INSERT_TAIL(&mod->data_queue, eq, eq_link);
   pthread_mutex_unlock(&epggrab_data_mutex);
 }
 
@@ -492,7 +489,9 @@ void epggrab_init ( void )
   epggrab_cron_multi              = NULL;
 
   pthread_mutex_init(&epggrab_mutex, NULL);
+  pthread_mutex_init(&epggrab_data_mutex, NULL);
   pthread_cond_init(&epggrab_cond, NULL);
+  pthread_cond_init(&epggrab_data_cond, NULL);
 
   TAILQ_INIT(&epggrab_data_modules);
 
index e05b0288a49ecba639592bbec4224b715f02d9c2..51a5dd0e4c5c79f53692c60236beb9ad58e4bc81 100644 (file)
@@ -727,18 +727,18 @@ static int _eit_process_event
   mpegts_service_t *svc;
   channel_t *ch;
   eit_event_t ev;
-  const uint8_t *ptr = ptr0;
-  int r, len = len0;
+  const uint8_t *ptr;
+  int r, len;
   uint8_t dtag, dlen;
   int dllen;
 
-  if (len < 12) return -1;
+  if (len0 < 12) return -1;
 
-  dllen = ((ptr[10] & 0x0f) << 8) | ptr[11];
-  len0 -= 12;
-  ptr0 += 12;
+  dllen = ((ptr0[10] & 0x0f) << 8) | ptr0[11];
+  len = len0 - 12;
+  ptr = ptr0 + 12;
 
-  if (len0 < dllen) return -1;
+  if (len < dllen) return -1;
 
   memset(&ev, 0, sizeof(ev));
   while (dllen > 2) {
@@ -820,7 +820,7 @@ static int _eit_process_event
 
   if (ilm)
     return -1;
-  return 12 + (((ptr[10] & 0x0f) << 8) | ptr[11]);
+  return 12 + (((ptr0[10] & 0x0f) << 8) | ptr0[11]);
 }
 
 static void