[xiph-commits] r8597 - icecast/trunk/ices/src

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Mon Jan 3 11:48:43 PST 2005


Author: karl
Date: 2005-01-03 11:48:43 -0800 (Mon, 03 Jan 2005)
New Revision: 8597

Modified:
   icecast/trunk/ices/src/cfgparse.c
   icecast/trunk/ices/src/cfgparse.h
   icecast/trunk/ices/src/encode.c
   icecast/trunk/ices/src/encode.h
   icecast/trunk/ices/src/reencode.c
   icecast/trunk/ices/src/reencode.h
   icecast/trunk/ices/src/stream.c
   icecast/trunk/ices/src/stream_shared.c
Log:
allow xml to state the page flush trigger


Modified: icecast/trunk/ices/src/cfgparse.c
===================================================================
--- icecast/trunk/ices/src/cfgparse.c	2005-01-03 17:48:54 UTC (rev 8596)
+++ icecast/trunk/ices/src/cfgparse.c	2005-01-03 19:48:43 UTC (rev 8597)
@@ -62,7 +62,7 @@
 */
 #define SET_STRING(x) \
     do {\
-        if (x) free(x);\
+        if (x) xmlFree(x);\
         (x) = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);\
     } while (0) 
 
@@ -70,19 +70,19 @@
     do {\
         char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);\
         (x) = atoi(tmp);\
-        if (tmp) free(tmp);\
+        if (tmp) xmlFree(tmp);\
     } while (0)
 
 #define SET_FLOAT(x) \
     do {\
         char *tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);\
         (x) = atof(tmp);\
-        if (tmp) free(tmp);\
+        if (tmp) xmlFree(tmp);\
     } while (0)
 
 #define SET_PARM_STRING(p,x) \
         do {\
-                if (x) free(x);\
+                if (x) xmlFree(x);\
                 (x) = (char *)xmlGetProp(node, p);\
     } while (0)
 
@@ -181,8 +181,13 @@
             SET_INT(instance->channels);
         else if (strcmp(node->name, "managed") == 0)
             SET_INT(instance->managed);
+        else if (strcmp(node->name, "flush-samples") == 0)
+            SET_INT(instance->max_samples_ppage);
     } while ((node = node->next));
-
+    if (instance->max_samples_ppage == 0)
+        instance->max_samples_ppage = instance->samplerate;
+    if (instance->max_samples_ppage < instance->samplerate/100)
+        instance->max_samples_ppage = instance->samplerate/100;
 }
 
 static void _parse_metadata(instance_t *instance, config_t *config, 

Modified: icecast/trunk/ices/src/cfgparse.h
===================================================================
--- icecast/trunk/ices/src/cfgparse.h	2005-01-03 17:48:54 UTC (rev 8596)
+++ icecast/trunk/ices/src/cfgparse.h	2005-01-03 19:48:43 UTC (rev 8597)
@@ -56,7 +56,8 @@
     float quality;
     int samplerate;
     int channels;
-    
+    int max_samples_ppage;
+
     /* private */
     FILE *savefile;
     int buffer_failures;

Modified: icecast/trunk/ices/src/encode.c
===================================================================
--- icecast/trunk/ices/src/encode.c	2005-01-03 17:48:54 UTC (rev 8596)
+++ icecast/trunk/ices/src/encode.c	2005-01-03 19:48:43 UTC (rev 8597)
@@ -140,6 +140,7 @@
         s->samplerate = rate;
         s->samples_in_current_page = 0;
         s->prevgranulepos = 0;
+        s->max_samples_ppage = rate*2;
 
         return s;
     } while (0);
@@ -246,7 +247,7 @@
          * badly when doing things live. 
          * So, we flush the stream if we have too many samples buffered
          */
-        if(s->samples_in_current_page > s->samplerate * 2)
+        if(s->samples_in_current_page > s->max_samples_ppage)
         {
             /*LOG_DEBUG1("Forcing flush: Too many samples in current page (%d)",
                     s->samples_in_current_page); */

Modified: icecast/trunk/ices/src/encode.h
===================================================================
--- icecast/trunk/ices/src/encode.h	2005-01-03 17:48:54 UTC (rev 8596)
+++ icecast/trunk/ices/src/encode.h	2005-01-03 19:48:43 UTC (rev 8597)
@@ -24,6 +24,7 @@
     vorbis_info vi;
 
     int samples_in_current_page;
+    int max_samples_ppage;
     int samplerate;
     ogg_int64_t prevgranulepos;
     int in_header;

Modified: icecast/trunk/ices/src/reencode.c
===================================================================
--- icecast/trunk/ices/src/reencode.c	2005-01-03 17:48:54 UTC (rev 8596)
+++ icecast/trunk/ices/src/reencode.c	2005-01-03 19:48:43 UTC (rev 8597)
@@ -45,6 +45,7 @@
     new->out_channels = stream->channels;
     new->current_serial = -1; /* FIXME: that's a valid serial */
     new->need_headers = 0;
+    new->max_samples_ppage = stream->max_samples_ppage;
 
     return new;
 }
@@ -161,6 +162,7 @@
                         LOG_ERROR0("Failed to configure encoder for reencoding");
                         return -1;
                     }
+                    s->encoder->max_samples_ppage = s->max_samples_ppage;
                     if(s->vi.rate != s->out_samplerate) {
                         s->resamp = resample_initialise(s->out_channels,
                                 s->vi.rate, s->out_samplerate);

Modified: icecast/trunk/ices/src/reencode.h
===================================================================
--- icecast/trunk/ices/src/reencode.h	2005-01-03 17:48:54 UTC (rev 8596)
+++ icecast/trunk/ices/src/reencode.h	2005-01-03 19:48:43 UTC (rev 8597)
@@ -43,6 +43,7 @@
     vorbis_comment vc;
     vorbis_dsp_state vd;
     vorbis_block vb;
+    int max_samples_ppage;
 
     encoder_state *encoder;
     downmix_state *downmix;

Modified: icecast/trunk/ices/src/stream.c
===================================================================
--- icecast/trunk/ices/src/stream.c	2005-01-03 17:48:54 UTC (rev 8596)
+++ icecast/trunk/ices/src/stream.c	2005-01-03 19:48:43 UTC (rev 8597)
@@ -195,8 +195,11 @@
         if(!sdsc->enc) {
             LOG_ERROR0("Failed to configure encoder");
             stream->died = 1;
+            shout_free (sdsc->shout);
+            sdsc->shout = NULL;
             return NULL; /* FIXME: probably leaking some memory here */
         }
+        sdsc->enc->max_samples_ppage = sdsc->stream->max_samples_ppage;
     }
     else if(reencoding)
         sdsc->reenc = reencode_init(stream);

Modified: icecast/trunk/ices/src/stream_shared.c
===================================================================
--- icecast/trunk/ices/src/stream_shared.c	2005-01-03 17:48:54 UTC (rev 8596)
+++ icecast/trunk/ices/src/stream_shared.c	2005-01-03 19:48:43 UTC (rev 8597)
@@ -177,7 +177,7 @@
                 LOG_ERROR0("Failed to initialise encoder");
                 return -2;
             }
-
+            sdsc->enc->max_samples_ppage = sdsc->stream->max_samples_ppage;
         }
 
         if(sdsc->downmix) {



More information about the commits mailing list