From nobody@FreeBSD.org  Wed Jul 27 16:11:36 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id D0C3B1065674
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 27 Jul 2011 16:11:36 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id C11EC8FC13
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 27 Jul 2011 16:11:36 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p6RGBaji003966
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 27 Jul 2011 16:11:36 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p6RGBaii003965;
	Wed, 27 Jul 2011 16:11:36 GMT
	(envelope-from nobody)
Message-Id: <201107271611.p6RGBaii003965@red.freebsd.org>
Date: Wed, 27 Jul 2011 16:11:36 GMT
From: David Naylor <naylor.b.david@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] set PCM_CAP_DEFAULT for the default snd device's caps
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         159236
>Category:       kern
>Synopsis:       [pcm] [patch] set PCM_CAP_DEFAULT for the default snd device's caps
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-multimedia
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 27 16:20:04 UTC 2011
>Closed-Date:    
>Last-Modified:  Mon Mar 10 21:10:00 UTC 2014
>Originator:     David Naylor
>Release:        FreeBSD-9
>Organization:
Private
>Environment:
FreeBSD dragon.dg 9.0-BETA1 FreeBSD 9.0-BETA1 #0: Wed Jul 27 17:16:02 SAST 2011     root@dragon.dg:/tmp/home/freebsd9/src/sys/DRAGON  amd64
>Description:
FreeBSD currently does not set PCM_CAP_DEFAULT for any audio device.
The attached patch sets that flag for the default (hw.snd.default_unit)
device.  

It is noted that the OSS implementation from 4Front Technologies sets
PCM_CAP_DEFAULT for all devices.  
>How-To-Repeat:
This issue is obvious with Wine-1.3.25 where it checks for the first
device with PCM_CAP_DEFAULT set.  winecfg has an audio tab that can be
used to test the sound.  
>Fix:


Patch attached with submission follows:

--- dsp.c~	2011-07-27 16:57:42.000000000 +0200
+++ dsp.c	2011-07-27 17:08:32.000000000 +0200
@@ -2640,6 +2640,11 @@
 			 */
 			ai->caps = PCM_CAP_REALTIME | PCM_CAP_MMAP | PCM_CAP_TRIGGER |
 			    ((ch->direction == PCMDIR_PLAY) ? PCM_CAP_OUTPUT : PCM_CAP_INPUT);
+			/*
+			 * If the device is the default one (as per snd_unit) then indicate that.
+			 */
+			if (device_get_unit(d->dev) == snd_unit)
+				ai->caps |= PCM_CAP_DEFAULT;
 
 			/*
 			 * Collect formats supported @b natively by the


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-multimedia 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Jul 27 23:50:47 UTC 2011 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=159236 

From: Andriy Gapon <avg@FreeBSD.org>
To: bug-followup@FreeBSD.org, naylor.b.david@gmail.com
Cc:  
Subject: Re: kern/159236: [pcm] [patch] set PCM_CAP_DEFAULT for the default
 snd device&#39;s caps
Date: Thu, 28 Jul 2011 15:21:27 +0300

 I think that for this change to be complete we also need to have a sysctl handler
 for hw.snd.default_unit that would appropriately update PCM_CAP_DEFAULT flag.
 
 -- 
 Andriy Gapon

From: David Naylor <dbn@freebsd.org>
To: Andriy Gapon <avg@freebsd.org>
Cc: bug-followup@freebsd.org
Subject: Re: kern/159236: [pcm] [patch] set PCM_CAP_DEFAULT for the default snd device&#39;s caps
Date: Mon, 10 Mar 2014 23:04:33 +0300

 --nextPart2034591.Mx6WxTxczf
 Content-Transfer-Encoding: 7Bit
 Content-Type: text/plain; charset="us-ascii"
 
 On Thursday, 28 July 2011 15:21:27 Andriy Gapon wrote:
 > I think that for this change to be complete we also need to have a sysctl
 > handler for hw.snd.default_unit that would appropriately update
 > PCM_CAP_DEFAULT flag.
 
 Can you please clarify why a sysctl handler is required?  
 
 My understanding of the code is that dsp_oss_audioinfo() does not store the 
 device capabilities but gets called every time dsp_ioctl() is called with 
 SNDCTL_ENGINEINFO thus there is no persistent state to update when 
 hw.snd.default_unit changes?  
 --nextPart2034591.Mx6WxTxczf
 Content-Type: application/pgp-signature; name="signature.asc"
 Content-Description: This is a digitally signed message part.
 Content-Transfer-Encoding: 7Bit
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (FreeBSD)
 
 iQJ8BAABCgBmBQJTHijkXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
 ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ5NDhFQzUxMUEyN0YwMzAyRTc5OUI1M0FB
 RDYzRkE4REQ2QjJEQTU1AAoJEK1j+o3WstpV2wsQAJ1dMSOwiRZxTXMEAZtJcSwO
 QYfzdK2rvbKrxC472naCSXcJ2eCBPvVHPY9izYIhn29Itjz5t2x5HTlFi2YKQDXM
 dsa20YJjFa9Jo0p02Z+0I/1xr9DgoNzfGz74yq9RMCWRpV9kh7gLNY5t85Nk/NpW
 n9+RDCELMbAvJE91SUO3ouAkmMhSdY3oMfGRFPQi+4CoDrYhJrV2PJpYnOuLjq4c
 DC6BrpM0c78ds2PYVyossfk81oo02+wrUPAo9AV7zgWT4LN8GvIQw78Dy4epfVHI
 49MTnXvGP6hGbfRO7heLWauyO5CuTw9l0+xkyTEA8R5/GTSapeRWsK6PU3cfIxga
 mswncugmQdILGWYzU8DheyPevz3ht9kwYHqDvtg5YV+aP8FLwzw0Uov6SjFYkTEc
 13pZusZrRBMaXPeCNGraoR9dMeA9DPmLEZdW/Cgj638k6HHmdSasgq1eyewtL7ws
 AtxRNDwMlFKw18TM04XfrJWQaU/idvja/dflurqlo0aHEGU+wNk9jlUX361we29f
 PJIKrZ+mrYMBLClFfPR67N1s8wKwDJY4WV5GBpRYYxQFUHW9kZMWNhadpzJhhpzM
 TLD9DkprWCUQb//Yb49nI7UOjOo2k52E7g22vIfWiaIcWOyXuJgzBqvX0yo4s3IC
 q6Nuq56G41duIK2Cgkis
 =7GEZ
 -----END PGP SIGNATURE-----
 
 --nextPart2034591.Mx6WxTxczf--
 
>Unformatted:
