summaryrefslogtreecommitdiffstats
path: root/src/3rdparty
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty')
-rw-r--r--src/3rdparty/phonon/CMakeLists.txt6
-rw-r--r--src/3rdparty/phonon/ds9/abstractvideorenderer.cpp4
-rw-r--r--src/3rdparty/phonon/ds9/backend.cpp14
-rw-r--r--src/3rdparty/phonon/ds9/backend.h4
-rw-r--r--src/3rdparty/phonon/ds9/backendnode.cpp19
-rw-r--r--src/3rdparty/phonon/ds9/ds9.desktop17
-rw-r--r--src/3rdparty/phonon/ds9/effect.cpp4
-rw-r--r--src/3rdparty/phonon/ds9/fakesource.cpp34
-rw-r--r--src/3rdparty/phonon/ds9/iodevicereader.cpp91
-rw-r--r--src/3rdparty/phonon/ds9/iodevicereader.h1
-rw-r--r--src/3rdparty/phonon/ds9/mediagraph.cpp38
-rw-r--r--src/3rdparty/phonon/ds9/mediaobject.cpp201
-rw-r--r--src/3rdparty/phonon/ds9/mediaobject.h8
-rw-r--r--src/3rdparty/phonon/ds9/qasyncreader.cpp72
-rw-r--r--src/3rdparty/phonon/ds9/qasyncreader.h6
-rw-r--r--src/3rdparty/phonon/ds9/qaudiocdreader.cpp54
-rw-r--r--src/3rdparty/phonon/ds9/qaudiocdreader.h2
-rw-r--r--src/3rdparty/phonon/ds9/qbasefilter.cpp33
-rw-r--r--src/3rdparty/phonon/ds9/qbasefilter.h4
-rw-r--r--src/3rdparty/phonon/ds9/qevr9.h143
-rw-r--r--src/3rdparty/phonon/ds9/qmeminputpin.cpp113
-rw-r--r--src/3rdparty/phonon/ds9/qmeminputpin.h9
-rw-r--r--src/3rdparty/phonon/ds9/qpin.cpp73
-rw-r--r--src/3rdparty/phonon/ds9/qpin.h7
-rw-r--r--src/3rdparty/phonon/ds9/videorenderer_default.cpp153
-rw-r--r--src/3rdparty/phonon/ds9/videorenderer_default.h55
-rw-r--r--src/3rdparty/phonon/ds9/videorenderer_evr.cpp215
-rw-r--r--src/3rdparty/phonon/ds9/videorenderer_evr.h56
-rw-r--r--src/3rdparty/phonon/ds9/videorenderer_soft.cpp15
-rw-r--r--src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp113
-rw-r--r--src/3rdparty/phonon/ds9/videorenderer_vmr9.h1
-rw-r--r--src/3rdparty/phonon/ds9/videowidget.cpp50
-rw-r--r--src/3rdparty/phonon/ds9/volumeeffect.cpp5
-rw-r--r--src/3rdparty/phonon/ds9/volumeeffect.h2
-rw-r--r--src/3rdparty/phonon/gstreamer/CMakeLists.txt18
-rw-r--r--src/3rdparty/phonon/gstreamer/ConfigureChecks.cmake7
-rw-r--r--src/3rdparty/phonon/gstreamer/audiodataoutput.cpp143
-rw-r--r--src/3rdparty/phonon/gstreamer/audiodataoutput.h84
-rw-r--r--src/3rdparty/phonon/gstreamer/audiooutput.cpp16
-rw-r--r--src/3rdparty/phonon/gstreamer/backend.cpp73
-rw-r--r--src/3rdparty/phonon/gstreamer/backend.h1
-rw-r--r--src/3rdparty/phonon/gstreamer/devicemanager.cpp70
-rw-r--r--src/3rdparty/phonon/gstreamer/devicemanager.h6
-rw-r--r--src/3rdparty/phonon/gstreamer/effectmanager.cpp2
-rw-r--r--src/3rdparty/phonon/gstreamer/glrenderer.cpp2
-rw-r--r--src/3rdparty/phonon/gstreamer/gsthelper.cpp2
-rw-r--r--src/3rdparty/phonon/gstreamer/gstreamer.desktop57
-rw-r--r--src/3rdparty/phonon/gstreamer/medianode.cpp4
-rw-r--r--src/3rdparty/phonon/gstreamer/mediaobject.cpp296
-rw-r--r--src/3rdparty/phonon/gstreamer/mediaobject.h12
-rw-r--r--src/3rdparty/phonon/gstreamer/qwidgetvideosink.h1
-rw-r--r--src/3rdparty/phonon/gstreamer/videowidget.h1
-rw-r--r--src/3rdparty/phonon/gstreamer/x11renderer.cpp3
-rw-r--r--src/3rdparty/phonon/phonon/CMakeLists.txt35
-rw-r--r--src/3rdparty/phonon/phonon/audiodataoutput.cpp66
-rw-r--r--src/3rdparty/phonon/phonon/audiodataoutput.h129
-rw-r--r--src/3rdparty/phonon/phonon/audiodataoutput_p.h48
-rw-r--r--src/3rdparty/phonon/phonon/audiodataoutputinterface.h44
-rw-r--r--src/3rdparty/phonon/phonon/audiooutput.cpp107
-rw-r--r--src/3rdparty/phonon/phonon/audiooutput.h1
-rw-r--r--src/3rdparty/phonon/phonon/audiooutput_p.h8
-rw-r--r--src/3rdparty/phonon/phonon/audiooutputinterface.h2
-rw-r--r--src/3rdparty/phonon/phonon/backendcapabilities.cpp2
-rw-r--r--src/3rdparty/phonon/phonon/factory.cpp25
-rw-r--r--src/3rdparty/phonon/phonon/factory_p.h7
-rw-r--r--src/3rdparty/phonon/phonon/globalconfig.cpp358
-rw-r--r--src/3rdparty/phonon/phonon/globalconfig.h71
-rw-r--r--src/3rdparty/phonon/phonon/globalconfig_p.h31
-rw-r--r--src/3rdparty/phonon/phonon/mediaobject.cpp12
-rw-r--r--src/3rdparty/phonon/phonon/objectdescription.cpp44
-rw-r--r--src/3rdparty/phonon/phonon/objectdescriptionmodel.cpp2
-rw-r--r--src/3rdparty/phonon/phonon/objectdescriptionmodel.h36
-rw-r--r--src/3rdparty/phonon/phonon/path.cpp8
-rw-r--r--src/3rdparty/phonon/phonon/phonondefs.h5
-rw-r--r--src/3rdparty/phonon/phonon/pulsesupport.cpp1040
-rw-r--r--src/3rdparty/phonon/phonon/pulsesupport.h78
-rw-r--r--src/3rdparty/phonon/phonon/seekslider.cpp4
-rw-r--r--src/3rdparty/phonon/phonon/seekslider_p.h4
-rw-r--r--src/3rdparty/phonon/phonon/swiftslider.cpp103
-rw-r--r--src/3rdparty/phonon/phonon/swiftslider_p.h68
-rw-r--r--src/3rdparty/phonon/phonon/videowidget.cpp16
-rw-r--r--src/3rdparty/phonon/phonon/videowidget.h1
-rw-r--r--src/3rdparty/phonon/phonon/videowidgetinterface.h13
-rw-r--r--src/3rdparty/phonon/phonon/volumeslider_p.h4
-rw-r--r--src/3rdparty/phonon/qt7/audionode.h2
-rw-r--r--src/3rdparty/phonon/qt7/audionode.mm1
-rw-r--r--src/3rdparty/phonon/qt7/backendinfo.mm13
-rw-r--r--src/3rdparty/phonon/qt7/mediaobject.h40
-rw-r--r--src/3rdparty/phonon/qt7/mediaobject.mm306
-rw-r--r--src/3rdparty/phonon/qt7/mediaobjectaudionode.mm2
-rw-r--r--src/3rdparty/phonon/qt7/quicktimeaudioplayer.mm2
-rw-r--r--src/3rdparty/phonon/qt7/quicktimemetadata.h8
-rw-r--r--src/3rdparty/phonon/qt7/quicktimemetadata.mm43
-rw-r--r--src/3rdparty/phonon/qt7/quicktimevideoplayer.h28
-rw-r--r--src/3rdparty/phonon/qt7/quicktimevideoplayer.mm265
-rw-r--r--src/3rdparty/phonon/qt7/videoframe.mm24
96 files changed, 3611 insertions, 1915 deletions
diff --git a/src/3rdparty/phonon/CMakeLists.txt b/src/3rdparty/phonon/CMakeLists.txt
index a25ec5d..ef7d6f5 100644
--- a/src/3rdparty/phonon/CMakeLists.txt
+++ b/src/3rdparty/phonon/CMakeLists.txt
@@ -70,6 +70,10 @@ if (CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-DQT_NO_DEBUG)
endif (MINGW)
+ if (QT_USE_FRAMEWORKS)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -F${QT_LIBRARY_DIR}")
+ endif (QT_USE_FRAMEWORKS)
+
check_cxx_compiler_flag(-fPIE HAVE_FPIE_SUPPORT)
if(KDE4_ENABLE_FPIE)
if(HAVE_FPIE_SUPPORT)
@@ -149,7 +153,7 @@ set(CMAKE_COLOR_MAKEFILE ON)
set(PHONON_LIB_MAJOR_VERSION "4")
set(PHONON_LIB_MINOR_VERSION "3")
-set(PHONON_LIB_PATCH_VERSION "50")
+set(PHONON_LIB_PATCH_VERSION "80")
set(PHONON_LIB_VERSION "${PHONON_LIB_MAJOR_VERSION}.4.0")
set(PHONON_LIB_SOVERSION ${PHONON_LIB_MAJOR_VERSION})
diff --git a/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp b/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp
index a9d0694..e932e70 100644
--- a/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp
+++ b/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp
@@ -99,8 +99,8 @@ namespace Phonon
m_dstX = m_dstY = 0;
if (ratio > 0) {
- if ((realWidth / realHeight > ratio && scaleMode == Phonon::VideoWidget::FitInView)
- || (realWidth / realHeight < ratio && scaleMode == Phonon::VideoWidget::ScaleAndCrop)) {
+ if (realWidth / realHeight > ratio && scaleMode == Phonon::VideoWidget::FitInView
+ || realWidth / realHeight < ratio && scaleMode == Phonon::VideoWidget::ScaleAndCrop) {
//the height is correct, let's change the width
m_dstWidth = qRound(realHeight * ratio);
m_dstX = qRound((realWidth - realHeight * ratio) / 2.);
diff --git a/src/3rdparty/phonon/ds9/backend.cpp b/src/3rdparty/phonon/ds9/backend.cpp
index fbc4bdc..2c56af7 100644
--- a/src/3rdparty/phonon/ds9/backend.cpp
+++ b/src/3rdparty/phonon/ds9/backend.cpp
@@ -41,8 +41,6 @@ namespace Phonon
{
namespace DS9
{
- QMutex *Backend::directShowMutex = 0;
-
bool Backend::AudioMoniker::operator==(const AudioMoniker &other)
{
return other->IsEqual(*this) == S_OK;
@@ -52,8 +50,6 @@ namespace Phonon
Backend::Backend(QObject *parent, const QVariantList &)
: QObject(parent)
{
- directShowMutex = &m_directShowMutex;
-
::CoInitialize(0);
//registering meta types
@@ -66,8 +62,6 @@ namespace Phonon
m_audioOutputs.clear();
m_audioEffects.clear();
::CoUninitialize();
-
- directShowMutex = 0;
}
QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const QList<QVariant> &args)
@@ -137,7 +131,6 @@ namespace Phonon
QList<int> Backend::objectDescriptionIndexes(Phonon::ObjectDescriptionType type) const
{
- QMutexLocker locker(&m_directShowMutex);
QList<int> ret;
switch(type)
@@ -164,7 +157,7 @@ namespace Phonon
while (S_OK == enumMon->Next(1, mon.pparam(), 0)) {
LPOLESTR str = 0;
mon->GetDisplayName(0,0,&str);
- const QString name = QString::fromWCharArray(str);
+ const QString name = QString::fromUtf16((unsigned short*)str);
ComPointer<IMalloc> alloc;
::CoGetMalloc(1, alloc.pparam());
alloc->Free(str);
@@ -211,7 +204,6 @@ namespace Phonon
QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(Phonon::ObjectDescriptionType type, int index) const
{
- QMutexLocker locker(&m_directShowMutex);
QHash<QByteArray, QVariant> ret;
switch (type)
{
@@ -224,7 +216,7 @@ namespace Phonon
LPOLESTR str = 0;
HRESULT hr = mon->GetDisplayName(0,0, &str);
if (SUCCEEDED(hr)) {
- QString name = QString::fromWCharArray(str);
+ QString name = QString::fromUtf16((unsigned short*)str);
ComPointer<IMalloc> alloc;
::CoGetMalloc(1, alloc.pparam());
alloc->Free(str);
@@ -239,7 +231,7 @@ namespace Phonon
WCHAR name[80]; // 80 is clearly stated in the MSDN doc
HRESULT hr = ::DMOGetName(m_audioEffects[index], name);
if (SUCCEEDED(hr)) {
- ret["name"] = QString::fromWCharArray(name);
+ ret["name"] = QString::fromUtf16((unsigned short*)name);
}
}
break;
diff --git a/src/3rdparty/phonon/ds9/backend.h b/src/3rdparty/phonon/ds9/backend.h
index 7c3c109..ad638f2 100644
--- a/src/3rdparty/phonon/ds9/backend.h
+++ b/src/3rdparty/phonon/ds9/backend.h
@@ -23,7 +23,6 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#include <phonon/phononnamespace.h>
#include <QtCore/QList>
-#include <QtCore/QMutex>
#include "compointer.h"
#include "backendnode.h"
@@ -64,8 +63,6 @@ namespace Phonon
Filter getAudioOutputFilter(int index) const;
- static QMutex *directShowMutex;
-
Q_SIGNALS:
void objectDescriptionChanged(ObjectDescriptionType);
@@ -77,7 +74,6 @@ namespace Phonon
};
mutable QVector<AudioMoniker> m_audioOutputs;
mutable QVector<CLSID> m_audioEffects;
- mutable QMutex m_directShowMutex;
};
}
}
diff --git a/src/3rdparty/phonon/ds9/backendnode.cpp b/src/3rdparty/phonon/ds9/backendnode.cpp
index 737ab7b..7e0b3cd 100644
--- a/src/3rdparty/phonon/ds9/backendnode.cpp
+++ b/src/3rdparty/phonon/ds9/backendnode.cpp
@@ -57,25 +57,6 @@ namespace Phonon
BackendNode::~BackendNode()
{
- //this will remove the filter from the graph
- FILTER_INFO info;
- for(int i = 0; i < FILTER_COUNT; ++i) {
- const Filter &filter = m_filters[i];
- if (!filter)
- continue;
- filter->QueryFilterInfo(&info);
- if (info.pGraph) {
- HRESULT hr = info.pGraph->RemoveFilter(filter);
-
- if (FAILED(hr) && m_mediaObject) {
- m_mediaObject->ensureStopped();
-
- hr = info.pGraph->RemoveFilter(filter);
- }
- Q_ASSERT(SUCCEEDED(hr));
- info.pGraph->Release();
- }
- }
}
void BackendNode::setMediaObject(MediaObject *mo)
diff --git a/src/3rdparty/phonon/ds9/ds9.desktop b/src/3rdparty/phonon/ds9/ds9.desktop
index 764390e..1bc3451 100644
--- a/src/3rdparty/phonon/ds9/ds9.desktop
+++ b/src/3rdparty/phonon/ds9/ds9.desktop
@@ -5,12 +5,13 @@ MimeType=application/x-annodex;video/quicktime;video/x-quicktime;audio/x-m4a;app
X-KDE-Library=phonon_ds9
X-KDE-PhononBackendInfo-InterfaceVersion=1
X-KDE-PhononBackendInfo-Version=0.1
-X-KDE-PhononBackendInfo-Website=http://qt.nokia.com/
+X-KDE-PhononBackendInfo-Website=http://www.trolltech.com/
InitialPreference=15
Name=DirectShow9
Name[bg]=DirectShow9
Name[ca]=DirectShow9
+Name[ca@valencia]=DirectShow9
Name[cs]=DirectShow9
Name[da]=DirectShow9
Name[de]=DirectShow9
@@ -19,11 +20,14 @@ Name[en_GB]=DirectShow9
Name[es]=DirectShow9
Name[et]=DirectShow9
Name[eu]=DirectShow9
+Name[fi]=DirectShow9
Name[fr]=DirectShow9
Name[ga]=DirectShow9
Name[gl]=DirectShow9
+Name[hr]=DirectShow9
Name[hsb]=DirectShow9
Name[hu]=DirectShow9
+Name[id]=DirectShow9
Name[is]=DirectShow9
Name[it]=DirectShow9
Name[ja]=DirectShow9
@@ -31,6 +35,7 @@ Name[ko]=DirectShow9
Name[ku]=DirectShow9
Name[lt]=DirectShow9
Name[lv]=DirectShow9
+Name[nb]=DirectShow9
Name[nds]=DirectShow9
Name[nl]=DirectShow9
Name[nn]=DirectShow9
@@ -38,10 +43,13 @@ Name[pa]=ਡਾਇਰੈਕਸ਼ੋ9
Name[pl]=DirectShow9
Name[pt]=DirectShow9
Name[pt_BR]=DirectShow9
+Name[ru]=DirectShow9
Name[se]=DirectShow9
Name[sk]=DirectShow 9
Name[sl]=DirectShow 9
Name[sr]=Директшоу‑9
+Name[sr@ijekavian]=Директшоу‑9
+Name[sr@ijekavianlatin]=DirectShow‑9
Name[sr@latin]=DirectShow‑9
Name[sv]=Directshow 9
Name[tr]=DirectShow9
@@ -53,6 +61,7 @@ Name[zh_TW]=DirectShow9
Comment=Phonon DirectShow9 backend
Comment[bg]=Phonon DirectShow9
Comment[ca]=Dorsal DirectShow9 del Phonon
+Comment[ca@valencia]=Dorsal DirectShow9 del Phonon
Comment[cs]=Phonon DirectShow9 backend
Comment[da]=DirectShow9-backend til Phonon
Comment[de]=Phonon-Treiber für DirectShow9
@@ -61,11 +70,13 @@ Comment[en_GB]=Phonon DirectShow9 backend
Comment[es]=Motor DirectShow9 para Phonon
Comment[et]=Phononi DirectShow9 taustaprogramm
Comment[eu]=Phonon DirectShow9 backend
+Comment[fi]=Phonon DirectShow9-taustaohjelma
Comment[fr]=Système de gestion DirectShow9 pour Phonon
Comment[ga]=Inneall DirectShow9 le haghaidh Phonon
Comment[gl]=Infraestrutura de DirectShow9 para Phonon
Comment[hsb]=Phonon DirectShow9 backend
Comment[hu]=Phonon DirectShow9 modul
+Comment[id]=Phonon DirectShow9 backend
Comment[is]=Phonon DirectShow9 bakendi
Comment[it]=Motore DirectShow9 di Phonon
Comment[ja]=Phonon DirectShow9 バックエンド
@@ -73,6 +84,7 @@ Comment[ko]=Phonon DirectShow9 백엔드
Comment[ku]=Binesaza Phonon DirectShow9
Comment[lt]=Phonon DirectShow9 galinė sąsaja
Comment[lv]=Phonon DirectShow9 aizmugure
+Comment[nb]=Phonon-motor for DirectShow9
Comment[nds]=Phonon-Hülpprogrmm DirectShow9
Comment[nl]=DirectShow9-backend (Phonon)
Comment[nn]=Phonon-motor for DirectShow9
@@ -80,10 +92,13 @@ Comment[pa]=ਫੋਨੋਨ ਡਾਇਰੈਕਟਸ਼ੋ9 ਬੈਕਐਂਡ
Comment[pl]=Obsługa DirectShow9 przez Phonon
Comment[pt]=Infra-estrutura do DirectShow9 para o Phonon
Comment[pt_BR]=Infraestrutura Phonon DirectShow9
+Comment[ru]=Механизм DirectShow9 для Phonon
Comment[se]=Phonon DirectShow9 duogášmohtor
Comment[sk]=Phonon DirectShow 9 podsystém
Comment[sl]=Phononova Hrbtenica DirectShow 9
Comment[sr]=Директшоу‑9 као позадина Фонона
+Comment[sr@ijekavian]=Директшоу‑9 као позадина Фонона
+Comment[sr@ijekavianlatin]=DirectShow‑9 kao pozadina Phonona
Comment[sr@latin]=DirectShow‑9 kao pozadina Phonona
Comment[sv]=Phonon Directshow 9-gränssnitt
Comment[tr]=Phonon DirectShow9 arka ucu
diff --git a/src/3rdparty/phonon/ds9/effect.cpp b/src/3rdparty/phonon/ds9/effect.cpp
index ebe976b..104a3c1 100644
--- a/src/3rdparty/phonon/ds9/effect.cpp
+++ b/src/3rdparty/phonon/ds9/effect.cpp
@@ -82,7 +82,7 @@ namespace Phonon
current += wcslen(current) + 1; //skip the name
current += wcslen(current) + 1; //skip the unit
for(; *current; current += wcslen(current) + 1) {
- values.append( QString::fromWCharArray(current) );
+ values.append( QString::fromUtf16((unsigned short*)current) );
}
}
//FALLTHROUGH
@@ -107,7 +107,7 @@ namespace Phonon
Phonon::EffectParameter::Hints hint = info.mopCaps == MP_CAPS_CURVE_INVSQUARE ?
Phonon::EffectParameter::LogarithmicHint : Phonon::EffectParameter::Hints(0);
- const QString n = QString::fromWCharArray(name);
+ const QString n = QString::fromUtf16((unsigned short*)name);
ret.append(Phonon::EffectParameter(i, n, hint, def, min, max, values));
::CoTaskMemFree(name); //let's free the memory
}
diff --git a/src/3rdparty/phonon/ds9/fakesource.cpp b/src/3rdparty/phonon/ds9/fakesource.cpp
index 4dce138..9a61a2e 100644
--- a/src/3rdparty/phonon/ds9/fakesource.cpp
+++ b/src/3rdparty/phonon/ds9/fakesource.cpp
@@ -29,10 +29,8 @@ namespace Phonon
namespace DS9
{
static WAVEFORMATEX g_defaultWaveFormat = {WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0};
- static VIDEOINFOHEADER2 g_defaultVideoInfo = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0, {0}, 0, {sizeof(BITMAPINFOHEADER), 1, 1, 1, 0, 0, 0, 0, 0, 0, 0} };
-
- static const AM_MEDIA_TYPE g_fakeAudioType = {MEDIATYPE_Audio, MEDIASUBTYPE_PCM, 0, 0, 2, FORMAT_WaveFormatEx, 0, sizeof(WAVEFORMATEX), reinterpret_cast<BYTE*>(&g_defaultWaveFormat)};
- static const AM_MEDIA_TYPE g_fakeVideoType = {MEDIATYPE_Video, MEDIASUBTYPE_RGB32, TRUE, FALSE, 0, FORMAT_VideoInfo2, 0, sizeof(VIDEOINFOHEADER2), reinterpret_cast<BYTE*>(&g_defaultVideoInfo)};
+ static BITMAPINFOHEADER g_defautBitmapHeader = { sizeof(BITMAPINFOHEADER), 1, 1, 1, 0, 0, 0, 0, 0, 0, 0};
+ static VIDEOINFOHEADER2 g_defaultVideoInfo = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
class FakePin : public QPin
{
@@ -130,12 +128,36 @@ namespace Phonon
void FakeSource::createFakeAudioPin()
{
- new FakePin(this, g_fakeAudioType);
+ AM_MEDIA_TYPE mt;
+ qMemSet(&mt, 0, sizeof(AM_MEDIA_TYPE));
+ mt.majortype = MEDIATYPE_Audio;
+ mt.subtype = MEDIASUBTYPE_PCM;
+ mt.formattype = FORMAT_WaveFormatEx;
+ mt.lSampleSize = 2;
+
+ //fake the format (stereo 44.1 khz stereo 16 bits)
+ mt.cbFormat = sizeof(WAVEFORMATEX);
+ mt.pbFormat = reinterpret_cast<BYTE*>(&g_defaultWaveFormat);
+
+ new FakePin(this, mt);
}
void FakeSource::createFakeVideoPin()
{
- new FakePin(this, g_fakeVideoType);
+ AM_MEDIA_TYPE mt;
+ qMemSet(&mt, 0, sizeof(AM_MEDIA_TYPE));
+ mt.majortype = MEDIATYPE_Video;
+ mt.subtype = MEDIASUBTYPE_RGB32;
+ mt.formattype = FORMAT_VideoInfo2;
+ mt.bFixedSizeSamples = 1;
+
+ g_defaultVideoInfo.bmiHeader = g_defautBitmapHeader;
+
+ //fake the format
+ mt.cbFormat = sizeof(VIDEOINFOHEADER2);
+ mt.pbFormat = reinterpret_cast<BYTE*>(&g_defaultVideoInfo);
+
+ new FakePin(this, mt);
}
}
diff --git a/src/3rdparty/phonon/ds9/iodevicereader.cpp b/src/3rdparty/phonon/ds9/iodevicereader.cpp
index d706c82..9152712 100644
--- a/src/3rdparty/phonon/ds9/iodevicereader.cpp
+++ b/src/3rdparty/phonon/ds9/iodevicereader.cpp
@@ -36,20 +36,18 @@ namespace Phonon
//these mediatypes define a stream, its type will be autodetected by DirectShow
static QVector<AM_MEDIA_TYPE> getMediaTypes()
{
- //the order here is important because otherwise,
- //directshow might not be able to detect the stream type correctly
-
- AM_MEDIA_TYPE mt = { MEDIATYPE_Stream, MEDIASUBTYPE_Avi, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0};
+ AM_MEDIA_TYPE mt = { MEDIATYPE_Stream, MEDIASUBTYPE_NULL, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0};
QVector<AM_MEDIA_TYPE> ret;
+ //normal auto-detect stream
+ mt.subtype = MEDIASUBTYPE_NULL;
+ ret << mt;
//AVI stream
+ mt.subtype = MEDIASUBTYPE_Avi;
ret << mt;
//WAVE stream
mt.subtype = MEDIASUBTYPE_WAVE;
ret << mt;
- //normal auto-detect stream (must be at the end!)
- mt.subtype = MEDIASUBTYPE_NULL;
- ret << mt;
return ret;
}
@@ -66,6 +64,7 @@ namespace Phonon
//for Phonon::StreamInterface
void writeData(const QByteArray &data)
{
+ QWriteLocker locker(&m_lock);
m_pos += data.size();
m_buffer += data;
}
@@ -76,22 +75,54 @@ namespace Phonon
void setStreamSize(qint64 newSize)
{
- QMutexLocker locker(&m_mutex);
+ QWriteLocker locker(&m_lock);
m_size = newSize;
}
+ qint64 streamSize() const
+ {
+ QReadLocker locker(&m_lock);
+ return m_size;
+ }
+
void setStreamSeekable(bool s)
{
- QMutexLocker locker(&m_mutex);
+ QWriteLocker locker(&m_lock);
m_seekable = s;
}
+ bool streamSeekable() const
+ {
+ QReadLocker locker(&m_lock);
+ return m_seekable;
+ }
+
+ void setCurrentPos(qint64 pos)
+ {
+ QWriteLocker locker(&m_lock);
+ m_pos = pos;
+ seekStream(pos);
+ m_buffer.clear();
+ }
+
+ qint64 currentPos() const
+ {
+ QReadLocker locker(&m_lock);
+ return m_pos;
+ }
+
+ int currentBufferSize() const
+ {
+ QReadLocker locker(&m_lock);
+ return m_buffer.size();
+ }
+
//virtual pure members
//implementation from IAsyncReader
STDMETHODIMP Length(LONGLONG *total, LONGLONG *available)
{
- QMutexLocker locker(&m_mutex);
+ QReadLocker locker(&m_lock);
if (total) {
*total = m_size;
}
@@ -106,36 +137,37 @@ namespace Phonon
HRESULT read(LONGLONG pos, LONG length, BYTE *buffer, LONG *actual)
{
- Q_ASSERT(!m_mutex.tryLock());
+ QMutexLocker locker(&m_mutexRead);
- if(m_size != 1 && pos + length > m_size) {
+ if(streamSize() != 1 && pos + length > streamSize()) {
//it tries to read outside of the boundaries
return E_FAIL;
}
- if (m_pos - m_buffer.size() != pos) {
- if (!m_seekable) {
+ if (currentPos() - currentBufferSize() != pos) {
+ if (!streamSeekable()) {
return S_FALSE;
}
- m_pos = pos;
- seekStream(pos);
- m_buffer.clear();
+ setCurrentPos(pos);
}
- int oldSize = m_buffer.size();
- while (m_buffer.size() < int(length)) {
+ int oldSize = currentBufferSize();
+ while (currentBufferSize() < int(length)) {
needData();
- if (oldSize == m_buffer.size()) {
+ if (oldSize == currentBufferSize()) {
break; //we didn't get any data
}
- oldSize = m_buffer.size();
+ oldSize = currentBufferSize();
}
- int bytesRead = qMin(m_buffer.size(), int(length));
- qMemCopy(buffer, m_buffer.data(), bytesRead);
- //truncate the buffer
- m_buffer = m_buffer.mid(bytesRead);
+ DWORD bytesRead = qMin(currentBufferSize(), int(length));
+ {
+ QWriteLocker locker(&m_lock);
+ qMemCopy(buffer, m_buffer.data(), bytesRead);
+ //truncate the buffer
+ m_buffer = m_buffer.mid(bytesRead);
+ }
if (actual) {
*actual = bytesRead; //initialization
@@ -151,6 +183,7 @@ namespace Phonon
qint64 m_pos;
qint64 m_size;
+ QMutex m_mutexRead;
const MediaGraph *m_mediaGraph;
};
@@ -164,6 +197,14 @@ namespace Phonon
IODeviceReader::~IODeviceReader()
{
}
+
+ STDMETHODIMP IODeviceReader::Stop()
+ {
+ HRESULT hr = QBaseFilter::Stop();
+ m_streamReader->enoughData(); //this asks to cancel any blocked call to needData
+ return hr;
+ }
+
}
}
diff --git a/src/3rdparty/phonon/ds9/iodevicereader.h b/src/3rdparty/phonon/ds9/iodevicereader.h
index c8b91c3..af4b271 100644
--- a/src/3rdparty/phonon/ds9/iodevicereader.h
+++ b/src/3rdparty/phonon/ds9/iodevicereader.h
@@ -41,6 +41,7 @@ namespace Phonon
public:
IODeviceReader(const MediaSource &source, const MediaGraph *);
~IODeviceReader();
+ STDMETHODIMP Stop();
private:
StreamReader *m_streamReader;
diff --git a/src/3rdparty/phonon/ds9/mediagraph.cpp b/src/3rdparty/phonon/ds9/mediagraph.cpp
index 3e7a68b..db0ec84 100644
--- a/src/3rdparty/phonon/ds9/mediagraph.cpp
+++ b/src/3rdparty/phonon/ds9/mediagraph.cpp
@@ -68,8 +68,6 @@ namespace Phonon
return ret;
}
-
-/*
static HRESULT saveToFile(Graph graph, const QString &filepath)
{
const WCHAR wszStreamName[] = L"ActiveMovieGraph";
@@ -105,7 +103,7 @@ namespace Phonon
return hr;
}
-*/
+
MediaGraph::MediaGraph(MediaObject *mo, short index) :
m_graph(CLSID_FilterGraph, IID_IGraphBuilder),
@@ -379,12 +377,11 @@ namespace Phonon
FILTER_INFO info;
filter->QueryFilterInfo(&info);
#ifdef GRAPH_DEBUG
- qDebug() << "removeFilter" << QString((const QChar *)info.achName);
+ qDebug() << "removeFilter" << QString::fromUtf16(info.achName);
#endif
if (info.pGraph) {
info.pGraph->Release();
- if (info.pGraph == m_graph)
- return m_graph->RemoveFilter(filter);
+ return m_graph->RemoveFilter(filter);
}
//already removed
@@ -540,11 +537,11 @@ namespace Phonon
const QList<OutputPin> outputs = BackendNode::pins(filter, PINDIR_OUTPUT);
for(int i = 0; i < outputs.count(); ++i) {
const OutputPin &pin = outputs.at(i);
- if (HRESULT(VFW_E_NOT_CONNECTED) == pin->ConnectedTo(inPin.pparam())) {
+ if (VFW_E_NOT_CONNECTED == pin->ConnectedTo(inPin.pparam())) {
return SUCCEEDED(pin->Connect(newIn, 0));
}
}
- //we shoud never go here
+ //we should never go here
return false;
} else {
QAMMediaType type;
@@ -682,6 +679,7 @@ namespace Phonon
#ifndef QT_NO_PHONON_MEDIACONTROLLER
} else if (source.discType() == Phonon::Cd) {
m_realSource = Filter(new QAudioCDPlayer);
+ m_result = m_graph->AddFilter(m_realSource, 0);
#endif //QT_NO_PHONON_MEDIACONTROLLER
} else {
@@ -811,7 +809,7 @@ namespace Phonon
for (int i = 0; i < outputs.count(); ++i) {
const OutputPin &out = outputs.at(i);
InputPin pin;
- if (out->ConnectedTo(pin.pparam()) == HRESULT(VFW_E_NOT_CONNECTED)) {
+ if (out->ConnectedTo(pin.pparam()) == VFW_E_NOT_CONNECTED) {
m_decoderPins += out; //unconnected outputs can be decoded outputs
}
}
@@ -822,7 +820,7 @@ namespace Phonon
//let's reestablish the connections
for (int i = 0; i < connections.count(); ++i) {
const GraphConnection &connection = connections.at(i);
- //check if we shoud transfer the sink node
+ //check if we should transfer the sink node
grabFilter(connection.input);
grabFilter(connection.output);
@@ -875,7 +873,7 @@ namespace Phonon
{
FILTER_INFO info;
filter->QueryFilterInfo(&info);
- qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName);
+ qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName);
if (info.pGraph) {
info.pGraph->Release();
}
@@ -921,7 +919,7 @@ namespace Phonon
{
FILTER_INFO info;
filter->QueryFilterInfo(&info);
- qDebug() << "found a decoder filter" << QString((const QChar *)info.achName);
+ qDebug() << "found a decoder filter" << QString::fromUtf16(info.achName);
if (info.pGraph) {
info.pGraph->Release();
}
@@ -937,7 +935,7 @@ namespace Phonon
{
FILTER_INFO info;
filter->QueryFilterInfo(&info);
- qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName);
+ qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName);
if (info.pGraph) {
info.pGraph->Release();
}
@@ -956,7 +954,7 @@ namespace Phonon
{
FILTER_INFO info;
filter->QueryFilterInfo(&info);
- qDebug() << Q_FUNC_INFO << QString((const QChar *)info.achName);
+ qDebug() << Q_FUNC_INFO << QString::fromUtf16(info.achName);
if (info.pGraph) {
info.pGraph->Release();
}
@@ -990,7 +988,7 @@ namespace Phonon
{
FILTER_INFO info;
filter->QueryFilterInfo(&info);
- qDebug() << "found a demuxer filter" << QString((const QChar *)info.achName);
+ qDebug() << "found a demuxer filter" << QString::fromUtf16(info.achName);
if (info.pGraph) {
info.pGraph->Release();
}
@@ -1008,27 +1006,27 @@ namespace Phonon
BSTR str;
HRESULT hr = mediaContent->get_AuthorName(&str);
if (SUCCEEDED(hr)) {
- ret.insert(QLatin1String("ARTIST"), QString::fromWCharArray(str));
+ ret.insert(QLatin1String("ARTIST"), QString::fromUtf16((const unsigned short*)str));
SysFreeString(str);
}
hr = mediaContent->get_Title(&str);
if (SUCCEEDED(hr)) {
- ret.insert(QLatin1String("TITLE"), QString::fromWCharArray(str));
+ ret.insert(QLatin1String("TITLE"), QString::fromUtf16((const unsigned short*)str));
SysFreeString(str);
}
hr = mediaContent->get_Description(&str);
if (SUCCEEDED(hr)) {
- ret.insert(QLatin1String("DESCRIPTION"), QString::fromWCharArray(str));
+ ret.insert(QLatin1String("DESCRIPTION"), QString::fromUtf16((const unsigned short*)str));
SysFreeString(str);
}
hr = mediaContent->get_Copyright(&str);
if (SUCCEEDED(hr)) {
- ret.insert(QLatin1String("COPYRIGHT"), QString::fromWCharArray(str));
+ ret.insert(QLatin1String("COPYRIGHT"), QString::fromUtf16((const unsigned short*)str));
SysFreeString(str);
}
hr = mediaContent->get_MoreInfoText(&str);
if (SUCCEEDED(hr)) {
- ret.insert(QLatin1String("MOREINFO"), QString::fromWCharArray(str));
+ ret.insert(QLatin1String("MOREINFO"), QString::fromUtf16((const unsigned short*)str));
SysFreeString(str);
}
}
diff --git a/src/3rdparty/phonon/ds9/mediaobject.cpp b/src/3rdparty/phonon/ds9/mediaobject.cpp
index 34f92c2..d1e15c0 100644
--- a/src/3rdparty/phonon/ds9/mediaobject.cpp
+++ b/src/3rdparty/phonon/ds9/mediaobject.cpp
@@ -23,10 +23,11 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#ifndef Q_CC_MSVC
#include <dshow.h>
-#endif
+#endif //Q_CC_MSVC
#include <objbase.h>
#include <initguid.h>
#include <qnetwork.h>
+#include <comdef.h>
#include <evcode.h>
#include "mediaobject.h"
@@ -49,7 +50,7 @@ namespace Phonon
//first the definition of the WorkerThread class
WorkerThread::WorkerThread()
- : QThread(), m_finished(false), m_currentWorkId(1)
+ : QThread(), m_currentRenderId(0), m_finished(false), m_currentWorkId(1)
{
}
@@ -57,6 +58,24 @@ namespace Phonon
{
}
+ WorkerThread::Work WorkerThread::dequeueWork()
+ {
+ QMutexLocker locker(&m_mutex);
+ if (m_finished) {
+ return Work();
+ }
+ Work ret = m_queue.dequeue();
+
+ //we ensure to have the wait condition in the right state
+ if (m_queue.isEmpty()) {
+ m_waitCondition.reset();
+ } else {
+ m_waitCondition.set();
+ }
+
+ return ret;
+ }
+
void WorkerThread::run()
{
while (m_finished == false) {
@@ -70,6 +89,11 @@ namespace Phonon
}
DWORD result = ::WaitForMultipleObjects(count, handles, FALSE, INFINITE);
if (result == WAIT_OBJECT_0) {
+ if (m_finished) {
+ //that's the end of the thread execution
+ return;
+ }
+
handleTask();
} else {
//this is the event management
@@ -157,7 +181,6 @@ namespace Phonon
//we create a new graph
w.graph = Graph(CLSID_FilterGraph, IID_IGraphBuilder);
w.filter = filter;
- w.graph->AddFilter(filter, 0);
w.id = m_currentWorkId++;
m_queue.enqueue(w);
m_waitCondition.set();
@@ -177,29 +200,23 @@ namespace Phonon
void WorkerThread::handleTask()
{
- QMutexLocker locker(Backend::directShowMutex);
- {
- QMutexLocker locker(&m_mutex);
- if (m_finished || m_queue.isEmpty()) {
- return;
- }
-
- m_currentWork = m_queue.dequeue();
+ const Work w = dequeueWork();
- //we ensure to have the wait condition in the right state
- if (m_queue.isEmpty()) {
- m_waitCondition.reset();
- } else {
- m_waitCondition.set();
- }
+ if (m_finished) {
+ return;
}
HRESULT hr = S_OK;
- if (m_currentWork.task == ReplaceGraph) {
+ m_currentRender = w.graph;
+ m_currentRenderId = w.id;
+ if (w.task == ReplaceGraph) {
+ QMutexLocker locker(&m_mutex);
+ HANDLE h;
+
int index = -1;
for(int i = 0; i < FILTER_COUNT; ++i) {
- if (m_graphHandle[i].graph == m_currentWork.oldGraph) {
+ if (m_graphHandle[i].graph == w.oldGraph) {
m_graphHandle[i].graph = Graph();
index = i;
break;
@@ -212,40 +229,51 @@ namespace Phonon
Q_ASSERT(index != -1);
//add the new graph
- HANDLE h;
- if (SUCCEEDED(ComPointer<IMediaEvent>(m_currentWork.graph, IID_IMediaEvent)
+ if (SUCCEEDED(ComPointer<IMediaEvent>(w.graph, IID_IMediaEvent)
->GetEventHandle(reinterpret_cast<OAEVENT*>(&h)))) {
- m_graphHandle[index].graph = m_currentWork.graph;
+ m_graphHandle[index].graph = w.graph;
m_graphHandle[index].handle = h;
}
- } else if (m_currentWork.task == Render) {
- if (m_currentWork.filter) {
+ } else if (w.task == Render) {
+ if (w.filter) {
//let's render pins
- const QList<OutputPin> outputs = BackendNode::pins(m_currentWork.filter, PINDIR_OUTPUT);
- for (int i = 0; SUCCEEDED(hr) && i < outputs.count(); ++i) {
- hr = m_currentWork.graph->Render(outputs.at(i));
+ w.graph->AddFilter(w.filter, 0);
+ const QList<OutputPin> outputs = BackendNode::pins(w.filter, PINDIR_OUTPUT);
+ for (int i = 0; i < outputs.count(); ++i) {
+ //blocking call
+ hr = w.graph->Render(outputs.at(i));
+ if (FAILED(hr)) {
+ break;
+ }
}
- } else if (!m_currentWork.url.isEmpty()) {
+ } else if (!w.url.isEmpty()) {
//let's render a url (blocking call)
- hr = m_currentWork.graph->RenderFile(reinterpret_cast<const wchar_t *>(m_currentWork.url.utf16()), 0);
+ hr = w.graph->RenderFile(reinterpret_cast<const wchar_t *>(w.url.utf16()), 0);
}
if (hr != E_ABORT) {
- emit asyncRenderFinished(m_currentWork.id, hr, m_currentWork.graph);
+ emit asyncRenderFinished(w.id, hr, w.graph);
}
- } else if (m_currentWork.task == Seek) {
+ } else if (w.task == Seek) {
//that's a seekrequest
- ComPointer<IMediaSeeking> mediaSeeking(m_currentWork.graph, IID_IMediaSeeking);
- qint64 newtime = m_currentWork.time * 10000;
+ ComPointer<IMediaSeeking> mediaSeeking(w.graph, IID_IMediaSeeking);
+ qint64 newtime = w.time * 10000;
hr = mediaSeeking->SetPositions(&newtime, AM_SEEKING_AbsolutePositioning,
0, AM_SEEKING_NoPositioning);
- emit asyncSeekingFinished(m_currentWork.id, newtime / 10000);
+ qint64 currentTime = -1;
+ if (SUCCEEDED(hr)) {
+ hr = mediaSeeking->GetCurrentPosition(&currentTime);
+ if (SUCCEEDED(hr)) {
+ currentTime /= 10000; //convert to ms
+ }
+ }
+ emit asyncSeekingFinished(w.id, currentTime);
hr = E_ABORT; //to avoid emitting asyncRenderFinished
- } else if (m_currentWork.task == ChangeState) {
+ } else if (w.task == ChangeState) {
//remove useless decoders
QList<Filter> unused;
- for (int i = 0; i < m_currentWork.decoders.count(); ++i) {
- const Filter &filter = m_currentWork.decoders.at(i);
+ for (int i = 0; i < w.decoders.count(); ++i) {
+ const Filter &filter = w.decoders.at(i);
bool used = false;
const QList<OutputPin> pins = BackendNode::pins(filter, PINDIR_OUTPUT);
for( int i = 0; i < pins.count(); ++i) {
@@ -262,15 +290,15 @@ namespace Phonon
//we can get the state
for (int i = 0; i < unused.count(); ++i) {
//we should remove this filter from the graph
- m_currentWork.graph->RemoveFilter(unused.at(i));
+ w.graph->RemoveFilter(unused.at(i));
}
//we can get the state
- ComPointer<IMediaControl> mc(m_currentWork.graph, IID_IMediaControl);
+ ComPointer<IMediaControl> mc(w.graph, IID_IMediaControl);
//we change the state here
- switch(m_currentWork.state)
+ switch(w.state)
{
case State_Stopped:
mc->Stop();
@@ -288,38 +316,36 @@ namespace Phonon
if (SUCCEEDED(hr)) {
if (s == State_Stopped) {
- emit stateReady(m_currentWork.graph, Phonon::StoppedState);
+ emit stateReady(w.graph, Phonon::StoppedState);
} else if (s == State_Paused) {
- emit stateReady(m_currentWork.graph, Phonon::PausedState);
+ emit stateReady(w.graph, Phonon::PausedState);
} else /*if (s == State_Running)*/ {
- emit stateReady(m_currentWork.graph, Phonon::PlayingState);
+ emit stateReady(w.graph, Phonon::PlayingState);
}
}
}
- {
- QMutexLocker locker(&m_mutex);
- m_currentWork = Work(); //reinitialize
- }
+ m_currentRender = Graph();
+ m_currentRenderId = 0;
+
}
- void WorkerThread::abortCurrentRender(qint16 renderId)
- {
+ void WorkerThread::abortCurrentRender(qint16 renderId)
+ {
QMutexLocker locker(&m_mutex);
- if (m_currentWork.id == renderId) {
- m_currentWork.graph->Abort();
- }
bool found = false;
+ //we try to see if there is already an attempt to seek and we remove it
for(int i = 0; !found && i < m_queue.size(); ++i) {
const Work &w = m_queue.at(i);
if (w.id == renderId) {
found = true;
m_queue.removeAt(i);
- if (m_queue.isEmpty()) {
- m_waitCondition.reset();
- }
}
}
+
+ if (m_currentRender && m_currentRenderId == renderId) {
+ m_currentRender->Abort();
+ }
}
//tells the thread to stop processing
@@ -327,9 +353,9 @@ namespace Phonon
{
QMutexLocker locker(&m_mutex);
m_queue.clear();
- if (m_currentWork.graph) {
+ if (m_currentRender) {
//in case we're currently rendering something
- m_currentWork.graph->Abort();
+ m_currentRender->Abort();
}
@@ -361,17 +387,17 @@ namespace Phonon
m_graphs[i] = new MediaGraph(this, i);
}
- connect(&m_thread, SIGNAL(stateReady(Graph,Phonon::State)),
- SLOT(slotStateReady(Graph,Phonon::State)));
+ connect(&m_thread, SIGNAL(stateReady(Graph, Phonon::State)),
+ SLOT(slotStateReady(Graph, Phonon::State)));
- connect(&m_thread, SIGNAL(eventReady(Graph,long,long)),
- SLOT(handleEvents(Graph,long,long)));
+ connect(&m_thread, SIGNAL(eventReady(Graph, long, long)),
+ SLOT(handleEvents(Graph, long, long)));
- connect(&m_thread, SIGNAL(asyncRenderFinished(quint16,HRESULT,Graph)),
- SLOT(finishLoading(quint16,HRESULT,Graph)));
+ connect(&m_thread, SIGNAL(asyncRenderFinished(quint16, HRESULT, Graph)),
+ SLOT(finishLoading(quint16, HRESULT, Graph)));
- connect(&m_thread, SIGNAL(asyncSeekingFinished(quint16,qint64)),
- SLOT(finishSeeking(quint16,qint64)));
+ connect(&m_thread, SIGNAL(asyncSeekingFinished(quint16, qint64)),
+ SLOT(finishSeeking(quint16, qint64)));
//really special case
m_mediaObject = this;
m_thread.start();
@@ -494,18 +520,6 @@ namespace Phonon
qSwap(m_graphs[0], m_graphs[1]); //swap the graphs
- if (m_transitionTime >= 0)
- m_graphs[1]->stop(); //make sure we stop the previous graph
-
- if (currentGraph()->mediaSource().type() != Phonon::MediaSource::Invalid &&
- catchComError(currentGraph()->renderResult())) {
- setState(Phonon::ErrorState);
- return;
- }
-
- //we need to play the next media
- play();
-
//we tell the video widgets to switch now to the new source
#ifndef QT_NO_PHONON_VIDEO
for (int i = 0; i < m_videoWidgets.count(); ++i) {
@@ -514,6 +528,15 @@ namespace Phonon
#endif //QT_NO_PHONON_VIDEO
emit currentSourceChanged(currentGraph()->mediaSource());
+
+ if (currentGraph()->isLoading()) {
+ //will simply tell that when loading is finished
+ //it should start the playback
+ play();
+ }
+
+
+
emit metaDataChanged(currentGraph()->metadata());
if (nextGraph()->hasVideo() != currentGraph()->hasVideo()) {
@@ -526,6 +549,15 @@ namespace Phonon
#ifndef QT_NO_PHONON_MEDIACONTROLLER
setTitles(currentGraph()->titles());
#endif //QT_NO_PHONON_MEDIACONTROLLER
+
+ //this manages only gapless transitions
+ if (currentGraph()->mediaSource().type() != Phonon::MediaSource::Invalid) {
+ if (catchComError(currentGraph()->renderResult())) {
+ setState(Phonon::ErrorState);
+ } else {
+ play();
+ }
+ }
}
Phonon::State MediaObject::state() const
@@ -760,16 +792,15 @@ namespace Phonon
case Phonon::PausedState:
pause();
break;
+ case Phonon::StoppedState:
+ stop();
+ break;
case Phonon::PlayingState:
play();
break;
case Phonon::ErrorState:
setState(Phonon::ErrorState);
break;
- case Phonon::StoppedState:
- default:
- stop();
- break;
}
}
}
@@ -817,11 +848,11 @@ namespace Phonon
#endif
LPAMGETERRORTEXT getErrorText = (LPAMGETERRORTEXT)QLibrary::resolve(QLatin1String("quartz"), "AMGetErrorTextW");
- WCHAR buffer[MAX_ERROR_TEXT_LEN];
- if (getErrorText && getErrorText(hr, buffer, MAX_ERROR_TEXT_LEN)) {
- m_errorString = QString::fromWCharArray(buffer);
+ ushort buffer[MAX_ERROR_TEXT_LEN];
+ if (getErrorText && getErrorText(hr, (WCHAR*)buffer, MAX_ERROR_TEXT_LEN)) {
+ m_errorString = QString::fromUtf16(buffer);
} else {
- m_errorString = QString::fromLatin1("Unknown error");
+ m_errorString = QString::fromUtf16((ushort*)_com_error(hr).ErrorMessage());
}
const QString comError = QString::number(uint(hr), 16);
if (!m_errorString.toLower().contains(comError.toLower())) {
diff --git a/src/3rdparty/phonon/ds9/mediaobject.h b/src/3rdparty/phonon/ds9/mediaobject.h
index 34aa666..2c34ffc 100644
--- a/src/3rdparty/phonon/ds9/mediaobject.h
+++ b/src/3rdparty/phonon/ds9/mediaobject.h
@@ -114,7 +114,6 @@ namespace Phonon
enum Task
{
- None,
Render,
Seek,
ChangeState,
@@ -123,7 +122,6 @@ namespace Phonon
struct Work
{
- Work() : task(None), id(0), time(0) { }
Task task;
quint16 id;
Graph graph;
@@ -137,14 +135,16 @@ namespace Phonon
};
QList<Filter> decoders; //for the state change requests
};
+ Work dequeueWork();
void handleTask();
- Work m_currentWork;
+ Graph m_currentRender;
+ qint16 m_currentRenderId;
QQueue<Work> m_queue;
bool m_finished;
quint16 m_currentWorkId;
QWinWaitCondition m_waitCondition;
- QMutex m_mutex; // mutex for the m_queue, m_finished and m_currentWorkId
+ QMutex m_mutex;
//this is for WaitForMultipleObjects
struct
diff --git a/src/3rdparty/phonon/ds9/qasyncreader.cpp b/src/3rdparty/phonon/ds9/qasyncreader.cpp
index a3f9cda..68ec1f8 100644
--- a/src/3rdparty/phonon/ds9/qasyncreader.cpp
+++ b/src/3rdparty/phonon/ds9/qasyncreader.cpp
@@ -15,6 +15,8 @@ You should have received a copy of the GNU Lesser General Public License
along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <QtCore/QFile>
+
#include "qasyncreader.h"
#include "qbasefilter.h"
@@ -78,7 +80,8 @@ namespace Phonon
STDMETHODIMP QAsyncReader::Request(IMediaSample *sample,DWORD_PTR user)
{
- QMutexLocker locker(&m_mutex);
+ QMutexLocker mutexLocker(&m_mutexWait);
+ QWriteLocker locker(&m_lock);
if (m_flushing) {
return VFW_E_WRONG_STATE;
}
@@ -90,28 +93,33 @@ namespace Phonon
STDMETHODIMP QAsyncReader::WaitForNext(DWORD timeout, IMediaSample **sample, DWORD_PTR *user)
{
- QMutexLocker locker(&m_mutex);
+ QMutexLocker locker(&m_mutexWait);
if (!sample ||!user) {
return E_POINTER;
}
- //msdn says to return immediately if we're flushing but that doesn't seem to be true
- //since it triggers a dead-lock somewhere inside directshow (see task 258830)
-
*sample = 0;
*user = 0;
- if (m_requestQueue.isEmpty()) {
- if (m_requestWait.wait(&m_mutex, timeout) == false) {
- return VFW_E_TIMEOUT;
- }
- if (m_requestQueue.isEmpty()) {
+ AsyncRequest r = getNextRequest();
+
+ if (r.sample == 0) {
+ //there is no request in the queue
+ if (isFlushing()) {
return VFW_E_WRONG_STATE;
+ } else {
+ //First we need to lock the mutex
+ if (m_requestWait.wait(&m_mutexWait, timeout) == false) {
+ return VFW_E_TIMEOUT;
+ }
+ if (isFlushing()) {
+ return VFW_E_WRONG_STATE;
+ }
+
+ r = getNextRequest();
}
}
- AsyncRequest r = m_requestQueue.dequeue();
-
//at this point we're sure to have a request to proceed
if (r.sample == 0) {
return E_FAIL;
@@ -119,12 +127,14 @@ namespace Phonon
*sample = r.sample;
*user = r.user;
- return syncReadAlignedUnlocked(r.sample);
+
+ return SyncReadAligned(r.sample);
}
STDMETHODIMP QAsyncReader::BeginFlush()
{
- QMutexLocker locker(&m_mutex);
+ QMutexLocker mutexLocker(&m_mutexWait);
+ QWriteLocker locker(&m_lock);
m_flushing = true;
m_requestWait.wakeOne();
return S_OK;
@@ -132,28 +142,13 @@ namespace Phonon
STDMETHODIMP QAsyncReader::EndFlush()
{
- QMutexLocker locker(&m_mutex);
+ QWriteLocker locker(&m_lock);
m_flushing = false;
return S_OK;
}
STDMETHODIMP QAsyncReader::SyncReadAligned(IMediaSample *sample)
{
- QMutexLocker locker(&m_mutex);
- return syncReadAlignedUnlocked(sample);
- }
-
- STDMETHODIMP QAsyncReader::SyncRead(LONGLONG pos, LONG length, BYTE *buffer)
- {
- QMutexLocker locker(&m_mutex);
- return read(pos, length, buffer, 0);
- }
-
-
- STDMETHODIMP QAsyncReader::syncReadAlignedUnlocked(IMediaSample *sample)
- {
- Q_ASSERT(!m_mutex.tryLock());
-
if (!sample) {
return E_POINTER;
}
@@ -180,6 +175,23 @@ namespace Phonon
return sample->SetActualDataLength(actual);
}
+ STDMETHODIMP QAsyncReader::SyncRead(LONGLONG pos, LONG length, BYTE *buffer)
+ {
+ return read(pos, length, buffer, 0);
+ }
+
+
+ //addition
+ QAsyncReader::AsyncRequest QAsyncReader::getNextRequest()
+ {
+ QWriteLocker locker(&m_lock);
+ AsyncRequest ret;
+ if (!m_requestQueue.isEmpty()) {
+ ret = m_requestQueue.dequeue();
+ }
+
+ return ret;
+ }
}
}
diff --git a/src/3rdparty/phonon/ds9/qasyncreader.h b/src/3rdparty/phonon/ds9/qasyncreader.h
index 95872f9..cb789ee 100644
--- a/src/3rdparty/phonon/ds9/qasyncreader.h
+++ b/src/3rdparty/phonon/ds9/qasyncreader.h
@@ -48,12 +48,11 @@ namespace Phonon
STDMETHODIMP WaitForNext(DWORD,IMediaSample **,DWORD_PTR *);
STDMETHODIMP SyncReadAligned(IMediaSample *);
STDMETHODIMP SyncRead(LONGLONG,LONG,BYTE *);
- STDMETHODIMP Length(LONGLONG *,LONGLONG *) = 0;
+ virtual STDMETHODIMP Length(LONGLONG *,LONGLONG *) = 0;
STDMETHODIMP BeginFlush();
STDMETHODIMP EndFlush();
protected:
- STDMETHODIMP syncReadAlignedUnlocked(IMediaSample *);
virtual HRESULT read(LONGLONG pos, LONG length, BYTE *buffer, LONG *actual) = 0;
private:
@@ -63,6 +62,9 @@ namespace Phonon
IMediaSample *sample;
DWORD_PTR user;
};
+ AsyncRequest getNextRequest();
+
+ QMutex m_mutexWait;
QQueue<AsyncRequest> m_requestQueue;
QWaitCondition m_requestWait;
diff --git a/src/3rdparty/phonon/ds9/qaudiocdreader.cpp b/src/3rdparty/phonon/ds9/qaudiocdreader.cpp
index 6d0f335..b9f9fd6 100644
--- a/src/3rdparty/phonon/ds9/qaudiocdreader.cpp
+++ b/src/3rdparty/phonon/ds9/qaudiocdreader.cpp
@@ -103,8 +103,8 @@ namespace Phonon
private:
HANDLE m_cddrive;
- CDROM_TOC m_toc;
- WaveStructure m_waveHeader;
+ CDROM_TOC *m_toc;
+ WaveStructure *m_waveHeader;
qint64 m_trackAddress;
};
@@ -112,8 +112,19 @@ namespace Phonon
#define SECTOR_SIZE 2352
#define NB_SECTORS_READ 20
- static const AM_MEDIA_TYPE audioCDMediaType = { MEDIATYPE_Stream, MEDIASUBTYPE_WAVE, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0};
-
+ static AM_MEDIA_TYPE getAudioCDMediaType()
+ {
+ AM_MEDIA_TYPE mt;
+ qMemSet(&mt, 0, sizeof(AM_MEDIA_TYPE));
+ mt.majortype = MEDIATYPE_Stream;
+ mt.subtype = MEDIASUBTYPE_WAVE;
+ mt.bFixedSizeSamples = TRUE;
+ mt.bTemporalCompression = FALSE;
+ mt.lSampleSize = 1;
+ mt.formattype = GUID_NULL;
+ return mt;
+ }
+
int addressToSectors(UCHAR address[4])
{
return ((address[0] * 60 + address[1]) * 60 + address[2]) * 75 + address[3] - 150;
@@ -130,8 +141,11 @@ namespace Phonon
}
- QAudioCDReader::QAudioCDReader(QBaseFilter *parent, QChar drive) : QAsyncReader(parent, QVector<AM_MEDIA_TYPE>() << audioCDMediaType)
+ QAudioCDReader::QAudioCDReader(QBaseFilter *parent, QChar drive) : QAsyncReader(parent, QVector<AM_MEDIA_TYPE>() << getAudioCDMediaType())
{
+ m_toc = new CDROM_TOC;
+ m_waveHeader = new WaveStructure;
+
//now open the cd-drive
QString path;
if (drive.isNull()) {
@@ -140,30 +154,36 @@ namespace Phonon
path = QString::fromLatin1("\\\\.\\%1:").arg(drive);
}
- m_cddrive = ::CreateFile((const wchar_t *)path.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
+ m_cddrive = QT_WA_INLINE (
+ ::CreateFile( (TCHAR*)path.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL ),
+ ::CreateFileA( path.toLocal8Bit().constData(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL )
+ );
- qMemSet(&m_toc, 0, sizeof(CDROM_TOC));
+ qMemSet(m_toc, 0, sizeof(CDROM_TOC));
//read the TOC
DWORD bytesRead = 0;
- bool tocRead = ::DeviceIoControl(m_cddrive, IOCTL_CDROM_READ_TOC, 0, 0, &m_toc, sizeof(CDROM_TOC), &bytesRead, 0);
+ bool tocRead = ::DeviceIoControl(m_cddrive, IOCTL_CDROM_READ_TOC, 0, 0, m_toc, sizeof(CDROM_TOC), &bytesRead, 0);
if (!tocRead) {
qWarning("unable to load the TOC from the CD");
return;
}
- m_trackAddress = addressToSectors(m_toc.TrackData[0].Address);
- const qint32 nbSectorsToRead = (addressToSectors(m_toc.TrackData[m_toc.LastTrack + 1 - m_toc.FirstTrack].Address)
+ m_trackAddress = addressToSectors(m_toc->TrackData[0].Address);
+ const qint32 nbSectorsToRead = (addressToSectors(m_toc->TrackData[m_toc->LastTrack + 1 - m_toc->FirstTrack].Address)
- m_trackAddress);
const qint32 dataLength = nbSectorsToRead * SECTOR_SIZE;
- m_waveHeader.chunksize = 4 + (8 + m_waveHeader.chunksize2) + (8 + dataLength);
- m_waveHeader.dataLength = dataLength;
+ m_waveHeader->chunksize = 4 + (8 + m_waveHeader->chunksize2) + (8 + dataLength);
+ m_waveHeader->dataLength = dataLength;
}
QAudioCDReader::~QAudioCDReader()
{
::CloseHandle(m_cddrive);
+ delete m_toc;
+ delete m_waveHeader;
+
}
STDMETHODIMP_(ULONG) QAudioCDReader::AddRef()
@@ -179,7 +199,7 @@ namespace Phonon
STDMETHODIMP QAudioCDReader::Length(LONGLONG *total,LONGLONG *available)
{
- const LONGLONG length = sizeof(WaveStructure) + m_waveHeader.dataLength;
+ const LONGLONG length = sizeof(WaveStructure) + m_waveHeader->dataLength;
if (total) {
*total = length;
}
@@ -218,11 +238,11 @@ namespace Phonon
if (pos < sizeof(WaveStructure)) {
//we first copy the content of the structure
nbRead = qMin(LONG(sizeof(WaveStructure) - pos), length);
- qMemCopy(buffer, reinterpret_cast<char*>(&m_waveHeader) + pos, nbRead);
+ qMemCopy(buffer, reinterpret_cast<char*>(m_waveHeader) + pos, nbRead);
}
const LONGLONG posInTrack = pos - sizeof(WaveStructure) + nbRead;
- const int bytesLeft = qMin(m_waveHeader.dataLength - posInTrack, LONGLONG(length - nbRead));
+ const int bytesLeft = qMin(m_waveHeader->dataLength - posInTrack, LONGLONG(length - nbRead));
if (bytesLeft > 0) {
@@ -277,8 +297,8 @@ namespace Phonon
{
QList<qint64> ret;
ret << 0;
- for(int i = m_toc.FirstTrack; i <= m_toc.LastTrack ; ++i) {
- const uchar *address = m_toc.TrackData[i].Address;
+ for(int i = m_toc->FirstTrack; i <= m_toc->LastTrack ; ++i) {
+ const uchar *address = m_toc->TrackData[i].Address;
ret << ((address[0] * 60 + address[1]) * 60 + address[2]) * 1000 + address[3]*1000/75 - 2000;
}
diff --git a/src/3rdparty/phonon/ds9/qaudiocdreader.h b/src/3rdparty/phonon/ds9/qaudiocdreader.h
index eff845d..9049b66 100644
--- a/src/3rdparty/phonon/ds9/qaudiocdreader.h
+++ b/src/3rdparty/phonon/ds9/qaudiocdreader.h
@@ -31,7 +31,7 @@ namespace Phonon
{
struct CDROM_TOC;
struct WaveStructure;
- EXTERN_C const IID IID_ITitleInterface;
+ extern const IID IID_ITitleInterface;
//interface for the Titles
struct ITitleInterface : public IUnknown
diff --git a/src/3rdparty/phonon/ds9/qbasefilter.cpp b/src/3rdparty/phonon/ds9/qbasefilter.cpp
index 78b8b8f..95cab92 100644
--- a/src/3rdparty/phonon/ds9/qbasefilter.cpp
+++ b/src/3rdparty/phonon/ds9/qbasefilter.cpp
@@ -92,8 +92,8 @@ namespace Phonon
return E_POINTER;
}
- uint nbfetched = 0;
- while (nbfetched < count && m_index < m_pins.count()) {
+ int nbfetched = 0;
+ while (nbfetched < int(count) && m_index < m_pins.count()) {
IPin *current = m_pins[m_index];
current->AddRef();
ret[nbfetched] = current;
@@ -166,19 +166,19 @@ namespace Phonon
const QList<QPin *> QBaseFilter::pins() const
{
- QMutexLocker locker(&m_mutex);
+ QReadLocker locker(&m_lock);
return m_pins;
}
void QBaseFilter::addPin(QPin *pin)
{
- QMutexLocker locker(&m_mutex);
+ QWriteLocker locker(&m_lock);
m_pins.append(pin);
}
void QBaseFilter::removePin(QPin *pin)
{
- QMutexLocker locker(&m_mutex);
+ QWriteLocker locker(&m_lock);
m_pins.removeAll(pin);
}
@@ -211,8 +211,7 @@ namespace Phonon
}
else if (iid == IID_IMediaPosition || iid == IID_IMediaSeeking) {
if (inputPins().isEmpty()) {
- *out = getUpStreamInterface(iid);
- if (*out) {
+ if (*out = getUpStreamInterface(iid)) {
return S_OK; //we return here to avoid adding a reference
} else {
hr = E_NOINTERFACE;
@@ -251,35 +250,35 @@ namespace Phonon
STDMETHODIMP QBaseFilter::GetClassID(CLSID *clsid)
{
- QMutexLocker locker(&m_mutex);
+ QReadLocker locker(&m_lock);
*clsid = m_clsid;
return S_OK;
}
STDMETHODIMP QBaseFilter::Stop()
{
- QMutexLocker locker(&m_mutex);
+ QWriteLocker locker(&m_lock);
m_state = State_Stopped;
return S_OK;
}
STDMETHODIMP QBaseFilter::Pause()
{
- QMutexLocker locker(&m_mutex);
+ QWriteLocker locker(&m_lock);
m_state = State_Paused;
return S_OK;
}
STDMETHODIMP QBaseFilter::Run(REFERENCE_TIME)
{
- QMutexLocker locker(&m_mutex);
+ QWriteLocker locker(&m_lock);
m_state = State_Running;
return S_OK;
}
STDMETHODIMP QBaseFilter::GetState(DWORD, FILTER_STATE *state)
{
- QMutexLocker locker(&m_mutex);
+ QReadLocker locker(&m_lock);
if (!state) {
return E_POINTER;
}
@@ -290,7 +289,7 @@ namespace Phonon
STDMETHODIMP QBaseFilter::SetSyncSource(IReferenceClock *clock)
{
- QMutexLocker locker(&m_mutex);
+ QWriteLocker locker(&m_lock);
if (clock) {
clock->AddRef();
}
@@ -303,7 +302,7 @@ namespace Phonon
STDMETHODIMP QBaseFilter::GetSyncSource(IReferenceClock **clock)
{
- QMutexLocker locker(&m_mutex);
+ QReadLocker locker(&m_lock);
if (!clock) {
return E_POINTER;
}
@@ -342,7 +341,7 @@ namespace Phonon
STDMETHODIMP QBaseFilter::QueryFilterInfo(FILTER_INFO *info )
{
- QMutexLocker locker(&m_mutex);
+ QReadLocker locker(&m_lock);
if (!info) {
return E_POINTER;
}
@@ -356,9 +355,9 @@ namespace Phonon
STDMETHODIMP QBaseFilter::JoinFilterGraph(IFilterGraph *graph, LPCWSTR name)
{
- QMutexLocker locker(&m_mutex);
+ QWriteLocker locker(&m_lock);
m_graph = graph;
- m_name = QString::fromWCharArray(name);
+ m_name = QString::fromUtf16((const unsigned short*)name);
return S_OK;
}
diff --git a/src/3rdparty/phonon/ds9/qbasefilter.h b/src/3rdparty/phonon/ds9/qbasefilter.h
index a72d6fe..85f1431 100644
--- a/src/3rdparty/phonon/ds9/qbasefilter.h
+++ b/src/3rdparty/phonon/ds9/qbasefilter.h
@@ -22,7 +22,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#include <QtCore/QString>
#include <QtCore/QList>
-#include <QtCore/QMutex>
+#include <QtCore/QReadWriteLock>
#include <dshow.h>
@@ -127,7 +127,7 @@ namespace Phonon
IFilterGraph *m_graph;
FILTER_STATE m_state;
QList<QPin *> m_pins;
- mutable QMutex m_mutex;
+ mutable QReadWriteLock m_lock;
};
}
}
diff --git a/src/3rdparty/phonon/ds9/qevr9.h b/src/3rdparty/phonon/ds9/qevr9.h
deleted file mode 100644
index 8599fce..0000000
--- a/src/3rdparty/phonon/ds9/qevr9.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/* This file is part of the KDE project.
-
-Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-
-This library is free software: you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation, either version 2.1 or 3 of the License.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <d3d9.h>
-
-#define DXVA2_ProcAmp_Brightness 1
-#define DXVA2_ProcAmp_Contrast 2
-#define DXVA2_ProcAmp_Hue 4
-#define DXVA2_ProcAmp_Saturation 8
-
-typedef enum {
- MFVideoARMode_None = 0x00000000,
- MFVideoARMode_PreservePicture = 0x00000001,
- MFVideoARMode_PreservePixel = 0x00000002,
- MFVideoARMode_NonLinearStretch = 0x00000004,
- MFVideoARMode_Mask = 0x00000007
-} MFVideoAspectRatioMode;
-
-typedef struct {
- float left;
- float top;
- float right;
- float bottom;
-} MFVideoNormalizedRect;
-
-typedef struct {
- UINT DeviceCaps;
- D3DPOOL InputPool;
- UINT NumForwardRefSamples;
- UINT NumBackwardRefSamples;
- UINT Reserved;
- UINT DeinterlaceTechnology;
- UINT ProcAmpControlCaps;
- UINT VideoProcessorOperations;
- UINT NoiseFilterTechnology;
- UINT DetailFilterTechnology;
-} DXVA2_VideoProcessorCaps;
-
-typedef struct {
- union {
- struct {
- USHORT Fraction;
- SHORT Value;
- };
- LONG ll;
- };
-} DXVA2_Fixed32;
-
-typedef struct {
- DXVA2_Fixed32 MinValue;
- DXVA2_Fixed32 MaxValue;
- DXVA2_Fixed32 DefaultValue;
- DXVA2_Fixed32 StepSize;
-} DXVA2_ValueRange;
-
-typedef struct {
- DXVA2_Fixed32 Brightness;
- DXVA2_Fixed32 Contrast;
- DXVA2_Fixed32 Hue;
- DXVA2_Fixed32 Saturation;
-} DXVA2_ProcAmpValues;
-
-DXVA2_Fixed32 DXVA2FloatToFixed(const float _float_)
-{
- DXVA2_Fixed32 _fixed_;
- _fixed_.Fraction = LOWORD(_float_ * 0x10000);
- _fixed_.Value = HIWORD(_float_ * 0x10000);
- return _fixed_;
-}
-
-float DXVA2FixedToFloat(const DXVA2_Fixed32 _fixed_)
-{
- return (FLOAT)_fixed_.Value + (FLOAT)_fixed_.Fraction / 0x10000;
-}
-
-#undef INTERFACE
-#define INTERFACE IMFVideoDisplayControl
-DECLARE_INTERFACE_(IMFVideoDisplayControl, IUnknown)
-{
- STDMETHOD(GetNativeVideoSize)(THIS_ SIZE* pszVideo, SIZE* pszARVideo) PURE;
- STDMETHOD(GetIdealVideoSize)(THIS_ SIZE* pszMin, SIZE* pszMax) PURE;
- STDMETHOD(SetVideoPosition)(THIS_ const MFVideoNormalizedRect* pnrcSource, const LPRECT prcDest) PURE;
- STDMETHOD(GetVideoPosition)(THIS_ MFVideoNormalizedRect* pnrcSource, LPRECT prcDest) PURE;
- STDMETHOD(SetAspectRatioMode)(THIS_ DWORD dwAspectRatioMode) PURE;
- STDMETHOD(GetAspectRatioMode)(THIS_ DWORD* pdwAspectRatioMode) PURE;
- STDMETHOD(SetVideoWindow)(THIS_ HWND hwndVideo) PURE;
- STDMETHOD(GetVideoWindow)(THIS_ HWND* phwndVideo) PURE;
- STDMETHOD(RepaintVideo)(THIS_) PURE;
- STDMETHOD(GetCurrentImage)(THIS_ BITMAPINFOHEADER* pBih, BYTE** pDib, DWORD* pcbDib, LONGLONG* pTimeStamp) PURE;
- STDMETHOD(SetBorderColor)(THIS_ COLORREF Clr) PURE;
- STDMETHOD(GetBorderColor)(THIS_ COLORREF* pClr) PURE;
- STDMETHOD(SetRenderingPrefs)(THIS_ DWORD dwRenderFlags) PURE;
- STDMETHOD(GetRenderingPrefs)(THIS_ DWORD* pdwRenderFlags) PURE;
- STDMETHOD(SetFullScreen)(THIS_ BOOL fFullscreen) PURE;
- STDMETHOD(GetFullScreen)(THIS_ BOOL* pfFullscreen) PURE;
-};
-#undef INTERFACE
-#define INTERFACE IMFVideoMixerControl
-DECLARE_INTERFACE_(IMFVideoMixerControl, IUnknown)
-{
- STDMETHOD(SetStreamZOrder)(THIS_ DWORD dwStreamID, DWORD dwZ) PURE;
- STDMETHOD(GetStreamZOrder)(THIS_ DWORD dwStreamID, DWORD* pdwZ) PURE;
- STDMETHOD(SetStreamOutputRect)(THIS_ DWORD dwStreamID, const MFVideoNormalizedRect* pnrcOutput) PURE;
- STDMETHOD(GetStreamOutputRect)(THIS_ DWORD dwStreamID, MFVideoNormalizedRect* pnrcOutput) PURE;
-};
-#undef INTERFACE
-#define INTERFACE IMFVideoProcessor
-DECLARE_INTERFACE_(IMFVideoProcessor, IUnknown)
-{
- STDMETHOD(GetAvailableVideoProcessorModes)(THIS_ UINT* lpdwNumProcessingModes, GUID** ppVideoProcessingModes) PURE;
- STDMETHOD(GetVideoProcessorCaps)(THIS_ LPGUID lpVideoProcessorMode, DXVA2_VideoProcessorCaps* lpVideoProcessorCaps) PURE;
- STDMETHOD(GetVideoProcessorMode)(THIS_ LPGUID lpMode) PURE;
- STDMETHOD(SetVideoProcessorMode)(THIS_ LPGUID lpMode) PURE;
- STDMETHOD(GetProcAmpRange)(THIS_ DWORD dwProperty, DXVA2_ValueRange* pPropRange) PURE;
- STDMETHOD(GetProcAmpValues)(THIS_ DWORD dwFlags, DXVA2_ProcAmpValues* Values) PURE;
- STDMETHOD(SetProcAmpValues)(THIS_ DWORD dwFlags, DXVA2_ProcAmpValues* pValues) PURE;
- STDMETHOD(GetFilteringRange)(THIS_ DWORD dwProperty, DXVA2_ValueRange* pPropRange) PURE;
- STDMETHOD(GetFilteringValue)(THIS_ DWORD dwProperty, DXVA2_Fixed32* pValue) PURE;
- STDMETHOD(SetFilteringValue)(THIS_ DWORD dwProperty, DXVA2_Fixed32* pValue) PURE;
- STDMETHOD(GetBackgroundColor)(THIS_ COLORREF* lpClrBkg) PURE;
- STDMETHOD(SetBackgroundColor)(THIS_ COLORREF ClrBkg) PURE;
-};
-#undef INTERFACE
-#define INTERFACE IMFGetService
-DECLARE_INTERFACE_(IMFGetService, IUnknown)
-{
- STDMETHOD(GetService)(THIS_ REFGUID guidService, REFIID riid, LPVOID* ppvObject) PURE;
-};
-#undef INTERFACE
diff --git a/src/3rdparty/phonon/ds9/qmeminputpin.cpp b/src/3rdparty/phonon/ds9/qmeminputpin.cpp
index a21fbe7..dca99db 100644
--- a/src/3rdparty/phonon/ds9/qmeminputpin.cpp
+++ b/src/3rdparty/phonon/ds9/qmeminputpin.cpp
@@ -28,8 +28,8 @@ namespace Phonon
namespace DS9
{
- QMemInputPin::QMemInputPin(QBaseFilter *parent, const QVector<AM_MEDIA_TYPE> &mt, bool transform, QPin *output) :
- QPin(parent, PINDIR_INPUT, mt), m_shouldDuplicateSamples(true), m_transform(transform), m_output(output)
+ QMemInputPin::QMemInputPin(QBaseFilter *parent, const QVector<AM_MEDIA_TYPE> &mt, bool transform) :
+ QPin(parent, PINDIR_INPUT, mt), m_shouldDuplicateSamples(true), m_transform(transform)
{
}
@@ -66,9 +66,11 @@ namespace Phonon
{
//this allows to serialize with Receive calls
QMutexLocker locker(&m_mutexReceive);
- IPin *conn = m_output ? m_output->connected() : 0;
- if (conn) {
- conn->EndOfStream();
+ for(int i = 0; i < m_outputs.count(); ++i) {
+ IPin *conn = m_outputs.at(i)->connected();
+ if (conn) {
+ conn->EndOfStream();
+ }
}
return S_OK;
}
@@ -76,11 +78,13 @@ namespace Phonon
STDMETHODIMP QMemInputPin::BeginFlush()
{
//pass downstream
- IPin *conn = m_output ? m_output->connected() : 0;
- if (conn) {
- conn->BeginFlush();
+ for(int i = 0; i < m_outputs.count(); ++i) {
+ IPin *conn = m_outputs.at(i)->connected();
+ if (conn) {
+ conn->BeginFlush();
+ }
}
- QMutexLocker locker(&m_mutex);
+ QWriteLocker locker(&m_lock);
m_flushing = true;
return S_OK;
}
@@ -88,19 +92,22 @@ namespace Phonon
STDMETHODIMP QMemInputPin::EndFlush()
{
//pass downstream
- IPin *conn = m_output ? m_output->connected() : 0;
- if (conn) {
- conn->EndFlush();
+ for(int i = 0; i < m_outputs.count(); ++i) {
+ IPin *conn = m_outputs.at(i)->connected();
+ if (conn) {
+ conn->EndFlush();
+ }
}
- QMutexLocker locker(&m_mutex);
+ QWriteLocker locker(&m_lock);
m_flushing = false;
return S_OK;
}
STDMETHODIMP QMemInputPin::NewSegment(REFERENCE_TIME start, REFERENCE_TIME stop, double rate)
{
- if (m_output)
- m_output->NewSegment(start, stop, rate);
+ for(int i = 0; i < m_outputs.count(); ++i) {
+ m_outputs.at(i)->NewSegment(start, stop, rate);
+ }
return S_OK;
}
@@ -112,9 +119,14 @@ namespace Phonon
if (hr == S_OK &&
mt->majortype != MEDIATYPE_NULL &&
mt->subtype != MEDIASUBTYPE_NULL &&
- mt->formattype != GUID_NULL && m_output) {
- //we tell the output pin that it should connect with this type
- hr = m_output->setAcceptedMediaType(connectedType());
+ mt->formattype != GUID_NULL) {
+ //we tell the output pins that they should connect with this type
+ for(int i = 0; i < m_outputs.count(); ++i) {
+ hr = m_outputs.at(i)->setAcceptedMediaType(connectedType());
+ if (FAILED(hr)) {
+ break;
+ }
+ }
}
return hr;
}
@@ -125,8 +137,7 @@ namespace Phonon
return E_POINTER;
}
- *alloc = memoryAllocator(true);
- if (*alloc) {
+ if (*alloc = memoryAllocator(true)) {
return S_OK;
}
@@ -140,15 +151,18 @@ namespace Phonon
}
{
- QMutexLocker locker(&m_mutex);
+ QWriteLocker locker(&m_lock);
m_shouldDuplicateSamples = m_transform && readonly;
}
setMemoryAllocator(alloc);
- if (m_output) {
- ComPointer<IMemInputPin> input(m_output, IID_IMemInputPin);
- input->NotifyAllocator(alloc, m_shouldDuplicateSamples);
+ for(int i = 0; i < m_outputs.count(); ++i) {
+ IPin *pin = m_outputs.at(i)->connected();
+ if (pin) {
+ ComPointer<IMemInputPin> input(pin, IID_IMemInputPin);
+ input->NotifyAllocator(alloc, m_shouldDuplicateSamples);
+ }
}
return S_OK;
@@ -187,18 +201,22 @@ namespace Phonon
}
}
- if (m_output) {
+ for (int i = 0; i < m_outputs.count(); ++i) {
+ QPin *current = m_outputs.at(i);
IMediaSample *outSample = m_shouldDuplicateSamples ?
- duplicateSampleForOutput(sample, m_output->memoryAllocator())
+ duplicateSampleForOutput(sample, current->memoryAllocator())
: sample;
if (m_shouldDuplicateSamples) {
m_parent->processSample(outSample);
}
- ComPointer<IMemInputPin> input(m_output->connected(), IID_IMemInputPin);
- if (input) {
- input->Receive(outSample);
+ IPin *pin = current->connected();
+ if (pin) {
+ ComPointer<IMemInputPin> input(pin, IID_IMemInputPin);
+ if (input) {
+ input->Receive(outSample);
+ }
}
if (m_shouldDuplicateSamples) {
@@ -229,16 +247,39 @@ namespace Phonon
STDMETHODIMP QMemInputPin::ReceiveCanBlock()
{
- //we test the output to see if it can block
- if (m_output) {
- ComPointer<IMemInputPin> meminput(m_output->connected(), IID_IMemInputPin);
- if (meminput && meminput->ReceiveCanBlock() != S_FALSE) {
- return S_OK;
+ //we test the output to see if they can block
+ for(int i = 0; i < m_outputs.count(); ++i) {
+ IPin *input = m_outputs.at(i)->connected();
+ if (input) {
+ ComPointer<IMemInputPin> meminput(input, IID_IMemInputPin);
+ if (meminput && meminput->ReceiveCanBlock() != S_FALSE) {
+ return S_OK;
+ }
}
}
return S_FALSE;
}
+ //addition
+ //this should be used by the filter to tell its input pins to which output they should route the samples
+
+ void QMemInputPin::addOutput(QPin *output)
+ {
+ QWriteLocker locker(&m_lock);
+ m_outputs += output;
+ }
+
+ void QMemInputPin::removeOutput(QPin *output)
+ {
+ QWriteLocker locker(&m_lock);
+ m_outputs.removeOne(output);
+ }
+
+ QList<QPin*> QMemInputPin::outputs() const
+ {
+ QReadLocker locker(&m_lock);
+ return m_outputs;
+ }
ALLOCATOR_PROPERTIES QMemInputPin::getDefaultAllocatorProperties() const
{
@@ -253,7 +294,7 @@ namespace Phonon
LONG length = sample->GetActualDataLength();
HRESULT hr = alloc->Commit();
- if (hr == HRESULT(VFW_E_SIZENOTSET)) {
+ if (hr == VFW_E_SIZENOTSET) {
ALLOCATOR_PROPERTIES prop = getDefaultAllocatorProperties();
prop.cbBuffer = qMax(prop.cbBuffer, length);
ALLOCATOR_PROPERTIES actual;
@@ -283,7 +324,7 @@ namespace Phonon
{
LONGLONG start, end;
hr = sample->GetMediaTime(&start, &end);
- if (hr != HRESULT(VFW_E_MEDIA_TIME_NOT_SET)) {
+ if (hr != VFW_E_MEDIA_TIME_NOT_SET) {
hr = out->SetMediaTime(&start, &end);
Q_ASSERT(SUCCEEDED(hr));
}
diff --git a/src/3rdparty/phonon/ds9/qmeminputpin.h b/src/3rdparty/phonon/ds9/qmeminputpin.h
index d74c451..c449721 100644
--- a/src/3rdparty/phonon/ds9/qmeminputpin.h
+++ b/src/3rdparty/phonon/ds9/qmeminputpin.h
@@ -37,7 +37,7 @@ namespace Phonon
class QMemInputPin : public QPin, public IMemInputPin
{
public:
- QMemInputPin(QBaseFilter *, const QVector<AM_MEDIA_TYPE> &, bool transform, QPin *output);
+ QMemInputPin(QBaseFilter *, const QVector<AM_MEDIA_TYPE> &, bool transform);
~QMemInputPin();
//reimplementation from IUnknown
@@ -60,13 +60,18 @@ namespace Phonon
STDMETHODIMP ReceiveMultiple(IMediaSample **,long,long *);
STDMETHODIMP ReceiveCanBlock();
+ //addition
+ void addOutput(QPin *output);
+ void removeOutput(QPin *output);
+ QList<QPin*> outputs() const;
+
private:
IMediaSample *duplicateSampleForOutput(IMediaSample *, IMemAllocator *);
ALLOCATOR_PROPERTIES getDefaultAllocatorProperties() const;
bool m_shouldDuplicateSamples;
const bool m_transform; //defines if the pin is transforming the samples
- QPin* const m_output;
+ QList<QPin*> m_outputs;
QMutex m_mutexReceive;
};
}
diff --git a/src/3rdparty/phonon/ds9/qpin.cpp b/src/3rdparty/phonon/ds9/qpin.cpp
index b4afd10..37fe48d 100644
--- a/src/3rdparty/phonon/ds9/qpin.cpp
+++ b/src/3rdparty/phonon/ds9/qpin.cpp
@@ -28,7 +28,20 @@ namespace Phonon
namespace DS9
{
- static const AM_MEDIA_TYPE defaultMediaType = { MEDIATYPE_NULL, MEDIASUBTYPE_NULL, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0};
+ static const AM_MEDIA_TYPE defaultMediaType()
+ {
+ AM_MEDIA_TYPE ret;
+ ret.majortype = MEDIATYPE_NULL;
+ ret.subtype = MEDIASUBTYPE_NULL;
+ ret.bFixedSizeSamples = TRUE;
+ ret.bTemporalCompression = FALSE;
+ ret.lSampleSize = 1;
+ ret.formattype = GUID_NULL;
+ ret.pUnk = 0;
+ ret.cbFormat = 0;
+ ret.pbFormat = 0;
+ return ret;
+ }
class QEnumMediaTypes : public IEnumMediaTypes
{
@@ -91,8 +104,8 @@ namespace Phonon
return E_INVALIDARG;
}
- uint nbFetched = 0;
- while (nbFetched < count && m_index < m_pin->mediaTypes().count()) {
+ int nbFetched = 0;
+ while (nbFetched < int(count) && m_index < m_pin->mediaTypes().count()) {
//the caller will deallocate the memory
*out = static_cast<AM_MEDIA_TYPE *>(::CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)));
const AM_MEDIA_TYPE original = m_pin->mediaTypes().at(m_index);
@@ -145,9 +158,9 @@ namespace Phonon
QPin::QPin(QBaseFilter *parent, PIN_DIRECTION dir, const QVector<AM_MEDIA_TYPE> &mt) :
- m_parent(parent), m_flushing(false), m_refCount(1), m_connected(0),
- m_direction(dir), m_mediaTypes(mt), m_connectedType(defaultMediaType),
- m_memAlloc(0)
+ m_memAlloc(0), m_parent(parent), m_refCount(1), m_connected(0),
+ m_direction(dir), m_mediaTypes(mt), m_connectedType(defaultMediaType()),
+ m_flushing(false)
{
Q_ASSERT(m_parent);
m_parent->addPin(this);
@@ -260,7 +273,7 @@ namespace Phonon
if (FAILED(hr)) {
setConnected(0);
- setConnectedType(defaultMediaType);
+ setConnectedType(defaultMediaType());
} else {
ComPointer<IMemInputPin> input(pin, IID_IMemInputPin);
if (input) {
@@ -302,8 +315,10 @@ namespace Phonon
}
setConnected(0);
- setConnectedType(defaultMediaType);
- setMemoryAllocator(0);
+ setConnectedType(defaultMediaType());
+ if (m_direction == PINDIR_INPUT) {
+ setMemoryAllocator(0);
+ }
return S_OK;
}
@@ -323,7 +338,7 @@ namespace Phonon
STDMETHODIMP QPin::ConnectionMediaType(AM_MEDIA_TYPE *type)
{
- QMutexLocker locker(&m_mutex);
+ QReadLocker locker(&m_lock);
if (!type) {
return E_POINTER;
}
@@ -338,6 +353,7 @@ namespace Phonon
STDMETHODIMP QPin::QueryPinInfo(PIN_INFO *info)
{
+ QReadLocker locker(&m_lock);
if (!info) {
return E_POINTER;
}
@@ -345,12 +361,14 @@ namespace Phonon
info->dir = m_direction;
info->pFilter = m_parent;
m_parent->AddRef();
- info->achName[0] = 0;
+ qMemCopy(info->achName, m_name.utf16(), qMin(MAX_FILTER_NAME, m_name.length()+1) *2);
+
return S_OK;
}
STDMETHODIMP QPin::QueryDirection(PIN_DIRECTION *dir)
{
+ QReadLocker locker(&m_lock);
if (!dir) {
return E_POINTER;
}
@@ -361,18 +379,20 @@ namespace Phonon
STDMETHODIMP QPin::QueryId(LPWSTR *id)
{
+ QReadLocker locker(&m_lock);
if (!id) {
return E_POINTER;
}
- *id = static_cast<LPWSTR>(::CoTaskMemAlloc(2));
- *id[0] = 0;
+ int nbBytes = (m_name.length()+1)*2;
+ *id = static_cast<LPWSTR>(::CoTaskMemAlloc(nbBytes));
+ qMemCopy(*id, m_name.utf16(), nbBytes);
return S_OK;
}
STDMETHODIMP QPin::QueryAccept(const AM_MEDIA_TYPE *type)
{
- QMutexLocker locker(&m_mutex);
+ QReadLocker locker(&m_lock);
if (!type) {
return E_POINTER;
}
@@ -419,7 +439,7 @@ namespace Phonon
STDMETHODIMP QPin::NewSegment(REFERENCE_TIME start, REFERENCE_TIME stop, double rate)
{
- QMutexLocker locker(&m_mutex);
+ QReadLocker locker(&m_lock);
if (m_direction == PINDIR_OUTPUT && m_connected) {
//we deliver this downstream
m_connected->NewSegment(start, stop, rate);
@@ -436,8 +456,8 @@ namespace Phonon
HRESULT QPin::checkOutputMediaTypesConnection(IPin *pin)
{
- ComPointer<IEnumMediaTypes> emt;
- HRESULT hr = pin->EnumMediaTypes(emt.pparam());
+ IEnumMediaTypes *emt = 0;
+ HRESULT hr = pin->EnumMediaTypes(&emt);
if (hr != S_OK) {
return hr;
}
@@ -450,7 +470,7 @@ namespace Phonon
freeMediaType(type);
return S_OK;
} else {
- setConnectedType(defaultMediaType);
+ setConnectedType(defaultMediaType());
freeMediaType(type);
}
}
@@ -500,7 +520,7 @@ namespace Phonon
void QPin::setConnectedType(const AM_MEDIA_TYPE &type)
{
- QMutexLocker locker(&m_mutex);
+ QWriteLocker locker(&m_lock);
//1st we free memory
freeMediaType(m_connectedType);
@@ -510,13 +530,13 @@ namespace Phonon
const AM_MEDIA_TYPE &QPin::connectedType() const
{
- QMutexLocker locker(&m_mutex);
+ QReadLocker locker(&m_lock);
return m_connectedType;
}
void QPin::setConnected(IPin *pin)
{
- QMutexLocker locker(&m_mutex);
+ QWriteLocker locker(&m_lock);
if (pin) {
pin->AddRef();
}
@@ -528,7 +548,7 @@ namespace Phonon
IPin *QPin::connected(bool addref) const
{
- QMutexLocker locker(&m_mutex);
+ QReadLocker locker(&m_lock);
if (addref && m_connected) {
m_connected->AddRef();
}
@@ -537,12 +557,13 @@ namespace Phonon
bool QPin::isFlushing() const
{
- QMutexLocker locker(&m_mutex);
+ QReadLocker locker(&m_lock);
return m_flushing;
}
FILTER_STATE QPin::filterState() const
{
+ QReadLocker locker(&m_lock);
FILTER_STATE fstate = State_Stopped;
m_parent->GetState(0, &fstate);
return fstate;
@@ -550,7 +571,7 @@ namespace Phonon
QVector<AM_MEDIA_TYPE> QPin::mediaTypes() const
{
- QMutexLocker locker(&m_mutex);
+ QReadLocker locker(&m_lock);
return m_mediaTypes;
}
@@ -586,7 +607,7 @@ namespace Phonon
void QPin::setMemoryAllocator(IMemAllocator *alloc)
{
- QMutexLocker locker(&m_mutex);
+ QWriteLocker locker(&m_lock);
if (alloc) {
alloc->AddRef();
}
@@ -598,7 +619,7 @@ namespace Phonon
IMemAllocator *QPin::memoryAllocator(bool addref) const
{
- QMutexLocker locker(&m_mutex);
+ QReadLocker locker(&m_lock);
if (addref && m_memAlloc) {
m_memAlloc->AddRef();
}
diff --git a/src/3rdparty/phonon/ds9/qpin.h b/src/3rdparty/phonon/ds9/qpin.h
index 280ad61..a3287c4 100644
--- a/src/3rdparty/phonon/ds9/qpin.h
+++ b/src/3rdparty/phonon/ds9/qpin.h
@@ -22,7 +22,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#include <QtCore/QString>
#include <QtCore/QVector>
-#include <QtCore/QMutex>
+#include <QtCore/QReadWriteLock>
#include <dshow.h>
@@ -85,8 +85,8 @@ namespace Phonon
protected:
//this can be used by sub-classes
- mutable QMutex m_mutex;
- QBaseFilter * const m_parent;
+ mutable QReadWriteLock m_lock;
+ QBaseFilter *m_parent;
bool m_flushing;
private:
@@ -98,6 +98,7 @@ namespace Phonon
const PIN_DIRECTION m_direction;
QVector<AM_MEDIA_TYPE> m_mediaTypes; //accepted media types
AM_MEDIA_TYPE m_connectedType;
+ QString m_name;
IMemAllocator *m_memAlloc;
};
diff --git a/src/3rdparty/phonon/ds9/videorenderer_default.cpp b/src/3rdparty/phonon/ds9/videorenderer_default.cpp
deleted file mode 100644
index 0045a49..0000000
--- a/src/3rdparty/phonon/ds9/videorenderer_default.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/* This file is part of the KDE project.
-
-Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-
-This library is free software: you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation, either version 2.1 or 3 of the License.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-
-#include "videorenderer_default.h"
-
-#ifndef QT_NO_PHONON_VIDEO
-
-#include <QtGui/QWidget>
-#include <QtGui/QPainter>
-
-#include <uuids.h>
-
-QT_BEGIN_NAMESPACE
-
-
-namespace Phonon
-{
- namespace DS9
- {
- VideoRendererDefault::~VideoRendererDefault()
- {
- }
-
- bool VideoRendererDefault::isNative() const
- {
- return true;
- }
-
-
- VideoRendererDefault::VideoRendererDefault(QWidget *target) : m_target(target)
- {
- m_target->setAttribute(Qt::WA_PaintOnScreen, true);
- m_filter = Filter(CLSID_VideoRenderer, IID_IBaseFilter);
- }
-
- QSize VideoRendererDefault::videoSize() const
- {
- LONG w = 0,
- h = 0;
- ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo);
- if (basic) {
- basic->GetVideoSize( &w, &h);
- }
- return QSize(w, h);
- }
-
- void VideoRendererDefault::repaintCurrentFrame(QWidget * /*target*/, const QRect & /*rect*/)
- {
- //nothing to do here: the renderer paints everything
- }
-
- void VideoRendererDefault::notifyResize(const QSize &size, Phonon::VideoWidget::AspectRatio aspectRatio,
- Phonon::VideoWidget::ScaleMode scaleMode)
- {
- if (!isActive()) {
- ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo);
- if (basic) {
- basic->SetDestinationPosition(0, 0, 0, 0);
- }
- return;
- }
-
- ComPointer<IVideoWindow> video(m_filter, IID_IVideoWindow);
-
- OAHWND owner;
- HRESULT hr = video->get_Owner(&owner);
- if (FAILED(hr)) {
- return;
- }
-
- const OAHWND newOwner = reinterpret_cast<OAHWND>(m_target->winId());
- if (owner != newOwner) {
- video->put_Owner(newOwner);
- video->put_MessageDrain(newOwner);
- video->put_WindowStyle(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
- }
-
- //make sure the widget takes the whole size of the parent
- video->SetWindowPosition(0, 0, size.width(), size.height());
-
- const QSize vsize = videoSize();
- internalNotifyResize(size, vsize, aspectRatio, scaleMode);
-
- ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo);
- if (basic) {
- basic->SetDestinationPosition(m_dstX, m_dstY, m_dstWidth, m_dstHeight);
- }
- }
-
- void VideoRendererDefault::applyMixerSettings(qreal /*brightness*/, qreal /*contrast*/, qreal /*m_hue*/, qreal /*saturation*/)
- {
- //this can't be supported for the default renderer
- }
-
- QImage VideoRendererDefault::snapshot() const
- {
- ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo);
- if (basic) {
- LONG bufferSize = 0;
- //1st we get the buffer size
- basic->GetCurrentImage(&bufferSize, 0);
-
- QByteArray buffer;
- buffer.resize(bufferSize);
- HRESULT hr = basic->GetCurrentImage(&bufferSize, reinterpret_cast<long*>(buffer.data()));
-
- if (SUCCEEDED(hr)) {
-
- const BITMAPINFOHEADER *bmi = reinterpret_cast<const BITMAPINFOHEADER*>(buffer.constData());
-
- const int w = qAbs(bmi->biWidth),
- h = qAbs(bmi->biHeight);
-
- // Create image and copy data into image.
- QImage ret(w, h, QImage::Format_RGB32);
-
- if (!ret.isNull()) {
- const char *data = buffer.constData() + bmi->biSize;
- const int bytes_per_line = w * sizeof(QRgb);
- for (int y = h - 1; y >= 0; --y) {
- qMemCopy(ret.scanLine(y), //destination
- data, //source
- bytes_per_line);
- data += bytes_per_line;
- }
- }
- return ret;
- }
- }
- return QImage();
- }
-
- }
-}
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_PHONON_VIDEO
diff --git a/src/3rdparty/phonon/ds9/videorenderer_default.h b/src/3rdparty/phonon/ds9/videorenderer_default.h
deleted file mode 100644
index 43768d9..0000000
--- a/src/3rdparty/phonon/ds9/videorenderer_default.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* This file is part of the KDE project.
-
-Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-
-This library is free software: you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation, either version 2.1 or 3 of the License.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PHONON_VIDEORENDERER_DEFAULT_H
-#define PHONON_VIDEORENDERER_DEFAULT_H
-
-#include "abstractvideorenderer.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_PHONON_VIDEO
-
-namespace Phonon
-{
- namespace DS9
- {
- class VideoRendererDefault : public AbstractVideoRenderer
- {
- public:
- VideoRendererDefault(QWidget *target);
- ~VideoRendererDefault();
-
- //Implementation from AbstractVideoRenderer
- void repaintCurrentFrame(QWidget *target, const QRect &rect);
- void notifyResize(const QSize&, Phonon::VideoWidget::AspectRatio, Phonon::VideoWidget::ScaleMode);
- QSize videoSize() const;
- QImage snapshot() const;
- void applyMixerSettings(qreal brightness, qreal contrast, qreal m_hue, qreal saturation);
- bool isNative() const;
- private:
- QWidget *m_target;
- };
- }
-}
-
-#endif //QT_NO_PHONON_VIDEO
-
-QT_END_NAMESPACE
-
-#endif
-
diff --git a/src/3rdparty/phonon/ds9/videorenderer_evr.cpp b/src/3rdparty/phonon/ds9/videorenderer_evr.cpp
deleted file mode 100644
index d23d9ce..0000000
--- a/src/3rdparty/phonon/ds9/videorenderer_evr.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/* This file is part of the KDE project.
-
-Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-
-This library is free software: you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation, either version 2.1 or 3 of the License.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-
-#include "videorenderer_evr.h"
-#include "qevr9.h"
-
-#ifndef QT_NO_PHONON_VIDEO
-
-#include <QtGui/QWidget>
-#include <QtGui/QPainter>
-
-QT_BEGIN_NAMESPACE
-
-namespace Phonon
-{
- namespace DS9
- {
- //we have to define them here because not all compilers/sdk have them
- static const GUID MR_VIDEO_RENDER_SERVICE = {0x1092a86c, 0xab1a, 0x459a, {0xa3, 0x36, 0x83, 0x1f, 0xbc, 0x4d, 0x11, 0xff} };
- static const GUID MR_VIDEO_MIXER_SERVICE = { 0x73cd2fc, 0x6cf4, 0x40b7, {0x88, 0x59, 0xe8, 0x95, 0x52, 0xc8, 0x41, 0xf8} };
- static const IID IID_IMFVideoDisplayControl = {0xa490b1e4, 0xab84, 0x4d31, {0xa1, 0xb2, 0x18, 0x1e, 0x03, 0xb1, 0x07, 0x7a} };
- static const IID IID_IMFVideoMixerControl = {0xA5C6C53F, 0xC202, 0x4aa5, {0x96, 0x95, 0x17, 0x5B, 0xA8, 0xC5, 0x08, 0xA5} };
- static const IID IID_IMFVideoProcessor = {0x6AB0000C, 0xFECE, 0x4d1f, {0xA2, 0xAC, 0xA9, 0x57, 0x35, 0x30, 0x65, 0x6E} };
- static const IID IID_IMFGetService = {0xFA993888, 0x4383, 0x415A, {0xA9, 0x30, 0xDD, 0x47, 0x2A, 0x8C, 0xF6, 0xF7} };
- static const GUID CLSID_EnhancedVideoRenderer = {0xfa10746c, 0x9b63, 0x4b6c, {0xbc, 0x49, 0xfc, 0x30, 0xe, 0xa5, 0xf2, 0x56} };
-
- template <typename T> ComPointer<T> getService(const Filter &filter, REFGUID guidService, REFIID riid)
- {
- //normally we should use IID_IMFGetService but this introduces another dependency
- //so here we simply define our own IId with the same value
- ComPointer<IMFGetService> getService(filter, IID_IMFGetService);
- Q_ASSERT(getService);
- T *ptr = 0;
- HRESULT hr = getService->GetService(guidService, riid, reinterpret_cast<void **>(&ptr));
- if (!SUCCEEDED(hr) || ptr == 0)
- Q_ASSERT(!SUCCEEDED(hr) && ptr != 0);
- ComPointer<T> service(ptr);
- return service;
- }
-
- VideoRendererEVR::~VideoRendererEVR()
- {
- }
-
- bool VideoRendererEVR::isNative() const
- {
- return true;
- }
-
- VideoRendererEVR::VideoRendererEVR(QWidget *target) : m_target(target)
- {
- m_filter = Filter(CLSID_EnhancedVideoRenderer, IID_IBaseFilter);
- if (!m_filter) {
- return;
- }
-
- ComPointer<IMFVideoDisplayControl> filterControl = getService<IMFVideoDisplayControl>(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl);
-
- filterControl->SetVideoWindow(reinterpret_cast<HWND>(target->winId()));
- filterControl->SetAspectRatioMode(MFVideoARMode_None); // We're in control of the size
- }
-
- QImage VideoRendererEVR::snapshot() const
- {
- // This will always capture black areas where no video is drawn, if any are present.
- // Due to the hack in notifyResize()
- ComPointer<IMFVideoDisplayControl> filterControl = getService<IMFVideoDisplayControl>(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl);
- if (filterControl) {
- BITMAPINFOHEADER bmi;
- BYTE *buffer = 0;
- DWORD bufferSize;
- LONGLONG timeStamp;
-
- bmi.biSize = sizeof(BITMAPINFOHEADER);
-
- HRESULT hr = filterControl->GetCurrentImage(&bmi, &buffer, &bufferSize, &timeStamp);
- if (SUCCEEDED(hr)) {
-
- const int w = qAbs(bmi.biWidth),
- h = qAbs(bmi.biHeight);
-
- // Create image and copy data into image.
- QImage ret(w, h, QImage::Format_RGB32);
-
- if (!ret.isNull()) {
- uchar *data = buffer;
- const int bytes_per_line = w * sizeof(QRgb);
- for (int y = h - 1; y >= 0; --y) {
- qMemCopy(ret.scanLine(y), //destination
- data, //source
- bytes_per_line);
- data += bytes_per_line;
- }
- }
- ::CoTaskMemFree(buffer);
- return ret;
- }
- }
- return QImage();
- }
-
- QSize VideoRendererEVR::videoSize() const
- {
- SIZE nativeSize;
- SIZE aspectRatioSize;
-
- ComPointer<IMFVideoDisplayControl> filterControl = getService<IMFVideoDisplayControl>(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl);
-
- filterControl->GetNativeVideoSize(&nativeSize, &aspectRatioSize);
-
- return QSize(nativeSize.cx, nativeSize.cy);
- }
-
- void VideoRendererEVR::repaintCurrentFrame(QWidget *target, const QRect &rect)
- {
- // repaint the video
- ComPointer<IMFVideoDisplayControl> filterControl = getService<IMFVideoDisplayControl>(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl);
- // All failed results can be safely ignored
- filterControl->RepaintVideo();
- }
-
- void VideoRendererEVR::notifyResize(const QSize &size, Phonon::VideoWidget::AspectRatio aspectRatio,
- Phonon::VideoWidget::ScaleMode scaleMode)
- {
- if (!isActive()) {
- RECT dummyRect = { 0, 0, 0, 0};
- ComPointer<IMFVideoDisplayControl> filterControl = getService<IMFVideoDisplayControl>(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl);
- filterControl->SetVideoPosition(0, &dummyRect);
- return;
- }
-
- const QSize vsize = videoSize();
- internalNotifyResize(size, vsize, aspectRatio, scaleMode);
-
- RECT dstRectWin = { 0, 0, size.width(), size.height()};
-
- // Resize the Stream output rect instead of the destination rect.
- // Hacky workaround for flicker in the areas outside of the destination rect
- // This way these areas don't exist
- MFVideoNormalizedRect streamOutputRect = { float(m_dstX) / float(size.width()), float(m_dstY) / float(size.height()),
- float(m_dstWidth + m_dstX) / float(size.width()), float(m_dstHeight + m_dstY) / float(size.height())};
-
- ComPointer<IMFVideoMixerControl> filterMixer = getService<IMFVideoMixerControl>(m_filter, MR_VIDEO_MIXER_SERVICE, IID_IMFVideoMixerControl);
- ComPointer<IMFVideoDisplayControl> filterControl = getService<IMFVideoDisplayControl>(m_filter, MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl);
-
- filterMixer->SetStreamOutputRect(0, &streamOutputRect);
- filterControl->SetVideoPosition(0, &dstRectWin);
- }
-
- void VideoRendererEVR::applyMixerSettings(qreal brightness, qreal contrast, qreal hue, qreal saturation)
- {
- InputPin sink = BackendNode::pins(m_filter, PINDIR_INPUT).first();
- OutputPin source;
- if (FAILED(sink->ConnectedTo(source.pparam()))) {
- return; //it must be connected to work
- }
-
- // Get the "Video Processor" (used for brightness/contrast/saturation/hue)
- ComPointer<IMFVideoProcessor> processor = getService<IMFVideoProcessor>(m_filter, MR_VIDEO_MIXER_SERVICE, IID_IMFVideoProcessor);
- Q_ASSERT(processor);
-
- DXVA2_ValueRange contrastRange;
- DXVA2_ValueRange brightnessRange;
- DXVA2_ValueRange saturationRange;
- DXVA2_ValueRange hueRange;
-
- if (FAILED(processor->GetProcAmpRange(DXVA2_ProcAmp_Contrast, &contrastRange)))
- return;
- if (FAILED(processor->GetProcAmpRange(DXVA2_ProcAmp_Brightness, &brightnessRange)))
- return;
- if (FAILED(processor->GetProcAmpRange(DXVA2_ProcAmp_Saturation, &saturationRange)))
- return;
- if (FAILED(processor->GetProcAmpRange(DXVA2_ProcAmp_Hue, &hueRange)))
- return;
-
- DXVA2_ProcAmpValues values;
-
- values.Contrast = DXVA2FloatToFixed(((contrast < 0
- ? DXVA2FixedToFloat(contrastRange.MinValue) : DXVA2FixedToFloat(contrastRange.MaxValue))
- - DXVA2FixedToFloat(contrastRange.DefaultValue)) * qAbs(contrast) + DXVA2FixedToFloat(contrastRange.DefaultValue));
- values.Brightness = DXVA2FloatToFixed(((brightness < 0
- ? DXVA2FixedToFloat(brightnessRange.MinValue) : DXVA2FixedToFloat(brightnessRange.MaxValue))
- - DXVA2FixedToFloat(brightnessRange.DefaultValue)) * qAbs(brightness) + DXVA2FixedToFloat(brightnessRange.DefaultValue));
- values.Saturation = DXVA2FloatToFixed(((saturation < 0
- ? DXVA2FixedToFloat(saturationRange.MinValue) : DXVA2FixedToFloat(saturationRange.MaxValue))
- - DXVA2FixedToFloat(saturationRange.DefaultValue)) * qAbs(saturation) + DXVA2FixedToFloat(saturationRange.DefaultValue));
- values.Hue = DXVA2FloatToFixed(((hue < 0
- ? DXVA2FixedToFloat(hueRange.MinValue) : DXVA2FixedToFloat(hueRange.MaxValue))
- - DXVA2FixedToFloat(hueRange.DefaultValue)) * qAbs(hue) + DXVA2FixedToFloat(hueRange.DefaultValue));
-
- //finally set the settings
- processor->SetProcAmpValues(DXVA2_ProcAmp_Contrast | DXVA2_ProcAmp_Brightness | DXVA2_ProcAmp_Saturation | DXVA2_ProcAmp_Hue, &values);
-
- }
- }
-}
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_PHONON_VIDEO
diff --git a/src/3rdparty/phonon/ds9/videorenderer_evr.h b/src/3rdparty/phonon/ds9/videorenderer_evr.h
deleted file mode 100644
index 229c36d..0000000
--- a/src/3rdparty/phonon/ds9/videorenderer_evr.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* This file is part of the KDE project.
-
-Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-
-This library is free software: you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation, either version 2.1 or 3 of the License.
-
-This library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Lesser General Public License for more details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with this library. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef PHONON_VIDEORENDERER_EVR_H
-#define PHONON_VIDEORENDERER_EVR_H
-
-#include "abstractvideorenderer.h"
-#include "compointer.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_PHONON_VIDEO
-
-namespace Phonon
-{
- namespace DS9
- {
- class VideoRendererEVR : public AbstractVideoRenderer
- {
- public:
- VideoRendererEVR(QWidget *target);
- ~VideoRendererEVR();
-
- //Implementation from AbstractVideoRenderer
- void repaintCurrentFrame(QWidget *target, const QRect &rect);
- void notifyResize(const QSize&, Phonon::VideoWidget::AspectRatio, Phonon::VideoWidget::ScaleMode);
- QSize videoSize() const;
- QImage snapshot() const;
- void applyMixerSettings(qreal brightness, qreal contrast, qreal m_hue, qreal saturation);
- bool isNative() const;
- private:
- QWidget *m_target;
- };
- }
-}
-
-#endif //QT_NO_PHONON_VIDEO
-
-QT_END_NAMESPACE
-
-#endif
-
diff --git a/src/3rdparty/phonon/ds9/videorenderer_soft.cpp b/src/3rdparty/phonon/ds9/videorenderer_soft.cpp
index 9c7993c..491d1bd 100644
--- a/src/3rdparty/phonon/ds9/videorenderer_soft.cpp
+++ b/src/3rdparty/phonon/ds9/videorenderer_soft.cpp
@@ -194,8 +194,8 @@ namespace Phonon
m_sampleBuffer = ComPointer<IMediaSample>();
#ifndef QT_NO_OPENGL
freeGLResources();
- m_textureUploaded = false;
#endif // QT_NO_OPENGL
+ m_textureUploaded = false;
}
void endOfStream()
@@ -314,6 +314,7 @@ namespace Phonon
REFERENCE_TIME m_start;
HANDLE m_renderEvent, m_receiveCanWait; // Signals sample to render
QSize m_size;
+ bool m_textureUploaded;
//mixer settings
qreal m_brightness,
@@ -355,7 +356,6 @@ namespace Phonon
bool m_checkedPrograms;
bool m_usingOpenGL;
- bool m_textureUploaded;
GLuint m_program[2];
GLuint m_texture[3];
#endif
@@ -365,7 +365,7 @@ namespace Phonon
{
public:
VideoRendererSoftPin(VideoRendererSoftFilter *parent) :
- QMemInputPin(parent, videoMediaTypes(), false /*no transformation of the samples*/, 0),
+ QMemInputPin(parent, videoMediaTypes(), false /*no transformation of the samples*/),
m_renderer(parent)
{
}
@@ -436,7 +436,7 @@ namespace Phonon
QBaseFilter(CLSID_NULL), m_inputPin(new VideoRendererSoftPin(this)),
m_renderer(renderer), m_start(0)
#ifndef QT_NO_OPENGL
- , m_checkedPrograms(false), m_usingOpenGL(false), m_textureUploaded(false)
+ ,m_usingOpenGL(false), m_checkedPrograms(false), m_textureUploaded(false)
#endif
{
m_renderEvent = ::CreateEvent(0, 0, 0, 0);
@@ -661,10 +661,7 @@ namespace Phonon
#ifndef QT_NO_OPENGL
- if (painter.paintEngine() &&
- (painter.paintEngine()->type() == QPaintEngine::OpenGL || painter.paintEngine()->type() == QPaintEngine::OpenGL2)
- && checkGLPrograms()) {
-
+ if (painter.paintEngine() && painter.paintEngine()->type() == QPaintEngine::OpenGL && checkGLPrograms()) {
//for now we only support YUV (both YV12 and YUY2)
updateTexture();
@@ -676,7 +673,6 @@ namespace Phonon
}
//let's draw the texture
- painter.beginNativePainting();
//Let's pass the other arguments
const Program prog = (m_inputPin->connectedType().subtype == MEDIASUBTYPE_YV12) ? YV12toRGB : YUY2toRGB;
@@ -726,7 +722,6 @@ namespace Phonon
glDisableClientState(GL_VERTEX_ARRAY);
glDisable(GL_FRAGMENT_PROGRAM_ARB);
- painter.endNativePainting();
return;
} else
#endif
diff --git a/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp b/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp
index 545b31e..298e9fa 100644
--- a/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp
+++ b/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp
@@ -22,9 +22,14 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#include <QtGui/QWidget>
#include <QtGui/QPainter>
+#include <QtCore/QTimerEvent>
+#ifndef Q_OS_WINCE
#include <d3d9.h>
#include <vmr9.h>
+#else
+#include <uuids.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -43,10 +48,116 @@ namespace Phonon
}
+#ifdef Q_OS_WINCE
+ VideoRendererVMR9::VideoRendererVMR9(QWidget *target) : m_target(target)
+ {
+ m_target->setAttribute(Qt::WA_PaintOnScreen, true);
+ m_filter = Filter(CLSID_VideoRenderer, IID_IBaseFilter);
+ }
+
+ QSize VideoRendererVMR9::videoSize() const
+ {
+ LONG w = 0,
+ h = 0;
+ ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo);
+ if (basic) {
+ basic->GetVideoSize( &w, &h);
+ }
+ return QSize(w, h);
+ }
+
+ void VideoRendererVMR9::repaintCurrentFrame(QWidget * /*target*/, const QRect & /*rect*/)
+ {
+ //nothing to do here: the renderer paints everything
+ }
+
+ void VideoRendererVMR9::notifyResize(const QSize &size, Phonon::VideoWidget::AspectRatio aspectRatio,
+ Phonon::VideoWidget::ScaleMode scaleMode)
+ {
+ if (!isActive()) {
+ ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo);
+ if (basic) {
+ basic->SetDestinationPosition(0, 0, 0, 0);
+ }
+ return;
+ }
+
+ ComPointer<IVideoWindow> video(m_filter, IID_IVideoWindow);
+
+ OAHWND owner;
+ HRESULT hr = video->get_Owner(&owner);
+ if (FAILED(hr)) {
+ return;
+ }
+
+ const OAHWND newOwner = reinterpret_cast<OAHWND>(m_target->winId());
+ if (owner != newOwner) {
+ video->put_Owner(newOwner);
+ video->put_MessageDrain(newOwner);
+ video->put_WindowStyle(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
+ }
+
+ //make sure the widget takes the whole size of the parent
+ video->SetWindowPosition(0, 0, size.width(), size.height());
+
+ const QSize vsize = videoSize();
+ internalNotifyResize(size, vsize, aspectRatio, scaleMode);
+
+ ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo);
+ if (basic) {
+ basic->SetDestinationPosition(m_dstX, m_dstY, m_dstWidth, m_dstHeight);
+ }
+ }
+
+ void VideoRendererVMR9::applyMixerSettings(qreal /*brightness*/, qreal /*contrast*/, qreal /*m_hue*/, qreal /*saturation*/)
+ {
+ //this can't be supported for WinCE
+ }
+
+ QImage VideoRendererVMR9::snapshot() const
+ {
+ ComPointer<IBasicVideo> basic(m_filter, IID_IBasicVideo);
+ if (basic) {
+ LONG bufferSize = 0;
+ //1st we get the buffer size
+ basic->GetCurrentImage(&bufferSize, 0);
+
+ QByteArray buffer;
+ buffer.resize(bufferSize);
+ HRESULT hr = basic->GetCurrentImage(&bufferSize, reinterpret_cast<long*>(buffer.data()));
+
+ if (SUCCEEDED(hr)) {
+
+ const BITMAPINFOHEADER *bmi = reinterpret_cast<const BITMAPINFOHEADER*>(buffer.constData());
+
+ const int w = qAbs(bmi->biWidth),
+ h = qAbs(bmi->biHeight);
+
+ // Create image and copy data into image.
+ QImage ret(w, h, QImage::Format_RGB32);
+
+ if (!ret.isNull()) {
+ const char *data = buffer.constData() + bmi->biSize;
+ const int bytes_per_line = w * sizeof(QRgb);
+ for (int y = h - 1; y >= 0; --y) {
+ qMemCopy(ret.scanLine(y), //destination
+ data, //source
+ bytes_per_line);
+ data += bytes_per_line;
+ }
+ }
+ return ret;
+ }
+ }
+ return QImage();
+ }
+
+#else
VideoRendererVMR9::VideoRendererVMR9(QWidget *target) : m_target(target)
{
m_filter = Filter(CLSID_VideoMixingRenderer9, IID_IBaseFilter);
if (!m_filter) {
+ qWarning("the video widget could not be initialized correctly");
return;
}
@@ -58,7 +169,6 @@ namespace Phonon
Q_ASSERT(SUCCEEDED(hr));
ComPointer<IVMRWindowlessControl9> windowlessControl(m_filter, IID_IVMRWindowlessControl9);
windowlessControl->SetVideoClippingWindow(reinterpret_cast<HWND>(target->winId()));
- windowlessControl->SetAspectRatioMode(VMR9ARMode_None); //we're in control of the size
}
QImage VideoRendererVMR9::snapshot() const
@@ -214,6 +324,7 @@ namespace Phonon
//finally set the settings
mixer->SetProcAmpControl(0, &ctrl);
}
+#endif
}
}
diff --git a/src/3rdparty/phonon/ds9/videorenderer_vmr9.h b/src/3rdparty/phonon/ds9/videorenderer_vmr9.h
index 516d79d..4eb237e 100644
--- a/src/3rdparty/phonon/ds9/videorenderer_vmr9.h
+++ b/src/3rdparty/phonon/ds9/videorenderer_vmr9.h
@@ -19,6 +19,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#define PHONON_VIDEORENDERER_VMR9_H
#include "abstractvideorenderer.h"
+#include "compointer.h"
QT_BEGIN_NAMESPACE
diff --git a/src/3rdparty/phonon/ds9/videowidget.cpp b/src/3rdparty/phonon/ds9/videowidget.cpp
index 09d42a4..de7ce5f 100644
--- a/src/3rdparty/phonon/ds9/videowidget.cpp
+++ b/src/3rdparty/phonon/ds9/videowidget.cpp
@@ -24,12 +24,7 @@ along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "mediaobject.h"
-#ifndef Q_OS_WINCE
-#include "videorenderer_evr.h"
#include "videorenderer_vmr9.h"
-#else
-#include "videorenderer_default.h"
-#endif
#include "videorenderer_soft.h"
QT_BEGIN_NAMESPACE
@@ -89,19 +84,7 @@ namespace Phonon
void setCurrentRenderer(AbstractVideoRenderer *renderer)
{
m_currentRenderer = renderer;
- //we disallow repaint on that widget for just a fraction of second
- //this allows better transition between videos
- setUpdatesEnabled(false);
- m_flickerFreeTimer.start(20, this);
- }
-
- void timerEvent(QTimerEvent *e)
- {
- if (e->timerId() == m_flickerFreeTimer.timerId()) {
- m_flickerFreeTimer.stop();
- setUpdatesEnabled(true);
- }
- QWidget::timerEvent(e);
+ update();
}
QSize sizeHint() const
@@ -123,8 +106,6 @@ namespace Phonon
void paintEvent(QPaintEvent *e)
{
- if (!updatesEnabled())
- return; //this avoids repaint from native events
checkCurrentRenderingMode();
m_currentRenderer->repaintCurrentFrame(this, e->rect());
}
@@ -172,14 +153,13 @@ namespace Phonon
}
} else if (!isEmbedded()) {
m_currentRenderer = m_node->switchRendering(m_currentRenderer);
- setAttribute(Qt::WA_PaintOnScreen, false);
+ setAttribute(Qt::WA_PaintOnScreen, true);
}
}
VideoWidget *m_node;
AbstractVideoRenderer *m_currentRenderer;
QVariant m_restoreScreenSaverActive;
- QBasicTimer m_flickerFreeTimer;
};
VideoWidget::VideoWidget(QWidget *parent)
@@ -223,9 +203,6 @@ namespace Phonon
if (toNative && m_noNativeRendererSupported)
return current; //no switch here
- if (!mediaObject())
- return current;
-
//firt we delete the renderer
//initialization of the widgets
for(int i = 0; i < FILTER_COUNT; ++i) {
@@ -284,7 +261,6 @@ namespace Phonon
{
m_aspectRatio = aspectRatio;
updateVideoSize();
- m_widget->update();
}
Phonon::VideoWidget::ScaleMode VideoWidget::scaleMode() const
@@ -303,7 +279,6 @@ namespace Phonon
{
m_scaleMode = scaleMode;
updateVideoSize();
- m_widget->update();
}
void VideoWidget::setBrightness(qreal b)
@@ -357,29 +332,14 @@ namespace Phonon
int index = graphIndex * 2 + type;
if (m_renderers[index] == 0 && autoCreate) {
AbstractVideoRenderer *renderer = 0;
- if (type == Native) {
-#ifndef Q_OS_WINCE
- renderer = new VideoRendererEVR(m_widget);
- if (renderer->getFilter() == 0) {
- delete renderer;
- //EVR not present, let's try VMR
- renderer = new VideoRendererVMR9(m_widget);
- if (renderer->getFilter() == 0) {
- //instanciating the renderer might fail
- m_noNativeRendererSupported = true;
- delete renderer;
- renderer = 0;
- }
- }
-#else
- renderer = new VideoRendererDefault(m_widget);
+ if (type == Native) {
+ renderer = new VideoRendererVMR9(m_widget);
if (renderer->getFilter() == 0) {
- //instanciating the renderer might fail
+ //instanciating the renderer might fail with error VFW_E_DDRAW_CAPS_NOT_SUITABLE (0x80040273)
m_noNativeRendererSupported = true;
delete renderer;
renderer = 0;
}
-#endif
}
if (renderer == 0) {
diff --git a/src/3rdparty/phonon/ds9/volumeeffect.cpp b/src/3rdparty/phonon/ds9/volumeeffect.cpp
index a93b074..b9a5fce 100644
--- a/src/3rdparty/phonon/ds9/volumeeffect.cpp
+++ b/src/3rdparty/phonon/ds9/volumeeffect.cpp
@@ -76,7 +76,7 @@ namespace Phonon
class VolumeMemInputPin : public QMemInputPin
{
public:
- VolumeMemInputPin(QBaseFilter *parent, const QVector<AM_MEDIA_TYPE> &mt, QPin *output) : QMemInputPin(parent, mt, true /*transform*/, output)
+ VolumeMemInputPin(QBaseFilter *parent, const QVector<AM_MEDIA_TYPE> &mt) : QMemInputPin(parent, mt, true /*transform*/)
{
}
@@ -139,7 +139,8 @@ namespace Phonon
//then creating the input
mt << audioMediaType();
- m_input = new VolumeMemInputPin(this, mt, m_output);
+ m_input = new VolumeMemInputPin(this, mt);
+ m_input->addOutput(m_output); //make the connection here
}
void VolumeEffectFilter::treatOneSamplePerChannel(BYTE **buffer, int sampleSize, int channelCount, int frequency)
diff --git a/src/3rdparty/phonon/ds9/volumeeffect.h b/src/3rdparty/phonon/ds9/volumeeffect.h
index d1b0186..39b20d0 100644
--- a/src/3rdparty/phonon/ds9/volumeeffect.h
+++ b/src/3rdparty/phonon/ds9/volumeeffect.h
@@ -47,7 +47,7 @@ namespace Phonon
private:
float m_volume;
- //paramaters used to fade
+ //parameters used to fade
Phonon::VolumeFaderEffect::FadeCurve m_fadeCurve;
bool m_fading; //determines if we should be fading.
diff --git a/src/3rdparty/phonon/gstreamer/CMakeLists.txt b/src/3rdparty/phonon/gstreamer/CMakeLists.txt
index 08f892a..2249ac3 100644
--- a/src/3rdparty/phonon/gstreamer/CMakeLists.txt
+++ b/src/3rdparty/phonon/gstreamer/CMakeLists.txt
@@ -19,7 +19,7 @@ include(ConfigureChecks.cmake)
if (BUILD_PHONON_GSTREAMER)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
- ${GSTREAMER_INCLUDE_DIR}
+ ${GSTREAMER_INCLUDE_DIR}
${GLIB2_INCLUDE_DIR}
${LIBXML2_INCLUDE_DIR}
${X11_X11_INCLUDE_PATH})
@@ -34,7 +34,6 @@ if (BUILD_PHONON_GSTREAMER)
set(phonon_gstreamer_SRCS
audiooutput.cpp
- artssink.cpp
backend.cpp
devicemanager.cpp
effectmanager.cpp
@@ -50,14 +49,20 @@ if (BUILD_PHONON_GSTREAMER)
message.cpp
audioeffect.cpp
abstractrenderer.cpp
- x11renderer.cpp
widgetrenderer.cpp
glrenderer.cpp
volumefadereffect.cpp
+ audiodataoutput.cpp
)
- find_package(Alsa)
- macro_ensure_version("0.10.22" ${GSTREAMER_VERSION} GSTREAMER_HAS_NONBLOCKING_ALSASINK)
+ if(NOT WIN32)
+ set(phonon_gstreamer_SRCS
+ ${phonon_gstreamer_SRCS}
+ artssink.cpp
+ x11renderer.cpp)
+ macro_optional_find_package(Alsa)
+ macro_ensure_version("0.10.22" ${GSTREAMER_VERSION} GSTREAMER_HAS_NONBLOCKING_ALSASINK)
+ endif(NOT WIN32)
if(ALSA_FOUND AND NOT GSTREAMER_HAS_NONBLOCKING_ALSASINK)
add_definitions(-DUSE_ALSASINK2)
include_directories(${ALSA_INCLUDES})
@@ -78,6 +83,9 @@ if (BUILD_PHONON_GSTREAMER)
if(ALSA_FOUND)
target_link_libraries(phonon_gstreamer ${ASOUND_LIBRARY})
endif(ALSA_FOUND)
+ if(USE_INSTALL_PLUGIN)
+ target_link_libraries(phonon_gstreamer ${GSTREAMER_PLUGIN_PBUTILS_LIBRARIES})
+ endif(USE_INSTALL_PLUGIN)
install(TARGETS phonon_gstreamer DESTINATION ${PLUGIN_INSTALL_DIR}/plugins/phonon_backend)
install(FILES gstreamer.desktop DESTINATION ${SERVICES_INSTALL_DIR}/phononbackends)
diff --git a/src/3rdparty/phonon/gstreamer/ConfigureChecks.cmake b/src/3rdparty/phonon/gstreamer/ConfigureChecks.cmake
index f2922e1..eaf5b99 100644
--- a/src/3rdparty/phonon/gstreamer/ConfigureChecks.cmake
+++ b/src/3rdparty/phonon/gstreamer/ConfigureChecks.cmake
@@ -17,6 +17,7 @@ macro_log_feature(GSTREAMER_FOUND "GStreamer" "gstreamer 0.10 is required for th
macro_optional_find_package(GStreamerPlugins)
macro_log_feature(GSTREAMER_PLUGIN_VIDEO_LIBRARIES "GStreamer video plugin" "The gstreamer video plugin (part of gstreamer-plugins-base 0.10) is required for the multimedia gstreamer backend" "http://gstreamer.freedesktop.org/modules/" FALSE "0.10")
+macro_log_feature(GSTREAMER_PLUGIN_AUDIO_LIBRARIES "GStreamer audio plugin" "The gstreamer audio plugin (part of gstreamer-plugins-base 0.10) is required for the multimedia gstreamer backend" "http://gstreamer.freedesktop.org/modules/" FALSE "0.10")
macro_optional_find_package(GLIB2)
macro_log_feature(GLIB2_FOUND "GLib2" "GLib 2 is required to compile the gstreamer backend for Phonon" "http://www.gtk.org/download/" FALSE)
@@ -30,8 +31,8 @@ macro_log_feature(LIBXML2_FOUND "LibXml2" "LibXml2 is required to compile the gs
macro_optional_find_package(OpenGL)
macro_log_feature(OPENGL_FOUND "OpenGL" "OpenGL support is required to compile the gstreamer backend for Phonon" "" FALSE)
-if (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
+if (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GSTREAMER_PLUGIN_AUDIO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
set(BUILD_PHONON_GSTREAMER TRUE)
-else (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
+else (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GSTREAMER_PLUGIN_AUDIO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
set(BUILD_PHONON_GSTREAMER FALSE)
-endif (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
+endif (GSTREAMER_FOUND AND GSTREAMER_PLUGIN_VIDEO_LIBRARIES AND GSTREAMER_PLUGIN_AUDIO_LIBRARIES AND GLIB2_FOUND AND GOBJECT_FOUND AND LIBXML2_FOUND AND OPENGL_FOUND)
diff --git a/src/3rdparty/phonon/gstreamer/audiodataoutput.cpp b/src/3rdparty/phonon/gstreamer/audiodataoutput.cpp
new file mode 100644
index 0000000..30dabdf
--- /dev/null
+++ b/src/3rdparty/phonon/gstreamer/audiodataoutput.cpp
@@ -0,0 +1,143 @@
+/* This file is part of the KDE project
+ Copyright (C) 2006 Matthias Kretz <kretz@kde.org>
+ Copyright (C) 2009 Martin Sandsmark <sandsmark@samfundet.no>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), Nokia Corporation
+ (or its successors, if any) and the KDE Free Qt Foundation, which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "audiodataoutput.h"
+#include "gsthelper.h"
+#include "medianode.h"
+#include "mediaobject.h"
+#include <QtCore/QVector>
+#include <QtCore/QMap>
+#include <phonon/audiooutput.h>
+
+namespace Phonon
+{
+namespace Gstreamer
+{
+AudioDataOutput::AudioDataOutput(Backend *backend, QObject *parent)
+ : QObject(parent),
+ MediaNode(backend, AudioSink | AudioSource)
+{
+ static int count = 0;
+ m_name = "AudioDataOutput" + QString::number(count++);
+
+ m_queue = gst_element_factory_make ("identity", NULL);
+ gst_object_ref(m_queue);
+ m_isValid = true;
+}
+
+AudioDataOutput::~AudioDataOutput()
+{
+ gst_element_set_state(m_queue, GST_STATE_NULL);
+ gst_object_unref(m_queue);
+}
+
+int AudioDataOutput::dataSize() const
+{
+ return m_dataSize;
+}
+
+int AudioDataOutput::sampleRate() const
+{
+ return 44100;
+}
+
+void AudioDataOutput::setDataSize(int size)
+{
+ m_dataSize = size;
+}
+
+typedef QMap<Phonon::AudioDataOutput::Channel, QVector<float> > FloatMap;
+typedef QMap<Phonon::AudioDataOutput::Channel, QVector<qint16> > IntMap;
+
+inline void AudioDataOutput::convertAndEmit(const QVector<qint16> &leftBuffer, const QVector<qint16> &rightBuffer)
+{
+ //TODO: Floats
+ IntMap map;
+ map.insert(Phonon::AudioDataOutput::LeftChannel, leftBuffer);
+ map.insert(Phonon::AudioDataOutput::RightChannel, rightBuffer);
+ emit dataReady(map);
+}
+
+void AudioDataOutput::processBuffer(GstPad*, GstBuffer* buffer, gpointer gThat)
+{
+ // TODO emit endOfMedia
+ AudioDataOutput *that = reinterpret_cast<AudioDataOutput*>(gThat);
+
+ // determine the number of channels
+ GstStructure* structure = gst_caps_get_structure (GST_BUFFER_CAPS(buffer), 0);
+ gst_structure_get_int (structure, "channels", &that->m_channels);
+
+ if (that->m_channels > 2 || that->m_channels < 0) {
+ qWarning() << Q_FUNC_INFO << ": Number of channels not supported: " << that->m_channels;
+ return;
+ }
+
+ gint16 *data = reinterpret_cast<gint16*>(GST_BUFFER_DATA(buffer));
+ guint size = GST_BUFFER_SIZE(buffer) / sizeof(gint16);
+
+ that->m_pendingData.reserve(that->m_pendingData.size() + size);
+
+ for (uint i=0; i<size; i++) {
+ // 8 bit? interleaved? yay for lacking documentation!
+ that->m_pendingData.append(data[i]);
+ }
+
+ while (that->m_pendingData.size() > that->m_dataSize * that->m_channels) {
+ if (that->m_channels == 1) {
+ QVector<qint16> intBuffer(that->m_dataSize);
+ memcpy(intBuffer.data(), that->m_pendingData.constData(), that->m_dataSize * sizeof(qint16));
+
+ that->convertAndEmit(intBuffer, intBuffer);
+ int newSize = that->m_pendingData.size() - that->m_dataSize;
+ memmove(that->m_pendingData.data(), that->m_pendingData.constData() + that->m_dataSize, newSize * sizeof(qint16));
+ that->m_pendingData.resize(newSize);
+ } else {
+ QVector<qint16> left(that->m_dataSize), right(that->m_dataSize);
+ for (int i=0; i<that->m_dataSize; i++) {
+ left[i] = that->m_pendingData[i*2];
+ right[i] = that->m_pendingData[i*2+1];
+ }
+ that->m_pendingData.resize(that->m_pendingData.size() - that->m_dataSize*2);
+ that->convertAndEmit(left, right);
+ }
+ }
+}
+
+void AudioDataOutput::mediaNodeEvent(const MediaNodeEvent *event)
+{
+ if (event->type() == MediaNodeEvent::MediaObjectConnected && root()) {
+ g_object_set(G_OBJECT(audioElement()), "sync", true, (const char*)NULL);
+ GstPad *audiopad = gst_element_get_pad (audioElement(), "src");
+ gst_pad_add_buffer_probe (audiopad, G_CALLBACK(processBuffer), this);
+ gst_object_unref (audiopad);
+ return;
+ }
+
+ MediaNode::mediaNodeEvent(event);
+}
+
+}} //namespace Phonon::Gstreamer
+
+#include "moc_audiodataoutput.cpp"
+// vim: sw=4 ts=4
+
diff --git a/src/3rdparty/phonon/gstreamer/audiodataoutput.h b/src/3rdparty/phonon/gstreamer/audiodataoutput.h
new file mode 100644
index 0000000..5e30a1d
--- /dev/null
+++ b/src/3rdparty/phonon/gstreamer/audiodataoutput.h
@@ -0,0 +1,84 @@
+/* This file is part of the KDE project
+ Copyright (C) 2006 Matthias Kretz <kretz@kde.org>
+ Copyright (C) 2009 Martin Sandsmark <sandsmark@samfundet.no>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), Nokia Corporation
+ (or its successors, if any) and the KDE Free Qt Foundation, which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef Phonon_GSTREAMER_AUDIODATAOUTPUT_H
+#define Phonon_GSTREAMER_AUDIODATAOUTPUT_H
+
+#include "abstractaudiooutput.h"
+#include "backend.h"
+#include "medianode.h"
+#include <phonon/audiodataoutput.h>
+#include <phonon/audiodataoutputinterface.h>
+
+namespace Phonon
+{
+namespace Gstreamer
+{
+ /**
+ * \author Martin Sandsmark <sandsmark@samfundet.no>
+ */
+ class AudioDataOutput : public QObject,
+ public AudioDataOutputInterface,
+ public MediaNode
+ {
+ Q_OBJECT
+ Q_INTERFACES(Phonon::AudioDataOutputInterface Phonon::Gstreamer::MediaNode)
+
+ public:
+ AudioDataOutput(Backend *, QObject *);
+ ~AudioDataOutput();
+
+ public Q_SLOTS:
+ int dataSize() const;
+ int sampleRate() const;
+ void setDataSize(int size);
+
+ public:
+ /// callback function for handling new audio data
+ static void processBuffer(GstPad*, GstBuffer*, gpointer);
+
+ Phonon::AudioDataOutput* frontendObject() const { return m_frontend; }
+ void setFrontendObject(Phonon::AudioDataOutput *frontend) { m_frontend = frontend; }
+
+ GstElement *audioElement() { return m_queue; }
+
+ void mediaNodeEvent(const MediaNodeEvent *event);
+
+
+ signals:
+ void dataReady(const QMap<Phonon::AudioDataOutput::Channel, QVector<qint16> > &data);
+ void dataReady(const QMap<Phonon::AudioDataOutput::Channel, QVector<float> > &data);
+ void endOfMedia(int remainingSamples);
+
+ private:
+ void convertAndEmit(const QVector<qint16>&, const QVector<qint16>&);
+
+ GstElement *m_queue;
+ int m_dataSize;
+ QVector<qint16> m_pendingData;
+ Phonon::AudioDataOutput *m_frontend;
+ int m_channels;
+ };
+}} //namespace Phonon::Gstreamer
+
+// vim: sw=4 ts=4 tw=80
+#endif // Phonon_FAKE_AUDIODATAOUTPUT_H
diff --git a/src/3rdparty/phonon/gstreamer/audiooutput.cpp b/src/3rdparty/phonon/gstreamer/audiooutput.cpp
index 641ff6b..f3137b2 100644
--- a/src/3rdparty/phonon/gstreamer/audiooutput.cpp
+++ b/src/3rdparty/phonon/gstreamer/audiooutput.cpp
@@ -125,6 +125,7 @@ void AudioOutput::setVolume(qreal newVolume)
bool AudioOutput::setOutputDevice(int newDevice)
{
m_backend->logMessage(Q_FUNC_INFO + QString::number(newDevice), Backend::Info, this);
+
if (newDevice == m_device)
return true;
@@ -135,20 +136,11 @@ bool AudioOutput::setOutputDevice(int newDevice)
}
bool success = false;
- const QList<AudioDevice> deviceList = m_backend->deviceManager()->audioOutputDevices();
- int deviceIdx = -1;
- for (int i=0; i<deviceList.size(); i++) {
- if (deviceList.at(i).id == newDevice) {
- deviceIdx = i;
- break;
- }
- }
-
- if (m_audioSink && deviceIdx >= 0) {
+ if (m_audioSink && newDevice >= 0) {
// Save previous state
GstState oldState = GST_STATE(m_audioSink);
const QByteArray oldDeviceValue = GstHelper::property(m_audioSink, "device");
- const QByteArray deviceId = deviceList.at(deviceIdx).gstId;
+ const QByteArray deviceId = m_backend->deviceManager()->gstId(newDevice);
m_device = newDevice;
// We test if the device can be opened by checking if it can go from NULL to READY state
@@ -170,7 +162,7 @@ bool AudioOutput::setOutputDevice(int newDevice)
deviceId, Backend::Info, this);
}
- // Note the stopped state should not really be neccessary, but seems to be required to
+ // Note the stopped state should not really be necessary, but seems to be required to
// properly reset after changing the audio state
if (root()) {
QMetaObject::invokeMethod(root(), "setState", Qt::QueuedConnection, Q_ARG(State, StoppedState));
diff --git a/src/3rdparty/phonon/gstreamer/backend.cpp b/src/3rdparty/phonon/gstreamer/backend.cpp
index dab6f35..729a1d3 100644
--- a/src/3rdparty/phonon/gstreamer/backend.cpp
+++ b/src/3rdparty/phonon/gstreamer/backend.cpp
@@ -18,6 +18,7 @@
#include "common.h"
#include "backend.h"
#include "audiooutput.h"
+#include "audiodataoutput.h"
#include "audioeffect.h"
#include "mediaobject.h"
#include "videowidget.h"
@@ -26,6 +27,7 @@
#include "message.h"
#include "volumefadereffect.h"
#include <gst/interfaces/propertyprobe.h>
+#include <phonon/pulsesupport.h>
#include <QtCore/QSet>
#include <QtCore/QVariant>
@@ -49,13 +51,17 @@ Backend::Backend(QObject *parent, const QVariantList &)
, m_debugLevel(Warning)
, m_isValid(false)
{
+ // Initialise PulseAudio support
+ PulseSupport *pulse = PulseSupport::getInstance();
+ pulse->enable();
+ connect(pulse, SIGNAL(objectDescriptionChanged(ObjectDescriptionType)), SIGNAL(objectDescriptionChanged(ObjectDescriptionType)));
+
// In order to support reloading, we only set the app name once...
static bool first = true;
if (first) {
first = false;
g_set_application_name(qApp->applicationName().toUtf8());
}
-
GError *err = 0;
bool wasInit = gst_init_check(0, 0, &err); //init gstreamer: must be called before any gst-related functions
if (err)
@@ -92,6 +98,9 @@ Backend::Backend(QObject *parent, const QVariantList &)
Backend::~Backend()
{
+ delete m_effectManager;
+ delete m_deviceManager;
+ PulseSupport::shutdown();
}
gboolean Backend::busCall(GstBus *bus, GstMessage *msg, gpointer data)
@@ -119,18 +128,15 @@ QObject *Backend::createObject(BackendInterface::Class c, QObject *parent, const
case MediaObjectClass:
return new MediaObject(this, parent);
- case AudioOutputClass: {
- AudioOutput *ao = new AudioOutput(this, parent);
- m_audioOutputs.append(ao);
- return ao;
- }
+ case AudioOutputClass:
+ return new AudioOutput(this, parent);
+
#ifndef QT_NO_PHONON_EFFECT
case EffectClass:
return new AudioEffect(this, args[0].toInt(), parent);
#endif //QT_NO_PHONON_EFFECT
case AudioDataOutputClass:
- logMessage("createObject() : AudioDataOutput not implemented");
- break;
+ return new AudioDataOutput(this, parent);
#ifndef QT_NO_PHONON_VIDEO
case VideoDataOutputClass:
@@ -214,14 +220,14 @@ QStringList Backend::availableMimeTypes() const
GstPluginFeature *feature = GST_PLUGIN_FEATURE(iter->data);
QString klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(feature));
- if (klass == QLatin1String("Codec/Decoder") ||
- klass == QLatin1String("Codec/Decoder/Audio") ||
- klass == QLatin1String("Codec/Decoder/Video") ||
- klass == QLatin1String("Codec/Demuxer") ||
- klass == QLatin1String("Codec/Demuxer/Audio") ||
- klass == QLatin1String("Codec/Demuxer/Video") ||
- klass == QLatin1String("Codec/Parser") ||
- klass == QLatin1String("Codec/Parser/Audio") ||
+ if (klass == QLatin1String("Codec/Decoder") ||
+ klass == QLatin1String("Codec/Decoder/Audio") ||
+ klass == QLatin1String("Codec/Decoder/Video") ||
+ klass == QLatin1String("Codec/Demuxer") ||
+ klass == QLatin1String("Codec/Demuxer/Audio") ||
+ klass == QLatin1String("Codec/Demuxer/Video") ||
+ klass == QLatin1String("Codec/Parser") ||
+ klass == QLatin1String("Codec/Parser/Audio") ||
klass == QLatin1String("Codec/Parser/Video")) {
const GList *static_templates;
@@ -234,16 +240,28 @@ QStringList Backend::availableMimeTypes() const
GstCaps *caps = gst_static_pad_template_get_caps (padTemplate);
if (caps) {
- const GstStructure* capsStruct = gst_caps_get_structure (caps, 0);
- QString mime = QString::fromUtf8(gst_structure_get_name (capsStruct));
- if (!availableMimeTypes.contains(mime))
- availableMimeTypes.append(mime);
+ for (unsigned int struct_idx = 0; struct_idx < gst_caps_get_size (caps); struct_idx++) {
+
+ const GstStructure* capsStruct = gst_caps_get_structure (caps, struct_idx);
+ QString mime = QString::fromUtf8(gst_structure_get_name (capsStruct));
+ if (!availableMimeTypes.contains(mime))
+ availableMimeTypes.append(mime);
+ }
}
}
}
}
}
g_list_free(factoryList);
+ if (availableMimeTypes.contains("audio/x-vorbis")
+ && availableMimeTypes.contains("application/x-ogm-audio")) {
+ if (!availableMimeTypes.contains("audio/x-vorbis+ogg"))
+ availableMimeTypes.append("audio/x-vorbis+ogg");
+ if (!availableMimeTypes.contains("application/ogg")) /* *.ogg */
+ availableMimeTypes.append("application/ogg");
+ if (!availableMimeTypes.contains("audio/ogg")) /* *.oga */
+ availableMimeTypes.append("audio/ogg");
+ }
availableMimeTypes.sort();
return availableMimeTypes;
}
@@ -293,14 +311,11 @@ QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(ObjectDescripti
switch (type) {
case Phonon::AudioOutputDeviceType: {
- QList<AudioDevice> audioDevices = deviceManager()->audioOutputDevices();
- foreach(const AudioDevice &device, audioDevices) {
- if (device.id == index) {
- ret.insert("name", device.gstId);
- ret.insert("description", device.description);
- ret.insert("icon", QLatin1String("audio-card"));
- break;
- }
+ AudioDevice* ad;
+ if ((ad = deviceManager()->audioDevice(index))) {
+ ret.insert("name", ad->gstId);
+ ret.insert("description", ad->description);
+ ret.insert("icon", ad->icon);
}
}
break;
@@ -429,7 +444,7 @@ EffectManager* Backend::effectManager() const
/**
* Returns a debuglevel that is determined by the
- * PHONON_GSTREAMER_DEBUG environment variable.
+ * PHONON_GST_DEBUG environment variable.
*
* Warning - important warnings
* Info - general info
diff --git a/src/3rdparty/phonon/gstreamer/backend.h b/src/3rdparty/phonon/gstreamer/backend.h
index 2aab6fa..d157f11 100644
--- a/src/3rdparty/phonon/gstreamer/backend.h
+++ b/src/3rdparty/phonon/gstreamer/backend.h
@@ -86,7 +86,6 @@ private Q_SLOTS:
private:
static gboolean busCall(GstBus *bus, GstMessage *msg, gpointer data);
- QList<QPointer<AudioOutput> > m_audioOutputs;
DeviceManager *m_deviceManager;
EffectManager *m_effectManager;
diff --git a/src/3rdparty/phonon/gstreamer/devicemanager.cpp b/src/3rdparty/phonon/gstreamer/devicemanager.cpp
index 60e860f..c3826eb 100644
--- a/src/3rdparty/phonon/gstreamer/devicemanager.cpp
+++ b/src/3rdparty/phonon/gstreamer/devicemanager.cpp
@@ -24,6 +24,7 @@
#include "widgetrenderer.h"
#include "x11renderer.h"
#include "artssink.h"
+#include "pulsesupport.h"
#ifdef USE_ALSASINK2
#include "alsasink2.h"
@@ -44,9 +45,12 @@ namespace Gstreamer
AudioDevice::AudioDevice(DeviceManager *manager, const QByteArray &gstId)
: gstId(gstId)
{
- //get an id
- static int counter = 0;
- id = counter++;
+ // This should never be called when PulseAudio is active.
+ Q_ASSERT(!PulseSupport::getInstance()->isActive());
+
+ id = manager->allocateDeviceId();
+ icon = "audio-card";
+
//get name from device
if (gstId == "default") {
description = "Default audio device";
@@ -71,22 +75,25 @@ AudioDevice::AudioDevice(DeviceManager *manager, const QByteArray &gstId)
DeviceManager::DeviceManager(Backend *backend)
: QObject(backend)
, m_backend(backend)
+ , m_audioDeviceCounter(0)
{
- m_audioSink = qgetenv("PHONON_GST_AUDIOSINK");
- m_videoSinkWidget = qgetenv("PHONON_GST_VIDEOMODE");
-
-#ifndef QT_NO_SETTINGS
QSettings settings(QLatin1String("Trolltech"));
settings.beginGroup(QLatin1String("Qt"));
+ PulseSupport *pulse = PulseSupport::getInstance();
+ m_audioSink = qgetenv("PHONON_GST_AUDIOSINK");
if (m_audioSink.isEmpty()) {
m_audioSink = settings.value(QLatin1String("audiosink"), "Auto").toByteArray().toLower();
+ if (m_audioSink == "auto" && pulse->isActive())
+ m_audioSink = "pulsesink";
}
+ if ("pulsesink" != m_audioSink)
+ pulse->enable(false);
+ m_videoSinkWidget = qgetenv("PHONON_GST_VIDEOMODE");
if (m_videoSinkWidget.isEmpty()) {
m_videoSinkWidget = settings.value(QLatin1String("videomode"), "Auto").toByteArray().toLower();
}
-#endif //QT_NO_SETTINGS
if (m_backend->isValid())
updateDeviceList();
@@ -271,9 +278,17 @@ AbstractRenderer *DeviceManager::createVideoRenderer(VideoWidget *parent)
}
#endif //QT_NO_PHONON_VIDEO
-/*
- * Returns a positive device id or -1 if device
- * does not exist
+/**
+ * Allocate a device id for a new audio device
+ */
+int DeviceManager::allocateDeviceId()
+{
+ return m_audioDeviceCounter++;
+}
+
+
+/**
+ * Returns a positive device id or -1 if device does not exist
*
* The gstId is typically in the format hw:1,0
*/
@@ -288,16 +303,30 @@ int DeviceManager::deviceId(const QByteArray &gstId) const
}
/**
- * Get a human-readable description from a device id
+ * Returns a gstId or "default" if device does not exist
+ *
+ * The gstId is typically in the format hw:1,0
*/
-QByteArray DeviceManager::deviceDescription(int id) const
+const QByteArray DeviceManager::gstId(int deviceId)
+{
+ if (!PulseSupport::getInstance()->isActive()) {
+ AudioDevice *ad = audioDevice(deviceId);
+ if (ad)
+ return QByteArray(ad->gstId);
+ }
+ return QByteArray("default");
+}
+
+/**
+* Get the AudioDevice for a given device id
+*/
+AudioDevice* DeviceManager::audioDevice(int id)
{
for (int i = 0 ; i < m_audioDeviceList.size() ; ++i) {
- if (m_audioDeviceList[i].id == id) {
- return m_audioDeviceList[i].description;
- }
+ if (m_audioDeviceList[i].id == id)
+ return &m_audioDeviceList[i];
}
- return QByteArray();
+ return NULL;
}
/**
@@ -311,8 +340,11 @@ void DeviceManager::updateDeviceList()
QList<QByteArray> list;
if (audioSink) {
- list = GstHelper::extractProperties(audioSink, "device");
- list.prepend("default");
+ if (!PulseSupport::getInstance()->isActive()) {
+ // If we're using pulse, the PulseSupport class takes care of things for us.
+ list = GstHelper::extractProperties(audioSink, "device");
+ list.prepend("default");
+ }
for (int i = 0 ; i < list.size() ; ++i) {
QByteArray gstId = list.at(i);
diff --git a/src/3rdparty/phonon/gstreamer/devicemanager.h b/src/3rdparty/phonon/gstreamer/devicemanager.h
index a5e8289..9c6aa8d 100644
--- a/src/3rdparty/phonon/gstreamer/devicemanager.h
+++ b/src/3rdparty/phonon/gstreamer/devicemanager.h
@@ -42,6 +42,7 @@ public :
int id;
QByteArray gstId;
QByteArray description;
+ QString icon;
};
class DeviceManager : public QObject {
@@ -51,8 +52,10 @@ public:
virtual ~DeviceManager();
const QList<AudioDevice> audioOutputDevices() const;
GstPad *requestPad(int device) const;
+ int allocateDeviceId();
int deviceId(const QByteArray &gstId) const;
- QByteArray deviceDescription(int id) const;
+ const QByteArray gstId(int id);
+ AudioDevice* audioDevice(int id);
GstElement *createGNOMEAudioSink(Category category);
GstElement *createAudioSink(Category category = NoCategory);
AbstractRenderer *createVideoRenderer(VideoWidget *parent);
@@ -68,6 +71,7 @@ private:
bool canOpenDevice(GstElement *element) const;
Backend *m_backend;
QList <AudioDevice> m_audioDeviceList;
+ int m_audioDeviceCounter;
QTimer m_devicePollTimer;
QByteArray m_audioSink;
QByteArray m_videoSinkWidget;
diff --git a/src/3rdparty/phonon/gstreamer/effectmanager.cpp b/src/3rdparty/phonon/gstreamer/effectmanager.cpp
index 563e6fc..6c88148 100644
--- a/src/3rdparty/phonon/gstreamer/effectmanager.cpp
+++ b/src/3rdparty/phonon/gstreamer/effectmanager.cpp
@@ -54,7 +54,7 @@ EffectManager::EffectManager(Backend *backend)
// "volume" not needed
// "equalizer-nbands" not really useful at the moment
- // These plugins simply dont work or have major stability issues:
+ // These plugins simply don't work or have major stability issues:
// "iir" Does not seem to do much at the moment
// "audioinvert" Only works for some streams, should be invesigated
// "lpwsinc" Crashes for large values of filter kernel
diff --git a/src/3rdparty/phonon/gstreamer/glrenderer.cpp b/src/3rdparty/phonon/gstreamer/glrenderer.cpp
index 0203028..106884f 100644
--- a/src/3rdparty/phonon/gstreamer/glrenderer.cpp
+++ b/src/3rdparty/phonon/gstreamer/glrenderer.cpp
@@ -266,7 +266,7 @@ GLRenderWidgetImplementation::GLRenderWidgetImplementation(VideoWidget*videoWidg
palette.setColor(QPalette::Background, Qt::black);
setPalette(palette);
setAutoFillBackground(true);
- // Videowidget allways have this property to allow hiding the mouse cursor
+ // Videowidget always have this property to allow hiding the mouse cursor
setMouseTracking(true);
}
diff --git a/src/3rdparty/phonon/gstreamer/gsthelper.cpp b/src/3rdparty/phonon/gstreamer/gsthelper.cpp
index 34d99fa..69bb75c 100644
--- a/src/3rdparty/phonon/gstreamer/gsthelper.cpp
+++ b/src/3rdparty/phonon/gstreamer/gsthelper.cpp
@@ -121,7 +121,7 @@ GstElement* GstHelper::createPluggablePlaybin()
{
GstElement *playbin = 0;
//init playbin and add to our pipeline
- playbin = gst_element_factory_make("playbin", NULL);
+ playbin = gst_element_factory_make("playbin2", NULL);
//Create an identity element to redirect sound
GstElement *audioSinkBin = gst_bin_new (NULL);
diff --git a/src/3rdparty/phonon/gstreamer/gstreamer.desktop b/src/3rdparty/phonon/gstreamer/gstreamer.desktop
index b62472b..0861762 100644
--- a/src/3rdparty/phonon/gstreamer/gstreamer.desktop
+++ b/src/3rdparty/phonon/gstreamer/gstreamer.desktop
@@ -10,28 +10,81 @@ Icon=phonon-gstreamer
InitialPreference=10
Name=GStreamer
+Name[bg]=GStreamer
+Name[ca]=GStreamer
+Name[ca@valencia]=GStreamer
+Name[cs]=GStreamer
+Name[da]=GStreamer
+Name[de]=GStreamer
+Name[el]=GStreamer
+Name[en_GB]=GStreamer
+Name[es]=GStreamer
+Name[et]=GStreamer
+Name[eu]=GStreamer
+Name[fi]=GStreamer
+Name[fr]=GStreamer
+Name[ga]=GStreamer
+Name[gl]=GStreamer
+Name[hsb]=GStreamer
+Name[hu]=GStreamer
+Name[id]=GStreamer
+Name[is]=GStreamer
+Name[it]=GStreamer
+Name[ja]=GStreamer
+Name[ko]=GStreamer
+Name[ku]=GStreamer
+Name[lt]=GStreamer
+Name[lv]=GStreamer
+Name[nb]=GStreamer
+Name[nds]=GStreamer
+Name[nl]=GStreamer
+Name[nn]=GStreamer
Name[pa]=ਜੀਸਟੀਰਮਰ
+Name[pl]=GStreamer
+Name[pt]=GStreamer
+Name[pt_BR]=GStreamer
+Name[ru]=GStreamer
+Name[se]=GStreamer
+Name[sk]=GStreamer
+Name[sl]=GStreamer
Name[sr]=Гстример
+Name[sr@ijekavian]=Гстример
+Name[sr@ijekavianlatin]=GStreamer
+Name[sr@latin]=GStreamer
Name[sv]=Gstreamer
+Name[tr]=GStreamer
+Name[uk]=GStreamer
Name[x-test]=xxGStreamerxx
+Name[zh_CN]=GStreamer
+Name[zh_TW]=GStreamer
Comment=Phonon GStreamer backend
Comment[bg]=Phonon GStreamer
Comment[ca]=Dorsal GStreamer del Phonon
+Comment[ca@valencia]=Dorsal GStreamer del Phonon
+Comment[cs]=Phonon GStreamer backend
Comment[da]=GStreamer-backend til Phonon
Comment[de]=Phonon-Treiber für GStreamer
Comment[el]=Σύστημα υποστήριξης GStreamer του Phonon
+Comment[en_GB]=Phonon GStreamer backend
Comment[es]=Motor GStreamer para Phonon
Comment[et]=Phononi GStreameri taustaprogramm
+Comment[eu]=Phonon GStreamer backend
+Comment[fi]=Phonon GStreamer-taustaohjelma
Comment[fr]=Système de gestion GStreamer pour Phonon
Comment[ga]=Inneall GStreamer le haghaidh Phonon
Comment[gl]=Infraestrutura de GStreamer para Phonon
+Comment[hsb]=Phonon GStreamer backend
+Comment[hu]=Phonon GStreamer modul
+Comment[id]=Phonon GStreamer backend
Comment[is]=Phonon GStreamer bakendi
Comment[it]=Motore Gstreamer di Phonon
Comment[ja]=Phonon GStreamer バックエンド
Comment[ko]=Phonon GStreamer 백엔드
Comment[ku]=Binesaza Phonon GStreamer
+Comment[lt]=Phonon GStreamer galinė sąsaja
Comment[lv]=Phonon GStreamer aizmugure
+Comment[nb]=Phonon-motor for GStreamer
Comment[nds]=Phonon-Hülpprogramm GStreamer
Comment[nl]=GStreamer-backend (Phonon)
Comment[nn]=Phonon-motor for GStreamer
@@ -39,9 +92,13 @@ Comment[pa]=ਫੋਨੋਨ ਜਸਟੀਰਮਰ ਬੈਕਐਂਡ
Comment[pl]=Obsługa GStreamera przez Phonon
Comment[pt]=Infra-estrutura do GStreamer para o Phonon
Comment[pt_BR]=Infraestrutura Phonon GStreamer
+Comment[ru]=Механизм GStreamer для Phonon
+Comment[se]=Phonon GStreamer duogášmohtor
Comment[sk]=GStreamer podsystém
Comment[sl]=Phononova hrbtenica GStreamer
Comment[sr]=Гстример као позадина Фонона
+Comment[sr@ijekavian]=Гстример као позадина Фонона
+Comment[sr@ijekavianlatin]=GStreamer kao pozadina Phonona
Comment[sr@latin]=GStreamer kao pozadina Phonona
Comment[sv]=Phonon Gstreamer-gränssnitt
Comment[tr]=Phonon GStreamer arka ucu
diff --git a/src/3rdparty/phonon/gstreamer/medianode.cpp b/src/3rdparty/phonon/gstreamer/medianode.cpp
index 7257972..1a84592 100644
--- a/src/3rdparty/phonon/gstreamer/medianode.cpp
+++ b/src/3rdparty/phonon/gstreamer/medianode.cpp
@@ -198,9 +198,9 @@ bool MediaNode::disconnectNode(QObject *obj)
// Disconnecting elements while playing or paused seems to cause
// potential deadlock. Hence we force the pipeline into ready state
// before any nodes are disconnected.
- gst_element_set_state(root()->pipeline(), GST_STATE_READY);
+ gst_element_set_state(root()->pipeline(), GST_STATE_READY);
- Q_ASSERT(sink->root()); //sink has to have a root since it is onnected
+ Q_ASSERT(sink->root()); //sink has to have a root since it is connected
if (sink->description() & (AudioSink)) {
GstPad *sinkPad = gst_element_get_pad(sink->audioElement(), "sink");
diff --git a/src/3rdparty/phonon/gstreamer/mediaobject.cpp b/src/3rdparty/phonon/gstreamer/mediaobject.cpp
index b6d23ec..3e0addc 100644
--- a/src/3rdparty/phonon/gstreamer/mediaobject.cpp
+++ b/src/3rdparty/phonon/gstreamer/mediaobject.cpp
@@ -16,6 +16,7 @@
*/
#include <cmath>
#include <gst/interfaces/propertyprobe.h>
+#include <gst/pbutils/install-plugins.h>
#include "common.h"
#include "mediaobject.h"
#include "videowidget.h"
@@ -53,6 +54,7 @@ MediaObject::MediaObject(Backend *backend, QObject *parent)
, m_tickTimer(new QTimer(this))
, m_prefinishMark(0)
, m_transitionTime(0)
+ , m_isStream(false)
, m_posAtSeek(-1)
, m_prefinishMarkReachedNotEmitted(true)
, m_aboutToFinishEmitted(false)
@@ -79,6 +81,7 @@ MediaObject::MediaObject(Backend *backend, QObject *parent)
, m_autoplayTitles(true)
, m_availableTitles(0)
, m_currentTitle(1)
+ , m_pendingTitle(1)
{
qRegisterMetaType<GstCaps*>("GstCaps*");
qRegisterMetaType<State>("State");
@@ -95,8 +98,8 @@ MediaObject::MediaObject(Backend *backend, QObject *parent)
m_backend->addBusWatcher(this);
connect(m_tickTimer, SIGNAL(timeout()), SLOT(emitTick()));
}
- connect(this, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
- this, SLOT(notifyStateChange(Phonon::State,Phonon::State)));
+ connect(this, SIGNAL(stateChanged(Phonon::State, Phonon::State)),
+ this, SLOT(notifyStateChange(Phonon::State, Phonon::State)));
}
@@ -136,6 +139,14 @@ QString stateString(const Phonon::State &state)
return QString();
}
+void
+pluginInstallationDone( GstInstallPluginsReturn res, gpointer userData )
+{
+ // Nothing inside yet
+ Q_UNUSED(res);
+ Q_UNUSED(userData);
+}
+
void MediaObject::saveState()
{
//Only first resumeState is respected
@@ -195,13 +206,35 @@ void MediaObject::noMorePadsAvailable ()
if (m_missingCodecs.size() > 0) {
bool canPlay = (m_hasAudio || m_videoStreamFound);
Phonon::ErrorType error = canPlay ? Phonon::NormalError : Phonon::FatalError;
+#ifdef PLUGIN_INSTALL_API
+ GstInstallPluginsContext *ctx = gst_install_plugins_context_new ();
+ gchar *details[2];
+ details[0] = m_missingCodecs[0].toLocal8Bit().data();
+ details[1] = NULL;
+ GstInstallPluginsReturn status;
+
+ status = gst_install_plugins_async( details, ctx, pluginInstallationDone, NULL );
+ gst_install_plugins_context_free ( ctx );
+
+ if ( status != GST_INSTALL_PLUGINS_STARTED_OK )
+ {
+ if( status == GST_INSTALL_PLUGINS_HELPER_MISSING )
+ setError(QString(tr("Missing codec helper script assistant.")), Phonon::FatalError );
+ else
+ setError(QString(tr("Plugin codec installation failed for codec: %0"))
+ .arg(m_missingCodecs[0].split("|")[3]), error);
+ }
+ m_missingCodecs.clear();
+#else
+ QString codecs = m_missingCodecs.join(", ");
+
if (error == Phonon::NormalError && m_hasVideo && !m_videoStreamFound) {
m_hasVideo = false;
emit hasVideoChanged(false);
}
- QString codecs = m_missingCodecs.join(", ");
setError(QString(tr("A required codec is missing. You need to install the following codec(s) to play this content: %0")).arg(codecs), error);
m_missingCodecs.clear();
+#endif
}
}
@@ -248,7 +281,16 @@ void MediaObject::cb_unknown_type (GstElement *decodebin, GstPad *pad, GstCaps *
value = QString::fromUtf8(gst_structure_get_name (str));
}
- media->addMissingCodecName(value);
+
+#ifdef PLUGIN_INSTALL_API
+ QString plugins = QString("gstreamer|0.10|%0|%1|decoder-%2")
+ .arg( qApp->applicationName() )
+ .arg( value )
+ .arg( QString::fromUtf8(gst_caps_to_string (caps) ) );
+ media->addMissingCodecName( plugins );
+#else
+ media->addMissingCodecName( value );
+#endif
}
static void notifyVideoCaps(GObject *obj, GParamSpec *, gpointer data)
@@ -309,7 +351,7 @@ void MediaObject::connectVideo(GstPad *pad)
m_backend->logMessage("Video track connected", Backend::Info, this);
// Note that the notify::caps _must_ be installed after linking to work with Dapper
m_capsHandler = g_signal_connect(pad, "notify::caps", G_CALLBACK(notifyVideoCaps), this);
-
+
if (!m_loading && !m_hasVideo) {
m_hasVideo = m_videoStreamFound;
emit hasVideoChanged(m_hasVideo);
@@ -368,7 +410,10 @@ bool MediaObject::createPipefromURL(const QUrl &url)
}
// Create a new datasource based on the input URL
- QByteArray encoded_cstr_url = url.toEncoded();
+ // add the 'file' scheme if it's missing; the double '/' is needed!
+ QByteArray encoded_cstr_url = (url.scheme() == QLatin1String("") ?
+ "file://" + url.toEncoded() :
+ url.toEncoded());
m_datasource = gst_element_make_from_uri(GST_URI_SRC, encoded_cstr_url.constData(), (const char*)NULL);
if (!m_datasource)
return false;
@@ -388,6 +433,14 @@ bool MediaObject::createPipefromURL(const QUrl &url)
g_object_set (G_OBJECT (m_datasource), "read-speed", 2, (const char*)NULL);
m_backend->logMessage(QString("new device speed : 2X"), Backend::Info, this);
}
+ }
+
+ /* make HTTP sources send extra headers so we get icecast
+ * metadata in case the stream is an icecast stream */
+ if (encoded_cstr_url.startsWith("http://")
+ && g_object_class_find_property (G_OBJECT_GET_CLASS (m_datasource), "iradio-mode")) {
+ g_object_set (m_datasource, "iradio-mode", TRUE, NULL);
+ m_isStream = true;
}
// Link data source into pipeline
@@ -442,7 +495,7 @@ void MediaObject::createPipeline()
gst_object_ref (GST_OBJECT (m_pipeline));
gst_object_sink (GST_OBJECT (m_pipeline));
- m_decodebin = gst_element_factory_make ("decodebin", NULL);
+ m_decodebin = gst_element_factory_make ("decodebin2", NULL);
g_signal_connect (m_decodebin, "new-decoded-pad", G_CALLBACK (&cb_newpad), this);
g_signal_connect (m_decodebin, "unknown-type", G_CALLBACK (&cb_unknown_type), this);
g_signal_connect (m_decodebin, "no-more-pads", G_CALLBACK (&cb_no_more_pads), this);
@@ -646,7 +699,7 @@ void MediaObject::setState(State newstate)
m_backend->logMessage("EOS already reached", Backend::Info, this);
} else if (currentState == GST_STATE_PLAYING) {
changeState(Phonon::PlayingState);
- } else if (!m_atEndOfStream && gst_element_set_state(m_pipeline, GST_STATE_PLAYING) != GST_STATE_CHANGE_FAILURE) {
+ } else if (gst_element_set_state(m_pipeline, GST_STATE_PLAYING) != GST_STATE_CHANGE_FAILURE) {
m_pendingState = Phonon::PlayingState;
} else {
m_backend->logMessage("phonon state request failed", Backend::Info, this);
@@ -676,7 +729,7 @@ void MediaObject::changeState(State newstate)
return;
Phonon::State oldState = m_state;
- m_state = newstate; // m_state must be set before emitting, since
+ m_state = newstate; // m_state must be set before emitting, since
// Error state requires that state() will return the new value
m_pendingState = newstate;
emit stateChanged(newstate, oldState);
@@ -696,6 +749,8 @@ void MediaObject::changeState(State newstate)
case Phonon::StoppedState:
m_backend->logMessage("phonon state changed: Stopped", Backend::Info, this);
+ // We must reset the pipeline when playing again
+ m_resetNeeded = true;
m_tickTimer->stop();
break;
@@ -861,7 +916,7 @@ void MediaObject::setSource(const MediaSource &source)
// such as failing duration queries etc
GstState state;
gst_element_set_state(m_pipeline, GST_STATE_NULL);
- gst_element_get_state (m_pipeline, &state, NULL, 2000);
+ gst_element_get_state(m_pipeline, &state, NULL, 2000);
m_source = source;
emit currentSourceChanged(m_source);
@@ -871,7 +926,9 @@ void MediaObject::setSource(const MediaSource &source)
// Go into to loading state
changeState(Phonon::LoadingState);
m_loading = true;
- m_resetNeeded = false;
+ // IMPORTANT: Honor the m_resetNeeded flag as it currently stands.
+ // See https://qa.mandriva.com/show_bug.cgi?id=56807
+ //m_resetNeeded = false;
m_resumeState = false;
m_pendingState = Phonon::StoppedState;
@@ -884,8 +941,8 @@ void MediaObject::setSource(const MediaSource &source)
// Clear any existing errors
m_aboutToFinishEmitted = false;
m_error = NoError;
- m_errorString = QString();
-
+ m_errorString.clear();
+
m_bufferPercent = 0;
m_prefinishMarkReachedNotEmitted = true;
m_aboutToFinishEmitted = false;
@@ -894,22 +951,23 @@ void MediaObject::setSource(const MediaSource &source)
setTotalTime(-1);
m_atEndOfStream = false;
- // Clear exising meta tags
+ m_availableTitles = 0;
+ m_pendingTitle = 1;
+ m_currentTitle = 1;
+
+ // Clear existing meta tags
m_metaData.clear();
+ m_isStream = false;
switch (source.type()) {
- case MediaSource::Url: {
- if (createPipefromURL(source.url()))
- m_loading = true;
- else
+ case MediaSource::Url: {
+ if (!createPipefromURL(source.url()))
setError(tr("Could not open media source."));
}
break;
case MediaSource::LocalFile: {
- if (createPipefromURL(QUrl::fromLocalFile(source.fileName())))
- m_loading = true;
- else
+ if (!createPipefromURL(QUrl::fromLocalFile(source.fileName())))
setError(tr("Could not open media source."));
}
break;
@@ -922,17 +980,15 @@ void MediaObject::setSource(const MediaSource &source)
break;
case MediaSource::Stream:
- if (createPipefromStream(source))
- m_loading = true;
- else
+ if (!createPipefromStream(source))
setError(tr("Could not open media source."));
break;
case MediaSource::Disc:
{
- QString mediaUrl;
- switch (source.discType()) {
- case Phonon::NoDisc:
+ QString mediaUrl;
+ switch (source.discType()) {
+ case Phonon::NoDisc:
qWarning() << "I should never get to see a MediaSource that is a disc but doesn't specify which one";
return;
case Phonon::Cd: // CD tracks can be specified by setting the url in the following way uri=cdda:4
@@ -948,9 +1004,7 @@ void MediaObject::setSource(const MediaSource &source)
qWarning() << "media " << source.discType() << " not implemented";
return;
}
- if (!mediaUrl.isEmpty() && createPipefromURL(QUrl(mediaUrl)))
- m_loading = true;
- else
+ if (mediaUrl.isEmpty() || !createPipefromURL(QUrl(mediaUrl)))
setError(tr("Could not open media source."));
}
break;
@@ -966,8 +1020,7 @@ void MediaObject::setSource(const MediaSource &source)
// We need to link this node to ensure that fake sinks are connected
// before loading, otherwise the stream will be blocked
- if (m_loading)
- link();
+ link();
beginLoad();
}
@@ -1004,22 +1057,22 @@ void MediaObject::getStreamInfo()
emit hasVideoChanged(m_hasVideo);
}
- m_availableTitles = 1;
- gint64 titleCount;
- GstFormat format = gst_format_get_by_nick("track");
- if (gst_element_query_duration (m_pipeline, &format, &titleCount)) {
+ if (m_source.discType() == Phonon::Cd) {
+ gint64 titleCount;
+ GstFormat format = gst_format_get_by_nick("track");
+ if (gst_element_query_duration (m_pipeline, &format, &titleCount)) {
//check if returned format is still "track",
//gstreamer sometimes returns the total time, if tracks information is not available.
- if (qstrcmp(gst_format_get_name(format), "track") == 0) {
- int oldAvailableTitles = m_availableTitles;
- m_availableTitles = (int)titleCount;
- if (m_availableTitles != oldAvailableTitles) {
- emit availableTitlesChanged(m_availableTitles);
- m_backend->logMessage(QString("Available titles changed: %0").arg(m_availableTitles), Backend::Info, this);
+ if (qstrcmp(gst_format_get_name(format), "track") == 0) {
+ int oldAvailableTitles = m_availableTitles;
+ m_availableTitles = (int)titleCount;
+ if (m_availableTitles != oldAvailableTitles) {
+ emit availableTitlesChanged(m_availableTitles);
+ m_backend->logMessage(QString("Available titles changed: %0").arg(m_availableTitles), Backend::Info, this);
+ }
}
}
}
-
}
void MediaObject::setPrefinishMark(qint32 newPrefinishMark)
@@ -1077,7 +1130,7 @@ void MediaObject::seek(qint64 time)
}
quint64 current = currentTime();
- quint64 total = totalTime();
+ quint64 total = totalTime();
if (current < total - m_prefinishMark)
m_prefinishMarkReachedNotEmitted = true;
@@ -1098,7 +1151,7 @@ void MediaObject::emitTick()
if (m_tickInterval > 0 && currentTime != m_previousTickTime) {
emit tick(currentTime);
- m_previousTickTime = currentTime;
+ m_previousTickTime = currentTime;
}
if (m_state == Phonon::PlayingState) {
if (currentTime >= totalTime - m_prefinishMark) {
@@ -1109,7 +1162,12 @@ void MediaObject::emitTick()
}
// Prepare load of next source
if (currentTime >= totalTime - ABOUT_TO_FINNISH_TIME) {
- if (!m_aboutToFinishEmitted) {
+ if (m_source.type() == MediaSource::Disc &&
+ m_autoplayTitles &&
+ m_availableTitles > 1 &&
+ m_currentTitle < m_availableTitles) {
+ m_aboutToFinishEmitted = false;
+ } else if (!m_aboutToFinishEmitted) {
m_aboutToFinishEmitted = true; // track is about to finish
emit aboutToFinish();
}
@@ -1213,8 +1271,8 @@ void MediaObject::handleBusMessage(const Message &message)
switch (GST_MESSAGE_TYPE (gstMessage)) {
- case GST_MESSAGE_EOS:
- m_backend->logMessage("EOS recieved", Backend::Info, this);
+ case GST_MESSAGE_EOS:
+ m_backend->logMessage("EOS received", Backend::Info, this);
handleEndOfStream();
break;
@@ -1222,14 +1280,98 @@ void MediaObject::handleBusMessage(const Message &message)
GstTagList* tag_list = 0;
gst_message_parse_tag(gstMessage, &tag_list);
if (tag_list) {
+ TagMap newTags;
+ gst_tag_list_foreach (tag_list, &foreach_tag_function, &newTags);
+ gst_tag_list_free(tag_list);
+
+ // Determine if we should no fake the album/artist tags.
+ // This is a little confusing as we want to fake it on initial
+ // connection where title, album and artist are all missing.
+ // There are however times when we get just other information,
+ // e.g. codec, and so we want to only do clever stuff if we
+ // have a commonly available tag (ORGANIZATION) or we have a
+ // change in title
+ bool fake_it =
+ (m_isStream
+ && ((!newTags.contains("TITLE")
+ && newTags.contains("ORGANIZATION"))
+ || (newTags.contains("TITLE")
+ && m_metaData.value("TITLE") != newTags.value("TITLE")))
+ && !newTags.contains("ALBUM")
+ && !newTags.contains("ARTIST"));
+
TagMap oldMap = m_metaData; // Keep a copy of the old one for reference
- // Append any new meta tags to the existing tag list
- gst_tag_list_foreach (tag_list, &foreach_tag_function, &m_metaData);
+
+ // Now we've checked the new data, append any new meta tags to the existing tag list
+ // We cannot use TagMap::iterator as this is a multimap and when streaming data
+ // could in theory be lost.
+ QList<QString> keys = newTags.keys();
+ for (QList<QString>::iterator i = keys.begin(); i != keys.end(); ++i) {
+ QString key = *i;
+ if (m_isStream) {
+ // If we're streaming, we need to remove data in m_metaData
+ // in order to stop it filling up indefinitely (as it's a multimap)
+ m_metaData.remove(key);
+ }
+ QList<QString> values = newTags.values(key);
+ for (QList<QString>::iterator j = values.begin(); j != values.end(); ++j) {
+ QString value = *j;
+ QString currVal = m_metaData.value(key);
+ if (!m_metaData.contains(key) || currVal != value) {
+ m_metaData.insert(key, value);
+ }
+ }
+ }
+
m_backend->logMessage("Meta tags found", Backend::Info, this);
- if (oldMap != m_metaData && !m_loading)
- emit metaDataChanged(m_metaData);
- gst_tag_list_free(tag_list);
- }
+ if (oldMap != m_metaData) {
+ // This is a bit of a hack to ensure that stream metadata is
+ // returned. We get as much as we can from the Shoutcast server's
+ // StreamTitle= header. If further info is decoded from the stream
+ // itself later, then it will overwrite this info.
+ if (m_isStream && fake_it) {
+ m_metaData.remove("ALBUM");
+ m_metaData.remove("ARTIST");
+
+ // Detect whether we want to "fill in the blanks"
+ QString str;
+ if (m_metaData.contains("TITLE"))
+ {
+ str = m_metaData.value("TITLE");
+ int splitpoint;
+ // Check to see if our title matches "%s - %s"
+ // Where neither %s are empty...
+ if ((splitpoint = str.indexOf(" - ")) > 0
+ && str.size() > (splitpoint+3)) {
+ m_metaData.insert("ARTIST", str.left(splitpoint));
+ m_metaData.replace("TITLE", str.mid(splitpoint+3));
+ }
+ } else {
+ str = m_metaData.value("GENRE");
+ if (!str.isEmpty())
+ m_metaData.insert("TITLE", str);
+ else
+ m_metaData.insert("TITLE", "Streaming Data");
+ }
+ if (!m_metaData.contains("ARTIST")) {
+ str = m_metaData.value("LOCATION");
+ if (!str.isEmpty())
+ m_metaData.insert("ARTIST", str);
+ else
+ m_metaData.insert("ARTIST", "Streaming Data");
+ }
+ str = m_metaData.value("ORGANIZATION");
+ if (!str.isEmpty())
+ m_metaData.insert("ALBUM", str);
+ else
+ m_metaData.insert("ALBUM", "Streaming Data");
+ }
+ // As we manipulate the title, we need to recompare
+ // oldMap and m_metaData here...
+ if (oldMap != m_metaData && !m_loading)
+ emit metaDataChanged(m_metaData);
+ }
+ }
}
break;
@@ -1255,6 +1397,9 @@ void MediaObject::handleBusMessage(const Message &message)
m_backend->logMessage("gstreamer: pipeline state set to playing", Backend::Info, this);
m_tickTimer->start();
changeState(Phonon::PlayingState);
+ if ((m_source.type() == MediaSource::Disc) && (m_currentTitle != m_pendingTitle)) {
+ setTrack(m_pendingTitle);
+ }
if (m_resumeState && m_oldState == Phonon::PlayingState) {
seek(m_oldPos);
m_resumeState = false;
@@ -1290,6 +1435,9 @@ void MediaObject::handleBusMessage(const Message &message)
changeState(Phonon::StoppedState);
m_backend->logMessage("gstreamer: pipeline state set to ready", Backend::Debug, this);
m_tickTimer->stop();
+ if ((m_source.type() == MediaSource::Disc) && (m_currentTitle != m_pendingTitle)) {
+ setTrack(m_pendingTitle);
+ }
break;
case GST_STATE_VOID_PENDING :
@@ -1328,7 +1476,7 @@ void MediaObject::handleBusMessage(const Message &message)
setError(err->message, Phonon::FatalError);
gst_caps_unref (caps);
gst_object_unref (sinkPad);
- }
+ }
} else {
setError(QString(err->message), Phonon::FatalError);
}
@@ -1400,8 +1548,8 @@ void MediaObject::handleBusMessage(const Message &message)
//case GST_MESSAGE_STEP_DONE:
//case GST_MESSAGE_LATENCY: only from 0.10.12
//case GST_MESSAGE_ASYNC_DONE: only from 0.10.13
- default:
- break;
+ default:
+ break;
}
}
@@ -1417,7 +1565,8 @@ void MediaObject::handleEndOfStream()
if (!m_seekable)
m_atEndOfStream = true;
- if (m_autoplayTitles &&
+ if (m_source.type() == MediaSource::Disc &&
+ m_autoplayTitles &&
m_availableTitles > 1 &&
m_currentTitle < m_availableTitles) {
_iface_setCurrentTitle(m_currentTitle + 1);
@@ -1444,6 +1593,14 @@ void MediaObject::handleEndOfStream()
}
}
+void MediaObject::invalidateGraph()
+{
+ m_resetNeeded = true;
+ if (m_state == Phonon::PlayingState || m_state == Phonon::PausedState) {
+ changeState(Phonon::StoppedState);
+ }
+}
+
// Notifes the pipeline about state changes in the media object
void MediaObject::notifyStateChange(Phonon::State newstate, Phonon::State oldstate)
{
@@ -1502,15 +1659,30 @@ int MediaObject::_iface_currentTitle() const
void MediaObject::_iface_setCurrentTitle(int title)
{
- GstFormat trackFormat = gst_format_get_by_nick("track");
m_backend->logMessage(QString("setCurrentTitle %0").arg(title), Backend::Info, this);
- if ((title == m_currentTitle) || (title < 1) || (title > m_availableTitles))
+ if ((title == m_currentTitle) || (title == m_pendingTitle))
+ return;
+
+ m_pendingTitle = title;
+
+ if (m_state == Phonon::PlayingState || m_state == Phonon::StoppedState) {
+ setTrack(m_pendingTitle);
+ } else {
+ setState(Phonon::StoppedState);
+ }
+}
+
+void MediaObject::setTrack(int title)
+{
+ if (((m_state != Phonon::PlayingState) && (m_state != Phonon::StoppedState)) || (title < 1) || (title > m_availableTitles))
return;
- m_currentTitle = title;
//let's seek to the beginning of the song
- if (gst_element_seek_simple(m_pipeline, trackFormat, GST_SEEK_FLAG_FLUSH, m_currentTitle - 1)) {
+ GstFormat trackFormat = gst_format_get_by_nick("track");
+ m_backend->logMessage(QString("setTrack %0").arg(title), Backend::Info, this);
+ if (gst_element_seek_simple(m_pipeline, trackFormat, GST_SEEK_FLAG_FLUSH, title - 1)) {
+ m_currentTitle = title;
updateTotalTime();
m_atEndOfStream = false;
emit titleChanged(title);
diff --git a/src/3rdparty/phonon/gstreamer/mediaobject.h b/src/3rdparty/phonon/gstreamer/mediaobject.h
index 64b3510..d588ffc 100644
--- a/src/3rdparty/phonon/gstreamer/mediaobject.h
+++ b/src/3rdparty/phonon/gstreamer/mediaobject.h
@@ -55,6 +55,7 @@ class MediaObject : public QObject, public MediaObjectInterface
, public MediaNode
{
friend class Stream;
+ friend class AudioDataOutput;
Q_OBJECT
Q_INTERFACES(Phonon::MediaObjectInterface
#ifndef QT_NO_PHONON_MEDIACONTROLLER
@@ -144,12 +145,8 @@ public:
void handleBusMessage(const Message &msg);
void handleEndOfStream();
void addMissingCodecName(const QString &codec) { m_missingCodecs.append(codec); }
- void invalidateGraph() {
- m_resetNeeded = true;
- if (m_state == Phonon::PlayingState || m_state == Phonon::PausedState) {
- changeState(Phonon::StoppedState);
- }
- }
+ void invalidateGraph();
+
static void cb_newpad (GstElement *decodebin, GstPad *pad, gboolean last, gpointer data);
static void cb_pad_added (GstElement *decodebin, GstPad *pad, gpointer data);
static void cb_unknown_type (GstElement *decodebin, GstPad *pad, GstCaps *caps, gpointer data);
@@ -236,6 +233,7 @@ private:
int _iface_availableTitles() const;
int _iface_currentTitle() const;
void _iface_setCurrentTitle(int title);
+ void setTrack(int title);
bool m_resumeState;
State m_oldState;
@@ -250,6 +248,7 @@ private:
MediaSource m_nextSource;
qint32 m_prefinishMark;
qint32 m_transitionTime;
+ bool m_isStream;
qint64 m_posAtSeek;
@@ -285,6 +284,7 @@ private:
bool m_autoplayTitles;
int m_availableTitles;
int m_currentTitle;
+ int m_pendingTitle;
};
}
} //namespace Phonon::Gstreamer
diff --git a/src/3rdparty/phonon/gstreamer/qwidgetvideosink.h b/src/3rdparty/phonon/gstreamer/qwidgetvideosink.h
index 73a494a..f83dba5 100644
--- a/src/3rdparty/phonon/gstreamer/qwidgetvideosink.h
+++ b/src/3rdparty/phonon/gstreamer/qwidgetvideosink.h
@@ -19,6 +19,7 @@
#define Phonon_GSTREAMER_VIDEOSINK_H
#include "common.h"
+#include "qwidgetvideosink.h"
#include <QtCore/QByteArray>
#include <QtCore/QEvent>
diff --git a/src/3rdparty/phonon/gstreamer/videowidget.h b/src/3rdparty/phonon/gstreamer/videowidget.h
index dc0754d..8603f6a 100644
--- a/src/3rdparty/phonon/gstreamer/videowidget.h
+++ b/src/3rdparty/phonon/gstreamer/videowidget.h
@@ -25,6 +25,7 @@
#include "common.h"
#include "medianode.h"
#include "abstractrenderer.h"
+#include "videowidget.h"
#include <gst/gst.h>
diff --git a/src/3rdparty/phonon/gstreamer/x11renderer.cpp b/src/3rdparty/phonon/gstreamer/x11renderer.cpp
index 73877a8..968f3a8 100644
--- a/src/3rdparty/phonon/gstreamer/x11renderer.cpp
+++ b/src/3rdparty/phonon/gstreamer/x11renderer.cpp
@@ -90,7 +90,7 @@ GstElement* X11Renderer::createVideoSink()
gst_object_unref(GST_OBJECT(videoSink));
videoSink = 0;
} else {
- // Note that this should not really be neccessary as these are
+ // Note that this should not really be necessary as these are
// default values, though under certain conditions values are retained
// even between application instances. (reproducible on 0.10.16/Gutsy)
g_object_set(G_OBJECT(videoSink), "brightness", 0, (const char*)NULL);
@@ -138,6 +138,7 @@ void X11Renderer::scaleModeChanged(Phonon::VideoWidget::ScaleMode)
void X11Renderer::movieSizeChanged(const QSize &movieSize)
{
Q_UNUSED(movieSize);
+
if (m_renderWidget) {
m_renderWidget->setGeometry(m_videoWidget->calculateDrawFrameRect());
}
diff --git a/src/3rdparty/phonon/phonon/CMakeLists.txt b/src/3rdparty/phonon/phonon/CMakeLists.txt
index 11d7913..ace934a 100644
--- a/src/3rdparty/phonon/phonon/CMakeLists.txt
+++ b/src/3rdparty/phonon/phonon/CMakeLists.txt
@@ -8,6 +8,30 @@ endif (PHONON_BUILD_EXAMPLES)
add_subdirectory(experimental)
+set(PULSEAUDIO_MINIMUM_VERSION "0.9.15")
+macro_optional_find_package(PulseAudio)
+if (PULSEAUDIO_FOUND)
+ # PULSEAUDIO_DEVICE_MANAGER feature check could be moved to FindPulseAudio.cmake, hint hint. -- Rex
+ macro_ensure_version("0.9.21" "${PULSEAUDIO_VERSION}" PULSEAUDIO_DEVICE_MANAGER)
+endif (PULSEAUDIO_FOUND)
+macro_log_feature(PULSEAUDIO_FOUND "PulseAudio" "A cross-platform, networked sound server." "http://www.pulseaudio.org" FALSE "" "Allows audio playback via the PulseAudio soundserver when it is running")
+macro_optional_find_package(GLIB2)
+macro_log_feature(GLIB2_FOUND "GLib2" "GLib 2 is required to compile the pulseaudio for Phonon" "http://www.gtk.org/download/" FALSE)
+
+
+if (GLIB2_FOUND AND PULSEAUDIO_FOUND)
+ add_definitions(-DHAVE_PULSEAUDIO)
+ include_directories(${GLIB2_INCLUDE_DIR} ${PULSEAUDIO_INCLUDE_DIR})
+ if (PULSEAUDIO_DEVICE_MANAGER)
+ add_definitions(-DHAVE_PULSEAUDIO_DEVICE_MANAGER)
+ endif(PULSEAUDIO_DEVICE_MANAGER)
+else(GLIB2_FOUND AND PULSEAUDIO_FOUND)
+ set(PULSEAUDIO_INCLUDE_DIR "")
+ set(PULSEAUDIO_LIBRARY "")
+ set(PULSEAUDIO_MAINLOOP_LIBRARY "")
+endif(GLIB2_FOUND AND PULSEAUDIO_FOUND)
+
+
set(phonon_LIB_SRCS
objectdescription.cpp
objectdescriptionmodel.cpp
@@ -35,9 +59,12 @@ set(phonon_LIB_SRCS
videowidget.cpp
videoplayer.cpp
seekslider.cpp
+ swiftslider.cpp
volumeslider.cpp
effectwidget.cpp
iodevicestream.cpp
+ audiodataoutput.cpp
+ pulsesupport.cpp
)
if (QT_QTDBUS_FOUND)
@@ -50,6 +77,10 @@ endif (QT_QTDBUS_FOUND)
add_definitions(-DPHONON_LIBRARY_PATH="${PLUGIN_INSTALL_DIR}/plugins")
automoc4_add_library(phonon SHARED ${phonon_LIB_SRCS})
target_link_libraries(phonon ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
+if (GLIB2_FOUND AND PULSEAUDIO_FOUND)
+target_link_libraries(phonon ${GLIB2_LIBRARIES} ${GOBJECT_LIBRARIES} ${PULSEAUDIO_LIBRARY} ${PULSEAUDIO_MAINLOOP_LIBRARY})
+endif (GLIB2_FOUND AND PULSEAUDIO_FOUND)
+
if (QT_QTDBUS_FOUND)
target_link_libraries(phonon ${QT_QTDBUS_LIBRARY})
endif (QT_QTDBUS_FOUND)
@@ -99,6 +130,10 @@ install(FILES
volumeslider.h
effectwidget.h
platformplugin.h
+ audiodataoutput.h
+ audiodataoutputinterface.h
+ globalconfig.h
+ pulsesupport.h
DESTINATION ${INCLUDE_INSTALL_DIR}/phonon COMPONENT Devel)
install(FILES org.kde.Phonon.AudioOutput.xml DESTINATION ${DBUS_INTERFACES_INSTALL_DIR})
diff --git a/src/3rdparty/phonon/phonon/audiodataoutput.cpp b/src/3rdparty/phonon/phonon/audiodataoutput.cpp
new file mode 100644
index 0000000..3a7d3a1
--- /dev/null
+++ b/src/3rdparty/phonon/phonon/audiodataoutput.cpp
@@ -0,0 +1,66 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005 Matthias Kretz <kretz@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), Nokia Corporation
+ (or its successors, if any) and the KDE Free Qt Foundation, which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "audiodataoutput.h"
+#include "audiodataoutput_p.h"
+#include "factory_p.h"
+
+#define PHONON_CLASSNAME AudioDataOutput
+
+namespace Phonon
+{
+
+PHONON_HEIR_IMPL(AbstractAudioOutput)
+
+PHONON_GETTER(int, dataSize, d->dataSize)
+PHONON_GETTER(int, sampleRate, -1)
+PHONON_SETTER(setDataSize, dataSize, int)
+
+bool AudioDataOutputPrivate::aboutToDeleteBackendObject()
+{
+ Q_ASSERT(m_backendObject);
+ pBACKEND_GET(int, dataSize, "dataSize");
+
+ return AbstractAudioOutputPrivate::aboutToDeleteBackendObject();
+}
+
+void AudioDataOutputPrivate::setupBackendObject()
+{
+ Q_Q(AudioDataOutput);
+ Q_ASSERT(m_backendObject);
+ AbstractAudioOutputPrivate::setupBackendObject();
+
+ // set up attributes
+ pBACKEND_CALL1("setDataSize", int, dataSize);
+
+ qRegisterMetaType<QMap<Phonon::AudioDataOutput::Channel, QVector<qint16> > >("QMap<Phonon::AudioDataOutput::Channel, QVector<qint16> >");
+
+ QObject::connect(m_backendObject,
+ SIGNAL(dataReady(const QMap<Phonon::AudioDataOutput::Channel, QVector<qint16> > &)),
+ q, SIGNAL(dataReady(const QMap<Phonon::AudioDataOutput::Channel, QVector<qint16> > &)));
+ QObject::connect(m_backendObject, SIGNAL(endOfMedia(int)), q, SIGNAL(endOfMedia(int)));
+}
+
+} // namespace Phonon
+
+#undef PHONON_CLASSNAME
+// vim: sw=4 ts=4 tw=80
diff --git a/src/3rdparty/phonon/phonon/audiodataoutput.h b/src/3rdparty/phonon/phonon/audiodataoutput.h
new file mode 100644
index 0000000..8e8f8e0
--- /dev/null
+++ b/src/3rdparty/phonon/phonon/audiodataoutput.h
@@ -0,0 +1,129 @@
+/* This file is part of the KDE project
+ Copyright (C) 2005-2006 Matthias Kretz <kretz@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), Nokia Corporation
+ (or its successors, if any) and the KDE Free Qt Foundation, which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+#ifndef Phonon_AUDIODATAOUTPUT_H
+#define Phonon_AUDIODATAOUTPUT_H
+
+#include "phonon_export.h"
+#include "abstractaudiooutput.h"
+#include "phonondefs.h"
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+template<typename T> class QVector;
+template<typename Key, typename T> class QMap;
+#endif
+
+namespace Phonon
+{
+ class AudioDataOutputPrivate;
+
+ /**
+ * \short This class gives you the audio data (for visualizations).
+ *
+ * This class implements a special AbstractAudioOutput that gives your
+ * application the audio data. Don't expect realtime performance. But
+ * the latencies should be low enough to use the audio data for
+ * visualizations. You can also use the audio data for further processing
+ * (e.g. encoding and saving to a file).
+ *
+ * \author Matthias Kretz <kretz@kde.org>
+ */
+ class PHONON_EXPORT AudioDataOutput : public AbstractAudioOutput
+ {
+ Q_OBJECT
+ K_DECLARE_PRIVATE(AudioDataOutput)
+ Q_ENUMS(Channel)
+ Q_PROPERTY(int dataSize READ dataSize WRITE setDataSize)
+ PHONON_HEIR(AudioDataOutput)
+ public:
+ /**
+ * Specifies the channel the audio data belongs to.
+ */
+ enum Channel
+ {
+ LeftChannel,
+ RightChannel,
+ CenterChannel,
+ LeftSurroundChannel,
+ RightSurroundChannel,
+ SubwooferChannel
+ };
+
+ /**
+ * Returns the currently used number of samples passed through
+ * the signal.
+ *
+ * \see setDataSize
+ */
+ int dataSize() const;
+
+ /**
+ * Returns the sample rate in Hz. Common sample rates are 44100 Hz
+ * and 48000 Hz. AudioDataOutput will not do any sample rate
+ * conversion for you. If you need to convert the sample rate you
+ * might want to take a look at libsamplerate. For visualizations it
+ * is often enough to do simple interpolation or even drop/duplicate
+ * samples.
+ *
+ * \return The sample rate as reported by the backend. If the
+ * backend is unavailable -1 is returned.
+ */
+ int sampleRate() const;
+
+ public Q_SLOTS:
+ /**
+ * Sets the number of samples to be passed in one signal emission.
+ *
+ * Defaults to 512 samples per emitted signal.
+ *
+ * \param size the number of samples
+ */
+ void setDataSize(int size);
+
+ Q_SIGNALS:
+ /**
+ * Emitted whenever another dataSize number of samples are ready.
+ *
+ * \param data A mapping of Channel to a vector holding the audio data.
+ */
+ void dataReady(const QMap<Phonon::AudioDataOutput::Channel, QVector<qint16> > &data);
+
+
+ /**
+ * This signal is emitted before the last dataReady signal of a
+ * media is emitted.
+ *
+ * If, for example, the playback of a media file has finished and the
+ * last audio data of that file is going to be passed with the next
+ * dataReady signal, and only the 28 first samples of the data
+ * vector are from that media file endOfMedia will be emitted right
+ * before dataReady with \p remainingSamples = 28.
+ *
+ * \param remainingSamples The number of samples in the next
+ * dataReady vector that belong to the media that was playing to
+ * this point.
+ */
+ void endOfMedia(int remainingSamples);
+ };
+} // namespace Phonon
+
+// vim: sw=4 ts=4 tw=80
+#endif // Phonon_AUDIODATAOUTPUT_H
diff --git a/src/3rdparty/phonon/phonon/audiodataoutput_p.h b/src/3rdparty/phonon/phonon/audiodataoutput_p.h
new file mode 100644
index 0000000..91103a9
--- /dev/null
+++ b/src/3rdparty/phonon/phonon/audiodataoutput_p.h
@@ -0,0 +1,48 @@
+/* This file is part of the KDE project
+ Copyright (C) 2006 Matthias Kretz <kretz@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), Nokia Corporation
+ (or its successors, if any) and the KDE Free Qt Foundation, which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef AUDIODATAOUTPUT_P_H
+#define AUDIODATAOUTPUT_P_H
+
+#include "audiodataoutput.h"
+#include "abstractaudiooutput_p.h"
+
+namespace Phonon
+{
+
+class AudioDataOutputPrivate : public AbstractAudioOutputPrivate
+{
+ Q_DECLARE_PUBLIC(AudioDataOutput)
+ PHONON_PRIVATECLASS
+ protected:
+ AudioDataOutputPrivate()
+ : dataSize(512)
+ {
+ }
+
+ int dataSize;
+};
+
+} // namespace Phonon
+
+#endif // AUDIODATAOUTPUT_P_H
+// vim: sw=4 ts=4 tw=80
diff --git a/src/3rdparty/phonon/phonon/audiodataoutputinterface.h b/src/3rdparty/phonon/phonon/audiodataoutputinterface.h
new file mode 100644
index 0000000..bc1aad0
--- /dev/null
+++ b/src/3rdparty/phonon/phonon/audiodataoutputinterface.h
@@ -0,0 +1,44 @@
+/* This file is part of the KDE project
+ Copyright (C) 2008 Matthias Kretz <kretz@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), Nokia Corporation
+ (or its successors, if any) and the KDE Free Qt Foundation, which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef PHONON_AUDIODATAOUTPUTINTERFACE_H
+#define PHONON_AUDIODATAOUTPUTINTERFACE_H
+
+namespace Phonon
+{
+
+class AudioDataOutput;
+
+class AudioDataOutputInterface
+{
+ public:
+ virtual ~AudioDataOutputInterface() {}
+
+ virtual AudioDataOutput *frontendObject() const = 0;
+ virtual void setFrontendObject(AudioDataOutput *) = 0;
+};
+
+} // namespace Phonon
+
+Q_DECLARE_INTERFACE(Phonon::AudioDataOutputInterface, "0AudioDataOutputInterface.phonon.kde.org")
+
+#endif // PHONON_AUDIODATAOUTPUTINTERFACE_H
diff --git a/src/3rdparty/phonon/phonon/audiooutput.cpp b/src/3rdparty/phonon/phonon/audiooutput.cpp
index 0f6a49b..e94caad 100644
--- a/src/3rdparty/phonon/phonon/audiooutput.cpp
+++ b/src/3rdparty/phonon/phonon/audiooutput.cpp
@@ -24,12 +24,14 @@
#include "factory_p.h"
#include "objectdescription.h"
#include "audiooutputadaptor_p.h"
-#include "globalconfig_p.h"
+#include "globalconfig.h"
#include "audiooutputinterface.h"
#include "phononnamespace_p.h"
#include "platform_p.h"
+#include "pulsesupport.h"
#include <QtCore/qmath.h>
+#include <QtCore/quuid.h>
#define PHONON_CLASSNAME AudioOutput
#define IFACES2 AudioOutputInterface42
@@ -42,8 +44,12 @@ QT_BEGIN_NAMESPACE
namespace Phonon
{
-static inline bool callSetOutputDevice(MediaNodePrivate *const d, int index)
+static inline bool callSetOutputDevice(AudioOutputPrivate *const d, int index)
{
+ PulseSupport *pulse = PulseSupport::getInstance();
+ if (pulse->isActive())
+ return pulse->setOutputDevice(d->getStreamUuid(), index);
+
Iface<IFACES2> iface(d);
if (iface) {
return iface->setOutputDevice(AudioOutputDevice::fromIndex(index));
@@ -51,8 +57,12 @@ static inline bool callSetOutputDevice(MediaNodePrivate *const d, int index)
return Iface<IFACES0>::cast(d)->setOutputDevice(index);
}
-static inline bool callSetOutputDevice(MediaNodePrivate *const d, const AudioOutputDevice &dev)
+static inline bool callSetOutputDevice(AudioOutputPrivate *const d, const AudioOutputDevice &dev)
{
+ PulseSupport *pulse = PulseSupport::getInstance();
+ if (pulse->isActive())
+ return pulse->setOutputDevice(d->getStreamUuid(), dev.index());
+
Iface<IFACES2> iface(d);
if (iface) {
return iface->setOutputDevice(dev);
@@ -89,16 +99,20 @@ void AudioOutputPrivate::init(Phonon::Category c)
#endif
category = c;
-
- // select hardware device according to the category
- device = AudioOutputDevice::fromIndex(GlobalConfig().audioOutputDeviceFor(category, GlobalConfig::AdvancedDevicesFromSettings | GlobalConfig::HideUnavailableDevices));
+ streamUuid = QUuid::createUuid().toString();
+ PulseSupport *pulse = PulseSupport::getInstance();
+ pulse->setStreamPropList(category, streamUuid);
+ q->connect(pulse, SIGNAL(usingDevice(QString,int)), SLOT(_k_deviceChanged(QString,int)));
createBackendObject();
q->connect(Factory::sender(), SIGNAL(availableAudioOutputDevicesChanged()), SLOT(_k_deviceListChanged()));
}
-
+QString AudioOutputPrivate::getStreamUuid()
+{
+ return streamUuid;
+}
void AudioOutputPrivate::createBackendObject()
{
@@ -106,6 +120,7 @@ void AudioOutputPrivate::createBackendObject()
return;
Q_Q(AudioOutput);
m_backendObject = Factory::createAudioOutput(q);
+ device = AudioOutputDevice::fromIndex(GlobalConfig().audioOutputDeviceFor(category, GlobalConfig::AdvancedDevicesFromSettings | GlobalConfig::HideUnavailableDevices));
if (m_backendObject) {
setupBackendObject();
}
@@ -220,21 +235,21 @@ bool AudioOutput::setOutputDevice(const AudioOutputDevice &newAudioOutputDevice)
{
K_D(AudioOutput);
if (!newAudioOutputDevice.isValid()) {
- d->outputDeviceOverridden = false;
+ d->outputDeviceOverridden = d->forceMove = false;
const int newIndex = GlobalConfig().audioOutputDeviceFor(d->category);
if (newIndex == d->device.index()) {
return true;
}
d->device = AudioOutputDevice::fromIndex(newIndex);
} else {
- d->outputDeviceOverridden = true;
+ d->outputDeviceOverridden = d->forceMove = true;
if (d->device == newAudioOutputDevice) {
return true;
}
d->device = newAudioOutputDevice;
}
if (k_ptr->backendObject()) {
- return callSetOutputDevice(k_ptr, d->device.index());
+ return callSetOutputDevice(d, d->device.index());
}
return true;
}
@@ -261,7 +276,10 @@ void AudioOutputPrivate::setupBackendObject()
#ifndef QT_NO_PHONON_SETTINGSGROUP
// if the output device is not available and the device was not explicitly set
- if (!callSetOutputDevice(this, device) && !outputDeviceOverridden) {
+ // There is no need to set the output device initially if PA is used as
+ // we know it will not work (stream doesn't exist yet) and that this will be
+ // handled by _k_deviceChanged()
+ if (!PulseSupport::getInstance()->isActive() && !callSetOutputDevice(this, device) && !outputDeviceOverridden) {
// fall back in the preference list of output devices
QList<int> deviceList = GlobalConfig().audioOutputDeviceListFor(category, GlobalConfig::AdvancedDevicesFromSettings | GlobalConfig::HideUnavailableDevices);
if (deviceList.isEmpty()) {
@@ -306,10 +324,14 @@ void AudioOutputPrivate::_k_revertFallback()
void AudioOutputPrivate::_k_audioDeviceFailed()
{
+ if (PulseSupport::getInstance()->isActive())
+ return;
+
+#ifndef QT_NO_PHONON_SETTINGSGROUP
+
pDebug() << Q_FUNC_INFO;
// outputDeviceIndex identifies a failing device
// fall back in the preference list of output devices
-#ifndef QT_NO_PHONON_SETTINGSGROUP
const QList<int> deviceList = GlobalConfig().audioOutputDeviceListFor(category, GlobalConfig::AdvancedDevicesFromSettings | GlobalConfig::HideUnavailableDevices);
for (int i = 0; i < deviceList.count(); ++i) {
const int devIndex = deviceList.at(i);
@@ -331,8 +353,15 @@ void AudioOutputPrivate::_k_audioDeviceFailed()
void AudioOutputPrivate::_k_deviceListChanged()
{
- pDebug() << Q_FUNC_INFO;
+ if (PulseSupport::getInstance()->isActive())
+ return;
+
#ifndef QT_NO_PHONON_SETTINGSGROUP
+ pDebug() << Q_FUNC_INFO;
+ // Check to see if we have an override and do not change to a higher priority device if the overridden device is still present.
+ if (outputDeviceOverridden && device.property("available").toBool()) {
+ return;
+ }
// let's see if there's a usable device higher in the preference list
const QList<int> deviceList = GlobalConfig().audioOutputDeviceListFor(category, GlobalConfig::AdvancedDevicesFromSettings);
DeviceChangeType changeType = HigherPreferenceChange;
@@ -361,6 +390,36 @@ void AudioOutputPrivate::_k_deviceListChanged()
#endif //QT_NO_PHONON_SETTINGSGROUP
}
+void AudioOutputPrivate::_k_deviceChanged(QString inStreamUuid, int deviceIndex)
+{
+ // Note that this method is only used by PulseAudio at present.
+ if (inStreamUuid == streamUuid) {
+ // 1. Check to see if we are overridden. If we are, and devices do not match,
+ // then try and apply our own device as the output device.
+ // We only do this the first time
+ if (outputDeviceOverridden && forceMove) {
+ forceMove = false;
+ const AudioOutputDevice &currentDevice = AudioOutputDevice::fromIndex(deviceIndex);
+ if (currentDevice != device) {
+ if (!callSetOutputDevice(this, device)) {
+ // What to do if we are overridden and cannot change to our preferred device?
+ }
+ }
+ }
+ // 2. If we are not overridden, then we need to update our perception of what
+ // device we are using. If the devices do not match, something lower in the
+ // stack is overriding our preferences (e.g. a per-application stream preference,
+ // specific application move, priority list changed etc. etc.)
+ else if (!outputDeviceOverridden) {
+ const AudioOutputDevice &currentDevice = AudioOutputDevice::fromIndex(deviceIndex);
+ if (currentDevice != device) {
+ // The device is not what we think it is, so lets say what is happening.
+ handleAutomaticDeviceChange(currentDevice, SoundSystemChange);
+ }
+ }
+ }
+}
+
static struct
{
int first;
@@ -405,11 +464,33 @@ void AudioOutputPrivate::handleAutomaticDeviceChange(const AudioOutputDevice &de
g_lastFallback.second = 0;
}
break;
+ case SoundSystemChange:
+ {
+#ifndef QT_NO_PHONON_PLATFORMPLUGIN
+ if (device1.property("available").toBool()) {
+ const QString text = AudioOutput::tr("<html>Switching to the audio playback device <b>%1</b><br/>"
+ "which has higher preference or is specifically configured for this stream.</html>").arg(device2.name());
+ Platform::notification("AudioDeviceFallback", text,
+ QStringList(AudioOutput::tr("Revert back to device '%1'").arg(device1.name())),
+ q, SLOT(_k_revertFallback()));
+ } else {
+ const QString &text =
+ AudioOutput::tr("<html>The audio playback device <b>%1</b> does not work.<br/>"
+ "Falling back to <b>%2</b>.</html>").arg(device1.name()).arg(device2.name());
+ Platform::notification("AudioDeviceFallback", text);
+ }
+#endif //QT_NO_PHONON_PLATFORMPLUGIN
+ //outputDeviceOverridden = true;
+ g_lastFallback.first = 0;
+ g_lastFallback.second = 0;
+ }
+ break;
}
}
AudioOutputPrivate::~AudioOutputPrivate()
{
+ PulseSupport::getInstance()->clearStreamCache(streamUuid);
#ifndef QT_NO_DBUS
if (adaptor) {
emit adaptor->outputDestroyed();
diff --git a/src/3rdparty/phonon/phonon/audiooutput.h b/src/3rdparty/phonon/phonon/audiooutput.h
index 4edf135..513a863 100644
--- a/src/3rdparty/phonon/phonon/audiooutput.h
+++ b/src/3rdparty/phonon/phonon/audiooutput.h
@@ -169,6 +169,7 @@ namespace Phonon
Q_PRIVATE_SLOT(k_func(), void _k_revertFallback())
Q_PRIVATE_SLOT(k_func(), void _k_audioDeviceFailed())
Q_PRIVATE_SLOT(k_func(), void _k_deviceListChanged())
+ Q_PRIVATE_SLOT(k_func(), void _k_deviceChanged(QString streamUuid, int device))
};
} //namespace Phonon
diff --git a/src/3rdparty/phonon/phonon/audiooutput_p.h b/src/3rdparty/phonon/phonon/audiooutput_p.h
index fdee299..01dc48f 100644
--- a/src/3rdparty/phonon/phonon/audiooutput_p.h
+++ b/src/3rdparty/phonon/phonon/audiooutput_p.h
@@ -46,6 +46,7 @@ class AudioOutputPrivate : public AbstractAudioOutputPrivate
return 0;
}
void init(Phonon::Category c);
+ QString getStreamUuid();
protected:
@@ -58,6 +59,7 @@ class AudioOutputPrivate : public AbstractAudioOutputPrivate
#endif
deviceBeforeFallback(-1),
outputDeviceOverridden(false),
+ forceMove(false),
muted(false)
{
}
@@ -66,7 +68,8 @@ class AudioOutputPrivate : public AbstractAudioOutputPrivate
enum DeviceChangeType {
FallbackChange,
- HigherPreferenceChange
+ HigherPreferenceChange,
+ SoundSystemChange
};
void handleAutomaticDeviceChange(const AudioOutputDevice &newDev, DeviceChangeType type);
@@ -74,17 +77,20 @@ class AudioOutputPrivate : public AbstractAudioOutputPrivate
void _k_revertFallback();
void _k_audioDeviceFailed();
void _k_deviceListChanged();
+ void _k_deviceChanged(QString streamUuid, int deviceIndex);
private:
QString name;
Phonon::AudioOutputDevice device;
qreal volume;
+ QString streamUuid;
#ifndef QT_NO_DBUS
Phonon::AudioOutputAdaptor *adaptor;
#endif
Category category;
int deviceBeforeFallback;
bool outputDeviceOverridden;
+ bool forceMove;
bool muted;
};
} //namespace Phonon
diff --git a/src/3rdparty/phonon/phonon/audiooutputinterface.h b/src/3rdparty/phonon/phonon/audiooutputinterface.h
index 80ba11c..cce12b2 100644
--- a/src/3rdparty/phonon/phonon/audiooutputinterface.h
+++ b/src/3rdparty/phonon/phonon/audiooutputinterface.h
@@ -64,7 +64,7 @@ class AudioOutputInterface40
* A value of 0.0 means muted, 1.0 means unchanged, 2.0 means double voltage (i.e. all
* samples are multiplied by 2).
*
- * Everytime the volume in the backend changes it should emit volumeChanged(qreal), also
+ * Every time the volume in the backend changes it should emit volumeChanged(qreal), also
* inside this function.
*/
virtual void setVolume(qreal) = 0;
diff --git a/src/3rdparty/phonon/phonon/backendcapabilities.cpp b/src/3rdparty/phonon/phonon/backendcapabilities.cpp
index fbeb020..8dad589 100644
--- a/src/3rdparty/phonon/phonon/backendcapabilities.cpp
+++ b/src/3rdparty/phonon/phonon/backendcapabilities.cpp
@@ -26,7 +26,7 @@
#include "phonondefs_p.h"
#include "backendinterface.h"
#include "factory_p.h"
-#include "globalconfig_p.h"
+#include "globalconfig.h"
#include "globalstatic_p.h"
#include "objectdescription.h"
diff --git a/src/3rdparty/phonon/phonon/factory.cpp b/src/3rdparty/phonon/phonon/factory.cpp
index 9967c971..2785dff 100644
--- a/src/3rdparty/phonon/phonon/factory.cpp
+++ b/src/3rdparty/phonon/phonon/factory.cpp
@@ -134,30 +134,24 @@ bool FactoryPrivate::createBackend()
continue;
}
- QStringList plugins(dir.entryList(QDir::Files));
+ QStringList plugins(dir.entryList(QDir::Files));
#ifdef Q_OS_SYMBIAN
/* On Symbian OS we might have two plugins, one which uses Symbian
- * MMF framework("phonon_mmf"), and one which uses Real Networks's
+ * MMF framework("mmf"), and one which uses Real Networks's
* Helix("hxphonon"). We prefer the latter because it's more
* sophisticated, so we make sure the Helix backend is attempted
* to be loaded first, and the MMF backend is used for backup. */
{
-
- const int hxphonon = plugins.indexOf(QLatin1String("hxphonon"));
- if (hxphonon != -1)
- plugins.move(hxphonon, 0);
-
- // Code for debugging the MMF backend.
- if(hxphonon != -1) {
- qDebug() << "Found hxphonon backend and removed it from the lookup list.";
- plugins.removeAll(QLatin1String("hxphonon"));
- }
+ const int helix = plugins.indexOf(QLatin1String("hxphonon"));
+ if (helix != -1)
+ plugins.move(helix, 0);
}
#endif
- for (int i = 0; i < plugins.count(); ++i) {
- QPluginLoader pluginLoader(libPath + plugins.at(i));
+ const QStringList files = dir.entryList(QDir::Files);
+ for (int i = 0; i < files.count(); ++i) {
+ QPluginLoader pluginLoader(libPath + files.at(i));
if (!pluginLoader.load()) {
pDebug() << Q_FUNC_INFO << " load failed:"
<< pluginLoader.errorString();
@@ -350,6 +344,7 @@ FACTORY_IMPL(AudioOutput)
#ifndef QT_NO_PHONON_VIDEO
FACTORY_IMPL(VideoWidget)
#endif //QT_NO_PHONON_VIDEO
+FACTORY_IMPL(AudioDataOutput)
#undef FACTORY_IMPL
@@ -469,7 +464,7 @@ GET_STRING_PROPERTY(backendWebsite)
QObject *Factory::registerQObject(QObject *o)
{
if (o) {
- QObject::connect(o, SIGNAL(destroyed(QObject*)), globalFactory, SLOT(objectDestroyed(QObject*)), Qt::DirectConnection);
+ QObject::connect(o, SIGNAL(destroyed(QObject *)), globalFactory, SLOT(objectDestroyed(QObject *)), Qt::DirectConnection);
globalFactory->objects.append(o);
}
return o;
diff --git a/src/3rdparty/phonon/phonon/factory_p.h b/src/3rdparty/phonon/phonon/factory_p.h
index dee2b56..41b8c5b 100644
--- a/src/3rdparty/phonon/phonon/factory_p.h
+++ b/src/3rdparty/phonon/phonon/factory_p.h
@@ -122,6 +122,13 @@ namespace Factory
#endif //QT_NO_PHONON_VIDEO
/**
+ * Create a new backend object for a AudioDataOutput.
+ *
+ * \return a pointer to the AudioDataOutput the backend provides.
+ */
+ PHONON_EXPORT QObject *createAudioDataOutput(QObject *parent = 0);
+
+ /**
* \return a pointer to the backend interface.
*/
PHONON_EXPORT QObject *backend(bool createWhenNull = true);
diff --git a/src/3rdparty/phonon/phonon/globalconfig.cpp b/src/3rdparty/phonon/phonon/globalconfig.cpp
index 3b77a18..be751ce 100644
--- a/src/3rdparty/phonon/phonon/globalconfig.cpp
+++ b/src/3rdparty/phonon/phonon/globalconfig.cpp
@@ -20,6 +20,7 @@
*/
+#include "globalconfig.h"
#include "globalconfig_p.h"
#include "factory_p.h"
@@ -29,6 +30,7 @@
#include "backendinterface.h"
#include "qsettingsgroup_p.h"
#include "phononnamespace_p.h"
+#include "pulsesupport.h"
#include <QtCore/QList>
#include <QtCore/QVariant>
@@ -38,15 +40,18 @@ QT_BEGIN_NAMESPACE
namespace Phonon
{
+GlobalConfigPrivate::GlobalConfigPrivate() : config(QLatin1String("kde.org"), QLatin1String("libphonon"))
+{
+}
+
GlobalConfig::GlobalConfig()
-#ifndef QT_NO_SETTINGS
- : m_config(QLatin1String("kde.org"), QLatin1String("libphonon"))
-#endif //QT_NO_SETTINGS
+ : k_ptr(new GlobalConfigPrivate)
{
}
GlobalConfig::~GlobalConfig()
{
+ delete k_ptr;
}
enum WhatToFilter {
@@ -59,7 +64,11 @@ static void filter(ObjectDescriptionType type, BackendInterface *backendIface, Q
{
QMutableListIterator<int> it(*list);
while (it.hasNext()) {
- const QHash<QByteArray, QVariant> properties = backendIface->objectDescriptionProperties(type, it.next());
+ QHash<QByteArray, QVariant> properties;
+ if (backendIface)
+ properties = backendIface->objectDescriptionProperties(type, it.next());
+ else
+ properties = PulseSupport::getInstance()->objectDescriptionProperties(type, it.next());
QVariant var;
if (whatToFilter & FilterAdvancedDevices) {
var = properties.value("isAdvanced");
@@ -73,6 +82,7 @@ static void filter(ObjectDescriptionType type, BackendInterface *backendIface, Q
if (var.isValid() && var.toBool()) {
it.remove();
continue;
+#ifndef QT_NO_PHONON_SETTINGSGROUP
}
}
if (whatToFilter & FilterUnavailableDevices) {
@@ -85,9 +95,12 @@ static void filter(ObjectDescriptionType type, BackendInterface *backendIface, Q
}
}
-#ifndef QT_NO_PHONON_SETTINGSGROUP
-static QList<int> listSortedByConfig(const QSettingsGroup &backendConfig, Phonon::Category category, QList<int> &defaultList)
+static QList<int> sortDevicesByCategoryPriority(const GlobalConfig *config, const QSettingsGroup *backendConfig, ObjectDescriptionType type, Phonon::Category category, QList<int> &defaultList)
{
+ Q_ASSERT(config);
+ Q_ASSERT(backendConfig);
+ Q_ASSERT(type == AudioOutputDeviceType || type == AudioCaptureDeviceType);
+
if (defaultList.size() <= 1) {
// nothing to sort
return defaultList;
@@ -104,20 +117,26 @@ static QList<int> listSortedByConfig(const QSettingsGroup &backendConfig, Phonon
}
}
- QString categoryKey = QLatin1String("Category_") + QString::number(static_cast<int>(category));
- if (!backendConfig.hasKey(categoryKey)) {
- // no list in config for the given category
- categoryKey = QLatin1String("Category_") + QString::number(static_cast<int>(Phonon::NoCategory));
- if (!backendConfig.hasKey(categoryKey)) {
- // no list in config for NoCategory
- return defaultList;
+ QList<int> deviceList;
+ PulseSupport *pulse = PulseSupport::getInstance();
+ if (pulse->isActive()) {
+ deviceList = pulse->objectIndexesByCategory(type, category);
+ } else {
+ QString categoryKey = QLatin1String("Category_") + QString::number(static_cast<int>(category));
+ if (!backendConfig->hasKey(categoryKey)) {
+ // no list in config for the given category
+ categoryKey = QLatin1String("Category_") + QString::number(static_cast<int>(Phonon::NoCategory));
+ if (!backendConfig->hasKey(categoryKey)) {
+ // no list in config for NoCategory
+ return defaultList;
+ }
}
- }
- //Now the list from m_config
- QList<int> deviceList = backendConfig.value(categoryKey, QList<int>());
+ //Now the list from d->config
+ deviceList = backendConfig->value(categoryKey, QList<int>());
+ }
- //if there are devices in m_config that the backend doesn't report, remove them from the list
+ //if there are devices in d->config that the backend doesn't report, remove them from the list
QMutableListIterator<int> i(deviceList);
while (i.hasNext()) {
if (0 == defaultList.removeAll(i.next())) {
@@ -125,58 +144,198 @@ static QList<int> listSortedByConfig(const QSettingsGroup &backendConfig, Phonon
}
}
- //if the backend reports more devices that are not in m_config append them to the list
+ //if the backend reports more devices that are not in d->config append them to the list
deviceList += defaultList;
return deviceList;
}
+
+bool GlobalConfig::hideAdvancedDevices() const
+{
+ K_D(const GlobalConfig);
+ //The devices need to be stored independently for every backend
+ const QSettingsGroup generalGroup(&d->config, QLatin1String("General"));
+ return generalGroup.value(QLatin1String("HideAdvancedDevices"), true);
+}
+
+void GlobalConfig::setHideAdvancedDevices(bool hide)
+{
+ K_D(GlobalConfig);
+ QSettingsGroup generalGroup(&d->config, QLatin1String("General"));
+ generalGroup.setValue(QLatin1String("HideAdvancedDevices"), hide);
+}
+
+static bool isHiddenAudioOutputDevice(const GlobalConfig *config, int i)
+{
+ Q_ASSERT(config);
+
+ if (!config->hideAdvancedDevices())
+ return false;
+
+ AudioOutputDevice ad = AudioOutputDevice::fromIndex(i);
+ const QVariant var = ad.property("isAdvanced");
+ return (var.isValid() && var.toBool());
+}
+
+#ifndef QT_NO_PHONON_AUDIOCAPTURE
+static bool isHiddenAudioCaptureDevice(const GlobalConfig *config, int i)
+{
+ Q_ASSERT(config);
+
+ if (!config->hideAdvancedDevices())
+ return false;
+
+ AudioCaptureDevice ad = AudioCaptureDevice::fromIndex(i);
+ const QVariant var = ad.property("isAdvanced");
+ return (var.isValid() && var.toBool());
+}
+#endif
+
+static QList<int> reindexList(const GlobalConfig *config, Phonon::Category category, QList<int>newOrder, bool output)
+{
+ Q_ASSERT(config);
+#ifdef QT_NO_PHONON_AUDIOCAPTURE
+ Q_ASSERT(output);
+#endif
+
+ /*QString sb;
+ sb = QString("(Size %1)").arg(currentList.size());
+ foreach (int i, currentList)
+ sb += QString("%1, ").arg(i);
+ fprintf(stderr, "=== Reindex Current: %s\n", sb.toUtf8().constData());
+ sb = QString("(Size %1)").arg(newOrder.size());
+ foreach (int i, newOrder)
+ sb += QString("%1, ").arg(i);
+ fprintf(stderr, "=== Reindex Before : %s\n", sb.toUtf8().constData());*/
+
+ QList<int> currentList;
+ if (output)
+ currentList = config->audioOutputDeviceListFor(category, GlobalConfig::ShowUnavailableDevices|GlobalConfig::ShowAdvancedDevices);
+#ifndef QT_NO_PHONON_AUDIOCAPTURE
+ else
+ currentList = config->audioCaptureDeviceListFor(category, GlobalConfig::ShowUnavailableDevices|GlobalConfig::ShowAdvancedDevices);
+#endif
+
+ QList<int> newList;
+
+ foreach (int i, newOrder) {
+ int found = currentList.indexOf(i);
+ if (found < 0) {
+ // It's not in the list, so something is odd (e.g. client error). Ignore it.
+ continue;
+ }
+
+ // Iterate through the list from this point onward. If there are hidden devices
+ // immediately following, take them too.
+ newList.append(currentList.takeAt(found));
+ while (found < currentList.size()) {
+ bool hidden = true;
+ if (output)
+ hidden = isHiddenAudioOutputDevice(config, currentList.at(found));
+#ifndef QT_NO_PHONON_AUDIOCAPTURE
+ else
+ hidden = isHiddenAudioCaptureDevice(config, currentList.at(found));
+#endif
+
+ if (!hidden)
+ break;
+ newList.append(currentList.takeAt(found));
+ }
+ }
+
+ // If there are any devices left in.. just tack them on the end.
+ if (currentList.size() > 0)
+ newList += currentList;
+
+ /*sb = QString("(Size %1)").arg(newList.size());
+ foreach (int i, newList)
+ sb += QString("%1, ").arg(i);
+ fprintf(stderr, "=== Reindex After : %s\n", sb.toUtf8().constData());*/
+ return newList;
+}
+
+
+void GlobalConfig::setAudioOutputDeviceListFor(Phonon::Category category, QList<int> order)
+{
+ PulseSupport *pulse = PulseSupport::getInstance();
+ if (pulse->isActive()) {
+ pulse->setOutputDevicePriorityForCategory(category, order);
+ return;
+ }
+
+ K_D(GlobalConfig);
+ QSettingsGroup backendConfig(&d->config, QLatin1String("AudioOutputDevice")); // + Factory::identifier());
+
+ order = reindexList(this, category, order, true);
+
+ const QList<int> noCategoryOrder = audioOutputDeviceListFor(Phonon::NoCategory, ShowUnavailableDevices|ShowAdvancedDevices);
+ if (category != Phonon::NoCategory && order == noCategoryOrder) {
+ backendConfig.removeEntry(QLatin1String("Category_") + QString::number(category));
+ } else {
+ backendConfig.setValue(QLatin1String("Category_") + QString::number(category), order);
+ }
+}
#endif //QT_NO_PHONON_SETTINGSGROUP
#ifndef QT_NO_PHONON_SETTINGSGROUP
QList<int> GlobalConfig::audioOutputDeviceListFor(Phonon::Category category, int override) const
{
- //The devices need to be stored independently for every backend
- const QSettingsGroup backendConfig(&m_config, QLatin1String("AudioOutputDevice")); // + Factory::identifier());
- const QSettingsGroup generalGroup(&m_config, QLatin1String("General"));
- const bool hideAdvancedDevices = ((override & AdvancedDevicesFromSettings)
- ? generalGroup.value(QLatin1String("HideAdvancedDevices"), true)
+ K_D(const GlobalConfig);
+
+ const bool hide = ((override & AdvancedDevicesFromSettings)
+ ? hideAdvancedDevices()
: static_cast<bool>(override & HideAdvancedDevices));
QList<int> defaultList;
+
+ PulseSupport *pulse = PulseSupport::getInstance();
+ if (pulse->isActive()) {
+ defaultList = pulse->objectDescriptionIndexes(Phonon::AudioOutputDeviceType);
+ if (hide || (override & HideUnavailableDevices)) {
+ filter(AudioOutputDeviceType, NULL, &defaultList,
+ (hide ? FilterAdvancedDevices : 0)
+ | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0)
+ );
+ }
+ } else {
+ BackendInterface *backendIface = qobject_cast<BackendInterface *>(Factory::backend());
+
#ifndef QT_NO_PHONON_PLATFORMPLUGIN
- if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) {
- // the platform plugin lists the audio devices for the platform
- // this list already is in default order (as defined by the platform plugin)
- defaultList = platformPlugin->objectDescriptionIndexes(Phonon::AudioOutputDeviceType);
- if (hideAdvancedDevices) {
- QMutableListIterator<int> it(defaultList);
- while (it.hasNext()) {
- AudioOutputDevice objDesc = AudioOutputDevice::fromIndex(it.next());
- const QVariant var = objDesc.property("isAdvanced");
- if (var.isValid() && var.toBool()) {
- it.remove();
+ if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) {
+ // the platform plugin lists the audio devices for the platform
+ // this list already is in default order (as defined by the platform plugin)
+ defaultList = platformPlugin->objectDescriptionIndexes(Phonon::AudioOutputDeviceType);
+ if (hide) {
+ QMutableListIterator<int> it(defaultList);
+ while (it.hasNext()) {
+ AudioOutputDevice objDesc = AudioOutputDevice::fromIndex(it.next());
+ const QVariant var = objDesc.property("isAdvanced");
+ if (var.isValid() && var.toBool()) {
+ it.remove();
+ }
}
}
}
- }
#endif //QT_NO_PHONON_PLATFORMPLUGIN
- // lookup the available devices directly from the backend (mostly for virtual devices)
- if (BackendInterface *backendIface = qobject_cast<BackendInterface *>(Factory::backend())) {
- // this list already is in default order (as defined by the backend)
- QList<int> list = backendIface->objectDescriptionIndexes(Phonon::AudioOutputDeviceType);
- if (hideAdvancedDevices || !defaultList.isEmpty() || (override & HideUnavailableDevices)) {
- filter(AudioOutputDeviceType, backendIface, &list,
- (hideAdvancedDevices ? FilterAdvancedDevices : 0)
- // the platform plugin already provided the hardware devices
- | (defaultList.isEmpty() ? 0 : FilterHardwareDevices)
- | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0)
- );
+ // lookup the available devices directly from the backend
+ if (backendIface) {
+ // this list already is in default order (as defined by the backend)
+ QList<int> list = backendIface->objectDescriptionIndexes(Phonon::AudioOutputDeviceType);
+ if (hide || !defaultList.isEmpty() || (override & HideUnavailableDevices)) {
+ filter(AudioOutputDeviceType, backendIface, &list,
+ (hide ? FilterAdvancedDevices : 0)
+ // the platform plugin maybe already provided the hardware devices?
+ | (defaultList.isEmpty() ? 0 : FilterHardwareDevices)
+ | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0)
+ );
+ }
+ defaultList += list;
}
- defaultList += list;
}
- return listSortedByConfig(backendConfig, category, defaultList);
+ const QSettingsGroup backendConfig(&d->config, QLatin1String("AudioOutputDevice")); // + Factory::identifier());
+ return sortDevicesByCategoryPriority(this, &backendConfig, AudioOutputDeviceType, category, defaultList);
}
#endif //QT_NO_PHONON_SETTINGSGROUP
int GlobalConfig::audioOutputDeviceFor(Phonon::Category category, int override) const
@@ -190,54 +349,89 @@ int GlobalConfig::audioOutputDeviceFor(Phonon::Category category, int override)
}
#ifndef QT_NO_PHONON_AUDIOCAPTURE
-QList<int> GlobalConfig::audioCaptureDeviceListFor(Phonon::Category category, int override) const
+void GlobalConfig::setAudioCaptureDeviceListFor(Phonon::Category category, QList<int> order)
{
#ifndef QT_NO_PHONON_SETTINGSGROUP
- //The devices need to be stored independently for every backend
- const QSettingsGroup backendConfig(&m_config, QLatin1String("AudioCaptureDevice")); // + Factory::identifier());
- const QSettingsGroup generalGroup(&m_config, QLatin1String("General"));
- const bool hideAdvancedDevices = ((override & AdvancedDevicesFromSettings)
- ? generalGroup.value(QLatin1String("HideAdvancedDevices"), true)
+ PulseSupport *pulse = PulseSupport::getInstance();
+ if (pulse->isActive()) {
+ pulse->setCaptureDevicePriorityForCategory(category, order);
+ return;
+ }
+
+ K_D(GlobalConfig);
+ QSettingsGroup backendConfig(&d->config, QLatin1String("AudioCaptureDevice")); // + Factory::identifier());
+
+ order = reindexList(this, category, order, false);
+
+ const QList<int> noCategoryOrder = audioCaptureDeviceListFor(Phonon::NoCategory, ShowUnavailableDevices|ShowAdvancedDevices);
+ if (category != Phonon::NoCategory && order == noCategoryOrder) {
+ backendConfig.removeEntry(QLatin1String("Category_") + QString::number(category));
+ } else {
+ backendConfig.setValue(QLatin1String("Category_") + QString::number(category), order);
+ }
+}
+
+QList<int> GlobalConfig::audioCaptureDeviceListFor(Phonon::Category category, int override) const
+{
+ K_D(const GlobalConfig);
+
+ const bool hide = ((override & AdvancedDevicesFromSettings)
+ ? hideAdvancedDevices()
: static_cast<bool>(override & HideAdvancedDevices));
QList<int> defaultList;
+
+ PulseSupport *pulse = PulseSupport::getInstance();
+ if (pulse->isActive()) {
+ defaultList = pulse->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType);
+ if (hide || (override & HideUnavailableDevices)) {
+ filter(AudioCaptureDeviceType, NULL, &defaultList,
+ (hide ? FilterAdvancedDevices : 0)
+ | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0)
+ );
+ }
+ } else {
+ BackendInterface *backendIface = qobject_cast<BackendInterface *>(Factory::backend());
+
#ifndef QT_NO_PHONON_PLATFORMPLUGIN
- if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) {
- // the platform plugin lists the audio devices for the platform
- // this list already is in default order (as defined by the platform plugin)
- defaultList = platformPlugin->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType);
- if (hideAdvancedDevices) {
- QMutableListIterator<int> it(defaultList);
- while (it.hasNext()) {
- AudioCaptureDevice objDesc = AudioCaptureDevice::fromIndex(it.next());
- const QVariant var = objDesc.property("isAdvanced");
- if (var.isValid() && var.toBool()) {
- it.remove();
+#else //QT_NO_SETTINGSGROUP
+ return QList<int>();
+#endif //QT_NO_SETTINGSGROUP
+ if (PlatformPlugin *platformPlugin = Factory::platformPlugin()) {
+ // the platform plugin lists the audio devices for the platform
+ // this list already is in default order (as defined by the platform plugin)
+ defaultList = platformPlugin->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType);
+ if (hide) {
+ QMutableListIterator<int> it(defaultList);
+ while (it.hasNext()) {
+ AudioCaptureDevice objDesc = AudioCaptureDevice::fromIndex(it.next());
+ const QVariant var = objDesc.property("isAdvanced");
+ if (var.isValid() && var.toBool()) {
+ it.remove();
+ }
}
}
}
- }
#endif //QT_NO_PHONON_PLATFORMPLUGIN
- // lookup the available devices directly from the backend (mostly for virtual devices)
- if (BackendInterface *backendIface = qobject_cast<BackendInterface *>(Factory::backend())) {
- // this list already is in default order (as defined by the backend)
- QList<int> list = backendIface->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType);
- if (hideAdvancedDevices || !defaultList.isEmpty() || (override & HideUnavailableDevices)) {
- filter(AudioCaptureDeviceType, backendIface, &list,
- (hideAdvancedDevices ? FilterAdvancedDevices : 0)
- // the platform plugin already provided the hardware devices
- | (defaultList.isEmpty() ? 0 : FilterHardwareDevices)
- | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0)
- );
+ // lookup the available devices directly from the backend
+ if (backendIface) {
+ // this list already is in default order (as defined by the backend)
+ QList<int> list = backendIface->objectDescriptionIndexes(Phonon::AudioCaptureDeviceType);
+ if (hide || !defaultList.isEmpty() || (override & HideUnavailableDevices)) {
+ filter(AudioCaptureDeviceType, backendIface, &list,
+ (hide ? FilterAdvancedDevices : 0)
+ // the platform plugin maybe already provided the hardware devices?
+ | (defaultList.isEmpty() ? 0 : FilterHardwareDevices)
+ | ((override & HideUnavailableDevices) ? FilterUnavailableDevices : 0)
+ );
+ }
+ defaultList += list;
}
- defaultList += list;
}
- return listSortedByConfig(backendConfig, category, defaultList);
-#else //QT_NO_SETTINGSGROUP
- return QList<int>();
-#endif //QT_NO_SETTINGSGROUP
+ const QSettingsGroup backendConfig(&d->config, QLatin1String("AudioCaptureDevice")); // + Factory::identifier());
+ return sortDevicesByCategoryPriority(this, &backendConfig, AudioCaptureDeviceType, category, defaultList);
}
int GlobalConfig::audioCaptureDeviceFor(Phonon::Category category, int override) const
diff --git a/src/3rdparty/phonon/phonon/globalconfig.h b/src/3rdparty/phonon/phonon/globalconfig.h
new file mode 100644
index 0000000..5233c7b
--- /dev/null
+++ b/src/3rdparty/phonon/phonon/globalconfig.h
@@ -0,0 +1,71 @@
+/* This file is part of the KDE project
+Copyright (C) 2006-2008 Matthias Kretz <kretz@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), Nokia Corporation
+ (or its successors, if any) and the KDE Free Qt Foundation, which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef PHONON_GLOBALCONFIG_H
+#define PHONON_GLOBALCONFIG_H
+
+#include "phonon_export.h"
+#include "phononnamespace.h"
+#include "phonondefs.h"
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+namespace Phonon
+{
+ class GlobalConfigPrivate;
+
+ class PHONON_EXPORT GlobalConfig
+ {
+ K_DECLARE_PRIVATE(GlobalConfig)
+ public:
+ GlobalConfig();
+ virtual ~GlobalConfig();
+
+ enum DevicesToHideFlag {
+ ShowUnavailableDevices = 0,
+ ShowAdvancedDevices = 0,
+ HideAdvancedDevices = 1,
+ AdvancedDevicesFromSettings = 2,
+ HideUnavailableDevices = 4
+ };
+ bool hideAdvancedDevices() const;
+ void setHideAdvancedDevices(bool hide = true);
+ void setAudioOutputDeviceListFor(Phonon::Category category, QList<int> order);
+ QList<int> audioOutputDeviceListFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const;
+ int audioOutputDeviceFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const;
+
+#ifndef QT_NO_PHONON_AUDIOCAPTURE
+ void setAudioCaptureDeviceListFor(Phonon::Category category, QList<int> order);
+ QList<int> audioCaptureDeviceListFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const;
+ int audioCaptureDeviceFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const;
+#endif //QT_NO_PHONON_AUDIOCAPTURE
+
+ protected:
+ GlobalConfigPrivate *const k_ptr;
+ };
+} // namespace Phonon
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif // PHONON_GLOBALCONFIG_H
diff --git a/src/3rdparty/phonon/phonon/globalconfig_p.h b/src/3rdparty/phonon/phonon/globalconfig_p.h
index ec70b6f..090ca6b 100644
--- a/src/3rdparty/phonon/phonon/globalconfig_p.h
+++ b/src/3rdparty/phonon/phonon/globalconfig_p.h
@@ -26,40 +26,19 @@ Copyright (C) 2006-2008 Matthias Kretz <kretz@kde.org>
#include <QtCore/QSettings>
#include "phonon_export.h"
-#include "phononnamespace.h"
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
namespace Phonon
{
- class PHONON_EXPORT GlobalConfig
+ class GlobalConfigPrivate
{
- public:
- GlobalConfig();
- virtual ~GlobalConfig();
+ public:
+ GlobalConfigPrivate();
+ virtual ~GlobalConfigPrivate() {}
- enum DevicesToHideFlag {
- ShowUnavailableDevices = 0,
- ShowAdvancedDevices = 0,
- HideAdvancedDevices = 1,
- AdvancedDevicesFromSettings = 2,
- HideUnavailableDevices = 4
- };
-#ifndef QT_NO_PHONON_SETTINGSGROUP
- QList<int> audioOutputDeviceListFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const;
-#endif //QT_NO_PHONON_SETTINGSGROUP
- int audioOutputDeviceFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const;
-
-#ifndef QT_NO_PHONON_AUDIOCAPTURE
- QList<int> audioCaptureDeviceListFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const;
- int audioCaptureDeviceFor(Phonon::Category category, int override = AdvancedDevicesFromSettings) const;
-#endif //QT_NO_PHONON_AUDIOCAPTURE
-
- protected:
-#ifndef QT_NO_SETTINGS
- QSettings m_config;
-#endif //QT_NO_SETTINGS
+ QSettings config;
};
} // namespace Phonon
diff --git a/src/3rdparty/phonon/phonon/mediaobject.cpp b/src/3rdparty/phonon/phonon/mediaobject.cpp
index 41e8dc2..13d303c 100644
--- a/src/3rdparty/phonon/phonon/mediaobject.cpp
+++ b/src/3rdparty/phonon/phonon/mediaobject.cpp
@@ -453,9 +453,9 @@ void MediaObjectPrivate::setupBackendObject()
//pDebug() << Q_FUNC_INFO;
#ifndef QT_NO_PHONON_ABSTRACTMEDIASTREAM
- QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), q, SLOT(_k_stateChanged(Phonon::State,Phonon::State)));
+ QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), q, SLOT(_k_stateChanged(Phonon::State, Phonon::State)));
#else
- QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State,Phonon::State)), q, SIGNAL(stateChanged(Phonon::State,Phonon::State)));
+ QObject::connect(m_backendObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), q, SIGNAL(stateChanged(Phonon::State, Phonon::State)));
#endif // QT_NO_PHONON_ABSTRACTMEDIASTREAM
QObject::connect(m_backendObject, SIGNAL(tick(qint64)), q, SIGNAL(tick(qint64)));
QObject::connect(m_backendObject, SIGNAL(seekableChanged(bool)), q, SIGNAL(seekableChanged(bool)));
@@ -467,10 +467,10 @@ void MediaObjectPrivate::setupBackendObject()
QObject::connect(m_backendObject, SIGNAL(aboutToFinish()), q, SLOT(_k_aboutToFinish()));
QObject::connect(m_backendObject, SIGNAL(prefinishMarkReached(qint32)), q, SIGNAL(prefinishMarkReached(qint32)));
QObject::connect(m_backendObject, SIGNAL(totalTimeChanged(qint64)), q, SIGNAL(totalTimeChanged(qint64)));
- QObject::connect(m_backendObject, SIGNAL(metaDataChanged(QMultiMap<QString,QString>)),
- q, SLOT(_k_metaDataChanged(QMultiMap<QString,QString>)));
- QObject::connect(m_backendObject, SIGNAL(currentSourceChanged(MediaSource)),
- q, SLOT(_k_currentSourceChanged(MediaSource)));
+ QObject::connect(m_backendObject, SIGNAL(metaDataChanged(const QMultiMap<QString, QString> &)),
+ q, SLOT(_k_metaDataChanged(const QMultiMap<QString, QString> &)));
+ QObject::connect(m_backendObject, SIGNAL(currentSourceChanged(const MediaSource&)),
+ q, SLOT(_k_currentSourceChanged(const MediaSource&)));
// set up attributes
pINTERFACE_CALL(setTickInterval(tickInterval));
diff --git a/src/3rdparty/phonon/phonon/objectdescription.cpp b/src/3rdparty/phonon/phonon/objectdescription.cpp
index e058b89..55e74b5 100644
--- a/src/3rdparty/phonon/phonon/objectdescription.cpp
+++ b/src/3rdparty/phonon/phonon/objectdescription.cpp
@@ -29,6 +29,7 @@
#include <QtCore/QStringList>
#include "backendinterface.h"
#include "platformplugin.h"
+#include "pulsesupport.h"
QT_BEGIN_NAMESPACE
@@ -108,27 +109,38 @@ bool ObjectDescriptionData::isValid() const
ObjectDescriptionData *ObjectDescriptionData::fromIndex(ObjectDescriptionType type, int index)
{
- // prefer to get the ObjectDescriptionData from the platform plugin for audio devices
+ bool is_audio_device = (AudioOutputDeviceType == type || AudioCaptureDeviceType == type);
+
+ PulseSupport *pulse = PulseSupport::getInstance();
+ if (is_audio_device && pulse->isActive()) {
+ QList<int> indexes = pulse->objectDescriptionIndexes(type);
+ if (indexes.contains(index)) {
+ QHash<QByteArray, QVariant> properties = pulse->objectDescriptionProperties(type, index);
+ return new ObjectDescriptionData(index, properties);
+ }
+ } else {
+ BackendInterface *iface = qobject_cast<BackendInterface *>(Factory::backend());
+
+ // prefer to get the ObjectDescriptionData from the platform plugin for audio devices
#ifndef QT_NO_PHONON_PLATFORMPLUGIN
- if (type == AudioOutputDeviceType || type == AudioCaptureDeviceType) {
- PlatformPlugin *platformPlugin = Factory::platformPlugin();
- if (platformPlugin) {
- QList<int> indexes = platformPlugin->objectDescriptionIndexes(type);
- if (indexes.contains(index)) {
- QHash<QByteArray, QVariant> properties = platformPlugin->objectDescriptionProperties(type, index);
- return new ObjectDescriptionData(index, properties);
+ if (is_audio_device) {
+ PlatformPlugin *platformPlugin = Factory::platformPlugin();
+ if (platformPlugin) {
+ QList<int> indexes = platformPlugin->objectDescriptionIndexes(type);
+ if (indexes.contains(index)) {
+ QHash<QByteArray, QVariant> properties = platformPlugin->objectDescriptionProperties(type, index);
+ return new ObjectDescriptionData(index, properties);
+ }
}
}
- }
#endif //QT_NO_PHONON_PLATFORMPLUGIN
- QObject *b = Factory::backend();
- BackendInterface *iface = qobject_cast<BackendInterface *>(b);
- if (iface) {
- QList<int> indexes = iface->objectDescriptionIndexes(type);
- if (indexes.contains(index)) {
- QHash<QByteArray, QVariant> properties = iface->objectDescriptionProperties(type, index);
- return new ObjectDescriptionData(index, properties);
+ if (iface) {
+ QList<int> indexes = iface->objectDescriptionIndexes(type);
+ if (indexes.contains(index)) {
+ QHash<QByteArray, QVariant> properties = iface->objectDescriptionProperties(type, index);
+ return new ObjectDescriptionData(index, properties);
+ }
}
}
return new ObjectDescriptionData(0); // invalid
diff --git a/src/3rdparty/phonon/phonon/objectdescriptionmodel.cpp b/src/3rdparty/phonon/phonon/objectdescriptionmodel.cpp
index bf5be6d..741a74c 100644
--- a/src/3rdparty/phonon/phonon/objectdescriptionmodel.cpp
+++ b/src/3rdparty/phonon/phonon/objectdescriptionmodel.cpp
@@ -362,6 +362,7 @@ QStringList ObjectDescriptionModelData::mimeTypes(ObjectDescriptionType type) co
return QStringList(QLatin1String("application/x-phonon-objectdescription") + QString::number(static_cast<int>(type)));
}
+#if !defined(Q_CC_MSVC) || _MSC_VER > 1300 || defined(Q_CC_INTEL) || defined(Q_CC_MINGW)
#define INSTANTIATE_META_FUNCTIONS(type) \
template const QMetaObject *ObjectDescriptionModel<type>::metaObject() const; \
template void *ObjectDescriptionModel<type>::qt_metacast(const char *)
@@ -371,6 +372,7 @@ INSTANTIATE_META_FUNCTIONS(AudioCaptureDeviceType);
INSTANTIATE_META_FUNCTIONS(EffectType);
INSTANTIATE_META_FUNCTIONS(AudioChannelType);
INSTANTIATE_META_FUNCTIONS(SubtitleType);
+#endif
/*INSTANTIATE_META_FUNCTIONS(VideoOutputDeviceType);
INSTANTIATE_META_FUNCTIONS(VideoCaptureDeviceType);
INSTANTIATE_META_FUNCTIONS(AudioCodecType);
diff --git a/src/3rdparty/phonon/phonon/objectdescriptionmodel.h b/src/3rdparty/phonon/phonon/objectdescriptionmodel.h
index 8fd622f..a1540e8 100644
--- a/src/3rdparty/phonon/phonon/objectdescriptionmodel.h
+++ b/src/3rdparty/phonon/phonon/objectdescriptionmodel.h
@@ -35,6 +35,18 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_PHONON_OBJECTDESCRIPTIONMODEL
+/* MinGW 3.4.x gives an ICE when trying to instantiate one of the
+ ObjectDescriptionModel<foo> classes because it can't handle
+ half exported classes correct. gcc 4.3.x has a fix for this but
+ we currently there's no official gcc 4.3 on windows available.
+ Because of this we need this little hack
+ */
+#if defined(Q_CC_MINGW)
+#define PHONON_EXPORT_ODM
+#else
+#define PHONON_EXPORT_ODM PHONON_EXPORT
+#endif
+
namespace Phonon
{
class ObjectDescriptionModelDataPrivate;
@@ -139,21 +151,6 @@ namespace Phonon
ObjectDescriptionModelDataPrivate *const d;
};
-/* Required to ensure template class vtables are exported on both symbian
-and existing builds. */
-#if defined(Q_OS_SYMBIAN) && defined(Q_CC_RVCT)
-// RVCT compiler (2.2.686) requires the export declaration to be on the class to export vtables
-// MWC compiler works both ways
-// GCCE compiler is unknown (it can't compile QtCore yet)
-#define PHONON_TEMPLATE_CLASS_EXPORT PHONON_EXPORT
-#define PHONON_TEMPLATE_CLASS_MEMBER_EXPORT
-#else
-// Windows builds (at least) do not support export declaration on templated class
-// But if you export a member function, the vtable is implicitly exported
-#define PHONON_TEMPLATE_CLASS_EXPORT
-#define PHONON_TEMPLATE_CLASS_MEMBER_EXPORT PHONON_EXPORT
-#endif
-
/** \class ObjectDescriptionModel objectdescriptionmodel.h Phonon/ObjectDescriptionModel
* \short The ObjectDescriptionModel class provides a model from
* a list of ObjectDescription objects.
@@ -190,17 +187,16 @@ and existing builds. */
* \author Matthias Kretz <kretz@kde.org>
*/
template<ObjectDescriptionType type>
- class PHONON_TEMPLATE_CLASS_EXPORT ObjectDescriptionModel : public QAbstractListModel
+ class ObjectDescriptionModel : public QAbstractListModel
{
public:
Q_OBJECT_CHECK
-
/** \internal */
- static PHONON_TEMPLATE_CLASS_MEMBER_EXPORT const QMetaObject staticMetaObject;
+ static PHONON_EXPORT const QMetaObject staticMetaObject;
/** \internal */
- PHONON_TEMPLATE_CLASS_MEMBER_EXPORT const QMetaObject *metaObject() const;
+ PHONON_EXPORT_ODM const QMetaObject *metaObject() const;
/** \internal */
- PHONON_TEMPLATE_CLASS_MEMBER_EXPORT void *qt_metacast(const char *_clname);
+ PHONON_EXPORT_ODM void *qt_metacast(const char *_clname);
//int qt_metacall(QMetaObject::Call _c, int _id, void **_a);
/**
diff --git a/src/3rdparty/phonon/phonon/path.cpp b/src/3rdparty/phonon/phonon/path.cpp
index 51c33b2..1c25b89 100644
--- a/src/3rdparty/phonon/phonon/path.cpp
+++ b/src/3rdparty/phonon/phonon/path.cpp
@@ -310,8 +310,8 @@ bool PathPrivate::executeTransaction( const QList<QObjectPair> &disconnections,
if (!transaction)
return false;
- QList<QObjectPair>::const_iterator it = disconnections.constBegin();
- for(;it != disconnections.constEnd();++it) {
+ QList<QObjectPair>::const_iterator it = disconnections.begin();
+ for(;it != disconnections.end();++it) {
const QObjectPair &pair = *it;
if (!backend->disconnectNodes(pair.first, pair.second)) {
@@ -327,8 +327,8 @@ bool PathPrivate::executeTransaction( const QList<QObjectPair> &disconnections,
}
}
- for(it = connections.constBegin(); it != connections.constEnd(); ++it) {
- const QObjectPair pair = *it;
+ for(it = connections.begin(); it != connections.end();++it) {
+ const QObjectPair &pair = *it;
if (!backend->connectNodes(pair.first, pair.second)) {
//Error: a connection failed
QList<QObjectPair>::const_iterator it2 = connections.begin();
diff --git a/src/3rdparty/phonon/phonon/phonondefs.h b/src/3rdparty/phonon/phonon/phonondefs.h
index 15a1815..765eb1c 100644
--- a/src/3rdparty/phonon/phonon/phonondefs.h
+++ b/src/3rdparty/phonon/phonon/phonondefs.h
@@ -29,6 +29,11 @@
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
+#ifdef PHONON_BACKEND_VERSION_4_4
+# ifndef PHONON_BACKEND_VERSION_4_3
+# define PHONON_BACKEND_VERSION_4_3
+# endif
+#endif
#ifdef PHONON_BACKEND_VERSION_4_3
# ifndef PHONON_BACKEND_VERSION_4_2
# define PHONON_BACKEND_VERSION_4_2
diff --git a/src/3rdparty/phonon/phonon/pulsesupport.cpp b/src/3rdparty/phonon/phonon/pulsesupport.cpp
new file mode 100644
index 0000000..642843f
--- /dev/null
+++ b/src/3rdparty/phonon/phonon/pulsesupport.cpp
@@ -0,0 +1,1040 @@
+/* This file is part of the KDE project
+ Copyright (C) 2009 Colin Guthrie <cguthrie@mandriva.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), Nokia Corporation
+ (or its successors, if any) and the KDE Free Qt Foundation, which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include <QtCore/QAbstractEventDispatcher>
+#include <QtCore/QEventLoop>
+#include <QtCore/QDebug>
+#include <QtCore/QStringList>
+
+#ifdef HAVE_PULSEAUDIO
+#include <glib.h>
+#include <pulse/pulseaudio.h>
+#include <pulse/xmalloc.h>
+#include <pulse/glib-mainloop.h>
+#ifdef HAVE_PULSEAUDIO_DEVICE_MANAGER
+# include <pulse/ext-device-manager.h>
+#endif
+#endif // HAVE_PULSEAUDIO
+
+#include "pulsesupport.h"
+
+QT_BEGIN_NAMESPACE
+
+namespace Phonon
+{
+
+static PulseSupport* s_instance = NULL;
+
+#ifdef HAVE_PULSEAUDIO
+/***
+* Prints a conditional debug message based on the current debug level
+* If obj is provided, classname and objectname will be printed as well
+*
+* see debugLevel()
+*/
+
+static int debugLevel() {
+ static int level = -1;
+ if (level < 1) {
+ level = 0;
+ QString pulseenv = qgetenv("PHONON_PULSEAUDIO_DEBUG");
+ int l = pulseenv.toInt();
+ if (l > 0)
+ level = (l > 2 ? 2 : l);
+ }
+ return level;
+}
+
+static void logMessage(const QString &message, int priority = 2, QObject *obj=0);
+static void logMessage(const QString &message, int priority, QObject *obj)
+{
+ if (debugLevel() > 0) {
+ QString output;
+ if (obj) {
+ // Strip away namespace from className
+ QString className(obj->metaObject()->className());
+ int nameLength = className.length() - className.lastIndexOf(':') - 1;
+ className = className.right(nameLength);
+ output.sprintf("%s %s (%s %p)", message.toLatin1().constData(),
+ obj->objectName().toLatin1().constData(),
+ className.toLatin1().constData(), obj);
+ }
+ else {
+ output = message;
+ }
+ if (priority <= debugLevel()) {
+ qDebug() << QString("PulseSupport(%1): %2").arg(priority).arg(output);
+ }
+ }
+}
+
+
+class AudioDevice
+{
+ public:
+ inline
+ AudioDevice(QString name, QString desc, QString icon, uint32_t index)
+ : pulseName(name), pulseIndex(index)
+ {
+ properties["name"] = desc;
+ properties["description"] = ""; // We don't have descriptions (well we do, but we use them as the name!)
+ properties["icon"] = icon;
+ properties["available"] = (index != PA_INVALID_INDEX);
+ properties["isAdvanced"] = false; // Nothing is advanced!
+ }
+
+ // Needed for QMap
+ inline AudioDevice() {}
+
+ QString pulseName;
+ uint32_t pulseIndex;
+ QHash<QByteArray, QVariant> properties;
+};
+bool operator!=(const AudioDevice &a, const AudioDevice &b)
+{
+ return !(a.pulseName == b.pulseName && a.properties == b.properties);
+}
+
+class PulseUserData
+{
+ public:
+ inline
+ PulseUserData()
+ {
+ }
+
+ QMap<QString, AudioDevice> newOutputDevices;
+ QMap<Phonon::Category, QMap<int, int> > newOutputDevicePriorities; // prio, device
+
+ QMap<QString, AudioDevice> newCaptureDevices;
+ QMap<Phonon::Category, QMap<int, int> > newCaptureDevicePriorities; // prio, device
+};
+
+static QMap<QString, Phonon::Category> s_roleCategoryMap;
+
+static bool s_pulseActive = false;
+
+static pa_glib_mainloop *s_mainloop = NULL;
+static pa_context *s_context = NULL;
+
+
+
+static int s_deviceIndexCounter = 0;
+
+static QMap<QString, int> s_outputDeviceIndexes;
+static QMap<int, AudioDevice> s_outputDevices;
+static QMap<Phonon::Category, QMap<int, int> > s_outputDevicePriorities; // prio, device
+static QMap<QString, uint32_t> s_outputStreamIndexMap;
+
+static QMap<QString, int> s_captureDeviceIndexes;
+static QMap<int, AudioDevice> s_captureDevices;
+static QMap<Phonon::Category, QMap<int, int> > s_captureDevicePriorities; // prio, device
+static QMap<QString, uint32_t> s_captureStreamIndexMap;
+
+static void createGenericDevices()
+{
+ // OK so we don't have the device manager extension, but we can show a single device and fake it.
+ int index;
+ s_outputDeviceIndexes.clear();
+ s_outputDevices.clear();
+ s_outputDevicePriorities.clear();
+ index = s_deviceIndexCounter++;
+ s_outputDeviceIndexes.insert("sink:default", index);
+ s_outputDevices.insert(index, AudioDevice("sink:default", QObject::tr("PulseAudio Sound Server").toUtf8(), "audio-backend-pulseaudio", 0));
+ for (int i = Phonon::NoCategory; i <= Phonon::LastCategory; ++i) {
+ Phonon::Category cat = static_cast<Phonon::Category>(i);
+ s_outputDevicePriorities[cat].insert(0, index);
+ }
+
+ s_captureDeviceIndexes.clear();
+ s_captureDevices.clear();
+ s_captureDevicePriorities.clear();
+ index = s_deviceIndexCounter++;
+ s_captureDeviceIndexes.insert("source:default", index);
+ s_captureDevices.insert(index, AudioDevice("source:default", QObject::tr("PulseAudio Sound Server").toUtf8(), "audio-backend-pulseaudio", 0));
+ for (int i = Phonon::NoCategory; i <= Phonon::LastCategory; ++i) {
+ Phonon::Category cat = static_cast<Phonon::Category>(i);
+ s_captureDevicePriorities[cat].insert(0, index);
+ }
+}
+
+#ifdef HAVE_PULSEAUDIO_DEVICE_MANAGER
+static void ext_device_manager_read_cb(pa_context *c, const pa_ext_device_manager_info *info, int eol, void *userdata) {
+ Q_ASSERT(c);
+ Q_ASSERT(userdata);
+
+ PulseUserData *u = reinterpret_cast<PulseUserData*>(userdata);
+
+ if (eol < 0) {
+ logMessage(QString("Failed to initialize device manager extension: %1").arg(pa_strerror(pa_context_errno(c))));
+ logMessage("Falling back to single device mode");
+ createGenericDevices();
+ delete u;
+
+ // If this is our probe phase, exit now
+ if (s_context != c)
+ pa_context_disconnect(c);
+
+ return;
+ }
+
+ if (eol) {
+ // We're done reading the data, so order it by priority and copy it into the
+ // static variables where it can then be accessed by those classes that need it.
+
+ QMap<QString, AudioDevice>::iterator newdev_it;
+
+ // Check for new output devices or things changing about known output devices.
+ bool output_changed = false;
+ for (newdev_it = u->newOutputDevices.begin(); newdev_it != u->newOutputDevices.end(); ++newdev_it) {
+ QString name = newdev_it.key();
+
+ // The name + index map is always written when a new device is added.
+ Q_ASSERT(s_outputDeviceIndexes.contains(name));
+
+ int index = s_outputDeviceIndexes[name];
+ if (!s_outputDevices.contains(index)) {
+ // This is a totally new device
+ output_changed = true;
+ logMessage(QString("Brand New Output Device Found."));
+ s_outputDevices.insert(index, *newdev_it);
+ } else if (s_outputDevices[index] != *newdev_it) {
+ // We have this device already, but is it different?
+ output_changed = true;
+ logMessage(QString("Change to Existing Output Device (may be Added/Removed or something else)"));
+ s_outputDevices.remove(index);
+ s_outputDevices.insert(index, *newdev_it);
+ }
+ }
+ // Go through the output devices we know about and see if any are no longer mentioned in the list.
+ QMutableMapIterator<QString, int> output_existing_it(s_outputDeviceIndexes);
+ while (output_existing_it.hasNext()) {
+ output_existing_it.next();
+ if (!u->newOutputDevices.contains(output_existing_it.key())) {
+ output_changed = true;
+ logMessage(QString("Output Device Completely Removed"));
+ s_outputDevices.remove(output_existing_it.value());
+ output_existing_it.remove();
+ }
+ }
+
+ // Check for new capture devices or things changing about known capture devices.
+ bool capture_changed = false;
+ for (newdev_it = u->newCaptureDevices.begin(); newdev_it != u->newCaptureDevices.end(); ++newdev_it) {
+ QString name = newdev_it.key();
+
+ // The name + index map is always written when a new device is added.
+ Q_ASSERT(s_captureDeviceIndexes.contains(name));
+
+ int index = s_captureDeviceIndexes[name];
+ if (!s_captureDevices.contains(index)) {
+ // This is a totally new device
+ capture_changed = true;
+ logMessage(QString("Brand New Capture Device Found."));
+ s_captureDevices.insert(index, *newdev_it);
+ } else if (s_captureDevices[index] != *newdev_it) {
+ // We have this device already, but is it different?
+ capture_changed = true;
+ logMessage(QString("Change to Existing Capture Device (may be Added/Removed or something else)"));
+ s_captureDevices.remove(index);
+ s_captureDevices.insert(index, *newdev_it);
+ }
+ }
+ // Go through the capture devices we know about and see if any are no longer mentioned in the list.
+ QMutableMapIterator<QString, int> capture_existing_it(s_captureDeviceIndexes);
+ while (capture_existing_it.hasNext()) {
+ capture_existing_it.next();
+ if (!u->newCaptureDevices.contains(capture_existing_it.key())) {
+ capture_changed = true;
+ logMessage(QString("Capture Device Completely Removed"));
+ s_captureDevices.remove(capture_existing_it.value());
+ capture_existing_it.remove();
+ }
+ }
+
+ // Just copy accross the new priority lists as we know they are valid
+ if (s_outputDevicePriorities != u->newOutputDevicePriorities) {
+ output_changed = true;
+ s_outputDevicePriorities = u->newOutputDevicePriorities;
+ }
+ if (s_captureDevicePriorities != u->newCaptureDevicePriorities) {
+ capture_changed = true;
+ s_captureDevicePriorities = u->newCaptureDevicePriorities;
+ }
+
+ if (s_instance) {
+ // This wont be emitted durring the connection probe phase
+ // which is intensional
+ if (output_changed)
+ s_instance->emitObjectDescriptionChanged(AudioOutputDeviceType);
+ if (capture_changed)
+ s_instance->emitObjectDescriptionChanged(AudioCaptureDeviceType);
+ }
+
+ // We can free the user data as we will not be called again.
+ delete u;
+
+ // Some debug
+ logMessage(QString("Output Device Priority List:"));
+ for (int i = Phonon::NoCategory; i <= Phonon::LastCategory; ++i) {
+ Phonon::Category cat = static_cast<Phonon::Category>(i);
+ if (s_outputDevicePriorities.contains(cat)) {
+ logMessage(QString(" Phonon Category %1").arg(cat));
+ int count = 0;
+ foreach (int j, s_outputDevicePriorities[cat]) {
+ QHash<QByteArray, QVariant> &props = s_outputDevices[j].properties;
+ logMessage(QString(" %1. %2 (Available: %3)").arg(++count).arg(props["name"].toString()).arg(props["available"].toBool()));
+ }
+ }
+ }
+ logMessage(QString("Capture Device Priority List:"));
+ for (int i = Phonon::NoCategory; i <= Phonon::LastCategory; ++i) {
+ Phonon::Category cat = static_cast<Phonon::Category>(i);
+ if (s_captureDevicePriorities.contains(cat)) {
+ logMessage(QString(" Phonon Category %1").arg(cat));
+ int count = 0;
+ foreach (int j, s_captureDevicePriorities[cat]) {
+ QHash<QByteArray, QVariant> &props = s_captureDevices[j].properties;
+ logMessage(QString(" %1. %2 (Available: %3)").arg(++count).arg(props["name"].toString()).arg(props["available"].toBool()));
+ }
+ }
+ }
+
+ // If this is our probe phase, exit now as we're finished reading
+ // our device info and can exit and reconnect
+ if (s_context != c)
+ pa_context_disconnect(c);
+ }
+
+ if (!info)
+ return;
+
+ Q_ASSERT(info->name);
+ Q_ASSERT(info->description);
+ Q_ASSERT(info->icon);
+
+ // QString wrapper
+ QString name(info->name);
+ int index;
+ QMap<Phonon::Category, QMap<int, int> > *new_prio_map_cats; // prio, device
+ QMap<QString, AudioDevice> *new_devices;
+
+ if (name.startsWith("sink:")) {
+ new_devices = &u->newOutputDevices;
+ new_prio_map_cats = &u->newOutputDevicePriorities;
+
+ if (s_outputDeviceIndexes.contains(name))
+ index = s_outputDeviceIndexes[name];
+ else
+ index = s_outputDeviceIndexes[name] = s_deviceIndexCounter++;
+ } else if (name.startsWith("source:")) {
+ new_devices = &u->newCaptureDevices;
+ new_prio_map_cats = &u->newCaptureDevicePriorities;
+
+ if (s_captureDeviceIndexes.contains(name))
+ index = s_captureDeviceIndexes[name];
+ else
+ index = s_captureDeviceIndexes[name] = s_deviceIndexCounter++;
+ } else {
+ // This indicates a bug in pulseaudio.
+ return;
+ }
+
+ // Add the new device itself.
+ new_devices->insert(name, AudioDevice(name, info->description, info->icon, info->index));
+
+ // For each role in the priority, map it to a phonon category and store the order.
+ for (uint32_t i = 0; i < info->n_role_priorities; ++i) {
+ pa_ext_device_manager_role_priority_info* role_prio = &info->role_priorities[i];
+ Q_ASSERT(role_prio->role);
+
+ if (s_roleCategoryMap.contains(role_prio->role)) {
+ Phonon::Category cat = s_roleCategoryMap[role_prio->role];
+
+ (*new_prio_map_cats)[cat].insert(role_prio->priority, index);
+ }
+ }
+}
+
+static void ext_device_manager_subscribe_cb(pa_context *c, void *) {
+ Q_ASSERT(c);
+
+ pa_operation *o;
+ PulseUserData *u = new PulseUserData;
+ if (!(o = pa_ext_device_manager_read(c, ext_device_manager_read_cb, u))) {
+ logMessage(QString("pa_ext_device_manager_read() failed."));
+ delete u;
+ return;
+ }
+ pa_operation_unref(o);
+}
+#endif
+
+void sink_input_cb(pa_context *c, const pa_sink_input_info *i, int eol, void *userdata) {
+ Q_UNUSED(userdata);
+ Q_ASSERT(c);
+
+ if (eol < 0) {
+ if (pa_context_errno(c) == PA_ERR_NOENTITY)
+ return;
+
+ logMessage(QString("Sink input callback failure"));
+ return;
+ }
+
+ if (eol > 0)
+ return;
+
+ Q_ASSERT(i);
+
+ // loop through (*i) and extract phonon->streamindex...
+ const char *t;
+ if ((t = pa_proplist_gets(i->proplist, "phonon.streamid"))) {
+ logMessage(QString("Found PulseAudio stream index %1 for Phonon Output Stream %2").arg(i->index).arg(t));
+ s_outputStreamIndexMap[QString(t)] = i->index;
+
+ // Find the sink's phonon index and notify whoever cares...
+ if (PA_INVALID_INDEX != i->sink) {
+ bool found = false;
+ int device;
+ QMap<int, AudioDevice>::iterator it;
+ for (it = s_outputDevices.begin(); it != s_outputDevices.end(); ++it) {
+ if ((*it).pulseIndex == i->sink) {
+ found = true;
+ device = it.key();
+ break;
+ }
+ }
+ if (found) {
+ // OK so we just emit our signal
+ logMessage(QString("Letting the rest of phonon know about this"));
+ s_instance->emitUsingDevice(QString(t), device);
+ }
+ }
+ }
+}
+
+void source_output_cb(pa_context *c, const pa_source_output_info *i, int eol, void *userdata) {
+ Q_UNUSED(userdata);
+ Q_ASSERT(c);
+
+ if (eol < 0) {
+ if (pa_context_errno(c) == PA_ERR_NOENTITY)
+ return;
+
+ logMessage(QString("Source output callback failure"));
+ return;
+ }
+
+ if (eol > 0)
+ return;
+
+ Q_ASSERT(i);
+
+ // loop through (*i) and extract phonon->streamindex...
+ const char *t;
+ if ((t = pa_proplist_gets(i->proplist, "phonon.streamid"))) {
+ logMessage(QString("Found PulseAudio stream index %1 for Phonon Capture Stream %2").arg(i->index).arg(t));
+ s_captureStreamIndexMap[QString(t)] = i->index;
+
+ // Find the source's phonon index and notify whoever cares...
+ if (PA_INVALID_INDEX != i->source) {
+ bool found = false;
+ int device;
+ QMap<int, AudioDevice>::iterator it;
+ for (it = s_captureDevices.begin(); it != s_captureDevices.end(); ++it) {
+ if ((*it).pulseIndex == i->source) {
+ found = true;
+ device = it.key();
+ break;
+ }
+ }
+ if (found) {
+ // OK so we just emit our signal
+ logMessage(QString("Letting the rest of phonon know about this"));
+ s_instance->emitUsingDevice(QString(t), device);
+ }
+ }
+ }
+}
+
+static void subscribe_cb(pa_context *c, pa_subscription_event_type_t t, uint32_t index, void *userdata) {
+ Q_UNUSED(userdata);
+
+ switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) {
+ case PA_SUBSCRIPTION_EVENT_SINK_INPUT:
+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
+ QString phononid = s_outputStreamIndexMap.key(index);
+ if (!phononid.isEmpty()) {
+ if (s_outputStreamIndexMap.contains(phononid)) {
+ logMessage(QString("Phonon Output Stream %1 is gone at the PA end. Marking it as invalid in our cache as we may reuse it.").arg(phononid));
+ s_outputStreamIndexMap[phononid] = PA_INVALID_INDEX;
+ } else {
+ logMessage(QString("Removing Phonon Output Stream %1 (it's gone!)").arg(phononid));
+ s_outputStreamIndexMap.remove(phononid);
+ }
+ }
+ } else {
+ pa_operation *o;
+ if (!(o = pa_context_get_sink_input_info(c, index, sink_input_cb, NULL))) {
+ logMessage(QString("pa_context_get_sink_input_info() failed"));
+ return;
+ }
+ pa_operation_unref(o);
+ }
+ break;
+
+ case PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT:
+ if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
+ QString phononid = s_captureStreamIndexMap.key(index);
+ if (!phononid.isEmpty()) {
+ if (s_captureStreamIndexMap.contains(phononid)) {
+ logMessage(QString("Phonon Capture Stream %1 is gone at the PA end. Marking it as invalid in our cache as we may reuse it.").arg(phononid));
+ s_captureStreamIndexMap[phononid] = PA_INVALID_INDEX;
+ } else {
+ logMessage(QString("Removing Phonon Capture Stream %1 (it's gone!)").arg(phononid));
+ s_captureStreamIndexMap.remove(phononid);
+ }
+ }
+ } else {
+ pa_operation *o;
+ if (!(o = pa_context_get_source_output_info(c, index, source_output_cb, NULL))) {
+ logMessage(QString("pa_context_get_sink_input_info() failed"));
+ return;
+ }
+ pa_operation_unref(o);
+ }
+ break;
+ }
+}
+
+
+static const char* statename(pa_context_state_t state)
+{
+ switch (state)
+ {
+ case PA_CONTEXT_UNCONNECTED: return "Unconnected";
+ case PA_CONTEXT_CONNECTING: return "Connecting";
+ case PA_CONTEXT_AUTHORIZING: return "Authorizing";
+ case PA_CONTEXT_SETTING_NAME: return "Setting Name";
+ case PA_CONTEXT_READY: return "Ready";
+ case PA_CONTEXT_FAILED: return "Failed";
+ case PA_CONTEXT_TERMINATED: return "Terminated";
+ }
+
+ static QString unknown;
+ unknown = QString("Unknown state: %0").arg(state);
+ return unknown.toAscii().constData();
+}
+
+static void context_state_callback(pa_context *c, void *)
+{
+ Q_ASSERT(c);
+
+ logMessage(QString("context_state_callback %1").arg(statename(pa_context_get_state(c))));
+ pa_context_state_t state = pa_context_get_state(c);
+ if (state == PA_CONTEXT_READY) {
+ // We've connected to PA, so it is active
+ s_pulseActive = true;
+
+ // Attempt to load things up
+ pa_operation *o;
+
+ // 1. Register for the stream changes (except during probe)
+ if (s_context == c) {
+ pa_context_set_subscribe_callback(c, subscribe_cb, NULL);
+
+ if (!(o = pa_context_subscribe(c, (pa_subscription_mask_t)
+ (PA_SUBSCRIPTION_MASK_SINK_INPUT|
+ PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT), NULL, NULL))) {
+ logMessage(QString("pa_context_subscribe() failed"));
+ return;
+ }
+ pa_operation_unref(o);
+ }
+
+#ifdef HAVE_PULSEAUDIO_DEVICE_MANAGER
+ // 2a. Attempt to initialise Device Manager info (except during probe)
+ if (s_context == c) {
+ pa_ext_device_manager_set_subscribe_cb(c, ext_device_manager_subscribe_cb, NULL);
+ if (!(o = pa_ext_device_manager_subscribe(c, 1, NULL, NULL))) {
+ logMessage(QString("pa_ext_device_manager_subscribe() failed"));
+ return;
+ }
+ pa_operation_unref(o);
+ }
+
+ // 3. Attempt to read info from Device Manager
+ PulseUserData *u = new PulseUserData;
+ if (!(o = pa_ext_device_manager_read(c, ext_device_manager_read_cb, u))) {
+ logMessage(QString("pa_ext_device_manager_read() failed. Attempting to continue without device manager support"));
+ createGenericDevices();
+ delete u;
+
+ // If this is our probe phase, exit immediately
+ if (s_context != c)
+ pa_context_disconnect(c);
+
+ return;
+ }
+ pa_operation_unref(o);
+
+#else
+ // If we know do not have Device Manager support, we just create our dummy devices now
+ createGenericDevices();
+
+ // If this is our probe phase, exit immediately
+ if (s_context != c)
+ pa_context_disconnect(c);
+#endif
+ } else if (!PA_CONTEXT_IS_GOOD(state)) {
+ /// @todo Deal with reconnection...
+ //logMessage("Connection to PulseAudio lost");
+
+ // If this is our probe phase, exit our context immediately
+ if (s_context != c)
+ pa_context_disconnect(c);
+ }
+}
+#endif // HAVE_PULSEAUDIO
+
+
+PulseSupport* PulseSupport::getInstance()
+{
+ if (NULL == s_instance) {
+ s_instance = new PulseSupport();
+ }
+ return s_instance;
+}
+
+void PulseSupport::shutdown()
+{
+ if (NULL != s_instance) {
+ delete s_instance;
+ s_instance = NULL;
+ }
+}
+
+PulseSupport::PulseSupport()
+ : QObject(), mEnabled(false)
+{
+#ifdef HAVE_PULSEAUDIO
+ // Initialise our map (is there a better way to do this?)
+ s_roleCategoryMap["none"] = Phonon::NoCategory;
+ s_roleCategoryMap["video"] = Phonon::VideoCategory;
+ s_roleCategoryMap["music"] = Phonon::MusicCategory;
+ s_roleCategoryMap["game"] = Phonon::GameCategory;
+ s_roleCategoryMap["event"] = Phonon::NotificationCategory;
+ s_roleCategoryMap["phone"] = Phonon::CommunicationCategory;
+ //s_roleCategoryMap["animation"]; // No Mapping
+ //s_roleCategoryMap["production"]; // No Mapping
+ s_roleCategoryMap["a11y"] = Phonon::AccessibilityCategory;
+
+ // To allow for easy debugging, give an easy way to disable this pulseaudio check
+ QString pulseenv = qgetenv("PHONON_PULSEAUDIO_DISABLE");
+ if (pulseenv.toInt()) {
+ logMessage("PulseAudio support disabled: PHONON_PULSEAUDIO_DISABLE is set");
+ return;
+ }
+
+ // We require a glib event loop
+ if (QLatin1String(QAbstractEventDispatcher::instance()->metaObject()->className())
+ != "QGuiEventDispatcherGlib") {
+ logMessage("Disabling PulseAudio integration for lack of GLib event loop.");
+ return;
+ }
+
+ // First of all conenct to PA via simple/blocking means and if that succeeds,
+ // use a fully async integrated mainloop method to connect and get proper support.
+ pa_mainloop *p_test_mainloop;
+ if (!(p_test_mainloop = pa_mainloop_new())) {
+ logMessage("PulseAudio support disabled: Unable to create mainloop");
+ return;
+ }
+
+ pa_context *p_test_context;
+ if (!(p_test_context = pa_context_new(pa_mainloop_get_api(p_test_mainloop), "libphonon-probe"))) {
+ logMessage("PulseAudio support disabled: Unable to create context");
+ pa_mainloop_free(p_test_mainloop);
+ return;
+ }
+
+ logMessage("Probing for PulseAudio...");
+ // (cg) Convert to PA_CONTEXT_NOFLAGS when PulseAudio 0.9.19 is required
+ if (pa_context_connect(p_test_context, NULL, static_cast<pa_context_flags_t>(0), NULL) < 0) {
+ logMessage(QString("PulseAudio support disabled: %1").arg(pa_strerror(pa_context_errno(p_test_context))));
+ pa_context_disconnect(p_test_context);
+ pa_context_unref(p_test_context);
+ pa_mainloop_free(p_test_mainloop);
+ return;
+ }
+
+ pa_context_set_state_callback(p_test_context, &context_state_callback, NULL);
+ for (;;) {
+ pa_mainloop_iterate(p_test_mainloop, 1, NULL);
+
+ if (!PA_CONTEXT_IS_GOOD(pa_context_get_state(p_test_context))) {
+ logMessage("PulseAudio probe complete.");
+ break;
+ }
+ }
+ pa_context_disconnect(p_test_context);
+ pa_context_unref(p_test_context);
+ pa_mainloop_free(p_test_mainloop);
+
+ if (!s_pulseActive) {
+ logMessage("PulseAudio support is not available.");
+ return;
+ }
+
+ // If we're still here, PA is available.
+ logMessage("PulseAudio support enabled");
+
+ // Now we connect for real using a proper main loop that we can forget
+ // all about processing.
+ s_mainloop = pa_glib_mainloop_new(NULL);
+ Q_ASSERT(s_mainloop);
+ pa_mainloop_api *api = pa_glib_mainloop_get_api(s_mainloop);
+
+ s_context = pa_context_new(api, "libphonon");
+ // (cg) Convert to PA_CONTEXT_NOFLAGS when PulseAudio 0.9.19 is required
+ if (pa_context_connect(s_context, NULL, static_cast<pa_context_flags_t>(0), 0) >= 0)
+ pa_context_set_state_callback(s_context, &context_state_callback, NULL);
+#endif
+}
+
+PulseSupport::~PulseSupport()
+{
+#ifdef HAVE_PULSEAUDIO
+ if (s_context) {
+ pa_context_disconnect(s_context);
+ s_context = NULL;
+ }
+
+ if (s_mainloop) {
+ pa_glib_mainloop_free(s_mainloop);
+ s_mainloop = NULL;
+ }
+#endif
+}
+
+bool PulseSupport::isActive()
+{
+#ifdef HAVE_PULSEAUDIO
+ return mEnabled && s_pulseActive;
+#else
+ return false;
+#endif
+}
+
+void PulseSupport::enable(bool enabled)
+{
+ mEnabled = enabled;
+}
+
+QList<int> PulseSupport::objectDescriptionIndexes(ObjectDescriptionType type) const
+{
+ QList<int> list;
+
+ if (type != AudioOutputDeviceType && type != AudioCaptureDeviceType)
+ return list;
+
+#ifdef HAVE_PULSEAUDIO
+ if (s_pulseActive) {
+ switch (type) {
+
+ case AudioOutputDeviceType: {
+ QMap<QString, int>::iterator it;
+ for (it = s_outputDeviceIndexes.begin(); it != s_outputDeviceIndexes.end(); ++it) {
+ list.append(*it);
+ }
+ break;
+ }
+ case AudioCaptureDeviceType: {
+ QMap<QString, int>::iterator it;
+ for (it = s_captureDeviceIndexes.begin(); it != s_captureDeviceIndexes.end(); ++it) {
+ list.append(*it);
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+#endif
+
+ return list;
+}
+
+QHash<QByteArray, QVariant> PulseSupport::objectDescriptionProperties(ObjectDescriptionType type, int index) const
+{
+ QHash<QByteArray, QVariant> ret;
+
+ if (type != AudioOutputDeviceType && type != AudioCaptureDeviceType)
+ return ret;
+
+#ifndef HAVE_PULSEAUDIO
+ Q_UNUSED(index);
+#else
+ if (s_pulseActive) {
+ switch (type) {
+
+ case AudioOutputDeviceType:
+ Q_ASSERT(s_outputDevices.contains(index));
+ ret = s_outputDevices[index].properties;
+ break;
+
+ case AudioCaptureDeviceType:
+ Q_ASSERT(s_captureDevices.contains(index));
+ ret = s_captureDevices[index].properties;
+ break;
+
+ default:
+ break;
+ }
+ }
+#endif
+
+ return ret;
+}
+
+QList<int> PulseSupport::objectIndexesByCategory(ObjectDescriptionType type, Category category) const
+{
+ QList<int> ret;
+
+ if (type != AudioOutputDeviceType && type != AudioCaptureDeviceType)
+ return ret;
+
+#ifndef HAVE_PULSEAUDIO
+ Q_UNUSED(category);
+#else
+ if (s_pulseActive) {
+ switch (type) {
+
+ case AudioOutputDeviceType:
+ if (s_outputDevicePriorities.contains(category))
+ ret = s_outputDevicePriorities[category].values();
+ break;
+
+ case AudioCaptureDeviceType:
+ if (s_captureDevicePriorities.contains(category))
+ ret = s_captureDevicePriorities[category].values();
+ break;
+
+ default:
+ break;
+ }
+ }
+#endif
+
+ return ret;
+}
+
+#ifdef HAVE_PULSEAUDIO
+static void setDevicePriority(Category category, QStringList list)
+{
+ QString role = s_roleCategoryMap.key(category);
+ if (role.isEmpty())
+ return;
+
+ logMessage(QString("Reindexing %1: %2").arg(role).arg(list.join(", ")));
+
+ char **devices;
+ devices = pa_xnew(char *, list.size()+1);
+ int i = 0;
+ foreach (QString str, list) {
+ devices[i++] = pa_xstrdup(str.toUtf8().constData());
+ }
+ devices[list.size()] = NULL;
+
+#ifdef HAVE_PULSEAUDIO_DEVICE_MANAGER
+ pa_operation *o;
+ if (!(o = pa_ext_device_manager_reorder_devices_for_role(s_context, role.toUtf8().constData(), (const char**)devices, NULL, NULL)))
+ logMessage(QString("pa_ext_device_manager_reorder_devices_for_role() failed"));
+ else
+ pa_operation_unref(o);
+#endif
+
+ for (i = 0; i < list.size(); ++i)
+ pa_xfree(devices[i]);
+ pa_xfree(devices);
+}
+#endif
+
+void PulseSupport::setOutputDevicePriorityForCategory(Category category, QList<int> order)
+{
+#ifndef HAVE_PULSEAUDIO
+ Q_UNUSED(category);
+ Q_UNUSED(order);
+#else
+ QStringList list;
+ QList<int>::iterator it;
+
+ for (it = order.begin(); it != order.end(); ++it) {
+ if (s_outputDevices.contains(*it)) {
+ list << s_outputDeviceIndexes.key(*it);
+ }
+ }
+ setDevicePriority(category, list);
+#endif
+}
+
+void PulseSupport::setCaptureDevicePriorityForCategory(Category category, QList<int> order)
+{
+#ifndef HAVE_PULSEAUDIO
+ Q_UNUSED(category);
+ Q_UNUSED(order);
+#else
+ QStringList list;
+ QList<int>::iterator it;
+
+ for (it = order.begin(); it != order.end(); ++it) {
+ if (s_captureDevices.contains(*it)) {
+ list << s_captureDeviceIndexes.key(*it);
+ }
+ }
+ setDevicePriority(category, list);
+#endif
+}
+
+void PulseSupport::setStreamPropList(Category category, QString streamUuid)
+{
+#ifndef HAVE_PULSEAUDIO
+ Q_UNUSED(category);
+ Q_UNUSED(streamUuid);
+#else
+ QString role = s_roleCategoryMap.key(category);
+ if (role.isEmpty())
+ return;
+
+ logMessage(QString("Setting role to %1 for streamindex %2").arg(role).arg(streamUuid));
+ setenv("PULSE_PROP_media.role", role.toLatin1().constData(), 1);
+ setenv("PULSE_PROP_phonon.streamid", streamUuid.toLatin1().constData(), 1);
+#endif
+}
+
+void PulseSupport::emitObjectDescriptionChanged(ObjectDescriptionType type)
+{
+ emit objectDescriptionChanged(type);
+}
+
+void PulseSupport::emitUsingDevice(QString streamUuid, int device)
+{
+ emit usingDevice(streamUuid, device);
+}
+
+bool PulseSupport::setOutputDevice(QString streamUuid, int device) {
+#ifndef HAVE_PULSEAUDIO
+ Q_UNUSED(streamUuid);
+ Q_UNUSED(device);
+ return false;
+#else
+ if (s_outputDevices.size() < 2)
+ return true;
+
+ if (!s_outputDevices.contains(device)) {
+ logMessage(QString("Attempting to set Output Device for invalid device id %1.").arg(device));
+ return false;
+ }
+ const QVariant var = s_outputDevices[device].properties["name"];
+ logMessage(QString("Attempting to set Output Device to '%1' for Output Stream %2").arg(var.toString()).arg(streamUuid));
+
+ // Attempt to look up the pulse stream index.
+ if (s_outputStreamIndexMap.contains(streamUuid) && s_outputStreamIndexMap[streamUuid] != PA_INVALID_INDEX) {
+ logMessage(QString("... Found in map. Moving now"));
+
+ uint32_t pulse_device_index = s_outputDevices[device].pulseIndex;
+ uint32_t pulse_stream_index = s_outputStreamIndexMap[streamUuid];
+
+ logMessage(QString("Moving Pulse Sink Input %1 to '%2' (Pulse Sink %3)").arg(pulse_stream_index).arg(var.toString()).arg(pulse_device_index));
+
+ /// @todo Find a way to move the stream without saving it... We don't want to pollute the stream restore db.
+ pa_operation* o;
+ if (!(o = pa_context_move_sink_input_by_index(s_context, pulse_stream_index, pulse_device_index, NULL, NULL))) {
+ logMessage(QString("pa_context_move_sink_input_by_index() failed"));
+ return false;
+ }
+ pa_operation_unref(o);
+ } else {
+ logMessage(QString("... Not found in map. We will be notified of the device when the stream appears and we can process any moves needed then"));
+ }
+ return true;
+#endif
+}
+
+bool PulseSupport::setCaptureDevice(QString streamUuid, int device) {
+#ifndef HAVE_PULSEAUDIO
+ Q_UNUSED(streamUuid);
+ Q_UNUSED(device);
+ return false;
+#else
+ if (s_captureDevices.size() < 2)
+ return true;
+
+ if (!s_captureDevices.contains(device)) {
+ logMessage(QString("Attempting to set Capture Device for invalid device id %1.").arg(device));
+ return false;
+ }
+ const QVariant var = s_captureDevices[device].properties["name"];
+ logMessage(QString("Attempting to set Capture Device to '%1' for Capture Stream %2").arg(var.toString()).arg(streamUuid));
+
+ // Attempt to look up the pulse stream index.
+ if (s_captureStreamIndexMap.contains(streamUuid) && s_captureStreamIndexMap[streamUuid] == PA_INVALID_INDEX) {
+ logMessage(QString("... Found in map. Moving now"));
+
+ uint32_t pulse_device_index = s_captureDevices[device].pulseIndex;
+ uint32_t pulse_stream_index = s_captureStreamIndexMap[streamUuid];
+
+ logMessage(QString("Moving Pulse Source Output %1 to '%2' (Pulse Sink %3)").arg(pulse_stream_index).arg(var.toString()).arg(pulse_device_index));
+
+ /// @todo Find a way to move the stream without saving it... We don't want to pollute the stream restore db.
+ pa_operation* o;
+ if (!(o = pa_context_move_source_output_by_index(s_context, pulse_stream_index, pulse_device_index, NULL, NULL))) {
+ logMessage(QString("pa_context_move_source_output_by_index() failed"));
+ return false;
+ }
+ pa_operation_unref(o);
+ } else {
+ logMessage(QString("... Not found in map. We will be notified of the device when the stream appears and we can process any moves needed then"));
+ }
+ return true;
+#endif
+}
+
+void PulseSupport::clearStreamCache(QString streamUuid) {
+#ifndef HAVE_PULSEAUDIO
+ Q_UNUSED(streamUuid);
+ return;
+#else
+ logMessage(QString("Clearing stream cache for stream %1").arg(streamUuid));
+ s_outputStreamIndexMap.remove(streamUuid);
+ s_captureStreamIndexMap.remove(streamUuid);
+#endif
+}
+
+} // namespace Phonon
+
+QT_END_NAMESPACE
+
+#include "moc_pulsesupport.cpp"
+
+// vim: sw=4 ts=4
diff --git a/src/3rdparty/phonon/phonon/pulsesupport.h b/src/3rdparty/phonon/phonon/pulsesupport.h
new file mode 100644
index 0000000..c38bece
--- /dev/null
+++ b/src/3rdparty/phonon/phonon/pulsesupport.h
@@ -0,0 +1,78 @@
+/* This file is part of the KDE project
+ Copyright (C) 2009 Colin Guthrie <cguthrie@mandriva.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), Nokia Corporation
+ (or its successors, if any) and the KDE Free Qt Foundation, which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef PHONON_PULSESUPPORT_H
+#define PHONON_PULSESUPPORT_H
+
+#include "phonon_export.h"
+#include "phononnamespace.h"
+#include "objectdescription.h"
+
+#include <QtCore/QtGlobal>
+#include <QtCore/QSet>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+namespace Phonon
+{
+ class PHONON_EXPORT PulseSupport : public QObject
+ {
+ Q_OBJECT
+ public:
+ static PulseSupport* getInstance();
+ static void shutdown();
+
+ bool isActive();
+ void enable(bool enabled = true);
+
+ QList<int> objectDescriptionIndexes(ObjectDescriptionType type) const;
+ QHash<QByteArray, QVariant> objectDescriptionProperties(ObjectDescriptionType type, int index) const;
+ QList<int> objectIndexesByCategory(ObjectDescriptionType type, Category category) const;
+
+ void setOutputDevicePriorityForCategory(Category category, QList<int> order);
+ void setCaptureDevicePriorityForCategory(Category category, QList<int> order);
+
+ void setStreamPropList(Category category, QString streamUuid);
+ void emitObjectDescriptionChanged(ObjectDescriptionType);
+ void emitUsingDevice(QString streamUuid, int device);
+
+ bool setOutputDevice(QString streamUuid, int device);
+ bool setCaptureDevice(QString streamUuid, int device);
+ void clearStreamCache(QString streamUuid);
+
+ signals:
+ void objectDescriptionChanged(ObjectDescriptionType);
+ void usingDevice(QString streamUuid, int device);
+
+ private:
+ PulseSupport();
+ ~PulseSupport();
+
+ bool mEnabled;
+ };
+} // namespace Phonon
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif // PHONON_PULSESUPPORT_H
diff --git a/src/3rdparty/phonon/phonon/seekslider.cpp b/src/3rdparty/phonon/phonon/seekslider.cpp
index 41baf2d..b5b25f0 100644
--- a/src/3rdparty/phonon/phonon/seekslider.cpp
+++ b/src/3rdparty/phonon/phonon/seekslider.cpp
@@ -72,12 +72,12 @@ void SeekSlider::setMediaObject(MediaObject *media)
d->media = media;
if (media) {
- connect(media, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
+ connect(media, SIGNAL(stateChanged(Phonon::State, Phonon::State)),
SLOT(_k_stateChanged(Phonon::State)));
connect(media, SIGNAL(totalTimeChanged(qint64)), SLOT(_k_length(qint64)));
connect(media, SIGNAL(tick(qint64)), SLOT(_k_tick(qint64)));
connect(media, SIGNAL(seekableChanged(bool)), SLOT(_k_seekableChanged(bool)));
- connect(media, SIGNAL(currentSourceChanged(Phonon::MediaSource)), SLOT(_k_currentSourceChanged()));
+ connect(media, SIGNAL(currentSourceChanged(const Phonon::MediaSource&)), SLOT(_k_currentSourceChanged()));
d->_k_stateChanged(media->state());
d->_k_seekableChanged(media->isSeekable());
d->_k_length(media->totalTime());
diff --git a/src/3rdparty/phonon/phonon/seekslider_p.h b/src/3rdparty/phonon/phonon/seekslider_p.h
index c87a4b0..911ab25 100644
--- a/src/3rdparty/phonon/phonon/seekslider_p.h
+++ b/src/3rdparty/phonon/phonon/seekslider_p.h
@@ -24,8 +24,8 @@
#define SEEKSLIDER_P_H
#include "seekslider.h"
+#include "swiftslider_p.h"
#include <QtGui/QBoxLayout>
-#include <QtGui/QSlider>
#include <QtGui/QLabel>
#include <QtGui/QPixmap>
#include <QtGui/QIcon>
@@ -84,7 +84,7 @@ class SeekSliderPrivate
void _k_currentSourceChanged();
QBoxLayout layout;
- QSlider slider;
+ SwiftSlider slider;
QLabel iconLabel;
QPointer<MediaObject> media;
bool ticking;
diff --git a/src/3rdparty/phonon/phonon/swiftslider.cpp b/src/3rdparty/phonon/phonon/swiftslider.cpp
new file mode 100644
index 0000000..1e274aa
--- /dev/null
+++ b/src/3rdparty/phonon/phonon/swiftslider.cpp
@@ -0,0 +1,103 @@
+/* This file is part of the KDE project
+ Copyright (C) 2006-2008 Ricardo Villalba <rvm@escomposlinux.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), Nokia Corporation
+ (or its successors, if any) and the KDE Free Qt Foundation, which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "swiftslider_p.h"
+
+#include <QtGui/QMouseEvent>
+#include <QtGui/QStyle>
+#include <QtGui/QStyleOption>
+
+QT_BEGIN_NAMESPACE
+
+#if !defined(QT_NO_PHONON_SEEKSLIDER) && !defined(QT_NO_PHONON_VOLUMESLIDER)
+
+namespace Phonon
+{
+
+SwiftSlider::SwiftSlider(Qt::Orientation orientation, QWidget * parent)
+ : QSlider(orientation, parent)
+{
+}
+
+SwiftSlider::~SwiftSlider()
+{
+}
+
+// Function copied from qslider.cpp
+inline int SwiftSlider::pick(const QPoint &pt) const
+{
+ return orientation() == Qt::Horizontal ? pt.x() : pt.y();
+}
+
+// Function copied from qslider.cpp and modified to make it compile
+int SwiftSlider::pixelPosToRangeValue(int pos) const
+{
+ QStyleOptionSlider opt;
+ initStyleOption(&opt);
+ QRect gr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, this);
+ QRect sr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
+ int sliderMin, sliderMax, sliderLength;
+
+ if (orientation() == Qt::Horizontal) {
+ sliderLength = sr.width();
+ sliderMin = gr.x();
+ sliderMax = gr.right() - sliderLength + 1;
+ } else {
+ sliderLength = sr.height();
+ sliderMin = gr.y();
+ sliderMax = gr.bottom() - sliderLength + 1;
+ }
+ return QStyle::sliderValueFromPosition(minimum(), maximum(), pos - sliderMin,
+ sliderMax - sliderMin, opt.upsideDown);
+}
+
+// Based on code from qslider.cpp
+void SwiftSlider::mousePressEvent(QMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton) {
+ QStyleOptionSlider opt;
+ initStyleOption(&opt);
+ const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
+ const QPoint center = sliderRect.center() - sliderRect.topLeft();
+ // to take half of the slider off for the setSliderPosition call we use the center - topLeft
+
+ if (!sliderRect.contains(event->pos())) {
+ event->accept();
+
+ setSliderPosition(pixelPosToRangeValue(pick(event->pos() - center)));
+ triggerAction(SliderMove);
+ setRepeatAction(SliderNoAction);
+ } else {
+ QSlider::mousePressEvent(event);
+ }
+ } else {
+ QSlider::mousePressEvent(event);
+ }
+}
+
+} // namespace Phonon
+
+#endif //QT_NO_PHONON_VOLUMESLIDER && QT_NO_PHONON_VOLUMESLIDER
+
+QT_END_NAMESPACE
+
+#include "moc_swiftslider_p.cpp"
diff --git a/src/3rdparty/phonon/phonon/swiftslider_p.h b/src/3rdparty/phonon/phonon/swiftslider_p.h
new file mode 100644
index 0000000..b063b47
--- /dev/null
+++ b/src/3rdparty/phonon/phonon/swiftslider_p.h
@@ -0,0 +1,68 @@
+/* This file is part of the KDE project
+ Copyright (C) 2006-2008 Ricardo Villalba <rvm@escomposlinux.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) version 3, or any
+ later version accepted by the membership of KDE e.V. (or its
+ successor approved by the membership of KDE e.V.), Nokia Corporation
+ (or its successors, if any) and the KDE Free Qt Foundation, which shall
+ act as a proxy defined in Section 6 of version 3 of the license.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef SWIFTSLIDER_H
+#define SWIFTSLIDER_H
+
+#include <QtGui/QSlider>
+
+QT_BEGIN_NAMESPACE
+
+#if !defined(QT_NO_PHONON_SEEKSLIDER) && !defined(QT_NO_PHONON_VOLUMESLIDER)
+
+namespace Phonon
+{
+
+/** \class SwiftSlider swiftslider_p.h phonon/SwiftSlider
+ * \short Modified QSlider that allows sudden/quick moves instead of stepped moves ("Click'n'Go" QSlider)
+ *
+ * This is an internal class used by SeekSlider and VolumeSlider.
+ *
+ * Ricardo Villalba, the original author of MySlider.cpp (from the SMPlayer project)
+ * gave his permission for the inclusion of this code inside Phonon by
+ * switching MySlider.cpp to the LGPLv2.1+ license.
+ * See http://smplayer.svn.sourceforge.net/viewvc/smplayer/smplayer/trunk/src/myslider.cpp?revision=2406&view=markup
+ *
+ * The original discussion about a "Click'n'Go QSlider": http://lists.trolltech.com/qt-interest/2006-11/msg00363.html
+ *
+ * \ingroup PhononWidgets
+ */
+class SwiftSlider : public QSlider
+{
+ Q_OBJECT
+public:
+ SwiftSlider(Qt::Orientation orientation, QWidget * parent);
+ ~SwiftSlider();
+
+private:
+ void mousePressEvent(QMouseEvent *event);
+ inline int pick(const QPoint &pt) const;
+ int pixelPosToRangeValue(int pos) const;
+};
+
+} // namespace Phonon
+
+#endif //QT_NO_PHONON_VOLUMESLIDER && QT_NO_PHONON_VOLUMESLIDER
+
+QT_END_NAMESPACE
+
+#endif //SWIFTSLIDER_H
diff --git a/src/3rdparty/phonon/phonon/videowidget.cpp b/src/3rdparty/phonon/phonon/videowidget.cpp
index a9e83a6..4575dfd 100644
--- a/src/3rdparty/phonon/phonon/videowidget.cpp
+++ b/src/3rdparty/phonon/phonon/videowidget.cpp
@@ -28,8 +28,9 @@
#include "phononnamespace_p.h"
#include <QtGui/QAction>
-
-#define PHONON_INTERFACENAME VideoWidgetInterface
+#define IFACES4 VideoWidgetInterface44
+#define IFACES0 VideoWidgetInterface, IFACES4
+#define PHONON_INTERFACENAME IFACES0
QT_BEGIN_NAMESPACE
@@ -48,6 +49,8 @@ VideoWidget::VideoWidget(QWidget *parent)
setMouseTracking(true);
}
+
+
VideoWidget::VideoWidget(VideoWidgetPrivate &dd, QWidget *parent)
: QWidget(parent),
Phonon::AbstractVideoOutput(dd)
@@ -98,6 +101,15 @@ PHONON_INTERFACE_SETTER(setHue, hue, qreal)
PHONON_INTERFACE_GETTER(qreal, saturation, d->saturation)
PHONON_INTERFACE_SETTER(setSaturation, saturation, qreal)
+
+QImage VideoWidget::snapshot() const {
+ K_D(const VideoWidget);
+ ConstIface<IFACES4> iface(d);
+ if(iface) return iface->snapshot();
+ return QImage(); // TODO not implemented in VideoInterface
+}
+
+
void VideoWidget::setFullScreen(bool newFullScreen)
{
pDebug() << Q_FUNC_INFO << newFullScreen;
diff --git a/src/3rdparty/phonon/phonon/videowidget.h b/src/3rdparty/phonon/phonon/videowidget.h
index 1d95490..804e61a 100644
--- a/src/3rdparty/phonon/phonon/videowidget.h
+++ b/src/3rdparty/phonon/phonon/videowidget.h
@@ -172,6 +172,7 @@ class AbstractVideoOutput;
qreal contrast() const;
qreal hue() const;
qreal saturation() const;
+ QImage snapshot() const;
//TODO: bar colors property
public Q_SLOTS:
diff --git a/src/3rdparty/phonon/phonon/videowidgetinterface.h b/src/3rdparty/phonon/phonon/videowidgetinterface.h
index 3e6fd22..0c33956 100644
--- a/src/3rdparty/phonon/phonon/videowidgetinterface.h
+++ b/src/3rdparty/phonon/phonon/videowidgetinterface.h
@@ -53,8 +53,21 @@ class VideoWidgetInterface
//X virtual int overlayCapabilities() const = 0;
//X virtual bool createOverlay(QWidget *widget, int type) = 0;
};
+
+class VideoWidgetInterface44 : public VideoWidgetInterface
+{
+ public:
+ virtual QImage snapshot() const = 0;
+};
}
+#ifdef PHONON_BACKEND_VERSION_4_4
+namespace Phonon { typedef VideoWidgetInterface44 VideoWidgetInterfaceLatest; }
+#else
+namespace Phonon { typedef VideoWidgetInterface VideoWidgetInterfaceLatest; }
+#endif
+
+Q_DECLARE_INTERFACE(Phonon::VideoWidgetInterface44, "VideoWidgetInterface44.phonon.kde.org")
Q_DECLARE_INTERFACE(Phonon::VideoWidgetInterface, "VideoWidgetInterface3.phonon.kde.org")
#endif //QT_NO_PHONON_VIDEO
diff --git a/src/3rdparty/phonon/phonon/volumeslider_p.h b/src/3rdparty/phonon/phonon/volumeslider_p.h
index 3827659..623275f 100644
--- a/src/3rdparty/phonon/phonon/volumeslider_p.h
+++ b/src/3rdparty/phonon/phonon/volumeslider_p.h
@@ -24,8 +24,8 @@
#define VOLUMESLIDER_P_H
#include "volumeslider.h"
+#include "swiftslider_p.h"
#include <QtGui/QBoxLayout>
-#include <QtGui/QSlider>
#include <QtGui/QLabel>
#include <QtGui/QPixmap>
#include <QtGui/QToolButton>
@@ -83,7 +83,7 @@ class VolumeSliderPrivate
private:
QBoxLayout layout;
- QSlider slider;
+ SwiftSlider slider;
QToolButton muteButton;
QIcon volumeIcon;
QIcon mutedIcon;
diff --git a/src/3rdparty/phonon/qt7/audionode.h b/src/3rdparty/phonon/qt7/audionode.h
index 2498e49..dfec817f 100644
--- a/src/3rdparty/phonon/qt7/audionode.h
+++ b/src/3rdparty/phonon/qt7/audionode.h
@@ -72,7 +72,7 @@ namespace QT7
AudioUnit m_audioUnit;
// Only the following methods needs to
- // be overidden by only_one-audio-unit nodes:
+ // be overridden by only_one-audio-unit nodes:
virtual ComponentDescription getAudioNodeDescription() const;
virtual void initializeAudioUnit();
diff --git a/src/3rdparty/phonon/qt7/audionode.mm b/src/3rdparty/phonon/qt7/audionode.mm
index 961230c..77cd627 100644
--- a/src/3rdparty/phonon/qt7/audionode.mm
+++ b/src/3rdparty/phonon/qt7/audionode.mm
@@ -77,6 +77,7 @@ void AudioNode::createAndConnectAUNodes()
// AudioComponentDescription only exists on 10.6+. More fun than we need to
// deal with at the moment, so we'll take the "deprecated" warning instead.
err = AUGraphNewNode(m_audioGraph->audioGraphRef(), &description, 0, 0, &m_auNode);
+
BACKEND_ASSERT2(err != kAUGraphErr_OutputNodeErr, "A MediaObject can only be connected to one audio output device.", FATAL_ERROR)
BACKEND_ASSERT2(err == noErr, "Could not create new AUNode.", FATAL_ERROR)
}
diff --git a/src/3rdparty/phonon/qt7/backendinfo.mm b/src/3rdparty/phonon/qt7/backendinfo.mm
index 0d51db0..d84e014 100644
--- a/src/3rdparty/phonon/qt7/backendinfo.mm
+++ b/src/3rdparty/phonon/qt7/backendinfo.mm
@@ -15,6 +15,12 @@
along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+#import <QTKit/QTMovie.h>
+#ifdef QUICKTIME_C_API_AVAILABLE
+ #include <QuickTime/QuickTime.h>
+ #undef check // avoid name clash;
+#endif
+
#include "backendinfo.h"
#include "backendheader.h"
@@ -22,13 +28,6 @@
#include <AudioUnit/AudioUnit.h>
#include <CoreServices/CoreServices.h>
-#include <QtGui/qmacdefines_mac.h>
-#import <QTKit/QTMovie.h>
-
-#ifdef QUICKTIME_C_API_AVAILABLE
- #include <QuickTime/QuickTime.h>
- #undef check // avoid name clash;
-#endif
QT_BEGIN_NAMESPACE
diff --git a/src/3rdparty/phonon/qt7/mediaobject.h b/src/3rdparty/phonon/qt7/mediaobject.h
index c93eddc..27949ec 100644
--- a/src/3rdparty/phonon/qt7/mediaobject.h
+++ b/src/3rdparty/phonon/qt7/mediaobject.h
@@ -25,10 +25,6 @@
#include "medianode.h"
-#if QT_ALLOW_QUICKTIME
- #include <QuickTime/QuickTime.h>
-#endif
-
QT_BEGIN_NAMESPACE
namespace Phonon
@@ -42,10 +38,7 @@ namespace QT7
class MediaObjectAudioNode;
class MediaObject : public MediaNode,
- public Phonon::MediaObjectInterface
-#ifndef QT_NO_PHONON_MEDIACONTROLLER
- , public Phonon::AddonInterface
-#endif
+ public Phonon::MediaObjectInterface, public Phonon::AddonInterface
{
Q_OBJECT
Q_INTERFACES(Phonon::MediaObjectInterface Phonon::AddonInterface)
@@ -99,10 +92,6 @@ namespace QT7
int videoOutputCount();
-#if QT_ALLOW_QUICKTIME
- void displayLinkEvent();
-#endif
-
signals:
void stateChanged(Phonon::State,Phonon::State);
void tick(qint64);
@@ -116,16 +105,6 @@ namespace QT7
void metaDataChanged(QMultiMap<QString,QString>);
void currentSourceChanged(const MediaSource &newSource);
- // Add-on interface:
- void availableSubtitlesChanged();
- void availableAudioChannelsChanged();
- void titleChanged(int);
- void availableTitlesChanged(int);
- void chapterChanged(int);
- void availableChaptersChanged(int);
- void angleChanged(int);
- void availableAnglesChanged(int);
-
protected:
void mediaNodeEvent(const MediaNodeEvent *event);
bool event(QEvent *event);
@@ -139,14 +118,7 @@ namespace QT7
QuickTimeVideoPlayer *m_nextVideoPlayer;
QuickTimeAudioPlayer *m_nextAudioPlayer;
MediaObjectAudioNode *m_mediaObjectAudioNode;
-
-#if QT_ALLOW_QUICKTIME
- CVDisplayLinkRef m_displayLink;
- QMutex m_displayLinkMutex;
- bool m_pendingDisplayLinkEvent;
- void startDisplayLink();
- void stopDisplayLink();
-#endif
+ QuickTimeMetaData *m_metaData;
qint32 m_tickInterval;
qint32 m_transitionTime;
@@ -155,14 +127,12 @@ namespace QT7
float m_percentageLoaded;
int m_tickTimer;
- int m_videoTimer;
- int m_audioTimer;
+ int m_bufferTimer;
int m_rapidTimer;
bool m_waitNextSwap;
int m_swapTimeLeft;
QTime m_swapTime;
- bool m_autoplayTitles;
void synchAudioVideo();
void updateCurrentTime();
@@ -171,7 +141,8 @@ namespace QT7
void pause_internal();
void play_internal();
void setupAudioSystem();
- void restartAudioVideoTimers();
+ void updateTimer(int &timer, int interval);
+ void bufferAudioVideo();
void updateRapidly();
void updateCrossFade();
void updateAudioBuffers();
@@ -183,7 +154,6 @@ namespace QT7
void inspectVideoGraphRecursive(MediaNode *node, int &effectCount, int &outputCount);
void inspectGraph();
bool isCrossFading();
- void setCurrentTrack(int track);
QString m_errorString;
Phonon::ErrorType m_errorType;
diff --git a/src/3rdparty/phonon/qt7/mediaobject.mm b/src/3rdparty/phonon/qt7/mediaobject.mm
index 677640c..002c337 100644
--- a/src/3rdparty/phonon/qt7/mediaobject.mm
+++ b/src/3rdparty/phonon/qt7/mediaobject.mm
@@ -46,6 +46,7 @@ MediaObject::MediaObject(QObject *parent) : MediaNode(AudioSource | VideoSource,
m_mediaObjectAudioNode = new MediaObjectAudioNode(m_audioPlayer, m_nextAudioPlayer);
setAudioNode(m_mediaObjectAudioNode);
+ m_metaData = new QuickTimeMetaData();
m_audioGraph = new AudioGraph(this);
m_tickInterval = 0;
@@ -54,7 +55,6 @@ MediaObject::MediaObject(QObject *parent) : MediaNode(AudioSource | VideoSource,
m_transitionTime = 0;
m_percentageLoaded = 0;
m_waitNextSwap = false;
- m_autoplayTitles = true;
m_audioEffectCount = 0;
m_audioOutputCount = 0;
m_videoEffectCount = 0;
@@ -63,28 +63,20 @@ MediaObject::MediaObject(QObject *parent) : MediaNode(AudioSource | VideoSource,
m_errorType = Phonon::NoError;
m_tickTimer = 0;
- m_videoTimer = 0;
- m_audioTimer = 0;
+ m_bufferTimer = 0;
m_rapidTimer = 0;
-#if QT_ALLOW_QUICKTIME
- m_displayLink = 0;
- m_pendingDisplayLinkEvent = false;
-#endif
-
checkForError();
}
MediaObject::~MediaObject()
-{
- // m_mediaObjectAudioNode is owned by super class.
-#if QT_ALLOW_QUICKTIME
- stopDisplayLink();
-#endif
+{
+ // m_mediaObjectAudioNode is owned by super class.
m_audioPlayer->unsetVideoPlayer();
m_nextAudioPlayer->unsetVideoPlayer();
delete m_videoPlayer;
delete m_nextVideoPlayer;
+ delete m_metaData;
checkForError();
}
@@ -96,7 +88,7 @@ bool MediaObject::setState(Phonon::State state)
emit stateChanged(m_state, prevState);
if (m_state != state){
// End-application did something
- // upon receiving the signal.
+ // upon receiving the signal.
return false;
}
}
@@ -130,7 +122,7 @@ void MediaObject::inspectGraph()
// Inspect the graph to check wether there are any
// effects or outputs connected. This will have
// influence on the audio system and video system that ends up beeing used:
- int prevVideoOutputCount = m_videoOutputCount;
+ int prevVideoOutputCount = m_videoOutputCount;
m_audioEffectCount = 0;
m_audioOutputCount = 0;
m_videoEffectCount = 0;
@@ -142,7 +134,7 @@ void MediaObject::inspectGraph()
if (m_videoOutputCount != prevVideoOutputCount){
MediaNodeEvent e1(MediaNodeEvent::VideoOutputCountChanged, &m_videoOutputCount);
notify(&e1);
- }
+ }
}
void MediaObject::setupAudioSystem()
@@ -175,14 +167,14 @@ void MediaObject::setupAudioSystem()
if (newAudioSystem == m_audioSystem)
return;
-
+
// Enable selected audio system:
- m_audioSystem = newAudioSystem;
+ m_audioSystem = newAudioSystem;
switch (newAudioSystem){
case AS_Silent:
m_audioGraph->stop();
m_videoPlayer->enableAudio(false);
- m_nextVideoPlayer->enableAudio(false);
+ m_nextVideoPlayer->enableAudio(false);
m_audioPlayer->enableAudio(false);
m_nextAudioPlayer->enableAudio(false);
break;
@@ -222,28 +214,28 @@ void MediaObject::setSource(const MediaSource &source)
IMPLEMENTED;
PhononAutoReleasePool pool;
setState(Phonon::LoadingState);
-
+
// Save current state for event/signal handling below:
bool prevHasVideo = m_videoPlayer->hasVideo();
qint64 prevTotalTime = totalTime();
- int prevTrackCount = m_videoPlayer->trackCount();
m_waitNextSwap = false;
-
+
// Cancel cross-fade if any:
m_nextVideoPlayer->pause();
m_nextAudioPlayer->pause();
m_mediaObjectAudioNode->cancelCrossFade();
-
+
// Set new source:
m_audioPlayer->unsetVideoPlayer();
m_videoPlayer->setMediaSource(source);
m_audioPlayer->setVideoPlayer(m_videoPlayer);
+ m_metaData->setVideo(m_videoPlayer);
- m_audioGraph->updateStreamSpecifications();
+ m_audioGraph->updateStreamSpecifications();
m_nextAudioPlayer->unsetVideoPlayer();
- m_nextVideoPlayer->unsetCurrentMediaSource();
+ m_nextVideoPlayer->unsetVideo();
m_currentTime = 0;
-
+
// Emit/notify information about the new source:
QRect videoRect = m_videoPlayer->videoRect();
MediaNodeEvent e1(MediaNodeEvent::VideoFrameSizeChanged, &videoRect);
@@ -254,14 +246,12 @@ void MediaObject::setSource(const MediaSource &source)
updateVideo(emptyFrame);
emit currentSourceChanged(source);
- emit metaDataChanged(m_videoPlayer->metaData());
+ emit metaDataChanged(m_metaData->metaData());
if (prevHasVideo != m_videoPlayer->hasVideo())
- emit hasVideoChanged(m_videoPlayer->hasVideo());
+ emit hasVideoChanged(m_videoPlayer->hasVideo());
if (prevTotalTime != totalTime())
- emit totalTimeChanged(totalTime());
- if (prevTrackCount != m_videoPlayer->trackCount())
- emit availableTitlesChanged(m_videoPlayer->trackCount());
+ emit totalTimeChanged(totalTime());
if (checkForError())
return;
if (!m_videoPlayer->isDrmAuthorized())
@@ -270,7 +260,7 @@ void MediaObject::setSource(const MediaSource &source)
return;
if (!m_videoPlayer->canPlayMedia())
SET_ERROR("Cannot play media.", FATAL_ERROR)
-
+
// The state might have changed from LoadingState
// as a response to an error state change. So we
// need to check it before stopping:
@@ -297,30 +287,28 @@ void MediaObject::swapCurrentWithNext(qint32 transitionTime)
// Save current state for event/signal handling below:
bool prevHasVideo = m_videoPlayer->hasVideo();
qint64 prevTotalTime = totalTime();
- int prevTrackCount = m_videoPlayer->trackCount();
qSwap(m_audioPlayer, m_nextAudioPlayer);
qSwap(m_videoPlayer, m_nextVideoPlayer);
m_mediaObjectAudioNode->startCrossFade(transitionTime);
m_audioGraph->updateStreamSpecifications();
+ m_metaData->setVideo(m_videoPlayer);
m_waitNextSwap = false;
m_currentTime = 0;
-
+
// Emit/notify information about the new source:
QRect videoRect = m_videoPlayer->videoRect();
MediaNodeEvent e1(MediaNodeEvent::VideoFrameSizeChanged, &videoRect);
notify(&e1);
emit currentSourceChanged(m_videoPlayer->mediaSource());
- emit metaDataChanged(m_videoPlayer->metaData());
+ emit metaDataChanged(m_metaData->metaData());
if (prevHasVideo != m_videoPlayer->hasVideo())
- emit hasVideoChanged(m_videoPlayer->hasVideo());
+ emit hasVideoChanged(m_videoPlayer->hasVideo());
if (prevTotalTime != totalTime())
emit totalTimeChanged(totalTime());
- if (prevTrackCount != m_videoPlayer->trackCount())
- emit availableTitlesChanged(m_videoPlayer->trackCount());
if (checkForError())
return;
if (!m_videoPlayer->isDrmAuthorized())
@@ -339,107 +327,28 @@ void MediaObject::swapCurrentWithNext(qint32 transitionTime)
}
}
-#if QT_ALLOW_QUICKTIME
-static CVReturn displayLinkCallback(CVDisplayLinkRef /*displayLink*/,
- const CVTimeStamp */*inNow*/,
- const CVTimeStamp */*inOutputTime*/,
- CVOptionFlags /*flagsIn*/,
- CVOptionFlags */*flagsOut*/,
- void *userData)
-{
- MediaObject *mediaObject = static_cast<MediaObject *>(userData);
- mediaObject->displayLinkEvent();
- return kCVReturnSuccess;
-}
-
-void MediaObject::displayLinkEvent()
-{
- // This function is called from a
- // thread != gui thread. So we post the event.
- // But we need to make sure that we don't post faster
- // than the event loop can eat:
- m_displayLinkMutex.lock();
- bool pending = m_pendingDisplayLinkEvent;
- m_pendingDisplayLinkEvent = true;
- m_displayLinkMutex.unlock();
-
- if (!pending)
- qApp->postEvent(this, new QEvent(QEvent::User), Qt::HighEventPriority);
-}
-
-void MediaObject::startDisplayLink()
+void MediaObject::updateTimer(int &timer, int interval)
{
- if (m_displayLink)
- return;
- OSStatus err = CVDisplayLinkCreateWithCGDisplay(kCGDirectMainDisplay, &m_displayLink);
- if (err != noErr)
- goto fail;
- err = CVDisplayLinkSetCurrentCGDisplay(m_displayLink, kCGDirectMainDisplay);
- if (err != noErr)
- goto fail;
- err = CVDisplayLinkSetOutputCallback(m_displayLink, displayLinkCallback, this);
- if (err != noErr)
- goto fail;
- err = CVDisplayLinkStart(m_displayLink);
- if (err != noErr)
- goto fail;
- return;
-fail:
- stopDisplayLink();
-}
-
-void MediaObject::stopDisplayLink()
-{
- if (!m_displayLink)
- return;
- CVDisplayLinkStop(m_displayLink);
- CFRelease(m_displayLink);
- m_displayLink = 0;
-}
-#endif
-
-void MediaObject::restartAudioVideoTimers()
-{
- if (m_videoTimer)
- killTimer(m_videoTimer);
- if (m_audioTimer)
- killTimer(m_audioTimer);
-
-#if QT_ALLOW_QUICKTIME
- // We prefer to use a display link as timer if available, since
- // it is more steady, and results in better and smoother frame drawing:
- startDisplayLink();
- if (!m_displayLink){
- float fps = m_videoPlayer->staticFps();
- long videoUpdateFrequency = fps ? long(1000.0f / fps) : 0.001;
- m_videoTimer = startTimer(videoUpdateFrequency);
- }
-#else
- float fps = m_videoPlayer->staticFps();
- long videoUpdateFrequency = fps ? long(1000.0f / fps) : 0.001;
- m_videoTimer = startTimer(videoUpdateFrequency);
-#endif
-
- long audioUpdateFrequency = m_audioPlayer->regularTaskFrequency();
- m_audioTimer = startTimer(audioUpdateFrequency);
- updateVideoFrames();
- updateAudioBuffers();
+ if (timer)
+ killTimer(timer);
+ timer = 0;
+ if (interval >= 0)
+ timer = startTimer(interval);
}
void MediaObject::play_internal()
{
// Play main audio/video:
m_videoPlayer->play();
- m_audioPlayer->play();
+ m_audioPlayer->play();
updateLipSynch(0);
// Play old audio/video to finish cross-fade:
if (m_nextVideoPlayer->currentTime() > 0){
m_nextVideoPlayer->play();
m_nextAudioPlayer->play();
}
- restartAudioVideoTimers();
- if (!m_rapidTimer)
- m_rapidTimer = startTimer(100);
+ bufferAudioVideo();
+ updateTimer(m_rapidTimer, 100);
}
void MediaObject::pause_internal()
@@ -449,15 +358,9 @@ void MediaObject::pause_internal()
m_nextAudioPlayer->pause();
m_videoPlayer->pause();
m_nextVideoPlayer->pause();
- killTimer(m_rapidTimer);
- killTimer(m_videoTimer);
- killTimer(m_audioTimer);
- m_rapidTimer = 0;
- m_videoTimer = 0;
- m_audioTimer = 0;
-#if QT_ALLOW_QUICKTIME
- stopDisplayLink();
-#endif
+ updateTimer(m_rapidTimer, -1);
+ updateTimer(m_bufferTimer, -1);
+
if (m_waitNextSwap)
m_swapTimeLeft = m_swapTime.msecsTo(QTime::currentTime());
}
@@ -479,7 +382,7 @@ void MediaObject::play()
if (!m_videoPlayer->canPlayMedia())
return;
if (!setState(Phonon::PlayingState))
- return;
+ return;
if (m_audioSystem == AS_Graph){
m_audioGraph->start();
m_mediaObjectAudioNode->setMute(true);
@@ -520,7 +423,7 @@ void MediaObject::stop()
if (!setState(Phonon::StoppedState))
return;
m_waitNextSwap = false;
- m_nextVideoPlayer->unsetCurrentMediaSource();
+ m_nextVideoPlayer->unsetVideo();
m_nextAudioPlayer->unsetVideoPlayer();
pause_internal();
seek(0);
@@ -532,9 +435,9 @@ void MediaObject::seek(qint64 milliseconds)
IMPLEMENTED;
if (m_state == Phonon::ErrorState)
return;
-
+
// Stop cross-fade if any:
- m_nextVideoPlayer->unsetCurrentMediaSource();
+ m_nextVideoPlayer->unsetVideo();
m_nextAudioPlayer->unsetVideoPlayer();
m_mediaObjectAudioNode->cancelCrossFade();
@@ -543,7 +446,7 @@ void MediaObject::seek(qint64 milliseconds)
m_videoPlayer->seek(milliseconds);
m_audioPlayer->seek(m_videoPlayer->currentTime());
m_mediaObjectAudioNode->setMute(false);
-
+
// Update time and cancel pending swap:
if (m_currentTime < m_videoPlayer->duration())
m_waitNextSwap = false;
@@ -654,7 +557,7 @@ bool MediaObject::isSeekable() const
qint64 MediaObject::currentTime() const
{
IMPLEMENTED_SILENT;
- const_cast<MediaObject *>(this)->updateCurrentTime();
+ const_cast<MediaObject *>(this)->updateCurrentTime();
return m_currentTime;
}
@@ -664,24 +567,19 @@ void MediaObject::updateCurrentTime()
m_currentTime = (m_audioSystem == AS_Graph) ? m_audioPlayer->currentTime() : m_videoPlayer->currentTime();
quint64 total = m_videoPlayer->duration();
- if (m_videoPlayer->currentTrack() < m_videoPlayer->trackCount() - 1){
- // There are still more tracks to play after the current track.
- if (m_autoplayTitles) {
- if (lastUpdateTime < m_currentTime && m_currentTime == total)
- setCurrentTrack(m_videoPlayer->currentTrack() + 1);
- }
- } else if (m_nextVideoPlayer->state() == QuickTimeVideoPlayer::NoMedia){
- // There is no more sources or tracks to play after the current source.
- // Check if it's time to emit aboutToFinish:
- quint32 mark = qMax(quint64(0), qMin(total, total + m_transitionTime - 2000));
- if (lastUpdateTime < mark && mark <= m_currentTime)
- emit aboutToFinish();
-
- // Check if it's time to emit prefinishMarkReached:
- mark = qMax(quint64(0), total - m_prefinishMark);
- if (lastUpdateTime < mark && mark <= m_currentTime)
- emit prefinishMarkReached(total - m_currentTime);
+ // Check if it's time to emit aboutToFinish:
+ quint32 mark = qMax(quint64(0), qMin(total, total + m_transitionTime - 2000));
+ if (lastUpdateTime < mark && mark <= m_currentTime)
+ emit aboutToFinish();
+ // Check if it's time to emit prefinishMarkReached:
+ mark = qMax(quint64(0), total - m_prefinishMark);
+ if (lastUpdateTime < mark && mark <= m_currentTime)
+ emit prefinishMarkReached(total - m_currentTime);
+
+ if (m_nextVideoPlayer->state() == QuickTimeVideoPlayer::NoMedia){
+ // There is no next source in que.
+ // Check if it's time to emit finished:
if (lastUpdateTime < m_currentTime && m_currentTime == total){
emit finished();
m_currentTime = (m_audioSystem == AS_Graph) ? m_audioPlayer->currentTime() : m_videoPlayer->currentTime();
@@ -691,7 +589,7 @@ void MediaObject::updateCurrentTime()
} else {
// We have a next source.
// Check if it's time to swap to next source:
- quint32 mark = qMax(quint64(0), total + m_transitionTime);
+ mark = qMax(quint64(0), total + m_transitionTime);
if (m_waitNextSwap && m_state == Phonon::PlayingState &&
m_transitionTime < m_swapTime.msecsTo(QTime::currentTime())){
swapCurrentWithNext(0);
@@ -794,14 +692,14 @@ bool MediaObject::setAudioDeviceOnMovie(int id)
void MediaObject::updateCrossFade()
{
- m_mediaObjectAudioNode->updateCrossFade(m_currentTime);
+ m_mediaObjectAudioNode->updateCrossFade(m_currentTime);
// Clean-up previous movie if done fading:
if (m_mediaObjectAudioNode->m_fadeDuration == 0){
if (m_nextVideoPlayer->isPlaying() || m_nextAudioPlayer->isPlaying()){
- m_nextVideoPlayer->unsetCurrentMediaSource();
+ m_nextVideoPlayer->unsetVideo();
m_nextAudioPlayer->unsetVideoPlayer();
}
- }
+ }
}
void MediaObject::updateBufferStatus()
@@ -830,7 +728,7 @@ void MediaObject::updateVideoFrames()
// Draw next frame if awailable:
if (m_videoPlayer->videoFrameChanged()){
updateLipSynch(50);
- VideoFrame frame(m_videoPlayer);
+ VideoFrame frame(m_videoPlayer);
if (m_nextVideoPlayer->isPlaying()
&& m_nextVideoPlayer->hasVideo()
&& isCrossFading()){
@@ -838,9 +736,9 @@ void MediaObject::updateVideoFrames()
frame.setBackgroundFrame(bgFrame);
frame.setBaseOpacity(m_mediaObjectAudioNode->m_volume1);
}
-
+
// Send the frame through the graph:
- updateVideo(frame);
+ updateVideo(frame);
checkForError();
}
}
@@ -851,7 +749,7 @@ void MediaObject::updateLipSynch(int allowedOffset)
return;
if (m_videoSinkList.isEmpty() || m_audioSinkList.isEmpty())
return;
-
+
if (m_videoPlayer->hasVideo()){
qint64 diff = m_audioPlayer->currentTime() - m_videoPlayer->currentTime();
if (-allowedOffset > diff || diff > allowedOffset)
@@ -865,6 +763,16 @@ void MediaObject::updateLipSynch(int allowedOffset)
}
}
+void MediaObject::bufferAudioVideo()
+{
+ long nextVideoUpdate = m_videoPlayer->hasVideo() ? 30 : INT_MAX;
+ long nextAudioUpdate = m_audioPlayer->regularTaskFrequency();
+ updateAudioBuffers();
+ updateVideoFrames();
+ if (m_state == Phonon::PlayingState)
+ updateTimer(m_bufferTimer, qMin(nextVideoUpdate, nextAudioUpdate));
+}
+
void MediaObject::updateRapidly()
{
updateCurrentTime();
@@ -889,8 +797,8 @@ void MediaObject::mediaNodeEvent(const MediaNodeEvent *event)
synchAudioVideo();
checkForError();
m_mediaObjectAudioNode->setMute(false);
- if (m_state == Phonon::PlayingState)
- restartAudioVideoTimers();
+ if (m_state == Phonon::PlayingState)
+ bufferAudioVideo();
break;
case MediaNodeEvent::AudioGraphCannotPlay:
case MediaNodeEvent::AudioGraphInitialized:
@@ -901,7 +809,7 @@ void MediaObject::mediaNodeEvent(const MediaNodeEvent *event)
checkForError();
m_mediaObjectAudioNode->setMute(false);
}
- break;
+ break;
default:
break;
}
@@ -910,67 +818,29 @@ void MediaObject::mediaNodeEvent(const MediaNodeEvent *event)
bool MediaObject::event(QEvent *event)
{
switch (event->type()){
-#if QT_ALLOW_QUICKTIME
- case QEvent::User:{
- m_displayLinkMutex.lock();
- m_pendingDisplayLinkEvent = false;
- m_displayLinkMutex.unlock();
- updateVideoFrames();
- break; }
-#endif
- case QEvent::Timer:{
- int timerId = static_cast<QTimerEvent *>(event)->timerId();
- if (timerId == m_rapidTimer)
+ case QEvent::Timer: {
+ QTimerEvent *timerEvent = static_cast<QTimerEvent *>(event);
+ if (timerEvent->timerId() == m_rapidTimer)
updateRapidly();
- else if (timerId == m_tickTimer)
+ else if (timerEvent->timerId() == m_tickTimer)
emit tick(currentTime());
- else if (timerId == m_videoTimer)
- updateVideoFrames();
- else if (timerId == m_audioTimer)
- updateAudioBuffers();
- break; }
+ else if (timerEvent->timerId() == m_bufferTimer)
+ bufferAudioVideo();
+ }
+ break;
default:
break;
}
return QObject::event(event);
}
-void MediaObject::setCurrentTrack(int track)
+bool MediaObject::hasInterface(Interface /*interface*/) const
{
- if (track == m_videoPlayer->currentTrack() || track < 0 || track >= m_videoPlayer->trackCount())
- return;
-
- m_videoPlayer->setCurrentTrack(track);
- emit titleChanged(track);
- emit metaDataChanged(m_videoPlayer->metaData());
+ return false;
}
-bool MediaObject::hasInterface(Interface iface) const
+QVariant MediaObject::interfaceCall(Interface /*interface*/, int /*command*/, const QList<QVariant> &/*arguments*/)
{
- return iface == AddonInterface::TitleInterface;
-}
-
-QVariant MediaObject::interfaceCall(Interface iface, int command, const QList<QVariant> &params)
-{
- switch (iface) {
- case TitleInterface:
- switch (command) {
- case availableTitles:
- return m_videoPlayer->trackCount();
- case title:
- return m_videoPlayer->currentTrack();
- case setTitle:
- setCurrentTrack(params.first().toInt());
- break;
- case autoplayTitles:
- return m_autoplayTitles;
- case setAutoplayTitles:
- m_autoplayTitles = params.first().toBool();
- break;
- }
- default:
- break;
- }
return QVariant();
}
diff --git a/src/3rdparty/phonon/qt7/mediaobjectaudionode.mm b/src/3rdparty/phonon/qt7/mediaobjectaudionode.mm
index 66d6041..39b0d4e 100644
--- a/src/3rdparty/phonon/qt7/mediaobjectaudionode.mm
+++ b/src/3rdparty/phonon/qt7/mediaobjectaudionode.mm
@@ -15,6 +15,8 @@
along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+#import <QTKit/QTMovie.h>
+
#include "mediaobjectaudionode.h"
#include "quicktimeaudioplayer.h"
#include "quicktimevideoplayer.h"
diff --git a/src/3rdparty/phonon/qt7/quicktimeaudioplayer.mm b/src/3rdparty/phonon/qt7/quicktimeaudioplayer.mm
index 61c97cc..aefec02 100644
--- a/src/3rdparty/phonon/qt7/quicktimeaudioplayer.mm
+++ b/src/3rdparty/phonon/qt7/quicktimeaudioplayer.mm
@@ -15,6 +15,8 @@
along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+#import <QTKit/QTMovie.h>
+
#include "quicktimeaudioplayer.h"
#include "quicktimevideoplayer.h"
#include "audiograph.h"
diff --git a/src/3rdparty/phonon/qt7/quicktimemetadata.h b/src/3rdparty/phonon/qt7/quicktimemetadata.h
index c589535..d524183 100644
--- a/src/3rdparty/phonon/qt7/quicktimemetadata.h
+++ b/src/3rdparty/phonon/qt7/quicktimemetadata.h
@@ -38,8 +38,10 @@ namespace QT7
class QuickTimeMetaData
{
public:
- QuickTimeMetaData(QuickTimeVideoPlayer *videoPlayer);
- void update();
+ QuickTimeMetaData();
+ virtual ~QuickTimeMetaData();
+
+ void setVideo(QuickTimeVideoPlayer *videoPlayer);
QMultiMap<QString, QString> metaData();
private:
@@ -47,8 +49,6 @@ namespace QT7
bool m_movieChanged;
QuickTimeVideoPlayer *m_videoPlayer;
void readMetaData();
- void guessMetaDataForCD();
- void readMetaDataFromMovie();
#ifdef QUICKTIME_C_API_AVAILABLE
QString stripCopyRightSymbol(const QString &key);
diff --git a/src/3rdparty/phonon/qt7/quicktimemetadata.mm b/src/3rdparty/phonon/qt7/quicktimemetadata.mm
index 2dcc152..4ae3e2c 100644
--- a/src/3rdparty/phonon/qt7/quicktimemetadata.mm
+++ b/src/3rdparty/phonon/qt7/quicktimemetadata.mm
@@ -15,7 +15,8 @@
along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <QtCore/QFileInfo>
+#import <QTKit/QTMovie.h>
+
#include "quicktimemetadata.h"
#include "quicktimevideoplayer.h"
@@ -26,14 +27,19 @@ namespace Phonon
namespace QT7
{
-QuickTimeMetaData::QuickTimeMetaData(QuickTimeVideoPlayer *videoPlayer)
+QuickTimeMetaData::QuickTimeMetaData()
{
- m_videoPlayer = videoPlayer;
+ m_videoPlayer = 0;
m_movieChanged = false;
}
-void QuickTimeMetaData::update()
+QuickTimeMetaData::~QuickTimeMetaData()
+{
+}
+
+void QuickTimeMetaData::setVideo(QuickTimeVideoPlayer *videoPlayer)
{
+ m_videoPlayer = videoPlayer;
m_movieChanged = true;
m_metaData.clear();
}
@@ -141,22 +147,14 @@ void QuickTimeMetaData::readFormattedData(QTMetaDataRef metaDataRef, OSType form
#endif // QUICKTIME_C_API_AVAILABLE
-void QuickTimeMetaData::guessMetaDataForCD()
-{
- QString album = QFileInfo(m_videoPlayer->movieCompactDiscPath()).fileName();
- QString title = QFileInfo(m_videoPlayer->currentTrackPath()).fileName();
- title = title.left(title.lastIndexOf('.'));
- m_metaData.insert(QLatin1String("ALBUM"), album);
- m_metaData.insert(QLatin1String("TITLE"), title);
- m_metaData.insert(QLatin1String("TRACKNUMBER"), QString::number(m_videoPlayer->currentTrack()));
-}
-
-void QuickTimeMetaData::readMetaDataFromMovie()
+void QuickTimeMetaData::readMetaData()
{
+ if (!m_videoPlayer)
+ return;
QMultiMap<QString, QString> metaMap;
-
+
#ifdef QUICKTIME_C_API_AVAILABLE
- QTMetaDataRef metaDataRef;
+ QTMetaDataRef metaDataRef;
OSStatus err = QTCopyMovieMetaData([m_videoPlayer->qtMovie() quickTimeMovie], &metaDataRef);
BACKEND_ASSERT2(err == noErr, "Could not read QuickTime meta data", NORMAL_ERROR)
@@ -177,17 +175,6 @@ void QuickTimeMetaData::readMetaDataFromMovie()
m_metaData.insert(QLatin1String("DESCRIPTION"), metaMap.value(QLatin1String("des")));
}
-void QuickTimeMetaData::readMetaData()
-{
- if (!m_videoPlayer)
- return;
-
- if (m_videoPlayer->mediaSource().type() == Phonon::MediaSource::Disc)
- guessMetaDataForCD();
- else
- readMetaDataFromMovie();
-}
-
QMultiMap<QString, QString> QuickTimeMetaData::metaData()
{
if (m_videoPlayer && m_videoPlayer->hasMovie() && m_movieChanged)
diff --git a/src/3rdparty/phonon/qt7/quicktimevideoplayer.h b/src/3rdparty/phonon/qt7/quicktimevideoplayer.h
index 98eacb5..0b3aec2 100644
--- a/src/3rdparty/phonon/qt7/quicktimevideoplayer.h
+++ b/src/3rdparty/phonon/qt7/quicktimevideoplayer.h
@@ -20,7 +20,6 @@
#include "backendheader.h"
-#include <QtGui/qmacdefines_mac.h>
#import <QTKit/QTDataReference.h>
#import <QTKit/QTMovie.h>
@@ -39,7 +38,6 @@ namespace Phonon
namespace QT7
{
class QuickTimeStreamReader;
- class QuickTimeMetaData;
class VideoRenderWidgetQTMovieView;
class QuickTimeVideoPlayer : QObject
@@ -57,7 +55,7 @@ namespace QT7
void setMediaSource(const MediaSource &source);
MediaSource mediaSource() const;
- void unsetCurrentMediaSource();
+ void unsetVideo();
void play();
void pause();
@@ -68,13 +66,11 @@ namespace QT7
GLuint currentFrameAsGLTexture();
void *currentFrameAsCIImage();
QImage currentFrameAsQImage();
- void releaseImageCache();
QRect videoRect() const;
quint64 duration() const;
quint64 currentTime() const;
long timeScale() const;
- float staticFps();
QString currentTimeString();
void setColors(qreal brightness = 0, qreal contrast = 1, qreal hue = 0, qreal saturation = 1);
@@ -87,7 +83,6 @@ namespace QT7
bool setAudioDevice(int id);
void setPlaybackRate(float rate);
QTMovie *qtMovie() const;
- QMultiMap<QString, QString> metaData();
float playbackRate() const;
float prefferedPlaybackRate() const;
@@ -107,12 +102,6 @@ namespace QT7
float percentageLoaded();
quint64 timeLoaded();
- int trackCount() const;
- int currentTrack() const;
- void setCurrentTrack(int track);
- QString movieCompactDiscPath() const;
- QString currentTrackPath() const;
-
static QString timeToString(quint64 ms);
// Help functions when drawing to more that one widget in cocoa 64:
@@ -126,10 +115,6 @@ namespace QT7
QTMovie *m_QTMovie;
State m_state;
QGLPixelBuffer *m_QImagePixelBuffer;
- QuickTimeMetaData *m_metaData;
-
- CVOpenGLTextureRef m_cachedCVTextureRef;
- QImage m_cachedQImage;
bool m_playbackRateSat;
bool m_isDrmProtected;
@@ -140,18 +125,13 @@ namespace QT7
float m_masterVolume;
float m_relativeVolume;
float m_playbackRate;
- float m_staticFps;
quint64 m_currentTime;
MediaSource m_mediaSource;
-
void *m_primaryRenderingCIImage;
qreal m_brightness;
qreal m_contrast;
qreal m_hue;
qreal m_saturation;
- NSArray *m_folderTracks;
- int m_currentTrack;
- QString m_movieCompactDiscPath;
#ifdef QUICKTIME_C_API_AVAILABLE
QTVisualContextRef m_visualContext;
@@ -159,26 +139,20 @@ namespace QT7
VideoFrame m_currentFrame;
QuickTimeStreamReader *m_streamReader;
- void prepareCurrentMovieForPlayback();
void createVisualContext();
void openMovieFromCurrentMediaSource();
void openMovieFromDataRef(QTDataReference *dataRef);
void openMovieFromFile();
void openMovieFromUrl();
void openMovieFromStream();
- void openMovieFromCompactDisc();
void openMovieFromData(QByteArray *data, char *fileType);
void openMovieFromDataGuessType(QByteArray *data);
QString mediaSourcePath();
bool codecExistsAccordingToSuffix(const QString &fileName);
- NSString* pathToCompactDisc();
- bool isCompactDisc(NSString *path);
- NSArray* scanFolder(NSString *path);
void setError(NSError *error);
bool errorOccured();
void readProtection();
- void calculateStaticFps();
void checkIfVideoAwailable();
bool movieNotLoaded();
void waitStatePlayable();
diff --git a/src/3rdparty/phonon/qt7/quicktimevideoplayer.mm b/src/3rdparty/phonon/qt7/quicktimevideoplayer.mm
index 23c76e3..3f76132 100644
--- a/src/3rdparty/phonon/qt7/quicktimevideoplayer.mm
+++ b/src/3rdparty/phonon/qt7/quicktimevideoplayer.mm
@@ -20,7 +20,6 @@
#include "videowidget.h"
#include "audiodevice.h"
#include "quicktimestreamreader.h"
-#include "quicktimemetadata.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QEventLoop>
@@ -53,7 +52,6 @@ QuickTimeVideoPlayer::QuickTimeVideoPlayer() : QObject(0)
{
m_state = NoMedia;
m_mediaSource = MediaSource();
- m_metaData = new QuickTimeMetaData(this);
m_QTMovie = 0;
m_streamReader = 0;
m_playbackRate = 1.0f;
@@ -63,16 +61,12 @@ QuickTimeVideoPlayer::QuickTimeVideoPlayer() : QObject(0)
m_mute = false;
m_audioEnabled = false;
m_hasVideo = false;
- m_staticFps = 0;
m_playbackRateSat = false;
m_isDrmProtected = false;
m_isDrmAuthorized = true;
m_primaryRenderingTarget = 0;
m_primaryRenderingCIImage = 0;
m_QImagePixelBuffer = 0;
- m_cachedCVTextureRef = 0;
- m_folderTracks = 0;
- m_currentTrack = 0;
#ifdef QUICKTIME_C_API_AVAILABLE
OSStatus err = EnterMovies();
@@ -83,9 +77,7 @@ QuickTimeVideoPlayer::QuickTimeVideoPlayer() : QObject(0)
QuickTimeVideoPlayer::~QuickTimeVideoPlayer()
{
- PhononAutoReleasePool pool;
- unsetCurrentMediaSource();
- delete m_metaData;
+ unsetVideo();
[(NSObject*)m_primaryRenderingTarget release];
m_primaryRenderingTarget = 0;
#ifdef QUICKTIME_C_API_AVAILABLE
@@ -94,15 +86,6 @@ QuickTimeVideoPlayer::~QuickTimeVideoPlayer()
#endif
}
-void QuickTimeVideoPlayer::releaseImageCache()
-{
- if (m_cachedCVTextureRef){
- CVOpenGLTextureRelease(m_cachedCVTextureRef);
- m_cachedCVTextureRef = 0;
- }
- m_cachedQImage = QImage();
-}
-
void QuickTimeVideoPlayer::createVisualContext()
{
#ifdef QUICKTIME_C_API_AVAILABLE
@@ -142,10 +125,7 @@ bool QuickTimeVideoPlayer::videoFrameChanged()
return false;
QTVisualContextTask(m_visualContext);
- bool changed = QTVisualContextIsNewImageAvailable(m_visualContext, 0);
- if (changed)
- releaseImageCache();
- return changed;
+ return QTVisualContextIsNewImageAvailable(m_visualContext, 0);
#elif defined(QT_MAC_USE_COCOA)
return true;
@@ -160,11 +140,10 @@ CVOpenGLTextureRef QuickTimeVideoPlayer::currentFrameAsCVTexture()
#ifdef QUICKTIME_C_API_AVAILABLE
if (!m_visualContext)
return 0;
- if (!m_cachedCVTextureRef){
- OSStatus err = QTVisualContextCopyImageForTime(m_visualContext, 0, 0, &m_cachedCVTextureRef);
- BACKEND_ASSERT3(err == noErr, "Could not copy image for time in QuickTime player", FATAL_ERROR, 0)
- }
- return m_cachedCVTextureRef;
+ CVOpenGLTextureRef texture = 0;
+ OSStatus err = QTVisualContextCopyImageForTime(m_visualContext, 0, 0, &texture);
+ BACKEND_ASSERT3(err == noErr, "Could not copy image for time in QuickTime player", FATAL_ERROR, 0)
+ return texture;
#else
return 0;
@@ -173,9 +152,6 @@ CVOpenGLTextureRef QuickTimeVideoPlayer::currentFrameAsCVTexture()
QImage QuickTimeVideoPlayer::currentFrameAsQImage()
{
- if (!m_cachedQImage.isNull())
- return m_cachedQImage;
-
#ifdef QUICKTIME_C_API_AVAILABLE
QGLContext *prevContext = const_cast<QGLContext *>(QGLContext::currentContext());
CVOpenGLTextureRef texture = currentFrameAsCVTexture();
@@ -205,11 +181,12 @@ QImage QuickTimeVideoPlayer::currentFrameAsQImage()
glVertex2i(-1, -1);
glEnd();
- m_cachedQImage = m_QImagePixelBuffer->toImage();
+ QImage image = m_QImagePixelBuffer->toImage();
+ CVOpenGLTextureRelease(texture);
// Because of QuickTime, m_QImagePixelBuffer->doneCurrent() will fail.
// So we store, and restore, the context our selves:
prevContext->makeCurrent();
- return m_cachedQImage;
+ return image;
#else
CIImage *img = (CIImage *)currentFrameAsCIImage();
if (!img)
@@ -218,10 +195,10 @@ QImage QuickTimeVideoPlayer::currentFrameAsQImage()
NSBitmapImageRep* bitmap = [[NSBitmapImageRep alloc] initWithCIImage:img];
CGRect bounds = [img extent];
QImage qImg([bitmap bitmapData], bounds.size.width, bounds.size.height, QImage::Format_ARGB32);
- m_cachedQImage = qImg.rgbSwapped();
+ QImage swapped = qImg.rgbSwapped();
[bitmap release];
[img release];
- return m_cachedQImage;
+ return swapped;
#endif
}
@@ -273,7 +250,8 @@ void *QuickTimeVideoPlayer::currentFrameAsCIImage()
#ifdef QUICKTIME_C_API_AVAILABLE
CVOpenGLTextureRef cvImg = currentFrameAsCVTexture();
CIImage *img = [[CIImage alloc] initWithCVImageBuffer:cvImg];
- return img;
+ CVOpenGLTextureRelease(cvImg);
+ return img;
#else
return 0;
#endif
@@ -295,7 +273,7 @@ GLuint QuickTimeVideoPlayer::currentFrameAsGLTexture()
int samplesPerPixel = [bitmap samplesPerPixel];
if (![bitmap isPlanar] && (samplesPerPixel == 3 || samplesPerPixel == 4)){
- glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0,
+ glTexImage2D(GL_TEXTURE_RECTANGLE_EXT, 0,
samplesPerPixel == 4 ? GL_RGBA8 : GL_RGB8,
[bitmap pixelsWide], [bitmap pixelsHigh],
0, samplesPerPixel == 4 ? GL_RGBA : GL_RGB,
@@ -324,7 +302,7 @@ void QuickTimeVideoPlayer::setVolume(float masterVolume, float relativeVolume)
m_masterVolume = masterVolume;
m_relativeVolume = relativeVolume;
if (!m_QTMovie || !m_audioEnabled || m_mute)
- return;
+ return;
[m_QTMovie setVolume:(m_masterVolume * m_relativeVolume)];
}
@@ -335,7 +313,7 @@ void QuickTimeVideoPlayer::setMute(bool mute)
return;
// Work-around bug that happends if you set/unset mute
- // before movie is playing, and audio is not played
+ // before movie is playing, and audio is not played
// through graph. Then audio is delayed.
[m_QTMovie setMuted:mute];
[m_QTMovie setVolume:(mute ? 0 : m_masterVolume * m_relativeVolume)];
@@ -348,7 +326,7 @@ void QuickTimeVideoPlayer::enableAudio(bool enable)
return;
// Work-around bug that happends if you set/unset mute
- // before movie is playing, and audio is not played
+ // before movie is playing, and audio is not played
// through graph. Then audio is delayed.
[m_QTMovie setMuted:(!enable || m_mute)];
[m_QTMovie setVolume:((!enable || m_mute) ? 0 : m_masterVolume * m_relativeVolume)];
@@ -367,7 +345,7 @@ bool QuickTimeVideoPlayer::setAudioDevice(int id)
#ifdef QUICKTIME_C_API_AVAILABLE
// The following code will not work for some media codecs that
// typically mingle audio/video frames (e.g mpeg).
- CFStringRef idString = PhononCFString::toCFStringRef(AudioDevice::deviceUID(id));
+ CFStringRef idString = PhononCFString::toCFStringRef(AudioDevice::deviceUID(id));
QTAudioContextRef context;
QTAudioContextCreateForAudioDevice(kCFAllocatorDefault, idString, 0, &context);
OSStatus err = SetMovieAudioContext([m_QTMovie quickTimeMovie], context);
@@ -391,16 +369,11 @@ void QuickTimeVideoPlayer::setColors(qreal brightness, qreal contrast, qreal hue
contrast += 1;
saturation += 1;
- if (m_brightness == brightness
- && m_contrast == contrast
- && m_hue == hue
- && m_saturation == saturation)
- return;
-
m_brightness = brightness;
m_contrast = contrast;
m_hue = hue;
m_saturation = saturation;
+
#ifdef QUICKTIME_C_API_AVAILABLE
Float32 value;
value = brightness;
@@ -412,7 +385,6 @@ void QuickTimeVideoPlayer::setColors(qreal brightness, qreal contrast, qreal hue
value = saturation;
SetMovieVisualSaturation([m_QTMovie quickTimeMovie], value, 0);
#endif
- releaseImageCache();
}
QRect QuickTimeVideoPlayer::videoRect() const
@@ -425,7 +397,7 @@ QRect QuickTimeVideoPlayer::videoRect() const
return QRect(0, 0, size.width, size.height);
}
-void QuickTimeVideoPlayer::unsetCurrentMediaSource()
+void QuickTimeVideoPlayer::unsetVideo()
{
if (!m_QTMovie)
return;
@@ -438,17 +410,11 @@ void QuickTimeVideoPlayer::unsetCurrentMediaSource()
m_state = NoMedia;
m_isDrmProtected = false;
m_isDrmAuthorized = true;
- m_hasVideo = false;
- m_staticFps = 0;
m_mediaSource = MediaSource();
- m_movieCompactDiscPath.clear();
[(CIImage *)m_primaryRenderingCIImage release];
m_primaryRenderingCIImage = 0;
delete m_QImagePixelBuffer;
m_QImagePixelBuffer = 0;
- releaseImageCache();
- [m_folderTracks release];
- m_folderTracks = 0;
}
QuickTimeVideoPlayer::State QuickTimeVideoPlayer::state() const
@@ -558,25 +524,18 @@ bool QuickTimeVideoPlayer::codecExistsAccordingToSuffix(const QString &fileName)
void QuickTimeVideoPlayer::setMediaSource(const MediaSource &mediaSource)
{
PhononAutoReleasePool pool;
- unsetCurrentMediaSource();
-
+ unsetVideo();
m_mediaSource = mediaSource;
if (mediaSource.type() == MediaSource::Empty || mediaSource.type() == MediaSource::Invalid){
m_state = NoMedia;
return;
}
-
openMovieFromCurrentMediaSource();
if (errorOccured()){
- unsetCurrentMediaSource();
+ unsetVideo();
return;
}
- prepareCurrentMovieForPlayback();
-}
-
-void QuickTimeVideoPlayer::prepareCurrentMovieForPlayback()
-{
#ifdef QUICKTIME_C_API_AVAILABLE
if (m_visualContext)
SetMovieVisualContext([m_QTMovie quickTimeMovie], m_visualContext);
@@ -584,25 +543,23 @@ void QuickTimeVideoPlayer::prepareCurrentMovieForPlayback()
waitStatePlayable();
if (errorOccured()){
- unsetCurrentMediaSource();
+ unsetVideo();
return;
}
readProtection();
preRollMovie();
if (errorOccured()){
- unsetCurrentMediaSource();
+ unsetVideo();
return;
}
if (!m_playbackRateSat)
m_playbackRate = prefferedPlaybackRate();
checkIfVideoAwailable();
- calculateStaticFps();
enableAudio(m_audioEnabled);
setMute(m_mute);
setVolume(m_masterVolume, m_relativeVolume);
- m_metaData->update();
pause();
}
@@ -616,7 +573,7 @@ void QuickTimeVideoPlayer::openMovieFromCurrentMediaSource()
openMovieFromUrl();
break;
case MediaSource::Disc:
- openMovieFromCompactDisc();
+ CASE_UNSUPPORTED("Could not open media source.", FATAL_ERROR)
break;
case MediaSource::Stream:
openMovieFromStream();
@@ -678,7 +635,7 @@ void QuickTimeVideoPlayer::openMovieFromDataGuessType(QByteArray *data)
// than using e.g [QTMovie movieFileTypes:QTIncludeCommonTypes]. Some
// codecs *think* they can decode the stream, and crash...
#define TryOpenMovieWithCodec(type) gClearError(); \
- openMovieFromData(data, (char *)"."type); \
+ openMovieFromData(data, "."type); \
if (m_QTMovie) return;
TryOpenMovieWithCodec("avi");
@@ -718,50 +675,6 @@ void QuickTimeVideoPlayer::openMovieFromStream()
openMovieFromDataGuessType(m_streamReader->pointerToData());
}
-typedef void (*qt_sighandler_t)(int);
-static void sigtest(int) {
- qApp->exit(0);
-}
-
-void QuickTimeVideoPlayer::openMovieFromCompactDisc()
-{
- // Interrupting the application while the device is open
- // causes the application to hang. So we need to handle
- // this in a more graceful way:
- qt_sighandler_t hndl = signal(SIGINT, sigtest);
- if (hndl)
- signal(SIGINT, hndl);
-
- PhononAutoReleasePool pool;
- NSString *cd = 0;
- QString devName = m_mediaSource.deviceName();
- if (devName.isEmpty()) {
- cd = pathToCompactDisc();
- if (!cd) {
- SET_ERROR("Could not open media source.", NORMAL_ERROR)
- return;
- }
- m_movieCompactDiscPath = PhononCFString::toQString(reinterpret_cast<CFStringRef>(cd));
- } else {
- if (!QFileInfo(devName).isAbsolute())
- devName = QLatin1String("/Volumes/") + devName;
- cd = [reinterpret_cast<const NSString *>(PhononCFString::toCFStringRef(devName)) autorelease];
- if (!isCompactDisc(cd)) {
- SET_ERROR("Could not open media source.", NORMAL_ERROR)
- return;
- }
- m_movieCompactDiscPath = devName;
- }
-
- m_folderTracks = [scanFolder(cd) retain];
- setCurrentTrack(0);
-}
-
-QString QuickTimeVideoPlayer::movieCompactDiscPath() const
-{
- return m_movieCompactDiscPath;
-}
-
MediaSource QuickTimeVideoPlayer::mediaSource() const
{
return m_mediaSource;
@@ -807,44 +720,6 @@ long QuickTimeVideoPlayer::timeScale() const
return [[m_QTMovie attributeForKey:@"QTMovieTimeScaleAttribute"] longValue];
}
-float QuickTimeVideoPlayer::staticFps()
-{
- return m_staticFps;
-}
-
-void QuickTimeVideoPlayer::calculateStaticFps()
-{
- if (!m_hasVideo){
- m_staticFps = 0;
- return;
- }
-
-#ifdef QT_ALLOW_QUICKTIME
- Boolean isMpeg = false;
- Track videoTrack = GetMovieIndTrackType([m_QTMovie quickTimeMovie], 1,
- FOUR_CHAR_CODE('vfrr'), // 'vfrr' means: has frame rate
- movieTrackCharacteristic | movieTrackEnabledOnly);
- Media media = GetTrackMedia(videoTrack);
- MediaHandler mediaH = GetMediaHandler(media);
- MediaHasCharacteristic(mediaH, FOUR_CHAR_CODE('mpeg'), &isMpeg);
-
- if (isMpeg){
- MHInfoEncodedFrameRateRecord frameRate;
- Size frameRateSize = sizeof(frameRate);
- MediaGetPublicInfo(mediaH, kMHInfoEncodedFrameRate, &frameRate, &frameRateSize);
- m_staticFps = float(Fix2X(frameRate.encodedFrameRate));
- } else {
- Media media = GetTrackMedia(videoTrack);
- long sampleCount = GetMediaSampleCount(media);
- TimeValue64 duration = GetMediaDisplayDuration(media);
- TimeValue64 timeScale = GetMediaTimeScale(media);
- m_staticFps = float((double)sampleCount * (double)timeScale / (double)duration);
- }
-#else
- m_staticFps = 30.0f;
-#endif
-}
-
QString QuickTimeVideoPlayer::timeToString(quint64 ms)
{
int sec = ms/1000;
@@ -1075,94 +950,6 @@ void QuickTimeVideoPlayer::readProtection()
}
}
-QMultiMap<QString, QString> QuickTimeVideoPlayer::metaData()
-{
- return m_metaData->metaData();
-}
-
-int QuickTimeVideoPlayer::trackCount() const
-{
- if (!m_folderTracks)
- return 0;
- return [m_folderTracks count];
-}
-
-int QuickTimeVideoPlayer::currentTrack() const
-{
- return m_currentTrack;
-}
-
-QString QuickTimeVideoPlayer::currentTrackPath() const
-{
- if (!m_folderTracks)
- return QString();
-
- PhononAutoReleasePool pool;
- NSString *trackPath = [m_folderTracks objectAtIndex:m_currentTrack];
- return PhononCFString::toQString(reinterpret_cast<CFStringRef>(trackPath));
-}
-
-NSString* QuickTimeVideoPlayer::pathToCompactDisc()
-{
- PhononAutoReleasePool pool;
- NSArray *devices = [[NSWorkspace sharedWorkspace] mountedRemovableMedia];
- for (unsigned int i=0; i<[devices count]; ++i) {
- NSString *dev = [devices objectAtIndex:i];
- if (isCompactDisc(dev))
- return [dev retain];
- }
- return 0;
-}
-
-bool QuickTimeVideoPlayer::isCompactDisc(NSString *path)
-{
- PhononAutoReleasePool pool;
- NSString *type = [NSString string];
- [[NSWorkspace sharedWorkspace] getFileSystemInfoForPath:path
- isRemovable:0
- isWritable:0
- isUnmountable:0
- description:0
- type:&type];
- return [type hasPrefix:@"cdd"];
-}
-
-NSArray* QuickTimeVideoPlayer::scanFolder(NSString *path)
-{
- NSMutableArray *tracks = [NSMutableArray arrayWithCapacity:20];
- if (!path)
- return tracks;
-
- NSDirectoryEnumerator *enumerator = [[NSFileManager defaultManager] enumeratorAtPath:path];
- while (NSString *track = [enumerator nextObject]) {
- if (![track hasPrefix:@"."])
- [tracks addObject:[path stringByAppendingPathComponent:track]];
- }
- return tracks;
-}
-
-void QuickTimeVideoPlayer::setCurrentTrack(int track)
-{
- PhononAutoReleasePool pool;
- [m_QTMovie release];
- m_QTMovie = 0;
- m_currentTime = 0;
- m_currentTrack = track;
-
- if (!m_folderTracks)
- return;
- if (track < 0 || track >= (int)[m_folderTracks count])
- return;
-
- NSString *trackPath = [m_folderTracks objectAtIndex:track];
- QTDataReference *dataRef = [QTDataReference dataReferenceWithReferenceToFile:trackPath];
- State currentState = m_state;
- openMovieFromDataRef(dataRef);
- prepareCurrentMovieForPlayback();
- if (currentState == Playing)
- play();
-}
-
}}
QT_END_NAMESPACE
diff --git a/src/3rdparty/phonon/qt7/videoframe.mm b/src/3rdparty/phonon/qt7/videoframe.mm
index 7b67b5e..92a3cd5 100644
--- a/src/3rdparty/phonon/qt7/videoframe.mm
+++ b/src/3rdparty/phonon/qt7/videoframe.mm
@@ -20,8 +20,6 @@
#import <QuartzCore/CIFilter.h>
#import <QuartzCore/CIContext.h>
-//#define CACHE_CV_TEXTURE
-
QT_BEGIN_NAMESPACE
namespace Phonon
@@ -72,9 +70,7 @@ namespace QT7
void VideoFrame::copyMembers(const VideoFrame& frame)
{
-#ifdef CACHE_CV_TEXTURE
m_cachedCVTextureRef = frame.m_cachedCVTextureRef;
-#endif
m_cachedCIImage = frame.m_cachedCIImage;
m_cachedQImage = frame.m_cachedQImage;
m_cachedNSBitmap = frame.m_cachedNSBitmap;
@@ -109,20 +105,11 @@ namespace QT7
CVOpenGLTextureRef VideoFrame::cachedCVTexture() const
{
-#ifdef CACHE_CV_TEXTURE
if (!m_cachedCVTextureRef && m_videoPlayer){
m_videoPlayer->setColors(m_brightness, m_contrast, m_hue, m_saturation);
(const_cast<VideoFrame *>(this))->m_cachedCVTextureRef = m_videoPlayer->currentFrameAsCVTexture();
- CVOpenGLTextureRetain((const_cast<VideoFrame *>(this))->m_cachedCVTextureRef);
}
return m_cachedCVTextureRef;
-#else
- if (m_videoPlayer){
- m_videoPlayer->setColors(m_brightness, m_contrast, m_hue, m_saturation);
- return m_videoPlayer->currentFrameAsCVTexture();
- }
- return 0;
-#endif
}
void *VideoFrame::cachedCIImage() const
@@ -342,12 +329,10 @@ namespace QT7
void VideoFrame::invalidateImage() const
{
-#ifdef CACHE_CV_TEXTURE
if (m_cachedCVTextureRef){
CVOpenGLTextureRelease(m_cachedCVTextureRef);
(const_cast<VideoFrame *>(this))->m_cachedCVTextureRef = 0;
}
-#endif
if (m_cachedCIImage){
[(CIImage *) m_cachedCIImage release];
(const_cast<VideoFrame *>(this))->m_cachedCIImage = 0;
@@ -361,10 +346,8 @@ namespace QT7
void VideoFrame::retain() const
{
-#ifdef CACHE_CV_TEXTURE
if (m_cachedCVTextureRef)
CVOpenGLTextureRetain(m_cachedCVTextureRef);
-#endif
if (m_cachedCIImage)
[(CIImage *) m_cachedCIImage retain];
if (m_backgroundFrame)
@@ -375,12 +358,8 @@ namespace QT7
void VideoFrame::release() const
{
-#ifdef CACHE_CV_TEXTURE
- if (m_cachedCVTextureRef){
+ if (m_cachedCVTextureRef)
CVOpenGLTextureRelease(m_cachedCVTextureRef);
- (const_cast<VideoFrame *>(this))->m_cachedCVTextureRef = 0;
- }
-#endif
if (m_cachedCIImage)
[(CIImage *) m_cachedCIImage release];
if (m_backgroundFrame)
@@ -389,6 +368,7 @@ namespace QT7
[m_cachedNSBitmap release];
(const_cast<VideoFrame *>(this))->m_backgroundFrame = 0;
+ (const_cast<VideoFrame *>(this))->m_cachedCVTextureRef = 0;
(const_cast<VideoFrame *>(this))->m_cachedCIImage = 0;
(const_cast<VideoFrame *>(this))->m_cachedNSBitmap = 0;
}