Refine signal caching and Sample device lifecycle

Compared with 350e8e5:

- perform one fresh GigabyteLib signal query for each explicit channel Start and reject a no-lock request with GVFG_ETIMEOUT instead of entering a placeholder monitoring stream

- keep running signal-status reads on the SDK cache and synchronize format-change, input plug-in, and input unplug state before publishing the corresponding event

- invalidate cached video information when the output depth changes so format selection does not cause an extra immediate hardware read

- make the Qt Sample refresh SDI information after a successful Start and on signal events without polling it from the periodic status timer

- close the Sample device session after the final running channel stops or an idle Start path fails, while preserving the selected device for the next Start

- document the updated Start result, event/cache ordering, query boundaries, and Sample ownership policy across the public API and internal flow guides

Validation: git diff --check passed. The SDK and Qt Sample builds completed successfully during this change. Hardware no-signal, plug/unplug, dual-process handoff, and recording tests were not rerun for this commit.
This commit is contained in:
Mark.lin
2026-09-16 10:37:18 +08:00
parent 350e8e519c
commit 7fb0028ba6
11 changed files with 178 additions and 72 deletions
@@ -139,6 +139,10 @@ void GigabyteCaptureSession::close_vendor_channel() const
std::lock_guard<std::mutex> lock(state_mutex_);
video_info_valid_ = false;
audio_info_valid_ = false;
cached_signal_ = {};
cached_signal_.channel = channel_;
video_info_ = {};
audio_info_ = {};
}
if (context_)
GvfgCloseDev(&context_);
@@ -214,7 +218,12 @@ gvfg_status_t GigabyteCaptureSession::set_video_format(gvfg_pixel_format_t forma
: GVFG_VIDEO_COLOR_DEPTH_8_BITS;
const gvfg_status_t status = from_vendor(
GvfgSetVideoColorDepth(context_, channel_, colorDepth));
return status == GVFG_OK ? refresh_video_info() : status;
if (status == GVFG_OK)
{
std::lock_guard<std::mutex> lock(state_mutex_);
video_info_valid_ = false;
}
return status;
}
gvfg_status_t GigabyteCaptureSession::refresh_video_info() const
@@ -364,17 +373,6 @@ gvfg_status_t GigabyteCaptureSession::configure_stream()
const gvfg_status_t openStatus = ensure_vendor_channel_open();
if (openStatus != GVFG_OK)
return openStatus;
bool refresh = false;
{
std::lock_guard<std::mutex> lock(state_mutex_);
refresh = !video_info_valid_;
}
if (refresh)
{
const gvfg_status_t status = refresh_video_info();
if (status != GVFG_OK)
return status;
}
configured_ = true;
return GVFG_OK;
}
@@ -537,6 +535,12 @@ gvfg_status_t GigabyteCaptureSession::release_frame()
return GVFG_OK;
}
void GigabyteCaptureSession::get_cached_signal_status(gvfg_signal_status_t &out) const
{
std::lock_guard<std::mutex> lock(state_mutex_);
out = cached_signal_;
}
gvfg_status_t GigabyteCaptureSession::wait_audio(
uint32_t timeoutMs, void *destination, uint32_t destinationCapacity, uint32_t &outBytes)
{
@@ -47,6 +47,7 @@ namespace gvfg::internal
gvfg_status_t set_audio_enabled(bool enabled);
gvfg_status_t set_video_format(gvfg_pixel_format_t format);
gvfg_status_t get_signal_status(gvfg_signal_status_t &out) const;
void get_cached_signal_status(gvfg_signal_status_t &out) const;
gvfg_status_t get_device_capabilities(gvfg_device_capabilities_t &out) const;
gvfg_status_t get_sdi_info(gvfg_sdi_info_t &out) const;
gvfg_status_t get_audio_format(GigabyteAudioInfo &out) const;