NetBSD Problem Report #51999

From ryo_on@yk.rim.or.jp  Fri Feb 24 04:25:15 2017
Return-Path: <ryo_on@yk.rim.or.jp>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 5EF357A168
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 24 Feb 2017 04:25:15 +0000 (UTC)
Message-Id: <3vTygq1x66z1XLhPK@mail.SiriusCloud.jp>
Date: Fri, 24 Feb 2017 13:25:07 +0900
From: ryoon@NetBSD.org
Reply-To: ryoon@NetBSD.org
To: gnats-bugs@NetBSD.org
Subject: Recent change in OSS audio breaks audio playback via pkgsrc/audio/pulseaudio
X-Send-Pr-Version: 3.95

>Number:         51999
>Category:       kern
>Synopsis:       Recent change in OSS audio breaks audio playback via pkgsrc/audio/pulseaudio
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 24 04:30:00 +0000 2017
>Closed-Date:    Mon Mar 27 23:44:41 +0000 2017
>Last-Modified:  Mon Mar 27 23:44:41 +0000 2017
>Originator:     Ryo ONODERA
>Release:        NetBSD 7.99.62
>Organization:

>Environment:


System: NetBSD brownie 7.99.62 NetBSD 7.99.62 (DTRACE7) #0: Fri Feb 24 08:55:03 JST 2017 ryoon@brownie:/usr/world/7.99/amd64/obj/sys/arch/amd64/compile/DTRACE7 amd64
Architecture: x86_64
Machine: amd64
>Description:
After this commit
http://mail-index.netbsd.org/source-changes/2017/02/10/msg081897.html ,
OSS audio playback via pkgsrc/audio/pulseaudio does not work properly
on NetBSD/amd64 current.

mplayer -ao pulse from pkgsrc/multimedia/mplayer and Firefox web broser
from pkgsrc/www/firefox with alsa-plugins-pulse does not work.
mplayer case is as follows.

$ mplayer -ao pulse track01.cdda.wav.mp3     MPlayer 1.3.0-5.4.0 (C) 2000-2016 MPlayer Team
224 audio & 451 video codecs

Playing track01.cdda.wav.mp3.
libavformat version 57.56.101 (external)
Audio only file format detected.
Load subtitles in ./
==========================================================================
Requested audio codec family [mpg123] (afm=mpg123) not available.
Enable it at compilation.
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
libavcodec version 57.64.101 (external)
AUDIO: 44100 Hz, 2 ch, floatle, 128.0 kbit/4.54% (ratio: 16002->352800)
Selected audio codec: [ffmp3float] afm: ffmpeg (FFmpeg MPEG layer-3 audio)
==========================================================================


MPlayer interrupted by signal 2 in module: ao2_init


MPlayer interrupted by signal 2 in module: ao2_init




>How-To-Repeat:

Play audio file via pulseaudio.
>Fix:

I have no idea.

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/51999: pulseaudio does not work
Date: Tue, 21 Mar 2017 09:21:27 +0100

 I think this is a libpthread bug.

 A more obvisous failure mode is with mpg123 (install audio/pulseaudio,
 audio/mpg123-pulse, audio/mpg123):

  mpg123 -o pulse $any_mp3_file

 and see:

 High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
         version 1.23.8; written and copyright by Michael Hipp and others
         free software (LGPL) without any warranty but with best wishes
 Assertion 'r == 0 || r == 86' failed at pulsecore/mutex-posix.c:55, function pa_mutex_new(). Aborting.
 Abort (core dumped)


 The code in question is:

 #ifdef HAVE_PTHREAD_PRIO_INHERIT
     if (inherit_priority) {
         r = pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT);
         pa_assert(r == 0 || r == ENOTSUP);
     }
 #endif

 and according to my reading of Posix we should return ENOTSUP here instead
 of EINVAL, as PTHREAD_PRIO_INHERIT is a valid protocol, but we just do not
 support it.

 Martin

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/51999: pulseaudio does not work
Date: Tue, 21 Mar 2017 09:34:50 +0100

 On Tue, Mar 21, 2017 at 08:25:01AM +0000, Martin Husemann wrote:
 >  I think this is a libpthread bug.

 After more digging our libpthread seems to be correct, but it returns
 EINVAL if the attr has not been properly initialized.

 The pulse code seems to do that, but there is macro magic involved...

 Martin

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/51999: pulseaudio does not work
Date: Tue, 21 Mar 2017 09:59:07 +0100

 On Tue, Mar 21, 2017 at 08:35:01AM +0000, Martin Husemann wrote:
 >  The pulse code seems to do that, but there is macro magic involved...

 It is worse.

 The pulse code calls pthread_mutexattr_init() but libpthread defers
 that to libc, since __uselibcstub is true.

 Something missing -pthread in CFLAGS ?

 Martin

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/51999: pulseaudio does not work
Date: Tue, 21 Mar 2017 11:58:01 +0100

 On Tue, Mar 21, 2017 at 09:59:07AM +0100, Martin Husemann wrote:
 > Something missing -pthread in CFLAGS ?

 Yeah, of course: mpg123 is not build with pthreads.

 The patch below gets past this problem, and no I get similar failure mode
 as this PR started with.

 Martin

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/51999: pulseaudio does not work
Date: Tue, 21 Mar 2017 11:58:21 +0100

 And here the patch...

 Index: Makefile
 ===================================================================
 RCS file: /cvsroot/pkgsrc/audio/mpg123/Makefile,v
 retrieving revision 1.55
 diff -u -r1.55 Makefile
 --- Makefile	18 Dec 2016 22:58:34 -0000	1.55
 +++ Makefile	21 Mar 2017 10:55:54 -0000
 @@ -11,6 +11,8 @@
  MPG123_BUILDING_BASE=	# empty

  .include "../../mk/bsd.prefs.mk"
 +PTHREAD_AUTO_VARS=yes
 +.include "../../mk/pthread.buildlink3.mk"

  PLIST_VARS+=	coreaudio oss sun


From: Ryo ONODERA <ryo_on@yk.rim.or.jp>
To: gnats-bugs@NetBSD.org, martin@duskware.de
Cc: 
Subject: Re: kern/51999: pulseaudio does not work
Date: Wed, 22 Mar 2017 22:02:53 +0900 (JST)

 Hi,

 From: Martin Husemann <martin@duskware.de>, Date: Tue, 21 Mar 2017 11:00:03 +0000 (UTC)

 > The following reply was made to PR kern/51999; it has been noted by GNATS.
 > 
 > From: Martin Husemann <martin@duskware.de>
 > To: gnats-bugs@NetBSD.org
 > Cc: 
 > Subject: Re: kern/51999: pulseaudio does not work
 > Date: Tue, 21 Mar 2017 11:58:21 +0100
 > 
 >  And here the patch...
 >  
 >  Index: Makefile
 >  ===================================================================
 >  RCS file: /cvsroot/pkgsrc/audio/mpg123/Makefile,v
 >  retrieving revision 1.55
 >  diff -u -r1.55 Makefile
 >  --- Makefile	18 Dec 2016 22:58:34 -0000	1.55
 >  +++ Makefile	21 Mar 2017 10:55:54 -0000
 >  @@ -11,6 +11,8 @@
 >   MPG123_BUILDING_BASE=	# empty
 >   
 >   .include "../../mk/bsd.prefs.mk"
 >  +PTHREAD_AUTO_VARS=yes
 >  +.include "../../mk/pthread.buildlink3.mk"
 >   
 >   PLIST_VARS+=	coreaudio oss sun
 >   
 >  
 With your patch, 'mpg123 -o pulse test.mp3' has gotten freeze.
 And I cannot detect any sound from the speaker of my machine.
 My NetBSD is amd64-current of Tue Mar 21 21:52:57 JST 2017.

 --
 Ryo ONODERA // ryo_on@yk.rim.or.jp
 PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/51999: pulseaudio does not work
Date: Wed, 22 Mar 2017 14:09:36 +0100

 On Wed, Mar 22, 2017 at 01:05:01PM +0000, Ryo ONODERA wrote:
 >  With your patch, 'mpg123 -o pulse test.mp3' has gotten freeze.
 >  And I cannot detect any sound from the speaker of my machine.
 >  My NetBSD is amd64-current of Tue Mar 21 21:52:57 JST 2017.

 Yes, I did not get it working either. Do you get any error messages loged?
 I likely have some generic console/polkit setup issue.

 Martin

From: Nathanial Sloss <nat@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/51999 pulseaudio broken.
Date: Thu, 23 Mar 2017 18:29:33 +1100

 Hi,

 I believe there is an in liboss inparticular GETISPACE.

 Acording to the OSS documentation get ispace should return the number of bytes 
 that can be read without blocking which would be equal to the record seek 
 value.  It currently returns how by how many bytes empty the record buffer is.

 With the attached patch I was able too get pulseaudio to work.  pacat had no 
 problems andms and the pach worked with other oss applications.

 --- ossaudio.c	2017-02-11 05:16:31.000000000 +1100
 +++ /home/test/ossaudio.c	2017-03-23 18:06:13.000000000 +1100
 @@ -411,11 +411,10 @@ audio_ioctl(int fd, unsigned long com, v
  			return retval;
  		setblocksize(fd, &tmpinfo);
  		bufinfo.fragsize = tmpinfo.blocksize;
 -		bufinfo.fragments = tmpinfo.hiwat - (tmpinfo.play.seek
 -		    + tmpinfo.blocksize - 1) / tmpinfo.blocksize;
 +		bufinfo.fragments = (tmpinfo.hiwat * tmpinfo.blocksize -
 +		    tmpinfo.play.seek) / tmpinfo.blocksize;
  		bufinfo.fragstotal = tmpinfo.hiwat;
 -		bufinfo.bytes = tmpinfo.hiwat * tmpinfo.blocksize
 -		    - tmpinfo.play.seek;
 +		bufinfo.bytes = bufinfo.fragments * tmpinfo.blocksize;
  		*(struct audio_buf_info *)argp = bufinfo;
  		break;
  	case SNDCTL_DSP_GETISPACE:
 @@ -424,11 +423,10 @@ audio_ioctl(int fd, unsigned long com, v
  			return retval;
  		setblocksize(fd, &tmpinfo);
  		bufinfo.fragsize = tmpinfo.blocksize;
 -		bufinfo.fragments = tmpinfo.hiwat - (tmpinfo.record.seek +
 -		    tmpinfo.blocksize - 1) / tmpinfo.blocksize;
 +		bufinfo.fragments = (tmpinfo.record.seek)
 +		    / tmpinfo.blocksize;
  		bufinfo.fragstotal = tmpinfo.hiwat;
 -		bufinfo.bytes = tmpinfo.hiwat * tmpinfo.blocksize
 -		    - tmpinfo.record.seek;
 +		bufinfo.bytes = tmpinfo.record.seek;
  		*(struct audio_buf_info *)argp = bufinfo;
  		break;
  	case SNDCTL_DSP_NONBLOCK:


 Best regards,

 Nat

From: Nathanial Sloss <nat@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: kern/51999 pulseaudio broken
Date: Thu, 23 Mar 2017 21:55:59 +1100

 With this patch to liboss playback and recording with pulseaudio work.

 --- src/lib/libossaudio/ossaudio.c	2017-02-11 05:16:31.000000000 +1100
 +++ /home/netbsd/ossaudio.c	2017-03-23 21:51:14.000000000 +1100
 @@ -411,11 +411,11 @@ audio_ioctl(int fd, unsigned long com, v
  			return retval;
  		setblocksize(fd, &tmpinfo);
  		bufinfo.fragsize = tmpinfo.blocksize;
 -		bufinfo.fragments = tmpinfo.hiwat - (tmpinfo.play.seek
 -		    + tmpinfo.blocksize - 1) / tmpinfo.blocksize;
 +		bufinfo.fragments = (tmpinfo.hiwat * tmpinfo.blocksize - (
 +		    tmpinfo.play.seek + tmpinfo.blocksize -1)) /
 +		    tmpinfo.blocksize;
  		bufinfo.fragstotal = tmpinfo.hiwat;
 -		bufinfo.bytes = tmpinfo.hiwat * tmpinfo.blocksize
 -		    - tmpinfo.play.seek;
 +		bufinfo.bytes = bufinfo.fragments * tmpinfo.blocksize;
  		*(struct audio_buf_info *)argp = bufinfo;
  		break;
  	case SNDCTL_DSP_GETISPACE:
 @@ -424,11 +424,10 @@ audio_ioctl(int fd, unsigned long com, v
  			return retval;
  		setblocksize(fd, &tmpinfo);
  		bufinfo.fragsize = tmpinfo.blocksize;
 -		bufinfo.fragments = tmpinfo.hiwat - (tmpinfo.record.seek +
 -		    tmpinfo.blocksize - 1) / tmpinfo.blocksize;
 +		bufinfo.fragments = (tmpinfo.record.seek)
 +		    / tmpinfo.blocksize;
  		bufinfo.fragstotal = tmpinfo.hiwat;
 -		bufinfo.bytes = tmpinfo.hiwat * tmpinfo.blocksize
 -		    - tmpinfo.record.seek;
 +		bufinfo.bytes = bufinfo.fragments * tmpinfo.blocksize;
  		*(struct audio_buf_info *)argp = bufinfo;
  		break;
  	case SNDCTL_DSP_NONBLOCK:


 Best regards,

 Nat

From: Ryo ONODERA <ryo_on@yk.rim.or.jp>
To: gnats-bugs@NetBSD.org, nat@netbsd.org
Cc: 
Subject: Re: kern/51999 pulseaudio broken
Date: Thu, 23 Mar 2017 21:16:34 +0900 (JST)

 Hi,

 Your patch fixes audio playback from pkgsrc/multimedia/mplayer
 and pkgsrc/www/firefox via pkgsrc/audio/pulseaudio.

 Thank you very much.

 From: Nathanial Sloss <nat@netbsd.org>, Date: Thu, 23 Mar 2017 11:00:01 +0000 (UTC)

 > The following reply was made to PR kern/51999; it has been noted by GNATS.
 > 
 > From: Nathanial Sloss <nat@netbsd.org>
 > To: gnats-bugs@netbsd.org
 > Cc: 
 > Subject: Re: kern/51999 pulseaudio broken
 > Date: Thu, 23 Mar 2017 21:55:59 +1100
 > 
 >  With this patch to liboss playback and recording with pulseaudio work.
 >  
 >  --- src/lib/libossaudio/ossaudio.c	2017-02-11 05:16:31.000000000 +1100
 >  +++ /home/netbsd/ossaudio.c	2017-03-23 21:51:14.000000000 +1100
 >  @@ -411,11 +411,11 @@ audio_ioctl(int fd, unsigned long com, v
 >   			return retval;
 >   		setblocksize(fd, &tmpinfo);
 >   		bufinfo.fragsize = tmpinfo.blocksize;
 >  -		bufinfo.fragments = tmpinfo.hiwat - (tmpinfo.play.seek
 >  -		    + tmpinfo.blocksize - 1) / tmpinfo.blocksize;
 >  +		bufinfo.fragments = (tmpinfo.hiwat * tmpinfo.blocksize - (
 >  +		    tmpinfo.play.seek + tmpinfo.blocksize -1)) /
 >  +		    tmpinfo.blocksize;
 >   		bufinfo.fragstotal = tmpinfo.hiwat;
 >  -		bufinfo.bytes = tmpinfo.hiwat * tmpinfo.blocksize
 >  -		    - tmpinfo.play.seek;
 >  +		bufinfo.bytes = bufinfo.fragments * tmpinfo.blocksize;
 >   		*(struct audio_buf_info *)argp = bufinfo;
 >   		break;
 >   	case SNDCTL_DSP_GETISPACE:
 >  @@ -424,11 +424,10 @@ audio_ioctl(int fd, unsigned long com, v
 >   			return retval;
 >   		setblocksize(fd, &tmpinfo);
 >   		bufinfo.fragsize = tmpinfo.blocksize;
 >  -		bufinfo.fragments = tmpinfo.hiwat - (tmpinfo.record.seek +
 >  -		    tmpinfo.blocksize - 1) / tmpinfo.blocksize;
 >  +		bufinfo.fragments = (tmpinfo.record.seek)
 >  +		    / tmpinfo.blocksize;
 >   		bufinfo.fragstotal = tmpinfo.hiwat;
 >  -		bufinfo.bytes = tmpinfo.hiwat * tmpinfo.blocksize
 >  -		    - tmpinfo.record.seek;
 >  +		bufinfo.bytes = bufinfo.fragments * tmpinfo.blocksize;
 >   		*(struct audio_buf_info *)argp = bufinfo;
 >   		break;
 >   	case SNDCTL_DSP_NONBLOCK:
 >  
 >  
 >  Best regards,
 >  
 >  Nat
 >  

 --
 Ryo ONODERA // ryo_on@yk.rim.or.jp
 PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3

From: Ryo ONODERA <ryo_on@yk.rim.or.jp>
To: gnats-bugs@NetBSD.org, nat@netbsd.org
Cc: 
Subject: Re: kern/51999 pulseaudio broken
Date: Thu, 23 Mar 2017 23:14:13 +0900 (JST)

 Hi,

 Could you commit your patch?

 From: Ryo ONODERA <ryo_on@yk.rim.or.jp>, Date: Thu, 23 Mar 2017 21:16:34 +0900 (JST)

 > Hi,
 > 
 > Your patch fixes audio playback from pkgsrc/multimedia/mplayer
 > and pkgsrc/www/firefox via pkgsrc/audio/pulseaudio.
 > 
 > Thank you very much.

 --
 Ryo ONODERA // ryo_on@yk.rim.or.jp
 PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3

From: "Nathanial Sloss" <nat@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/51999 CVS commit: src
Date: Thu, 23 Mar 2017 15:50:48 +0000

 Module Name:	src
 Committed By:	nat
 Date:		Thu Mar 23 15:50:48 UTC 2017

 Modified Files:
 	src/distrib/sets/lists/base: shl.mi
 	src/lib/libossaudio: ossaudio.c shlib_version

 Log Message:
 Calculate GETISPACE/GETOSPACE properly.
 Bump version.

 Addresses PR kern/51999.


 To generate a diff of this commit:
 cvs rdiff -u -r1.804 -r1.805 src/distrib/sets/lists/base/shl.mi
 cvs rdiff -u -r1.32 -r1.33 src/lib/libossaudio/ossaudio.c
 cvs rdiff -u -r1.7 -r1.8 src/lib/libossaudio/shlib_version

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: nat@NetBSD.org
State-Changed-When: Mon, 27 Mar 2017 23:44:41 +0000
State-Changed-Why:
The submitter has confimed that the patch which has been committed
fixes the problem.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.