# GVFG Customer API Reference English | [繁體中文](GVFG_CUSTOMER_API_REFERENCE.zh-TW.md) SDK 3.2.0. Capture, OSD, and Playback are three DLLs. Capture and Playback have their own APIs and status codes; OSD uses the Capture `gvfg_status_t`. SDK 3.2.0 moved the OSD functions and types from `gvfg_capture.h`/`gvfg.dll` to `gvfg_osd.h`/`gvfg_osd.dll`, and added an HDMI audio query. Recompile with this version's headers, import libraries, and DLLs; do not mix in binaries from 3.1 or earlier. - [Capture types and constants](#1-gvfg-api-types-and-constants) - [Capture functions](#2-gvfg-api-functions) - [OSD API](#3-osd-api) - [Playback image types](#4-image-types-used-by-playback) - [Playback API, config, and limits](#5-unified-playback-api) ## 1. GVFG API types and constants This section describes every public constant, type, and struct in `gvfg_capture.h`; OSD types are in section 3. Unless noted otherwise, initialize every output struct with `{0}` first. ### 1.1 Public constants | Constant | Value | Meaning | | ----------------------- | ------------:| -------------------------------------------------------- | | `GVFG_MAX_DEVICES` | 16 | Maximum number of devices enumerated at once | | `GVFG_TIMEOUT_INFINITE` | `UINT32_MAX` | Wait indefinitely; `timeout_ms == 0` never waits | ### 1.2 `gvfg_status_t` `gvfg_status_t` is a 32-bit integer. `0` means success; failures return a negative `GVFG_E*` status. | Member | Value | Meaning | | --------------- | ---:| ---------------------------------------------------------------------- | | `GVFG_OK` | 0 | Success | | `GVFG_EINVAL` | -1 | Invalid argument such as a NULL pointer, channel, buffer size, or token | | `GVFG_ENODEV` | -2 | No device found, or the device cannot be opened | | `GVFG_ESTATE` | -3 | The call order or current session state does not allow the operation | | `GVFG_EIO` | -4 | SDK I/O, GPU, or other processing failure | | `GVFG_ENOTSUP` | -5 | Requested feature or format is not supported | | `GVFG_ETIMEOUT` | -6 | No frame, event, or completion within the time limit | | `GVFG_EBUSY` | -7 | Device or capture resource is in use | Always test for failure with `status != GVFG_OK`; do not use Windows `FAILED()`/`SUCCEEDED()`. `gvfg_strerror()` returns the matching public English description. ### 1.3 `gvfg_pixel_format_t` | Member | Value | Meaning | | --------------------- | ---:| ---------------------------------------------------------------------- | | `GVFG_PIXFMT_UNKNOWN` | 0 | Unknown, or no valid signal format yet | | `GVFG_PIXFMT_YUY2` | 1 | 8-bit packed YUV 4:2:2; byte order Y0 U0 Y1 V0, 2 bytes per pixel | | `GVFG_PIXFMT_Y210` | 2 | 10-bit packed YUV 4:2:2; currently 4 bytes per pixel | ### 1.4 `gvfg_channel_t` | Member | Value | Meaning | | ---------------- | ---:| ---------------------- | | `GVFG_CHANNEL_0` | 0 | Device input channel 0 | | `GVFG_CHANNEL_1` | 1 | Device input channel 1 | ### 1.5 `gvfg_video_interface_t` | Member | Value | Meaning | | --------------------------- | ---:| ---------- | | `GVFG_INPUT_INTERFACE_SDI` | 0 | SDI input | | `GVFG_INPUT_INTERFACE_HDMI` | 1 | HDMI input | ### 1.6 `gvfg_sdi_mode_t` | Member | Value | Meaning | | ------------------------ | ---:| ------------ | | `GVFG_SDI_INPUT_MODE_HD` | 0 | HD-SDI input | | `GVFG_SDI_INPUT_MODE_SD` | 1 | SD-SDI input | | `GVFG_SDI_INPUT_MODE_3G` | 2 | 3G-SDI input | ### 1.7 `gvfg_sdi_resolution_t` | Member | Value | Meaning | | -------------------------------------------------- | -----:| ------------------------------------- | | `GVFG_SDI_INPUT_RESOLUTION_SMPTE_ST_274_1920X1080` | `0x0` | SMPTE ST 274, 1920 x 1080 | | `GVFG_SDI_INPUT_RESOLUTION_SMPTE_ST_296_1280X720` | `0x1` | SMPTE ST 296, 1280 x 720 | | `GVFG_SDI_INPUT_RESOLUTION_SMPTE_2048_2048X1080` | `0x2` | SMPTE 2048, 2048 x 1080 | | `GVFG_SDI_INPUT_RESOLUTION_SMPTE_295_1920X1080` | `0x3` | SMPTE 295, 1920 x 1080 | | `GVFG_SDI_INPUT_RESOLUTION_NTSC_720X486` | `0x8` | NTSC, 720 x 486 | | `GVFG_SDI_INPUT_RESOLUTION_PAL_720X576` | `0x9` | PAL, 720 x 576 | | `GVFG_SDI_INPUT_RESOLUTION_UNKNOWN` | `0xF` | Unknown or unsupported resolution | ### 1.8 `gvfg_sdi_fps_t` | Member | Value | Meaning | | -------------------------- | -----:| -------------------------- | | `GVFG_SDI_INPUT_FPS_NONE` | `0x0` | No frame rate available | | `GVFG_SDI_INPUT_FPS_23_98` | `0x2` | 23.98 fps | | `GVFG_SDI_INPUT_FPS_24` | `0x3` | 24 fps | | `GVFG_SDI_INPUT_FPS_47_95` | `0x4` | 47.95 fps | | `GVFG_SDI_INPUT_FPS_25` | `0x5` | 25 fps | | `GVFG_SDI_INPUT_FPS_29_97` | `0x6` | 29.97 fps | | `GVFG_SDI_INPUT_FPS_30` | `0x7` | 30 fps | | `GVFG_SDI_INPUT_FPS_48` | `0x8` | 48 fps | | `GVFG_SDI_INPUT_FPS_50` | `0x9` | 50 fps | | `GVFG_SDI_INPUT_FPS_59_94` | `0xA` | 59.94 fps | | `GVFG_SDI_INPUT_FPS_60` | `0xB` | 60 fps | ### 1.9 `gvfg_device_info_t` Filled by `gvfg_enumerate_devices()`. | Field | Type | Meaning | | ------ | ----------- | ------------------------------------------------------------ | | `name` | `char[128]` | UTF-8, null-terminated device name for UI/log display | ### 1.10 `gvfg_sdi_info_t` Filled by `gvfg_get_channel_sdi_info()`. Numeric fields are for program logic; the matching `*_name` fields are null-terminated English strings that can be shown directly in a UI or log. | Field | Type | Meaning | | -------------------------- | ----------------------- | ------------------------------------------ | | `connected` | `int` | Non-zero when the SDI input signal is locked | | `mode` | `gvfg_sdi_mode_t` | Detected SDI link mode | | `resolution` | `gvfg_sdi_resolution_t` | Detected SDI resolution code | | `fps` | `gvfg_sdi_fps_t` | Detected SDI frame-rate code | | `progressive` | `int` | Non-zero for progressive; 0 for interlaced | | `level_b` | `int` | Non-zero for 3G-SDI Level B | | `st352_payload` | `uint32_t` | SMPTE ST 352 payload identifier | | `error_count` | `uint32_t` | Signal error count reported by the device | | `signal_lock_name[32]` | `char[32]` | Signal lock description | | `mode_name[16]` | `char[16]` | SDI mode name | | `resolution_name[64]` | `char[64]` | Resolution name | | `fps_name[24]` | `char[24]` | Frame-rate name | | `scan_name[16]` | `char[16]` | Scan mode name | | `st352_format_name[64]` | `char[64]` | ST 352 format name | | `st352_fps_name[24]` | `char[24]` | ST 352 frame-rate name | | `st352_chroma_name[36]` | `char[36]` | ST 352 chroma name | | `st352_bit_depth_name[24]` | `char[24]` | ST 352 bit-depth name | ### 1.11 `gvfg_signal_status_t` Filled by `gvfg_get_channel_signal_status()`. | Field | Type | Meaning | | ----------------- | ----- | ----------------------------------------------------------------- | | `connected` | `int` | Non-zero when the queried channel currently has a valid input signal | | `channel` | `int` | The `gvfg_channel_t` value for this query | | `width` | `int` | Input width when connected; 0 when not connected | | `height` | `int` | Input height when connected; 0 when not connected | | `pixel_format` | `int` | `gvfg_pixel_format_t` value of the actual frame payload | | `bit_depth` | `int` | Bits per color channel derived from the payload format | | `video_interface` | `int` | `gvfg_video_interface_t`: SDI or HDMI | ### 1.12 `gvfg_runtime_info_t` Filled by `gvfg_get_channel_runtime_info()`. The statistics reset when a channel successfully moves from stopped into a new running session; calling start again on a running channel does not reset them. | Field | Type | Meaning | | ------------------ | ---------- | ------------------------------------------------------------------------------- | | `capture_fps` | `double` | FPS estimated from successful `gvfg_read_channel_frame()` deliveries; 0 until enough frames | | `delivered_frames` | `uint64_t` | Frames successfully delivered to the caller in this running session | ### 1.13 `gvfg_frame_t` Filled by `gvfg_read_channel_frame()`; it is also the frame descriptor later passed to `gvfg_release_channel_frame()`. | Field | Type | Meaning | | ------------------ | -------------- | ----------------------------------------------------------------- | | `data` | `const void *` | Borrowed frame buffer; invalid after release or stop | | `data_size` | `uint64_t` | Total bytes in this frame payload | | `width` | `int` | Frame width in pixels | | `height` | `int` | Frame height in pixels | | `row_stride_bytes` | `int` | Bytes between the starts of adjacent rows; always use it when processing rows | | `pixel_format` | `int` | `gvfg_pixel_format_t` value | | `bit_depth` | `int` | Bits per color channel of the native frame | | `frame_id` | `uint64_t` | SDK delivery sequence number; restarts at 1 on every channel start | | `timestamp_ns` | `uint64_t` | SDK delivery time in ns; shares the monotonic clock with audio | The caller passes the descriptor from read back to release; the SDK identifies the currently held frame by `data + frame_id`. ### 1.14 `gvfg_audio_format_t` Filled by `gvfg_get_channel_audio_format()`. It contains only the PCM metadata the application needs to set up playback or recording. | Field | Type | Meaning | | ----------------- | ---------- | -------------------------------- | | `sample_rate` | `uint32_t` | Samples per second | | `channels` | `uint32_t` | Interleaved PCM channel count | | `bits_per_sample` | `uint32_t` | Bits per PCM sample | The valid data length of each audio frame is given by `gvfg_audio_frame_t.data_size`. ### 1.15 `gvfg_audio_frame_t` Filled by `gvfg_read_channel_audio_frame()`; it is also the audio frame descriptor later passed to `gvfg_release_channel_audio_frame()`. | Field | Type | Meaning | | ----------------- | -------------- | ---------------------------------------------------------------- | | `data` | `const void *` | Borrowed interleaved PCM; invalid after release or stop | | `data_size` | `uint64_t` | Valid PCM bytes in this frame | | `sample_rate` | `uint32_t` | Samples per second | | `channels` | `uint32_t` | Interleaved PCM channel count | | `bits_per_sample` | `uint32_t` | Bits per PCM sample | | `frame_id` | `uint64_t` | SDK delivery sequence number; restarts at 1 on every channel start | | `timestamp_ns` | `uint64_t` | SDK delivery time in ns; shares the monotonic clock with video | As with video, each channel holds at most one audio frame at a time; release identifies the held frame by `data + frame_id`. Video and audio `timestamp_ns` values can be compared directly within the same process/session. They represent SDK delivery time, not the time the frame was produced at the signal source. ### 1.16 `gvfg_gpu_output_format_t` | Member | Value | Meaning | | ------------------------- | ---:| ------------------------------------------------------------------ | | `GVFG_GPU_OUTPUT_BGRA8` | 1 | DXGI `B8G8R8A8_UNORM` byte layout, alpha 255 | | `GVFG_GPU_OUTPUT_RGB10A2` | 2 | DXGI `R10G10B10A2_UNORM` packed `uint32_t`, alpha 3 | | `GVFG_GPU_OUTPUT_NV12` | 3 | 8-bit BT.709 limited-range 4:2:0; Y plane followed by interleaved UV | ### 1.17 `gvfg_gpu_output_buffer_t` Created by the caller and passed to `gvfg_gpu_convert_to_buffer()`. | Field | Type | Meaning | | -------------- | ---------- | --------------------------------------------------------- | | `data` | `void *` | Caller-owned destination buffer; must not be NULL | | `data_size` | `uint64_t` | Usable bytes in the destination buffer | | `row_bytes` | `int` | Destination stride; NV12 Y and UV planes share it | | `pixel_format` | `int` | Requested `gvfg_gpu_output_format_t` value | The caller must check that the size multiplication does not overflow and keep the destination valid until the conversion returns. For the calling sequence, see [Guide: GPU conversion example](../GVFG_CUSTOMER_API.md#gpu-conversion-example). ### 1.18 `gvfg_event_type_t` | Member | Value | Meaning | | --------------------------------- | ---:| --------------------------------------------- | | `GVFG_EVENT_UNKNOWN` | 0 | Unknown event; normal flows should not rely on it | | `GVFG_EVENT_VIDEO_FORMAT_CHANGED` | 1 | Input video format changed | | `GVFG_EVENT_VIDEO_INPUT_PLUGIN` | 2 | Video input connected | | `GVFG_EVENT_VIDEO_INPUT_UNPLUG` | 3 | Video input disconnected | The SDK creates and manages the complete set of channel events; applications receive them through `gvfg_poll_channel_event()`. ### 1.19 `gvfg_handle` ```c typedef struct gvfg_handle_t *gvfg_handle; ``` Created only by `gvfg_create()` and destroyed only by `gvfg_destroy()`; the caller must not access, allocate, or modify its contents. ### 1.20 `gvfg_hdmi_info_t` Filled by `gvfg_get_channel_hdmi_info()`. | Field | Type | Meaning | | ----------------------- | ---------- | --------------------------------------------------------------- | | `connected` | `int` | Non-zero when the HDMI video signal is locked | | `width`, `height` | `uint32_t` | Source width and height in pixels | | `fps` | `uint32_t` | Frames per second, for example `60` | | `color_format` | `uint32_t` | HDMI color format code | | `color_space` | `uint32_t` | HDMI color space and range code | | `bit_depth` | `uint32_t` | Source bit depth; may differ from the DMA output bit depth | | `fps_name[24]` | `char[24]` | Decimal text of `fps` without a unit, for example `"60"` | | `color_format_name[24]` | `char[24]` | For example `RGB`, `YUV 4:2:2`, `YUV 4:4:4`, `YUV 4:2:0`; `Unknown` otherwise | | `color_space_name[32]` | `char[32]` | For example `YUV 709`, `BT.2020 RGB`, `RGB (Limited)`; `Unknown` otherwise | ### 1.21 `gvfg_hdmi_audio_info_t` Filled by `gvfg_get_channel_hdmi_audio_info()`. | Field | Type | Meaning | | --------------------------- | ---------- | -------------------------------------------------------------- | | `connected` | `int` | Non-zero when the HDMI audio signal is locked | | `sample_frequency` | `uint32_t` | HDMI audio sample-frequency code, not a value in Hz | | `bits_per_sample` | `uint32_t` | Bits per sample | | `channels` | `uint32_t` | Number of audio channels | | `format` | `uint32_t` | HDMI audio format code | | `sample_frequency_name[24]` | `char[24]` | For example `48 kHz`, `96 kHz`, `HBR`; `Unknown` otherwise | | `format_name[24]` | `char[24]` | For example `Linear PCM`, `AC-3`, `Compressed Audio`; `Unknown` otherwise | When `connected == 0`, only the numeric fields are filled and both name fields stay empty. ### 1.22 `gvfg_chip_info_t` Filled by `gvfg_get_chip_info()`. | Field | Type | Meaning | | -------------- | ---------- | -------------------------------------------------------- | | `version_date` | `uint32_t` | Chip version date; read its hexadecimal digits as `YYYYMMDD` | | `version_time` | `uint32_t` | Chip version time; read its hexadecimal digits as `HHMMSS` | For example, `0x20261113` and `0x174645` represent `2026-11-13 17:46:45`. ## 2. GVFG API functions This section describes every public function in `gvfg_capture.h`. Parameter directions are marked `[in]`, `[out]`, and `[in, out]`: `[in]` is provided by the caller, `[out]` is written by the function, and `[in, out]` contains input fields the caller must set as well as results written back by the function. ### 2.1 `gvfg_enumerate_devices` ```c int gvfg_enumerate_devices(/* [out] */ gvfg_device_info_t *out_devices, /* [in] */ int max_devices); ``` Parameters: - `out_devices`: array that receives device entries; pass `NULL` to query the count only. - `max_devices`: number of entries the array can hold; values larger than `GVFG_MAX_DEVICES` are clamped. Pass 0 when `out_devices == NULL`. Return value: the number of entries written when an output array is provided; the number of available devices when only the count is queried; 0 when there is no device. This function returns a count, not a `gvfg_status_t`. ### 2.2 `gvfg_create` ```c gvfg_status_t gvfg_create(/* [out] */ gvfg_handle *out_handle); ``` - `out_handle`: receives the new handle; must not be NULL. - Success: `GVFG_OK`; the handle starts in the closed state. - Failure: `GVFG_EINVAL` (the output pointer is NULL). ### 2.3 `gvfg_destroy` ```c gvfg_status_t gvfg_destroy(/* [in] */ gvfg_handle handle); ``` - `handle`: handle returned by `gvfg_create()`; may be NULL. - Returns `GVFG_OK`. If capture is still running, the SDK stops it first. Do not use the handle after this call. ### 2.4 `gvfg_open_channel` ```c gvfg_status_t gvfg_open_channel(/* [in] */ gvfg_handle handle, /* [in] */ int device_index, /* [in] */ int channel_index); ``` - `handle`: an existing session handle. - `device_index`: zero-based position in the `gvfg_enumerate_devices()` result. - `channel_index`: `GVFG_CHANNEL_0` or `GVFG_CHANNEL_1`. - May return `GVFG_OK`, `GVFG_EINVAL`, `GVFG_ENODEV`, `GVFG_ESTATE`, `GVFG_EBUSY`, or `GVFG_EIO`. CH0 and CH1 can each be opened on the same handle. Once any channel is open, the same handle cannot switch to a different device index. ### 2.5 `gvfg_get_channel_sdi_info` ```c gvfg_status_t gvfg_get_channel_sdi_info( /* [in] */ gvfg_handle handle, /* [in] */ int channel_index, /* [out] */ gvfg_sdi_info_t *out_info); ``` - `handle`: session on which the channel is open. - `channel_index`: `GVFG_CHANNEL_0` or `GVFG_CHANNEL_1` to query. - `out_info`: receives detailed SDI information; must not be NULL. - `GVFG_OK`: query succeeded. - `GVFG_EINVAL`: handle or output pointer is NULL, or the channel index is invalid. - `GVFG_ESTATE`: the channel is not open. - May return `GVFG_EIO` if the device query fails. ### 2.6 HDMI input information, HDMI audio information, and chip version ```c gvfg_status_t gvfg_get_channel_hdmi_info( /* [in] */ gvfg_handle handle, /* [in] */ int channel_index, /* [out] */ gvfg_hdmi_info_t *out_info); gvfg_status_t gvfg_get_channel_hdmi_audio_info( /* [in] */ gvfg_handle handle, /* [in] */ int channel_index, /* [out] */ gvfg_hdmi_audio_info_t *out_info); gvfg_status_t gvfg_get_chip_info( /* [in] */ gvfg_handle handle, /* [out] */ gvfg_chip_info_t *out_info); ``` - Use the `video_interface` from `gvfg_get_channel_signal_status()` to choose the SDI or HDMI query. - The HDMI video and HDMI audio queries require the channel to be open; see sections 1.20 and 1.21 for the fields. - The chip version belongs to the device; at least one channel on the handle must be open. See section 1.22 for the fields. - `GVFG_EINVAL`: handle or output pointer is NULL, or the channel index is invalid. - `GVFG_ESTATE`: the channel required for the query is not open. - May return `GVFG_EIO` or another `GVFG_E*` status if the device query fails. - The output struct is cleared on entry; use the output only when the call returns `GVFG_OK`. ```c #include #include #include void print_chip_info(gvfg_handle handle) { gvfg_chip_info_t info = {0}; if (gvfg_get_chip_info(handle, &info) == GVFG_OK) { char date[9]; char time[9]; int date_len = snprintf(date, sizeof date, "%08" PRIX32, info.version_date); int time_len = snprintf(time, sizeof time, "%06" PRIX32, info.version_time); if (date_len == 8 && time_len == 6) printf("Chip version: %.4s-%.2s-%.2s %.2s:%.2s:%.2s\n", date, date + 4, date + 6, time, time + 2, time + 4); } } ``` ### 2.7 Zero-copy mode selection ```c gvfg_status_t gvfg_set_channel_zero_copy_enabled(/* [in] */ gvfg_handle handle, /* [in] */ int channel, /* [in] */ int enabled); gvfg_status_t gvfg_get_channel_zero_copy_enabled(/* [in] */ gvfg_handle handle, /* [in] */ int channel, /* [out] */ int *out_enabled); ``` - Call `set` only after `gvfg_create()` and before the channel is opened. - `enabled` accepts only 0 (copy) or 1 (zero-copy); each channel defaults to 0. - Calling `set` when the channel is already open returns `GVFG_ESTATE`; the other channel is not affected. - `get` queries the channel's mode; `out_enabled` must not be NULL. - In zero-copy mode `frame.data` is a borrowed pointer; you must still call `gvfg_release_channel_frame()` with the same descriptor, and each channel holds at most one frame at a time. - This setting controls how native frames are acquired. SDK processing such as OSD may deliver an SDK-owned output buffer; the caller's read/release flow is the same. ### 2.8 `gvfg_set_channel_video_format` ```c gvfg_status_t gvfg_set_channel_video_format(/* [in] */ gvfg_handle handle, /* [in] */ int channel_index, /* [in] */ gvfg_pixel_format_t format); ``` - Supports `GVFG_PIXFMT_YUY2` and `GVFG_PIXFMT_Y210`. - The channel must be open, and capture must not have started or must have been stopped. - Only one channel on a handle can select Y210 at a time; a conflicting request returns `GVFG_EBUSY`. - YUY2 corresponds to 8-bit color depth and Y210 to 10-bit. ### 2.9 Audio capture selection and frame ownership ```c gvfg_status_t gvfg_set_channel_audio_enabled(/* [in] */ gvfg_handle handle, /* [in] */ int channel_index, /* [in] */ int enabled); gvfg_status_t gvfg_get_channel_audio_format(/* [in] */ gvfg_handle handle, /* [in] */ int channel_index, /* [out] */ gvfg_audio_format_t *out_format); gvfg_status_t gvfg_read_channel_audio_frame(/* [in] */ gvfg_handle handle, /* [in] */ int channel_index, /* [out] */ gvfg_audio_frame_t *out_frame, /* [in] */ uint32_t timeout_ms); gvfg_status_t gvfg_release_channel_audio_frame(/* [in] */ gvfg_handle handle, /* [in] */ int channel_index, /* [in] */ const gvfg_audio_frame_t *frame); ``` - By default only video is captured. On CH0, enable audio with `gvfg_set_channel_audio_enabled()` before start. - `gvfg_start_channel()` starts video-only or video + audio capture according to the audio setting. - `gvfg_read_channel_audio_frame()` gets the next PCM frame and hands over a borrowed descriptor. Call `gvfg_release_channel_audio_frame()` when you are done with it. - Reading again before release returns `GVFG_ESTATE`. - A NULL `out_frame` or a modified release token returns `GVFG_EINVAL`. - `timeout_ms` follows the other read APIs: `0` does not wait, `GVFG_TIMEOUT_INFINITE` waits indefinitely, and a timeout returns `GVFG_ETIMEOUT`. - Read video and audio on separate worker threads; do not run two audio reads on the same channel concurrently. - The descriptor becomes invalid immediately after stop/close; copy the PCM if it must survive release or stop. ### 2.10 `gvfg_start_channel` ```c gvfg_status_t gvfg_start_channel(/* [in] */ gvfg_handle handle, /* [in] */ int channel_index); ``` - `handle`: a session handle that has been opened successfully. - `GVFG_OK`: capture started, or the channel is already running. - `GVFG_EINVAL`: handle is NULL. - `GVFG_ESTATE`: no device is open. - `GVFG_ETIMEOUT`: the live signal query for this start shows no lock; the channel does not enter running. - `GVFG_EBUSY`: the device or capture resource is in use. - `GVFG_EIO`: capture start or I/O failure. When a channel starts a new running session from stopped, it runs a fresh signal query instead of reusing the signal cache from before the stop. Calling start again on a running channel returns `GVFG_OK` directly without querying the signal again. With no signal, the application should wait for the input to return and then call start again. ### 2.11 `gvfg_read_channel_frame` ```c gvfg_status_t gvfg_read_channel_frame(/* [in] */ gvfg_handle handle, /* [in] */ int channel_index, /* [out] */ gvfg_frame_t *out_frame, /* [in] */ uint32_t timeout_ms); ``` - `handle`: a running session. - `out_frame`: receives the frame descriptor; must not be NULL. Clear it before the call. - `timeout_ms`: 0 is non-blocking; `GVFG_TIMEOUT_INFINITE` waits indefinitely; other values are in milliseconds. - `GVFG_OK`: a frame was received, and the caller now holds a token that must be released. - `GVFG_EINVAL`: handle or output pointer is NULL. - `GVFG_ESTATE`: not running, a frame is already held, another read is in progress, or the channel was stopped during the read (including a stop followed by a new start; a frame from before the stop is never delivered). - `GVFG_ETIMEOUT`: no frame within the time limit. - `GVFG_EBUSY` means the capture resource is in use; `GVFG_EIO` means a capture or I/O failure; `GVFG_ENOTSUP` means the SDK does not support the format. Both copy mode and zero-copy mode return a borrowed frame buffer. In both cases the pointer is only guaranteed valid until the matching `gvfg_release_channel_frame()`. ### 2.12 `gvfg_release_channel_frame` ```c gvfg_status_t gvfg_release_channel_frame(/* [in] */ gvfg_handle handle, /* [in] */ int channel_index, /* [in] */ const gvfg_frame_t *frame); ``` - `handle`: the same handle that read the frame. - `frame`: the complete descriptor returned unchanged by `gvfg_read_channel_frame()`. - `GVFG_OK`: the frame was returned. - Even if the input signal drops while the frame is held, the application should still release each frame it read successfully once. - `GVFG_EINVAL`: NULL, or the token does not match the held frame. - `GVFG_ESTATE`: the channel is not open, or no frame is currently held. ### 2.13 `gvfg_gpu_convert_to_buffer` ```c gvfg_status_t gvfg_gpu_convert_to_buffer( /* [in] */ const gvfg_frame_t *source, /* [in] */ const gvfg_gpu_output_buffer_t *output); ``` - `source`: a valid YUY2/Y210 frame; if it came from read, it must not be released yet. - `output`: the destination descriptor filled in by the caller. - `GVFG_OK`: synchronous conversion and copy completed. - `GVFG_EINVAL`: NULL, size, stride, buffer size, odd/even size, or overflow error. - `GVFG_ENOTSUP`: input or output format not supported. - `GVFG_EIO`: D3D/GPU resource, dispatch, or readback failure. ### 2.14 `gvfg_gpu_convert_to_bgra8` ```c gvfg_status_t gvfg_gpu_convert_to_bgra8( /* [in] */ const gvfg_frame_t *source, /* [out] */ void *destination, /* [in] */ uint64_t destination_size, /* [in] */ int row_bytes); ``` - `source`: a valid YUY2/Y210 frame that has not been released. - `destination`: caller-owned BGRA8 buffer. - `destination_size`: buffer size in bytes, at least `row_bytes * source->height`. - `row_bytes`: destination stride, at least `source->width * 4`. - Return statuses are the same as for the generic GPU conversion. ### 2.15 `gvfg_gpu_convert_to_rgb10a2` ```c gvfg_status_t gvfg_gpu_convert_to_rgb10a2( /* [in] */ const gvfg_frame_t *source, /* [out] */ void *destination, /* [in] */ uint64_t destination_size, /* [in] */ int row_bytes); ``` Parameters are the same as for the BGRA8 wrapper, but the destination layout is packed RGB10A2; each row still needs at least `source->width * 4` bytes. Return statuses are the same as for the generic GPU conversion. ### 2.16 `gvfg_gpu_convert_to_nv12` ```c gvfg_status_t gvfg_gpu_convert_to_nv12( /* [in] */ const gvfg_frame_t *source, /* [out] */ void *destination, /* [in] */ uint64_t destination_size, /* [in] */ int row_bytes); ``` - `source`: a valid YUY2/Y210 frame that has not been released; width and height must be even. - `destination`: caller-owned NV12 buffer. - `destination_size`: at least `row_bytes * (height + height / 2)`. - `row_bytes`: stride shared by the Y and UV planes, at least `width`. - Return statuses are the same as for the generic GPU conversion. ### 2.17 `gvfg_poll_channel_event` ```c gvfg_status_t gvfg_poll_channel_event(/* [in] */ gvfg_handle handle, /* [in] */ int channel_index, /* [out] */ gvfg_event_type_t *out_event_type, /* [in] */ uint32_t timeout_ms); ``` - `handle`: a running session. - `out_event_type`: receives one `gvfg_event_type_t` event kind; must not be NULL. - `timeout_ms`: same rules as read. - `GVFG_OK`: one event was taken. - `GVFG_EINVAL`: handle or output pointer is NULL. - `GVFG_ESTATE`: not running, or stopped while waiting. - `GVFG_ETIMEOUT`: no event within the time limit. ### 2.18 `gvfg_stop` ```c gvfg_status_t gvfg_stop(/* [in] */ gvfg_handle handle); ``` - `handle`: session handle; must not be NULL. - `GVFG_OK`: success; already stopped also counts as success. - `GVFG_EINVAL`: handle is NULL. This function stops capture, wakes waiting read/poll calls, and invalidates unreleased frames. ### 2.19 `gvfg_stop_channel` ```c gvfg_status_t gvfg_stop_channel(/* [in] */ gvfg_handle handle, /* [in] */ int channel_index); ``` - Stops only the given channel; `gvfg_stop()` stops every opened channel on the handle. - A channel that is not open returns `GVFG_ESTATE`. ### 2.20 `gvfg_get_channel_signal_status` ```c gvfg_status_t gvfg_get_channel_signal_status( /* [in] */ gvfg_handle handle, /* [in] */ int channel_index, /* [out] */ gvfg_signal_status_t *out_status); ``` - `handle`: an opened session. - `out_status`: receives the signal status; must not be NULL. - `GVFG_OK`: query succeeded; with no signal it still succeeds, with `connected == 0`. - `GVFG_EINVAL`: handle or output pointer is NULL. - `GVFG_ESTATE`: no device is open. - May return `GVFG_EIO` on capture I/O failure. While the channel is not running, this API refreshes the current signal status; while running, it returns the most recently observed state. After a format changed, input plug-in, or input unplug event, later queries reflect the updated state. ### 2.21 `gvfg_get_channel_runtime_info` ```c gvfg_status_t gvfg_get_channel_runtime_info( /* [in] */ gvfg_handle handle, /* [in] */ int channel_index, /* [out] */ gvfg_runtime_info_t *out_info); ``` - `handle`: an opened or running session. - `out_info`: receives runtime statistics; must not be NULL. - `GVFG_OK`: query succeeded. - `GVFG_EINVAL`: handle or output pointer is NULL. - `GVFG_ESTATE`: the channel is not open. ### 2.22 `gvfg_get_version` / `gvfg_get_gigabyte_lib_version` ```c const char *gvfg_get_version(void); const char *gvfg_get_gigabyte_lib_version(void); ``` - `gvfg_get_version()` returns the version of the GVFG runtime DLL actually loaded, for example `"3.2.0"`. - The return value is a static null-terminated string; the caller must not free it. - Use it for logs, problem reports, and to confirm that the header and DLL come from the same version. - `gvfg_get_gigabyte_lib_version()` returns the GigabyteLib version constant compiled into the current runtime. It is not a run-time driver/FPGA version query. It is also a static string, needs no handle, and must not be freed. ### 2.23 `gvfg_pixel_format_name` ```c const char *gvfg_pixel_format_name(/* [in] */ int pixel_format); ``` - `pixel_format`: a `gvfg_pixel_format_t` or any other integer. - Returns the static English string `"YUY2"`, `"Y210"`, or `"UNKNOWN"`. The caller must not free it. ### 2.24 `gvfg_strerror` ```c const char *gvfg_strerror(/* [in] */ gvfg_status_t status); ``` - `status`: any GVFG status code. - Returns a static, null-terminated English description; unknown values return an "unknown" style description. The caller must not free it. ### 2.25 `gvfg_get_channel_last_sdk_error_detail` ```c gvfg_status_t gvfg_get_channel_last_sdk_error_detail(/* [in] */ gvfg_handle handle, /* [in] */ int channel_index, /* [out] */ char *out_message, /* [in] */ uint32_t out_message_size); ``` This function adds detail to a public `GVFG_E*` failure status. The content only describes public error information the application can act on. - Copies the UTF-8 detail of the channel's most recent fault or rejected operation; it can be queried even if opening that channel failed. - Timeouts and empty non-blocking results from `gvfg_read_channel_frame()`/`gvfg_poll_channel_event()`, and a normal stop waking a waiter, do not overwrite it. - Every call to `gvfg_start_channel()` clears the previously saved detail. - If several threads operate on the same channel, a later error may overwrite the detail; query it right after the failure. - `GVFG_EINVAL`: handle/message is NULL, the channel index is invalid, or the buffer size is 0. ## 3. OSD API OSD is declared in `gvfg_osd.h` (which includes `gvfg_capture.h`), exported by `gvfg_osd.dll`, and returns the Capture `gvfg_status_t`. Link `gvfg_osd.lib` (`libgvfg_osd.dll.a` for MinGW) and deploy `gvfg_osd.dll` and `gvfg.dll` from the same SDK build with the application. Plain capture only needs the import library for `gvfg.dll`. ### 3.1 OSD constants and types | Constant | Value | Meaning | |---|---:|---| | `GVFG_OSD_MAX_TEXT_CHARACTERS` | 32 | Maximum printable ASCII characters per OSD slot | | `GVFG_OSD_SLOT_COUNT` | 2 | Independent OSD slots per channel | ```c typedef struct gvfg_channel_osd_config_t { const char *text; const char *font_family; uint32_t font_size_px; uint32_t color_rgb; int32_t x; int32_t y; } gvfg_channel_osd_config_t; typedef struct gvfg_osd_font_list_t { uint32_t count; const char *const *names; } gvfg_osd_font_list_t; typedef struct gvfg_osd_bitmap_t { const uint8_t *data; uint64_t data_size; uint32_t width; uint32_t height; uint32_t stride; } gvfg_osd_bitmap_t; ``` `text` is NUL-terminated printable ASCII of 1–32 characters; `font_family` is the NUL-terminated UTF-8 name of an installed font family. Set copies both strings before it returns. `font_size_px` must be non-zero; `color_rgb` is `0x00RRGGBB`; `x/y` are the frame coordinates of the text box's top-left corner. The font list is managed by the SDK and must not be modified or freed by the customer; see section 3.3 for its lifetime. `gvfg_osd_bitmap_t.data` is owned by the SDK, `data_size` is `stride * height`, and `stride` is `width * 4`; see section 3.4 for its lifetime. ### 3.2 `gvfg_measure_osd_text` ```c gvfg_status_t gvfg_measure_osd_text( /* [in] */ const gvfg_channel_osd_config_t *config, /* [out] */ uint32_t *out_width, /* [out] */ uint32_t *out_height); ``` Needs no capture handle or device. It uses the same text, font, and size as rendering and ignores position and color. The result is a conservative complete text box that includes overhang and a one-pixel guard on each edge; the outputs are zeroed on failure. A missing font or invalid input returns `GVFG_EINVAL`. ### 3.3 OSD fonts, setting, show/hide, and clear ```c gvfg_status_t gvfg_get_osd_fonts(/* [out] */ gvfg_osd_font_list_t *out_list); gvfg_status_t gvfg_set_channel_osd( gvfg_handle handle, int channel_index, uint32_t osd_index, const gvfg_channel_osd_config_t *config); gvfg_status_t gvfg_set_channel_osd_visible( gvfg_handle handle, int channel_index, uint32_t osd_index, int visible); gvfg_status_t gvfg_clear_channel_osd( gvfg_handle handle, int channel_index, uint32_t osd_index); ``` | Item | Contract | |---|---| | Channel/slot | Set, visibility, and Clear require the channel to be open; `osd_index` is 0 or 1, and slot 1 is on top where they overlap | | `gvfg_get_osd_fonts()` | Needs no handle; rechecks the fonts installed in Windows on every call. On success returns `count` and UTF-8 `names`; on failure the list is empty | | List ownership | The SDK owns the array and strings; the caller must not modify or free them. Valid until the next list query (including a failed one) or DLL unload. Copy names you need to keep; the caller must serialize querying and reading | | `gvfg_set_channel_osd()` | Configures and shows one slot, copies the text and font name before returning, and applies to subsequent frames; on failure the previous settings are kept | | Text/font | `text` is NUL-terminated, 1–32 ASCII characters 0x20–0x7e; `font_family` is the NUL-terminated UTF-8 name of an installed family. Missing fonts and invalid UTF-8 are rejected | | Size/color | `font_size_px` is a non-zero em size, not the actual ink height of the glyphs; normal weight/style/stretch. `color_rgb` is 0x00RRGGBB; output uses BT.709 limited range | | Position/size | `x/y` is the top-left of the conservatively measured text box and is clamped inside the frame. If the box is too large, only that slot is paused; it resumes after the settings or frame size change. Text is never shrunk, truncated, or wrapped | | `gvfg_set_channel_osd_visible()` | `visible` accepts only 0/1; hiding keeps the settings, and showing does not require Set again. Showing a slot that was never set or has been cleared returns `GVFG_ESTATE` | | `gvfg_clear_channel_osd()` | Disables and clears the slot; it must be set again afterwards. The other slot is not affected | | Settings lifetime | Settings are not kept after `gvfg_destroy()`; the application keeps whatever it needs to restore | - `GVFG_OK`: the call succeeded; frames already delivered do not change. - `GVFG_EINVAL`: NULL pointer, or an invalid string, font, size, slot, or visibility value. - `GVFG_ESTATE`: the channel is not open, or a slot that was never set is being shown. - `GVFG_EIO`: measurement, allocation, or other processing failure. For the full calling sequence and example, see [Guide: OSD example](../GVFG_CUSTOMER_API.md#osd-example). ### 3.4 `gvfg_render_osd_frame_bgra` ```c gvfg_status_t gvfg_render_osd_frame_bgra( /* [in] */ uint32_t video_width, /* [in] */ uint32_t video_height, /* [in] */ const gvfg_channel_osd_config_t *slot0, /* [in] */ const gvfg_channel_osd_config_t *slot1, /* [out] */ gvfg_osd_bitmap_t *out_bitmap); ``` Produces a transparent OSD overlay the same size as the video, for an FPGA or another component to composite. - Needs no capture handle; `video_width`/`video_height` is the target video size in pixels. - The output is top-down BGRA8888 with premultiplied alpha, `stride = width * 4`, and contains no video pixels. - Pass NULL for `slot0`/`slot1` to omit that slot; with both NULL the output is fully transparent. Slot 1 is composited over slot 0. - `x/y` are frame coordinates clamped inside the frame; a text box larger than the frame skips that slot. - The output is valid until the next call to this function on the same thread (including a failed call), thread exit, or DLL unload; copy it before any asynchronous transfer. - `GVFG_EINVAL`: invalid arguments or dimensions (including a total byte size above `UINT32_MAX`). - `GVFG_EIO`: allocation or rendering failure. On failure the output is empty. - This function does not affect the channel's GPU OSD. ## 4. Image types used by Playback The following types are defined directly in `gvfg_playback.h`; no extra backend header is needed. That header contains Playback's public types and functions; this section covers the image types, and playback operations are in section 5. ### 4.1 Preview types This section describes the data types used by Playback; functions and error codes are in section 5. `gvfg_preview_pixel_format_t`: | Member | Value | Meaning | | ---------------------------------------- | ---:| ---------------------------------------------------------------------- | | `GVFG_PREVIEW_PIXFMT_YUY2` | 1 | Packed 8-bit YUV 4:2:2, Y0 U0 Y1 V0; map Capture formats explicitly | | `GVFG_PREVIEW_PIXFMT_Y210` | 2 | Packed 10-bit YUV 4:2:2 in 16-bit containers | | `GVFG_PREVIEW_PIXFMT_GRAY16` | 4 | One 16-bit unsigned grayscale component per pixel | | `GVFG_PREVIEW_PIXFMT_RGBA16` | 5 | Four 16-bit UNORM components per pixel: R, G, B, A | | `GVFG_PREVIEW_PIXFMT_DICOM_YBR_FULL_422` | 6 | Four 16-bit words per pixel pair: Y0, Y1, Cb, Cr, right-aligned to bit_depth | `gvfg_preview_frame_t`: | Field | Meaning | | -------------------- | ----------------------------------------------------------------------- | | `data`, `data_size` | Caller-owned frame pointer and byte count | | `width`, `height` | Frame size in pixels | | `pixel_format` | `gvfg_preview_pixel_format_t` | | `bit_depth` | Frame bit depth | | `row_bytes` | Source row stride; usually `gvfg_frame_t.row_stride_bytes` | | `frame_id` | Frame identifier; usually `gvfg_frame_t.frame_id` | `gvfg_preview_info_t`: | Field | Meaning | | ------------------------------- | ---------------------------------------- | | `active` | Non-zero when the preview pipeline is active | | `width`, `height`, `bit_depth` | Most recently used frame information | | `pixel_format[32]` | Null-terminated format name | | `adapter_name[160]` | Null-terminated D3D adapter name | | `adapter_index` | Index of the adapter in use | `gvfg_preview_stats_t`: | Field | Meaning | | ------------------ | ---------------------------------------------------------------------------- | | `present_fps` | Rate of successful Presents over the last five seconds | | `presented_frames` | Cumulative number of successfully presented frames | | `skipped_presents` | Cumulative presents skipped by the preview; not the total frames dropped by capture or recording | ## 5. Unified Playback API The public header is `gvfg_playback.h`; link `gvfg_playback.lib` and deploy `gvfg_playback.dll`. MinGW uses `libgvfg_playback.dll.a`. `gvfg_playback` is an opaque handle. `config.struct_size` must be set to the size of the config struct; call `gvfg_playback_default_config()` first to fill in the defaults. The audio format `gvfg_audio_playback_format_t` contains sample_rate, channels, and bits_per_sample; signed interleaved PCM16 is currently supported. | Function | Behavior | |---|---| | `gvfg_playback_default_config(config)` | Default audio-video mode, External master, 100 ms preroll, 48 kHz stereo PCM16 | | `gvfg_playback_create(out)` | Creates a handle without starting output | | `gvfg_playback_attach_window(p, hwnd)` | Sets the HWND; NULL means no picture output while the video timeline is still consumed | | `gvfg_playback_start(p, config)` | Starts the selected video-only, audio-only, or audio-video mode | | `gvfg_playback_submit_video(p, frame)` | Copies the image and timestamp into the shared playback queue | | `gvfg_playback_submit_audio(p, pcm, bytes, timestamp_ns)` | Copies PCM and builds the source sample timeline from SDK delivery time | | `gvfg_playback_present_image(p, image)` | Synchronously displays a single image on a stopped handle with an attached HWND; needs no start or PTS; returns EOUTPUT when the image was not actually presented | | `gvfg_playback_enable_audio_reconnect(p)` | Optional, before start; after the audio output fails in audio-video mode, automatically retries the Windows default output device | | `gvfg_playback_set_volume(p, gain)` | PCM16 software volume, range 0.0 to 2.0 | | `gvfg_playback_set_sync_enabled(p, enabled)` | 0 plays streams independently with no automatic resync; 1 enables sync; default 1 | | `gvfg_playback_reset_timeline(p)` | Discards pending data and rebuilds the timeline with the original config | | `gvfg_playback_stop(p)` | Stops playback and discards pending data; can be called repeatedly | | `gvfg_playback_destroy(p)` | Stops and destroys; NULL is safely ignored | | `gvfg_playback_get_preview_info(p, info)` | Video output information | | `gvfg_playback_get_preview_stats(p, stats)` | GPU/presentation statistics | | `gvfg_playback_set_signal_connected(p, connected)` | Forwards the signal state from the UI thread: 0 shows the helper's built-in NO SIGNAL card, 1 hides it | | `gvfg_playback_strerror(status)` | Static English error string; must not be freed | The status codes are OK, EINVAL, ESTATE, EOUTPUT, EQUEUE_FULL, EDISCONTINUITY, and EAUDIO. Queue pressure automatically degrades playback and skips stale data; the caller does not need to stop capture because of it. The preview may skip stale frames; a successful submit does not guarantee that every image is actually displayed. Audio and independent recording are not affected by this preview policy. After submit returns, the caller can release the SDK frame immediately; for present_image the data must stay valid until the function returns. Control operations (including present_image) must be serialized by the caller; separate video and audio producers may submit concurrently. Stop/reset cancel; they are not a lossless EOS drain. For the complete flow and compilable submission examples, see the [Unified Playback Guide](../GVFG_PLAYBACK_API.md). ### 5.1 `gvfg_playback_config_t` Call `gvfg_playback_default_config(&config)` first; you do not need to fill in struct_size yourself. Start copies the config; it only accepts a stopped handle and does not stop existing playback on the caller's behalf. Typical users keep the defaults for `max_video_frames`, `max_audio_ms`, and `max_video_bytes`. These are advanced capacity limits to change only for specific memory or pending-capacity requirements; they do not represent a fixed playback latency. | Field | Default | Limits and meaning | |---|---|---| | `struct_size` | `sizeof(gvfg_playback_config_t)` | Must equal the current full struct size | | `mode` | `GVFG_PLAYBACK_AUDIO_VIDEO` | Video-only=1, Audio-only=2, Audio-video=3 | | `master` | `GVFG_PLAYBACK_MASTER_EXTERNAL` | External=0, Audio=1, Video=2; video-only forces External, audio-only forces Audio | | `audio_format.sample_rate` | 48000 | 1–384000 Hz when audio is enabled; passing validation does not mean the Windows device supports it | | `audio_format.channels` | 2 | 1–32 when audio is enabled | | `audio_format.bits_per_sample` | 16 | Must be 16 when audio is enabled; signed interleaved PCM | | `preroll_ms` | 100 | 1–1000 ms; initial/rebuffer coverage required for the enabled streams | | `max_video_frames` | 32 | 1–600; maximum pending video frames; must be valid even for audio-only | | `max_audio_ms` | 1000 | At least preroll_ms and at most 10000; includes the shared queue and output-side pending audio | | `max_video_bytes` | 256 MiB | Must be greater than 0; includes pending and in-process video | With External/Audio master, the preview allows expired frames to be retired and GPU-busy skips; it is not lossless frame-by-frame output. Video master does not enable automatic expiry; bounded buffers also do not guarantee that every frame is accepted forever if output cannot keep up. Choosing a mode does not change the Capture SDK's settings; Capture audio enable is still managed by the caller. ### 5.2 `gvfg_playback_video_frame_t` | Field | Meaning | |---|---| | `image` | `gvfg_preview_frame_t`: data pointer, usable bytes, size, format, effective bit depth, row stride, frame ID | | `timestamp_ns` | Delivery time in ns on the shared monotonic source timeline; non-zero, strictly increasing per stream, at most INT64_MAX | The image supports YUY2, Y210, GRAY16, RGBA16, and DICOM YBR_FULL_422, specified with `GVFG_PREVIEW_PIXFMT_*`. Capture `GVFG_PIXFMT_*` values must be mapped explicitly; do not copy the enum integers directly. `data_size` must cover at least `row_bytes * height`, and row_bytes must be large enough for one row of the given format: | Format | Minimum `row_bytes` | |---|---| | YUY2 | `((width + 1) / 2) * 4`; odd widths must still hold a whole 4-byte macropixel | | Y210 | `width * 4` | | GRAY16 | `width * 2` | | RGBA16 | `width * 8` | | DICOM YBR_FULL_422 | `((width + 1) / 2) * 8` | Submit copies the actual image rows. The frame ID is used only for identity/statistics, not to compute the PTS. See section 4 for the image fields and format layouts. ### 5.3 `gvfg_playback_submit_audio()` input | Parameter | Contract | |---|---| | `p` | A started handle with audio enabled | | `pcm` | Non-NULL signed interleaved PCM16, valid until the call returns | | `bytes` | Greater than 0, a multiple of channels × 2, at most 100 ms per packet | | `timestamp_ns` | SDK delivery time in the same source clock domain; greater than the packet duration, non-zero, strictly increasing, at most INT64_MAX | The source start of the first packet is estimated as the timestamp minus the packet duration; after that a continuous sample timeline is maintained that smoothly tracks long-term drift against the delivery clock. If the gap between adjacent delivery timestamps exceeds 250 ms plus the current packet duration, playback switches to independent mode and builds a new audio mapping; capture is not stopped because of it. Duplicate or backwards timestamps still report EDISCONTINUITY. These rules do not provide the hardware capture time, the number of lost samples, or the absolute acoustic latency. ### 5.4 Status codes | Value | Name | Caller action | |---:|---|---| | 0 | `GVFG_PLAYBACK_OK` | Success; a successful submit means accepted, not presented | | -1 | `GVFG_PLAYBACK_EINVAL` | Fix the NULL, format, size, alignment, struct_size, or config range | | -2 | `GVFG_PLAYBACK_ESTATE` | Check whether the handle is started, whether the mode enables that stream, and whether single-image calls are on a stopped handle with a window | | -3 | `GVFG_PLAYBACK_EOUTPUT` | Check WASAPI/GPU/window/memory and the restart flow; do not assume automatic recovery | | -4 | `GVFG_PLAYBACK_EQUEUE_FULL` | Reserved; current APIs do not return it. Queue pressure is handled by the core automatically; a single item larger than the capacity returns EINVAL | | -5 | `GVFG_PLAYBACK_EDISCONTINUITY` | Coordinate the producers and reset the timeline; a new audio format needs stop/start with a new config | | -6 | `GVFG_PLAYBACK_EAUDIO` | Audio monitoring in audio-video mode has been disabled by an output failure, and video continues. Warn once and keep capturing/recording independently. With audio reconnect enabled, keep submitting PCM until it recovers; otherwise only a recreated handle retries audio | In audio-video mode, an audio output failure is reported by audio submit as `EAUDIO`, and video submit continues. If the audio device cannot be opened at audio-video start, start can still succeed and audio submit reports `EAUDIO`. Without audio reconnect, the disabled state persists across stop/start/reset and only a recreated handle retries audio. After `gvfg_playback_enable_audio_reconnect()` is called before start, audio-video mode retries the Windows default output device about once per second; the application keeps submitting new PCM, and audio submit returns OK again once output is restored. Audio-only mode does not retry and still treats it as an output failure. Other asynchronous output errors are reported by later submits. A successful start does not guarantee that later output will work. ### 5.5 Control API details `gvfg_playback_set_sync_enabled(p, enabled)` accepts 0 or 1; other values or a NULL handle return EINVAL. It can be called before start or while running: 0 switches to independent playback immediately with no automatic resync, and 1 resyncs once conditions are stable. The setting persists across stop/start and reset_timeline; a newly created handle defaults to 1. | API | State, ownership, and limits | |---|---| | `default_config(config)` | Does nothing for NULL; otherwise fills in all defaults and struct_size | | `create(out)` | out must not be NULL; on success the caller owns the handle; on failure out is NULL | | `attach_window(p, hwnd)` | Binds the HWND; NULL hides output but keeps the mode and video timeline; does not start automatically | | `start(p, config)` | Must be stopped; resets counters, queues, and clocks; keeps the volume and window already set | | `submit_video(p, frame)` | Started with video enabled; after it returns, whether it succeeded or not, the caller must end its own Capture frame ownership | | `submit_audio(p, pcm, bytes, ts)` | Started with audio enabled; copying completes before a successful return | | `present_image(p, image)` | Requires a stopped handle with an HWND, otherwise ESTATE. Waits synchronously for the work to finish; the data must stay valid until it returns. Returns EOUTPUT if DXGI Present did not accept the image (for example GPU busy or timeout); OK means presented, not that physical scanout has completed | | `enable_audio_reconnect(p)` | Callable only before start (ESTATE while running); affects only audio-video mode; the setting stays with the handle | | `set_volume(p, gain)` | Finite 0.0–2.0; can be set before start; 0 mutes rather than stopping audio | | `reset_timeline(p)` | Cancels old pending data and resets the timeline; keeps the config and resumes playback if it was playing. Check the return value | | `stop(p)` | Stops playback and cancels pending data; can be called repeatedly | | `destroy(p)` | NULL-safe; stops playback and frees the handle | | `get_preview_info(p, info)` | Returns video information; zero values before Preview has been created | | `get_preview_stats(p, stats)` | Returns present FPS/counters; zero values before Preview has been created | | `set_signal_connected(p, connected)` | Accepts only 0/1, default 1. 0 shows the helper's built-in card and 1 hides it. Can be set before attach and persists across stop/start/reset/reattach; serialize with attach/destroy on the HWND thread. The card scales with the window and is freed by detach/destroy. This API does not query Capture, does not change frames or sync, and does not infer the signal from FPS | | `strerror(status)` | Static string, must not be freed; unknown values return "unknown error" text | Every function's full name is `gvfg_playback_` followed by the name in the table. Getter output pointers must not be NULL. Control operations, including present_image, must be serialized by the caller; one video producer and one audio producer may submit concurrently. Playback does not control the Capture handle and does not take over its read/release or channel lifecycle.