Re: LOR with sound

From: Don Lewis <truckman_at_FreeBSD.org>
Date: Tue, 17 Feb 2004 09:14:23 -0800 (PST)
On 18 Feb, Munehiro Matsuda wrote:
> Hello Don Lewis,
> 
> Thank you for looking into the problem, but....
> 
> ::Can you try the patch below?  Be warned that I don't have the
> ::appropriate combination of hardware and software to really exercise it.
> ::I know that it won't fix the problem of
> 
> I cannot seem to find the patch. ;-)

I forgot to attach it.  Maybe I'll remember this time ...

Index: sys/dev/sound/pcm/dsp.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/sound/pcm/dsp.c,v
retrieving revision 1.72
diff -u -r1.72 dsp.c
--- sys/dev/sound/pcm/dsp.c	28 Jan 2004 08:02:15 -0000	1.72
+++ sys/dev/sound/pcm/dsp.c	17 Feb 2004 16:30:03 -0000
_at__at_ -500,8 +500,14 _at__at_
 			p->play_size = 0;
 			p->rec_size = 0;
 	    		if (wrch) {
+				if (rdch)
+					CHN_UNLOCK(rdch);
 				chn_setblocksize(wrch, 2, p->play_size);
 				p->play_size = sndbuf_getblksz(wrch->bufsoft);
+				CHN_UNLOCK(wrch);
+				wrch = NULL;
+				if (rdch)
+					CHN_LOCK(rdch);
 			}
 	    		if (rdch) {
 				chn_setblocksize(rdch, 2, p->rec_size);
_at__at_ -525,8 +531,14 _at__at_
 	    		snd_chan_param *p = (snd_chan_param *)arg;
 
 	    		if (wrch) {
+				if (rdch)
+					CHN_UNLOCK(rdch);
 				chn_setformat(wrch, p->play_format);
 				chn_setspeed(wrch, p->play_rate);
+				CHN_UNLOCK(wrch);
+				wrch = NULL;
+				if (rdch)
+					CHN_LOCK(rdch);
 	    		}
 	    		if (rdch) {
 				chn_setformat(rdch, p->rec_format);
_at__at_ -633,8 +645,15 _at__at_
 
     	case SNDCTL_DSP_SETBLKSIZE:
 		RANGE(*arg_i, 16, 65536);
-		if (wrch)
+		if (wrch) {
+			if (rdch)
+				CHN_UNLOCK(rdch);
 			chn_setblocksize(wrch, 2, *arg_i);
+			CHN_UNLOCK(wrch);
+			wrch = NULL;
+			if (rdch)
+				CHN_LOCK(rdch);
+		}
 		if (rdch)
 			chn_setblocksize(rdch, 2, *arg_i);
 		break;
_at__at_ -662,8 +681,14 _at__at_
 		/* chn_setspeed may sleep */
 		tmp = 0;
 		if (wrch) {
+			if (rdch)
+				CHN_UNLOCK(rdch);
 			ret = chn_setspeed(wrch, *arg_i);
 			tmp = wrch->speed;
+			CHN_UNLOCK(wrch);
+			wrch = NULL;
+			if (rdch)
+				CHN_LOCK(rdch);
 		}
 		if (rdch && ret == 0) {
 			ret = chn_setspeed(rdch, *arg_i);
_at__at_ -681,8 +706,14 _at__at_
 		tmp = -1;
 		*arg_i = (*arg_i)? AFMT_STEREO : 0;
 		if (wrch) {
+			if (rdch)
+				CHN_UNLOCK(rdch);
 			ret = chn_setformat(wrch, (wrch->format & ~AFMT_STEREO) | *arg_i);
 			tmp = (wrch->format & AFMT_STEREO)? 1 : 0;
+			CHN_UNLOCK(wrch);
+			wrch = NULL;
+			if (rdch)
+				CHN_LOCK(rdch);
 		}
 		if (rdch && ret == 0) {
 			ret = chn_setformat(rdch, (rdch->format & ~AFMT_STEREO) | *arg_i);
_at__at_ -698,8 +729,14 _at__at_
 			tmp = 0;
 			*arg_i = (*arg_i != 1)? AFMT_STEREO : 0;
 	  		if (wrch) {
+				if (rdch)
+					CHN_UNLOCK(rdch);
 				ret = chn_setformat(wrch, (wrch->format & ~AFMT_STEREO) | *arg_i);
 				tmp = (wrch->format & AFMT_STEREO)? 2 : 1;
+				CHN_UNLOCK(wrch);
+				wrch = NULL;
+				if (rdch)
+					CHN_LOCK(rdch);
 			}
 			if (rdch && ret == 0) {
 				ret = chn_setformat(rdch, (rdch->format & ~AFMT_STEREO) | *arg_i);
_at__at_ -724,8 +761,14 _at__at_
 		if ((*arg_i != AFMT_QUERY)) {
 			tmp = 0;
 			if (wrch) {
+				if (rdch)
+					CHN_UNLOCK(rdch);
 				ret = chn_setformat(wrch, (*arg_i) | (wrch->format & AFMT_STEREO));
 				tmp = wrch->format & ~AFMT_STEREO;
+				CHN_UNLOCK(wrch);
+				wrch = NULL;
+				if (rdch)
+					CHN_LOCK(rdch);
 			}
 			if (rdch && ret == 0) {
 				ret = chn_setformat(rdch, (*arg_i) | (rdch->format & AFMT_STEREO));
_at__at_ -757,9 +800,15 _at__at_
 
 			DEB(printf("SNDCTL_DSP_SETFRAGMENT %d frags, %d sz\n", maxfrags, fragsz));
 		    	if (rdch) {
+				if (wrch)
+					CHN_UNLOCK(wrch);
 				ret = chn_setblocksize(rdch, maxfrags, fragsz);
 				maxfrags = sndbuf_getblkcnt(rdch->bufsoft);
 				fragsz = sndbuf_getblksz(rdch->bufsoft);
+				CHN_UNLOCK(rdch);
+				rdch = NULL;
+				if (wrch)
+					CHN_LOCK(wrch);
 			}
 		    	if (wrch && ret == 0) {
 				ret = chn_setblocksize(wrch, maxfrags, fragsz);
Received on Tue Feb 17 2004 - 08:14:58 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:43 UTC