Refine backend status handling

Compared with 5ee2ee1:

- update the bundled GigabyteLib interface and binary, reset backend events across stream transitions, and wait for requested video format changes before reporting refreshed signal state

- translate private GigabyteLib results into stable public GVFG errors, including GVFG_EBUSY, while keeping vendor API names, enum values, and raw codes in internal diagnostics

- keep customer-facing error strings and detailed faults backend-neutral, and show the original library failure only in the Debug internal Sample

- update the public and internal error-handling documentation to match the new ownership boundary

Validation: git diff --check passed. The SDK MSVC Release build and Qt Sample MSVC Release and Debug builds completed successfully. Hardware behavior was not tested.
This commit is contained in:
Mark.lin
2026-09-22 10:15:49 +08:00
parent 5ee2ee12e6
commit 0fc22a1646
13 changed files with 1573 additions and 883 deletions
+9 -8
View File
@@ -88,11 +88,10 @@ extern "C"
GVFG_ESTATE = -3, /* API was called in the wrong state. */
GVFG_EIO = -4, /* SDK-owned I/O, GPU, or internal extension failure. */
GVFG_ENOTSUP = -5, /* Requested feature or format is not supported. */
GVFG_ETIMEOUT = -6 /* Timed out waiting for driver/backend work. */
GVFG_ETIMEOUT = -6, /* Timed out waiting for driver/backend work. */
GVFG_EBUSY = -7 /* Device or capture resource is currently busy. */
};
/* Positive return values are unmodified GigabyteLib GVFG_HRESULT values. */
typedef enum
{
GVFG_PIXFMT_UNKNOWN = 0,
@@ -192,7 +191,7 @@ extern "C"
int height; /* Signal height in pixels when connected. */
int pixel_format; /* gvfg_pixel_format_t value for the actual DMA payload. */
int bit_depth; /* Signal bit depth derived from the payload format. */
int video_interface; /* gvfg_video_interface_t reported by GigabyteLib. */
int video_interface; /* gvfg_video_interface_t reported by the capture backend. */
} gvfg_signal_status_t;
typedef struct
@@ -326,7 +325,8 @@ extern "C"
* - GVFG_OK on success.
* - GVFG_EINVAL if handle is NULL or channel_index is invalid.
* - GVFG_ENODEV if the device cannot be opened.
* - A positive, unmodified GVFG_HRESULT for GigabyteLib failures.
* - GVFG_EBUSY if the device or capture resource is already in use.
* - GVFG_EIO for other capture backend failures.
*/
GVFG_API gvfg_status_t gvfg_open_channel(
GVFG_PARAM_IN gvfg_handle handle,
@@ -415,7 +415,8 @@ extern "C"
* - GVFG_ESTATE if capture is not running or a previous frame has not been
* released.
* - GVFG_ETIMEOUT if no frame is ready before timeout_ms expires.
* - A positive, unmodified GVFG_HRESULT for GigabyteLib failures.
* - GVFG_EBUSY if the device or capture resource is busy.
* - GVFG_EIO for other capture backend failures.
*
* In copy mode the returned data pointer is owned by the SDK. In zero-copy
* mode it points to driver-owned memory. In both modes it remains valid
@@ -570,7 +571,7 @@ extern "C"
*
* No input signal is a normal state: the function returns GVFG_OK with
* out_status->connected set to 0. Before capture starts, this function
* refreshes the status from GigabyteLib. While capture is running, it returns
* refreshes the status from the capture backend. While capture is running, it returns
* the SDK cache; format-change, input-plug and input-unplug processing updates
* that cache before the corresponding public event is queued.
*/
@@ -630,7 +631,7 @@ extern "C"
/*
* Copy the most recent SDK-owned detailed fault or rejected API call for
* one channel. Positive GigabyteLib results and normal timeouts are not stored.
* one channel. Backend implementation details and normal timeouts are not stored.
* A successful gvfg_start_channel() begins a new diagnostic lifetime.
*/
GVFG_API gvfg_status_t gvfg_get_channel_last_sdk_error_detail(
+3
View File
@@ -30,6 +30,9 @@ typedef struct
double get_frame_timing_average_us;
double get_frame_timing_max300_us;
double get_frame_timing_max_us;
int32_t last_vendor_error_code;
char last_vendor_api[64];
char last_vendor_error_name[64];
} gvfg_debug_backend_stats_t;
/*
File diff suppressed because it is too large Load Diff
@@ -75,7 +75,7 @@ namespace gvfg::internal
gvfg_status_t wait_for_recovery(uint32_t timeoutMs);
gvfg_status_t refresh_video_info();
gvfg_status_t refresh_audio_info();
static gvfg_status_t from_vendor(GVFG_HRESULT result);
gvfg_status_t from_vendor(GVFG_HRESULT result, const char *apiName);
gvfg_status_t reject(gvfg_status_t status, const char *message) const;
void record_get_frame_timing(double elapsedUs);
@@ -89,6 +89,8 @@ namespace gvfg::internal
bool events_created_ = false;
bool channel_open_ = false;
bool video_info_valid_ = false;
bool format_change_pending_ = false;
gvfg_pixel_format_t requested_video_format_ = GVFG_PIXFMT_UNKNOWN;
bool audio_info_valid_ = false;
gvfg_signal_status_t cached_signal_{};
GVFG_VIDEO_INFO video_info_{};
+3 -15
View File
@@ -1263,22 +1263,10 @@ extern "C"
return "Not supported";
case GVFG_ETIMEOUT:
return "Timeout";
case GVFG_HRESULT_ERROR:
return "GVFG_HRESULT_ERROR";
case GVFG_HRESULT_DEV_ERROR:
return "GVFG_HRESULT_DEV_ERROR";
case GVFG_HRESULT_DEV_BUSY:
return "GVFG_HRESULT_DEV_BUSY";
case GVFG_HRESULT_VIDEO_CHN_ERROR:
return "GVFG_HRESULT_VIDEO_CHN_ERROR";
case GVFG_HRESULT_CONTEXT_ERROR:
return "GVFG_HRESULT_CONTEXT_ERROR";
case GVFG_HRESULT_VIDEO_CHN_INVALID:
return "GVFG_HRESULT_VIDEO_CHN_INVALID";
case GVFG_HRESULT_API_ERROR:
return "GVFG_HRESULT_API_ERROR";
case GVFG_EBUSY:
return "Device busy";
default:
return status > 0 ? "GVFG_HRESULT_UNKNOWN" : "Unknown";
return "Unknown";
}
}
+26
View File
@@ -1,5 +1,6 @@
#pragma once
#include <cstdint>
#include <mutex>
#include <string>
#include <utility>
@@ -9,16 +10,34 @@ namespace gvfg::internal
class ChannelErrorState final
{
public:
struct VendorDetail
{
int32_t code = 0;
std::string api;
std::string name;
};
void set(std::string message)
{
std::lock_guard<std::mutex> lock(mutex_);
message_ = std::move(message);
vendor_detail_ = {};
}
void set_vendor(std::string message, int32_t code, std::string api, std::string name)
{
std::lock_guard<std::mutex> lock(mutex_);
message_ = std::move(message);
vendor_detail_.code = code;
vendor_detail_.api = std::move(api);
vendor_detail_.name = std::move(name);
}
void clear()
{
std::lock_guard<std::mutex> lock(mutex_);
message_.clear();
vendor_detail_ = {};
}
std::string message() const
@@ -27,8 +46,15 @@ namespace gvfg::internal
return message_;
}
VendorDetail vendor_detail() const
{
std::lock_guard<std::mutex> lock(mutex_);
return vendor_detail_;
}
private:
mutable std::mutex mutex_;
std::string message_;
VendorDetail vendor_detail_;
};
}