Subject: kern/2015: The audio driver uses a bad low water mark.
To: None <gnats-bugs@NetBSD.ORG>
From: Lennart Augustsson <augustss@cs.chalmers.se>
List: netbsd-bugs
Date: 02/01/1996 22:32:09
>Number:         2015
>Category:       kern
>Synopsis:       The audio driver uses a bad low water mark.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb  1 17:05:09 1996
>Last-Modified:
>Originator:     Lennart Augustsson
>Organization:
CS at Chalmers University of Technology
>Release:        NetBSD 1.1 current, 1996 Jan 31
>Environment:
System: NetBSD calvin.cs.chalmers.se 1.1A NetBSD 1.1A (CALVIN) #33: Thu Feb 1 21:59:20 MET 1996 augustss@calvin.cs.chalmers.se:/usr/src/sys/arch/i386/compile/CALVIN i386


>Description:
	The default low water mark in the audio driver is 1.
	This means that the time to refill the other buffers is
	at a minimum.  This can easily cause cracks in the sound.
	
>How-To-Repeat:
	Check the default low water mark value.
>Fix:
	Set the low water mark to 75% of the available buffers,
	and the high water mark at the max.  Also make sure both
	of them are at least set to 1.

*** dev/audio.c.old	Thu Feb  1 13:34:02 1996
--- dev/audio.c	Thu Feb  1 21:57:12 1996
***************
*** 441,451 ****
  
  	audio_init_ring(&sc->rr, sc->sc_blksize);
  	audio_init_ring(&sc->pr, sc->sc_blksize);
! 	sc->sc_lowat = 1;
  	if (nblk == 1)
! 	  sc->sc_hiwat = 1;
! 	else
! 	  sc->sc_hiwat = nblk - sc->sc_lowat;
  }
  
  static inline int
--- 441,452 ----
  
  	audio_init_ring(&sc->rr, sc->sc_blksize);
  	audio_init_ring(&sc->pr, sc->sc_blksize);
! 	sc->sc_hiwat = nblk - 1;
! 	sc->sc_lowat = 3*nblk/4;
  	if (nblk == 1)
! 	    sc->sc_hiwat = 1;
! 	if (sc->sc_lowat > sc->sc_hiwat)
! 	    sc->sc_lowat = sc->sc_hiwat;
  }
  
  static inline int
>Audit-Trail:
>Unformatted: