[Expat-discuss] FW: OverExecuting characterDataHandler()
Karl Waclawek
karl at waclawek.net
Wed Dec 10 18:44:42 CET 2008
James Renton wrote:
> I am using expat to quickly extract and parse an audio stream encoded in
> base64. This way I can include all kinds of useful meta-data as
> attributes of each chunk.
>
You mean the stream is XML, and the chunks are base64? I would be
surprised of Expat parsed base64 directly.
> The source of my audio produces 8000 – 32000 bytes per second. I just
> produced a working prototype and noticed that calls to my
> characterDataHandler() (set by using XML_SetCharacterDataHandler()) are
> occurring as follows:
> 1. All bytes up to but excluding the first/next carriage return (in my
> case 80)
> 2. Carriage return (single byte)
> 3. Repeat (1)
>
> I am pushing this data off-process and streaming it to various endpoints
> using sockets (not decoding). This is producing a VERY LARGE quantity of
> function calls to my handler which is not optimum. It would be much
> better if at least 1-15 kilobytes of data were passed to the
> characterDataHandler at a time rather. My questions:
> 1. How exactly does the character data parsing in expat work? Some
> insight in this regard might answer all of my questions.
> 2. Is the behavior of the libraries calls to the handler configurable
> in any way (possibly using #define’s, custom builds etc…)?
> 3. Is there any other way to decrease the number of function calls in
> this case?
>
>
The call-back logic would be hard to change, but you can always
accumulate character data in a buffer and make your other calls based on
having accumulated enough data to warrant a network call.
Karl
More information about the Expat-discuss
mailing list