On Sat, Dec 27, 2008 at 04:27:08PM +0900, Iwata wrote:
> >> +static int acntl(int request, void *arg)
> >> +{
> >> + switch(request) {
> >> + case PM_REQ_DISCARD:
> >> + case PM_REQ_PLAY_START: /* Called just before playing */
> >> + case PM_REQ_PLAY_END: /* Called just after playing */
> >> + return 0;
> >> + }
> >
> > might it be better to use sio_start/sio_stop here? I don't know,
> > just thinking aloud.
>
> Output function does not send messge when changing to stop state.
> It stops to calling output_data(), merely.
don't worry about it then. sndio is smart enough to stop
when input stops.
> Don't worry about to treat PM_REQ_START/END, because output_data() is
> atomic.
>
> > it's also good style to use sio_getpar and check that the parameters
> > that were asked for are the parameters that got set.
>
> Is it ok that calling sio_getpar() after sio_setpar()?
> Or should be strict checking like devel/sdl?
you have to check the parameters. sio_getpar just fills the
sio_par with the current parameters.
for example, copy par to another sio_par (reqpar in the example)
before calling sio_setpar, then after calling sio_getpar:
if (par.pchan != reqpar.pchan ||
par.bits != reqpar.bits ||
par.sig != reqpar.sig ||
par.le != reqpar.le ||
fabs((par.rate - reqpar.rate) / reqpar.rate) > 0.5) {
error("returned parameters don't match requested");
}
you should allow rate to be a little, but not too much different
than what you wanted. 5% is probably a bit much, but it's close
enough to not cause false positives or miss e.g. requested rate
44100 but got 48000.
--
[email protected]
SDF Public Access UNIX System - http://sdf.lonestar.org