[xiph-commits] r7219 - icecast/branches/icecast-singleq/src

karl at dactyl.lonelymoon.com karl
Wed Jul 21 06:13:04 PDT 2004


Author: karl
Date: Wed Jul 21 06:13:04 2004
New Revision: 7219

Modified:
icecast/branches/icecast-singleq/src/cfgfile.c
icecast/branches/icecast-singleq/src/cfgfile.h
icecast/branches/icecast-singleq/src/client.c
icecast/branches/icecast-singleq/src/client.h
icecast/branches/icecast-singleq/src/connection.c
icecast/branches/icecast-singleq/src/source.c
icecast/branches/icecast-singleq/src/source.h
Log:
add burst on connect (aka fast prebuffering) feature back in, the previous
mechanism would not of worked with this queue structure. A per mount
setting overrides the global one.


Modified: icecast/branches/icecast-singleq/src/cfgfile.c
===================================================================
--- icecast/branches/icecast-singleq/src/cfgfile.c	2004-07-21 13:01:56 UTC (rev 7218)
+++ icecast/branches/icecast-singleq/src/cfgfile.c	2004-07-21 13:13:03 UTC (rev 7219)
@@ -339,7 +339,8 @@
configuration->num_yp_directories = 0;
configuration->relay_username = NULL;
configuration->relay_password = NULL;
-    configuration->burst_on_connect = 0;
+    /* default to a typical prebuffer size used by clients */
+    configuration->burst_size = 65536;
}

static void _parse_root(xmlDocPtr doc, xmlNodePtr node,
@@ -463,8 +464,13 @@
if (tmp) xmlFree(tmp);
} else if (strcmp(node->name, "burst-on-connect") == 0) {
tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
-            configuration->burst_on_connect = atoi(tmp);
+            if (atoi(tmp) == 0)
+                configuration->burst_size = 0;
if (tmp) xmlFree(tmp);
+        } else if (strcmp(node->name, "burst-size") == 0) {
+            tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+            configuration->burst_size = atoi(tmp);
+            if (tmp) xmlFree(tmp);
}
} while ((node = node->next));
}
@@ -489,7 +495,9 @@
else
configuration->mounts = mount;

+    /* default <mount> settings */
mount->max_listeners = -1;
+    mount->burst_size = -1;
mount->next = NULL;

do {
@@ -574,6 +582,10 @@
mount->source_timeout = atoi (tmp);
xmlFree(tmp);
}
+        } else if (strcmp(node->name, "burst-size") == 0) {
+            tmp = (char *)xmlNodeListGetString(doc, node->xmlChildrenNode, 1);
+            mount->burst_size = atoi(tmp);
+            if (tmp) xmlFree(tmp);
}
} while ((node = node->next));
}

Modified: icecast/branches/icecast-singleq/src/cfgfile.h
===================================================================
--- icecast/branches/icecast-singleq/src/cfgfile.h	2004-07-21 13:01:56 UTC (rev 7218)
+++ icecast/branches/icecast-singleq/src/cfgfile.h	2004-07-21 13:13:03 UTC (rev 7219)
@@ -54,8 +54,10 @@
clients from the fallback? */
int no_mount; /* Do we permit direct requests of this mountpoint? (or only
indirect, through fallbacks) */
-    unsigned queue_size_limit;
-    unsigned source_timeout;  /* source timeout in seconds */
+    int burst_size; /* amount to send to a new client if possible, -1 take
+                     * from global setting */
+    unsigned int queue_size_limit;
+    unsigned int source_timeout;  /* source timeout in seconds */

char *auth_type; /* Authentication type */
config_options_t *auth_options; /* Options for this type */
@@ -84,8 +86,9 @@

int client_limit;
int source_limit;
-    unsigned queue_size_limit;
+    unsigned int queue_size_limit;
int threadpool_size;
+    unsigned int burst_size;
int client_timeout;
int header_timeout;
int source_timeout;
@@ -133,7 +136,6 @@
char *yp_url[MAX_YP_DIRECTORIES];
int    yp_url_timeout[MAX_YP_DIRECTORIES];
int num_yp_directories;
-    int burst_on_connect;
} ice_config_t;

typedef struct {

Modified: icecast/branches/icecast-singleq/src/client.c
===================================================================
--- icecast/branches/icecast-singleq/src/client.c	2004-07-21 13:01:56 UTC (rev 7218)
+++ icecast/branches/icecast-singleq/src/client.c	2004-07-21 13:13:03 UTC (rev 7219)
@@ -44,7 +44,6 @@
client->parser = parser;
client->refbuf = NULL;
client->pos = 0;
-    client->burst_sent = 0;

return client;
}

Modified: icecast/branches/icecast-singleq/src/client.h
===================================================================
--- icecast/branches/icecast-singleq/src/client.h	2004-07-21 13:01:56 UTC (rev 7218)
+++ icecast/branches/icecast-singleq/src/client.h	2004-07-21 13:13:03 UTC (rev 7219)
@@ -46,7 +46,6 @@

/* function to call to release format specific resources */
void (*free_client_data)(struct _client_tag *client);
-    int burst_sent;
} client_t;

client_t *client_create(connection_t *con, http_parser_t *parser);

Modified: icecast/branches/icecast-singleq/src/connection.c
===================================================================
--- icecast/branches/icecast-singleq/src/connection.c	2004-07-21 13:01:56 UTC (rev 7218)
+++ icecast/branches/icecast-singleq/src/connection.c	2004-07-21 13:13:03 UTC (rev 7219)
@@ -482,6 +482,7 @@
/* set global settings first */
source->queue_size_limit = config->queue_size_limit;
source->timeout = config->source_timeout;
+        source->burst_size = config->burst_size;

/* for relays, we don't yet have a client, however we do require one
* to retrieve the stream from.  This is created here, quite late,

Modified: icecast/branches/icecast-singleq/src/source.c
===================================================================
--- icecast/branches/icecast-singleq/src/source.c	2004-07-21 13:01:56 UTC (rev 7218)
+++ icecast/branches/icecast-singleq/src/source.c	2004-07-21 13:13:03 UTC (rev 7219)
@@ -228,6 +228,10 @@
if (source->yp_public)
yp_remove (source->mount);

+    source->burst_point = NULL;
+    source->burst_size = 0;
+    source->burst_offset = 0;
+    source->queue_size = 0;
source->queue_size_limit = 0;
source->listeners = 0;
source->no_mount = 0;
@@ -248,8 +252,6 @@
refbuf_release (p);
}
source->stream_data_tail = NULL;
-
-    source->burst_on_connect = 1;
}


@@ -426,8 +428,8 @@
/* new users need somewhere to start from */
if (client->refbuf == NULL)
{
-        /* make clients start at the most recent data on the queue */
-        client->refbuf = source->stream_data_tail;
+        /* make clients start at the per source burst point on the queue */
+        client->refbuf = source->burst_point;
if (client->refbuf == NULL)
return;
}
@@ -479,7 +481,6 @@
memset (listenurl, '\000', listen_url_size);
snprintf (listenurl, listen_url_size, "http://%s:%d%s",
config->hostname, config->port, source->mount);
-    source->burst_on_connect = config->burst_on_connect;
config_release_config();

/* maybe better in connection.c */
@@ -576,12 +577,24 @@
{
/* append buffer to the in-flight data queue,  */
if (source->stream_data == NULL)
+            {
source->stream_data = refbuf;
+                source->burst_point = refbuf;
+            }
if (source->stream_data_tail)
source->stream_data_tail->next = refbuf;
source->stream_data_tail = refbuf;
source->queue_size += refbuf->len;

+            /* new data on queue, so check the burst point */
+            source->burst_offset += refbuf->len;
+            if (source->burst_offset > source->burst_size)
+            {
+                source->burst_offset -= source->burst_point->len;
+                if (source->burst_point->next)
+                    source->burst_point = source->burst_point->next;
+            }
+
/* save stream to file */
if (source->dumpfile && source->format->write_buf_to_file)
source->format->write_buf_to_file (source, refbuf);
@@ -668,6 +681,13 @@
{
source->stream_data = to_go->next;
source->queue_size -= to_go->len;
+                /* make sure the burst point is not the refbuf we are
+                 * deleting, if so move on one  */
+                if (source->burst_point == to_go)
+                {
+                    source->burst_point = to_go->next;
+                    source->burst_offset -= to_go->len;
+                }
refbuf_release (to_go);
}
else
@@ -816,6 +836,9 @@
source->timeout = mountinfo->source_timeout;
DEBUG1 ("source timeout to %u", source->timeout);
}
+    if (mountinfo->burst_size > -1)
+        source->burst_size = mountinfo->burst_size;
+    DEBUG1 ("amount to burst on client connect set to %u", source->burst_size);
}



Modified: icecast/branches/icecast-singleq/src/source.h
===================================================================
--- icecast/branches/icecast-singleq/src/source.h	2004-07-21 13:01:56 UTC (rev 7218)
+++ icecast/branches/icecast-singleq/src/source.h	2004-07-21 13:13:03 UTC (rev 7219)
@@ -56,6 +56,11 @@
int fallback_override;
int no_mount;

+    /* per source burst handling for connecting clients */
+    unsigned burst_size;    /* trigger level for burst on connect */
+    unsigned burst_offset;
+    refbuf_t *burst_point;
+
unsigned queue_size;
unsigned queue_size_limit;

@@ -66,7 +71,6 @@
refbuf_t *stream_data;
refbuf_t *stream_data_tail;

-    int burst_on_connect;
} source_t;

source_t *source_reserve (const char *mount);



More information about the commits mailing list