[Icecast-dev] patch: single-q

Karl Heyes karl
Thu Jul 1 19:39:13 PDT 2004


I finally managed to get back to working on this patch. To get some
feedback I've linked to it and posted a few comments on it.

http://mediacast1.com/~karl/single-q.diff

My previous patch (client write) I sent to the list needs to be applied
first, there was no feedback to it.

http://www.xiph.org/archives/icecast-dev/1153.html
(looks like it still applies to svn, if not then let me know)

The mechanism in this queue patch is used in the -kh tree for placing
stream data into a per-source queue instead of the current per-client
queues.

The main differences shown in the diff are in source.c, format_*.c as
these interact considerably with the queue code but there are 2 main
aspects to the queue differences

1. An associated pointer is added to refbuf. This is just a pointer to
another refbuf object but its use is up to the specific format plugin.
In the case of mp3 this stores the shoutcast metadata at that point in
the stream, in the case of Ogg this refers is a list of refbuf objects
containing Ogg header pages.

In both cases (mp3 and ogg) the pointer to this associated refbuf is
stored in the reader part and copied (pointer only) to newly allocated
stream data refbuf objects for the queue, eventually dropping off the
other end of the queue. With this any new ogg headers or shoutcast
metadata is easily handled by the format plugin code.

This, by comparison to v2.0, takes Ogg header pages out of the stream
and stores them separately, so the refbuf objects in the queue refer to
non-header pages and each associated pointer refers to the ogg header
pages at that point in the stream.
In the case of mp3 streams, any metadata is still stored separately but
any changes (via url or inline) do not overwrite the existing metadata,
instead new space is allocated and attached to a new stream data refbuf
object. For mp3 (typically relays with inline metadata) this means that
any stalled clients don't have their metadata changed from under them,
as this can lead to segv errors or stack corruption.

2. The per-source queue acts as the single structure for storing the
stream refbuf objects, maintaining the queue is trivial, and by using
the associated pointers, any new clients can start anywhere on the queue
and have the correct information to hand, without any need to maintain
separate structures eg predata/burst.


A few other points to raise with this patch which may not be obvious

. burst-on-connect would not work due to the fact that the code for
placement of new clients is not in. This is be fairly trivial but I
avoided it here to focus on the queue side.

. format_ogg.[ch] is new. format_vorbis would need to be changed for the
queue access, but as theora support maybe added later I created an ogg
generic file instead. It has the basic multi-codec bits in although only
vorbis is in this patch. Whether per-codec bits should be in separate
files is another consideration.

. refbuf_queue and format_vorbis have not been removed just to help
reduce patch clutter but they are not really used.

There are probably other points I've missed...

karl.




More information about the Icecast-dev mailing list