From owner-freebsd-multimedia@FreeBSD.ORG Sat Dec 10 08:38:28 2005 Return-Path: X-Original-To: freebsd-multimedia@freebsd.org Delivered-To: freebsd-multimedia@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C74AD16A41F for ; Sat, 10 Dec 2005 08:38:28 +0000 (GMT) (envelope-from CQG00620@nifty.ne.jp) Received: from mail.asahi-net.or.jp (mail2.asahi-net.or.jp [202.224.39.198]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5B8BA43D55 for ; Sat, 10 Dec 2005 08:38:27 +0000 (GMT) (envelope-from CQG00620@nifty.ne.jp) Received: from asahi-net.jp (h204195.ppp.asahi-net.or.jp [61.114.204.195]) by mail.asahi-net.or.jp (Postfix) with ESMTP id B72C61B626 for ; Sat, 10 Dec 2005 17:38:26 +0900 (JST) Date: Sat, 10 Dec 2005 17:40:43 +0900 From: Watanabe Kazuhiro To: freebsd-multimedia User-Agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.7 (=?ISO-8859-4?Q?Sanj=F2?=) APEL/10.6 Emacs/20.7 (i386--freebsd) MULE/4.0 (HANANOEN) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Message-Id: <20051210083826.B72C61B626@mail.asahi-net.or.jp> Subject: wavrec(1) cannot record from the second time on half-duplex mode X-BeenThere: freebsd-multimedia@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Multimedia discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Dec 2005 08:38:28 -0000 Hi, everyone. When I try to record with wavrec (a part of ports/audio/wavplay) on half-duplex mode, cannot record from the second time. At the first time it works correctly. I've tested other recording software. Rec (ports/audio/sox) and rawrec (ports/audio/rawrec) is no problem at least. * Environment (FreeBSD-current: CVSup'ed Dec. 7) $ uname -a FreeBSD scorpio.zodiac.org 7.0-CURRENT FreeBSD 7.0-CURRENT #8: Wed Dec 7 21:36:50 JST 2005 nabe@scorpio.zodiac.org:/FreeBSD/obj-current/FreeBSD/FreeBSD-current/src/sys/GENERIC i386 $ cat /dev/sndstat FreeBSD Audio Driver (newpcm) Installed devices: pcm0: at io 0xe800 irq 9 kld snd_als4000 (1p/1r/0v channels duplex default) pcm1: at io 0x240 irq 5 drq 1:5 bufsz 4096 kld snd_sb16 (1p/1r/0v channels duplex) pcm2: at io 0x534 irq 10 drq 3:0 bufsz 4096 (1p/1r/0v channels duplex) $ * Case 1 (full-duplex mode, works fine) $ grep sbc /boot/device.hints hint.sbc.0.at="isa" hint.sbc.0.port="0x240" hint.sbc.0.irq="5" hint.sbc.0.drq="1" hint.sbc.0.flags="0x15" $ cat /dev/sndstat | grep pcm1 pcm1: at io 0x240 irq 5 drq 1:5 bufsz 4096 kld snd_sb16 (1p/1r/0v channels duplex) $ time wavrec -d /dev/dsp1 -S -s 44100 -b 16 -t 10 test.wav 10.07 real 0.02 user 1.18 sys $ time wavrec -d /dev/dsp1 -S -s 44100 -b 16 -t 10 test.wav 10.07 real 0.01 user 1.19 sys $ ls -l test.wav -rw-r--r-- 1 nabe nabe 1764044 Dec 9 21:23 test.wav $ * Case 2 (half-duplex mode, works only once) $ grep sbc /boot/device.hints hint.sbc.0.at="isa" hint.sbc.0.port="0x240" hint.sbc.0.irq="5" hint.sbc.0.drq="1" hint.sbc.0.flags="0" $ cat /dev/sndstat | grep pcm1 pcm1: at io 0x240 irq 5 drq 1 bufsz 4096 kld snd_sb16 (1p/1r/0v channels) $ time wavrec -d /dev/dsp1 -S -s 44100 -b 16 -t 10 test.wav 10.15 real 0.00 user 1.19 sys $ time wavrec -d /dev/dsp1 -S -s 44100 -b 16 -t 10 test.wav Device busy: Opening audio device /dev/dsp1 1.60 real 0.00 user 1.59 sys $ ls -l test.wav -rw-r--r-- 1 nabe nabe 44 Dec 9 21:30 test.wav $ In case 2, there is a LOR message on the console. The LOR message is below: lock order reversal: 1st 0xc22e8640 pcm1 (sound cdev) @ /FreeBSD/FreeBSD-current/src/sys/modules/sound/sound/../../../dev/sound/pcm/dsp.c:277 2nd 0xc22e85e0 pcm1:record:0 (pcm record channel) @ /FreeBSD/FreeBSD-current/src/sys/modules/sound/sound/../../../dev/sound/pcm/dsp.c:290 KDB: stack backtrace: kdb_backtrace(0,ffffffff,c0954ff0,c0954f78,c08e27a4) at kdb_backtrace+0x29 witness_checkorder(c22e85e0,9,c0ac7b63,122) at witness_checkorder+0x580 _mtx_lock_flags(c22e85e0,0,c0ac7b63,122,1) at _mtx_lock_flags+0x5b dsp_open(c22f8800,3,2000,c25ffd80,c094614c) at dsp_open+0x2fd giant_open(c22f8800,3,2000,c25ffd80,c22f8800) at giant_open+0x30 devfs_open(d1398a08) at devfs_open+0x223 VOP_OPEN_APV(c08db0c0,d1398a08) at VOP_OPEN_APV+0x7e vn_open_cred(d1398b70,d1398c70,0,c260b100,4) at vn_open_cred+0x3fe vn_open(d1398b70,d1398c70,0,4,6b2) at vn_open+0x1e kern_open(c25ffd80,bfbfed76,0,3,0) at kern_open+0xb6 open(c25ffd80,d1398d04,c,c25ffd80,d1398d30) at open+0x1a syscall(3b,3b,3b,805204c,8051000) at syscall+0x27e Xint0x80_syscall() at Xint0x80_syscall+0x1f --- syscall (5, FreeBSD ELF32, open), eip = 0x2811fb5f, esp = 0xbfbfeadc, ebp = 0xbfbfeb08 --- Wavrec open a sound device (default: /dev/audio) with O_RDWR flag. Probably it's wrong. Because wavrec doesn't support full-duplex operation. It is documented in "Open Sound System(TM) Programmer's Guide" pp29: | It is recommended that the device file is opened in read only | (O_RDONLY) or write only (O_WRONLY) mode. Read write mode (O_RDWR) | should be used only when it is necessary to record and play back at | the same time (full duplex mode). ("Selecting and Opening the Sound Device" http://www.opensound.com/pguide/oss.pdf) Actually, this problem can be fixed by the patch: --- recplay.c.configured Fri Dec 9 21:47:01 2005 +++ recplay.c Fri Dec 9 21:50:53 2005 @@ -190,7 +190,7 @@ wfile = svr.wfile; /* And the file is already opened */ } - if ( (dfile = OpenDSP(wfile,O_RDWR,v_erf)) == NULL ) + if ( (dfile = OpenDSP(wfile,O_RDONLY,v_erf)) == NULL ) goto errxit; if ( RecordDSP(dfile,wfile,samples,svr_work_proc,v_erf) ) Is it an only wavrec's bug? If so, I will send-pr. If it's a newpcm's bug, please somebody fix the problem... In FreeBSD/pc98, most of PC-98 have an on-board MSS chip (CS4231A). These are only works on half-duplex mode (single DRQ). And SoundBlaster16 for PC-98 is also worked on half-duplex too. --- Watanabe Kazuhiro (CQG00620@nifty.ne.jp)