From 7adae4f0078fd9364081c66aa84431bf4a2108f5 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Fri, 30 Apr 2010 11:13:23 +1000 Subject: Fix crash in direct show media service with mingw and a video surface. Mingw appears unable to resolve a valid pointer to the IMemInputPin interface from the DirectShowSampleScheduler class when it inherits from QWinEventNotifier. Inheriting from QObject does not have the same problem, so do that instead and connect to the activated signal of a separate instance of QWinEventNotifier. Task-number: 10221 Reviewed-by: Justin McPherson --- .../mediaplayer/directshowsamplescheduler.cpp | 23 ++++++---------------- .../mediaplayer/directshowsamplescheduler.h | 5 ++--- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.cpp b/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.cpp index 150860f..23675fb 100644 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.cpp +++ b/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.cpp @@ -118,7 +118,7 @@ bool DirectShowTimedSample::isReady(IReferenceClock *clock) const } DirectShowSampleScheduler::DirectShowSampleScheduler(IUnknown *pin, QObject *parent) - : QWinEventNotifier(parent) + : QObject(parent) , m_pin(pin) , m_clock(0) , m_allocator(0) @@ -131,13 +131,15 @@ DirectShowSampleScheduler::DirectShowSampleScheduler(IUnknown *pin, QObject *par { m_semaphore.release(m_maximumSamples); - setHandle(m_timeoutEvent); - setEnabled(true); + m_eventNotifier.setHandle(m_timeoutEvent); + m_eventNotifier.setEnabled(true); + + connect(&m_eventNotifier, SIGNAL(activated(HANDLE)), this, SIGNAL(sampleReady())); } DirectShowSampleScheduler::~DirectShowSampleScheduler() { - setEnabled(false); + m_eventNotifier.setEnabled(false); ::CloseHandle(m_timeoutEvent); @@ -398,17 +400,4 @@ bool DirectShowSampleScheduler::scheduleEndOfStream() } } -bool DirectShowSampleScheduler::event(QEvent *event) -{ - if (event->type() == QEvent::WinEventAct) { - QObject::event(event); - - emit sampleReady(); - - return true; - } else { - return QWinEventNotifier::event(event); - } -} - QT_END_NAMESPACE diff --git a/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.h b/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.h index 007fa99..21823c3 100644 --- a/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.h +++ b/src/plugins/mediaservices/directshow/mediaplayer/directshowsamplescheduler.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE class DirectShowTimedSample; -class DirectShowSampleScheduler : public QWinEventNotifier, public IMemInputPin +class DirectShowSampleScheduler : public QObject, public IMemInputPin { Q_OBJECT public: @@ -101,8 +101,6 @@ public: IMediaSample *takeSample(bool *eos); - bool event(QEvent *event); - Q_SIGNALS: void sampleReady(); @@ -118,6 +116,7 @@ private: HANDLE m_timeoutEvent; QSemaphore m_semaphore; QMutex m_mutex; + QWinEventNotifier m_eventNotifier; }; QT_END_NAMESPACE -- cgit v0.12