From 59629bef84af3fd817de1b3724189f45bacc5aea Mon Sep 17 00:00:00 2001 From: Yoann Lopes Date: Mon, 1 Feb 2016 17:29:43 +0100 Subject: Windows EVR: fix EndOfStream event never being sent. This was causing QMediaPlayer to never go into the EndOfMedia state. Task-number: QTBUG-50814 Change-Id: I8920cf93db37a834f67b9e0b4abcf5a4934dfe0e Reviewed-by: Christian Stromme --- src/plugins/common/evr/evrcustompresenter.cpp | 28 +++++++-------------------- 1 file changed, 7 insertions(+), 21 deletions(-) (limited to 'src/plugins/common/evr/evrcustompresenter.cpp') diff --git a/src/plugins/common/evr/evrcustompresenter.cpp b/src/plugins/common/evr/evrcustompresenter.cpp index 73d032aa6..3afd2342f 100644 --- a/src/plugins/common/evr/evrcustompresenter.cpp +++ b/src/plugins/common/evr/evrcustompresenter.cpp @@ -248,6 +248,12 @@ HRESULT Scheduler::flush() return S_OK; } +bool Scheduler::areSamplesScheduled() +{ + QMutexLocker locker(&m_mutex); + return m_scheduledSamples.count() > 0; +} + HRESULT Scheduler::scheduleSample(IMFSample *sample, bool presentNow) { if (!m_schedulerThread) @@ -441,7 +447,6 @@ DWORD Scheduler::schedulerThreadProcPrivate() SamplePool::SamplePool() : m_initialized(false) - , m_pending(0) { } @@ -468,8 +473,6 @@ HRESULT SamplePool::getSample(IMFSample **sample) IMFSample *taken = m_videoSampleQueue.takeFirst(); - m_pending++; - // Give the sample to the caller. *sample = taken; (*sample)->AddRef(); @@ -489,25 +492,9 @@ HRESULT SamplePool::returnSample(IMFSample *sample) m_videoSampleQueue.append(sample); sample->AddRef(); - m_pending--; - return S_OK; } -BOOL SamplePool::areSamplesPending() -{ - QMutexLocker locker(&m_mutex); - - bool ret = false; - - if (!m_initialized) - ret = false; - else - ret = (m_pending > 0); - - return ret; -} - HRESULT SamplePool::initialize(QList &samples) { QMutexLocker locker(&m_mutex); @@ -540,7 +527,6 @@ HRESULT SamplePool::clear() m_videoSampleQueue[i]->Release(); m_videoSampleQueue.clear(); m_initialized = false; - m_pending = 0; return S_OK; } @@ -1214,7 +1200,7 @@ HRESULT EVRCustomPresenter::checkEndOfStream() return S_OK; } - if (m_samplePool.areSamplesPending()) { + if (m_scheduler.areSamplesScheduled()) { // Samples are still scheduled for rendering. return S_OK; } -- cgit v1.2.3