summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJøger Hansegård <joger.hansegard@qt.io>2023-10-30 22:06:45 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-11-01 09:43:22 +0000
commit943204d2ce411c1c7762bb196d8df5c8c292c101 (patch)
tree31b5be498bdc0408d693c4dc538a8508d92e49d0
parent5c90b355ddcf61220f8e578da150015e18b4f73a (diff)
Simplify lifetime handling of IMFSample instances for frame stepping
In this change we replace a queue of IMFSample interface pointers with a queue of smart pointers in the FrameStep struct. This way, we turn the queue into an owning queue, and reduce the need for manually calling AddRef and Release on the contained COM interfaces. Pick-to: 6.5 Change-Id: I3f284b9fb636b6284342f9ccce6d7927bab94ba8 Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> Reviewed-by: Pavel Dubsky <pavel.dubsky@qt.io> (cherry picked from commit fde9561d9a73306fe70e1679e3ceee847ba452da) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/multimedia/windows/evr/evrcustompresenter.cpp29
-rw-r--r--src/plugins/multimedia/windows/evr/evrcustompresenter_p.h2
2 files changed, 8 insertions, 23 deletions
diff --git a/src/plugins/multimedia/windows/evr/evrcustompresenter.cpp b/src/plugins/multimedia/windows/evr/evrcustompresenter.cpp
index fe3cb6bf6..5607be9e3 100644
--- a/src/plugins/multimedia/windows/evr/evrcustompresenter.cpp
+++ b/src/plugins/multimedia/windows/evr/evrcustompresenter.cpp
@@ -896,8 +896,6 @@ HRESULT EVRCustomPresenter::OnClockSetRate(MFTIME, float rate)
// frame-step operation.
if ((m_playbackRate == 0.0f) && (rate != 0.0f)) {
cancelFrameStep();
- for (auto sample : std::as_const(m_frameStep.samples))
- sample->Release();
m_frameStep.samples.clear();
}
@@ -1100,8 +1098,6 @@ HRESULT EVRCustomPresenter::flush()
m_scheduler.flush();
// Flush the frame-step queue.
- for (auto sample : std::as_const(m_frameStep.samples))
- sample->Release();
m_frameStep.samples.clear();
if (m_renderState == RenderStopped && m_videoSink) {
@@ -1194,9 +1190,6 @@ HRESULT EVRCustomPresenter::prepareFrameStep(DWORD steps)
HRESULT EVRCustomPresenter::startFrameStep()
{
- HRESULT hr = S_OK;
- IMFSample *sample = NULL;
-
if (m_frameStep.state == FrameStepWaitingStart) {
// We have a frame-step request, and are waiting for the clock to start.
// Set the state to "pending," which means we are waiting for samples.
@@ -1204,13 +1197,11 @@ HRESULT EVRCustomPresenter::startFrameStep()
// If the frame-step queue already has samples, process them now.
while (!m_frameStep.samples.isEmpty() && (m_frameStep.state == FrameStepPending)) {
- sample = m_frameStep.samples.takeFirst();
+ const ComPtr<IMFSample> sample = m_frameStep.samples.takeFirst();
- hr = deliverFrameStepSample(sample);
+ const HRESULT hr = deliverFrameStepSample(sample.Get());
if (FAILED(hr))
- goto done;
-
- qt_evr_safe_release(&sample);
+ return hr;
// We break from this loop when:
// (a) the frame-step queue is empty, or
@@ -1220,19 +1211,15 @@ HRESULT EVRCustomPresenter::startFrameStep()
// We are not frame stepping. Therefore, if the frame-step queue has samples,
// we need to process them normally.
while (!m_frameStep.samples.isEmpty()) {
- sample = m_frameStep.samples.takeFirst();
+ const ComPtr<IMFSample> sample = m_frameStep.samples.takeFirst();
- hr = deliverSample(sample, false);
+ const HRESULT hr = deliverSample(sample.Get(), false);
if (FAILED(hr))
- goto done;
-
- qt_evr_safe_release(&sample);
+ return hr;
}
}
-done:
- qt_evr_safe_release(&sample);
- return hr;
+ return S_OK;
}
HRESULT EVRCustomPresenter::completeFrameStep(IMFSample *sample)
@@ -1678,7 +1665,6 @@ HRESULT EVRCustomPresenter::deliverFrameStepSample(IMFSample *sample)
// A frame was already submitted. Put this sample on the frame-step queue,
// in case we are asked to step to the next frame. If frame-stepping is
// cancelled, this sample will be processed normally.
- sample->AddRef();
m_frameStep.samples.append(sample);
} else {
// We're ready to frame-step.
@@ -1693,7 +1679,6 @@ HRESULT EVRCustomPresenter::deliverFrameStepSample(IMFSample *sample)
// This is the right frame, but the clock hasn't started yet. Put the
// sample on the frame-step queue. When the clock starts, the sample
// will be processed.
- sample->AddRef();
m_frameStep.samples.append(sample);
} else {
// This is the right frame *and* the clock has started. Deliver this sample.
diff --git a/src/plugins/multimedia/windows/evr/evrcustompresenter_p.h b/src/plugins/multimedia/windows/evr/evrcustompresenter_p.h
index 5d49c1db9..17a6e386e 100644
--- a/src/plugins/multimedia/windows/evr/evrcustompresenter_p.h
+++ b/src/plugins/multimedia/windows/evr/evrcustompresenter_p.h
@@ -315,7 +315,7 @@ private:
struct FrameStep
{
FrameStepState state = FrameStepNone;
- QList<IMFSample*> samples;
+ QList<ComPtr<IMFSample>> samples;
DWORD steps = 0;
DWORD_PTR sampleNoRef = 0;
};