summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVladimir Belyavsky <belyavskyv@gmail.com>2023-12-11 09:24:57 +0300
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-12-13 11:07:05 +0000
commit0f37d32162dc318809888412385af3555845d3b2 (patch)
treefdc6e54bc7c31dd8d5f8cc6b4bc90f8d23633bf0 /src
parent220baf91c989682368a0ffd399dadd9b5c6ddcc0 (diff)
EVRCustomPresenter: cleanup processOutput() method
- get rid goto statements - reorganize the code for better readability Pick-to: 6.6 6.5 Change-Id: Idb2be63f52adb8deacac55ee914049a7705446be Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Artem Dyomin <artem.dyomin@qt.io> (cherry picked from commit cf4ed8bff4db50214925fed4aec294fe86c8f99d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/multimedia/windows/evr/evrcustompresenter.cpp75
1 files changed, 32 insertions, 43 deletions
diff --git a/src/plugins/multimedia/windows/evr/evrcustompresenter.cpp b/src/plugins/multimedia/windows/evr/evrcustompresenter.cpp
index 6a7f8f566..a98ca703b 100644
--- a/src/plugins/multimedia/windows/evr/evrcustompresenter.cpp
+++ b/src/plugins/multimedia/windows/evr/evrcustompresenter.cpp
@@ -1461,17 +1461,8 @@ void EVRCustomPresenter::processOutputLoop()
HRESULT EVRCustomPresenter::processOutput()
{
- HRESULT hr = S_OK;
- DWORD status = 0;
- LONGLONG mixerStartTime = 0, mixerEndTime = 0;
- MFTIME systemTime = 0;
-
- MFT_OUTPUT_DATA_BUFFER dataBuffer;
- ZeroMemory(&dataBuffer, sizeof(dataBuffer));
-
// If the clock is not running, we present the first sample,
// and then don't present any more until the clock starts.
-
if ((m_renderState != RenderStarted) && m_prerolled)
return S_FALSE;
@@ -1487,17 +1478,21 @@ HRESULT EVRCustomPresenter::processOutput()
// From now on, we have a valid video sample pointer, where the mixer will
// write the video data.
+ LONGLONG mixerStartTime = 0, mixerEndTime = 0;
+ MFTIME systemTime = 0;
+
if (m_clock) {
// Latency: Record the starting time for ProcessOutput.
m_clock->GetCorrelatedTime(0, &mixerStartTime, &systemTime);
}
// Now we are ready to get an output sample from the mixer.
- dataBuffer.dwStreamID = 0;
+ DWORD status = 0;
+ MFT_OUTPUT_DATA_BUFFER dataBuffer = {};
dataBuffer.pSample = sample.Get();
- dataBuffer.dwStatus = 0;
-
- hr = m_mixer->ProcessOutput(0, 1, &dataBuffer, &status);
+ HRESULT hr = m_mixer->ProcessOutput(0, 1, &dataBuffer, &status);
+ // Important: Release any events returned from the ProcessOutput method.
+ qt_evr_safe_release(&dataBuffer.pEvents);
if (FAILED(hr)) {
// Return the sample to the pool.
@@ -1515,43 +1510,37 @@ HRESULT EVRCustomPresenter::processOutput()
// We have to wait for the mixer to get more input.
m_sampleNotify = false;
}
- } else {
- // We got an output sample from the mixer.
- if (m_clock) {
- // Latency: Record the ending time for the ProcessOutput operation,
- // and notify the EVR of the latency.
+ return hr;
+ }
- m_clock->GetCorrelatedTime(0, &mixerEndTime, &systemTime);
+ // We got an output sample from the mixer.
+ if (m_clock) {
+ // Latency: Record the ending time for the ProcessOutput operation,
+ // and notify the EVR of the latency.
- LONGLONG latencyTime = mixerEndTime - mixerStartTime;
- notifyEvent(EC_PROCESSING_LATENCY, reinterpret_cast<LONG_PTR>(&latencyTime), 0);
- }
+ m_clock->GetCorrelatedTime(0, &mixerEndTime, &systemTime);
- // Set up notification for when the sample is released.
- hr = trackSample(sample);
- if (FAILED(hr))
- goto done;
+ LONGLONG latencyTime = mixerEndTime - mixerStartTime;
+ notifyEvent(EC_PROCESSING_LATENCY, reinterpret_cast<LONG_PTR>(&latencyTime), 0);
+ }
- // Schedule the sample.
- if (m_frameStep.state == FrameStepNone) {
- hr = deliverSample(sample);
- if (FAILED(hr))
- goto done;
- } else {
- // We are frame-stepping
- hr = deliverFrameStepSample(sample);
- if (FAILED(hr))
- goto done;
- }
+ // Set up notification for when the sample is released.
+ hr = trackSample(sample);
+ if (FAILED(hr))
+ return hr;
- m_prerolled = true; // We have presented at least one sample now.
- }
+ // Schedule the sample.
+ if (m_frameStep.state == FrameStepNone)
+ hr = deliverSample(sample);
+ else // We are frame-stepping
+ hr = deliverFrameStepSample(sample);
-done:
- // Important: Release any events returned from the ProcessOutput method.
- qt_evr_safe_release(&dataBuffer.pEvents);
- return hr;
+ if (FAILED(hr))
+ return hr;
+
+ m_prerolled = true; // We have presented at least one sample now.
+ return S_OK;
}
HRESULT EVRCustomPresenter::deliverSample(const ComPtr<IMFSample> &sample)