PERFORCE change 162516 for review

Hans Petter Selasky hselasky at FreeBSD.org
Fri May 22 16:35:46 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=162516

Change 162516 by hselasky at hselasky_laptop001 on 2009/05/22 16:34:49

	
	USB audio:
	 - fix for USB devices that do not support mono or stereo operation.
	
	Reported by: MIHIRA Sanpei Yoshiro

Affected files ...

.. //depot/projects/usb/src/sys/dev/sound/usb/uaudio.c#43 edit

Differences ...

==== //depot/projects/usb/src/sys/dev/sound/usb/uaudio.c#43 (text+ko) ====

@@ -97,6 +97,7 @@
 
 #define	MAKE_WORD(h,l) (((h) << 8) | (l))
 #define	BIT_TEST(bm,bno) (((bm)[(bno) / 8] >> (7 - ((bno) % 8))) & 1)
+#define	UAUDIO_MAX_CHAN(x) (((x) < 2) ? (x) : 2)	/* XXX fixme later */
 
 struct uaudio_mixer_node {
 	int32_t	minval;
@@ -936,7 +937,7 @@
 #endif
 
 			wFormat = UGETW(asid->wFormatTag);
-			bChannels = asf1d->bNrChannels;
+			bChannels = UAUDIO_MAX_CHAN(asf1d->bNrChannels);
 			bBitResolution = asf1d->bBitResolution;
 
 			if (asf1d->bSamFreqType == 0) {
@@ -1020,7 +1021,8 @@
 						chan->usb2_cfg =
 						    uaudio_cfg_play;
 
-					sample_size = ((chan->p_asf1d->bNrChannels *
+					sample_size = ((
+					    UAUDIO_MAX_CHAN(chan->p_asf1d->bNrChannels) *
 					    chan->p_asf1d->bBitResolution) / 8);
 
 					/*
@@ -1334,7 +1336,7 @@
 
 	ch->pcm_cap.fmtlist[0] = ch->p_fmt->freebsd_fmt;
 
-	if (ch->p_asf1d->bNrChannels == 2) {
+	if (ch->p_asf1d->bNrChannels >= 2) {
 		ch->pcm_cap.fmtlist[0] |= AFMT_STEREO;
 	}
 	ch->pcm_cap.fmtlist[1] = 0;


More information about the p4-projects mailing list