December 2016

I fixed a crash that happened if module-combine-sink was used on top of a filter sink, and the filter sink was removed while the combine sink was running.

It was reported that module-xenpv-sink fails to build. I contacted Giorgos Boutsioukis (the module author) in hopes of getting some clues about why the module might have suddenly stopped building. He didn’t have ideas about the build failure, but he explained that the module has probably never been used by anyone (if I understood correctly, there was a project to develop an audio driver in Xen which the PulseAudio module was intended to use, but the driver was never adopted in Xen). We decided to remove the module from PulseAudio.

I addressed a couple of licensing issues: the license text for the audio filtering code copied from WebKit was not being included in release tarballs, and the top-level license file didn’t mention that the qpaeq utility is licensed under AGPL. Regarding qpaeq, I added the missing note to the top-level license file, but I also started the process to relicense qpaeq from AGPL to LGPL like the rest of PulseAudio code. I haven’t yet received permission from all qpaeq contributors to change the license.

A serious regression was about to creep in the 10.0 release (streaming would stop if a client sent “proactively” more data than the server had requested), but luckily Ahmed Darwish noticed it while working on a different bug. I made a fix for that.

It seemed that I could make the first 10.0 release candidate in December, but due to last minute problems it was postponed a bit. Now the release candidate is out, however, so please test it if you can!

This post was originally written on 2017-01-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.

November 2016

Preparing for the 10.0 release

I continued to work on the combine sink crash that is blocking the release. My fix (which still needs some work) changes the core memory handling in such an invasive way that I think it’s best to postpone merging it after the release so that it gets a bit more testing before becoming widely used. The crash that it fixes is so rare that it’s not very serious if we don’t get the fix in the upcoming release.

My patch for making module-raop-sink compatible with the newest openssl release got reviewed, and I had to make a couple of revisions for the patch. Now it’s merged.

Ahmed Darwish was awesome and fixed two blocker bugs (97769 and 98475), so now only two release blockers remain: removing module-xen-sink and fixing one crash. module-xen-sink will be removed, because it doesn’t build any more, and the module author said that it’s probably not used by anyone. Removing the module is easy, and the remaining crash looks like it will be easy to reproduce, so hopefully we can publish the first release candidate in December.

Other things

I had prepared a libsamplerate update for OpenEmbedded earlier, and now that the OpenEmbedded-Core repository was unfrozen after a release, I submitted the update and cleaned up the libsamplerate packaging a bit. I also studied some odd bits of the OpenEmbedded alsa-lib packaging, resulting in a couple of minor fixes.

Hajime Fujita submitted a new version of his big RAOP patch set that makes module-raop-sink compatible with more recent AirPlay hardware. The patches have existed for a long time, but nobody has had time to review them. This time around Anton Lundin helped by reviewing some of them. It was also discussed that it might be best to skip the review step for the patches if nobody has time for reviewing, since the patches mostly affect just module-raop-sink and that module is becoming more and more obsolete due to only supporting old hardware.

It was reported that the “System Sounds” volume slider doesn’t affect the sounds that are played by module-x11-bell. X11 has its own volume setting for bell sounds, and PulseAudio used to honor that setting, but since the result is a confusing UI, I changed module-x11-bell so that it uses the system sound volume instead of the X11 volume.

This post was originally written on 2016-12-05, 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 2016

Here’s my second monthly report about my PulseAudio activity (there’s not really anything to report on the OpenEmbedded front this time). We’re preparing for the 10.0 release, which means that I should concentrate on getting rid of the release blocker bugs, but actually I ended up doing some other things too.

Another default device handling improvement

I continued to work on the bug about HDMI being preferred over headphones (it should be the other way around). In September I made patches that set the headphone sink as the default when headphones are plugged in, now I made a patch that also moves existing streams to the headphones. So if the user hasn’t explicitly chosen a sink for a stream, such streams now automatically move when the default sink changes. I’m happy this is finally fixed (the patches still are pending review, though), now I think the only major remaining issue with our default device handling is that if the user sets a USB device as the default, that choice is forgotten if the device is removed and plugged in again later.

module-combine-sink crash

Another major work item was bug 95352, which is about a crash when using module-combine-sink. It’s great that we got a backtrace from the bug reporter, because trying to reproduce the problem would be very hard. Based on the backtrace, I’m pretty confident I know why the crash happens, and I’ve been working on a fix. The fix requires relatively big changes, and my first idea didn’t work as well as I expected, so it will take some time to finish it.

The problem is basically that when a client exits, the shared memory associated with the client is freed, and if there’s some part of the system still using a “memblock” that references that memory area, the memory is copied from the shared memory to a local memory pool in the server. This copying involves changing the “type” of the memblock. However, there’s code that assumes that the memblock type won’t change, and if such code runs at the same time the memblock type is being changed, a crash happens. One option would be to remove the incorrect assumptions by adding more locking to the memblock code, but that could cause performance problems and it would also increase the complexity of the memblock code that I think is complex enough already. My current plan is to get rid of the memblock type changes instead. There should be no need to forcibly free the shared memory area that is associated with a disconnecting client, so the memblock type change should be avoidable. There’s also a different situation where the memblock type changes, but I have a plan for getting rid of that too.

module-bluetooth-policy crash

The new feature in module-bluetooth-policy for automatic switching beween A2DP and HSP turned out to cause crashing if there are no other sources in the system than the HSP source. I made a fix for that, but the fix then made module-suspend-on-idle crash due to an old bug that just hadn’t been triggered before. I fixed that too.

Patreon launch

Preparing for the Patreon launch took a significant chunk of time. In particular, deciding what to say in the introduction pitch on the main Patreon page and how to say it was a slow process. Whatever I wrote, it never seemed to be quite right. Well, now I’m finally reasonably happy with the page, and the campaign is live! It has been about a week now since the launch, and the results are better than what I expected – big thanks to all of you who signed up already!

Other things

Thanks to investigating bug 97064, I learnt that I can comfortably blame the kernel or hardware configuration for a certain class of Bluetooth audio problems: if PulseAudio successfully creates a sink and source for HSP, but no audio gets transmitted, the reason may be missing firmware or the Bluetooth adapter may be in a wrong mode.

We have an annoying dependency on GConf due to paprefs, but Sylvain Baubeau has done some work to move paprefs to GSettings. There was initially some unclarity about how to cleanly manage the transition so that the existing settings stored in GConf are preserved, but now it’s starting to look much clearer: we’ll probably ship PulseAudio with both GConf and GSettings enabled by default, and then a bit later update paprefs. The first time the new version of paprefs is run, the settings in GConf get moved to GSettings. At some point in the future we can then drop GConf support from PulseAudio.

I also wrote a few miscellaneous small patches, here’s a list:

  • a patch for allowing Chinese characters (or anything else in UTF-8) in Bluetooth device descriptions.
  • a patch that removes the use of readdir_r(), which glibc has recently deprecated.
  • a couple of patches for making the system.pa configuration file more similar to default.pa. Some modules were loaded in the wrong order, causing volume restoring to not work properly. It seems that the system mode configuration has been severely neglected over the years, and there would still be work to be done to make the configuration more similar to the normal per-user mode (the configuration files can’t be exactly the same, though – there’s a reason why system.pa and default.pa are separate files).
  • a fix for a small error in threaded mainloop example code.
  • a fix for a minor bug found by Coverity: we didn’t always check the return value of dbus_message_iter_append_basic(). The function can in theory fail due to lack of memory.

I think that’s all for now. Thanks for reading!

This post was originally written on 2016-11-01, 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 2016

Here’s my first monthly summary! Last month I made the decision to start a Patreon campaign, and the first concrete action towards that was to start writing notes every day about things I did, because it was clear from the beginning that monthly reports would be a part of the campaign, and there was no way I could write them without notes. So, let’s see what the notes say…

The loopback patches

The month began with reviewing the last few loopback patches from the big patch set that I had started reviewing already a while ago. Georg Chini has been working on them for a long time, this was already the sixth iteration. The patches include many improvements, my favourite is that module-loopback shouldn’t any more accumulate huge latencies if the audio consuming device (speakers) is for some reason slow to start. It’s also nice that it’s now much clearer to me how the dynamic sample rate regulation works in principle. Previously even the basic logic was unclear to me, now it works simply by measuring the end-to-end latency every now and then, and if it’s something else than desired, the sample rate is adjusted accordingly. The specifics of the regulator still go above my head, but according to Georg’s measurements, the latency should be very stable, and the new regulator should work much better than the old one.

Some of the patches were accepted, but most of the good stuff will have to wait until Georg submits the seventh iteration.

Improving default device selection

I decided to tackle bug 93006 (“headphone output is not preferred over HDMI”), even though there are release blocker bugs open and this was not one of them. I try to make occasional contributions to OpenEmbedded(/Yocto) beyond just the routine package updates, and this kind of falls into that category. My understanding is that the bug was found as part of the Yocto project’s QA process. The bug probably isn’t a serious problem for the Yocto folks, but I was motivated to fix it anyway (the problem is certainly not some weird corner case that would only affect Yocto).

So the problem was that the default sink was chosen badly. Headphones should be preferred over HDMI by default. Sinks have a priority value assigned to them, and the priorities are used to determine which sink is the default. Obviously there was something wrong with the priorities.

Headphone and HDMI output priorities are actually associated with ports, not sinks. The headphone port already has a higher priority than the HDMI port, so that was not the issue, but when the default sink is chosen, only sink priorities matter and the port priorities are ignored. I figured that there’s no need to have separate priorities for sinks and ports, so I changed things so that the sink priority is always the same as the priority of the active port. If a sink has multiple ports, the sink’s priority changes when changing the port.

My patches haven’t been reviewed yet, which means that the fix won’t be in the upcoming 10.0 release.

There’s still the problem that if the default sink changes, existing streams don’t get automatically moved to the new default sink (except when using Gnome’s sound settings application). So in the case of HDMI and headphones, my patches fix things so that after headphones are plugged in, new streams will correctly be routed to headphones, but it’s still so that streams that play to HDMI at the time when headphones are plugged in don’t get automatically moved to headphones. I plan to fix this during this month. This behaviour has annoyed me for a long time, so I’m excited to finally make it right.

Enabling memfd by default

PulseAudio 9.0 got the ability to use memfd for shared memory, but the feature wasn’t enabled by default. We want to enable it in 10.0, so I made a simple patch for that. Phoronix created a news story about that, which seemed funny, because users won’t notice any change (with the exception of firejail users, since firejail isn’t compatible with PulseAudio’s old shared memory mechanism). I guess it’s kind of newsworthy, though, since it’s a step towards really useful stuff like safe audio access for untrusted sandboxed applications.

Unfortunately, a serious problem was found relating to memfd. It turned out that 32-bit applications don’t work with 64-bit server if memfd is enabled. This is considered a release blocker bug, so either this will be fixed, or memfd can’t be enabled by default after all. The bug report is here: 67769.

Squashing release blocker bugs

I made some good progress on fixing the bugs that are blocking the 10.0 release. The master branch was frozen on 2016-09-22, but there’s no release candidate yet, because some release blocker bugs are still lacking a fix. Here are the bugs that got attention from me last month:

The new openssl 1.1.0 release is not compatible with code that was written against older versions, so I had to make some changes in module-raop-sink to make it compatible with both old and new openssl versions. It seems weird that an established project like openssl does something like this – libraries should in principle never break compatibility in this way, but I’d guess there was some very good reason for this. I expect distributions to have a lot of fun with transitioning all software to the new openssl version. At least PulseAudio is ready for that transition.

Running out of file descriptors makes the server crash. Fix submitted.

module-rtp-recv crashes when receiving an eight-channel audio stream. Fix submitted.

On some systems unloading a module also removes the module from the memory, which causes crashing if a module unloads itself (this has happened at least with module-bluez5-device). I submitted a fix that makes it safe for a module to unload itself.

The new automatic switching of bluetooth profiles makes the server crash if the bluetooth headset is the only audio device in the system. I started to investigate this, but at the time of writing I don’t have a fix, or even know why the crash happens.

libsamplerate update

On Monday 2016-09-19 the OpenEmbedded recipe reporting system reported that libsamplerate had got a new release (the first new release in years, by the way). That was surprising, since I’m on the libsamplerate mailing list and there was no release announcement (the recipe reporting system found out about the release by monitoring the libsamplerate download page). Nevertheless, I started the usual package update process.

The new release has a new optional dependency on alsa-lib, but the configure script warned about unsupported options when trying to enable or disable the alsa code. Those warnings turned out to be harmless, but I anyway submitted a fix for the configure script to get rid of the warnings.

The current status is weird. I have the package update ready for OpenEmbedded, but the new release has been removed from the libsamplerate web site. The release seemed a bit unfinished from the very start, so I guess the libsamplerate maintainer decided to pull the new release until he has time to do the release properly. The maintainer was travelling last week, but I’d expect something to happen this week.

Miscellaneous patch reviews

Sylvain Baubeau: “Use local icon for zeroconf shared devices” – This improves (in some situations) the device icon shown in GUIs for remote devices. Accepted.

Sylvain Baubeau: “module-gsettings: new module to store configuration using gsettings” – This helps us get rid of the gconf dependency of paprefs (gconf is a dead project). I didn’t review the code in detail, because it was very unclear how the data transition is supposed to be done without causing trouble for paprefs users with old configuration stored in gconf. The discussion is still ongoing, but I expect this to move forward soon.

Jan Steffens: “launch: Remove the already implicit After=pulseaudio.socket” – Cleanup for our systemd service file. Accepted.

Marcin Lewandowski: “core-util: log error if we hit file descriptors limit” – Accepted.

Pali Rohár: “bluetooth: Add support for automatic switch between hsp and a2dp profiles also for bluez5” – PulseAudio 10.0 will have a new feature for automatically switching bluetooth headsets to HSP mode when starting a VoIP call. I haven’t tested this myself, but I hope that this will be a big usability improvement for people that use bluetooth headsets for VoIP calls. This particular patch just adds bluez5 support, because at first this was supported only with bluez4. Accepted.

Pali Rohár: “bluetooth: bluez5: Add profile name to sinks and sources” – This makes A2DP and HSP volumes separate. I hope that’s a good thing. Accepted.

Deepak Srivastava: “xen: Fixed possible memory leak.” – Accepted.

Philip Withnall: “zeroconf-discover: fix a memory leak” – Accepted.

Other things

As usual, some of my time went to responding to questions on the mailing list bug tracker and IRC.

Setting up Patreon and the blog took a significant chunk of time, more than I expected. I expected to launch in September, but I still have things to do before that can happen.

I upgraded my “desktop” computer, a Raspberry Pi 2, from the old Wheezy based Raspbian to the newest release. As was recommended, I did the upgrade by installing the system from scratch. There were some issues with setting up the keyboard layout, so I got an opportunity to contribute to a new project – I submitted a fix for raspberrypi-ui-mods.

Last words

This turned out to be a rather lengthy post. This whole monthly summary thing is new to me – did you like the format? Should there be more or less detail? Would it be better to write two posts per month so that the individual posts would be shorter? Let me know in the comments.

This post was originally written on 2016-10-03, and first made available to my Patreon supporters. In the future these monthly reports will appear on my blog with much less delay than this one. 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.