Bug 31398

Summary: [sound] newpcm does not play back the tail of sound
Product: Base System Reporter: iwaki <iwaki>
Component: kernAssignee: freebsd-multimedia (Nobody) <multimedia>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.4-STABLE   
Hardware: Any   
OS: Any   

Description iwaki 2001-10-21 09:30:00 UTC
If you play back any sound file, you cannot hear the tail, especially
in the case that the sound file does not have enough silence.  That
is, 

% cat hoge.au > /dev/audio

does not play back the tail part.  

% cat hoge.au hoge.au > /dev/audio

plays back the first completely, but the last.  The sound file is as
follows:

% file hoge.au
ttt.au: Sun/NeXT audio data: 8-bit ISDN u-law, mono, 8012 Hz
% ls -l ttt.au
-rw-r--r--  1 iwaki  luser  6705 Aug 25  1997 hoge.au

It looks like independent of brige drivers like sbc because the
following two environments cause the same problem and others have
reported the same probrem in Japanese mailing list.  

(Desktop)
% uname -a
FreeBSD mi000.merlin.gs.niigata-u.ac.jp 4.4-STABLE FreeBSD 4.4-STABLE #0: Sat O\
ct 20 13:45:30 JST 2001     root@mi000.merlin.gs.niigata-u.ac.jp:/usr1/obj/amd/\
mi004/home2/FreeBSD-src/stable4/src/sys/MI  i386
% dmesg | grep snd
Preloaded elf module "snd_sb16.ko" at 0xc033522c.
Preloaded elf module "snd_sbc.ko" at 0xc03352cc.
Preloaded elf module "snd_pcm.ko" at 0xc033536c.
% dmesg | grep sbc
Preloaded elf module "snd_sbc.ko" at 0xc03352cc.
sbc0: <Creative SB AWE64> at port 0x220-0x22f,0x330-0x331,0x388-0x38b irq 5 drq\
 1,5 on isa0
pcm0: <SB16 DSP 4.16> on sbc0

(Notebook)
%uname -a
FreeBSD  4.4-STABLE FreeBSD 4.4-STABLE #1: Sat Oct 20 16:05:53 JST 2001     root@:/usr/local/obj/usr/src/sys/PORTAGE300CT  i386
%dmesg | grep pcm
pcm0: <OPL3-SA3 (YMF715)> at port 0x530-0x537,0x370-0x371,0xf8c-0xf94,0xe0e irq 5 drq 1 flags 0xc110 on isa0

How-To-Repeat: This problem does not appear in 4.3-RELEASE, but before 4.4-RELEASE,
and still exests in 4-STABLE.
Comment 1 Doug Barton freebsd_committer freebsd_triage 2001-10-21 20:29:50 UTC
Responsible Changed
From-To: freebsd-bugs->cg


Cameron is Mr. PCM
Comment 2 Andriy Gapon 2003-10-18 18:52:48 UTC
I can confirm this problem as well. It seems that wav files shorter than 4k do
no produce any sound on playback. The matter may be not in the size, but it
definitely correlates with it.
Incidentally I have the same hardware as in one of the originally reported cases:

  >cat /dev/sndstat
FreeBSD Audio Driver (newpcm)
Installed devices:
pcm0: <SB16 DSP 4.16> at io 0x220 irq 5 drq 1:5 bufsz 4096d (1p/1r/6v channels
duplex)

  >dmesg | fgrep sbc
Preloaded elf module "snd_sbc.ko" at 0xc03c3198.
sbc0: <Creative SB AWE64 Gold> at port 0x220-0x22f,0x330-0x331,0x388-0x38b irq
5 drq 1,5 on isa0
sbc0: setting card to irq 5, drq 1, 5
pcm0: <SB16 DSP 4.16> on sbc0

P.S. the problem is present regardless of whether the sound drivers are loaded
as modules or built into a kernel.

-- 
Andriy Gapon
Comment 3 Andriy Gapon 2003-10-18 22:22:19 UTC
Correction: what I see is not exactly the same problem as originally reported.
What I see seems to be related to SNDCTL_DSP_SYNC.
If I do:

	fd = open("dev/dsp", O_WRONLY);
	write(fd, );
	close(fd);

then everything is ok.
But if I do:

	fd = open("dev/dsp", O_WRONLY);
	write(fd, );
	ioctl(fd, SNDCTL_DSP_SYNC);
	close(fd);

and if size of data written is less than 2k (maybe it has something to do with 
being less than a half of sound buffer size), then it is lost.
I am not sure if this is relevant, but please note that I have vchans 
configured (see my previous followup for details).

-- 
Andriy Gapon
Comment 4 Mark Linimon freebsd_committer freebsd_triage 2004-09-09 20:31:36 UTC
Responsible Changed
From-To: cg->sound

With permission, reassign to mailing list alias.
Comment 5 Jean-Yves Lefort 2004-09-28 04:20:21 UTC
Same problem here. Very short sound files are not played.

Note that this very same hardware always worked fine with FreeBSD 4.x
(even with 4.4). The problem arose today, after upgrading from 4.10 to
5.3-BETA6.

$ uname -a
FreeBSD jsite.lefort.net 5.3-BETA6 FreeBSD 5.3-BETA6 #0: Tue Sep 28 00:10:28 CEST 2004     jylefort@jsite.lefort.net:/usr/obj/usr/src/sys/JSITE  i386

$ cat /dev/sndstat
FreeBSD Audio Driver (newpcm)
Installed devices:
pcm0: <AudioPCI ES1373-8> at io 0x9000 irq 11 kld snd_es137x (1p/1r/4v channels duplex default)

$ grep pcm /var/run/dmesg.boot
pcm0: <AudioPCI ES1373-8> port 0x9000-0x903f at device 12.0 on pci0
pcm0: <TriTech TR28602 AC97 Codec>
pcm0: [GIANT-LOCKED]

$ sysctl -a | grep snd
hw.snd.targetirqrate: 32
hw.snd.report_soft_formats: 1
hw.snd.verbose: 1
hw.snd.unit: 0
hw.snd.maxautovchans: 0
hw.snd.pcm0.buffersize: 4096

-- 
Jean-Yves Lefort

jylefort@brutele.be
http://lefort.be.eu.org/
Comment 6 Alexander Leidinger freebsd_committer freebsd_triage 2005-09-11 13:56:29 UTC
State Changed
From-To: open->feedback

Is this still a problem with a recent -current?
Comment 7 Jean-Yves Lefort freebsd_committer freebsd_triage 2005-11-08 15:18:29 UTC
Same with 6.0-RELEASE.

-- 
Jean-Yves Lefort

jylefort@FreeBSD.org
http://lefort.be.eu.org/
Comment 8 Alexander Leidinger freebsd_committer freebsd_triage 2005-11-13 13:29:19 UTC
State Changed
From-To: feedback->closed

Fixed in -current.