Index: conf/icecast.xml
===================================================================
RCS file: /usr/local/cvsroot/icecast/conf/icecast.xml,v
retrieving revision 1.12
diff -u -r1.12 icecast.xml
--- conf/icecast.xml 18 Aug 2002 05:06:58 -0000 1.12
+++ conf/icecast.xml 21 Jan 2003 00:27:19 -0000
@@ -9,6 +9,8 @@
30
15
10
+
+ 0
hackme
Index: src/config.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/config.c,v
retrieving revision 1.20
diff -u -r1.20 config.c
--- src/config.c 29 Dec 2002 14:06:20 -0000 1.20
+++ src/config.c 21 Jan 2003 00:27:20 -0000
@@ -28,6 +28,7 @@
#define CONFIG_DEFAULT_USER NULL
#define CONFIG_DEFAULT_GROUP NULL
#define CONFIG_MASTER_UPDATE_INTERVAL 120
+#define CONFIG_DEFAULT_FASTSTART 0
#ifndef _WIN32
#define CONFIG_DEFAULT_BASE_DIR "/usr/local/icecast"
@@ -185,6 +186,7 @@
_configuration.chuid = CONFIG_DEFAULT_CHUID;
_configuration.user = CONFIG_DEFAULT_USER;
_configuration.group = CONFIG_DEFAULT_GROUP;
+ _configuration.faststart = CONFIG_DEFAULT_FASTSTART;
}
static void _parse_root(xmlDocPtr doc, xmlNodePtr node)
@@ -290,6 +292,9 @@
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
_configuration.source_timeout = atoi(tmp);
if (tmp) xmlFree(tmp);
+ } else if (strcmp(node->name, "faststart") == 0) {
+ tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+ _configuration.faststart = atoi(tmp) * 1024; // In KB in the XML
}
} while ((node = node->next));
}
Index: src/config.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/config.h,v
retrieving revision 1.10
diff -u -r1.10 config.h
--- src/config.h 18 Aug 2002 05:06:58 -0000 1.10
+++ src/config.h 21 Jan 2003 00:27:20 -0000
@@ -26,6 +26,7 @@
int source_timeout;
int ice_login;
int fileserve;
+ int faststart;
char *source_password;
char *relay_password;
Index: src/format_vorbis.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/format_vorbis.c,v
retrieving revision 1.11
diff -u -r1.11 format_vorbis.c
--- src/format_vorbis.c 30 Dec 2002 07:55:56 -0000 1.11
+++ src/format_vorbis.c 21 Jan 2003 00:27:21 -0000
@@ -17,6 +17,7 @@
#include "stats.h"
#include "format.h"
+#include "config.h"
#define CATMODULE "format-vorbis"
#include "log.h"
@@ -36,6 +37,9 @@
int header;
refbuf_t *headbuf[MAX_HEADER_PAGES];
int packets;
+ long faststart_size; // If > 0, max bytes in queue
+ refbuf_queue_t *faststart_queue;
+ long faststart_queue_size; // In bytes
} vstate_t;
static void format_vorbis_free_plugin(format_plugin_t *self);
@@ -68,6 +72,9 @@
ogg_sync_init(&state->oy);
plugin->_state = (void *)state;
+ state->faststart_size=config_get_config()->faststart;
+ state->faststart_queue = NULL;
+ state->faststart_queue_size = 0;
return plugin;
}
@@ -75,6 +82,7 @@
void format_vorbis_free_plugin(format_plugin_t *self)
{
int i;
+ refbuf_t *faststartbuf;
vstate_t *state = (vstate_t *)self->_state;
/* free memory associated with this plugin instance */
@@ -91,6 +99,8 @@
state->headbuf[i] = NULL;
}
}
+ while ((faststartbuf = refbuf_queue_remove(&state->faststart_queue)))
+ refbuf_release(faststartbuf);
free(state);
@@ -104,7 +114,8 @@
int i, result;
ogg_packet op;
char *tag;
- refbuf_t *refbuf;
+ refbuf_t *refbuf, *faststartbuf;
+ refbuf_queue_t *faststartbuf_queue;
vstate_t *state = (vstate_t *)self->_state;
if (data) {
@@ -132,6 +143,11 @@
state->headbuf[i] = NULL;
}
}
+ /* release old faststart buffers */
+ while ((faststartbuf = refbuf_queue_remove(&state->faststart_queue)))
+ refbuf_release(faststartbuf);
+ state->faststart_queue_size = 0;
+
/* Clear old stuff. Rarely but occasionally needed. */
ogg_stream_clear(&state->os);
vorbis_comment_clear(&state->vc);
@@ -198,6 +214,22 @@
}
}
}
+ } else {
+
+ /* cache for faststart */
+ if (state->faststart_size > 0) {
+ state->faststart_queue_size += refbuf->len;
+ faststartbuf_queue = state->faststart_queue;
+ /* Remove expired items */
+ while (faststartbuf_queue && state->faststart_queue_size > state->faststart_size) {
+ faststartbuf_queue = faststartbuf_queue->next;
+ faststartbuf = refbuf_queue_remove(&state->faststart_queue);
+ state->faststart_queue_size -= faststartbuf->len;
+ refbuf_release(faststartbuf);
+ }
+ refbuf_addref(refbuf);
+ refbuf_queue_add(&state->faststart_queue, refbuf);
+ }
}
}
@@ -207,7 +239,8 @@
refbuf_queue_t *format_vorbis_get_predata(format_plugin_t *self)
{
- refbuf_queue_t *queue;
+ refbuf_queue_t *queue, *faststartbuf_queue;
+ refbuf_t *faststartbuf;
int i;
vstate_t *state = (vstate_t *)self->_state;
@@ -219,6 +252,14 @@
} else {
break;
}
+ }
+ /* Add faststart items */
+ faststartbuf_queue = state->faststart_queue;
+ while (faststartbuf_queue) {
+ faststartbuf = faststartbuf_queue->refbuf;
+ refbuf_addref(faststartbuf);
+ refbuf_queue_add(&queue, faststartbuf);
+ faststartbuf_queue = faststartbuf_queue->next;
}
return queue;
܆+mb+rzqk7&zzmyƬ:.˛mkab֦zhǜj]zު笷rj)
'+a{
+v칻&ފ{ay,rجy'rzgǧ-b"Vފ ~)mz