Pulseaudio always uses the first audio device
My system has two audio devices. This is probably a common situation these days. The first (device 0) is for the HDMI audio on a PCIE video card. The second (device 1) is the usual audio device on the motherboard. That's the one I use for a pair of speakers. Consequently, I get no sound in the speakers because pulseudio sends it to the HDMI audio channel.
My first change was to place:
into my desktop environment by adding it to my .profile . (/dev/audio is a symlink to /dev/sound/0). Use of AUDIODEV is a standard Solaris strategy that has been inherited by illumos and OI, with fallback to /dev/audio .
Other changes are all made to the OI hipster product in oi-userland. In module-detect.c, the change merely undefines the symbol HAVE_OSS_OUTPUT, fixing bug #9655 . The first result is that the module no longer includes a function to load module-oss. This function and module are only needed for Linux or FreeBSD. module-detect still loads module-solaris as it did before.
In module-oss.c, the change sets up the correct audio device default for illumos and oi-userland, rather than the previous default that was only suitable for Linux. It also selects the correct mixer device instead of always the first one, and changes to comments to describe what it does.
In oss-util.c, the function get_device_number() now resolves a symbolic link to obtain the device number, but only does it if necessary. That's because some device names already have the device number as a trailing digit. As well, it defines the correct mixer name for illumos and oi-userland, rather than the one that works for Linux. Finally, some have the error messages have been improved to include the name of the device that caused the error.
All of these changes are make by patches to the source. New patches are attached to this bug report. You must also remove these patches:
08-oss4.patch 09-sndstat-parse.patch 10-default.patch
All of the changes from these patches are incorporated into new ones. The patch 08-oss4.patch is split into these four new patches to make manipulation easier:
08-default-pa.patch 11-oss-util.patch 14-module-oss.patch 15-oss-util-h.patch
These patches include the changes outlined in the bug report. On patch, 13-module-detect.patch, is completely new. As well, I had to change Makefile to accomodate the patch changes.
With the changes, pulseaudio produces sound in my speakers on the system described above. I also tested it on another system that had only one audio device. It worked there too, with no changes to .profile .
Updated by Gary Mills over 2 years ago
I just built and tested pulseaudio-12.2 . The patches are unchanged. Only the Makefile is changed, and that only slightly. I'm attaching the new version.
The reason these patch changes are necessary is that OSS on Linux has diverged from OSS on illumos. The method of selecting the active audio device is different, for example. The patches do it the illumos way.
Updated by Gary Mills 11 months ago
- % Done changed from 0 to 90
I've updated my patches for version 13.0 of pulseaudio. The purpose of these patches is to accomodate systems that have more than one audio device. The current version of the patches only works on systems that have one audio device, or on systems where the first audio device actually works. All three of my AMD Ryzen systems have two audio devices, one on the motherboard and one on the PCIe video card. Only the second device works. To select the on-board device, I use the AUDIODEV environment variable. This is the standard illumos method to specify the audio device.
All I have left to do is a bit of cleanup on the patches, plus a bit more testing. I'll post the patches here when they are ready.
This change leaves two outstanding problems with pulseaudio on OI. One is the low audio level. As far as I can tell, this problem is caused by the driver in illumos. I've documented my findings in illumos bug report number 13098 .
The other problems are with the Mate Sound Preference GUI. I'll post details later, but all the problems I noticed earlier seem to have been resolved.
Updated by Gary Mills 11 months ago
- File 08-oss4.patch 08-oss4.patch added
- File 13-module-detect.patch 13-module-detect.patch added
- File 15-stdin-util.patch 15-stdin-util.patch added
- File 16-module-gsettings.patch 16-module-gsettings.patch added
I've completed my cleanup and testing. It was completely successful.
With the new patches, pulseaudio handles multiple audio devices in the same way that audioplay and the other audio commands do. The module-detect module does this magic. It first attempts to get the audio device path name from the AUDIODEV environment variable. If this fails, it uses /dev/audio instead. Regardless, the path name must resolve to a character device. It obtains the instance number from this path to set the argument to device=/dev/dspN where N is the instance number, and then loads the module-oss module with this argument. The module-oss module opens and manipulates the correct devices with this instance number. Note that the module-oss module is commented out in /etc/pulse/default.pa, so that this module does not load by itself.
I tested the new pulseaudio package on two systems. One had one audio device and AUDIODEV unset in the environment. This is the usual case, and is the default. The other system had two audio devices with AUDIODEV=/dev/sound/1 set in the environment. This setting selects the second audio device. That was the one that actually produced sound. Both tests were completely successful.
All of the patch files reside in the patches directory. To begin, you must delete these files: 09-sndstat-parse.patch 10-default.patch . You must replace this patch file: 08-oss4.patch . Then add: 13-module-detect.patch 15-stdin-util.patch 16-module-gsettings.patch . These files are retained from the original files: 01-disable-tests.patch 02-glibc.patch 03-fix-pa-info.patch 05-gcc.patch 07-python.patch .
I'm attaching the four patch files that you will need.
To integrate my changes into OI, somebody will need to convert the new patch files or the patches directory into a git PR. I would do this myself, but I don't know how. If somebody could show me, I'd be happy to do it. So far, I've only used git to download the OI source. After that step, all that is needed is to publish the package to the OI repository.
I did promise to provide more details on problems with the Mate Sound Preferences GUI. Actually, it seems reasonably good now. These are all minor problems. I discovered that tput bel did not produce any sound until I used the GUI to enable sound effects. This happened in spite of the terminal bell being already enabled in Mate-terminal. Also in the GUI, the Sound Effects Alert volume setting stays at zero. You can set it higher, but the next time you look at it, it's back at zero. In the GUI, the hardware box is empty: it should show something. Finally, I'd recommend that the input and output devices not be changed in the GUI, mostly because I don't know what effect that would have. It does show two input devices, but I don't know what those are.
Updated by Gary Mills 10 months ago
With considerable help from Andreas Wacknitz, I have now created a PR for my pulseaudio changes. You can find it here:
I have verified that the patches that went into the PR were identical to the ones that attached to this bug report, and that the version of pulseaudio was also the same as before. That means that the testing I reported previously, both for the default case with one audio device and the special case of multiple audio devices, should still apply. I did do a gmake publish on the source that went into the PR. It was successful, as were all the preceeding steps.