[nas] Question regarding performance of playRaw and AuHandleEvents()

Jon Trulson jon at radscan.com
Tue Jun 22 17:37:16 MDT 2004


On Mon, 21 Jun 2004, Matt Prazak wrote:

> From: Matt Prazak <prazak_lists at yahoo.com>
> Date: Mon, 21 Jun 2004 17:07:35 -0700 (PDT)
> Subject: [nas] Question regarding performance of playRaw and
>     AuHandleEvents()
> To: nas at radscan.com
> X-Spam-Status: No, hits=-3.8 required=5.0 tests=AWL,BAYES_00 autolearn=no
> 	version=2.60
>
>
> I have been trying out the NAS plugin for libao (for audio output from
> Ogg Vorbis tools, e.g., ogg123), but have had trouble getting that
> driver working on my platform, Solaris 9/SPARC 12/02.  I am now trying
> piping the output of ogg123 directly to playRaw from NAS' example
> programs:
>
>   ogg123 --device=raw --file=- filename.ogg |
> .../nas-1.6/clients/audio/examples/playRaw -
>

	A shame... I would think the plugin would work better...

> This method works very well from an sound quality point-of-view, but
> the CPU utilization of playRaw is very high.  Profiling reveals that
> playRaw's event handler loop is the culprit, where both playRaw and the
> AuHandleEvents() function use inefficient while(1) loops for handling
> things.

	The loops themselves aren't really inefficient, since if there are
no events waiting those loops will sleep until one arrives.  My guess is
that you are just getting a continuous stream of them so there is little
sleeping going on.

>
> Is there a better way in libaudio to implement playRaw to drop the CPU
> utilization?  There looks to be an opportunity for an
> order-of-magnitude improvement if there is a way around the while(1)
> loops.
>

	Well, playRaw is just an example, so of course it wasn't designed
to be efficient.

	replacing the AuHandleEvent() clause with a more simple
AuNextEvent/AuDispatchEvent might be a little more efficient.  It might
also be worthwhile to increase the maxfrags setting in nasd.conf.

	Ideally, playRaw would send more data to the server for processing
and then sleep while awaiting an event telling playRaw to send more data.

	The default settings for nas.conf are geared to lower latency, so
there is not alot of data being queued up on the server, and hence
frequent low water events.

	With the default minfrags = 2 and maxfrags = 3, there is alot of
event traffic going on.  I'm assuming the ogg output data is 16b at 44.1kHz?

	Also, tweaking AuSoundPortDuration, AuSoundPortLowWaterMark, and
AuSoundPortHighWaterMark (library externs defined in audio.h) might
help...


-- 
Jon Trulson    mailto:jon at radscan.com
ID: 1A9A2B09, FP: C23F328A721264E7 B6188192EC733962
PGP keys at http://radscan.com/~jon/PGPKeys.txt
#include <std/disclaimer.h>
"I am Nomad." -Nomad




More information about the Nas mailing list