]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Removed nested function 'appendPidRange' from within function 'tvhdhomerun_frontend_u...
authorNorm Raden <norm.raden+github@gmail.com>
Thu, 14 Sep 2023 14:52:40 +0000 (10:52 -0400)
committerFlole998 <Flole998@users.noreply.github.com>
Sat, 14 Oct 2023 20:49:23 +0000 (22:49 +0200)
and converted it to a normal function 'tvhdhomerun_frontend_update_pids_appendPidRange'.

Nested functions are a non-standard extension to C that may only be supported by the gcc compiler.

src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c

index b40990c04001193e719fa9804ae93543335711f7..3f8f82081cc135ad43f03369e664e422dc1b1eb7 100644 (file)
@@ -488,6 +488,23 @@ tvhdhomerun_frontend_stop_mux
   mtimer_arm_rel(&hfe->hf_monitor_timer, tvhdhomerun_frontend_monitor_cb, hfe, sec2mono(2));
 }
 
+static void tvhdhomerun_frontend_update_pids_appendPidRange(int a, int b, int *firstDelimiter, char **pBuffer, const char **endBuffer )
+ /* A helper function that writes a range of pids to the 'buffer'.  This function is called more than once from tvhdhomerun_frontend_update_pids. */
+{
+  if(*firstDelimiter) /* Don't bother printing a space before the first range of pids. */
+     *firstDelimiter = 0;  /* Set this to false the first time. */
+  else {
+    if(*pBuffer < *endBuffer) /* Check if 'buffer' is full. */
+      *pBuffer += snprintf(*pBuffer, *endBuffer-*pBuffer, " "); /* After the first range, separate pid ranges by a space. */
+  }
+  if(*pBuffer < *endBuffer) { /* Check if 'buffer' is full. */
+    if(a == b)
+      *pBuffer += snprintf(*pBuffer, *endBuffer-*pBuffer, "0x%04x", a); /* First and last pid in a range are the same, then that one pid is appended. */
+    else
+      *pBuffer += snprintf(*pBuffer, *endBuffer-*pBuffer, "0x%04x-0x%04x", a, b); /* Append a range of pids to 'buffer'. */
+  }
+}
+
 static void tvhdhomerun_frontend_update_pids( mpegts_input_t *mi, mpegts_mux_t *mm )
 {
   tvhdhomerun_frontend_t *hfe = (tvhdhomerun_frontend_t*)mi;
@@ -538,22 +555,6 @@ static void tvhdhomerun_frontend_update_pids( mpegts_input_t *mi, mpegts_mux_t *
       char *pBuffer = buffer; /* Move this pointer through the buffer as we write formatted pids. */
       int firstDelimiter = -1; /* Set this to 'true' so that we can skip writing the first delimiter/space. */
 
-      void appendPidRange(int a, int b) /* A local function that writes a range of pids to the 'buffer'.  This function is called more than once. */
-      {
-        if(firstDelimiter) /* Don't bother printing a space before the first range of pids. */
-          firstDelimiter = 0;  /* Set this to false the first time. */
-        else {
-          if(pBuffer < endBuffer) /* Check if 'buffer' is full. */
-            pBuffer += snprintf(pBuffer, endBuffer-pBuffer, " "); /* After the first range, separate pid ranges by a space. */
-        }
-        if(pBuffer < endBuffer) { /* Check if 'buffer' is full. */
-          if(a == b)
-            pBuffer += snprintf(pBuffer, endBuffer-pBuffer, "0x%04x", a); /* First and last pid in a range are the same, then that one pid is appended. */
-          else
-            pBuffer += snprintf(pBuffer, endBuffer-pBuffer, "0x%04x-0x%04x", a, b); /* Append a range of pids to 'buffer'. */
-        }
-      }
-
       /* Walk the list of pids and keep track of runs of consecutive pids. Setup the state for the first pid. */
       for (i = 1, prev = begin = wpids.pids[0].pid; i < wpids.count; i++) {
 
@@ -568,7 +569,7 @@ static void tvhdhomerun_frontend_update_pids( mpegts_input_t *mi, mpegts_mux_t *
         if(prev + 1 != curr) {
           /* If the current pid is NOT +1 more than the previous pid, then this is the end of a range of pids.
            * Write out this range of consecutive pids. */
-          appendPidRange(begin, prev);
+          tvhdhomerun_frontend_update_pids_appendPidRange(begin, prev, &firstDelimiter, &pBuffer, &endBuffer);
 
           /* Also, this is the start of a new range of pids.  Set 'begin' to the beginning of the next range. */
           begin = curr;
@@ -578,7 +579,7 @@ static void tvhdhomerun_frontend_update_pids( mpegts_input_t *mi, mpegts_mux_t *
           break;
       }
       /* We are at the end of the list of pids, write the final range of consecutive pids to the 'buffer'. */
-      appendPidRange(begin, prev);
+      tvhdhomerun_frontend_update_pids_appendPidRange(begin, prev, &firstDelimiter, &pBuffer, &endBuffer);
 
       if(pBuffer >= endBuffer) { /* We could not fit the list of ranges of pids into the 'buffer' and have an incomplete/mangled 'buffer'
                                 * so as a backup, we will request all pids except NULL packets (0x1fff). */