PCM audio problem on 5.2R(Fix included)

Mathew Kanner mat at cnd.mcgill.ca
Sun Jan 18 13:00:04 PST 2004


On Jan 16, Pyun YongHyeon wrote:
> Hello All
> 
> I got two pcm audio problems on FreeBSD 5.2R.(These problems were
> not exist in 5.1R.)
> 
>  - Selecting a new song in play list of xmms, it takes about
>     1 seconds.
>  - Output old-buffered cranky sound while terminating xmms if xmms
>     playback was paused.(When xmms playback was stopped it does
>     not happen.)

	Hello Pyun,
	First let me say thanks for taking to create and submit this
patch.  I'm going to try to test this at the end of the day, my
machine won't be available for crashing until then.

	To the other member of the -mm list.  I'm very interested in
testing and committing this soon.  Could we all please try and test it.
In particular I would like to know if mplayer creates garbage noise in
between songs and if very short samples (<1 sec, or the size of the
buffer) play.  A Yes/Nay would be very helpful.

	Thanks again,

	--Mat
> 
> The following is truss(1) output while xmms try to change new
> song.
> 
> ...
> 0.000155886 poll(0x8150000,0x2,0x0)              = 1 (0x1)
> 0.000131301 write(11,0x822be70,2560)             = 2560 (0xa00)
> 0.000067327 ioctl(11,SNDCTL_DSP_GETOSPACE,0xbfabaf40) = 0 (0x0)
> 0.000177676 ioctl(11,SNDCTL_DSP_RESET,0x0)       = 0 (0x0)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 0.000086882 fstat(11,0xbfabae80)                 = 0 (0x0)
> 0.000345016 fcntl(0xb,0x3,0x0)                   = 5 (0x5)
> 0.000165943 fcntl(0xb,0x4,0x1)                   = 0 (0x0)
> 0.999180343 close(11)                            = 0 (0x0)
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 0.000238298 clock_gettime(0x0,0xbfaedfa8)        = 0 (0x0)
> 0.000203937 clock_gettime(0x0,0xbfaedfa8)        = 0 (0x0)
> 0.001563885 write(5,0x816b000,48)                = 48 (0x30)
> ...
> 
> As you can see, close(2) takes about 1 second. So I think previous
> SNDCTL_DSP_RESET ioctl was not handled properly.
> 
> Here is patch. It seems it solves the above two issues on 5.2R.
> The patch adds missing locks and clears buffer(hard + soft)
> to ensure to not playing old-buffered data in close(2).
> The patch may be appilcable to -current.
> 
> --- sys/dev/sound/pcm/dsp.c.ORG	Tue Nov 11 14:38:28 2003
> +++ sys/dev/sound/pcm/dsp.c	Fri Jan 16 20:21:27 2004
> @@ -664,10 +664,18 @@
>  
>      	case SNDCTL_DSP_RESET:
>  		DEB(printf("dsp reset\n"));
> -		if (wrch)
> +		if (wrch) {
> +			CHN_LOCK(wrch);
>  			chn_abort(wrch);
> -		if (rdch)
> +			chn_resetbuf(wrch);
> +			CHN_UNLOCK(wrch);
> +		}
> +		if (rdch) {
> +			CHN_LOCK(rdch);
>  			chn_abort(rdch);
> +			chn_resetbuf(rdch);
> +			CHN_UNLOCK(rdch);
> +		}
>  		break;
>  
>      	case SNDCTL_DSP_SYNC:
> 
> I'm not subscribed to this list. Please CC me.
> 
> Thank you.
> 
> Regards,
> Pyun YongHeyon
> -- 
> Pyun YongHyeon <http://www.kr.freebsd.org/~yongari>
> _______________________________________________
> freebsd-multimedia at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-multimedia
> To unsubscribe, send any mail to "freebsd-multimedia-unsubscribe at freebsd.org"

-- 
	(on the United States) Living next to you is in some ways
	like sleeping with an elephant. No matter how friendly and
	eventempered the beast, one is affected by every twitch and
	grunt.
			- Pierre Elliott Trudeau


More information about the freebsd-multimedia mailing list