Changeset 561 for trunk/src/3rdparty/phonon/ds9
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/3rdparty/phonon/ds9/CMakeLists.txt
r2 r561 41 41 42 42 add_definitions(-DPHONON_MAKE_QT_ONLY_BACKEND -DUNICODE) 43 automoc4_add_library(phonon_ds9 SHARED${phonon_ds9_SRCS})43 automoc4_add_library(phonon_ds9 MODULE ${phonon_ds9_SRCS}) 44 44 set_target_properties(phonon_ds9 PROPERTIES PREFIX "") 45 45 target_link_libraries(phonon_ds9 46 46 ${PHONON_LIBS} ${QT_QTOPENGL_LIBRARY} ${OPENGL_gl_LIBRARY} 47 47 dxguid strmiids dmoguids msdmo ole32 oleaut32 uuid gdi32) 48 # 'MODULE' is treated as a LIBRARY 48 49 install(TARGETS phonon_ds9 49 50 RUNTIME DESTINATION ${BIN_INSTALL_DIR}/phonon_backend 50 LIBRARY DESTINATION ${ LIB_INSTALL_DIR}51 LIBRARY DESTINATION ${BIN_INSTALL_DIR}/phonon_backend 51 52 ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) 52 53 install(FILES ds9.desktop DESTINATION ${SERVICES_INSTALL_DIR}/phononbackends) -
trunk/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp
r2 r561 100 100 101 101 if (ratio > 0) { 102 if ( realWidth / realHeight > ratio && scaleMode == Phonon::VideoWidget::FitInView103 || realWidth / realHeight < ratio && scaleMode == Phonon::VideoWidget::ScaleAndCrop) {102 if ((realWidth / realHeight > ratio && scaleMode == Phonon::VideoWidget::FitInView) 103 || (realWidth / realHeight < ratio && scaleMode == Phonon::VideoWidget::ScaleAndCrop)) { 104 104 //the height is correct, let's change the width 105 105 m_dstWidth = qRound(realHeight * ratio); -
trunk/src/3rdparty/phonon/ds9/backend.cpp
r2 r561 42 42 namespace DS9 43 43 { 44 QMutex *Backend::directShowMutex = 0; 45 44 46 bool Backend::AudioMoniker::operator==(const AudioMoniker &other) 45 47 { … … 51 53 : QObject(parent) 52 54 { 53 ::CoInitialize(0); 55 directShowMutex = &m_directShowMutex; 56 57 ::CoInitialize(0); 54 58 55 59 //registering meta types … … 62 66 m_audioOutputs.clear(); 63 67 m_audioEffects.clear(); 64 ::CoUninitialize(); 68 ::CoUninitialize(); 69 70 directShowMutex = 0; 65 71 } 66 72 … … 132 138 QList<int> Backend::objectDescriptionIndexes(Phonon::ObjectDescriptionType type) const 133 139 { 140 QMutexLocker locker(&m_directShowMutex); 134 141 QList<int> ret; 135 142 … … 158 165 LPOLESTR str = 0; 159 166 mon->GetDisplayName(0,0,&str); 160 const QString name = QString::from Utf16((unsigned short*)str);167 const QString name = QString::fromWCharArray(str); 161 168 ComPointer<IMalloc> alloc; 162 169 ::CoGetMalloc(1, alloc.pparam()); … … 205 212 QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(Phonon::ObjectDescriptionType type, int index) const 206 213 { 214 QMutexLocker locker(&m_directShowMutex); 207 215 QHash<QByteArray, QVariant> ret; 208 216 switch (type) … … 217 225 HRESULT hr = mon->GetDisplayName(0,0, &str); 218 226 if (SUCCEEDED(hr)) { 219 QString name = QString::from Utf16((unsigned short*)str);227 QString name = QString::fromWCharArray(str); 220 228 ComPointer<IMalloc> alloc; 221 229 ::CoGetMalloc(1, alloc.pparam()); … … 232 240 HRESULT hr = ::DMOGetName(m_audioEffects[index], name); 233 241 if (SUCCEEDED(hr)) { 234 ret["name"] = QString::from Utf16((unsigned short*)name);242 ret["name"] = QString::fromWCharArray(name); 235 243 } 236 244 } -
trunk/src/3rdparty/phonon/ds9/backend.h
r2 r561 24 24 25 25 #include <QtCore/QList> 26 #include <QtCore/QMutex> 26 27 27 28 #include "compointer.h" … … 64 65 Filter getAudioOutputFilter(int index) const; 65 66 67 static QMutex *directShowMutex; 68 66 69 Q_SIGNALS: 67 70 void objectDescriptionChanged(ObjectDescriptionType); … … 75 78 mutable QVector<AudioMoniker> m_audioOutputs; 76 79 mutable QVector<CLSID> m_audioEffects; 80 mutable QMutex m_directShowMutex; 77 81 }; 78 82 } -
trunk/src/3rdparty/phonon/ds9/backendnode.cpp
r2 r561 58 58 BackendNode::~BackendNode() 59 59 { 60 //this will remove the filter from the graph 61 FILTER_INFO info; 62 for(int i = 0; i < FILTER_COUNT; ++i) { 63 const Filter &filter = m_filters[i]; 64 if (!filter) 65 continue; 66 filter->QueryFilterInfo(&info); 67 if (info.pGraph) { 68 HRESULT hr = info.pGraph->RemoveFilter(filter); 69 70 if (hr == VFW_E_NOT_STOPPED && m_mediaObject) { 71 m_mediaObject->ensureStopped(); 72 73 hr = info.pGraph->RemoveFilter(filter); 74 } 75 Q_ASSERT(SUCCEEDED(hr)); 76 info.pGraph->Release(); 77 } 78 } 60 79 } 61 80 -
trunk/src/3rdparty/phonon/ds9/ds9.desktop
r2 r561 6 6 X-KDE-PhononBackendInfo-InterfaceVersion=1 7 7 X-KDE-PhononBackendInfo-Version=0.1 8 X-KDE-PhononBackendInfo-Website=http:// www.trolltech.com/8 X-KDE-PhononBackendInfo-Website=http://qt.nokia.com/ 9 9 InitialPreference=15 10 10 11 11 Name=DirectShow9 12 Name[bg]=DirectShow9 13 Name[ca]=DirectShow9 14 Name[cs]=DirectShow9 15 Name[da]=DirectShow9 16 Name[de]=DirectShow9 17 Name[el]=DirectShow9 18 Name[en_GB]=DirectShow9 19 Name[es]=DirectShow9 20 Name[et]=DirectShow9 21 Name[eu]=DirectShow9 22 Name[fr]=DirectShow9 23 Name[ga]=DirectShow9 24 Name[gl]=DirectShow9 25 Name[hsb]=DirectShow9 26 Name[hu]=DirectShow9 27 Name[is]=DirectShow9 28 Name[it]=DirectShow9 29 Name[ja]=DirectShow9 30 Name[ko]=DirectShow9 31 Name[ku]=DirectShow9 32 Name[lt]=DirectShow9 33 Name[lv]=DirectShow9 34 Name[nds]=DirectShow9 35 Name[nl]=DirectShow9 36 Name[nn]=DirectShow9 12 37 Name[pa]=àš¡àšŸàšàš°à©àšàšžàšŒà©9 38 Name[pl]=DirectShow9 39 Name[pt]=DirectShow9 40 Name[pt_BR]=DirectShow9 41 Name[se]=DirectShow9 13 42 Name[sk]=DirectShow 9 14 43 Name[sl]=DirectShow 9 … … 16 45 Name[sr@latin]=DirectShowâ9 17 46 Name[sv]=Directshow 9 47 Name[tr]=DirectShow9 48 Name[uk]=DirectShow9 18 49 Name[x-test]=xxDirectShow9xx 50 Name[zh_CN]=DirectShow9 51 Name[zh_TW]=DirectShow9 19 52 20 53 Comment=Phonon DirectShow9 backend 21 54 Comment[bg]=Phonon DirectShow9 22 55 Comment[ca]=Dorsal DirectShow9 del Phonon 56 Comment[cs]=Phonon DirectShow9 backend 23 57 Comment[da]=DirectShow9-backend til Phonon 24 58 Comment[de]=Phonon-Treiber fÃŒr DirectShow9 … … 26 60 ÏοÏÏήÏÎ¹ÎŸÎ·Ï DirectShow9 ÏÎ¿Ï 27 61 Phonon 62 Comment[en_GB]=Phonon DirectShow9 backend 28 63 Comment[es]=Motor DirectShow9 para Phonon 29 64 Comment[et]=Phononi DirectShow9 taustaprogramm 65 Comment[eu]=Phonon DirectShow9 backend 30 66 Comment[fr]=SystÚme de gestion DirectShow9 pour Phonon 31 67 Comment[ga]=Inneall DirectShow9 le haghaidh Phonon 32 68 Comment[gl]=Infraestrutura de DirectShow9 para Phonon 69 Comment[hsb]=Phonon DirectShow9 backend 70 Comment[hu]=Phonon DirectShow9 modul 71 Comment[is]=Phonon DirectShow9 bakendi 33 72 Comment[it]=Motore DirectShow9 di Phonon 34 73 Comment[ja]=Phonon DirectShow9 ããã¯ãšã³ã 35 74 Comment[ko]=Phonon DirectShow9 ë°±ìë 75 Comment[ku]=Binesaza Phonon DirectShow9 76 Comment[lt]=Phonon DirectShow9 galinÄ sÄ 77 saja 36 78 Comment[lv]=Phonon DirectShow9 aizmugure 37 79 Comment[nds]=Phonon-HÃŒlpprogrmm DirectShow9 … … 42 84 Comment[pt]=Infra-estrutura do DirectShow9 para o Phonon 43 85 Comment[pt_BR]=Infraestrutura Phonon DirectShow9 86 Comment[se]=Phonon DirectShow9 duogášmohtor 44 87 Comment[sk]=Phonon DirectShow 9 podsystém 45 88 Comment[sl]=Phononova Hrbtenica DirectShow 9 -
trunk/src/3rdparty/phonon/ds9/effect.cpp
r2 r561 83 83 current += wcslen(current) + 1; //skip the unit 84 84 for(; *current; current += wcslen(current) + 1) { 85 values.append( QString::from Utf16((unsigned short*)current) );85 values.append( QString::fromWCharArray(current) ); 86 86 } 87 87 } … … 108 108 Phonon::EffectParameter::LogarithmicHint : Phonon::EffectParameter::Hints(0); 109 109 110 const QString n = QString::from Utf16((unsigned short*)name);110 const QString n = QString::fromWCharArray(name); 111 111 ret.append(Phonon::EffectParameter(i, n, hint, def, min, max, values)); 112 112 ::CoTaskMemFree(name); //let's free the memory … … 139 139 Q_ASSERT(params); 140 140 141 MP_DATA data = float(v.toDouble()); 142 params->SetParam(p.id(), data); 141 params->SetParam(p.id(), v.toFloat()); 143 142 } 144 143 } -
trunk/src/3rdparty/phonon/ds9/fakesource.cpp
r2 r561 30 30 { 31 31 static WAVEFORMATEX g_defaultWaveFormat = {WAVE_FORMAT_PCM, 2, 44100, 176400, 4, 16, 0}; 32 static BITMAPINFOHEADER g_defautBitmapHeader = { sizeof(BITMAPINFOHEADER), 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}; 33 static VIDEOINFOHEADER2 g_defaultVideoInfo = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 32 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} }; 33 34 static const AM_MEDIA_TYPE g_fakeAudioType = {MEDIATYPE_Audio, MEDIASUBTYPE_PCM, 0, 0, 2, FORMAT_WaveFormatEx, 0, sizeof(WAVEFORMATEX), reinterpret_cast<BYTE*>(&g_defaultWaveFormat)}; 35 static const AM_MEDIA_TYPE g_fakeVideoType = {MEDIATYPE_Video, MEDIASUBTYPE_RGB32, TRUE, FALSE, 0, FORMAT_VideoInfo2, 0, sizeof(VIDEOINFOHEADER2), reinterpret_cast<BYTE*>(&g_defaultVideoInfo)}; 34 36 35 37 class FakePin : public QPin … … 129 131 void FakeSource::createFakeAudioPin() 130 132 { 131 AM_MEDIA_TYPE mt; 132 qMemSet(&mt, 0, sizeof(AM_MEDIA_TYPE)); 133 mt.majortype = MEDIATYPE_Audio; 134 mt.subtype = MEDIASUBTYPE_PCM; 135 mt.formattype = FORMAT_WaveFormatEx; 136 mt.lSampleSize = 2; 137 138 //fake the format (stereo 44.1 khz stereo 16 bits) 139 mt.cbFormat = sizeof(WAVEFORMATEX); 140 mt.pbFormat = reinterpret_cast<BYTE*>(&g_defaultWaveFormat); 141 142 new FakePin(this, mt); 133 new FakePin(this, g_fakeAudioType); 143 134 } 144 135 145 136 void FakeSource::createFakeVideoPin() 146 137 { 147 AM_MEDIA_TYPE mt; 148 qMemSet(&mt, 0, sizeof(AM_MEDIA_TYPE)); 149 mt.majortype = MEDIATYPE_Video; 150 mt.subtype = MEDIASUBTYPE_RGB32; 151 mt.formattype = FORMAT_VideoInfo2; 152 mt.bFixedSizeSamples = 1; 153 154 g_defaultVideoInfo.bmiHeader = g_defautBitmapHeader; 155 156 //fake the format 157 mt.cbFormat = sizeof(VIDEOINFOHEADER2); 158 mt.pbFormat = reinterpret_cast<BYTE*>(&g_defaultVideoInfo); 159 160 new FakePin(this, mt); 138 new FakePin(this, g_fakeVideoType); 161 139 } 162 140 -
trunk/src/3rdparty/phonon/ds9/iodevicereader.cpp
r2 r561 37 37 static QVector<AM_MEDIA_TYPE> getMediaTypes() 38 38 { 39 AM_MEDIA_TYPE mt; 40 mt.majortype = MEDIATYPE_Stream; 41 mt.bFixedSizeSamples = TRUE; 42 mt.bTemporalCompression = FALSE; 43 mt.lSampleSize = 1; 44 mt.formattype = GUID_NULL; 45 mt.pUnk = 0; 46 mt.cbFormat = 0; 47 mt.pbFormat = 0; 39 //the order here is important because otherwise, 40 //directshow might not be able to detect the stream type correctly 41 42 AM_MEDIA_TYPE mt = { MEDIATYPE_Stream, MEDIASUBTYPE_Avi, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0}; 48 43 49 44 QVector<AM_MEDIA_TYPE> ret; 50 //normal auto-detect stream51 mt.subtype = MEDIASUBTYPE_NULL;52 ret << mt;53 45 //AVI stream 54 mt.subtype = MEDIASUBTYPE_Avi;55 46 ret << mt; 56 47 //WAVE stream 57 48 mt.subtype = MEDIASUBTYPE_WAVE; 49 ret << mt; 50 //normal auto-detect stream (must be at the end!) 51 mt.subtype = MEDIASUBTYPE_NULL; 58 52 ret << mt; 59 53 return ret; … … 73 67 void writeData(const QByteArray &data) 74 68 { 75 QWriteLocker locker(&m_lock);76 69 m_pos += data.size(); 77 70 m_buffer += data; … … 84 77 void setStreamSize(qint64 newSize) 85 78 { 86 Q WriteLocker locker(&m_lock);79 QMutexLocker locker(&m_mutex); 87 80 m_size = newSize; 88 }89 90 qint64 streamSize() const91 {92 QReadLocker locker(&m_lock);93 return m_size;94 81 } 95 82 96 83 void setStreamSeekable(bool s) 97 84 { 98 Q WriteLocker locker(&m_lock);85 QMutexLocker locker(&m_mutex); 99 86 m_seekable = s; 100 }101 102 bool streamSeekable() const103 {104 QReadLocker locker(&m_lock);105 return m_seekable;106 }107 108 void setCurrentPos(qint64 pos)109 {110 QWriteLocker locker(&m_lock);111 m_pos = pos;112 seekStream(pos);113 m_buffer.clear();114 }115 116 qint64 currentPos() const117 {118 QReadLocker locker(&m_lock);119 return m_pos;120 }121 122 int currentBufferSize() const123 {124 QReadLocker locker(&m_lock);125 return m_buffer.size();126 87 } 127 88 … … 131 92 STDMETHODIMP Length(LONGLONG *total, LONGLONG *available) 132 93 { 133 Q ReadLocker locker(&m_lock);94 QMutexLocker locker(&m_mutex); 134 95 if (total) { 135 96 *total = m_size; … … 146 107 HRESULT read(LONGLONG pos, LONG length, BYTE *buffer, LONG *actual) 147 108 { 148 QMutexLocker locker(&m_mutexRead); 149 109 Q_ASSERT(!m_mutex.tryLock()); 150 110 if (m_mediaGraph->isStopping()) { 151 111 return VFW_E_WRONG_STATE; 152 112 } 153 113 154 if( streamSize() != 1 && pos + length > streamSize()) {114 if(m_size != 1 && pos + length > m_size) { 155 115 //it tries to read outside of the boundaries 156 116 return E_FAIL; 157 117 } 158 118 159 if ( currentPos() - currentBufferSize() != pos) {160 if (! streamSeekable()) {119 if (m_pos - m_buffer.size() != pos) { 120 if (!m_seekable) { 161 121 return S_FALSE; 162 122 } 163 setCurrentPos(pos); 123 m_pos = pos; 124 seekStream(pos); 125 m_buffer.clear(); 164 126 } 165 127 166 int oldSize = currentBufferSize();167 while ( currentBufferSize() < int(length)) {128 int oldSize = m_buffer.size(); 129 while (m_buffer.size() < int(length)) { 168 130 needData(); 169 131 if (m_mediaGraph->isStopping()) { … … 171 133 } 172 134 173 if (oldSize == currentBufferSize()) {135 if (oldSize == m_buffer.size()) { 174 136 break; //we didn't get any data 175 137 } 176 oldSize = currentBufferSize();138 oldSize = m_buffer.size(); 177 139 } 178 140 179 DWORD bytesRead = qMin(currentBufferSize(), int(length)); 180 { 181 QWriteLocker locker(&m_lock); 182 qMemCopy(buffer, m_buffer.data(), bytesRead); 183 //truncate the buffer 184 m_buffer = m_buffer.mid(bytesRead); 185 } 141 int bytesRead = qMin(m_buffer.size(), int(length)); 142 qMemCopy(buffer, m_buffer.data(), bytesRead); 143 //truncate the buffer 144 m_buffer = m_buffer.mid(bytesRead); 186 145 187 146 if (actual) { … … 199 158 qint64 m_size; 200 159 201 QMutex m_mutexRead;202 160 const MediaGraph *m_mediaGraph; 203 161 }; … … 213 171 { 214 172 } 215 216 STDMETHODIMP IODeviceReader::Stop()217 {218 HRESULT hr = QBaseFilter::Stop();219 m_streamReader->enoughData(); //this asks to cancel any blocked call to needData220 return hr;221 }222 223 173 } 224 174 } -
trunk/src/3rdparty/phonon/ds9/iodevicereader.h
r2 r561 42 42 IODeviceReader(const MediaSource &source, const MediaGraph *); 43 43 ~IODeviceReader(); 44 STDMETHODIMP Stop();45 44 46 45 private: -
trunk/src/3rdparty/phonon/ds9/mediagraph.cpp
r2 r561 69 69 } 70 70 71 72 /* 71 73 static HRESULT saveToFile(Graph graph, const QString &filepath) 72 74 { … … 104 106 return hr; 105 107 } 106 108 */ 107 109 108 110 MediaGraph::MediaGraph(MediaObject *mo, short index) : … … 382 384 if (info.pGraph) { 383 385 info.pGraph->Release(); 384 return m_graph->RemoveFilter(filter); 386 if (info.pGraph == m_graph) 387 return m_graph->RemoveFilter(filter); 385 388 } 386 389 … … 538 541 for(int i = 0; i < outputs.count(); ++i) { 539 542 const OutputPin &pin = outputs.at(i); 540 if ( VFW_E_NOT_CONNECTED== pin->ConnectedTo(inPin.pparam())) {543 if (HRESULT(VFW_E_NOT_CONNECTED) == pin->ConnectedTo(inPin.pparam())) { 541 544 return SUCCEEDED(pin->Connect(newIn, 0)); 542 545 } … … 680 683 } else if (source.discType() == Phonon::Cd) { 681 684 m_realSource = Filter(new QAudioCDPlayer); 682 m_result = m_graph->AddFilter(m_realSource, 0);683 685 684 686 #endif //QT_NO_PHONON_MEDIACONTROLLER … … 810 812 const OutputPin &out = outputs.at(i); 811 813 InputPin pin; 812 if (out->ConnectedTo(pin.pparam()) == VFW_E_NOT_CONNECTED) {814 if (out->ConnectedTo(pin.pparam()) == HRESULT(VFW_E_NOT_CONNECTED)) { 813 815 m_decoderPins += out; //unconnected outputs can be decoded outputs 814 816 } … … 1007 1009 HRESULT hr = mediaContent->get_AuthorName(&str); 1008 1010 if (SUCCEEDED(hr)) { 1009 ret.insert(QLatin1String("ARTIST"), QString::from Utf16((const unsigned short*)str));1011 ret.insert(QLatin1String("ARTIST"), QString::fromWCharArray(str)); 1010 1012 SysFreeString(str); 1011 1013 } 1012 1014 hr = mediaContent->get_Title(&str); 1013 1015 if (SUCCEEDED(hr)) { 1014 ret.insert(QLatin1String("TITLE"), QString::from Utf16((const unsigned short*)str));1016 ret.insert(QLatin1String("TITLE"), QString::fromWCharArray(str)); 1015 1017 SysFreeString(str); 1016 1018 } 1017 1019 hr = mediaContent->get_Description(&str); 1018 1020 if (SUCCEEDED(hr)) { 1019 ret.insert(QLatin1String("DESCRIPTION"), QString::from Utf16((const unsigned short*)str));1021 ret.insert(QLatin1String("DESCRIPTION"), QString::fromWCharArray(str)); 1020 1022 SysFreeString(str); 1021 1023 } 1022 1024 hr = mediaContent->get_Copyright(&str); 1023 1025 if (SUCCEEDED(hr)) { 1024 ret.insert(QLatin1String("COPYRIGHT"), QString::from Utf16((const unsigned short*)str));1026 ret.insert(QLatin1String("COPYRIGHT"), QString::fromWCharArray(str)); 1025 1027 SysFreeString(str); 1026 1028 } 1027 1029 hr = mediaContent->get_MoreInfoText(&str); 1028 1030 if (SUCCEEDED(hr)) { 1029 ret.insert(QLatin1String("MOREINFO"), QString::from Utf16((const unsigned short*)str));1031 ret.insert(QLatin1String("MOREINFO"), QString::fromWCharArray(str)); 1030 1032 SysFreeString(str); 1031 1033 } -
trunk/src/3rdparty/phonon/ds9/mediaobject.cpp
r2 r561 24 24 #ifndef Q_CC_MSVC 25 25 #include <dshow.h> 26 #endif //Q_CC_MSVC26 #endif 27 27 #include <objbase.h> 28 28 #include <initguid.h> … … 37 37 #include <QtCore/QDebug> 38 38 39 #define TIMER_INTERVAL 16 //... ms for the timer that polls the current state (we use the multimedia timer 39 #define TIMER_INTERVAL 16 //... ms for the timer that polls the current state (we use the multimedia timer) 40 40 #define PRELOAD_TIME 2000 // 2 seconds to load a source 41 41 … … 50 50 //first the definition of the WorkerThread class 51 51 WorkerThread::WorkerThread() 52 : QThread(), m_ currentRenderId(0), m_finished(false), m_currentWorkId(1)52 : QThread(), m_finished(false), m_currentWorkId(1) 53 53 { 54 54 } … … 56 56 WorkerThread::~WorkerThread() 57 57 { 58 }59 60 WorkerThread::Work WorkerThread::dequeueWork()61 {62 QMutexLocker locker(&m_mutex);63 if (m_finished) {64 return Work();65 }66 Work ret = m_queue.dequeue();67 68 //we ensure to have the wait condition in the right state69 if (m_queue.isEmpty()) {70 m_waitCondition.reset();71 } else {72 m_waitCondition.set();73 }74 75 return ret;76 58 } 77 59 … … 89 71 DWORD result = ::WaitForMultipleObjects(count, handles, FALSE, INFINITE); 90 72 if (result == WAIT_OBJECT_0) { 91 if (m_finished) {92 //that's the end if the thread execution93 return;94 }95 96 73 handleTask(); 97 74 } else { … … 181 158 w.graph = Graph(CLSID_FilterGraph, IID_IGraphBuilder); 182 159 w.filter = filter; 160 w.graph->AddFilter(filter, 0); 183 161 w.id = m_currentWorkId++; 184 162 m_queue.enqueue(w); … … 200 178 void WorkerThread::handleTask() 201 179 { 202 const Work w = dequeueWork(); 203 204 if (m_finished) { 205 return; 180 QMutexLocker locker(Backend::directShowMutex); 181 { 182 QMutexLocker locker(&m_mutex); 183 if (m_finished || m_queue.isEmpty()) { 184 return; 185 } 186 187 m_currentWork = m_queue.dequeue(); 188 189 //we ensure to have the wait condition in the right state 190 if (m_queue.isEmpty()) { 191 m_waitCondition.reset(); 192 } else { 193 m_waitCondition.set(); 194 } 206 195 } 207 196 208 197 HRESULT hr = S_OK; 209 198 210 m_currentRender = w.graph; 211 m_currentRenderId = w.id; 212 if (w.task == ReplaceGraph) { 213 QMutexLocker locker(&m_mutex); 214 HANDLE h; 215 199 if (m_currentWork.task == ReplaceGraph) { 216 200 int index = -1; 217 201 for(int i = 0; i < FILTER_COUNT; ++i) { 218 if (m_graphHandle[i].graph == w.oldGraph) {202 if (m_graphHandle[i].graph == m_currentWork.oldGraph) { 219 203 m_graphHandle[i].graph = Graph(); 220 204 index = i; … … 229 213 230 214 //add the new graph 231 if (SUCCEEDED(ComPointer<IMediaEvent>(w.graph, IID_IMediaEvent) 215 HANDLE h; 216 if (SUCCEEDED(ComPointer<IMediaEvent>(m_currentWork.graph, IID_IMediaEvent) 232 217 ->GetEventHandle(reinterpret_cast<OAEVENT*>(&h)))) { 233 m_graphHandle[index].graph = w.graph;218 m_graphHandle[index].graph = m_currentWork.graph; 234 219 m_graphHandle[index].handle = h; 235 220 } 236 } else if ( w.task == Render) {237 if ( w.filter) {221 } else if (m_currentWork.task == Render) { 222 if (m_currentWork.filter) { 238 223 //let's render pins 239 w.graph->AddFilter(w.filter, 0); 240 const QList<OutputPin> outputs = BackendNode::pins(w.filter, PINDIR_OUTPUT); 241 for (int i = 0; i < outputs.count(); ++i) { 242 //blocking call 243 hr = w.graph->Render(outputs.at(i)); 244 if (FAILED(hr)) { 245 break; 246 } 247 } 248 } else if (!w.url.isEmpty()) { 224 const QList<OutputPin> outputs = BackendNode::pins(m_currentWork.filter, PINDIR_OUTPUT); 225 for (int i = 0; SUCCEEDED(hr) && i < outputs.count(); ++i) { 226 hr = m_currentWork.graph->Render(outputs.at(i)); 227 } 228 } else if (!m_currentWork.url.isEmpty()) { 249 229 //let's render a url (blocking call) 250 hr = w.graph->RenderFile(reinterpret_cast<const wchar_t *>(w.url.utf16()), 0);230 hr = m_currentWork.graph->RenderFile(reinterpret_cast<const wchar_t *>(m_currentWork.url.utf16()), 0); 251 231 } 252 232 if (hr != E_ABORT) { 253 emit asyncRenderFinished(w.id, hr, w.graph);254 } 255 } else if ( w.task == Seek) {233 emit asyncRenderFinished(m_currentWork.id, hr, m_currentWork.graph); 234 } 235 } else if (m_currentWork.task == Seek) { 256 236 //that's a seekrequest 257 ComPointer<IMediaSeeking> mediaSeeking( w.graph, IID_IMediaSeeking);258 qint64 newtime = w.time * 10000;237 ComPointer<IMediaSeeking> mediaSeeking(m_currentWork.graph, IID_IMediaSeeking); 238 qint64 newtime = m_currentWork.time * 10000; 259 239 hr = mediaSeeking->SetPositions(&newtime, AM_SEEKING_AbsolutePositioning, 260 240 0, AM_SEEKING_NoPositioning); 261 qint64 currentTime = -1; 262 if (SUCCEEDED(hr)) { 263 hr = mediaSeeking->GetCurrentPosition(¤tTime); 264 if (SUCCEEDED(hr)) { 265 currentTime /= 10000; //convert to ms 266 } 267 } 268 emit asyncSeekingFinished(w.id, currentTime); 269 hr = E_ABORT; //to avoid emitting asyncRenderFinished 270 } else if (w.task == ChangeState) { 241 emit asyncSeekingFinished(m_currentWork.id, newtime / 10000); 242 hr = E_ABORT; //to avoid emitting asyncRenderFinished 243 } else if (m_currentWork.task == ChangeState) { 271 244 272 245 //remove useless decoders 273 246 QList<Filter> unused; 274 for (int i = 0; i < w.decoders.count(); ++i) {275 const Filter &filter = w.decoders.at(i);247 for (int i = 0; i < m_currentWork.decoders.count(); ++i) { 248 const Filter &filter = m_currentWork.decoders.at(i); 276 249 bool used = false; 277 250 const QList<OutputPin> pins = BackendNode::pins(filter, PINDIR_OUTPUT); … … 290 263 for (int i = 0; i < unused.count(); ++i) { 291 264 //we should remove this filter from the graph 292 w.graph->RemoveFilter(unused.at(i));265 m_currentWork.graph->RemoveFilter(unused.at(i)); 293 266 } 294 267 295 268 296 269 //we can get the state 297 ComPointer<IMediaControl> mc( w.graph, IID_IMediaControl);270 ComPointer<IMediaControl> mc(m_currentWork.graph, IID_IMediaControl); 298 271 299 272 //we change the state here 300 switch( w.state)273 switch(m_currentWork.state) 301 274 { 302 275 case State_Stopped: … … 316 289 if (SUCCEEDED(hr)) { 317 290 if (s == State_Stopped) { 318 emit stateReady( w.graph, Phonon::StoppedState);291 emit stateReady(m_currentWork.graph, Phonon::StoppedState); 319 292 } else if (s == State_Paused) { 320 emit stateReady( w.graph, Phonon::PausedState);293 emit stateReady(m_currentWork.graph, Phonon::PausedState); 321 294 } else /*if (s == State_Running)*/ { 322 emit stateReady(w.graph, Phonon::PlayingState); 323 } 324 } 325 } 326 327 m_currentRender = Graph(); 328 m_currentRenderId = 0; 329 330 } 331 332 void WorkerThread::abortCurrentRender(qint16 renderId) 333 { 295 emit stateReady(m_currentWork.graph, Phonon::PlayingState); 296 } 297 } 298 } 299 300 { 301 QMutexLocker locker(&m_mutex); 302 m_currentWork = Work(); //reinitialize 303 } 304 } 305 306 void WorkerThread::abortCurrentRender(qint16 renderId) 307 { 334 308 QMutexLocker locker(&m_mutex); 309 if (m_currentWork.id == renderId) { 310 m_currentWork.graph->Abort(); 311 } 335 312 bool found = false; 336 //we try to see if there is already an attempt to seek and we remove it337 313 for(int i = 0; !found && i < m_queue.size(); ++i) { 338 314 const Work &w = m_queue.at(i); … … 340 316 found = true; 341 317 m_queue.removeAt(i); 342 } 343 } 344 345 if (m_currentRender && m_currentRenderId == renderId) { 346 m_currentRender->Abort(); 347 } 348 } 318 if (m_queue.isEmpty()) { 319 m_waitCondition.reset(); 320 } 321 } 322 } 323 } 349 324 350 325 //tells the thread to stop processing … … 353 328 QMutexLocker locker(&m_mutex); 354 329 m_queue.clear(); 355 if (m_current Render) {330 if (m_currentWork.graph) { 356 331 //in case we're currently rendering something 357 m_current Render->Abort();332 m_currentWork.graph->Abort(); 358 333 359 334 } … … 384 359 385 360 for(int i = 0; i < FILTER_COUNT; ++i) { 386 m_graphs[i] = new MediaGraph(this, i); 387 } 388 389 connect(&m_thread, SIGNAL(stateReady(Graph, Phonon::State)),390 SLOT(slotStateReady(Graph, 391 392 connect(&m_thread, SIGNAL(eventReady(Graph, long, long)),393 SLOT(handleEvents(Graph, long,long)));394 395 connect(&m_thread, SIGNAL(asyncRenderFinished(quint16, HRESULT,Graph)),396 SLOT(finishLoading(quint16, HRESULT,Graph)));397 398 connect(&m_thread, SIGNAL(asyncSeekingFinished(quint16, 399 SLOT(finishSeeking(quint16, 361 m_graphs[i] = new MediaGraph(this, i); 362 } 363 364 connect(&m_thread, SIGNAL(stateReady(Graph,Phonon::State)), 365 SLOT(slotStateReady(Graph,Phonon::State))); 366 367 connect(&m_thread, SIGNAL(eventReady(Graph,long,long)), 368 SLOT(handleEvents(Graph,long,long))); 369 370 connect(&m_thread, SIGNAL(asyncRenderFinished(quint16,HRESULT,Graph)), 371 SLOT(finishLoading(quint16,HRESULT,Graph))); 372 373 connect(&m_thread, SIGNAL(asyncSeekingFinished(quint16,qint64)), 374 SLOT(finishSeeking(quint16,qint64))); 400 375 //really special case 401 376 m_mediaObject = this; … … 485 460 486 461 if (!m_aboutToFinishSent && remaining < PRELOAD_TIME - m_transitionTime + TIMER_INTERVAL/2) { 487 //let's take a 2 seconds time t ime to actually load the next file462 //let's take a 2 seconds time to actually load the next file 488 463 #ifdef GRAPH_DEBUG 489 464 qDebug() << "DS9: emit aboutToFinish" << remaining << QTime::currentTime().toString(); … … 520 495 qSwap(m_graphs[0], m_graphs[1]); //swap the graphs 521 496 497 if (m_transitionTime >= 0) 498 m_graphs[1]->stop(); //make sure we stop the previous graph 499 500 if (currentGraph()->mediaSource().type() != Phonon::MediaSource::Invalid && 501 catchComError(currentGraph()->renderResult())) { 502 setState(Phonon::ErrorState); 503 return; 504 } 505 506 //we need to play the next media 507 play(); 508 522 509 //we tell the video widgets to switch now to the new source 523 510 #ifndef QT_NO_PHONON_VIDEO … … 528 515 529 516 emit currentSourceChanged(currentGraph()->mediaSource()); 530 531 if (currentGraph()->isLoading()) {532 //will simply tell that when loading is finished533 //it should start the playback534 play();535 }536 537 538 539 517 emit metaDataChanged(currentGraph()->metadata()); 540 518 … … 549 527 setTitles(currentGraph()->titles()); 550 528 #endif //QT_NO_PHONON_MEDIACONTROLLER 551 552 //this manages only gapless transitions553 if (currentGraph()->mediaSource().type() != Phonon::MediaSource::Invalid) {554 if (catchComError(currentGraph()->renderResult())) {555 setState(Phonon::ErrorState);556 } else {557 play();558 }559 }560 529 } 561 530 … … 583 552 #ifndef QT_NO_PHONON_MEDIACONTROLLER 584 553 //1st, check if there is more titles after 585 const qint64 ret = (m_currentTitle < _iface_availableTitles() - 1) ? 554 const qint64 ret = (m_currentTitle < _iface_availableTitles() - 1) ? 586 555 titleAbsolutePosition(m_currentTitle+1) : currentGraph()->absoluteTotalTime(); 587 556 … … 596 565 { 597 566 //this handles inaccuracy when stopping on a title 598 return currentGraph()->absoluteCurrentTime() 567 return currentGraph()->absoluteCurrentTime() 599 568 #ifndef QT_NO_PHONON_MEDIACONTROLLER 600 569 - titleAbsolutePosition(m_currentTitle) … … 746 715 setState(Phonon::LoadingState); 747 716 //After loading we go into stopped state 748 m_nextState = Phonon::StoppedState; 717 m_nextState = Phonon::StoppedState; 749 718 catchComError(currentGraph()->loadSource(source)); 750 719 emit currentSourceChanged(source); … … 760 729 void MediaObject::loadingFinished(MediaGraph *mg) 761 730 { 762 if (mg == currentGraph()) { 731 if (mg == currentGraph()) { 763 732 #ifndef QT_NO_PHONON_MEDIACONTROLLER 764 733 //Title interface … … 791 760 case Phonon::PausedState: 792 761 pause(); 793 break;794 case Phonon::StoppedState:795 stop();796 762 break; 797 763 case Phonon::PlayingState: … … 801 767 setState(Phonon::ErrorState); 802 768 break; 769 case Phonon::StoppedState: 770 default: 771 stop(); 772 break; 803 773 } 804 774 } … … 817 787 void MediaObject::seekingFinished(MediaGraph *mg) 818 788 { 819 if (mg == currentGraph()) { 789 if (mg == currentGraph()) { 820 790 821 791 updateTargetTick(); … … 848 818 LPAMGETERRORTEXT getErrorText = (LPAMGETERRORTEXT)QLibrary::resolve(QLatin1String("quartz"), "AMGetErrorTextW"); 849 819 850 ushortbuffer[MAX_ERROR_TEXT_LEN];851 if (getErrorText && getErrorText(hr, (WCHAR*)buffer, MAX_ERROR_TEXT_LEN)) {852 m_errorString = QString::from Utf16(buffer);820 WCHAR buffer[MAX_ERROR_TEXT_LEN]; 821 if (getErrorText && getErrorText(hr, buffer, MAX_ERROR_TEXT_LEN)) { 822 m_errorString = QString::fromWCharArray(buffer); 853 823 } else { 854 824 m_errorString = QString::fromLatin1("Unknown error"); … … 892 862 if (VideoWidget *video = qobject_cast<VideoWidget*>(sink)) { 893 863 m_videoWidgets += video; 894 } else 864 } else 895 865 #endif //QT_NO_PHONON_VIDEO 896 866 if (AudioOutput *audio = qobject_cast<AudioOutput*>(sink)) { … … 911 881 if (VideoWidget *video = qobject_cast<VideoWidget*>(sink)) { 912 882 m_videoWidgets.removeOne(video); 913 } else 883 } else 914 884 #endif //QT_NO_PHONON_VIDEO 915 885 if (AudioOutput *audio = qobject_cast<AudioOutput*>(sink)) { … … 993 963 } 994 964 break; 995 case EC_LENGTH_CHANGED: 965 case EC_LENGTH_CHANGED: 996 966 if (graph == currentGraph()->graph()) { 997 967 emit totalTimeChanged( totalTime() ); -
trunk/src/3rdparty/phonon/ds9/mediaobject.h
r2 r561 115 115 enum Task 116 116 { 117 None, 117 118 Render, 118 119 Seek, … … 123 124 struct Work 124 125 { 126 Work() : task(None), id(0), time(0) { } 125 127 Task task; 126 128 quint16 id; … … 136 138 QList<Filter> decoders; //for the state change requests 137 139 }; 138 Work dequeueWork();139 140 void handleTask(); 140 141 141 Graph m_currentRender; 142 qint16 m_currentRenderId; 142 Work m_currentWork; 143 143 QQueue<Work> m_queue; 144 144 bool m_finished; 145 145 quint16 m_currentWorkId; 146 146 QWinWaitCondition m_waitCondition; 147 QMutex m_mutex; 147 QMutex m_mutex; // mutex for the m_queue, m_finished and m_currentWorkId 148 148 149 149 //this is for WaitForMultipleObjects -
trunk/src/3rdparty/phonon/ds9/qasyncreader.cpp
r2 r561 15 15 along with this library. If not, see <http://www.gnu.org/licenses/>. 16 16 */ 17 18 #include <QtCore/QFile>19 17 20 18 #include "qasyncreader.h" … … 81 79 STDMETHODIMP QAsyncReader::Request(IMediaSample *sample,DWORD_PTR user) 82 80 { 83 QMutexLocker mutexLocker(&m_mutexWait); 84 QWriteLocker locker(&m_lock); 81 QMutexLocker locker(&m_mutex); 85 82 if (m_flushing) { 86 83 return VFW_E_WRONG_STATE; … … 94 91 STDMETHODIMP QAsyncReader::WaitForNext(DWORD timeout, IMediaSample **sample, DWORD_PTR *user) 95 92 { 96 QMutexLocker locker(&m_mutex Wait);93 QMutexLocker locker(&m_mutex); 97 94 if (!sample ||!user) { 98 95 return E_POINTER; 99 96 } 100 97 98 //msdn says to return immediately if we're flushing but that doesn't seem to be true 99 //since it triggers a dead-lock somewhere inside directshow (see task 258830) 100 101 101 *sample = 0; 102 102 *user = 0; 103 103 104 AsyncRequest r = getNextRequest();105 106 if (r.sample == 0) {107 //there is no request in the queue108 if ( isFlushing()) {104 if (m_requestQueue.isEmpty()) { 105 if (m_requestWait.wait(&m_mutex, timeout) == false) { 106 return VFW_E_TIMEOUT; 107 } 108 if (m_requestQueue.isEmpty()) { 109 109 return VFW_E_WRONG_STATE; 110 } else {111 //First we need to lock the mutex112 if (m_requestWait.wait(&m_mutexWait, timeout) == false) {113 return VFW_E_TIMEOUT;114 }115 if (isFlushing()) {116 return VFW_E_WRONG_STATE;117 }118 119 r = getNextRequest();120 110 } 121 111 } 112 113 AsyncRequest r = m_requestQueue.dequeue(); 122 114 123 115 //at this point we're sure to have a request to proceed … … 128 120 *sample = r.sample; 129 121 *user = r.user; 130 131 return SyncReadAligned(r.sample); 122 return syncReadAlignedUnlocked(r.sample); 132 123 } 133 124 134 125 STDMETHODIMP QAsyncReader::BeginFlush() 135 126 { 136 QMutexLocker mutexLocker(&m_mutexWait); 137 QWriteLocker locker(&m_lock); 127 QMutexLocker locker(&m_mutex); 138 128 m_flushing = true; 139 129 m_requestWait.wakeOne(); … … 143 133 STDMETHODIMP QAsyncReader::EndFlush() 144 134 { 145 Q WriteLocker locker(&m_lock);135 QMutexLocker locker(&m_mutex); 146 136 m_flushing = false; 147 137 return S_OK; … … 150 140 STDMETHODIMP QAsyncReader::SyncReadAligned(IMediaSample *sample) 151 141 { 142 QMutexLocker locker(&m_mutex); 143 return syncReadAlignedUnlocked(sample); 144 } 145 146 STDMETHODIMP QAsyncReader::SyncRead(LONGLONG pos, LONG length, BYTE *buffer) 147 { 148 QMutexLocker locker(&m_mutex); 149 return read(pos, length, buffer, 0); 150 } 151 152 153 STDMETHODIMP QAsyncReader::syncReadAlignedUnlocked(IMediaSample *sample) 154 { 155 Q_ASSERT(!m_mutex.tryLock()); 156 152 157 if (!sample) { 153 158 return E_POINTER; … … 176 181 } 177 182 178 STDMETHODIMP QAsyncReader::SyncRead(LONGLONG pos, LONG length, BYTE *buffer)179 {180 return read(pos, length, buffer, 0);181 }182 183 184 //addition185 QAsyncReader::AsyncRequest QAsyncReader::getNextRequest()186 {187 QWriteLocker locker(&m_lock);188 AsyncRequest ret;189 if (!m_requestQueue.isEmpty()) {190 ret = m_requestQueue.dequeue();191 }192 193 return ret;194 }195 183 } 196 184 } -
trunk/src/3rdparty/phonon/ds9/qasyncreader.h
r2 r561 49 49 STDMETHODIMP SyncReadAligned(IMediaSample *); 50 50 STDMETHODIMP SyncRead(LONGLONG,LONG,BYTE *); 51 virtualSTDMETHODIMP Length(LONGLONG *,LONGLONG *) = 0;51 STDMETHODIMP Length(LONGLONG *,LONGLONG *) = 0; 52 52 STDMETHODIMP BeginFlush(); 53 53 STDMETHODIMP EndFlush(); 54 54 55 55 protected: 56 STDMETHODIMP syncReadAlignedUnlocked(IMediaSample *); 56 57 virtual HRESULT read(LONGLONG pos, LONG length, BYTE *buffer, LONG *actual) = 0; 57 58 … … 63 64 DWORD_PTR user; 64 65 }; 65 AsyncRequest getNextRequest();66 67 QMutex m_mutexWait;68 66 69 67 QQueue<AsyncRequest> m_requestQueue; -
trunk/src/3rdparty/phonon/ds9/qaudiocdreader.cpp
r2 r561 104 104 private: 105 105 HANDLE m_cddrive; 106 CDROM_TOC *m_toc;107 WaveStructure *m_waveHeader;106 CDROM_TOC m_toc; 107 WaveStructure m_waveHeader; 108 108 qint64 m_trackAddress; 109 109 }; … … 113 113 #define NB_SECTORS_READ 20 114 114 115 static AM_MEDIA_TYPE getAudioCDMediaType() 116 { 117 AM_MEDIA_TYPE mt; 118 qMemSet(&mt, 0, sizeof(AM_MEDIA_TYPE)); 119 mt.majortype = MEDIATYPE_Stream; 120 mt.subtype = MEDIASUBTYPE_WAVE; 121 mt.bFixedSizeSamples = TRUE; 122 mt.bTemporalCompression = FALSE; 123 mt.lSampleSize = 1; 124 mt.formattype = GUID_NULL; 125 return mt; 126 } 127 115 static const AM_MEDIA_TYPE audioCDMediaType = { MEDIATYPE_Stream, MEDIASUBTYPE_WAVE, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0}; 116 128 117 int addressToSectors(UCHAR address[4]) 129 118 { … … 142 131 143 132 144 QAudioCDReader::QAudioCDReader(QBaseFilter *parent, QChar drive) : QAsyncReader(parent, QVector<AM_MEDIA_TYPE>() << getAudioCDMediaType()) 145 { 146 m_toc = new CDROM_TOC; 147 m_waveHeader = new WaveStructure; 148 133 QAudioCDReader::QAudioCDReader(QBaseFilter *parent, QChar drive) : QAsyncReader(parent, QVector<AM_MEDIA_TYPE>() << audioCDMediaType) 134 { 149 135 //now open the cd-drive 150 136 QString path; … … 155 141 } 156 142 157 m_cddrive = QT_WA_INLINE ( 158 ::CreateFile( (TCHAR*)path.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL ), 159 ::CreateFileA( path.toLocal8Bit().constData(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL ) 160 ); 161 162 qMemSet(m_toc, 0, sizeof(CDROM_TOC)); 143 m_cddrive = ::CreateFile((const wchar_t *)path.utf16(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); 144 145 qMemSet(&m_toc, 0, sizeof(CDROM_TOC)); 163 146 //read the TOC 164 147 DWORD bytesRead = 0; 165 bool tocRead = ::DeviceIoControl(m_cddrive, IOCTL_CDROM_READ_TOC, 0, 0, m_toc, sizeof(CDROM_TOC), &bytesRead, 0);148 bool tocRead = ::DeviceIoControl(m_cddrive, IOCTL_CDROM_READ_TOC, 0, 0, &m_toc, sizeof(CDROM_TOC), &bytesRead, 0); 166 149 167 150 if (!tocRead) { … … 170 153 } 171 154 172 m_trackAddress = addressToSectors(m_toc ->TrackData[0].Address);173 const qint32 nbSectorsToRead = (addressToSectors(m_toc ->TrackData[m_toc->LastTrack + 1 - m_toc->FirstTrack].Address)155 m_trackAddress = addressToSectors(m_toc.TrackData[0].Address); 156 const qint32 nbSectorsToRead = (addressToSectors(m_toc.TrackData[m_toc.LastTrack + 1 - m_toc.FirstTrack].Address) 174 157 - m_trackAddress); 175 158 const qint32 dataLength = nbSectorsToRead * SECTOR_SIZE; 176 159 177 m_waveHeader ->chunksize = 4 + (8 + m_waveHeader->chunksize2) + (8 + dataLength);178 m_waveHeader ->dataLength = dataLength;160 m_waveHeader.chunksize = 4 + (8 + m_waveHeader.chunksize2) + (8 + dataLength); 161 m_waveHeader.dataLength = dataLength; 179 162 } 180 163 … … 182 165 { 183 166 ::CloseHandle(m_cddrive); 184 delete m_toc;185 delete m_waveHeader;186 187 167 } 188 168 … … 200 180 STDMETHODIMP QAudioCDReader::Length(LONGLONG *total,LONGLONG *available) 201 181 { 202 const LONGLONG length = sizeof(WaveStructure) + m_waveHeader ->dataLength;182 const LONGLONG length = sizeof(WaveStructure) + m_waveHeader.dataLength; 203 183 if (total) { 204 184 *total = length; … … 239 219 //we first copy the content of the structure 240 220 nbRead = qMin(LONG(sizeof(WaveStructure) - pos), length); 241 qMemCopy(buffer, reinterpret_cast<char*>( m_waveHeader) + pos, nbRead);221 qMemCopy(buffer, reinterpret_cast<char*>(&m_waveHeader) + pos, nbRead); 242 222 } 243 223 244 224 const LONGLONG posInTrack = pos - sizeof(WaveStructure) + nbRead; 245 const int bytesLeft = qMin(m_waveHeader ->dataLength - posInTrack, LONGLONG(length - nbRead));225 const int bytesLeft = qMin(m_waveHeader.dataLength - posInTrack, LONGLONG(length - nbRead)); 246 226 247 227 if (bytesLeft > 0) { … … 298 278 QList<qint64> ret; 299 279 ret << 0; 300 for(int i = m_toc ->FirstTrack; i <= m_toc->LastTrack ; ++i) {301 const uchar *address = m_toc ->TrackData[i].Address;280 for(int i = m_toc.FirstTrack; i <= m_toc.LastTrack ; ++i) { 281 const uchar *address = m_toc.TrackData[i].Address; 302 282 ret << ((address[0] * 60 + address[1]) * 60 + address[2]) * 1000 + address[3]*1000/75 - 2000; 303 283 -
trunk/src/3rdparty/phonon/ds9/qbasefilter.cpp
r2 r561 93 93 } 94 94 95 int nbfetched = 0;96 while (nbfetched < int(count)&& m_index < m_pins.count()) {95 uint nbfetched = 0; 96 while (nbfetched < count && m_index < m_pins.count()) { 97 97 IPin *current = m_pins[m_index]; 98 98 current->AddRef(); … … 167 167 const QList<QPin *> QBaseFilter::pins() const 168 168 { 169 Q ReadLocker locker(&m_lock);169 QMutexLocker locker(&m_mutex); 170 170 return m_pins; 171 171 } … … 173 173 void QBaseFilter::addPin(QPin *pin) 174 174 { 175 Q WriteLocker locker(&m_lock);175 QMutexLocker locker(&m_mutex); 176 176 m_pins.append(pin); 177 177 } … … 179 179 void QBaseFilter::removePin(QPin *pin) 180 180 { 181 Q WriteLocker locker(&m_lock);181 QMutexLocker locker(&m_mutex); 182 182 m_pins.removeAll(pin); 183 183 } … … 212 212 else if (iid == IID_IMediaPosition || iid == IID_IMediaSeeking) { 213 213 if (inputPins().isEmpty()) { 214 if (*out = getUpStreamInterface(iid)) { 214 *out = getUpStreamInterface(iid); 215 if (*out) { 215 216 return S_OK; //we return here to avoid adding a reference 216 217 } else { … … 251 252 STDMETHODIMP QBaseFilter::GetClassID(CLSID *clsid) 252 253 { 253 Q ReadLocker locker(&m_lock);254 QMutexLocker locker(&m_mutex); 254 255 *clsid = m_clsid; 255 256 return S_OK; … … 258 259 STDMETHODIMP QBaseFilter::Stop() 259 260 { 260 Q WriteLocker locker(&m_lock);261 QMutexLocker locker(&m_mutex); 261 262 m_state = State_Stopped; 262 263 return S_OK; … … 265 266 STDMETHODIMP QBaseFilter::Pause() 266 267 { 267 Q WriteLocker locker(&m_lock);268 QMutexLocker locker(&m_mutex); 268 269 m_state = State_Paused; 269 270 return S_OK; … … 272 273 STDMETHODIMP QBaseFilter::Run(REFERENCE_TIME) 273 274 { 274 Q WriteLocker locker(&m_lock);275 QMutexLocker locker(&m_mutex); 275 276 m_state = State_Running; 276 277 return S_OK; … … 279 280 STDMETHODIMP QBaseFilter::GetState(DWORD, FILTER_STATE *state) 280 281 { 281 Q ReadLocker locker(&m_lock);282 QMutexLocker locker(&m_mutex); 282 283 if (!state) { 283 284 return E_POINTER; … … 290 291 STDMETHODIMP QBaseFilter::SetSyncSource(IReferenceClock *clock) 291 292 { 292 Q WriteLocker locker(&m_lock);293 QMutexLocker locker(&m_mutex); 293 294 if (clock) { 294 295 clock->AddRef(); … … 303 304 STDMETHODIMP QBaseFilter::GetSyncSource(IReferenceClock **clock) 304 305 { 305 Q ReadLocker locker(&m_lock);306 QMutexLocker locker(&m_mutex); 306 307 if (!clock) { 307 308 return E_POINTER; … … 342 343 STDMETHODIMP QBaseFilter::QueryFilterInfo(FILTER_INFO *info ) 343 344 { 344 Q ReadLocker locker(&m_lock);345 QMutexLocker locker(&m_mutex); 345 346 if (!info) { 346 347 return E_POINTER; … … 356 357 STDMETHODIMP QBaseFilter::JoinFilterGraph(IFilterGraph *graph, LPCWSTR name) 357 358 { 358 Q WriteLocker locker(&m_lock);359 QMutexLocker locker(&m_mutex); 359 360 m_graph = graph; 360 m_name = QString::from Utf16((const unsigned short*)name);361 m_name = QString::fromWCharArray(name); 361 362 return S_OK; 362 363 } -
trunk/src/3rdparty/phonon/ds9/qbasefilter.h
r2 r561 23 23 #include <QtCore/QString> 24 24 #include <QtCore/QList> 25 #include <QtCore/Q ReadWriteLock>25 #include <QtCore/QMutex> 26 26 27 27 #include <dshow.h> … … 128 128 FILTER_STATE m_state; 129 129 QList<QPin *> m_pins; 130 mutable Q ReadWriteLock m_lock;130 mutable QMutex m_mutex; 131 131 }; 132 132 } -
trunk/src/3rdparty/phonon/ds9/qmeminputpin.cpp
r2 r561 29 29 { 30 30 31 QMemInputPin::QMemInputPin(QBaseFilter *parent, const QVector<AM_MEDIA_TYPE> &mt, bool transform ) :32 QPin(parent, PINDIR_INPUT, mt), m_shouldDuplicateSamples(true), m_transform(transform) 31 QMemInputPin::QMemInputPin(QBaseFilter *parent, const QVector<AM_MEDIA_TYPE> &mt, bool transform, QPin *output) : 32 QPin(parent, PINDIR_INPUT, mt), m_shouldDuplicateSamples(true), m_transform(transform), m_output(output) 33 33 { 34 34 } … … 67 67 //this allows to serialize with Receive calls 68 68 QMutexLocker locker(&m_mutexReceive); 69 for(int i = 0; i < m_outputs.count(); ++i) { 70 IPin *conn = m_outputs.at(i)->connected(); 71 if (conn) { 72 conn->EndOfStream(); 73 } 69 IPin *conn = m_output ? m_output->connected() : 0; 70 if (conn) { 71 conn->EndOfStream(); 74 72 } 75 73 return S_OK; … … 79 77 { 80 78 //pass downstream 81 for(int i = 0; i < m_outputs.count(); ++i) { 82 IPin *conn = m_outputs.at(i)->connected(); 83 if (conn) { 84 conn->BeginFlush(); 85 } 86 } 87 QWriteLocker locker(&m_lock); 79 IPin *conn = m_output ? m_output->connected() : 0; 80 if (conn) { 81 conn->BeginFlush(); 82 } 83 QMutexLocker locker(&m_mutex); 88 84 m_flushing = true; 89 85 return S_OK; … … 93 89 { 94 90 //pass downstream 95 for(int i = 0; i < m_outputs.count(); ++i) { 96 IPin *conn = m_outputs.at(i)->connected(); 97 if (conn) { 98 conn->EndFlush(); 99 } 100 } 101 QWriteLocker locker(&m_lock); 91 IPin *conn = m_output ? m_output->connected() : 0; 92 if (conn) { 93 conn->EndFlush(); 94 } 95 QMutexLocker locker(&m_mutex); 102 96 m_flushing = false; 103 97 return S_OK; … … 106 100 STDMETHODIMP QMemInputPin::NewSegment(REFERENCE_TIME start, REFERENCE_TIME stop, double rate) 107 101 { 108 for(int i = 0; i < m_outputs.count(); ++i) { 109 m_outputs.at(i)->NewSegment(start, stop, rate); 110 } 102 if (m_output) 103 m_output->NewSegment(start, stop, rate); 111 104 return S_OK; 112 105 } … … 120 113 mt->majortype != MEDIATYPE_NULL && 121 114 mt->subtype != MEDIASUBTYPE_NULL && 122 mt->formattype != GUID_NULL) { 123 //we tell the output pins that they should connect with this type 124 for(int i = 0; i < m_outputs.count(); ++i) { 125 hr = m_outputs.at(i)->setAcceptedMediaType(connectedType()); 126 if (FAILED(hr)) { 127 break; 128 } 129 } 115 mt->formattype != GUID_NULL && m_output) { 116 //we tell the output pin that it should connect with this type 117 hr = m_output->setAcceptedMediaType(connectedType()); 130 118 } 131 119 return hr; … … 138 126 } 139 127 140 if (*alloc = memoryAllocator(true)) { 128 *alloc = memoryAllocator(true); 129 if (*alloc) { 141 130 return S_OK; 142 131 } … … 152 141 153 142 { 154 Q WriteLocker locker(&m_lock);143 QMutexLocker locker(&m_mutex); 155 144 m_shouldDuplicateSamples = m_transform && readonly; 156 145 } … … 158 147 setMemoryAllocator(alloc); 159 148 160 for(int i = 0; i < m_outputs.count(); ++i) { 161 IPin *pin = m_outputs.at(i)->connected(); 162 if (pin) { 163 ComPointer<IMemInputPin> input(pin, IID_IMemInputPin); 164 input->NotifyAllocator(alloc, m_shouldDuplicateSamples); 165 } 149 if (m_output) { 150 ComPointer<IMemInputPin> input(m_output, IID_IMemInputPin); 151 input->NotifyAllocator(alloc, m_shouldDuplicateSamples); 166 152 } 167 153 … … 202 188 } 203 189 204 for (int i = 0; i < m_outputs.count(); ++i) { 205 QPin *current = m_outputs.at(i); 206 IMediaSample *outSample = m_shouldDuplicateSamples ? 207 duplicateSampleForOutput(sample, current->memoryAllocator()) 190 if (m_output) { 191 IMediaSample *outSample = m_shouldDuplicateSamples ? 192 duplicateSampleForOutput(sample, m_output->memoryAllocator()) 208 193 : sample; 209 194 … … 212 197 } 213 198 214 IPin *pin = current->connected(); 215 if (pin) { 216 ComPointer<IMemInputPin> input(pin, IID_IMemInputPin); 217 if (input) { 218 input->Receive(outSample); 219 } 199 ComPointer<IMemInputPin> input(m_output->connected(), IID_IMemInputPin); 200 if (input) { 201 input->Receive(outSample); 220 202 } 221 203 … … 248 230 STDMETHODIMP QMemInputPin::ReceiveCanBlock() 249 231 { 250 //we test the output to see if they can block 251 for(int i = 0; i < m_outputs.count(); ++i) { 252 IPin *input = m_outputs.at(i)->connected(); 253 if (input) { 254 ComPointer<IMemInputPin> meminput(input, IID_IMemInputPin); 255 if (meminput && meminput->ReceiveCanBlock() != S_FALSE) { 256 return S_OK; 257 } 232 //we test the output to see if it can block 233 if (m_output) { 234 ComPointer<IMemInputPin> meminput(m_output->connected(), IID_IMemInputPin); 235 if (meminput && meminput->ReceiveCanBlock() != S_FALSE) { 236 return S_OK; 258 237 } 259 238 } … … 261 240 } 262 241 263 //addition264 //this should be used by the filter to tell it's input pins to which output they should route the samples265 266 void QMemInputPin::addOutput(QPin *output)267 {268 QWriteLocker locker(&m_lock);269 m_outputs += output;270 }271 272 void QMemInputPin::removeOutput(QPin *output)273 {274 QWriteLocker locker(&m_lock);275 m_outputs.removeOne(output);276 }277 278 QList<QPin*> QMemInputPin::outputs() const279 {280 QReadLocker locker(&m_lock);281 return m_outputs;282 }283 242 284 243 ALLOCATOR_PROPERTIES QMemInputPin::getDefaultAllocatorProperties() const … … 295 254 296 255 HRESULT hr = alloc->Commit(); 297 if (hr == VFW_E_SIZENOTSET) {256 if (hr == HRESULT(VFW_E_SIZENOTSET)) { 298 257 ALLOCATOR_PROPERTIES prop = getDefaultAllocatorProperties(); 299 258 prop.cbBuffer = qMax(prop.cbBuffer, length); … … 325 284 LONGLONG start, end; 326 285 hr = sample->GetMediaTime(&start, &end); 327 if (hr != VFW_E_MEDIA_TIME_NOT_SET) {286 if (hr != HRESULT(VFW_E_MEDIA_TIME_NOT_SET)) { 328 287 hr = out->SetMediaTime(&start, &end); 329 288 Q_ASSERT(SUCCEEDED(hr)); -
trunk/src/3rdparty/phonon/ds9/qmeminputpin.h
r2 r561 38 38 { 39 39 public: 40 QMemInputPin(QBaseFilter *, const QVector<AM_MEDIA_TYPE> &, bool transform );40 QMemInputPin(QBaseFilter *, const QVector<AM_MEDIA_TYPE> &, bool transform, QPin *output); 41 41 ~QMemInputPin(); 42 42 … … 61 61 STDMETHODIMP ReceiveCanBlock(); 62 62 63 //addition64 void addOutput(QPin *output);65 void removeOutput(QPin *output);66 QList<QPin*> outputs() const;67 68 63 private: 69 64 IMediaSample *duplicateSampleForOutput(IMediaSample *, IMemAllocator *); … … 72 67 bool m_shouldDuplicateSamples; 73 68 const bool m_transform; //defines if the pin is transforming the samples 74 Q List<QPin*> m_outputs;69 QPin* const m_output; 75 70 QMutex m_mutexReceive; 76 71 }; -
trunk/src/3rdparty/phonon/ds9/qpin.cpp
r2 r561 29 29 { 30 30 31 static const AM_MEDIA_TYPE defaultMediaType() 32 { 33 AM_MEDIA_TYPE ret; 34 ret.majortype = MEDIATYPE_NULL; 35 ret.subtype = MEDIASUBTYPE_NULL; 36 ret.bFixedSizeSamples = TRUE; 37 ret.bTemporalCompression = FALSE; 38 ret.lSampleSize = 1; 39 ret.formattype = GUID_NULL; 40 ret.pUnk = 0; 41 ret.cbFormat = 0; 42 ret.pbFormat = 0; 43 return ret; 44 } 31 static const AM_MEDIA_TYPE defaultMediaType = { MEDIATYPE_NULL, MEDIASUBTYPE_NULL, TRUE, FALSE, 1, GUID_NULL, 0, 0, 0}; 45 32 46 33 class QEnumMediaTypes : public IEnumMediaTypes … … 105 92 } 106 93 107 int nbFetched = 0;108 while (nbFetched < int(count)&& m_index < m_pin->mediaTypes().count()) {94 uint nbFetched = 0; 95 while (nbFetched < count && m_index < m_pin->mediaTypes().count()) { 109 96 //the caller will deallocate the memory 110 97 *out = static_cast<AM_MEDIA_TYPE *>(::CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE))); … … 159 146 160 147 QPin::QPin(QBaseFilter *parent, PIN_DIRECTION dir, const QVector<AM_MEDIA_TYPE> &mt) : 161 m_memAlloc(0), m_parent(parent), m_refCount(1), m_connected(0),162 m_direction(dir), m_mediaTypes(mt), m_connectedType(defaultMediaType ()),163 m_ flushing(false)148 m_parent(parent), m_flushing(false), m_refCount(1), m_connected(0), 149 m_direction(dir), m_mediaTypes(mt), m_connectedType(defaultMediaType), 150 m_memAlloc(0) 164 151 { 165 152 Q_ASSERT(m_parent); … … 274 261 if (FAILED(hr)) { 275 262 setConnected(0); 276 setConnectedType(defaultMediaType ());263 setConnectedType(defaultMediaType); 277 264 } else { 278 265 ComPointer<IMemInputPin> input(pin, IID_IMemInputPin); … … 316 303 317 304 setConnected(0); 318 setConnectedType(defaultMediaType()); 319 if (m_direction == PINDIR_INPUT) { 320 setMemoryAllocator(0); 321 } 305 setConnectedType(defaultMediaType); 306 setMemoryAllocator(0); 322 307 return S_OK; 323 308 } … … 339 324 STDMETHODIMP QPin::ConnectionMediaType(AM_MEDIA_TYPE *type) 340 325 { 341 Q ReadLocker locker(&m_lock);326 QMutexLocker locker(&m_mutex); 342 327 if (!type) { 343 328 return E_POINTER; … … 354 339 STDMETHODIMP QPin::QueryPinInfo(PIN_INFO *info) 355 340 { 356 QReadLocker locker(&m_lock);357 341 if (!info) { 358 342 return E_POINTER; … … 362 346 info->pFilter = m_parent; 363 347 m_parent->AddRef(); 364 qMemCopy(info->achName, m_name.utf16(), qMin(MAX_FILTER_NAME, m_name.length()+1) *2); 365 348 info->achName[0] = 0; 366 349 return S_OK; 367 350 } … … 369 352 STDMETHODIMP QPin::QueryDirection(PIN_DIRECTION *dir) 370 353 { 371 QReadLocker locker(&m_lock);372 354 if (!dir) { 373 355 return E_POINTER; … … 380 362 STDMETHODIMP QPin::QueryId(LPWSTR *id) 381 363 { 382 QReadLocker locker(&m_lock);383 364 if (!id) { 384 365 return E_POINTER; 385 366 } 386 367 387 int nbBytes = (m_name.length()+1)*2; 388 *id = static_cast<LPWSTR>(::CoTaskMemAlloc(nbBytes)); 389 qMemCopy(*id, m_name.utf16(), nbBytes); 368 *id = static_cast<LPWSTR>(::CoTaskMemAlloc(2)); 369 *id[0] = 0; 390 370 return S_OK; 391 371 } … … 393 373 STDMETHODIMP QPin::QueryAccept(const AM_MEDIA_TYPE *type) 394 374 { 395 Q ReadLocker locker(&m_lock);375 QMutexLocker locker(&m_mutex); 396 376 if (!type) { 397 377 return E_POINTER; … … 440 420 STDMETHODIMP QPin::NewSegment(REFERENCE_TIME start, REFERENCE_TIME stop, double rate) 441 421 { 442 Q ReadLocker locker(&m_lock);422 QMutexLocker locker(&m_mutex); 443 423 if (m_direction == PINDIR_OUTPUT && m_connected) { 444 424 //we deliver this downstream … … 457 437 HRESULT QPin::checkOutputMediaTypesConnection(IPin *pin) 458 438 { 459 IEnumMediaTypes *emt = 0;460 HRESULT hr = pin->EnumMediaTypes( &emt);439 ComPointer<IEnumMediaTypes> emt; 440 HRESULT hr = pin->EnumMediaTypes(emt.pparam()); 461 441 if (hr != S_OK) { 462 442 return hr; … … 471 451 return S_OK; 472 452 } else { 473 setConnectedType(defaultMediaType ());453 setConnectedType(defaultMediaType); 474 454 freeMediaType(type); 475 455 } … … 521 501 void QPin::setConnectedType(const AM_MEDIA_TYPE &type) 522 502 { 523 Q WriteLocker locker(&m_lock);503 QMutexLocker locker(&m_mutex); 524 504 525 505 //1st we free memory … … 531 511 const AM_MEDIA_TYPE &QPin::connectedType() const 532 512 { 533 Q ReadLocker locker(&m_lock);513 QMutexLocker locker(&m_mutex); 534 514 return m_connectedType; 535 515 } … … 537 517 void QPin::setConnected(IPin *pin) 538 518 { 539 Q WriteLocker locker(&m_lock);519 QMutexLocker locker(&m_mutex); 540 520 if (pin) { 541 521 pin->AddRef(); … … 549 529 IPin *QPin::connected(bool addref) const 550 530 { 551 Q ReadLocker locker(&m_lock);531 QMutexLocker locker(&m_mutex); 552 532 if (addref && m_connected) { 553 533 m_connected->AddRef(); … … 558 538 bool QPin::isFlushing() const 559 539 { 560 Q ReadLocker locker(&m_lock);540 QMutexLocker locker(&m_mutex); 561 541 return m_flushing; 562 542 } … … 564 544 FILTER_STATE QPin::filterState() const 565 545 { 566 QReadLocker locker(&m_lock);567 546 FILTER_STATE fstate = State_Stopped; 568 547 m_parent->GetState(0, &fstate); … … 572 551 QVector<AM_MEDIA_TYPE> QPin::mediaTypes() const 573 552 { 574 Q ReadLocker locker(&m_lock);553 QMutexLocker locker(&m_mutex); 575 554 return m_mediaTypes; 576 555 } … … 608 587 void QPin::setMemoryAllocator(IMemAllocator *alloc) 609 588 { 610 Q WriteLocker locker(&m_lock);589 QMutexLocker locker(&m_mutex); 611 590 if (alloc) { 612 591 alloc->AddRef(); … … 620 599 IMemAllocator *QPin::memoryAllocator(bool addref) const 621 600 { 622 Q ReadLocker locker(&m_lock);601 QMutexLocker locker(&m_mutex); 623 602 if (addref && m_memAlloc) { 624 603 m_memAlloc->AddRef(); -
trunk/src/3rdparty/phonon/ds9/qpin.h
r2 r561 23 23 #include <QtCore/QString> 24 24 #include <QtCore/QVector> 25 #include <QtCore/Q ReadWriteLock>25 #include <QtCore/QMutex> 26 26 27 27 #include <dshow.h> … … 86 86 protected: 87 87 //this can be used by sub-classes 88 mutable Q ReadWriteLock m_lock;89 QBaseFilter * m_parent;88 mutable QMutex m_mutex; 89 QBaseFilter * const m_parent; 90 90 bool m_flushing; 91 91 … … 99 99 QVector<AM_MEDIA_TYPE> m_mediaTypes; //accepted media types 100 100 AM_MEDIA_TYPE m_connectedType; 101 QString m_name;102 101 IMemAllocator *m_memAlloc; 103 102 }; -
trunk/src/3rdparty/phonon/ds9/videorenderer_soft.cpp
r2 r561 64 64 "!!ARBfp1.0" 65 65 "PARAM c[5] = { program.local[0..1]," 66 " 67 " 68 " 66 "{ 1.164, 0, 1.596, 0.5 }," 67 "{ 0.0625, 1.164, -0.391, -0.81300002 }," 68 "{ 1.164, 2.0179999, 0 } };" 69 69 "TEMP R0;" 70 70 "TEX R0.x, fragment.texcoord[0], texture[1], 2D;" … … 90 90 91 91 static const char yuy2ToRgb[] = 92 92 "!!ARBfp1.0" 93 93 "PARAM c[5] = { program.local[0..1]," 94 " 95 " 96 " 94 "{ 0.5, 2, 1, 0.0625 }," 95 "{ 1.164, 0, 1.596, 2.0179999 }," 96 "{ 1.164, -0.391, -0.81300002 } };" 97 97 "TEMP R0;" 98 98 "TEMP R1;" … … 150 150 static const QVector<AM_MEDIA_TYPE> videoMediaTypes() 151 151 { 152 AM_MEDIA_TYPE mt; 153 qMemSet(&mt, 0, sizeof(AM_MEDIA_TYPE)); 154 mt.majortype = MEDIATYPE_Video; 155 156 //we accept any video format 157 mt.formattype = GUID_NULL; 158 mt.cbFormat = 0; 159 mt.pbFormat = 0; 152 AM_MEDIA_TYPE mt = { MEDIATYPE_Video, MEDIASUBTYPE_YV12, 0, 0, 0, GUID_NULL, 0, 0, 0 }; 160 153 161 154 QVector<AM_MEDIA_TYPE> ret; 162 155 163 //we support YUV (YV12 and YUY2) and RGB32 164 mt.subtype = MEDIASUBTYPE_YV12; 165 ret << mt; 156 //we add all the subtypes we support 157 ret << mt; //YV12 166 158 mt.subtype = MEDIASUBTYPE_YUY2; 167 ret << mt; 159 ret << mt; //YUY2 168 160 mt.subtype = MEDIASUBTYPE_RGB32; 169 ret << mt; 161 ret << mt; //RGB32 170 162 171 163 return ret; … … 203 195 #ifndef QT_NO_OPENGL 204 196 freeGLResources(); 197 m_textureUploaded = false; 205 198 #endif // QT_NO_OPENGL 206 m_textureUploaded = false;207 199 } 208 200 … … 323 315 HANDLE m_renderEvent, m_receiveCanWait; // Signals sample to render 324 316 QSize m_size; 325 bool m_textureUploaded;326 317 327 318 //mixer settings … … 365 356 bool m_checkedPrograms; 366 357 bool m_usingOpenGL; 358 bool m_textureUploaded; 367 359 GLuint m_program[2]; 368 360 GLuint m_texture[3]; … … 374 366 public: 375 367 VideoRendererSoftPin(VideoRendererSoftFilter *parent) : 376 QMemInputPin(parent, videoMediaTypes(), false /*no transformation of the samples*/ ),368 QMemInputPin(parent, videoMediaTypes(), false /*no transformation of the samples*/, 0), 377 369 m_renderer(parent) 378 370 { … … 445 437 m_renderer(renderer), m_start(0) 446 438 #ifndef QT_NO_OPENGL 447 , m_usingOpenGL(false), m_checkedPrograms(false), m_textureUploaded(false)439 , m_checkedPrograms(false), m_usingOpenGL(false), m_textureUploaded(false) 448 440 #endif 449 441 { … … 670 662 671 663 #ifndef QT_NO_OPENGL 672 if (painter.paintEngine() && painter.paintEngine()->type() == QPaintEngine::OpenGL && checkGLPrograms()) { 664 if (painter.paintEngine() && 665 (painter.paintEngine()->type() == QPaintEngine::OpenGL || painter.paintEngine()->type() == QPaintEngine::OpenGL2) 666 && checkGLPrograms()) { 667 673 668 //for now we only support YUV (both YV12 and YUY2) 674 669 updateTexture(); … … 682 677 683 678 //let's draw the texture 679 painter.beginNativePainting(); 684 680 685 681 //Let's pass the other arguments … … 731 727 732 728 glDisable(GL_FRAGMENT_PROGRAM_ARB); 729 painter.endNativePainting(); 733 730 return; 734 731 } else -
trunk/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp
r2 r561 170 170 ComPointer<IVMRWindowlessControl9> windowlessControl(m_filter, IID_IVMRWindowlessControl9); 171 171 windowlessControl->SetVideoClippingWindow(reinterpret_cast<HWND>(target->winId())); 172 windowlessControl->SetAspectRatioMode(VMR9ARMode_None); //we're in control of the size 172 173 } 173 174 -
trunk/src/3rdparty/phonon/ds9/videowidget.cpp
r2 r561 85 85 { 86 86 m_currentRenderer = renderer; 87 update(); 87 //we disallow repaint on that widget for just a fraction of second 88 //this allows better transition between videos 89 setUpdatesEnabled(false); 90 m_flickerFreeTimer.start(20, this); 91 } 92 93 void timerEvent(QTimerEvent *e) 94 { 95 if (e->timerId() == m_flickerFreeTimer.timerId()) { 96 m_flickerFreeTimer.stop(); 97 setUpdatesEnabled(true); 98 } 99 QWidget::timerEvent(e); 88 100 } 89 101 … … 107 119 void paintEvent(QPaintEvent *e) 108 120 { 121 if (!updatesEnabled()) 122 return; //this avoids repaint from native events 109 123 checkCurrentRenderingMode(); 110 124 m_currentRenderer->repaintCurrentFrame(this, e->rect()); … … 154 168 } else if (!isEmbedded()) { 155 169 m_currentRenderer = m_node->switchRendering(m_currentRenderer); 156 setAttribute(Qt::WA_PaintOnScreen, true);170 setAttribute(Qt::WA_PaintOnScreen, false); 157 171 } 158 172 } … … 161 175 AbstractVideoRenderer *m_currentRenderer; 162 176 QVariant m_restoreScreenSaverActive; 177 QBasicTimer m_flickerFreeTimer; 163 178 }; 164 179 … … 262 277 m_aspectRatio = aspectRatio; 263 278 updateVideoSize(); 279 m_widget->update(); 264 280 } 265 281 … … 280 296 m_scaleMode = scaleMode; 281 297 updateVideoSize(); 298 m_widget->update(); 282 299 } 283 300 -
trunk/src/3rdparty/phonon/ds9/volumeeffect.cpp
r2 r561 69 69 { 70 70 QVector<AM_MEDIA_TYPE> ret; 71 72 AM_MEDIA_TYPE mt; 73 mt.majortype = MEDIATYPE_Audio; 74 mt.subtype = MEDIASUBTYPE_PCM; 75 mt.bFixedSizeSamples = 1; 76 mt.bTemporalCompression = 0; 77 mt.pUnk = 0; 78 mt.lSampleSize = 1; 79 mt.cbFormat = 0; 80 mt.pbFormat = 0; 81 mt.formattype = GUID_NULL; 71 AM_MEDIA_TYPE mt = { MEDIATYPE_Audio, MEDIASUBTYPE_PCM, 1, 0, 1, GUID_NULL, 0, 0, 0}; 82 72 ret << mt; 83 73 return ret; … … 87 77 { 88 78 public: 89 VolumeMemInputPin(QBaseFilter *parent, const QVector<AM_MEDIA_TYPE> &mt ) : QMemInputPin(parent, mt, true /*transform*/)79 VolumeMemInputPin(QBaseFilter *parent, const QVector<AM_MEDIA_TYPE> &mt, QPin *output) : QMemInputPin(parent, mt, true /*transform*/, output) 90 80 { 91 81 } … … 150 140 //then creating the input 151 141 mt << audioMediaType(); 152 m_input = new VolumeMemInputPin(this, mt); 153 m_input->addOutput(m_output); //make the connection here 142 m_input = new VolumeMemInputPin(this, mt, m_output); 154 143 } 155 144
Note:
See TracChangeset
for help on using the changeset viewer.