Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 09 Aug 2016 03:18:26 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-ports-bugs@FreeBSD.org
Subject:   [Bug 211684] audio/pulseaudio: Respect hw.snd.default_unit
Message-ID:  <bug-211684-13@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D211684

            Bug ID: 211684
           Summary: audio/pulseaudio: Respect hw.snd.default_unit
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Keywords: patch
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: gnome@FreeBSD.org
          Reporter: t@tobik.me
                CC: gnome@FreeBSD.org, lightside@gmx.com
 Attachment #173433 maintainer-approval?(gnome@FreeBSD.org)
             Flags:
             Flags: maintainer-feedback?(gnome@FreeBSD.org)
                CC: gnome@FreeBSD.org
          Assignee: gnome@FreeBSD.org

Created attachment 173433
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D173433&action=
=3Dedit
pulseaudio.diff

I apologize in advance for the length, odd style and timing of this
bug report.  I know there is a pending update to PulseAudio 9.0 in
bug #210548.  But this should also be applicable to that version.
This one has been bugging me for a while, and others apparently:
https://forums.freebsd.org/threads/45829/#post-319611

IMHO the current pkg-message of PulseAudio reads like a bug report
already, so I'm going to paste part of it here:

> Pulseaudio doesn't know about the hw.snd.default_unit=3D3 sysctl for the
> FreeBSD OSS driver that is used to select the active input/output. So
> for Pulseaudio we also need to tell it which input/output to use. The
> difference is that Pulseaudio has separate input and output configure lin=
es.
> To change the default sink (output):
> # pacmd set-default-sink 3
> To change the default source (input):
> # pacmd set-default-source 3

I propose a small change to module-detect.c so we can make PulseAudio
actually respect the default device.

By loading an OSS module instance that uses /dev/dsp first (before all
the others in /dev/sndstat) we can make PulseAudio default to using
it instead of /dev/dsp0 i.e. it actually respects the default sound
unit set with sysctl hw.snd.default_unit.  The default device will
appear again in /dev/sndstat and thus will be duplicated in PulseAudio
but that should not matter much for the benefit gained (a sane default
user experience and a smaller patch).

How to test that this works (or how I tested that this works):

0. this is before patching and assumes you haven't changed the system
   configuration i.e. /usr/local/etc/pulse/*
1. rm -r ~/.config/pulse (just to make sure there are no previous settings
left)
2. set the default unit to something that isn't 0 e.g. sysctl
hw.snd.default_unit=3D5
3. pkill pulseaudio
4. pulseaudio --daemonize=3Dno -v (optional, only do this if you want to see
what's going on)
5. paplay /usr/local/share/sounds/alsa/Front_Center.wav (assuming
   alsa-utils installed, otherwise use another wav file)=20=20=20
6. silence...
7. a quick look at pacmd list-sinks shows that /dev/dsp0 is the active
   sink (the one with the *) and not /dev/dsp5

8. ok let's apply this patch
9. cd /usr/ports/audio/pulseaudio; svn patch ~/pulseaudio.diff
10. make reinstall
11. pkill pulseaudio
12. rm -r ~/.config/pulse (just to make sure there are no previous settings
left)
13. pulseaudio --daemonize=3Dno -v
14. paplay /usr/local/share/sounds/alsa/Front_Center.wav
15. "Front...Center". Great!
16. in pacmd list-sinks we see that /dev/dsp is the active sink

Thanks to PulseAudio suspending and reopening devices, changes to
hw.snd.default_unit are also picked up without restarting the daemon
(albeit with some latency and when no client currently uses it), or
editing some config file, or running an extra command after sysctl
hw.snd.default_unit=3D5.

Of course, even with this patch applied users can still use all the
other sinks like before if they have more advanced use cases than just
wanting Firefox (or any other PulseAudio client) to play sound.

portlint ok (ignoring preexisting warnings), Poudriere testport on
FreeBSD 9.3/i386 ok

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-211684-13>