On Wed, Jul 15, 2009 at 03:12:34PM +0000, Jacob Meuser wrote:
> On Wed, Jul 15, 2009 at 01:13:11AM +0300, 4625 wrote:
> > On OpenBSD timidity reproduce garbled sound, like when CPU overloaded. 
> > However, the same version of timidity on FreeBSD-4.11 play files very 
> > well.
> > 
> > OpenBSD localhost 4.5 200907101811#0 i386
> > timidity-2.13.2p1
> 
> can you try this please?  this adds sndio support.  iirc, it was sent
> to ports@ some onths ago by ray iwata.  I don't recall why it wasn't
> committed though.

i guess i forgot to handle it, i applogize to Ray Iwata, for
that.

this diff applies and works fine here; just for completness,
i added the below bits to check returned parameters (apply
on top of previous diff).

a possible improvement would be to set timidity output
parameters to ones returned by sio_getpar(3) rather than
failing with ``can't set parameters'' error. That's what
alsa backend seems to do.

Jacob, are the porting bits correct? if so this should go
in, imo.

-- Alexandre

--- sndio_a.c.old       Thu Jul 16 08:47:17 2009
+++ sndio_a.c   Thu Jul 16 08:48:39 2009
@@ -52,7 +52,7 @@ static struct sio_hdl *sndio_ctx;
 
 static int open_output(void)
 {
-  static struct sio_par par;
+  static struct sio_par par, newpar;
 
   sndio_ctx = sio_open(NULL, SIO_PLAY, 0);
   if (sndio_ctx == NULL) {
@@ -66,19 +66,34 @@ static int open_output(void)
   par.pchan = (dpm.encoding & PE_MONO) ? 1 : 2;
   par.le = SIO_LE_NATIVE;
   par.rate = dpm.rate;
-  par.bits = (dpm.encoding & PE_24BIT) ? 24 : 0;
-  par.bits = (dpm.encoding & PE_16BIT) ? 16 : 0;
-
-  if (par.bits == 0)
+  if (dpm.encoding & PE_24BIT) {
+    par.bits = 24;
+    par.bps = 3;
+  } else if (dpm.encoding & PE_16BIT) {
+    par.bits = 16;
+    par.bps = 2;
+  } else {
     par.bits = 8;
+    par.bps = 1;
+  }
 
   if (!sio_setpar(sndio_ctx, &par)) {
     ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "sio_setpar() failed");
     return -1;
   }
 
-  if (sio_getpar(sndio_ctx, &par) == 0) {
+  if (sio_getpar(sndio_ctx, &newpar) == 0) {
     ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "sio_getpar() failed");
+    return -1;
+  }
+  if (newpar.sig != par.sig ||
+      newpar.le != par.le ||
+      newpar.pchan != par.pchan ||
+      newpar.bits != par.bits ||
+      newpar.bps != par.bps ||
+      newpar.rate * 1000 > par.rate * 1005 ||
+      newpar.rate * 1000 < par.rate *  995) {
+    ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "couldn't set output play parameters");
     return -1;
   }
 

Reply via email to