From des@des.thinksec.com  Sat Feb 16 13:41:06 2002
Return-Path: <des@des.thinksec.com>
Received: from mx1.thinksec.com (time.thinksec.com [193.212.248.2])
	by hub.freebsd.org (Postfix) with ESMTP id 9136F37B416
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 16 Feb 2002 13:41:05 -0800 (PST)
Received: from des.thinksec.com (213-145-188-14.dd.nextgentel.com [213.145.188.14])
	by mx1.thinksec.com (Postfix) with ESMTP id 513A647E93
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 16 Feb 2002 22:41:04 +0100 (CET)
Received: by des.thinksec.com (Postfix, from userid 2602)
	id AF47355FE; Sat, 16 Feb 2002 22:41:03 +0100 (CET)
Message-Id: <20020216214103.AF47355FE@des.thinksec.com>
Date: Sat, 16 Feb 2002 22:41:03 +0100 (CET)
From: Dag-Erling Smorgrav <des@ofug.org>
Reply-To: Dag-Erling Smorgrav <des@ofug.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: audio/mpg123 port contains bogus patch
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         35009
>Category:       ports
>Synopsis:       audio/mpg123 port contains bogus patch
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Feb 16 13:50:00 PST 2002
>Closed-Date:    Mon Feb 18 01:36:42 PST 2002
>Last-Modified:  Mon Feb 18 01:36:44 PST 2002
>Originator:     Dag-Erling Smorgrav
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD des.thinksec.com 5.0-CURRENT FreeBSD 5.0-CURRENT #129: Fri Feb 15 16:45:40 CET 2002 des@des.thinksec.com:/usr/src/sys/i386/compile/DES i386

>Description:

ports/audio/mpg123/files/patch-audio.c is bogus: get_capabilities() is only
called if the verbose level is 2 or higher.  If you try to enable buffering
without setting a high verbose level, you get the following:

% mpg123 -b 512 **/*3
High Performance MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2 and 3.
Version 0.59r (1999/Jun/15). Written and copyrights by Michael Hipp.
Uses code from various people. See 'README' for more!
THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!

Directory: Volume 2/CD 1/
Playing MPEG stream from track01.mp3 ...
MPEG 1.0 layer III, 112 kbit/s, 44100 Hz joint-stereo
No supported rate found!
Yuck! Error in buffer handling...: Undefined error: 0

Moreover, with the patch applied, get_capabilities() is called once for each
possible combination of channel number, rate and encoding, which for an
average sound card is something like 120 combinations; however,
get_capabilities() already iterates over all those combinations, calling
audio_get_formats() once for each, this results in 14400 calls to 
audio_get_formats(), which is 14280 too many - and audio_get_formats() is I/O-
intensive, so the patch slows mpg123 down to a crawl at startup.

The original code loops over all channel/rate/encoding combinations exactly
once, before checking the verbosity level.

BTW, the kernel bug that ports/audio/mpg123/files/patch-ad tries to work
around was fixed at least half a year ago.

>How-To-Repeat:

See above.

>Fix:

Nuke ports/audio/mpg123/files/patch-audio.c.

>Release-Note:
>Audit-Trail:

From: Dag-Erling Smorgrav <des@ofug.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:  
Subject: Re: ports/35009: audio/mpg123 port contains bogus patch
Date: 16 Feb 2002 22:53:27 +0100

 Dag-Erling Smorgrav <des@ofug.org> writes:
 > BTW, the kernel bug that ports/audio/mpg123/files/patch-ad tries to work
 > around was fixed at least half a year ago.
 
 To be exact, it was fixed in revisions 1.51 (2001/02/13) and 1.19.2.12
 (2001/03/05) of src/sys/dev/sound/pcm/channel.c.  The last release
 that shipped with this bug was FreeBSD 4.2.
 
 DES
 -- 
 Dag-Erling Smorgrav - des@ofug.org
Responsible-Changed-From-To: freebsd-ports->sobomax 
Responsible-Changed-By: petef 
Responsible-Changed-When: Sat Feb 16 14:34:08 PST 2002 
Responsible-Changed-Why:  
Over to maintainer 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=35009 

From: Maxim Sobolev <sobomax@mail.ru>
To: Dag-Erling Smorgrav <des@ofug.org>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: ports/35009: audio/mpg123 port contains bogus patch
Date: 17 Feb 2002 14:48:19 +0200

 --=-F7u7y3lL+gB4ZgeCI989
 Content-Type: text/plain
 Content-Transfer-Encoding: quoted-printable
 
 On Sat, 2002-02-16 at 23:41, Dag-Erling Smorgrav wrote:
 > Nuke ports/audio/mpg123/files/patch-audio.c.
 
 Your diagnosis is incorrect. Actually without the patch startup of
 mpg123 is much slower than with it. See the following log (mpg123.orig
 is the binary compiled with patch-audio.c, while mpg123.des is one
 compiled without), system is 5.0-CURRENT from 25 Jan:
 
 root@notebook# dd if=3D/home/max/Aria/Iron8808.mp3 bs=3D1k count=3D50 of=3D=
 test
 50+0 records in
 50+0 records out
 51200 bytes transferred in 0.055087 secs (929439 bytes/sec)
 root@notebook# time ./mpg123.orig test=20
 High Performance MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2 and 3.
 Version 0.59r (1999/Jun/15). Written and copyrights by Michael Hipp.
 Uses code from various people. See 'README' for more!
 THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!
 
 Playing MPEG stream from test ...
 MPEG 1.0 layer III, 128 kbit/s, 44100 Hz stereo
 
 [0:03] Decoding of test finished.
 
 real    0m4.048s
 user    0m0.331s
 sys     0m0.740s
 root@notebook# time ./mpg123.des test=20
 High Performance MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2 and 3.
 Version 0.59r (1999/Jun/15). Written and copyrights by Michael Hipp.
 Uses code from various people. See 'README' for more!
 THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!
 
 Playing MPEG stream from test ...
 MPEG 1.0 layer III, 128 kbit/s, 44100 Hz stereo
 
 [0:03] Decoding of test finished.
 
 real    0m11.371s
 user    0m0.329s
 sys     0m7.542s
 root@notebook#
 
 Notice the huge difference in real and system times.
 
 -Maxim
 
 --=-F7u7y3lL+gB4ZgeCI989
 Content-Type: application/pgp-signature; name=signature.asc
 Content-Description: This is a digitally signed message part
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.0.6 (FreeBSD)
 Comment: For info see http://www.gnupg.org
 
 iD8DBQA8b6aToNu5t4iCBa8RAiT+AJ9REUhPpuGkiEcwNnMfrVo+J9KXmwCdEvtJ
 0XB3/5xU/sQ29xlaSy/V5TE=
 =+hmL
 -----END PGP SIGNATURE-----
 
 --=-F7u7y3lL+gB4ZgeCI989--
 

From: Dag-Erling Smorgrav <des@ofug.org>
To: sobomax@FreeBSD.org
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: ports/35009: audio/mpg123 port contains bogus patch
Date: 17 Feb 2002 13:55:54 +0100

 Maxim Sobolev <sobomax@mail.ru> writes:
 > On Sat, 2002-02-16 at 23:41, Dag-Erling Smorgrav wrote:
 > > Nuke ports/audio/mpg123/files/patch-audio.c.
 > Your diagnosis is incorrect. Actually without the patch startup of
 > mpg123 is much slower than with it. See the following log (mpg123.orig
 > is the binary compiled with patch-audio.c, while mpg123.des is one
 > compiled without), system is 5.0-CURRENT from 25 Jan:
 
 Please reread the PR, then redo your test with -vv so you're actually
 comparing similar behaviour.  Also, please understand that with
 buffering enabled, the patched code *does not work at all*.
 
 DES
 -- 
 Dag-Erling Smorgrav - des@ofug.org

From: Maxim Sobolev <sobomax@mail.ru>
To: Dag-Erling Smorgrav <des@ofug.org>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: ports/35009: audio/mpg123 port contains bogus patch
Date: 17 Feb 2002 15:27:30 +0200

 --=-ui0uSnMYZisQQtr1AZKm
 Content-Type: text/plain
 Content-Transfer-Encoding: quoted-printable
 
 On Sun, 2002-02-17 at 14:55, Dag-Erling Smorgrav wrote:
 > Maxim Sobolev <sobomax@mail.ru> writes:
 > > On Sat, 2002-02-16 at 23:41, Dag-Erling Smorgrav wrote:
 > > > Nuke ports/audio/mpg123/files/patch-audio.c.
 > > Your diagnosis is incorrect. Actually without the patch startup of
 > > mpg123 is much slower than with it. See the following log (mpg123.orig
 > > is the binary compiled with patch-audio.c, while mpg123.des is one
 > > compiled without), system is 5.0-CURRENT from 25 Jan:
 >=20
 > Please reread the PR,
 
 I did, but it is still remains mostly unclear to me. It seems that you
 are asserting that with the patch applied the code become much slower,
 but my test failed to confirm that.
 
 > then redo your test with -vv so you're actually
 > comparing similar behaviour.
 
 Who ever uses mpg123 with -vv? The patch fixes the slow startup in the
 more common case - when it's invoked without any options and this was
 the main its intent, not the workaround for the bug in the pcm code
 around 4.2 release as you have guessed.
 
 > Also, please understand that with
 > buffering enabled, the patched code *does not work at all*.
 
 I agree that buffering is broken and needs to be fixed, but removing
 patch-audio.c fixes one bug at the expense of another. Please provide a
 real fix that will resolve all problems and submit it as a followup to
 this PR.
 
 Thanks!
 
 -Maxim
 
 --=-ui0uSnMYZisQQtr1AZKm
 Content-Type: application/pgp-signature; name=signature.asc
 Content-Description: This is a digitally signed message part
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.0.6 (FreeBSD)
 Comment: For info see http://www.gnupg.org
 
 iD8DBQA8b6/CoNu5t4iCBa8RAj7KAJ0aUWXB2JEeAM3y8IXWnR/tbKh/nQCfYQmf
 8PSGdzpSR+1qnAt7+lAXDc4=
 =bsYo
 -----END PGP SIGNATURE-----
 
 --=-ui0uSnMYZisQQtr1AZKm--
 

From: Dag-Erling Smorgrav <des@ofug.org>
To: sobomax@mail.ru
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: ports/35009: audio/mpg123 port contains bogus patch
Date: 17 Feb 2002 14:58:42 +0100

 Maxim Sobolev <sobomax@mail.ru> writes:
 > Who ever uses mpg123 with -vv? The patch fixes the slow startup in the
 > more common case - when it's invoked without any options and this was
 > the main its intent, not the workaround for the bug in the pcm code
 > around 4.2 release as you have guessed.
 
 I know that.  The workaround for the pcm bug is in patch-ad, as
 mentioned in the PR.  You are clearly showing that you have not
 bothered to read or try to understand my problem description.  Is this
 an appropriate manner in which to treat PR originators?
 
 > I agree that buffering is broken and needs to be fixed, but removing
 > patch-audio.c fixes one bug at the expense of another.
 
 Wrong.  The patch is superfluous and incorrect.  With the patch,
 device capabilities are never probed unless verbose > 1, in which case
 they are probed 2*M*N times, where M is the number of rates mpg123
 supports and N is the number of formats it supports.  Without the
 patch, device capabilities are probed exactly once, regardless of the
 value of verbose.
 
 If you still feel that mpg123 starts up too slowly, you should
 investigate audio_get_formats() in audio_oss.c and figure out a way to
 detect supported modes using less than three ioctl(2) calls per
 channel/rate/format combination.
 
 DES
 -- 
 Dag-Erling Smorgrav - des@ofug.org

From: Maxim Sobolev <sobomax@mail.ru>
To: Dag-Erling Smorgrav <des@ofug.org>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: ports/35009: audio/mpg123 port contains bogus patch
Date: 17 Feb 2002 18:47:50 +0200

 --=-fHnU3SO6WcnRPEG1yUXf
 Content-Type: text/plain
 Content-Transfer-Encoding: quoted-printable
 
 On Sun, 2002-02-17 at 16:00, Dag-Erling Smorgrav wrote:
 > The following reply was made to PR ports/35009; it has been noted by GNAT=
 S.
 >=20
 > From: Dag-Erling Smorgrav <des@ofug.org>
 > To: sobomax@mail.ru
 > Cc: FreeBSD-gnats-submit@FreeBSD.ORG
 > Subject: Re: ports/35009: audio/mpg123 port contains bogus patch
 > Date: 17 Feb 2002 14:58:42 +0100
 >=20
 >  Maxim Sobolev <sobomax@mail.ru> writes:
 >  > Who ever uses mpg123 with -vv? The patch fixes the slow startup in the
 >  > more common case - when it's invoked without any options and this was
 >  > the main its intent, not the workaround for the bug in the pcm code
 >  > around 4.2 release as you have guessed.
 > =20
 >  I know that.  The workaround for the pcm bug is in patch-ad, as
 >  mentioned in the PR.
 
 Ok, I misread the name of the patch. However, since it doesn't hurt
 anything I would rather let it stay.
 
 >  You are clearly showing that you have not
 >  bothered to read or try to understand my problem description.  Is this
 >  an appropriate manner in which to treat PR originators?
 
 Wanna take over mpg123 maintainership? Please let me know if so because
 I don't really have much time to maintain it by myself properly.
 
 >  > I agree that buffering is broken and needs to be fixed, but removing
 >  > patch-audio.c fixes one bug at the expense of another.
 > =20
 >  Wrong.  The patch is superfluous and incorrect.  With the patch,
 >  device capabilities are never probed unless verbose > 1, in which case
 >  they are probed 2*M*N times, where M is the number of rates mpg123
 >  supports and N is the number of formats it supports.  Without the
 >  patch, device capabilities are probed exactly once, regardless of the
 >  value of verbose.
 
 Huh, are you sure about 2*M*N thing? Again my test run shows that
 startup time is roughly the same in the -vv case both with and without
 patch-audio.c:
 
 time ./mpg123.orig -vv test=20
 High Performance MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2 and 3.
 Version 0.59r (1999/Jun/15). Written and copyrights by Michael Hipp.
 Uses code from various people. See 'README' for more!
 THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!
 
 Audio capabilities:
         |  s16  |  u16  |  u8   |  s8   | ulaw  | alaw  |
  --------------------------------------------------------
   8000  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
  11025  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
  12000  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
  16000  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
  22050  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
  24000  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
  32000  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
  44100  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
  48000  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
 
 Using memory mapped IO for this stream.
 
 Playing MPEG stream from test ...
 MPEG 1.0, Layer: III, Freq: 44100, mode: Stereo, modext: 0, BPF : 417
 Channels: 2, copyright: No, original: Yes, CRC: No, emphasis: 0.
 Bitrate: 128 Kbits/s, Extension value: 0
 Audio: 1:1 conversion, rate: 44100, encoding: signed 16 bit, channels: 2
 Frame#   122 [    0], Time: 00:03.18 [00:00.00],=20
 [0:03] Decoding of test finished.
 
 real    0m11.171s
 user    0m0.315s
 sys     0m6.869s
 root@notebook# time ./mpg123.des -vv test=20
 High Performance MPEG 1.0/2.0/2.5 Audio Player for Layer 1, 2 and 3.
 Version 0.59r (1999/Jun/15). Written and copyrights by Michael Hipp.
 Uses code from various people. See 'README' for more!
 THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! USE AT YOUR OWN RISK!
 
 Audio capabilities:
         |  s16  |  u16  |  u8   |  s8   | ulaw  | alaw  |
  --------------------------------------------------------
   8000  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
  11025  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
  12000  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
  16000  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
  22050  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
  24000  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
  32000  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
  44100  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
  48000  |  M/S  |  M/S  |  M/S  |  M/S  |       |       |
 
 Using memory mapped IO for this stream.
 
 Playing MPEG stream from test ...
 MPEG 1.0, Layer: III, Freq: 44100, mode: Stereo, modext: 0, BPF : 417
 Channels: 2, copyright: No, original: Yes, CRC: No, emphasis: 0.
 Bitrate: 128 Kbits/s, Extension value: 0
 Audio: 1:1 conversion, rate: 44100, encoding: signed 16 bit, channels: 2
 Frame#   122 [    0], Time: 00:03.18 [00:00.00],=20
 [0:03] Decoding of test finished.
 
 real    0m11.452s
 user    0m0.351s
 sys     0m7.531s
 
 >  If you still feel that mpg123 starts up too slowly, you should
 >  investigate audio_get_formats() in audio_oss.c and figure out a way to
 >  detect supported modes using less than three ioctl(2) calls per
 >  channel/rate/format combination.
 
 Patch is always welcome, ya know.
 
 -Maxim
 
 --=-fHnU3SO6WcnRPEG1yUXf
 Content-Type: application/pgp-signature; name=signature.asc
 Content-Description: This is a digitally signed message part
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.0.6 (FreeBSD)
 Comment: For info see http://www.gnupg.org
 
 iD8DBQA8b961oNu5t4iCBa8RAo/BAJ4meZxM6jpGfsNrU1bMfpD5ogEkIwCbBXnv
 Ob5bZzT6ZtSvajueOS8dSv4=
 =Z2Nk
 -----END PGP SIGNATURE-----
 
 --=-fHnU3SO6WcnRPEG1yUXf--
 

From: Dag-Erling Smorgrav <des@ofug.org>
To: sobomax@FreeBSD.org
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: ports/35009: audio/mpg123 port contains bogus patch
Date: 17 Feb 2002 19:04:16 +0100

 Maxim Sobolev <sobomax@mail.ru> writes:
 > Wanna take over mpg123 maintainership? Please let me know if so because
 > I don't really have much time to maintain it by myself properly.
 
 If you're serious, then yes, I'd be willing to do that.
 
 DES
 -- 
 Dag-Erling Smorgrav - des@ofug.org
Responsible-Changed-From-To: sobomax->des 
Responsible-Changed-By: sobomax 
Responsible-Changed-When: Mon Feb 18 00:13:55 PST 2002 
Responsible-Changed-Why:  
Over to a new maintainer. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=35009 
State-Changed-From-To: open->closed 
State-Changed-By: des 
State-Changed-When: Mon Feb 18 01:36:42 PST 2002 
State-Changed-Why:  
Fixed in port revision 5. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=35009 
>Unformatted:
