ports/90226: [patch] wavrec(1) cannot record from the second time on half-duplex mode (ports/audio/wavplay)

Watanabe Kazuhiro CQG00620 at nifty.ne.jp
Sun Dec 11 07:10:06 UTC 2005


>Number:         90226
>Category:       ports
>Synopsis:       [patch] wavrec(1) cannot record from the second time on half-duplex mode (ports/audio/wavplay)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Dec 11 07:10:02 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Watanabe Kazuhiro
>Release:        FreeBSD 7.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD scorpio.zodiac.org 7.0-CURRENT FreeBSD 7.0-CURRENT #8: Wed Dec  7 21:36:50 JST 2005     nabe at scorpio.zodiac.org:/FreeBSD/obj-current/FreeBSD/FreeBSD-current/src/sys/GENERIC  i386

CVSup'ed Dec. 7.

Soundboard: SoundBlaster Vibra16S (CT2800)
Software: wavplay-1.4_1 from ports-current

$ cat /dev/sndstat
FreeBSD Audio Driver (newpcm)
Installed devices:
pcm0: <Avance Logic ALS4000> at io 0xe800 irq 9 kld snd_als4000 (1p/1r/0v channels duplex default)
pcm1: <SB16 DSP 4.13> at io 0x240 irq 5 drq 1:5 bufsz 4096 kld snd_sb16 (1p/1r/0v channels duplex)
pcm2: <CS423x> at io 0x534 irq 10 drq 3:0 bufsz 4096 (1p/1r/0v channels duplex)
$

>Description:
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.

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)

I've posted about the problem to the freebsd-multimedia mailing list,
and taken a comment.

http://lists.freebsd.org/pipermail/freebsd-multimedia/2005-December/003242.html

>How-To-Repeat:
 * 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: <SB16 DSP 4.13> 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: <SB16 DSP 4.13> 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
$

>Fix:
diff -ruN /usr/ports/audio/wavplay/files/patch-af wavplay/files/patch-af
--- /usr/ports/audio/wavplay/files/patch-af	Fri Jun  7 11:21:52 2002
+++ wavplay/files/patch-af	Sun Dec 11 12:57:42 2005
@@ -1,23 +1,30 @@
-*** recplay.c.orig	Sat Jan 15 12:56:46 2000
---- recplay.c	Sat Jan 15 13:16:42 2000
-***************
-*** 52,63 ****
---- 52,69 ----
-  #include <stdio.h>
-  #include <stdarg.h>
-  #include <stdlib.h>
-+ #ifndef FREEBSD
-  #include <malloc.h>
-+ #endif
-  #include <string.h>
-  #include <fcntl.h>
-  #include <errno.h>
-  #include <sys/stat.h>
-+ #ifndef FREEBSD
-  #include <linux/soundcard.h>
-+ #else
-+ #include <sys/soundcard.h>
-+ #endif
-  #include "wavplay.h"
-  #include "server.h"
-  
+--- recplay.c.orig	Sat Dec  4 09:06:42 1999
++++ recplay.c	Sun Dec 11 12:56:34 2005
+@@ -52,12 +52,18 @@
+ #include <stdio.h>
+ #include <stdarg.h>
+ #include <stdlib.h>
++#ifndef FREEBSD
+ #include <malloc.h>
++#endif
+ #include <string.h>
+ #include <fcntl.h>
+ #include <errno.h>
+ #include <sys/stat.h>
++#ifndef FREEBSD
+ #include <linux/soundcard.h>
++#else
++#include <sys/soundcard.h>
++#endif
+ #include "wavplay.h"
+ #include "server.h"
+ 
+@@ -184,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) )
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list