diff options
Diffstat (limited to 'src/plugins/directshow/common')
15 files changed, 65 insertions, 88 deletions
diff --git a/src/plugins/directshow/common/directshowbasefilter.cpp b/src/plugins/directshow/common/directshowbasefilter.cpp index d64021ed6..3a13dce0e 100644 --- a/src/plugins/directshow/common/directshowbasefilter.cpp +++ b/src/plugins/directshow/common/directshowbasefilter.cpp @@ -41,17 +41,12 @@ #include "directshowpinenum.h" +#include <mutex> + QT_BEGIN_NAMESPACE DirectShowBaseFilter::DirectShowBaseFilter() - : m_mutex(QMutex::Recursive) - , m_state(State_Stopped) - , m_graph(nullptr) - , m_clock(nullptr) - , m_sink(nullptr) -{ - -} + = default; DirectShowBaseFilter::~DirectShowBaseFilter() { @@ -75,15 +70,14 @@ HRESULT DirectShowBaseFilter::NotifyEvent(long eventCode, LONG_PTR eventParam1, eventParam2 = (LONG_PTR)(IBaseFilter*)this; return sink->Notify(eventCode, eventParam1, eventParam2); - } else { - return E_NOTIMPL; } + return E_NOTIMPL; } HRESULT DirectShowBaseFilter::Run(REFERENCE_TIME tStart) { Q_UNUSED(tStart) - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); m_startTime = tStart; @@ -100,7 +94,7 @@ HRESULT DirectShowBaseFilter::Run(REFERENCE_TIME tStart) HRESULT DirectShowBaseFilter::Pause() { - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); if (m_state == State_Stopped) { const QList<DirectShowPin *> pinList = pins(); @@ -120,7 +114,7 @@ HRESULT DirectShowBaseFilter::Pause() HRESULT DirectShowBaseFilter::Stop() { - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); HRESULT hr = S_OK; @@ -147,7 +141,7 @@ HRESULT DirectShowBaseFilter::GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *p if (!pState) { return E_POINTER; } else { - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); *pState = m_state; @@ -157,7 +151,7 @@ HRESULT DirectShowBaseFilter::GetState(DWORD dwMilliSecsTimeout, FILTER_STATE *p HRESULT DirectShowBaseFilter::SetSyncSource(IReferenceClock *pClock) { - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); if (m_clock) m_clock->Release(); @@ -197,7 +191,7 @@ HRESULT DirectShowBaseFilter::FindPin(LPCWSTR Id, IPin **ppPin) if (!ppPin || !Id) return E_POINTER; - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); const QList<DirectShowPin *> pinList = pins(); for (DirectShowPin *pin : pinList) { if (pin->name() == QStringView(Id)) { @@ -207,13 +201,13 @@ HRESULT DirectShowBaseFilter::FindPin(LPCWSTR Id, IPin **ppPin) } } - *ppPin = 0; + *ppPin = nullptr; return VFW_E_NOT_FOUND; } HRESULT DirectShowBaseFilter::JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName) { - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); m_filterName = QString::fromWCharArray(pName); m_graph = pGraph; diff --git a/src/plugins/directshow/common/directshowbasefilter.h b/src/plugins/directshow/common/directshowbasefilter.h index fe78f96b2..ce30891d7 100644 --- a/src/plugins/directshow/common/directshowbasefilter.h +++ b/src/plugins/directshow/common/directshowbasefilter.h @@ -78,13 +78,13 @@ public: STDMETHODIMP QueryVendorInfo(LPWSTR *pVendorInfo) override; protected: - QMutex m_mutex; - FILTER_STATE m_state; - IFilterGraph *m_graph; - IReferenceClock *m_clock; - IMediaEventSink *m_sink; + QRecursiveMutex m_mutex; + FILTER_STATE m_state = State_Stopped; + IFilterGraph *m_graph = nullptr; + IReferenceClock *m_clock = nullptr; + IMediaEventSink *m_sink = nullptr; QString m_filterName; - REFERENCE_TIME m_startTime; + REFERENCE_TIME m_startTime = 0; private: Q_DISABLE_COPY(DirectShowBaseFilter) diff --git a/src/plugins/directshow/common/directshoweventloop.cpp b/src/plugins/directshow/common/directshoweventloop.cpp index 843a78422..692c873cf 100644 --- a/src/plugins/directshow/common/directshoweventloop.cpp +++ b/src/plugins/directshow/common/directshoweventloop.cpp @@ -51,7 +51,6 @@ public: DirectShowPostedEvent(QObject *receiver, QEvent *event) : receiver(receiver) , event(event) - , next(0) { } @@ -62,13 +61,11 @@ public: QObject *receiver; QEvent *event; - DirectShowPostedEvent *next; + DirectShowPostedEvent *next = nullptr; }; DirectShowEventLoop::DirectShowEventLoop(QObject *parent) : QObject(parent) - , m_postsHead(0) - , m_postsTail(0) , m_eventHandle(::CreateEvent(nullptr, FALSE, FALSE, nullptr)) , m_waitHandle(::CreateEvent(nullptr, FALSE, FALSE, nullptr)) { @@ -141,7 +138,7 @@ void DirectShowEventLoop::processEvents() m_postsHead = m_postsHead->next; if (!m_postsHead) - m_postsTail = 0; + m_postsTail = nullptr; locker.unlock(); QCoreApplication::sendEvent(post->receiver, post->event); diff --git a/src/plugins/directshow/common/directshoweventloop.h b/src/plugins/directshow/common/directshoweventloop.h index a29274b7b..984bd23a4 100644 --- a/src/plugins/directshow/common/directshoweventloop.h +++ b/src/plugins/directshow/common/directshoweventloop.h @@ -54,7 +54,7 @@ class DirectShowEventLoop : public QObject { Q_OBJECT public: - DirectShowEventLoop(QObject *parent = 0); + DirectShowEventLoop(QObject *parent = nullptr); ~DirectShowEventLoop() override; void wait(QMutex *mutex); @@ -68,8 +68,8 @@ protected: private: void processEvents(); - DirectShowPostedEvent *m_postsHead; - DirectShowPostedEvent *m_postsTail; + DirectShowPostedEvent *m_postsHead = nullptr; + DirectShowPostedEvent *m_postsTail = nullptr; HANDLE m_eventHandle; HANDLE m_waitHandle; QMutex m_mutex; diff --git a/src/plugins/directshow/common/directshowglobal.h b/src/plugins/directshow/common/directshowglobal.h index d98dd36ee..12693e4f1 100644 --- a/src/plugins/directshow/common/directshowglobal.h +++ b/src/plugins/directshow/common/directshowglobal.h @@ -53,27 +53,27 @@ QT_END_NAMESPACE template <typename T> T *com_cast(IUnknown *unknown, const IID &iid) { - T *iface = 0; + T *iface = nullptr; return unknown && unknown->QueryInterface(iid, reinterpret_cast<void **>(&iface)) == S_OK ? iface - : 0; + : nullptr; } template <typename T> T *com_new(const IID &clsid) { - T *object = 0; + T *object = nullptr; return CoCreateInstance( clsid, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&object)) == S_OK ? object - : 0; + : nullptr; } template <typename T> T *com_new(const IID &clsid, const IID &iid) { - T *object = 0; + T *object = nullptr; return CoCreateInstance( clsid, nullptr, @@ -81,7 +81,7 @@ template <typename T> T *com_new(const IID &clsid, const IID &iid) iid, reinterpret_cast<void **>(&object)) == S_OK ? object - : 0; + : nullptr; } DEFINE_GUID(MEDIASUBTYPE_I420, diff --git a/src/plugins/directshow/common/directshowmediatypeenum.cpp b/src/plugins/directshow/common/directshowmediatypeenum.cpp index 56716ed75..0ff147fea 100644 --- a/src/plugins/directshow/common/directshowmediatypeenum.cpp +++ b/src/plugins/directshow/common/directshowmediatypeenum.cpp @@ -42,17 +42,13 @@ #include "directshowpin.h" DirectShowMediaTypeEnum::DirectShowMediaTypeEnum(DirectShowPin *pin) - : m_pin(pin) - , m_mediaTypes(pin->supportedMediaTypes()) - , m_index(0) + : m_mediaTypes(pin->supportedMediaTypes()) { m_pin->AddRef(); } DirectShowMediaTypeEnum::DirectShowMediaTypeEnum(const QList<DirectShowMediaType> &types) - : m_pin(nullptr) - , m_mediaTypes(types) - , m_index(0) + : m_mediaTypes(types) { } diff --git a/src/plugins/directshow/common/directshowmediatypeenum.h b/src/plugins/directshow/common/directshowmediatypeenum.h index e78e0a0f2..a5c347004 100644 --- a/src/plugins/directshow/common/directshowmediatypeenum.h +++ b/src/plugins/directshow/common/directshowmediatypeenum.h @@ -67,9 +67,9 @@ public: private: Q_DISABLE_COPY(DirectShowMediaTypeEnum) - DirectShowPin *m_pin; + DirectShowPin *m_pin = nullptr; QList<DirectShowMediaType> m_mediaTypes; - int m_index; + int m_index = 0; }; QT_END_NAMESPACE diff --git a/src/plugins/directshow/common/directshowpin.cpp b/src/plugins/directshow/common/directshowpin.cpp index 617cc2cf2..d8129748c 100644 --- a/src/plugins/directshow/common/directshowpin.cpp +++ b/src/plugins/directshow/common/directshowpin.cpp @@ -45,14 +45,14 @@ #include <qdebug.h> +#include <mutex> + QT_BEGIN_NAMESPACE DirectShowPin::DirectShowPin(DirectShowBaseFilter *filter, const QString &name, PIN_DIRECTION direction) - : m_mutex(QMutex::Recursive) - , m_filter(filter) + : m_filter(filter) , m_name(name) , m_direction(direction) - , m_peerPin(nullptr) { } @@ -64,7 +64,7 @@ HRESULT DirectShowPin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt) return E_POINTER; HRESULT hr = E_FAIL; - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); if (m_peerPin) return VFW_E_ALREADY_CONNECTED; @@ -170,7 +170,7 @@ HRESULT DirectShowPin::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE * if (!pConnector || !pmt) return E_POINTER; - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); if (m_peerPin) return VFW_E_ALREADY_CONNECTED; @@ -207,7 +207,7 @@ HRESULT DirectShowPin::ReceiveConnection(IPin *pConnector, const AM_MEDIA_TYPE * HRESULT DirectShowPin::Disconnect() { - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); if (m_filter->state() != State_Stopped) return VFW_E_NOT_STOPPED; @@ -233,9 +233,9 @@ HRESULT DirectShowPin::ConnectedTo(IPin **ppPin) if (!ppPin) return E_POINTER; - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); if (!m_peerPin) { - *ppPin = 0; + *ppPin = nullptr; return VFW_E_NOT_CONNECTED; } m_peerPin->AddRef(); @@ -248,7 +248,7 @@ HRESULT DirectShowPin::ConnectionMediaType(AM_MEDIA_TYPE *pmt) if (!pmt) return E_POINTER; - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); if (!m_peerPin) { DirectShowMediaType::init(pmt); return VFW_E_NOT_CONNECTED; @@ -380,8 +380,6 @@ HRESULT DirectShowPin::setActive(bool active) DirectShowOutputPin::DirectShowOutputPin(DirectShowBaseFilter *filter, const QString &name) : DirectShowPin(filter, name, PINDIR_OUTPUT) - , m_allocator(nullptr) - , m_inputPin(nullptr) { } @@ -485,9 +483,6 @@ HRESULT DirectShowOutputPin::EndOfStream() DirectShowInputPin::DirectShowInputPin(DirectShowBaseFilter *filter, const QString &name) : DirectShowPin(filter, name, PINDIR_INPUT) - , m_allocator(nullptr) - , m_flushing(false) - , m_inErrorState(false) { ZeroMemory(&m_sampleProperties, sizeof(m_sampleProperties)); } @@ -537,14 +532,14 @@ HRESULT DirectShowInputPin::EndOfStream() HRESULT DirectShowInputPin::BeginFlush() { - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); m_flushing = true; return S_OK; } HRESULT DirectShowInputPin::EndFlush() { - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); m_flushing = false; m_inErrorState = false; return S_OK; @@ -555,7 +550,7 @@ HRESULT DirectShowInputPin::GetAllocator(IMemAllocator **ppAllocator) if (!ppAllocator) return E_POINTER; - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); if (!m_allocator) { m_allocator = com_new<IMemAllocator>(CLSID_MemoryAllocator);; @@ -576,7 +571,7 @@ HRESULT DirectShowInputPin::NotifyAllocator(IMemAllocator *pAllocator, BOOL bRea if (!pAllocator) return E_POINTER; - QMutexLocker locker(&m_mutex); + const std::lock_guard<QRecursiveMutex> locker(m_mutex); if (m_allocator) m_allocator->Release(); diff --git a/src/plugins/directshow/common/directshowpin.h b/src/plugins/directshow/common/directshowpin.h index 6370fd367..160191ef3 100644 --- a/src/plugins/directshow/common/directshowpin.h +++ b/src/plugins/directshow/common/directshowpin.h @@ -96,13 +96,13 @@ public: protected: DirectShowPin(DirectShowBaseFilter *filter, const QString &name, PIN_DIRECTION direction); - QMutex m_mutex; + QRecursiveMutex m_mutex; DirectShowBaseFilter *m_filter; QString m_name; PIN_DIRECTION m_direction; - IPin *m_peerPin; + IPin *m_peerPin = nullptr; DirectShowMediaType m_mediaType; private: @@ -128,8 +128,8 @@ public: protected: DirectShowOutputPin(DirectShowBaseFilter *filter, const QString &name); - IMemAllocator *m_allocator; - IMemInputPin *m_inputPin; + IMemAllocator *m_allocator = nullptr; + IMemInputPin *m_inputPin = nullptr; private: Q_DISABLE_COPY(DirectShowOutputPin) @@ -166,9 +166,9 @@ public: protected: DirectShowInputPin(DirectShowBaseFilter *filter, const QString &name); - IMemAllocator *m_allocator; - bool m_flushing; - bool m_inErrorState; + IMemAllocator *m_allocator = nullptr; + bool m_flushing = false; + bool m_inErrorState = false; AM_SAMPLE2_PROPERTIES m_sampleProperties; private: diff --git a/src/plugins/directshow/common/directshowpinenum.cpp b/src/plugins/directshow/common/directshowpinenum.cpp index a340c0903..7ba1bb6e9 100644 --- a/src/plugins/directshow/common/directshowpinenum.cpp +++ b/src/plugins/directshow/common/directshowpinenum.cpp @@ -44,7 +44,6 @@ QT_BEGIN_NAMESPACE DirectShowPinEnum::DirectShowPinEnum(DirectShowBaseFilter *filter) : m_filter(filter) - , m_index(0) { m_filter->AddRef(); const QList<DirectShowPin *> pinList = filter->pins(); @@ -55,9 +54,7 @@ DirectShowPinEnum::DirectShowPinEnum(DirectShowBaseFilter *filter) } DirectShowPinEnum::DirectShowPinEnum(const QList<IPin *> &pins) - : m_filter(nullptr) - , m_pins(pins) - , m_index(0) + : m_pins(pins) { for (IPin *pin : qAsConst(m_pins)) pin->AddRef(); diff --git a/src/plugins/directshow/common/directshowpinenum.h b/src/plugins/directshow/common/directshowpinenum.h index d89f140b1..aada1a71e 100644 --- a/src/plugins/directshow/common/directshowpinenum.h +++ b/src/plugins/directshow/common/directshowpinenum.h @@ -68,9 +68,9 @@ public: private: Q_DISABLE_COPY(DirectShowPinEnum) - DirectShowBaseFilter *m_filter; + DirectShowBaseFilter *m_filter = nullptr; QList<IPin *> m_pins; - int m_index; + int m_index = 0; }; QT_END_NAMESPACE diff --git a/src/plugins/directshow/common/directshowsamplegrabber.cpp b/src/plugins/directshow/common/directshowsamplegrabber.cpp index 254066d4e..a9e74f9db 100644 --- a/src/plugins/directshow/common/directshowsamplegrabber.cpp +++ b/src/plugins/directshow/common/directshowsamplegrabber.cpp @@ -82,7 +82,8 @@ public: AddRef(); *ppvObject = static_cast<IUnknown *>(this); return S_OK; - } else if (riid == IID_ISampleGrabberCB /*__uuidof(ISampleGrabberCB)*/ ) { + } + if (riid == IID_ISampleGrabberCB /*__uuidof(ISampleGrabberCB)*/ ) { AddRef(); *ppvObject = static_cast<ISampleGrabberCB *>(this); return S_OK; @@ -115,9 +116,6 @@ private: DirectShowSampleGrabber::DirectShowSampleGrabber(QObject *p) : QObject(p) - , m_sampleGrabber(nullptr) - , m_sampleGabberCb(nullptr) - , m_callbackType(CallbackMethod::BufferCB) { // Create sample grabber filter HRESULT hr = CoCreateInstance(cLSID_SampleGrabber, nullptr, CLSCTX_INPROC, iID_ISampleGrabber, reinterpret_cast<void **>(&m_sampleGrabber)); diff --git a/src/plugins/directshow/common/directshowsamplegrabber.h b/src/plugins/directshow/common/directshowsamplegrabber.h index a9b72fcd1..5fc61de14 100644 --- a/src/plugins/directshow/common/directshowsamplegrabber.h +++ b/src/plugins/directshow/common/directshowsamplegrabber.h @@ -78,10 +78,10 @@ Q_SIGNALS: void bufferAvailable(double time, const QByteArray &data); private: - IBaseFilter *m_filter; - ISampleGrabber *m_sampleGrabber; - SampleGrabberCallbackPrivate *m_sampleGabberCb; - CallbackMethod m_callbackType; + IBaseFilter *m_filter = nullptr; + ISampleGrabber *m_sampleGrabber = nullptr; + SampleGrabberCallbackPrivate *m_sampleGabberCb = nullptr; + CallbackMethod m_callbackType= CallbackMethod::BufferCB; }; QT_END_NAMESPACE diff --git a/src/plugins/directshow/common/directshowutils.cpp b/src/plugins/directshow/common/directshowutils.cpp index 13b51deb5..1457837ce 100644 --- a/src/plugins/directshow/common/directshowutils.cpp +++ b/src/plugins/directshow/common/directshowutils.cpp @@ -300,7 +300,7 @@ bool DirectShowUtils::connectFilters(IGraphBuilder *graph, } IBaseFilter *nextFilter = nullptr; - while (S_OK == filters->Next(1, &nextFilter, 0)) { + while (S_OK == filters->Next(1, &nextFilter, nullptr)) { const ScopedSafeRelease<IBaseFilter> releaseNextFilter { &nextFilter }; if (nextFilter && findAndConnect(nextFilter)) return true; diff --git a/src/plugins/directshow/common/directshowvideobuffer.cpp b/src/plugins/directshow/common/directshowvideobuffer.cpp index 7f94da97e..fc329f58a 100644 --- a/src/plugins/directshow/common/directshowvideobuffer.cpp +++ b/src/plugins/directshow/common/directshowvideobuffer.cpp @@ -64,7 +64,7 @@ uchar *DirectShowVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine if (bytesPerLine) *bytesPerLine = m_bytesPerLine; - BYTE *bytes = 0; + BYTE *bytes = nullptr; if (m_sample->GetPointer(&bytes) == S_OK) { m_mapMode = mode; @@ -72,7 +72,7 @@ uchar *DirectShowVideoBuffer::map(MapMode mode, int *numBytes, int *bytesPerLine return reinterpret_cast<uchar *>(bytes); } } - return 0; + return nullptr; } void DirectShowVideoBuffer::unmap() |