From owner-freebsd-current@FreeBSD.ORG Thu Dec 11 19:57:16 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5AD6016A4CE for ; Thu, 11 Dec 2003 19:57:16 -0800 (PST) Received: from obsecurity.dyndns.org (adsl-63-207-60-234.dsl.lsan03.pacbell.net [63.207.60.234]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5E53643D33 for ; Thu, 11 Dec 2003 19:57:14 -0800 (PST) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id ED0A366C15; Thu, 11 Dec 2003 19:57:13 -0800 (PST) Date: Thu, 11 Dec 2003 19:57:13 -0800 From: Kris Kennaway To: juha.nygard1@netikka.fi Message-ID: <20031212035713.GA9295@xor.obsecurity.org> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="huq684BweRXVnRxX" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.1i cc: freebsd-current@freebsd.org Subject: Re: audio lag in 5.2-Beta (card emu10k1) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Dec 2003 03:57:16 -0000 --huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Dec 11, 2003 at 12:12:01PM +0200, juha.nygard1@netikka.fi wrote: > Upgrading from 5.1 to 5.2-BETA has introduced a startup lag when starting= =20 > to play something through /dev/dsp. It takes about two seconds from press= ing play=20 > button in xmms to hearing the sound. I don't really know if this is a bug= =20 > or a feature but still it is quite annoying. I've seen this on one of my machines too (also bursts of static when seeking in mplayer). Can you try backing out r1.89 of sys/dev/sound/pcm/channel.c? I've not been able to find time to test this hypothesis myself. Kris Index: channel.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /mnt2/ncvs/src/sys/dev/sound/pcm/channel.c,v retrieving revision 1.89 retrieving revision 1.88 diff -u -u -r1.89 -r1.88 --- channel.c 18 Aug 2003 23:18:47 -0000 1.89 +++ channel.c 26 Feb 2003 14:38:19 -0000 1.88 @@ -508,19 +508,7 @@ struct snd_dbuf *bs =3D c->bufsoft; =20 CHN_LOCKASSERT(c); - - /* if we haven't yet started and nothing is buffered, else start*/ - if (!(c->flags & CHN_F_TRIGGERED)) { - if (sndbuf_getready(bs) > 0) { - ret =3D chn_start(c, 1); - if (ret) - return ret; - } else { - return 0; - } - } - - for (;;) { + for (;;) { rdy =3D (c->direction =3D=3D PCMDIR_PLAY)? sndbuf_getfree(bs) : sndbuf_g= etready(bs); if (rdy <=3D threshold) { ret =3D chn_sleep(c, "pcmsyn", 1); @@ -584,13 +572,10 @@ =20 /* * this routine tries to flush the dma transfer. It is called - * on a close of a playback channel. - * first, if there is data in the buffer, but the dma has not yet - * begun, we need to start it. - * next, we wait for the play buffer to drain - * finally, we stop the dma. + * on a close. We immediately abort any read DMA + * operation, and then wait for the play buffer to drain. * - * called from: dsp_close, not valid for record channels. + * called from: dsp_close */ =20 int @@ -601,19 +586,10 @@ struct snd_dbuf *bs =3D c->bufsoft; =20 CHN_LOCKASSERT(c); - KASSERT(c->direction =3D=3D PCMDIR_PLAY, ("chn_flush on bad channel")); - DEB(printf("chn_flush: c->flags 0x%08x\n", c->flags)); - - /* if we haven't yet started and nothing is buffered, else start*/ - if (!(c->flags & CHN_F_TRIGGERED)) { - if (sndbuf_getready(bs) > 0) { - ret =3D chn_start(c, 1); - if (ret) - return ret; - } else { - return 0; - } - } + KASSERT(c->direction =3D=3D PCMDIR_PLAY, ("chn_wrupdate on bad channel")); + DEB(printf("chn_flush c->flags 0x%08x\n", c->flags)); + if (!(c->flags & CHN_F_TRIGGERED)) + return 0; =20 c->flags |=3D CHN_F_CLOSING; resid =3D sndbuf_getready(bs) + sndbuf_getready(b); @@ -627,16 +603,13 @@ ret =3D 0; if (ret =3D=3D 0) { resid =3D sndbuf_getready(bs) + sndbuf_getready(b); - if (resid =3D=3D resid_p) + if (resid >=3D resid_p) count--; - if (resid > resid_p) - DEB(printf("chn_flush: buffer length increasind %d -> %d\n", resid_p, = resid)); resid_p =3D resid; } } if (count =3D=3D 0) - DEB(printf("chn_flush: timeout, hw %d, sw %d\n", - sndbuf_getready(b), sndbuf_getready(bs))); + DEB(printf("chn_flush: timeout\n")); =20 c->flags &=3D ~CHN_F_TRIGGERED; /* kill the channel */ @@ -803,7 +776,7 @@ chn_setvolume(struct pcm_channel *c, int left, int right) { CHN_LOCKASSERT(c); - /* should add a feeder for volume changing if channel returns -1 */ + /* could add a feeder for volume changing if channel returns -1 */ c->volume =3D (left << 8) | right; return 0; } @@ -1102,7 +1075,7 @@ } flags =3D c->feederflags; =20 - DEB(printf("feederflags %x\n", flags)); + DEB(printf("not mapped, feederflags %x\n", flags)); =20 for (type =3D FEEDER_RATE; type <=3D FEEDER_LAST; type++) { if (flags & (1 << type)) { @@ -1120,7 +1093,7 @@ } =20 if (c->feeder->desc->out !=3D fc->desc->in) { - DEB(printf("build fmtchain from 0x%x to 0x%x: ", c->feeder->desc->out= , fc->desc->in)); + DEB(printf("build fmtchain from %x to %x: ", c->feeder->desc->out, fc= ->desc->in)); tmp[0] =3D fc->desc->in; tmp[1] =3D 0; if (chn_fmtchain(c, tmp) =3D=3D 0) { @@ -1133,11 +1106,11 @@ =20 err =3D chn_addfeeder(c, fc, fc->desc); if (err) { - DEB(printf("can't add feeder %p, output 0x%x, err %d\n", fc, fc->desc-= >out, err)); + DEB(printf("can't add feeder %p, output %x, err %d\n", fc, fc->desc->o= ut, err)); =20 return err; } - DEB(printf("added feeder %p, output 0x%x\n", fc, c->feeder->desc->out)); + DEB(printf("added feeder %p, output %x\n", fc, c->feeder->desc->out)); } } =20 @@ -1153,7 +1126,7 @@ u_int32_t *x =3D chn_getcaps(c)->fmtlist; printf("acceptable formats for %s:\n", c->name); while (*x) { - printf("[0x%8x] ", *x); + printf("[%8x] ", *x); x++; } #endif --huq684BweRXVnRxX Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQE/2TyZWry0BWjoQKURAm2sAJ4/fWZ2tH3C022jLBvK8JskZxJ3PQCfZVG0 8eaARThQKIH+bEPNmaVySpw= =g/Jq -----END PGP SIGNATURE----- --huq684BweRXVnRxX--