Trace desktop stream stalls across playback and preview UI
This commit is contained in:
1 parent
b1112981fa
commit
7ce60ca0f2
3 files changed
+100
-23
No files matched your search
@@ -146,6 +146,8 @@ struct StreamPublishEngine::Impl {
|
||||
QVideoFrame previewFrame;
|
||||
QVideoFrame presentedPreview;
|
||||
int64_t lastImageCaptureAt = 0;
|
||||
int64_t previewTickAt = 0, previewReportAt = 0, previewGapMax = 0, previewDispatchMax = 0;
|
||||
unsigned previewUpdates = 0; // Диагностика GUI-предпросмотра; только GUI-поток.
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -164,12 +166,29 @@ StreamPublishEngine::StreamPublishEngine(QObject* parent) : QObject(parent), m(s
|
||||
connect(qGuiApp, &QGuiApplication::screenRemoved, this, &StreamPublishEngine::sourcesChanged);
|
||||
m_previewTimer.setTimerType(Qt::PreciseTimer); m_previewTimer.setInterval(33);
|
||||
connect(&m_previewTimer, &QTimer::timeout, this, [this] {
|
||||
if (!m->running) return;
|
||||
if (!m->running) {
|
||||
m->previewTickAt = m->previewReportAt = m->previewGapMax = m->previewDispatchMax = 0;
|
||||
m->previewUpdates = 0; return;
|
||||
}
|
||||
int64_t tickAt = monotonicUs();
|
||||
if (m->previewTickAt) m->previewGapMax = std::max(m->previewGapMax, tickAt - m->previewTickAt);
|
||||
m->previewTickAt = tickAt;
|
||||
if (!m->previewReportAt) m->previewReportAt = tickAt;
|
||||
QVideoFrame frame;
|
||||
{ std::lock_guard<std::mutex> guard(m->lock);
|
||||
if (m->previewFrame == m->presentedPreview) return;
|
||||
frame = m->presentedPreview = m->previewFrame; }
|
||||
if (frame.isValid()) emit previewVideoChanged(QVariant::fromValue(frame));
|
||||
if (m->previewFrame != m->presentedPreview) frame = m->presentedPreview = m->previewFrame; }
|
||||
if (frame.isValid()) {
|
||||
int64_t dispatchAt = monotonicUs();
|
||||
emit previewVideoChanged(QVariant::fromValue(frame));
|
||||
m->previewDispatchMax = std::max(m->previewDispatchMax, monotonicUs() - dispatchAt); m->previewUpdates++;
|
||||
}
|
||||
if (tickAt - m->previewReportAt >= 1000000) {
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG,
|
||||
"desktop preview GUI id=%llu source_generation=%llu interval_us=%lld updates=%u tick_gap_max_us=%lld dispatch_max_us=%lld",
|
||||
(unsigned long long)m->id, (unsigned long long)m->sourceGeneration, (long long)(tickAt - m->previewReportAt),
|
||||
m->previewUpdates, (long long)m->previewGapMax, (long long)m->previewDispatchMax);
|
||||
m->previewReportAt = tickAt; m->previewUpdates = 0; m->previewGapMax = m->previewDispatchMax = 0;
|
||||
}
|
||||
});
|
||||
m_previewTimer.start();
|
||||
#endif
|
||||
|
||||
Reference in new issue
Block a user