January 2018

This month I continued reviewing Georg’s messaging patches (and also had a long discussion thread on the topic). We had some disagreements about how the public API should look like, but those disagreements have been largely resolved now.

It was reported that PulseAudio unnecessarily made dbus-daemon log error messages related to communication with bluetoothd. That was caused by sending a reply to a method call from bluetoothd, when bluetoothd indicated that didn’t want a reply to that call. I made a fix for that.

Raspberry Pi 3 has a bluetooth adapter that apparently is by default configured so that the HSP profile doesn’t work with PulseAudio. I was able to give a hint about similar problems with other adapters, and luckily a workaround for another Broadcom adapter worked also with the adapter in Raspberry Pi 3. Ideally the kernel driver would be fixed to work out-of-the-box, but for now you’ll need to run “sudo hcitool cmd 0x3F 0x01C 0x01 0x02 0x00 0x01 0x01” to make HSP work on Raspberry Pi 3.

The new 2.27 release of glibc added a syscall wrapper (memfd_create) that conflicts with PulseAudio’s internal implementation of that wrapper. I fixed PulseAudio so that it can now be built with both old and new glibc versions.

A recent patch of mine caused a bad case of crashing: whenever ports are changed on an alsa card (e.g. when plugging in headphones), PulseAudio will crash. The patch that introduced this bug is otherwise fine, it just didn’t take into account that the port change callback isn’t always called from the main thread as I assumed, causing things to happen in the wrong thread. I started fixing the issue, but the fix isn’t ready yet. I decided to clean up the core port changing design a bit, since calling the port change callback from different threads is not nice at all.

This post was originally written on 2018-02-06, and first made available to my Patreon supporters. Speaking of Patreon – I’m using crowdfunding in an attempt to make it financially sustainable to continue my volunteer work as a PulseAudio maintainer. If you’d like to help, check out my Patreon page (or Liberapay).

December 2017

The Intel HDMI LPE driver continues to cause problems to PulseAudio despite previous attempts at making it work. To recap, the driver acts in an unusual way when the HDMI cable is not plugged in and PulseAudio tries to play audio to it. Of course, PulseAudio shouldn’t play audio to it in that situation, but there are still cases where that might happen. I wrote a patch that immediately suspends the HDMI sink when the cable is unplugged, which should finally make the worst problems go away (PulseAudio used to get killed due to too much CPU use). Even if the sink is suspended, though, streams may still be connected to it, so I made another patch for automatically moving streams away in this situation, but that was rejected in review. Georg Chini made a proposal for a better scheme, which I will implement. Details will hopefully appear in the January report.

I also made a couple of smaller fixes: A recent patch in module-augment-properties introduced a memory leak that was caught by Coverity, and I fixed that. Another recent patch in the build system had a typo that prevented module-default-device-restore from getting loaded, I fixed that too.

In order to make this report appear less short, I’ll mention some patches that I reviewed:

  • Georg Chini fixed a crash related to profile changes (the root cause for the crash remains a mystery, but the patch adds an extra safety check that should make the crash impossible).
  • Arun Raghavan simplified the build system by changing how module symbols are defined (we used to generate “symdef headers” with an m4 script, the script is now gone).
  • Roliga added a new “sink_input_properties” option to module-ladspa-sink that allows setting e.g. a custom description for the virtual stream that the module creates.
  • Samo Pogačnik added a new “use_system_clock_for_timing” option for module-pipe-sink, which makes it possible to use e.g. the “cat” command to write the sink output to a file. Previously “cat” would consume data so fast that streams connected to the pipe sink couldn’t keep up.
  • Andrius Štikonas ported qpaeq from Qt 4 to Qt 5.
  • I reviewed one of the messaging subsystem patches from Georg Chini that I’ve mentioned before.

In other news, Arun Raghavan has been working on a Meson-based build system for PulseAudio. That may or may not be merged soon. It won’t fully replace the old Autotools-based build system at least in the beginning, but it should be usable in many cases, and improve the build speed in those cases.

This post was originally written on 2018-01-04, and first made available to my Patreon supporters. Speaking of Patreon – I’m using crowdfunding in an attempt to make it financially sustainable to continue my volunteer work as a PulseAudio maintainer. If you’d like to help, check out my Patreon page.

November 2017

It was reported that if a stream has a long underrun (i.e. doesn’t provide any data to play) and then tries to catch up, PulseAudio doesn’t handle that correctly in certain situations, resulting in some amount of silence being played instead of real audio data. I found out why this happens, but I didn’t fix the bug yet.

If a user manually selects a HDMI profile on a sound card that supports both analog and HDMI outputs, module-card-restore will remember that choice. If the HDMI cable is unplugged while PulseAudio is not running, and PulseAudio is then started, module-card-restore used to select the HDMI profile even though it wasn’t plugged in (and PulseAudio knew that it wasn’t plugged in). I fixed module-card-restore so that it doesn’t any more choose unavailable profiles.

Unloading module-echo-cancel crashed sometimes, because messages that the module sent from one thread to another could be processed after the module had been unloaded, and the message handling code didn’t take that into account. I made a fix for that.

Back in February I debugged crashing related to certain assembly code in PulseAudio. The assembly code was used to figure out the processor model in order to enable processor-specific optimizations. At that time my conclusion was that GCC was probably buggy, but I never got around to filing a bug report. Thankfully “EoD” (I don’t know their real name) now filed the bug, and the GCC developers quickly identified the problem: the assembly code in PulseAudio didn’t take x86-64’s feature known as “red zone” into account, so the bug was in PulseAudio after all. The GCC developers also provided several suggestions for fixing the problem, and it was quite straightforward to make a fix (it turned out that no assembly code was required in the first place, since at least GCC and clang provide the __get_cpuid() function that does what the assembly code used to do).

It was reported that the PulseEffects application didn’t work on KDE. Something was moving the application’s stream to a wrong device. After improving the stream moving logging in PulseAudio, the culprit was found to be module-device-manager. That module is only used on KDE to manage stream routing, which is why the problem was specific to KDE. I fixed the module so that it doesn’t mess with streams that have been routed following an explicit request from the owning application.

One recurring problem with bluetooth headsets is that while PulseAudio correctly detects that the headset supports the HSP profile, no audio gets streamed when trying to use the HSP profile. This is typically a problem in the computer’s bluetooth adapter. It may be missing some required firmware or it may be configured in a way that doesn’t work with PulseAudio. It can be hard to figure out what the underlying problem is, but sometimes a fix is found, and last month a user found a fix for the Broadcom BCM4354 bluetooth adapter. I documented the fix on our bluetooth wiki page.

I updated the PulseAudio, ALSA and LAME recipes in OpenEmbedded to the latest releases.

This post was originally written on 2017-12-06, and first made available to my Patreon supporters. Speaking of Patreon – I’m using crowdfunding in an attempt to make it financially sustainable to continue my volunteer work as a PulseAudio maintainer. If you’d like to help, check out my Patreon page.

October 2017

Last month I continued reviewing Georg Chini’s patches for improving the infrastructure for adding new module specific client APIs.

The webrtc backend of module-echo-cancel had locale-dependent parsing code for the beamforming parameters, which meant that parsing failed on those locales that use a comma as the decimal mark. I made the parsing locale-independent.

I found out that the alsa-lib configuration for Intel HDMI LPE contained a definition for the “front” device, which PulseAudio assumes to be analog output. That’s not strictly speaking a valid assumption, but without that assumption it becomes ambiguous whether the sound card has one or two devices if both “front” and “hdmi” exist. I made a patch for alsa-lib that removes the “front” device. With that alsa-lib patch and the earlier pulseaudio patches (of which I made a new version, still pending review) for autodetecting the HDMI device index the Intel HDMI LPE driver reportedly is finally working properly with PulseAudio!

When connecting a new bluetooth headset, PulseAudio used to activate the HSP profile by default. I made a patch that changes the profile priorities so that A2DP has higher priority. A2DP is a better default, because it has better audio quality. HSP is needed with phone applications, but we already have automatic profile switching when a phone application appears.

I updated some outdated volume documentation for libpulse, and also added some documentation about the difference between the sound card clock and the system clock.

I silenced one Coverity warning by adding a couple of assertions in the code. The warning was a false positive, but figuring that out was quite difficult, so I also added comments why the assertions are valid.

It was reported that having module-remap-source on top of a monitor source caused high latency. That was weird, because the processing that module-remap-source does shouldn’t cause any extra latency. I learned that monitor sources cause extra latency if they monitor a sink that supports rewinding. The amount of extra latency changes depending on the latency of streams connected to the monitored sink, but module-remap-source and module-virtual-source didn’t take those changes into account, often causing more latency than necessary. The alsa sink also was overly conservative when setting its “max rewind” value, which made the problem worse. I made fixes for both issues.

This post was originally written on 2017-11-03, and first made available to my Patreon supporters. Speaking of Patreon – I’m using crowdfunding in an attempt to make it financially sustainable to continue my volunteer work as a PulseAudio maintainer. If you’d like to help, check out my Patreon page.

September 2017

Last month PulseAudio 11.0 got released, hooray! The new stuff is documented in the release notes, and I’ve probably linked to the draft version before in these reports, but here’s the link again (this time not a draft): https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/11.0/

Quickly after the release some bad regressions were reported, boo! Some filter sinks were crashing in the new version if the flat volumes feature was enabled. Also, the ALSA mixer handling was broken for sound cards that don’t have any configuration in alsa-lib. I made a fix for both of these issues.

Also, the new bluetooth MTU autodetection feature was known to cause regressions, but it was enabled by default anyway in 11.0. That was deemed a bad idea after all, and the feature was disabled in 11.1. Arun also fixed a crash in the MTU autodetection code.

Another change in 11.1 was that I removed a priority boost for devices that report their form factor as “internal”. The 11.0 release notes advertised that bluetooth and USB sound cards are now prioritized over internal sound cards by default, but actually that was true only for bluetooth devices. The change had not been properly tested for USB, and the internal sound card priority boost still made internal sound cards have higher priority than USB sound cards (at least in cases where the USB sound card doesn’t provide any form factor information).

That’s enough about the releases. Now on to other stuff.

It was reported that on a certain sound card PulseAudio didn’t detect the speaker output. That was because ALSA didn’t indicate the existence of that port except by providing a jack detection mixer control named “Speaker Jack”, and PulseAudio didn’t have configuration for that. I made a patch for that.

When bluetooth headsets advertise their capabilities, they can choose from two different identifiers for the HSP Headset role, which was news to me. PulseAudio used to recognize only one of the identifiers, so to PulseAudio it seemed like the headset didn’t support the HSP profile at all, and naturally that prevented users from using that profile. Now both HSP HS identifiers are recognized.

The equalizer GUI “qpaeq” that is shipped with PulseAudio used to be licensed under AGPL, unlike all other PulseAudio code. Back in December I sent emails to all qpaeq contributors asking for a permission to relicense qpaeq under LGPL. It took some time to receive replies from all contributors, and then it took even longer time for me to take the next step, but now the qpaeq license has finally been changed to LGPL.

I improved the initial ALSA card profile selection. When a new sound card appears (either during PulseAudio startup or when hotplugging a card), PulseAudio will try to choose the best available profile for the card. In case of ALSA cards, the profile availability is based on what has been plugged in (assuming that ALSA provides that information). Previously the algorithm for setting the profile availability was very simplistic: only profiles whose all ports have been indicated as unplugged by ALSA were marked as unavailable. If for example a profile has a sink and a source, and only the sink is unavailable, PulseAudio used to mark the profile as available, which meant that PulseAudio could by default activate a profile whose output was not functional. Now all profiles (apart from some rare exceptions – the algorithm is still not perfect) that don’t have all of their devices available are marked as unavailable.

Victor Gaydov published a very long blog post that explains very comprehensively the PulseAudio design. I have read it all, and I can recommend you to have a look as well. The official PulseAudio documentation is severely lacking in providing an overview of all the core concepts, so this was a very welcome post.

This post was originally written on 2017-10-04, and first made available to my Patreon supporters. Speaking of Patreon – I’m using crowdfunding in an attempt to make it financially sustainable to continue my volunteer work as a PulseAudio maintainer. If you’d like to help, check out my Patreon page.

August 2017

A crash was reported when using an echo canceller together with a jack sink. The root cause was a recently introduced bug in how module-echo-cancel configures its latency range. Fixed.

It turned out that on some sound cards the digital input doesn’t work unless the “PCM Capture Source” ALSA mixer control is set to “IEC958 In”, which PulseAudio didn’t do. Now it does.

While explaining to a user how to use module-remap-sink, I found the existing documentation of the module to be lacking, so I improved it a bit.

I got introduced to the Steelseries Arctis headsets, which have the unusual feature that they have two separate playback volume controls: one for voice audio (mono) and another for all other audio (stereo). Gamers are supposed to appreciate that. In ALSA the headset appears as two devices, but the default configuration in PulseAudio only used the mono device, which was not nice. Johan Heikkilä wrote configuration that makes both devices show up in PulseAudio, but I claim some credit for the configuration too.

PulseAudio used to set the process umask to 022, meaning that the state information that PulseAudio writes on disk was readable by all users. Well, not really, because the files are written in a location that is not accessible to other users, but the files themselves had their permissions set up that way. This was noticed by a user, because at his workplace there’s a strict policy that files must never be readable by other users. The umask that PulseAudio was changed to 077 (i.e. the files are not readable by other users any more).

It was reported that loading, unloading and then loading again a module in the module configuration file didn’t work. Doing that may sound silly, but there’s actually a use case. PulseAudio loads the configuration from the home directory if it exists there, and if it doesn’t, then PulseAudio loads the configuration from /etc. It’s an either/or situation, but it would be useful to put some per-user modifications in the home directory and otherwise use the default system configuration in /etc. It’s possible to reference another file from the configuration, so the bug reporter referenced the system configuration from the per-user configuration and then unloaded module-stream-restore and reloaded it with different parameters. This didn’t work, because the “unload-module” command didn’t unload the module immediately, so the module was still loaded when trying to load it for the second time, and that caused an error. I fixed this simply by modifying the “unload-module” command so that it unloads the module immediately.

The new default device selection code that I wrote recently turned out to have a bug: it could pick a device that hadn’t yet been fully initialized. Fixed.

This post was originally written on 2017-09-06, and first made available to my Patreon supporters. Speaking of Patreon – I’m using crowdfunding in an attempt to make it financially sustainable to continue my volunteer work as a PulseAudio maintainer. If you’d like to help, check out my Patreon page.

July 2017

This month saw the release of PulseAudio 10.99.1, i.e. the first release candidate (RC) of 11.0. I’m not sure if there will be another RC. The Intel HDMI LPE fix was not included in the first RC, and it’s not clear if it will be included in the release at all. There still hasn’t been much testing, but one user had problems with the patch, so it doesn’t seem safe to apply it (unfortunately the user with the problem hasn’t responded to requests for more information). I will be getting some HDMI hardware myself soon. I don’t know what HDMI driver that computer will have, but if it doesn’t have the LPE driver, at least I can check that the patch doesn’t break non-LPE systems.

There are several bluetooth related changes in the upcoming release, and I updated the bluetooth wiki page to reflect those changes. Georg Chini wrote the updated oFono section. I also added a section for listing what features have been added in which PulseAudio version.

Georg Chini is working on a new mechanisms for applications to send messages to and receive notifications from modules. Currently it’s quite cumbersome to add module-specific functionality to the client API, and the new messaging API should help with that. I discussed the new API with Georg in some length.

As I noted in last month’s report, the latency reporting functionality in the “simple API” got an improvement, but there was still some weird behaviour. I managed to track down the remaining bug and fixed it. It turned out to not affect only the simple API, but also the normal streaming API. Basically all recording applications have been getting bad latency information if the recording stream has a different number of channels than the recording source. When recording, the latency information is often not very important (except in a recording studio setting, but those use cases usually use Jack anyway instead of PulseAudio), maybe that’s why we haven’t got much complaints about the bad latency reports.

I fixed a bunch of D-Bus message object leaks related to the dbus_connection_send_with_reply_and_block() function that turned out to be prone to such leaks.

The default equalizer sink description contains the description of the master sink, but the equalizer description was not updated when moving to another master sink. I fixed that.

It was reported that if the current card profile is “off”, because none of the outputs are plugged in, the profile doesn’t get automatically changed when plugging in headphones. I made a fix for that.

This post was originally written on 2017-08-06, and first made available to my Patreon supporters. Speaking of Patreon – I’m using crowdfunding in an attempt to make it financially sustainable to continue my volunteer work as a PulseAudio maintainer. If you’d like to help, check out my Patreon page.