Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/3rdparty/phonon/ds9/CMakeLists.txt

    r2 r561  
    4141
    4242    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})
    4444    set_target_properties(phonon_ds9 PROPERTIES PREFIX "")
    4545    target_link_libraries(phonon_ds9
    4646                ${PHONON_LIBS}  ${QT_QTOPENGL_LIBRARY} ${OPENGL_gl_LIBRARY}
    4747                dxguid strmiids dmoguids msdmo ole32 oleaut32 uuid gdi32)
     48    # 'MODULE' is treated as a LIBRARY
    4849    install(TARGETS phonon_ds9
    4950            RUNTIME DESTINATION ${BIN_INSTALL_DIR}/phonon_backend
    50             LIBRARY DESTINATION ${LIB_INSTALL_DIR}
     51            LIBRARY DESTINATION ${BIN_INSTALL_DIR}/phonon_backend
    5152            ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
    5253    install(FILES ds9.desktop DESTINATION ${SERVICES_INSTALL_DIR}/phononbackends)
  • trunk/src/3rdparty/phonon/ds9/abstractvideorenderer.cpp

    r2 r561  
    100100
    101101            if (ratio > 0) {
    102                 if (realWidth / realHeight > ratio && scaleMode == Phonon::VideoWidget::FitInView
    103                     || realWidth / realHeight < ratio && scaleMode == Phonon::VideoWidget::ScaleAndCrop) {
     102                if ((realWidth / realHeight > ratio && scaleMode == Phonon::VideoWidget::FitInView)
     103                    || (realWidth / realHeight < ratio && scaleMode == Phonon::VideoWidget::ScaleAndCrop)) {
    104104                        //the height is correct, let's change the width
    105105                        m_dstWidth = qRound(realHeight * ratio);
  • trunk/src/3rdparty/phonon/ds9/backend.cpp

    r2 r561  
    4242    namespace DS9
    4343    {
     44        QMutex *Backend::directShowMutex = 0;
     45
    4446        bool Backend::AudioMoniker::operator==(const AudioMoniker &other)
    4547        {
     
    5153            : QObject(parent)
    5254        {
    53                         ::CoInitialize(0);
     55            directShowMutex = &m_directShowMutex;
     56
     57            ::CoInitialize(0);
    5458
    5559            //registering meta types
     
    6266            m_audioOutputs.clear();
    6367            m_audioEffects.clear();
    64                         ::CoUninitialize();
     68            ::CoUninitialize();
     69
     70            directShowMutex = 0;
    6571        }
    6672
     
    132138        QList<int> Backend::objectDescriptionIndexes(Phonon::ObjectDescriptionType type) const
    133139        {
     140            QMutexLocker locker(&m_directShowMutex);
    134141            QList<int> ret;
    135142
     
    158165                        LPOLESTR str = 0;
    159166                        mon->GetDisplayName(0,0,&str);
    160                         const QString name = QString::fromUtf16((unsigned short*)str);
     167                        const QString name = QString::fromWCharArray(str);
    161168                                                ComPointer<IMalloc> alloc;
    162169                                                ::CoGetMalloc(1, alloc.pparam());
     
    205212        QHash<QByteArray, QVariant> Backend::objectDescriptionProperties(Phonon::ObjectDescriptionType type, int index) const
    206213        {
     214            QMutexLocker locker(&m_directShowMutex);
    207215            QHash<QByteArray, QVariant> ret;
    208216            switch (type)
     
    217225                    HRESULT hr = mon->GetDisplayName(0,0, &str);
    218226                    if (SUCCEEDED(hr)) {
    219                         QString name = QString::fromUtf16((unsigned short*)str);
     227                        QString name = QString::fromWCharArray(str);
    220228                                                ComPointer<IMalloc> alloc;
    221229                                                ::CoGetMalloc(1, alloc.pparam());
     
    232240                    HRESULT hr = ::DMOGetName(m_audioEffects[index], name);
    233241                    if (SUCCEEDED(hr)) {
    234                         ret["name"] = QString::fromUtf16((unsigned short*)name);
     242                        ret["name"] = QString::fromWCharArray(name);
    235243                    }
    236244                }
  • trunk/src/3rdparty/phonon/ds9/backend.h

    r2 r561  
    2424
    2525#include <QtCore/QList>
     26#include <QtCore/QMutex>
    2627
    2728#include "compointer.h"
     
    6465            Filter getAudioOutputFilter(int index) const;
    6566
     67            static QMutex *directShowMutex;
     68
    6669        Q_SIGNALS:
    6770            void objectDescriptionChanged(ObjectDescriptionType);
     
    7578            mutable QVector<AudioMoniker> m_audioOutputs;
    7679            mutable QVector<CLSID> m_audioEffects;
     80            mutable QMutex m_directShowMutex;
    7781        };
    7882    }
  • trunk/src/3rdparty/phonon/ds9/backendnode.cpp

    r2 r561  
    5858        BackendNode::~BackendNode()
    5959        {
     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            }
    6079        }
    6180
  • trunk/src/3rdparty/phonon/ds9/ds9.desktop

    r2 r561  
    66X-KDE-PhononBackendInfo-InterfaceVersion=1
    77X-KDE-PhononBackendInfo-Version=0.1
    8 X-KDE-PhononBackendInfo-Website=http://www.trolltech.com/
     8X-KDE-PhononBackendInfo-Website=http://qt.nokia.com/
    99InitialPreference=15
    1010
    1111Name=DirectShow9
     12Name[bg]=DirectShow9
     13Name[ca]=DirectShow9
     14Name[cs]=DirectShow9
     15Name[da]=DirectShow9
     16Name[de]=DirectShow9
     17Name[el]=DirectShow9
     18Name[en_GB]=DirectShow9
     19Name[es]=DirectShow9
     20Name[et]=DirectShow9
     21Name[eu]=DirectShow9
     22Name[fr]=DirectShow9
     23Name[ga]=DirectShow9
     24Name[gl]=DirectShow9
     25Name[hsb]=DirectShow9
     26Name[hu]=DirectShow9
     27Name[is]=DirectShow9
     28Name[it]=DirectShow9
     29Name[ja]=DirectShow9
     30Name[ko]=DirectShow9
     31Name[ku]=DirectShow9
     32Name[lt]=DirectShow9
     33Name[lv]=DirectShow9
     34Name[nds]=DirectShow9
     35Name[nl]=DirectShow9
     36Name[nn]=DirectShow9
    1237Name[pa]=àš¡àšŸàš‡àš°à©ˆàš•àšžàšŒà©‹9
     38Name[pl]=DirectShow9
     39Name[pt]=DirectShow9
     40Name[pt_BR]=DirectShow9
     41Name[se]=DirectShow9
    1342Name[sk]=DirectShow 9
    1443Name[sl]=DirectShow 9
     
    1645Name[sr@latin]=DirectShow‑9
    1746Name[sv]=Directshow 9
     47Name[tr]=DirectShow9
     48Name[uk]=DirectShow9
    1849Name[x-test]=xxDirectShow9xx
     50Name[zh_CN]=DirectShow9
     51Name[zh_TW]=DirectShow9
    1952
    2053Comment=Phonon DirectShow9 backend
    2154Comment[bg]=Phonon DirectShow9
    2255Comment[ca]=Dorsal DirectShow9 del Phonon
     56Comment[cs]=Phonon DirectShow9 backend
    2357Comment[da]=DirectShow9-backend til Phonon
    2458Comment[de]=Phonon-Treiber fÃŒr DirectShow9
     
    2660ποστήριΟης DirectShow9 τοÏ
    2761 Phonon
     62Comment[en_GB]=Phonon DirectShow9 backend
    2863Comment[es]=Motor DirectShow9 para Phonon
    2964Comment[et]=Phononi DirectShow9 taustaprogramm
     65Comment[eu]=Phonon DirectShow9 backend
    3066Comment[fr]=SystÚme de gestion DirectShow9 pour Phonon
    3167Comment[ga]=Inneall DirectShow9 le haghaidh Phonon
    3268Comment[gl]=Infraestrutura de DirectShow9 para Phonon
     69Comment[hsb]=Phonon DirectShow9 backend
     70Comment[hu]=Phonon DirectShow9 modul
     71Comment[is]=Phonon DirectShow9 bakendi
    3372Comment[it]=Motore DirectShow9 di Phonon
    3473Comment[ja]=Phonon DirectShow9 バック゚ンド
    3574Comment[ko]=Phonon DirectShow9 백엔드
     75Comment[ku]=Binesaza Phonon DirectShow9
     76Comment[lt]=Phonon DirectShow9 galinė sÄ
     77saja
    3678Comment[lv]=Phonon DirectShow9 aizmugure
    3779Comment[nds]=Phonon-HÃŒlpprogrmm DirectShow9
     
    4284Comment[pt]=Infra-estrutura do DirectShow9 para o Phonon
    4385Comment[pt_BR]=Infraestrutura Phonon DirectShow9
     86Comment[se]=Phonon DirectShow9 duogášmohtor
    4487Comment[sk]=Phonon DirectShow 9 podsystém
    4588Comment[sl]=Phononova Hrbtenica DirectShow 9
  • trunk/src/3rdparty/phonon/ds9/effect.cpp

    r2 r561  
    8383                        current += wcslen(current) + 1; //skip the unit
    8484                        for(; *current; current += wcslen(current) + 1) {
    85                             values.append( QString::fromUtf16((unsigned short*)current) );
     85                            values.append( QString::fromWCharArray(current) );
    8686                        }
    8787                    }
     
    108108                    Phonon::EffectParameter::LogarithmicHint : Phonon::EffectParameter::Hints(0);
    109109
    110                 const QString n = QString::fromUtf16((unsigned short*)name);
     110                const QString n = QString::fromWCharArray(name);
    111111                ret.append(Phonon::EffectParameter(i, n, hint, def, min, max, values));
    112112                ::CoTaskMemFree(name); //let's free the memory
     
    139139                Q_ASSERT(params);
    140140
    141                 MP_DATA data = float(v.toDouble());
    142                 params->SetParam(p.id(), data);
     141                params->SetParam(p.id(), v.toFloat());
    143142            }
    144143        }
  • trunk/src/3rdparty/phonon/ds9/fakesource.cpp

    r2 r561  
    3030    {
    3131        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)};
    3436
    3537        class FakePin : public QPin
     
    129131        void FakeSource::createFakeAudioPin()
    130132        {
    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);
    143134        }
    144135
    145136        void FakeSource::createFakeVideoPin()
    146137        {
    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);
    161139        }
    162140
  • trunk/src/3rdparty/phonon/ds9/iodevicereader.cpp

    r2 r561  
    3737        static QVector<AM_MEDIA_TYPE> getMediaTypes()
    3838        {
    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};
    4843
    4944            QVector<AM_MEDIA_TYPE> ret;
    50             //normal auto-detect stream
    51             mt.subtype = MEDIASUBTYPE_NULL;
    52             ret << mt;
    5345            //AVI stream
    54             mt.subtype = MEDIASUBTYPE_Avi;
    5546            ret << mt;
    5647            //WAVE stream
    5748            mt.subtype = MEDIASUBTYPE_WAVE;
     49            ret << mt;
     50            //normal auto-detect stream (must be at the end!)
     51            mt.subtype = MEDIASUBTYPE_NULL;
    5852            ret << mt;
    5953            return ret;
     
    7367              void writeData(const QByteArray &data)
    7468              {
    75                   QWriteLocker locker(&m_lock);
    7669                  m_pos += data.size();
    7770                  m_buffer += data;
     
    8477              void setStreamSize(qint64 newSize)
    8578              {
    86                   QWriteLocker locker(&m_lock);
     79                  QMutexLocker locker(&m_mutex);
    8780                  m_size = newSize;
    88               }
    89 
    90               qint64 streamSize() const
    91               {
    92                   QReadLocker locker(&m_lock);
    93                   return m_size;
    9481              }
    9582
    9683              void setStreamSeekable(bool s)
    9784              {
    98                   QWriteLocker locker(&m_lock);
     85                  QMutexLocker locker(&m_mutex);
    9986                  m_seekable = s;
    100               }
    101 
    102               bool streamSeekable() const
    103               {
    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() const
    117               {
    118                   QReadLocker locker(&m_lock);
    119                   return m_pos;
    120               }
    121 
    122               int currentBufferSize() const
    123               {
    124                   QReadLocker locker(&m_lock);
    125                   return m_buffer.size();
    12687              }
    12788
     
    13192              STDMETHODIMP Length(LONGLONG *total, LONGLONG *available)
    13293              {
    133                   QReadLocker locker(&m_lock);
     94                  QMutexLocker locker(&m_mutex);
    13495                  if (total) {
    13596                      *total = m_size;
     
    146107              HRESULT read(LONGLONG pos, LONG length, BYTE *buffer, LONG *actual)
    147108              {
    148                   QMutexLocker locker(&m_mutexRead);
    149 
     109                  Q_ASSERT(!m_mutex.tryLock());
    150110                  if (m_mediaGraph->isStopping()) {
    151111                      return VFW_E_WRONG_STATE;
    152112                  }
    153113
    154                   if(streamSize() != 1 && pos + length > streamSize()) {
     114                  if(m_size != 1 && pos + length > m_size) {
    155115                      //it tries to read outside of the boundaries
    156116                      return E_FAIL;
    157117                  }
    158118
    159                   if (currentPos() - currentBufferSize() != pos) {
    160                       if (!streamSeekable()) {
     119                  if (m_pos - m_buffer.size() != pos) {
     120                      if (!m_seekable) {
    161121                          return S_FALSE;
    162122                      }
    163                       setCurrentPos(pos);
     123                      m_pos = pos;
     124                      seekStream(pos);
     125                      m_buffer.clear();
    164126                  }
    165127
    166                   int oldSize = currentBufferSize();
    167                   while (currentBufferSize() < int(length)) {
     128                  int oldSize = m_buffer.size();
     129                  while (m_buffer.size() < int(length)) {
    168130                      needData();
    169131                      if (m_mediaGraph->isStopping()) {
     
    171133                      }
    172134
    173                       if (oldSize == currentBufferSize()) {
     135                      if (oldSize == m_buffer.size()) {
    174136                          break; //we didn't get any data
    175137                      }
    176                       oldSize = currentBufferSize();
     138                      oldSize = m_buffer.size();
    177139                  }
    178140
    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);
    186145
    187146                  if (actual) {
     
    199158            qint64 m_size;
    200159
    201             QMutex m_mutexRead;
    202160            const MediaGraph *m_mediaGraph;
    203161        };
     
    213171        {
    214172        }
    215 
    216         STDMETHODIMP IODeviceReader::Stop()
    217         {
    218             HRESULT hr = QBaseFilter::Stop();
    219             m_streamReader->enoughData(); //this asks to cancel any blocked call to needData
    220             return hr;
    221         }
    222 
    223173    }
    224174}
  • trunk/src/3rdparty/phonon/ds9/iodevicereader.h

    r2 r561  
    4242            IODeviceReader(const MediaSource &source, const MediaGraph *);
    4343            ~IODeviceReader();
    44             STDMETHODIMP Stop();
    4544
    4645        private:
  • trunk/src/3rdparty/phonon/ds9/mediagraph.cpp

    r2 r561  
    6969        }
    7070               
     71
     72/*
    7173        static HRESULT saveToFile(Graph graph, const QString &filepath)
    7274        {
     
    104106            return hr;
    105107        }
    106 
     108*/
    107109
    108110        MediaGraph::MediaGraph(MediaObject *mo, short index) :
     
    382384            if (info.pGraph) {
    383385                info.pGraph->Release();
    384                 return m_graph->RemoveFilter(filter);
     386                if (info.pGraph == m_graph)
     387                    return m_graph->RemoveFilter(filter);
    385388            }
    386389
     
    538541                    for(int i = 0; i < outputs.count(); ++i) {
    539542                        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())) {
    541544                            return SUCCEEDED(pin->Connect(newIn, 0));
    542545                        }
     
    680683               } else if (source.discType() == Phonon::Cd) {
    681684                    m_realSource = Filter(new QAudioCDPlayer);
    682                     m_result = m_graph->AddFilter(m_realSource, 0);
    683685
    684686#endif //QT_NO_PHONON_MEDIACONTROLLER
     
    810812                    const OutputPin &out = outputs.at(i);
    811813                    InputPin pin;
    812                     if (out->ConnectedTo(pin.pparam()) == VFW_E_NOT_CONNECTED) {
     814                    if (out->ConnectedTo(pin.pparam()) == HRESULT(VFW_E_NOT_CONNECTED)) {
    813815                        m_decoderPins += out; //unconnected outputs can be decoded outputs
    814816                    }
     
    10071009                HRESULT hr = mediaContent->get_AuthorName(&str);
    10081010                if (SUCCEEDED(hr)) {
    1009                     ret.insert(QLatin1String("ARTIST"), QString::fromUtf16((const unsigned short*)str));
     1011                    ret.insert(QLatin1String("ARTIST"), QString::fromWCharArray(str));
    10101012                    SysFreeString(str);
    10111013                }
    10121014                hr = mediaContent->get_Title(&str);
    10131015                if (SUCCEEDED(hr)) {
    1014                     ret.insert(QLatin1String("TITLE"), QString::fromUtf16((const unsigned short*)str));
     1016                    ret.insert(QLatin1String("TITLE"), QString::fromWCharArray(str));
    10151017                    SysFreeString(str);
    10161018                }
    10171019                hr = mediaContent->get_Description(&str);
    10181020                if (SUCCEEDED(hr)) {
    1019                     ret.insert(QLatin1String("DESCRIPTION"), QString::fromUtf16((const unsigned short*)str));
     1021                    ret.insert(QLatin1String("DESCRIPTION"), QString::fromWCharArray(str));
    10201022                    SysFreeString(str);
    10211023                }
    10221024                hr = mediaContent->get_Copyright(&str);
    10231025                if (SUCCEEDED(hr)) {
    1024                     ret.insert(QLatin1String("COPYRIGHT"), QString::fromUtf16((const unsigned short*)str));
     1026                    ret.insert(QLatin1String("COPYRIGHT"), QString::fromWCharArray(str));
    10251027                    SysFreeString(str);
    10261028                }
    10271029                hr = mediaContent->get_MoreInfoText(&str);
    10281030                if (SUCCEEDED(hr)) {
    1029                     ret.insert(QLatin1String("MOREINFO"), QString::fromUtf16((const unsigned short*)str));
     1031                    ret.insert(QLatin1String("MOREINFO"), QString::fromWCharArray(str));
    10301032                    SysFreeString(str);
    10311033                }
  • trunk/src/3rdparty/phonon/ds9/mediaobject.cpp

    r2 r561  
    2424#ifndef Q_CC_MSVC
    2525#include <dshow.h>
    26 #endif //Q_CC_MSVC
     26#endif
    2727#include <objbase.h>
    2828#include <initguid.h>
     
    3737#include <QtCore/QDebug>
    3838
    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)
    4040#define PRELOAD_TIME 2000 // 2 seconds to load a source
    4141
     
    5050        //first the definition of the WorkerThread class
    5151        WorkerThread::WorkerThread()
    52           : QThread(), m_currentRenderId(0), m_finished(false), m_currentWorkId(1)
     52          : QThread(), m_finished(false), m_currentWorkId(1)
    5353        {
    5454        }
     
    5656        WorkerThread::~WorkerThread()
    5757        {
    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 state
    69             if (m_queue.isEmpty()) {
    70                 m_waitCondition.reset();
    71             } else {
    72                 m_waitCondition.set();
    73             }
    74 
    75             return ret;
    7658        }
    7759
     
    8971                DWORD result = ::WaitForMultipleObjects(count, handles, FALSE, INFINITE);
    9072                if (result == WAIT_OBJECT_0) {
    91                     if (m_finished) {
    92                         //that's the end if the thread execution
    93                         return;
    94                     }
    95 
    9673                    handleTask();
    9774                } else {
     
    181158            w.graph = Graph(CLSID_FilterGraph, IID_IGraphBuilder);
    182159            w.filter = filter;
     160            w.graph->AddFilter(filter, 0);
    183161            w.id = m_currentWorkId++;
    184162            m_queue.enqueue(w);
     
    200178        void WorkerThread::handleTask()
    201179        {
    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                }
    206195            }
    207196
    208197            HRESULT hr = S_OK;
    209198
    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) {
    216200                int index = -1;
    217201                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) {
    219203                        m_graphHandle[i].graph = Graph();
    220204                        index = i;
     
    229213
    230214                //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)
    232217                    ->GetEventHandle(reinterpret_cast<OAEVENT*>(&h)))) {
    233                     m_graphHandle[index].graph = w.graph;
     218                    m_graphHandle[index].graph = m_currentWork.graph;
    234219                    m_graphHandle[index].handle = h;
    235220                }
    236             } else if (w.task == Render) {
    237                 if (w.filter) {
     221            } else if (m_currentWork.task == Render) {
     222                if (m_currentWork.filter) {
    238223                    //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()) {
    249229                    //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);
    251231                }
    252232                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) {
    256236                //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;
    259239                hr = mediaSeeking->SetPositions(&newtime, AM_SEEKING_AbsolutePositioning,
    260240                    0, AM_SEEKING_NoPositioning);
    261                 qint64 currentTime = -1;
    262                 if (SUCCEEDED(hr)) {
    263                     hr = mediaSeeking->GetCurrentPosition(&currentTime);
    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) {
    271244
    272245                //remove useless decoders
    273246                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);
    276249                    bool used = false;
    277250                    const QList<OutputPin> pins = BackendNode::pins(filter, PINDIR_OUTPUT);
     
    290263                for (int i = 0; i < unused.count(); ++i) {
    291264                    //we should remove this filter from the graph
    292                     w.graph->RemoveFilter(unused.at(i));
     265                    m_currentWork.graph->RemoveFilter(unused.at(i));
    293266                }
    294267
    295268
    296269                //we can get the state
    297                 ComPointer<IMediaControl> mc(w.graph, IID_IMediaControl);
     270                ComPointer<IMediaControl> mc(m_currentWork.graph, IID_IMediaControl);
    298271
    299272                //we change the state here
    300                 switch(w.state)
     273                switch(m_currentWork.state)
    301274                {
    302275                case State_Stopped:
     
    316289                if (SUCCEEDED(hr)) {
    317290                    if (s == State_Stopped) {
    318                         emit stateReady(w.graph, Phonon::StoppedState);
     291                        emit stateReady(m_currentWork.graph, Phonon::StoppedState);
    319292                    } else if (s == State_Paused) {
    320                         emit stateReady(w.graph, Phonon::PausedState);
     293                        emit stateReady(m_currentWork.graph, Phonon::PausedState);
    321294                    } 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        {
    334308            QMutexLocker locker(&m_mutex);
     309            if (m_currentWork.id == renderId) {
     310                m_currentWork.graph->Abort();
     311            }
    335312            bool found = false;
    336             //we try to see if there is already an attempt to seek and we remove it
    337313            for(int i = 0; !found && i < m_queue.size(); ++i) {
    338314                const Work &w = m_queue.at(i);
     
    340316                    found = true;
    341317                    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        }
    349324
    350325        //tells the thread to stop processing
     
    353328            QMutexLocker locker(&m_mutex);
    354329            m_queue.clear();
    355             if (m_currentRender) {
     330            if (m_currentWork.graph) {
    356331                //in case we're currently rendering something
    357                 m_currentRender->Abort();
     332                m_currentWork.graph->Abort();
    358333
    359334            }
     
    384359
    385360            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, Phonon::State)));
    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, qint64)),
    399                 SLOT(finishSeeking(quint16, qint64)));
     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)));
    400375            //really special case
    401376            m_mediaObject = this;
     
    485460
    486461                    if (!m_aboutToFinishSent && remaining < PRELOAD_TIME - m_transitionTime  + TIMER_INTERVAL/2) {
    487                         //let's take a 2 seconds time time to actually load the next file
     462                        //let's take a 2 seconds time to actually load the next file
    488463#ifdef GRAPH_DEBUG
    489464                        qDebug() << "DS9: emit aboutToFinish" << remaining << QTime::currentTime().toString();
     
    520495            qSwap(m_graphs[0], m_graphs[1]); //swap the graphs
    521496
     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
    522509            //we tell the video widgets to switch now to the new source
    523510#ifndef QT_NO_PHONON_VIDEO
     
    528515
    529516            emit currentSourceChanged(currentGraph()->mediaSource());
    530 
    531             if (currentGraph()->isLoading()) {
    532                 //will simply tell that when loading is finished
    533                 //it should start the playback
    534                 play();
    535             }
    536 
    537 
    538 
    539517            emit metaDataChanged(currentGraph()->metadata());
    540518
     
    549527            setTitles(currentGraph()->titles());
    550528#endif //QT_NO_PHONON_MEDIACONTROLLER
    551 
    552             //this manages only gapless transitions
    553             if (currentGraph()->mediaSource().type() != Phonon::MediaSource::Invalid) {
    554                 if (catchComError(currentGraph()->renderResult())) {
    555                     setState(Phonon::ErrorState);
    556                 } else {
    557                     play();
    558                 }
    559             }
    560529        }
    561530
     
    583552#ifndef QT_NO_PHONON_MEDIACONTROLLER
    584553            //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) ?
    586555                titleAbsolutePosition(m_currentTitle+1) : currentGraph()->absoluteTotalTime();
    587556
     
    596565        {
    597566            //this handles inaccuracy when stopping on a title
    598             return currentGraph()->absoluteCurrentTime() 
     567            return currentGraph()->absoluteCurrentTime()
    599568#ifndef QT_NO_PHONON_MEDIACONTROLLER
    600569                - titleAbsolutePosition(m_currentTitle)
     
    746715            setState(Phonon::LoadingState);
    747716            //After loading we go into stopped state
    748             m_nextState = Phonon::StoppedState; 
     717            m_nextState = Phonon::StoppedState;
    749718            catchComError(currentGraph()->loadSource(source));
    750719            emit currentSourceChanged(source);
     
    760729        void MediaObject::loadingFinished(MediaGraph *mg)
    761730        {
    762             if (mg == currentGraph()) { 
     731            if (mg == currentGraph()) {
    763732#ifndef QT_NO_PHONON_MEDIACONTROLLER
    764733                //Title interface
     
    791760                case Phonon::PausedState:
    792761                    pause();
    793                     break;
    794                 case Phonon::StoppedState:
    795                     stop();
    796762                    break;
    797763                case Phonon::PlayingState:
     
    801767                    setState(Phonon::ErrorState);
    802768                    break;
     769                case Phonon::StoppedState:
     770                default:
     771                    stop();
     772                    break;
    803773                }
    804774            }
     
    817787        void MediaObject::seekingFinished(MediaGraph *mg)
    818788        {
    819             if (mg == currentGraph()) { 
     789            if (mg == currentGraph()) {
    820790
    821791                updateTargetTick();
     
    848818                LPAMGETERRORTEXT getErrorText = (LPAMGETERRORTEXT)QLibrary::resolve(QLatin1String("quartz"), "AMGetErrorTextW");
    849819
    850                 ushort buffer[MAX_ERROR_TEXT_LEN];
    851                 if (getErrorText && getErrorText(hr, (WCHAR*)buffer, MAX_ERROR_TEXT_LEN)) {
    852                     m_errorString = QString::fromUtf16(buffer);
     820                WCHAR buffer[MAX_ERROR_TEXT_LEN];
     821                if (getErrorText && getErrorText(hr, buffer, MAX_ERROR_TEXT_LEN)) {
     822                    m_errorString = QString::fromWCharArray(buffer);
    853823                } else {
    854824                    m_errorString = QString::fromLatin1("Unknown error");
     
    892862                if (VideoWidget *video = qobject_cast<VideoWidget*>(sink)) {
    893863                    m_videoWidgets += video;
    894                 } else 
     864                } else
    895865#endif //QT_NO_PHONON_VIDEO
    896866                    if (AudioOutput *audio = qobject_cast<AudioOutput*>(sink)) {
     
    911881                if (VideoWidget *video = qobject_cast<VideoWidget*>(sink)) {
    912882                    m_videoWidgets.removeOne(video);
    913                 } else 
     883                } else
    914884#endif //QT_NO_PHONON_VIDEO
    915885                    if (AudioOutput *audio = qobject_cast<AudioOutput*>(sink)) {
     
    993963                }
    994964                break;
    995             case EC_LENGTH_CHANGED: 
     965            case EC_LENGTH_CHANGED:
    996966                if (graph == currentGraph()->graph()) {
    997967                    emit totalTimeChanged( totalTime() );
  • trunk/src/3rdparty/phonon/ds9/mediaobject.h

    r2 r561  
    115115            enum Task
    116116            {
     117                None,
    117118                Render,
    118119                Seek,
     
    123124            struct Work
    124125            {
     126                Work() : task(None), id(0), time(0) { }
    125127                Task task;
    126128                quint16 id;
     
    136138                QList<Filter> decoders; //for the state change requests
    137139            };
    138             Work dequeueWork();
    139140            void handleTask();
    140141
    141             Graph m_currentRender;
    142                         qint16 m_currentRenderId;
     142            Work m_currentWork;
    143143            QQueue<Work> m_queue;
    144144            bool m_finished;
    145145            quint16 m_currentWorkId;
    146146            QWinWaitCondition m_waitCondition;
    147             QMutex m_mutex;
     147            QMutex m_mutex; // mutex for the m_queue, m_finished and m_currentWorkId
    148148
    149149            //this is for WaitForMultipleObjects
  • trunk/src/3rdparty/phonon/ds9/qasyncreader.cpp

    r2 r561  
    1515along with this library.  If not, see <http://www.gnu.org/licenses/>.
    1616*/
    17 
    18 #include <QtCore/QFile>
    1917
    2018#include "qasyncreader.h"
     
    8179        STDMETHODIMP QAsyncReader::Request(IMediaSample *sample,DWORD_PTR user)
    8280        {
    83             QMutexLocker mutexLocker(&m_mutexWait);
    84             QWriteLocker locker(&m_lock);
     81            QMutexLocker locker(&m_mutex);
    8582            if (m_flushing) {
    8683                return VFW_E_WRONG_STATE;
     
    9491        STDMETHODIMP QAsyncReader::WaitForNext(DWORD timeout, IMediaSample **sample, DWORD_PTR *user)
    9592        {
    96             QMutexLocker locker(&m_mutexWait);
     93            QMutexLocker locker(&m_mutex);
    9794            if (!sample ||!user) {
    9895                return E_POINTER;
    9996            }
    10097
     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
    101101            *sample = 0;
    102102            *user = 0;
    103103
    104             AsyncRequest r = getNextRequest();
    105 
    106             if (r.sample == 0) {
    107                 //there is no request in the queue
    108                 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()) {
    109109                    return VFW_E_WRONG_STATE;
    110                 } else {
    111                     //First we need to lock the mutex
    112                     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();
    120110                }
    121111            }
     112
     113            AsyncRequest r = m_requestQueue.dequeue();
    122114
    123115            //at this point we're sure to have a request to proceed
     
    128120            *sample = r.sample;
    129121            *user = r.user;
    130 
    131             return SyncReadAligned(r.sample);
     122            return syncReadAlignedUnlocked(r.sample);
    132123        }
    133124
    134125        STDMETHODIMP QAsyncReader::BeginFlush()
    135126        {
    136             QMutexLocker mutexLocker(&m_mutexWait);
    137             QWriteLocker locker(&m_lock);
     127            QMutexLocker locker(&m_mutex);
    138128            m_flushing = true;
    139129            m_requestWait.wakeOne();
     
    143133        STDMETHODIMP QAsyncReader::EndFlush()
    144134        {
    145             QWriteLocker locker(&m_lock);
     135            QMutexLocker locker(&m_mutex);
    146136            m_flushing = false;
    147137            return S_OK;
     
    150140        STDMETHODIMP QAsyncReader::SyncReadAligned(IMediaSample *sample)
    151141        {
     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
    152157            if (!sample) {
    153158                return E_POINTER;
     
    176181        }
    177182
    178         STDMETHODIMP QAsyncReader::SyncRead(LONGLONG pos, LONG length, BYTE *buffer)
    179         {
    180             return read(pos, length, buffer, 0);
    181         }
    182 
    183 
    184         //addition
    185         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         }
    195183    }
    196184}
  • trunk/src/3rdparty/phonon/ds9/qasyncreader.h

    r2 r561  
    4949            STDMETHODIMP SyncReadAligned(IMediaSample *);
    5050            STDMETHODIMP SyncRead(LONGLONG,LONG,BYTE *);
    51             virtual STDMETHODIMP Length(LONGLONG *,LONGLONG *) = 0;
     51            STDMETHODIMP Length(LONGLONG *,LONGLONG *) = 0;
    5252            STDMETHODIMP BeginFlush();
    5353            STDMETHODIMP EndFlush();
    5454
    5555        protected:
     56            STDMETHODIMP syncReadAlignedUnlocked(IMediaSample *);
    5657            virtual HRESULT read(LONGLONG pos, LONG length, BYTE *buffer, LONG *actual) = 0;
    5758
     
    6364                DWORD_PTR user;
    6465            };
    65             AsyncRequest getNextRequest();
    66 
    67             QMutex m_mutexWait;
    6866
    6967            QQueue<AsyncRequest> m_requestQueue;
  • trunk/src/3rdparty/phonon/ds9/qaudiocdreader.cpp

    r2 r561  
    104104        private:
    105105            HANDLE m_cddrive;
    106             CDROM_TOC *m_toc;
    107             WaveStructure *m_waveHeader;
     106            CDROM_TOC m_toc;
     107            WaveStructure m_waveHeader;
    108108            qint64 m_trackAddress;
    109109        };
     
    113113#define NB_SECTORS_READ 20
    114114
    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 
    128117        int addressToSectors(UCHAR address[4])
    129118        {
     
    142131
    143132
    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        {
    149135            //now open the cd-drive
    150136            QString path;
     
    155141            }
    156142
    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));
    163146            //read the TOC
    164147            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);
    166149
    167150            if (!tocRead) {
     
    170153            }
    171154
    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)
    174157                - m_trackAddress);
    175158            const qint32 dataLength = nbSectorsToRead * SECTOR_SIZE;
    176159
    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;
    179162        }
    180163
     
    182165        {
    183166            ::CloseHandle(m_cddrive);
    184             delete m_toc;
    185             delete m_waveHeader;
    186 
    187167        }
    188168
     
    200180        STDMETHODIMP QAudioCDReader::Length(LONGLONG *total,LONGLONG *available)
    201181        {
    202             const LONGLONG length = sizeof(WaveStructure) + m_waveHeader->dataLength;
     182            const LONGLONG length = sizeof(WaveStructure) + m_waveHeader.dataLength;
    203183            if (total) {
    204184                *total = length;
     
    239219                //we first copy the content of the structure
    240220                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);
    242222            }
    243223
    244224            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));
    246226
    247227            if (bytesLeft > 0) {
     
    298278            QList<qint64> ret;
    299279            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;
    302282                ret << ((address[0] * 60 + address[1]) * 60 + address[2]) * 1000 + address[3]*1000/75 - 2000;
    303283
  • trunk/src/3rdparty/phonon/ds9/qbasefilter.cpp

    r2 r561  
    9393                }
    9494
    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()) {
    9797                    IPin *current = m_pins[m_index];
    9898                    current->AddRef();
     
    167167        const QList<QPin *> QBaseFilter::pins() const
    168168        {
    169             QReadLocker locker(&m_lock);
     169            QMutexLocker locker(&m_mutex);
    170170            return m_pins;
    171171        }
     
    173173        void QBaseFilter::addPin(QPin *pin)
    174174        {
    175             QWriteLocker locker(&m_lock);
     175            QMutexLocker locker(&m_mutex);
    176176            m_pins.append(pin);
    177177        }
     
    179179        void QBaseFilter::removePin(QPin *pin)
    180180        {
    181             QWriteLocker locker(&m_lock);
     181            QMutexLocker locker(&m_mutex);
    182182            m_pins.removeAll(pin);
    183183        }
     
    212212            else if (iid == IID_IMediaPosition || iid == IID_IMediaSeeking) {
    213213                if (inputPins().isEmpty()) {
    214                     if (*out = getUpStreamInterface(iid)) {
     214                    *out = getUpStreamInterface(iid);
     215                    if (*out) {
    215216                        return S_OK; //we return here to avoid adding a reference
    216217                    } else {
     
    251252        STDMETHODIMP QBaseFilter::GetClassID(CLSID *clsid)
    252253        {
    253             QReadLocker locker(&m_lock);
     254            QMutexLocker locker(&m_mutex);
    254255            *clsid = m_clsid;
    255256            return S_OK;
     
    258259        STDMETHODIMP QBaseFilter::Stop()
    259260        {
    260             QWriteLocker locker(&m_lock);
     261            QMutexLocker locker(&m_mutex);
    261262            m_state = State_Stopped;
    262263            return S_OK;
     
    265266        STDMETHODIMP QBaseFilter::Pause()
    266267        {
    267             QWriteLocker locker(&m_lock);
     268            QMutexLocker locker(&m_mutex);
    268269            m_state = State_Paused;
    269270            return S_OK;
     
    272273        STDMETHODIMP QBaseFilter::Run(REFERENCE_TIME)
    273274        {
    274             QWriteLocker locker(&m_lock);
     275            QMutexLocker locker(&m_mutex);
    275276            m_state = State_Running;
    276277            return S_OK;
     
    279280        STDMETHODIMP QBaseFilter::GetState(DWORD, FILTER_STATE *state)
    280281        {
    281             QReadLocker locker(&m_lock);
     282            QMutexLocker locker(&m_mutex);
    282283            if (!state) {
    283284                return E_POINTER;
     
    290291        STDMETHODIMP QBaseFilter::SetSyncSource(IReferenceClock *clock)
    291292        {
    292             QWriteLocker locker(&m_lock);
     293            QMutexLocker locker(&m_mutex);
    293294            if (clock) {
    294295                clock->AddRef();
     
    303304        STDMETHODIMP QBaseFilter::GetSyncSource(IReferenceClock **clock)
    304305        {
    305             QReadLocker locker(&m_lock);
     306            QMutexLocker locker(&m_mutex);
    306307            if (!clock) {
    307308                return E_POINTER;
     
    342343        STDMETHODIMP QBaseFilter::QueryFilterInfo(FILTER_INFO *info )
    343344        {
    344             QReadLocker locker(&m_lock);
     345            QMutexLocker locker(&m_mutex);
    345346            if (!info) {
    346347                return E_POINTER;
     
    356357        STDMETHODIMP QBaseFilter::JoinFilterGraph(IFilterGraph *graph, LPCWSTR name)
    357358        {
    358             QWriteLocker locker(&m_lock);
     359            QMutexLocker locker(&m_mutex);
    359360            m_graph = graph;
    360             m_name = QString::fromUtf16((const unsigned short*)name);
     361            m_name = QString::fromWCharArray(name);
    361362            return S_OK;
    362363        }
  • trunk/src/3rdparty/phonon/ds9/qbasefilter.h

    r2 r561  
    2323#include <QtCore/QString>
    2424#include <QtCore/QList>
    25 #include <QtCore/QReadWriteLock>
     25#include <QtCore/QMutex>
    2626
    2727#include <dshow.h>
     
    128128            FILTER_STATE m_state;
    129129            QList<QPin *> m_pins;
    130             mutable QReadWriteLock m_lock;
     130            mutable QMutex m_mutex;
    131131        };
    132132    }
  • trunk/src/3rdparty/phonon/ds9/qmeminputpin.cpp

    r2 r561  
    2929    {
    3030
    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)
    3333        {
    3434        }
     
    6767            //this allows to serialize with Receive calls
    6868            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();
    7472            }
    7573            return S_OK;
     
    7977        {
    8078            //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);
    8884            m_flushing = true;
    8985            return S_OK;
     
    9389        {
    9490            //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);
    10296            m_flushing = false;
    10397            return S_OK;
     
    106100        STDMETHODIMP QMemInputPin::NewSegment(REFERENCE_TIME start, REFERENCE_TIME stop, double rate)
    107101        {
    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);
    111104            return S_OK;
    112105        }
     
    120113                mt->majortype != MEDIATYPE_NULL &&
    121114                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());
    130118            }
    131119            return hr;
     
    138126            }
    139127
    140             if (*alloc = memoryAllocator(true)) {
     128            *alloc = memoryAllocator(true);
     129            if (*alloc) {
    141130                return S_OK;
    142131            }
     
    152141
    153142            {
    154                 QWriteLocker locker(&m_lock);
     143                QMutexLocker locker(&m_mutex);
    155144                m_shouldDuplicateSamples = m_transform && readonly;
    156145            }
     
    158147            setMemoryAllocator(alloc);
    159148
    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);
    166152            }
    167153
     
    202188            }
    203189
    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())
    208193                    : sample;
    209194
     
    212197                }
    213198
    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);
    220202                }
    221203
     
    248230        STDMETHODIMP QMemInputPin::ReceiveCanBlock()
    249231        {
    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;
    258237                }
    259238            }
     
    261240        }
    262241
    263         //addition
    264         //this should be used by the filter to tell it's input pins to which output they should route the samples
    265 
    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() const
    279         {
    280             QReadLocker locker(&m_lock);
    281             return m_outputs;
    282         }
    283242
    284243        ALLOCATOR_PROPERTIES QMemInputPin::getDefaultAllocatorProperties() const
     
    295254
    296255            HRESULT hr = alloc->Commit();
    297             if (hr == VFW_E_SIZENOTSET) {
     256            if (hr == HRESULT(VFW_E_SIZENOTSET)) {
    298257                ALLOCATOR_PROPERTIES prop = getDefaultAllocatorProperties();
    299258                prop.cbBuffer = qMax(prop.cbBuffer, length);
     
    325284                LONGLONG start, end;
    326285                hr = sample->GetMediaTime(&start, &end);
    327                 if (hr != VFW_E_MEDIA_TIME_NOT_SET) {
     286                if (hr != HRESULT(VFW_E_MEDIA_TIME_NOT_SET)) {
    328287                    hr = out->SetMediaTime(&start, &end);
    329288                    Q_ASSERT(SUCCEEDED(hr));
  • trunk/src/3rdparty/phonon/ds9/qmeminputpin.h

    r2 r561  
    3838        {
    3939        public:
    40             QMemInputPin(QBaseFilter *, const QVector<AM_MEDIA_TYPE> &, bool transform);
     40            QMemInputPin(QBaseFilter *, const QVector<AM_MEDIA_TYPE> &, bool transform, QPin *output);
    4141            ~QMemInputPin();
    4242
     
    6161            STDMETHODIMP ReceiveCanBlock();
    6262
    63             //addition
    64             void addOutput(QPin *output);
    65             void removeOutput(QPin *output);
    66             QList<QPin*> outputs() const;
    67 
    6863        private:
    6964            IMediaSample *duplicateSampleForOutput(IMediaSample *, IMemAllocator *);
     
    7267            bool m_shouldDuplicateSamples;
    7368            const bool m_transform; //defines if the pin is transforming the samples
    74             QList<QPin*> m_outputs;
     69            QPin* const m_output;
    7570            QMutex m_mutexReceive;
    7671        };
  • trunk/src/3rdparty/phonon/ds9/qpin.cpp

    r2 r561  
    2929    {
    3030
    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};
    4532
    4633        class QEnumMediaTypes : public IEnumMediaTypes
     
    10592                }
    10693
    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()) {
    10996                    //the caller will deallocate the memory
    11097                    *out = static_cast<AM_MEDIA_TYPE *>(::CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)));
     
    159146
    160147        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)
    164151        {
    165152            Q_ASSERT(m_parent);
     
    274261            if (FAILED(hr)) {
    275262                setConnected(0);
    276                 setConnectedType(defaultMediaType());
     263                setConnectedType(defaultMediaType);
    277264            } else {
    278265                ComPointer<IMemInputPin> input(pin, IID_IMemInputPin);
     
    316303
    317304            setConnected(0);
    318             setConnectedType(defaultMediaType());
    319             if (m_direction == PINDIR_INPUT) {
    320                 setMemoryAllocator(0);
    321             }
     305            setConnectedType(defaultMediaType);
     306            setMemoryAllocator(0);
    322307            return S_OK;
    323308        }
     
    339324        STDMETHODIMP QPin::ConnectionMediaType(AM_MEDIA_TYPE *type)
    340325        {
    341             QReadLocker locker(&m_lock);
     326            QMutexLocker locker(&m_mutex);
    342327            if (!type) {
    343328                return E_POINTER;
     
    354339        STDMETHODIMP QPin::QueryPinInfo(PIN_INFO *info)
    355340        {
    356             QReadLocker locker(&m_lock);
    357341            if (!info) {
    358342                return E_POINTER;
     
    362346            info->pFilter = m_parent;
    363347            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;
    366349            return S_OK;
    367350        }
     
    369352        STDMETHODIMP QPin::QueryDirection(PIN_DIRECTION *dir)
    370353        {
    371             QReadLocker locker(&m_lock);
    372354            if (!dir) {
    373355                return E_POINTER;
     
    380362        STDMETHODIMP QPin::QueryId(LPWSTR *id)
    381363        {
    382             QReadLocker locker(&m_lock);
    383364            if (!id) {
    384365                return E_POINTER;
    385366            }
    386367
    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;
    390370            return S_OK;
    391371        }
     
    393373        STDMETHODIMP QPin::QueryAccept(const AM_MEDIA_TYPE *type)
    394374        {
    395             QReadLocker locker(&m_lock);
     375            QMutexLocker locker(&m_mutex);
    396376            if (!type) {
    397377                return E_POINTER;
     
    440420        STDMETHODIMP QPin::NewSegment(REFERENCE_TIME start, REFERENCE_TIME stop, double rate)
    441421        {
    442             QReadLocker locker(&m_lock);
     422            QMutexLocker locker(&m_mutex);
    443423            if (m_direction == PINDIR_OUTPUT && m_connected) {
    444424                //we deliver this downstream
     
    457437        HRESULT QPin::checkOutputMediaTypesConnection(IPin *pin)
    458438        {
    459             IEnumMediaTypes *emt = 0;
    460             HRESULT hr = pin->EnumMediaTypes(&emt);
     439            ComPointer<IEnumMediaTypes> emt;
     440            HRESULT hr = pin->EnumMediaTypes(emt.pparam());
    461441            if (hr != S_OK) {
    462442                return hr;
     
    471451                        return S_OK;
    472452                    } else {
    473                         setConnectedType(defaultMediaType());
     453                        setConnectedType(defaultMediaType);
    474454                        freeMediaType(type);
    475455                    }
     
    521501        void QPin::setConnectedType(const AM_MEDIA_TYPE &type)
    522502        {
    523             QWriteLocker locker(&m_lock);
     503            QMutexLocker locker(&m_mutex);
    524504
    525505            //1st we free memory
     
    531511        const AM_MEDIA_TYPE &QPin::connectedType() const
    532512        {
    533             QReadLocker locker(&m_lock);
     513            QMutexLocker locker(&m_mutex);
    534514            return m_connectedType;
    535515        }
     
    537517        void QPin::setConnected(IPin *pin)
    538518        {
    539             QWriteLocker locker(&m_lock);
     519            QMutexLocker locker(&m_mutex);
    540520            if (pin) {
    541521                pin->AddRef();
     
    549529        IPin *QPin::connected(bool addref) const
    550530        {
    551             QReadLocker locker(&m_lock);
     531            QMutexLocker locker(&m_mutex);
    552532            if (addref && m_connected) {
    553533                m_connected->AddRef();
     
    558538        bool QPin::isFlushing() const
    559539        {
    560             QReadLocker locker(&m_lock);
     540            QMutexLocker locker(&m_mutex);
    561541            return m_flushing;
    562542        }
     
    564544        FILTER_STATE QPin::filterState() const
    565545        {
    566             QReadLocker locker(&m_lock);
    567546            FILTER_STATE fstate = State_Stopped;
    568547            m_parent->GetState(0, &fstate);
     
    572551        QVector<AM_MEDIA_TYPE> QPin::mediaTypes() const
    573552        {
    574             QReadLocker locker(&m_lock);
     553            QMutexLocker locker(&m_mutex);
    575554            return m_mediaTypes;
    576555        }
     
    608587        void QPin::setMemoryAllocator(IMemAllocator *alloc)
    609588        {
    610             QWriteLocker locker(&m_lock);
     589            QMutexLocker locker(&m_mutex);
    611590            if (alloc) {
    612591                alloc->AddRef();
     
    620599        IMemAllocator *QPin::memoryAllocator(bool addref) const
    621600        {
    622             QReadLocker locker(&m_lock);
     601            QMutexLocker locker(&m_mutex);
    623602            if (addref && m_memAlloc) {
    624603                m_memAlloc->AddRef();
  • trunk/src/3rdparty/phonon/ds9/qpin.h

    r2 r561  
    2323#include <QtCore/QString>
    2424#include <QtCore/QVector>
    25 #include <QtCore/QReadWriteLock>
     25#include <QtCore/QMutex>
    2626
    2727#include <dshow.h>
     
    8686        protected:
    8787            //this can be used by sub-classes
    88             mutable QReadWriteLock m_lock;
    89             QBaseFilter *m_parent;
     88            mutable QMutex m_mutex;
     89            QBaseFilter * const m_parent;
    9090            bool m_flushing;
    9191
     
    9999            QVector<AM_MEDIA_TYPE> m_mediaTypes; //accepted media types
    100100            AM_MEDIA_TYPE m_connectedType;
    101             QString m_name;
    102101            IMemAllocator *m_memAlloc;
    103102        };
  • trunk/src/3rdparty/phonon/ds9/videorenderer_soft.cpp

    r2 r561  
    6464"!!ARBfp1.0"
    6565"PARAM c[5] = { program.local[0..1],"
    66 "                { 1.164, 0, 1.596, 0.5 },"
    67 "                { 0.0625, 1.164, -0.391, -0.81300002 },"
    68 "                { 1.164, 2.0179999, 0 } };"
     66"{ 1.164, 0, 1.596, 0.5 },"
     67"{ 0.0625, 1.164, -0.391, -0.81300002 },"
     68"{ 1.164, 2.0179999, 0 } };"
    6969"TEMP R0;"
    7070"TEX R0.x, fragment.texcoord[0], texture[1], 2D;"
     
    9090
    9191static const char yuy2ToRgb[] =
    92     "!!ARBfp1.0"
     92"!!ARBfp1.0"
    9393"PARAM c[5] = { program.local[0..1],"
    94 "                { 0.5, 2, 1, 0.0625 },"
    95 "                { 1.164, 0, 1.596, 2.0179999 },"
    96 "                { 1.164, -0.391, -0.81300002 } };"
     94"{ 0.5, 2, 1, 0.0625 },"
     95"{ 1.164, 0, 1.596, 2.0179999 },"
     96"{ 1.164, -0.391, -0.81300002 } };"
    9797"TEMP R0;"
    9898"TEMP R1;"
     
    150150        static const QVector<AM_MEDIA_TYPE> videoMediaTypes()
    151151        {
    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 };
    160153
    161154            QVector<AM_MEDIA_TYPE> ret;
    162155
    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
    166158            mt.subtype = MEDIASUBTYPE_YUY2;
    167             ret << mt;
     159            ret << mt; //YUY2
    168160            mt.subtype = MEDIASUBTYPE_RGB32;
    169             ret << mt;
     161            ret << mt; //RGB32
    170162
    171163            return ret;
     
    203195#ifndef QT_NO_OPENGL
    204196                freeGLResources();
     197                m_textureUploaded = false;
    205198#endif // QT_NO_OPENGL
    206                 m_textureUploaded = false;
    207199            }
    208200
     
    323315            HANDLE m_renderEvent, m_receiveCanWait;         // Signals sample to render
    324316            QSize m_size;
    325             bool m_textureUploaded;
    326317
    327318            //mixer settings
     
    365356            bool m_checkedPrograms;
    366357            bool m_usingOpenGL;
     358            bool m_textureUploaded;
    367359            GLuint m_program[2];
    368360            GLuint m_texture[3];
     
    374366        public:
    375367            VideoRendererSoftPin(VideoRendererSoftFilter *parent) :
    376               QMemInputPin(parent, videoMediaTypes(), false /*no transformation of the samples*/),
     368              QMemInputPin(parent, videoMediaTypes(), false /*no transformation of the samples*/, 0),
    377369                  m_renderer(parent)
    378370              {
     
    445437            m_renderer(renderer), m_start(0)
    446438#ifndef QT_NO_OPENGL
    447             ,m_usingOpenGL(false), m_checkedPrograms(false), m_textureUploaded(false)
     439            , m_checkedPrograms(false), m_usingOpenGL(false), m_textureUploaded(false)
    448440#endif
    449441        {
     
    670662
    671663#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
    673668                //for now we only support YUV (both YV12 and YUY2)
    674669                updateTexture();
     
    682677
    683678                //let's draw the texture
     679                painter.beginNativePainting();
    684680
    685681                //Let's pass the other arguments
     
    731727
    732728                glDisable(GL_FRAGMENT_PROGRAM_ARB);
     729                painter.endNativePainting();
    733730                return;
    734731            } else
  • trunk/src/3rdparty/phonon/ds9/videorenderer_vmr9.cpp

    r2 r561  
    170170            ComPointer<IVMRWindowlessControl9> windowlessControl(m_filter, IID_IVMRWindowlessControl9);
    171171            windowlessControl->SetVideoClippingWindow(reinterpret_cast<HWND>(target->winId()));
     172            windowlessControl->SetAspectRatioMode(VMR9ARMode_None); //we're in control of the size
    172173        }
    173174
  • trunk/src/3rdparty/phonon/ds9/videowidget.cpp

    r2 r561  
    8585            {
    8686                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);
    88100            }
    89101
     
    107119            void paintEvent(QPaintEvent *e)
    108120            {
     121                if (!updatesEnabled())
     122                    return; //this avoids repaint from native events
    109123                checkCurrentRenderingMode();
    110124                m_currentRenderer->repaintCurrentFrame(this, e->rect());
     
    154168                } else if (!isEmbedded()) {
    155169                    m_currentRenderer = m_node->switchRendering(m_currentRenderer);
    156                     setAttribute(Qt::WA_PaintOnScreen, true);
     170                    setAttribute(Qt::WA_PaintOnScreen, false);
    157171                }
    158172            }
     
    161175            AbstractVideoRenderer *m_currentRenderer;
    162176            QVariant m_restoreScreenSaverActive;
     177            QBasicTimer m_flickerFreeTimer;
    163178        };
    164179
     
    262277            m_aspectRatio = aspectRatio;
    263278            updateVideoSize();
     279            m_widget->update();
    264280        }
    265281
     
    280296            m_scaleMode = scaleMode;
    281297            updateVideoSize();
     298            m_widget->update();
    282299        }
    283300
  • trunk/src/3rdparty/phonon/ds9/volumeeffect.cpp

    r2 r561  
    6969        {
    7070            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};
    8272            ret << mt;
    8373            return ret;
     
    8777        {
    8878        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)
    9080            {
    9181            }
     
    150140            //then creating the input
    151141            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);
    154143        }
    155144
Note: See TracChangeset for help on using the changeset viewer.