Illegitimi non carborundum


Some KDE PulseAudio bugfixes

Confession time. I think I cocked up. Someone was asking me about why the HDMI was the default sound device in Phonon when used with PulseAudio. I patiently explained that this was a bug a while back but I fixed it.I diligently went to look up the relevant commit refs and then realised that I hadn't actually committed the fix. Whoops. It seems I fixed that bug during a late part of the Mandriva development cycle and only applied the code changes as patches on top of the source rather than committing them properly. I think I did this because I wanted wider testing before deeming them "ready" for upstream inclusion but then basically forgot. The other reason was perhaps that I was ashamed of myself for using a bubble sort - I really need to make an ordered pa_hashmap for this as I've found myself needing it a couple times now and will definitely need it in the future too. Another item on my todo list!

So apologies for that. I know some distro maintainers look at the Mandriva packages subversion for patches etc. so I'm sure some folks will have these fixes already, but it was a mistake not to push them upstream sooner.

Anyway, fixes are pushed to upstream master and stable-queue and will be part of the (hopefully) upcoming bugfix release.

Share and Enjoy:
  • Digg
  • StumbleUpon
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks
  • Slashdot
  • Mark

    I have a question about Pulseaudio in KDE. I use KDE 4.5.1 Kubuntu Lucid packages. In Phonon Pulseaudio is set as default sound device, which would be ok, if there was a way to select the sound device itself. When I plugin my external speakers (which come with their own sound card) I can not find a way to make them the sound device.

    • Colin

      This is due to poor packaging in Kubuntu. You should bug them about it to make them fix it. I wrote a lot of details about how things should look like if everything is done properly on the PulseAudio wiki.

      The short version is, if you see the “PulseAudio” device in the Phonon settings you are running in why I call “degraded” mode. i.e. PulseAudio support is there in phonon but the relevant modules have not been loaded into PulseAudio to support the KDE Routing policies.

      Hope that helps.

      • Gonzalo

        A quick one, which distro would you recommend instead of Kubuntu? I’ve used it for years but its driving me crazy lately. Debian? Arch? SuSE? Mandriva?


        • Colin

          Well as I have always packaged up the stuff I develop for Mandriva first, I’d recommend that (although you may have heard in other news that we’re forking Mandriva after internal troubles meant that many key people have been laid off, so really I’d recommend Mageia, but as there is not an actual release of that yet, I’d recommend Mandriva for the time being – an upgrade path to Mageia will be provided so it should be painless :D). I’ve also heard good things about OpenSuSE and will actually be giving a talk at the OpenSuSE developer conference on the KDE integration work next month. I’ve not personally tried OpenSuSE so can only really go on what people say.

          I guess the best approach is to try lots of different ones and try to give them each a little time to bed in, and then see which you like best 🙂

          • Gonzalo

            Thanks for the quick response!

            I’m downloading Chakra (Arch based) atm, we’ll see how it works.

            Thanks again.

  • Anonymous Coward

    I’m intrested how did you end up using bublle sort. Couldn’t object be sorted by some generic quick sort or merge sort from library? Even if it would be not so effitient as your specilised hashmap it should still be better than bublle sort.
    Anyway, thanks for you fixes.

    • Colin

      I didn’t look too hard at the issue really if I’m honest. I didn’t check if there was a generic sorting routine already linked in in some library, but my immediate guess was that there was not.

      Ultimately it’s not a critical path and it only happens once per user so I won’t loose much sleep over it, but all the same my CS classes have drummed into me the “bubble sort sucks” mantra, so I can’t help feel slightly embarrassed/ashamed. 😀 I’ll fix it at some point tho’ 🙂

      • For a short mainly sorted list, bubble sort is fine: if only one item is out of order, that can sort with one pass (if it is below it’s position).

  • Kruz

    Thanks for the fix Colin! When are you going to do a bug fix release to the stable branch? And for the master branch?

    The PulseAudio integration to KDE in Kubuntu 10.10 (dev) works better that in
    10.04. Not optimal, but they are progressing 🙂

    • Colin

      I want to do a bug fix release from stable queue ASAP. I’m just waiting to talk to Lennart about it seeing as he’s currently still hiding behind his systemd project 🙂 He’ll be back soon tho’ so hopefully within the next few weeks. As for master, I’m not too sure. I’ve not really been running it so not sure what state it’s in. The DBus stuff will have to be finalised for release so it doesn’t deviate. So I wouldn’t expect a master release for a good few months yet (if not longer).

  • Malic

    Hey Colin,

    I have a small question.
    (in kde multimedia) When I change the device priority of my sound card above my hdmi output. I press apply and adjust for all the other categories. Where is this saved on disk.
    I use pulseaudio with the gstreamer backend

    Maybe strange question. I work with debian squeeze. I’ve build a custom live cd, boot it into ram, copy my config files to the fs in ram. And run my system completely out of ram. Except of my /home folder.
    The only thing I need to do after every boot is change my sound card order to be able to hear sound.

    Can you point me in the right direction?

    Thank you

    • Colin

      Hi Malic,

      The question of “where is the order stored on disk” is, annoyingly, “It depends!” :p In your case, the phonon library will actually just pass the priority list order straight to the PulseAudio daemon and it will store the order for you. (Just FYI, when used without PulseAudio, it is stored within KDE configuration system somewhere – I can’t remember off hand). Ultimately this is stored in ~/.pulse/ folder inside a file that ends in “device-manager.tdb”. This is a binary file format and is not editable by hand.

      That said, by default, PulseAudio should not prefer the HDMI device anyway. I was asked about this just the other day and I replied with a “Oh yeah, I fixed that ages ago” reply… sadly this made me realise that while I had fixed it ages ago in my packages, I had totally neglected to push the fix upstream 🙁 I did that just the other day, so if you add this patch to your PulseAudio build (or just take the latest stable-queue which is what we generally recommend) then HDMI wont be default any more and you wont have to do anything manually!

      But this brings me to another question…. why do you have to set this every boot if your /home is writeable? In theory, the setting is saved into ~/.pulse/ and thus should be preserved right? Yes, that is indeed the case, but I have a similar setup on my network-booting media PC system. It “forgets” it’s profile every boot too…. I managed to narrow this down to /var/lib/dbus/machine-id being regenerated every single boot. PA uses this value to save unique configuration files (the logic being that your home directory may be saved on different machines and hardware volume controls and sink lists etc, should be kept per-machine, not per-user) So when /var/lib/dbus/machine-id changes, I lose all my PA settings. So perhaps you should also look at somehow working out why the machine-id changes and fix that? If do you find out, let me know – I don’t reboot often enough for it to be a real problem for me, so I’ve not done the digging yet myself!!

      Hope this helps.

      • Malic

        Hey Colin,

        thanks for the reply!
        I’ve been searching everything, there is a phonondevicesrc config file in the home somewhere but that doesn’t make any difference.

        But everything is ok now! Your an angel. I’ve went into my pulse audio folder before and there was a HUGE list of files. I looked into a few but didn’t got wise out of them.

        Now what I did, I have a script that copies files from a folder in my home folder into the root fs (in ram) before booting everything. This gives me custom settings. Now I’ve copied my /var/lib/dbus/machine-id to my settings dir. So every boot I have the same one. And now 🙂 my order is saved. Verry happy now!


        • Colin

          Excellent, so the magically changing dbus machine id is to blame for you too.

          I’m gonna go and ask what generates that file so I can work out how to stop it happening so that others in the same situation are not bitten by this problem 🙂

          • Malic

            In my case it’s normal. I boot off a live cd, so every boot will probably has a new random key.
            Rebooted today, and everything is still running!
            This probably solves some other minor pa save problems.
            Nice 🙂