commit 7ab2d9572662f1afc776e5d90ecf35e212e3543c Author: cguthrie Date: Thu Jan 21 20:13:50 2010 +0000 xine: Always ensure we create the correct xine port for audio output. When integrating with pulseaudio it was possible that the port was not correctly created. This could happen if phonon was started and the first device detected from PA was a capture device rather than a playback device (which is unlikely) or if the first device detected was a removable audio device which was subsequently removed before playback started. There are possibly other cases where this could happen too. In this case xine would create a null port. This change reverts a previous 'fix' committed in r1051721. I now issue a special case for dealing with PA support in the createPort() method. As a result I no longer need to special case handle the audioDriverFor() method of the backend so this is now removed. CCBUG: 223662 git-svn-id: svn+ssh://svn.kde.org/home/kde/trunk/kdesupport/phonon@1078226 283d02a7-25f6-0310-bc7c-ecb5cbfe19da diff --git a/xine/audiooutput.cpp b/xine/audiooutput.cpp index c6ca730..1444aa3 100644 --- a/xine/audiooutput.cpp +++ b/xine/audiooutput.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "mediaobject.h" #include "backend.h" #include "events.h" @@ -48,10 +49,6 @@ namespace Xine AudioOutput::AudioOutput(QObject *parent) : AbstractAudioOutput(new AudioOutputXT, parent) { - // Always initialise the "device" in use. - // This is needed for PulseAudio support as subsequent calls to setOutputDevice() - // are suppressed - setOutputDevice(0); } AudioOutput::~AudioOutput() @@ -132,6 +129,17 @@ xine_audio_port_t *AudioOutput::createPort(const AudioOutputDevice &deviceDesc) { K_XT(AudioOutput); xine_audio_port_t *port = 0; + + PulseSupport *pulse = PulseSupport::getInstance(); + if (pulse->isActive()) { + // Here we trust that the PA plugin is setup correctly and we just want to use it. + const QByteArray &outputPlugin = "pulseaudio"; + debug() << Q_FUNC_INFO << "PA Active: use output plugin:" << outputPlugin; + port = xine_open_audio_driver(xt->m_xine, outputPlugin.constData(), 0); + debug() << Q_FUNC_INFO << "----------------------------------------------- audio_port created"; + return port; + } + if (!deviceDesc.isValid()) { // use null output for invalid devices port = xine_open_audio_driver(xt->m_xine, "none", 0); diff --git a/xine/backend.cpp b/xine/backend.cpp index 7e881da..9010b8c 100644 --- a/xine/backend.cpp +++ b/xine/backend.cpp @@ -588,9 +588,6 @@ QHash Backend::audioOutputProperties(int audioDevice) QByteArray Backend::audioDriverFor(int audioDevice) { - if (PulseSupport::getInstance()->isActive()) - return "pulseaudio"; - instance()->checkAudioOutputs(); const Backend *const that = instance(); for (int i = 0; i < that->m_audioOutputInfos.size(); ++i) {