Bug 234072 - Phonon appears not to work with Pulseaudio or JACK
Summary: Phonon appears not to work with Pulseaudio or JACK
Status: RESOLVED NOT A BUG
Alias: None
Product: Phonon
Classification: Frameworks and Libraries
Component: settings (show other bugs)
Version: 4.4.0 (KDE 4.4.2)
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Matthias Kretz
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-11 18:15 UTC by Mark Greenwood
Modified: 2010-12-05 22:17 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Greenwood 2010-04-11 18:15:27 UTC
Version:           4.6 (using KDE 4.4.2)
OS:                Linux
Installed from:    Ubuntu Packages

Phonon version 4.6 on Kubuntu.

When I configure either Pulseaudio or Jack Audio Connection Kit as the output in phonon, phonon ignores me and uses ALSA instead. 

In the Pulseaudio case the option to select 'PulseAudio' has disappeared to be replaced by 'Playback Using The Pulseaudio Sound Server', which actually uses the ALSA-pulse plugin and has severe latency issues.

In the JACK case I can still select 'Jack Audio Connection Kit' but nothing happens when I try to play audio from phonon applications. It may be that phonon is using ALSA in this case - my JACK connected card uses FFADO but I also have an ALSA card in the machine. However that card is not connected to any hardware so I can't tell if any sound is playing through it.

The previous version of Phonon I was using was 4.3.8, and it all worked correctly there.
Comment 1 Colin Guthrie 2010-04-11 19:10:43 UTC
Sounds like your PA server is not running and not configured to autospawn (this is likely why the directly pulseaudio "device" is hidden - phonon now knows to check for PA running and display devices accordingly)

Make sure you are using the phonon from gitorious and not the Qt supplied version.
Comment 2 Mark Greenwood 2010-04-11 19:41:56 UTC
Pulseaudio is definitely running - pavucontrol can see it, as can mplayer - sound output from mplayer via pulse works correctly - i.e. it does not use the ALSA-pulse plugin).

That also does not explain why it fails to work with JACK, because the JACK server in that case is also running.

How do I know if I'm using the Qt supplied version of phonon? I'm using Kubuntu packages. I reported this as a bug there first, and the reply I got was that they have 'the latest sources and all patches so this must be an upstream regression'.
Comment 3 Mark Greenwood 2010-04-11 19:51:49 UTC
Thinking about this some more, I notice that in the current Mandriva beta (which is admittedly using an earlier version of phonon), when pulseaudio is running the phonon configuration shows me what you might describe as pulseaudio output devices. In the Kubuntu case it is still showing me ALSA devices. It doesn't look right to me. Also the Kubuntu devs told me they haven't taken any of the kmix patches (i.e. kmix still shows ALSA settings, not pulseaudio settings).

It sounds a little like Kubuntu have some dodgy integration in their phonon packages.. what do you think?
Comment 4 Colin Guthrie 2010-04-11 20:52:43 UTC
Yeah I wrote the support for showing PA devices in phonon initially for Mandriva, but it's all upstream now.

I don't really know kubuntu development so don't really know if they ship the Qt version of phonon or the one from gitorious. FWIW the version of phonon in the Mandriva beta is a bit misleading - I basically cocked up the version number as the commit in phonon to change the version to 4.4.0 was not actually part of the git master branch which I used for Mandriva. I fixed this just the other day in git, but still need to update my Mandriva package.

Anyway, in order to see pulseaudio devices, phonon has to be built against pulseaudio 0.9.21 and the script start-pulseaudio-kde (part of pulseaudio) should be run at initial login.

So I think the problem is (like you say) probably the way the Kubuntu packages are compiled and or their version.


FWIW, with all this fixed, I'm wondering what will happen with the Jack case. Normally the PA/Jack integration works as follows:

1) Jack should start up and ask nicely for the audio devices via dbus (needs jack 2 and dbus support I believe but i'm not really clued up on this).
2) PA should release it's vice like grip of the audio devices and unload the sinks.
3) Jack should start up
4) PA should load module-jack-sink/source and thus still be able to use the audio h/w albeit now via jack.

This new jack based pulsaudio sink would show up as another device in phonon (because of the PA integration you saw in Mandriva) and phonon apps would then go via pulse to jack and on to the h/w.

As Phonon apps are mostly desktop in nature, this is probably the nicest/easiest solution without adding specific Jack support to phonon in an integrated kinda way.

I'm not sure how smoothly the above process works in practice as I've not really played with Jack much but certainly that's the intention and the principle of how it's supposed to work.
Comment 5 Mark Greenwood 2010-04-12 11:52:42 UTC
Thanks for that, very informative.

FWIW, in the Jack case I'm not running Pulseaudio at all, so I wonder if that might be causing the Jack issue or if that's a completely separate problem. In that system I want phonon to use its native Jack output. 

However, going back to the pulseaudio issue, you've pointed out something interesting. The script start-pulseaudio-kde does not exist on my Kubuntu system. Indeed I can't find a pulseaudio start script anywhere (I recall it used to live in /etc/X11/Xsession.d I think). So perhaps this is the issue all along. I was going to have a poke around on the Mandriva install to see if I could find it, however installing Kubuntu on the same machine in what I hoped would be a dual-boot kind of thing appears to have made my Mandriva unbootable. Ho-Hum. If I can access the partition and extract the scripts, which ones do I need and where do they live?
Comment 6 Colin Guthrie 2010-04-12 12:11:31 UTC
The start-pulseaudio-kde became available with PA 0.9.21, so perhaps the Ubuntu version is too old? I'm sure there is a PPA (audio-dev?) that has a newer one if that's the case.

The two X11 related scripts shipped with PA (start-pulseaudio-x11 and start-pulseaudio-kde) are both run via and XDG autostart .desktop file. These live in /etc/xdg/autostart (pulseaudio.desktop and pulseaudio-kde.desktop).

XDG compliant DEs (of which KDE is one) will run these both at login.
Comment 7 Mark Greenwood 2010-04-12 13:27:20 UTC
Thanks Colin, I'm running the pulseaudio from the audio-dev ppa already:
pulseaudio:
  Installed: 1:0.9.22~0.9.21+stable-queue-32-g8478-0ubuntu14~~karmic~ubuntuaudiodev1

I'll have a poke around and see if I can find what's going on. The pulseaudio-kde.desktop file does not exist. Looks like a (K)ubuntu packaging problem at the moment.
Comment 8 Myriam Schweingruber 2010-04-12 13:56:54 UTC
Mark, are you still using Karmic? Then it is pretty normal you don't find start-pulseaudio-kde, Since KDE in Karmic was not supposed to be run with Pulseaudio. I suggest you upgrade to Lucid, which is already in Beta2 stage and comes with KDE SC 4.4.2 and the newest Phonon packages. The Pulseaudio packages in Karmic are rather old anyway.
Comment 9 Mark Greenwood 2010-04-12 14:10:28 UTC
Hi all,

Myriam - I am running Karmic with all the kubuntu backports and beta PPAs enabled, as well as the ubuntu-audio-dev PPA which gives me the same version of pulseaudio and phonon that are in Lucid. I have another system where I am running Lucid Beta 2, and I get exactly the same behaviour on there. The pulseaudio kde startup scripts do not exist on either of them.

I have copied the start-pulseaudio-kde script and the desktop file from my Mandriva install, edited them to remove the Mandriva customisations, and tried again. Still the same result - phonon does not detect pulseaudio. I've verified that module-device-manager is being loaded (this seems to be one of the important steps). I don't think there's anything else I can try. This seems to be a kubuntu bug, but the kubuntu phonon guy is adamant it's an upstream bug.
Comment 10 Colin Guthrie 2010-04-12 15:11:28 UTC
Are they sure they've compiled phonon against pulseaudio development headers? It will fall back gracefully as if PulseAudio is not available if it is not installed.

Also make sure not to mix the libphonon from Qt and the libphonon from gitorious too (I'd recommend a snapshot of git master for now - but we'll be pushing out a new version pretty soon - 4.4.1). Ditto for the backend itself. e.g. Qt phonon comes with a gstreamer backend, but if it's used with the new libphonon, again pulseaudio support will not be present.

One thing you can try to see if it's a problem with libphonon is to run:

PHONON_PULSEAUDIO_DEBUG=3 kcmshell4 kcm_phonon

If that has output relating to "PulseSupport" in it, then phonon has been built against PA; if it doesn't, it's not.

Or even just a simple: ldd /usr/lib64/libphonon.so.4.4.0 (or where ever that lib is kept on Ubuntu). It should show you it's linked to pulseaudio too.

Hope that helps narrow down the problem.
Comment 11 Mark Greenwood 2010-04-12 16:09:07 UTC
Colin, I think you've got it.

Firstly, according to apt, phonon and libphonon are version 4.6.. however:

bob@hoss:/usr/lib$ ls -l libphonon*
lrwxrwxrwx 1 root root     18 2010-04-02 10:09 libphonon.so.4 -> libphonon.so.4.3.1
lrwxrwxrwx 1 root root     18 2010-04-02 10:09 libphonon.so.4.3 -> libphonon.so.4.3.1
-rw-r--r-- 1 root root 342536 2010-03-28 02:44 libphonon.so.4.3.1

So it appears libphonon is version 4.3.1, unless something really strange is occurring.

Secondly:

bob@hoss:/usr/lib$ ldd libphonon.so.4.3.1
        linux-gate.so.1 =>  (0x00b47000)
        libQtDBus.so.4 => /usr/lib/libQtDBus.so.4 (0x00e66000)
        libQtGui.so.4 => /usr/lib/libQtGui.so.4 (0x00ee2000)                                                                            
        libQtCore.so.4 => /usr/lib/libQtCore.so.4 (0x001ab000)                                                                          
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x0042a000)                                                                          
        libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0x00110000)                                                                          
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00841000)                                                                                
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0x006c2000)
        libQtXml.so.4 => /usr/lib/libQtXml.so.4 (0x00136000)
        libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x0017b000)
        libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0x00c98000)
        libaudio.so.2 => /usr/lib/libaudio.so.2 (0x0051c000)
        libglib-2.0.so.0 => /lib/libglib-2.0.so.0 (0x00b85000)
        libpng12.so.0 => /usr/lib/libpng12.so.0 (0x00df8000)
        libz.so.1 => /lib/libz.so.1 (0x00536000)
        libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x005bf000)
        libgobject-2.0.so.0 => /usr/lib/libgobject-2.0.so.0 (0x0054c000)
        libSM.so.6 => /usr/lib/libSM.so.6 (0x009ae000)
        libICE.so.6 => /usr/lib/libICE.so.6 (0x0063e000)
        libXrender.so.1 => /usr/lib/libXrender.so.1 (0x00a83000)
        libXext.so.6 => /usr/lib/libXext.so.6 (0x0058a000)
        libX11.so.6 => /usr/lib/libX11.so.6 (0x0085f000)
        libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0x0059a000)
        libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0x00ccb000)
        librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0x00ac4000)
        /lib/ld-linux.so.2 (0x005a2000)
        libexpat.so.1 => /lib/libexpat.so.1 (0x00807000)
        libXt.so.6 => /usr/lib/libXt.so.6 (0x009b7000)
        libXau.so.6 => /usr/lib/libXau.so.6 (0x0059e000)
        libpcre.so.3 => /lib/libpcre.so.3 (0x00a0a000)
        libuuid.so.1 => /lib/libuuid.so.1 (0x00659000)
        libxcb.so.1 => /usr/lib/libxcb.so.1 (0x0098e000)
        libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0x0065e000)

So, apparently not linked against libpulse. Does this look like the culprit to you?
Comment 12 Colin Guthrie 2010-04-12 16:57:48 UTC
Yup that looks like the problem.

Also, the phonon library should be .so.4.4.0 (if using the 4.4. version of phonon or .so.3.80.0 if using the git master up until last Friday and .so.4.4.1 if using git master from last Friday onwards (the change to 4.4.0 was only done in the 4.4 branch and not made on git master  - hence the confusion!).

I suspect that the version 4.3.1 is quite old.... not sure if this is the Qt version or not tho' :s
Comment 13 Mark Greenwood 2010-04-12 17:33:44 UTC
Thanks Colin, I'll report this back to Kubuntu.

I suspect it is the Qt version. 'apt-get source libphonon4' downloads the entire source for qt4-x11...
Comment 14 Myriam Schweingruber 2010-04-12 18:45:23 UTC
Jonathan, could you have a look at this, please?
Comment 15 Jonathan Thomas 2010-04-12 18:56:15 UTC
We've got libphonon patched up to the latest stable release, using a patch from Sandsmark. PA support is compiled in.
Comment 16 Jonathan Thomas 2010-04-12 18:59:02 UTC
Buildlog from the latest Qt upload, showing that PA support is compiled: http://launchpadlibrarian.net/43518237/buildlog_ubuntu-lucid-i386.qt4-x11_4:4.6.2-0ubuntu4_FULLYBUILT.txt.gz
Comment 17 Colin Guthrie 2010-04-12 19:14:01 UTC
That build log is for Qt not phonon on it's own. Do you actually patch up Qt to become the equiv of the phonon version in phonon?

If so this seems like a lot of effort to go to... We just build and ship phonon as a separate package. Our Qt is compiled with phonon support, but the headers and libraries are not installed/packaged. It's a little hacky too I guess, but it seems to be easier to manage (and easier to hack on phonon too!)

Anyway, it does indeed seem like pulsesupport is enabled, but I do not see a HAVE_PULSEAUDIO define anywhere and thus the "support" will basically be a noop - thus not interfering with other code. So I think your patch is broken in some capacity - missing some cmake magic.

Col
Comment 18 Colin Guthrie 2010-04-12 19:14:48 UTC
I meant to say:

That build log is for Qt not phonon on it's own. Do you actually patch up Qt to become the equiv of the phonon version in *gitorious*?
Comment 19 Jonathan Thomas 2010-04-12 20:59:12 UTC
Yes. Up until KDE 4.4 we were building Phonon from Qt, since otherwise it was impossible to provide phonon support for both PyQt4, as well as for QtWebkit. The packaging transition back to building phonon standalone was deemed too disruptive to be done within the context of an LTS cycle, so Martin provided us a patch for libphonon based off of the version in gitorious, which eventually became libphonon 4.4.0.
Comment 20 Mark Greenwood 2010-04-12 22:13:11 UTC
Great, so the source should be there. Now I confess to knowing next to nothing about cmake but I think we have two pieces of evidence:

If, as Colin suggests, the lack of HAVE_PULSEAUDIO in the build output is signficant, then it appears that HAVE_PULSEAUDIO is not defined when building the Kubuntu packages.

From what I can make from the CMakeLists.txt in the sources, a message should be printed when pulseaudio support is being built, and that message is also not in the above build output.

If these two are correct then it looks possible to me that the check for pulseaudio in src/3rdparty/phonon/phonon/CMakeLists.txt is failing for some reason.

As I say, the pulseaudio support works correctly in Mandriva (and also in Fedora now I've checked that) and if we assume (as seems to be likely) that the source code is the same in all cases, then the only reasonable conclusion is that something has gone wrong in the Kubuntu build.

I'd try to track it down if I knew how, but as I say, cmake is all Greek to me.
Comment 21 Jonathan Thomas 2010-04-14 00:24:28 UTC
Actually, Qt not using CMake turned out to be the entire problem. The patch that Martin graciously made for us was flawed in that it didn't patch the monster that is the Qt build system to export the HAVE_PULSEAUDIO flag. Luckily, the PA improvements have landed in the Qt 4.7 git branch, so it was a simple matter of copying the magic bits from 4.7.

On a related note, the patch also didn't bump the Qt version number. I've rectified this so as to avoid further confusion, and the new, fixed Qt should be available within the next few days in Kubuntu.

Setting status to invalid since it was a "partly upstream, partly downstream bug", in a  certain sense. (I think we can all live with that ;-) )