[xiph-cvs] cvs commit: ao/src/plugins/oss ao_oss.c

Stan Seibert volsung at xiph.org
Sun Aug 12 23:20:05 PDT 2001



volsung     01/08/12 23:20:05

  Modified:    src/plugins/oss ao_oss.c
  Log:
  OSS plugin correctly detects when audio rate cannot be set to correct value
  on device.

Revision  Changes    Path
1.11      +23 -5     ao/src/plugins/oss/ao_oss.c

Index: ao_oss.c
===================================================================
RCS file: /usr/local/cvsroot/ao/src/plugins/oss/ao_oss.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ao_oss.c	2001/08/12 15:12:45	1.10
+++ ao_oss.c	2001/08/13 06:20:05	1.11
@@ -220,8 +220,13 @@
                         format->channels);
                 goto ERR;
         }
-	ioctl(internal->fd,SNDCTL_DSP_STEREO,&tmp);
         
+	if (ioctl(internal->fd,SNDCTL_DSP_STEREO,&tmp) < 0) {
+		fprintf(stderr, "libao - OSS cannot set channels to %d\n", 
+			format->channels);
+		goto ERR;
+	}
+
         /* To eliminate the need for a swap buffer, we set the device
            to use whatever byte format the client selected. */
         switch (format->bits)
@@ -236,11 +241,24 @@
                         format->bits);
                 goto ERR;
         }
-	ioctl(internal->fd,SNDCTL_DSP_SAMPLESIZE,&tmp);
-	
+
+	if (ioctl(internal->fd,SNDCTL_DSP_SAMPLESIZE,&tmp) < 0) {
+		fprintf(stderr, "libao - OSS cannot set sample size to %d\n",
+			format->bits);
+		goto ERR;
+	}
+
         tmp = format->rate;
-	ioctl(internal->fd,SNDCTL_DSP_SPEED, &tmp);
-	
+	/* Some cards aren't too accurate with their clocks and set to the
+	   exact data rate, but something close.  Fail only if completely out
+	   of whack. */
+	if (ioctl(internal->fd,SNDCTL_DSP_SPEED, &tmp) < 0
+	    || tmp > 1.01 * format->rate || tmp < 0.99 * format->rate) {
+		fprintf(stderr, "libao - OSS cannot set rate to %d\n", 
+			format->rate);
+		goto ERR;
+	}
+
         return 1; /* Open successful */
 
  ERR:

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list