Separate public runtime data from debug diagnostics
Compared with 90af75c:
- keep only application-facing capture FPS and delivered-frame count in gvfg_runtime_info_t
- move GigabyteLib frame-acquire timing exclusively to the internal debug statistics
- remove duplicated runtime, zero-copy, and last-frame fields from the debug structure
- remove synthetic backend DMA, interrupt, sequence, and capture counters not supplied by GigabyteLib
- retain uniquely useful wait, event, audio, frame-hold, and timing diagnostics plus register access
- update the Qt sample and documentation for the clarified ownership boundary
This commit is contained in:
@@ -37,13 +37,11 @@ namespace
|
||||
|
||||
#if GVFG_INTERNAL_DIAGNOSTICS
|
||||
QString boolText(int value) { return value ? QStringLiteral("yes") : QStringLiteral("no"); }
|
||||
QString valueOrDash(uint64_t value) { return QString::number(static_cast<qulonglong>(value)); }
|
||||
|
||||
QString captureStatusText(const gvfg_debug_backend_stats_t &stats, bool signalConnected)
|
||||
{
|
||||
if (!stats.backend_running) return QStringLiteral("stopped");
|
||||
if (!stats.running) return QStringLiteral("stopped");
|
||||
if (!signalConnected) return QStringLiteral("waiting_signal");
|
||||
if (!stats.backend_capture_active) return QStringLiteral("paused");
|
||||
return QStringLiteral("streaming");
|
||||
}
|
||||
#endif
|
||||
@@ -429,10 +427,6 @@ void CaptureController::startCapture(int channelIndex)
|
||||
channel.audioFailedBytes = channel.audioIdGaps = channel.audioIdResets = 0;
|
||||
channel.audioLastId = 0;
|
||||
}
|
||||
#if GVFG_INTERNAL_DIAGNOSTICS
|
||||
channel.haveDebugBaseline = false;
|
||||
channel.lastDebugDmaErrors = 0;
|
||||
#endif
|
||||
channel.signalConnected.store(channel.cachedSignalStatus.connected != 0,
|
||||
std::memory_order_release);
|
||||
channel.stopRequested.store(false, std::memory_order_release);
|
||||
@@ -570,9 +564,6 @@ void CaptureController::updateSignalStatus(bool queryHardware)
|
||||
return;
|
||||
|
||||
QStringList statusLines;
|
||||
#if GVFG_INTERNAL_DIAGNOSTICS
|
||||
bool diagnosticProblemDetected = false;
|
||||
#endif
|
||||
for (int channelIndex = GVFG_CHANNEL_0; channelIndex <= GVFG_CHANNEL_1; ++channelIndex)
|
||||
{
|
||||
if (!channelStatusVisible_[channelIndex])
|
||||
@@ -685,41 +676,26 @@ void CaptureController::updateSignalStatus(bool queryHardware)
|
||||
.arg(static_cast<qulonglong>(readSamples))
|
||||
: QStringLiteral("CH%1 Read | measuring").arg(channelIndex));
|
||||
|
||||
gvfg_runtime_info_t runtimeInfo{};
|
||||
if (gvfg_get_channel_runtime_info(handle_, channelIndex, &runtimeInfo) == GVFG_OK)
|
||||
{
|
||||
statusLines << (runtimeInfo.driver_read_samples >= 300
|
||||
? QStringLiteral("CH%1 %2 | avg=%3 max300=%4 max=%5 us samples=%6")
|
||||
.arg(channelIndex)
|
||||
.arg(runtimeInfo.zero_copy_enabled
|
||||
? QStringLiteral("ZeroCopy Acquire")
|
||||
: QStringLiteral("Copy GetFrame"))
|
||||
.arg(runtimeInfo.driver_read_average_us, 0, 'f', 3)
|
||||
.arg(runtimeInfo.driver_read_max300_us, 0, 'f', 3)
|
||||
.arg(runtimeInfo.driver_read_max_us, 0, 'f', 3)
|
||||
.arg(static_cast<qulonglong>(runtimeInfo.driver_read_samples))
|
||||
: QStringLiteral("CH%1 Driver GetFrame | measuring").arg(channelIndex));
|
||||
}
|
||||
|
||||
#if GVFG_INTERNAL_DIAGNOSTICS
|
||||
gvfg_debug_backend_stats_t channelStats{};
|
||||
if (gvfg_debug_get_channel_backend_stats(handle_, channelIndex, &channelStats) == GVFG_OK)
|
||||
{
|
||||
statusLines << QStringLiteral("CH%1 Capture | status=%2 dma_errors=%3 no_frame_waits=%4")
|
||||
statusLines << (channelStats.get_frame_timing_samples >= 300
|
||||
? QStringLiteral("CH%1 %2 | avg=%3 max300=%4 max=%5 us samples=%6")
|
||||
.arg(channelIndex)
|
||||
.arg(channel.zeroCopy
|
||||
? QStringLiteral("ZeroCopy Acquire")
|
||||
: QStringLiteral("Copy GetFrame"))
|
||||
.arg(channelStats.get_frame_timing_average_us, 0, 'f', 3)
|
||||
.arg(channelStats.get_frame_timing_max300_us, 0, 'f', 3)
|
||||
.arg(channelStats.get_frame_timing_max_us, 0, 'f', 3)
|
||||
.arg(static_cast<qulonglong>(channelStats.get_frame_timing_samples))
|
||||
: QStringLiteral("CH%1 Driver GetFrame | measuring").arg(channelIndex));
|
||||
statusLines << QStringLiteral("CH%1 Capture | status=%2 no_frame_waits=%3 video_wakes=%4")
|
||||
.arg(channelIndex)
|
||||
.arg(captureStatusText(channelStats, signal.connected != 0))
|
||||
.arg(static_cast<qulonglong>(channelStats.backend_dma_errors))
|
||||
.arg(static_cast<qulonglong>(channelStats.backend_wait_timeouts));
|
||||
if (channel.haveDebugBaseline && channelStats.backend_dma_errors > channel.lastDebugDmaErrors)
|
||||
{
|
||||
appendLog(QStringLiteral("CH%1 ERROR DMA failures +%2, total=%3")
|
||||
.arg(channelIndex)
|
||||
.arg(valueOrDash(channelStats.backend_dma_errors - channel.lastDebugDmaErrors),
|
||||
valueOrDash(channelStats.backend_dma_errors)));
|
||||
diagnosticProblemDetected = true;
|
||||
}
|
||||
channel.lastDebugDmaErrors = channelStats.backend_dma_errors;
|
||||
channel.haveDebugBaseline = true;
|
||||
.arg(static_cast<qulonglong>(channelStats.frame_wait_timeouts))
|
||||
.arg(static_cast<qulonglong>(channelStats.video_event_wakes));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -733,10 +709,6 @@ void CaptureController::updateSignalStatus(bool queryHardware)
|
||||
}
|
||||
emit stateChanged();
|
||||
|
||||
#if GVFG_INTERNAL_DIAGNOSTICS
|
||||
if (diagnosticProblemDetected)
|
||||
writeDiagnosticSnapshot(statusText);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CaptureController::reportError(const QString &apiName, gvfg_status_t status, int channel)
|
||||
|
||||
@@ -100,10 +100,6 @@ private:
|
||||
gvfg_signal_status_t cachedSignalStatus{};
|
||||
bool haveCachedSignalStatus = false;
|
||||
QString lastLoggedInputStatus;
|
||||
#if GVFG_INTERNAL_DIAGNOSTICS
|
||||
uint64_t lastDebugDmaErrors = 0;
|
||||
bool haveDebugBaseline = false;
|
||||
#endif
|
||||
};
|
||||
|
||||
void reportError(const QString &apiName, gvfg_status_t status, int channel = -1);
|
||||
|
||||
@@ -150,12 +150,6 @@ extern "C"
|
||||
{
|
||||
double capture_fps; /* Runtime FPS measured from frames returned by gvfg_read_channel_frame(). */
|
||||
uint64_t delivered_frames; /* Number of frames returned by gvfg_read_channel_frame(). */
|
||||
int zero_copy_enabled; /* Non-zero when driver zero-copy delivery is selected. */
|
||||
uint32_t reserved;
|
||||
uint64_t driver_read_samples;
|
||||
double driver_read_average_us;
|
||||
double driver_read_max300_us;
|
||||
double driver_read_max_us;
|
||||
} gvfg_runtime_info_t;
|
||||
|
||||
typedef struct
|
||||
|
||||
@@ -17,40 +17,15 @@ extern "C" {
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int width; /* Width of the most recent frame returned by gvfg_read_channel_frame(). */
|
||||
int height; /* Height of the most recent frame returned by gvfg_read_channel_frame(). */
|
||||
int bit_depth; /* Bits per color channel of the frame buffer. */
|
||||
int pixel_format; /* gvfg_pixel_format_t value: YUY2 or Y210. */
|
||||
int valid; /* Non-zero after a frame is returned during the current running session. */
|
||||
} gvfg_debug_last_frame_info_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int sdk_running;
|
||||
int running;
|
||||
int frame_held;
|
||||
uint32_t event_queue_depth;
|
||||
|
||||
double runtime_fps;
|
||||
uint64_t frames_returned;
|
||||
gvfg_debug_last_frame_info_t last_frame;
|
||||
|
||||
int backend_state;
|
||||
uint64_t backend_frames_captured;
|
||||
uint64_t backend_frames_delivered;
|
||||
uint64_t backend_dma_errors;
|
||||
uint64_t backend_interrupt_count;
|
||||
uint64_t backend_wait_timeouts;
|
||||
|
||||
int backend_running;
|
||||
int backend_capture_active;
|
||||
uint64_t backend_latest_sequence;
|
||||
uint64_t backend_delivered_sequence;
|
||||
uint64_t frame_wait_timeouts;
|
||||
uint64_t video_event_wakes;
|
||||
uint64_t audio_dma_event_wakes;
|
||||
uint64_t extra_audio_event_wakes;
|
||||
uint64_t audio_frames_from_driver;
|
||||
uint64_t audio_bytes_from_driver;
|
||||
|
||||
int get_frame_zero_copy;
|
||||
uint64_t get_frame_timing_samples;
|
||||
double get_frame_timing_average_us;
|
||||
double get_frame_timing_max300_us;
|
||||
|
||||
@@ -596,20 +596,12 @@ void GigabyteCaptureSession::emit_event(gvfg_event_type_t type) const
|
||||
void GigabyteCaptureSession::fill_debug_stats(gvfg_debug_backend_stats_t &out) const
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(state_mutex_);
|
||||
out.backend_state = running_ ? 2 : configured_ ? 1 : 0;
|
||||
out.backend_frames_captured = video_event_wakes_;
|
||||
out.backend_frames_delivered = frame_id_;
|
||||
out.backend_interrupt_count = video_event_wakes_;
|
||||
out.backend_wait_timeouts = wait_timeout_count_;
|
||||
out.backend_running = running_ ? 1 : 0;
|
||||
out.backend_capture_active = running_ ? 1 : 0;
|
||||
out.backend_latest_sequence = video_event_wakes_;
|
||||
out.backend_delivered_sequence = frame_id_;
|
||||
out.frame_wait_timeouts = wait_timeout_count_;
|
||||
out.video_event_wakes = video_event_wakes_;
|
||||
out.audio_dma_event_wakes = audio_event_wakes_;
|
||||
out.extra_audio_event_wakes = extra_audio_event_wakes_;
|
||||
out.audio_frames_from_driver = audio_frames_from_driver_;
|
||||
out.audio_bytes_from_driver = audio_bytes_from_driver_;
|
||||
out.get_frame_zero_copy = zero_copy_enabled_ ? 1 : 0;
|
||||
out.get_frame_timing_samples = get_frame_timing_samples_;
|
||||
out.get_frame_timing_average_us = get_frame_timing_samples_
|
||||
? get_frame_timing_total_us_ / static_cast<double>(get_frame_timing_samples_) : 0.0;
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace
|
||||
static_assert(offsetof(gvfg_audio_frame_t, sample_rate) == 16);
|
||||
static_assert(offsetof(gvfg_audio_frame_t, frame_id) == 32);
|
||||
static_assert(offsetof(gvfg_audio_frame_t, timestamp_ns) == 40);
|
||||
static_assert(sizeof(gvfg_runtime_info_t) == 56, "gvfg_runtime_info_t x64 ABI must remain frozen");
|
||||
static_assert(sizeof(gvfg_runtime_info_t) == 16, "gvfg_runtime_info_t x64 ABI must remain frozen");
|
||||
static_assert(std::is_standard_layout_v<gvfg_frame_t>);
|
||||
static_assert(sizeof(gvfg_frame_t) == 56, "gvfg_frame_t x64 ABI must remain frozen");
|
||||
static_assert(offsetof(gvfg_frame_t, data) == 0);
|
||||
@@ -270,13 +270,6 @@ struct gvfg_channel_session_t
|
||||
std::memset(&out, 0, sizeof(out));
|
||||
out.capture_fps = runtimeFps.load(std::memory_order_relaxed);
|
||||
out.delivered_frames = deliveredFrames.load(std::memory_order_relaxed);
|
||||
gvfg_debug_backend_stats_t stats{};
|
||||
session->fill_debug_stats(stats);
|
||||
out.zero_copy_enabled = stats.get_frame_zero_copy;
|
||||
out.driver_read_samples = stats.get_frame_timing_samples;
|
||||
out.driver_read_average_us = stats.get_frame_timing_average_us;
|
||||
out.driver_read_max300_us = stats.get_frame_timing_max300_us;
|
||||
out.driver_read_max_us = stats.get_frame_timing_max_us;
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
@@ -537,17 +530,7 @@ struct gvfg_channel_session_t
|
||||
gvfg_status_t getDebugStats(gvfg_debug_backend_stats_t &out)
|
||||
{
|
||||
std::memset(&out, 0, sizeof(out));
|
||||
out.sdk_running = running.load(std::memory_order_relaxed) ? 1 : 0;
|
||||
out.runtime_fps = runtimeFps.load(std::memory_order_relaxed);
|
||||
out.frames_returned = deliveredFrames.load(std::memory_order_relaxed);
|
||||
out.last_frame.valid = out.sdk_running && out.frames_returned > 0 ? 1 : 0;
|
||||
if (out.last_frame.valid)
|
||||
{
|
||||
out.last_frame.width = static_cast<int>(deliveredWidth.load(std::memory_order_relaxed));
|
||||
out.last_frame.height = static_cast<int>(deliveredHeight.load(std::memory_order_relaxed));
|
||||
out.last_frame.bit_depth = static_cast<int>(deliveredBitDepth.load(std::memory_order_relaxed));
|
||||
out.last_frame.pixel_format = deliveredPixelFormat.load(std::memory_order_relaxed);
|
||||
}
|
||||
out.running = running.load(std::memory_order_relaxed) ? 1 : 0;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(frameMutex);
|
||||
|
||||
@@ -77,11 +77,9 @@ register 與 DMA 實作不屬於本文件。
|
||||
| ------------------ | ---------- | ------------------------------------------------------- |
|
||||
| `capture_fps` | `double` | 依 `gvfg_read_channel_frame()` 成功交付時間估算並平滑化的 FPS;尚無足夠 frame 時為 0 |
|
||||
| `delivered_frames` | `uint64_t` | 此次 running session 中成功交付給 caller 的 frame 數 |
|
||||
| `zero_copy_enabled` | `int` | 非零表示目前使用 driver zero-copy frame delivery |
|
||||
| `driver_read_samples` | `uint64_t` | 排除前 30 張 warmup 後的 driver read/acquire timing 樣本數 |
|
||||
| `driver_read_average_us` | `double` | `GET_FRAME` 或 zero-copy acquire 平均時間,單位為微秒 |
|
||||
| `driver_read_max300_us` | `double` | 最近完成的 300-sample window 最大值,單位為微秒 |
|
||||
| `driver_read_max_us` | `double` | 本次 capture lifetime 最大值,單位為微秒 |
|
||||
|
||||
Zero-copy 模式另由 `gvfg_get_channel_zero_copy_enabled()` 查詢;driver read/acquire
|
||||
timing 屬於內部診斷資訊,不放入客戶 runtime 結構。
|
||||
|
||||
### 1.8 `gvfg_frame_t`
|
||||
|
||||
|
||||
@@ -146,9 +146,8 @@ Backend event 映射:
|
||||
| `GIGABYTE_EVENT_STREAM_READY` | `GVFG_EVENT_STREAM_READY` |
|
||||
| `GIGABYTE_EVENT_FORMAT_CHANGE_BEGIN` | `GVFG_EVENT_FORMAT_CHANGE_BEGIN` |
|
||||
|
||||
每個 channel 的 public event mask 在 open 前設定。Video DMA event 永遠註冊;
|
||||
format-change、plug-in、unplug driver event 依 mask 選擇性註冊。關閉 driver event
|
||||
同時代表 backend 不執行該事件所驅動的自動 recovery。
|
||||
依 GigabyteLib 行為,video、format-change、plug-in 與 unplug events 在 open channel
|
||||
時固定註冊;使用者只選擇是否啟用 audio,SDK 不再提供重複的 event mask 層。
|
||||
|
||||
Facade queue 上限為 64;滿時丟棄最舊事件。`pollEvent()` 只允許 running 狀態,支援
|
||||
non-blocking、有限 timeout 與 infinite wait;stop 透過 `eventCv` 喚醒 waiter。
|
||||
@@ -161,8 +160,13 @@ non-blocking、有限 timeout 與 infinite wait;stop 透過 `eventCv` 喚醒 w
|
||||
|
||||
`gvfg_debug.h` 僅供內部工具,包含:
|
||||
|
||||
- `gvfg_debug_get_channel_backend_stats()`:指定 channel 的 facade/backend state、
|
||||
captured/delivered frame、DMA error、IRQ、timeout、sequence 與 GetFrame timing。
|
||||
- `gvfg_debug_get_channel_backend_stats()`:指定 channel 的 running/frame-held 狀態、
|
||||
event queue depth、frame wait timeout、video/audio event wake、audio 讀取量與
|
||||
GigabyteLib GetFrame/acquire timing。
|
||||
|
||||
公開的 `gvfg_runtime_info_t` 只保留 application-facing capture FPS 與 delivered frame
|
||||
數;zero-copy 用公開 getter 查詢。Debug 結構不重複這些公開資訊,也不偽造
|
||||
GigabyteLib 未提供的 DMA error、IRQ 或 driver sequence counter。
|
||||
|
||||
客戶診斷使用 `gvfg_get_channel_signal_status()`、`gvfg_get_channel_runtime_info()`、event、
|
||||
`gvfg_strerror()` 與 `gvfg_get_channel_last_error_detail()`。每個 channel 的 `ChannelErrorState`
|
||||
|
||||
Reference in New Issue
Block a user