Unify playback and harden preview/audio recovery for SDK 2.1.1

- expose one gvfg_playback DLL backed by static audio and preview libraries, retain public backend data types, and remove obsolete standalone backend exports and unused wrappers

- centralize playback clocks, timestamp scheduling, optional synchronization, audio rate correction, bounded queues and fallback while preserving legacy statistics buffer sizes

- provide still-image presentation and a helper-owned NO SIGNAL card with explicit SDK connection state, native window ownership and UI-thread checks

- report monitoring failures through EAUDIO without stopping video, retain the failed output state across timeline resets, and reject audio-only startup when output is unavailable

- make clearing an unconfigured preview a successful no-op so resetting before the first frame cannot leave playback stopped

- trace actual format-change events before event resets in Debug builds and refresh video metadata after plugin stream recovery while retaining the existing temporary HDMI lock bypass

- update SDK 2.1.1 public documentation, the playback guide and rendered API reference to describe the unified lifecycle, error handling and delivery boundaries

Validation: Full SDK Release build and git diff --cached --check passed. Native tests passed for video/reset lifecycle with synchronization enabled and disabled, signal-card lifecycle, bounded queue pressure and legacy statistics guards. Process-local WASAPI failure injection verified continued video, persistent monitoring failure and audio-only rejection; real WASAPI silence playback advanced the output clock in both synchronization modes. Public exports and rendered PDF pages/portable links were checked. No hardware capture, unplug/replug or long-running acoustic A/V synchronization test was performed.
This commit is contained in:
Mark.lin
2026-10-22 14:02:43 +08:00
parent da2ad24459
commit bfa9397f6b
36 changed files with 2389 additions and 2089 deletions
@@ -232,6 +232,10 @@ namespace gvfg::internal
if (!events_.hVideoFormatChangedEvent)
return reject(GVFG_EIO, "Capture backend did not provide a video-format event");
#ifndef NDEBUG
if (WaitForSingleObject(events_.hVideoFormatChangedEvent, 0) == WAIT_OBJECT_0)
OutputDebugStringA("[GVFG] Received VIDEO_FORMAT_CHANGED (before format reset)\n");
#endif
if (!ResetEvent(events_.hVideoFormatChangedEvent))
return reject(GVFG_EIO, "Capture video-format event reset failed");
@@ -303,6 +307,10 @@ namespace gvfg::internal
return reject(GVFG_EIO, "Capture backend did not provide a video-format event");
const DWORD wait = WaitForSingleObject(events_.hVideoFormatChangedEvent,
kVideoFormatChangeTimeoutMs);
#ifndef NDEBUG
if (wait == WAIT_OBJECT_0)
OutputDebugStringA("[GVFG] Received VIDEO_FORMAT_CHANGED\n");
#endif
if (wait != WAIT_OBJECT_0 && wait != WAIT_TIMEOUT)
return reject(GVFG_EIO, "Capture video-format event wait failed");
@@ -441,6 +449,11 @@ namespace gvfg::internal
const gvfg_status_t openStatus = ensure_vendor_channel_open();
if (openStatus != GVFG_OK)
return openStatus;
#ifndef NDEBUG
if (events_.hVideoFormatChangedEvent &&
WaitForSingleObject(events_.hVideoFormatChangedEvent, 0) == WAIT_OBJECT_0)
OutputDebugStringA("[GVFG] Received VIDEO_FORMAT_CHANGED (before start reset)\n");
#endif
const gvfg_status_t resetStatus = from_vendor(GvfgResetEvents(&events_), "GvfgResetEvents");
if (resetStatus != GVFG_OK)
return resetStatus;
@@ -502,6 +515,11 @@ namespace gvfg::internal
result = stopStatus;
if (stopStatus == GVFG_OK)
{
#ifndef NDEBUG
if (events_.hVideoFormatChangedEvent &&
WaitForSingleObject(events_.hVideoFormatChangedEvent, 0) == WAIT_OBJECT_0)
OutputDebugStringA("[GVFG] Received VIDEO_FORMAT_CHANGED (before stop reset)\n");
#endif
const gvfg_status_t resetStatus = from_vendor(GvfgResetEvents(&events_),
"GvfgResetEvents");
if (result == GVFG_OK)
@@ -760,6 +778,9 @@ namespace gvfg::internal
return;
if (kind == 1)
{
#ifndef NDEBUG
OutputDebugStringA("[GVFG] Received VIDEO_FORMAT_CHANGED\n");
#endif
refresh_video_info();
emit_event(GVFG_EVENT_VIDEO_FORMAT_CHANGED);
}
@@ -772,6 +793,9 @@ namespace gvfg::internal
recovery_pending_ = true;
SetEvent(recovery_event_);
recover_stream_after_plugin();
// Recovery restarts the vendor stream. Refresh the geometry
// again before publishing the plug-in event to clients.
refresh_video_info();
}
emit_event(GVFG_EVENT_VIDEO_INPUT_PLUGIN);
}
@@ -867,6 +867,10 @@ gvfg_preview_present_result_t D3DPreviewPipeline::present_texture(ID3D11Texture2
}
bool D3DPreviewPipeline::clear_preview_black()
{
// configurePreview can precede the first prepare/render: no presentation
// surface exists yet, so there is nothing to clear.
if (!preview_swapchain_ && !preview_rtv_)
return true;
if (!preview_enabled_ || !preview_swapchain_ || !preview_rtv_ || !ctx_)
return false;