Add independent dual-channel preview controls

Compared with f380a8a:

- Let CH0 and CH1 open, start, stop, and preview independently while sharing one device connection.

- Give each channel its own capture worker, preview window, frame ownership, runtime status, and failure reporting.

- Expose channel-indexed zero-copy selection to match the driver IOCTL contract and keep output format selection independent per channel.

- Prevent immediate timeout responses from hot-looping and flooding the Qt event queue.

- Align the CH0 and CH1 controls in equal-width channel panels and update the public and internal documentation.

Validation: Qt uic parsing and git diff --check passed; no build or hardware validation was run.
This commit is contained in:
Mark.lin
2026-08-27 17:13:22 +08:00
parent f380a8a143
commit 226369df0e
11 changed files with 539 additions and 523 deletions
+5 -4
View File
@@ -36,7 +36,7 @@ bin/gvfg_preview.dll
```text
gvfg_enumerate_devices
-> gvfg_create
-> gvfg_set_zero_copy_enabled (optional, before open)
-> gvfg_set_channel_zero_copy_enabled (optional, before channel open)
-> gvfg_open_channel
-> gvfg_start_channel
-> 重複:
@@ -155,9 +155,10 @@ int main(void)
- `gvfg_enumerate_devices(out_devices, max_devices)`:列舉裝置。傳入
`NULL, 0` 可只查數量;回傳值是寫入數量或可用裝置數,無裝置時為 `0`。
- `gvfg_create(&handle)`:建立 closed session。
- `gvfg_set_zero_copy_enabled(handle, enabled)`:選用 zero-copy;只能在
`gvfg_open_channel()` 前呼叫,預設為關閉。
- `gvfg_get_zero_copy_enabled(handle, &enabled)`:查詢 session 選擇的模式。
- `gvfg_set_channel_zero_copy_enabled(handle, channel, enabled)`:替指定 channel
選用 zero-copy;只能在該 channel open 前呼叫,預設為關閉。
- `gvfg_get_channel_zero_copy_enabled(handle, channel, &enabled)`:查詢指定
channel 選擇的模式。
- `gvfg_open_channel(handle, device_index, channel)`:開啟列舉所得裝置,channel
必須為 `GVFG_CHANNEL_0` 或 `GVFG_CHANNEL_1`。
- `gvfg_set_channel_event_mask(handle, channel, mask)`:在 open 前設定指定 channel
+6 -6
View File
@@ -210,14 +210,14 @@ gvfg_status_t gvfg_get_channel_event_mask(gvfg_handle handle,
### 1.18 Zero-copy mode selection
```c
gvfg_status_t gvfg_set_zero_copy_enabled(gvfg_handle handle, int enabled);
gvfg_status_t gvfg_get_zero_copy_enabled(gvfg_handle handle, int *out_enabled);
gvfg_status_t gvfg_set_channel_zero_copy_enabled(gvfg_handle handle, int channel, int enabled);
gvfg_status_t gvfg_get_channel_zero_copy_enabled(gvfg_handle handle, int channel, int *out_enabled);
```
- `set` 只能在 `gvfg_create()` 後、`gvfg_open_channel()` 前呼叫。
- `enabled` 只接受 0(copy)或 1(zero-copy),預設為 0。
- Device 已 open 時呼叫 `set` 會回傳 `GVFG_ESTATE`。
- `get` 可查詢 session 選定模式;`out_enabled` 不可為 NULL。
- `set` 只能在 `gvfg_create()` 後、指定 channel open 前呼叫。
- `enabled` 只接受 0(copy)或 1(zero-copy);每個 channel 預設為 0。
- 指定 channel 已 open 時呼叫 `set` 會回傳 `GVFG_ESTATE`;不影響另一條 channel。
- `get` 可查詢指定 channel 的模式;`out_enabled` 不可為 NULL。
- Zero-copy mode 的 `frame.data` 為 driver-owned pointer;仍必須以相同 descriptor
呼叫 `gvfg_release_channel_frame()`,且每個 channel 同時最多持有一張 frame。
- SDK 在 open 時 enable driver zero-copy,在 destroy/close 前 disable。
+1 -1
View File
@@ -42,7 +42,7 @@ flowchart LR
| `channelErrors[2]` | 每條 channel 最近一次詳細錯誤 |
| `eventMasks[2]` | open 前設定的 channel event mask |
| `currentIndex` | 此 handle 已綁定的 device index;`-1` 表示尚未綁定 |
| `zeroCopyRequested` | open 前選擇的共用 delivery mode |
| `zeroCopyRequested[2]` | 各 channel open 前獨立選擇的 delivery mode |
### `gvfg_channel_session_t`:公開 API facade
+1 -1
View File
@@ -99,7 +99,7 @@ Zero-copy mode 資料路徑:
```text
gvfg_create
-> gvfg_set_zero_copy_enabled(1)
-> gvfg_set_channel_zero_copy_enabled(channel, 1)
-> open channel 時 IOCTL_GIGA_ENABLE_FRAME_ZEROCOPY(channel)
-> DMA complete event
-> IOCTL_GIGA_ACQUIRE_VIDEO_FRAME_ZEROCOPY(channel, 0xFFFFFFFF)
+1 -1
View File
@@ -126,7 +126,7 @@ struct gvfg_handle_t
};
int currentIndex = -1;
bool zeroCopyRequested = false;
std::array<bool, 2> zeroCopyRequested{false, false};
};
```