Subject: pkg/20616: nas server underflows audio device
To: None <gnats-bugs@gnats.netbsd.org>
From: None <srp@tworoads.net>
List: netbsd-bugs
Date: 03/07/2003 09:27:13
>Number:         20616
>Category:       pkg
>Synopsis:       nas server (nasd) underflows /dev/audio
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 07 09:28:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Scott Presnell
>Release:        NetBSD 1.5.2
>Organization:
	Self
>Environment:
System: NetBSD low.tworoads.net 1.5.2 NetBSD 1.5.2 (YUKON) #29: Tue Jan 28 07:53:04 PST 2003 root@dirt.tworoads.net:/usr/src/sys/arch/i386/compile/YUKON i386


>Description:
	With local and remote sockets, nasd undeflows /dev/audio because of timing issues. 

	A NAS maintainer has been conacted regarding this issue.

>How-To-Repeat:
	Start nasd.
	Start a nas client (mpg123-nas, auplay)
	Play 44100hz/128bit samples.  Sound is lenghtened, hear regular popping.
	(Play at 22050hz, much better sound on PCI cards, still crappy on ISA cards)

>Fix:

Code block to consider:

  /* change timer according to new sample rate */
  if (rate == 0) {		/* Disable timer case */
    ntval.it_value.tv_sec = ntval.it_value.tv_usec = 0;
    ntval.it_interval.tv_sec = ntval.it_interval.tv_usec = 0;
    timer_ms = 0x7fff;
  } else {
    timer_ms = (auMinibufSamples * 700) / rate;
    ntval.it_interval.tv_sec = 0;
    ntval.it_interval.tv_usec = timer_ms * 1000;
    ntval.it_value.tv_sec = 0;
    ntval.it_value.tv_usec = timer_ms * 10 ;
  }
  foo = setitimer(ITIMER_REAL, &ntval, &otval);

===

  See line 527 (original code), 536 in NetBSD patched code.

  Reducing factor (700) to 500 eliminates underflow on PIII machine, with PCI audio 

NetBSD 1.5.2 (YUKON) #29: Tue Jan 28 07:53:04 PST 2003
    root@dirt.tworoads.net:/usr/src/sys/arch/i386/compile/YUKON
cpu0: Intel Pentium III (Coppermine) (686-class), 996.82 MHz
total memory = 255 MB
avail memory = 233 MB
eap0 at pci2 dev 12 function 0: Ensoniq CT5880 CT5880C (rev. 0x02)
eap0: interrupting at irq 10
eap0: SigmaTel STAC9708 codec; 18 bit DAC, 18 bit ADC, Rockwell 3D
audio0 at eap0: full duplex, mmap, independent

  Reducing factor (700) to 350 eliminates underflow on PPro machine, with ISA audio

NetBSD 1.5.2 (RHINE) #5: Wed Jun 26 08:31:04 PDT 2002
    root@dirt.tworoads.net:/usr/src/sys/arch/i386/compile/RHINE
cpu0: Intel Pentium Pro (686-class), 199.44 MHz
total memory = 65152 KB
avail memory = 57600 KB
sb0 at isa0 port 0x220-0x237 irq 5 drq 1 drq2 5: dsp v4.13
audio0 at sb0: full duplex, mmap, independent

Exact softare patch or adjustment may be machine specific?
>Release-Note:
>Audit-Trail:
>Unformatted: