[nas] mpg123 on NAS questions

Jon Trulson jon at radscan.com
Sat Jan 12 23:23:00 MST 2002


On Sat, 12 Jan 2002, Paul Fox wrote:

> Date: Sat, 12 Jan 2002 12:39:50 -0500
> From: Paul Fox <pgf at foxharp.boston.ma.us>
> To: nas at radscan.com
> Subject: Re: [nas] mpg123 on NAS questions 
> 
> <big snip of my buffering and latency problems with mpg123-nas>
> 
> [ i'm also removing michael hipp from the cc: line -- haven't
> heard from him, and there's no point filling his inbox with nas
> talk. ]
> 
> jon -- thanks for giving me enough pointers to make some more
> progress.
> 
> things are working better now, but still not quite right.
> 
> for instance, my "pause" problems have gone away now that i'm
> using AuPausFlow and AuStartFlow to control nas.  this works
> well.
> 

	Great...

> i can also use AuStopFlow to interrupt the flow immediately when 
> jumping tracks, for instance.
> 
> i'm still having other problems when i jump tracks:  i want
> to stop the flow, discard anything in it, and then start it
> again with new data:  if i do an AuStopFlow, then close and
> reopen the nas connection, it all works, but i get a small
> snippet of extraneous noise from the previous track when the
> next track starts.  if i try various combinations of
> AuStopFlow and AuFlush, i can't seem to get the next track
> to play at all.
> 

	What if you do 

	AuStopFlow(...)

	AuSync(aud, AuTrue);

	before closing the flow?  


> clearly i'm confused as to what i'm doing here, so let me ask some
> basic questions about the NAS api.
> 
> i've always found the terms "sync" and "flush" to be
> ambiguous (whether talking about caches, ttys, or audio
> devices :-), and the man pages don't seem to help me.  does
> AuFlush discard outstanding samples?  or does AuStop take
> care of that?  and what exactly does AuSync do?
> 

	;-)  They do similair things - the man pages can explain a little
better... AuSync() is very similiar to X11's Xsync() call.  The second arg
is a bool that tells AuSync() whether or not to discard pending
output to the server as well as subsequent events that may generated
as a result.

	AuFLush() (according to the manpage) just flushes any remaining
output data to the server.  

> and, after using one of these routines, do i need to loop
> and wait for some condition to be true?  mpg123 already has
> an event handler that watches for some state events (like
> AuStateStop), and sets some flags for itself when they
> occur.  but i'm not sure when i need to use that facility
> and when i don't.
> 
> i need to be able to do several primitives:
> 
>     - stop the flow immediately, so that it can be restarted.  (this
> 	seems to be AuPause followed by AuStart)
>     - wait for current outstanding data to drain to the sound device.

	I think for this (again without trying it myself) is the AuSync(*,
AuFalse) then wait for an AuStateStopped event, which you should get when
the device ran out of data.

	Use AuFalse to the AuSync() call so output is flushed and pending
events are handled.

>     - stop the flow immediately, and discard anything remaining, so
> 	that i can start a new flow.
> 

	I would think AuStopFlow(), then AuSync(*, AuTrue) followed by
shutting down the flow and re-opening.

> any pointers to existing clients that do these operations "properly"
> would be of great help.  even a pointer to a discussion of how to
> use the API more effectively would be good too -- the library.ps doc
> doesn't quite cut it.  :-)  am i missing some other doc?  (i think
> i know the answer to that question...  :-/  :-)
> 

	library.ps is a little out of date.  Guess the documentation in
NAS has been a little neglected.

	I use xmms and it has never had a problem stopping a song in
midstride and switching to a new one.  The xmms plugin for NAS is actually
pretty well written and it may provide you with clues.  Erik's libaudiooss
used that as a starting point back in the 0.0.0001 release ;-).  It's
changed alot since then (in libaudiooss), but it may give you some ideas
too.


-- 
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>
Bad Color Temperature, Too much Peach.




More information about the Nas mailing list