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:
@@ -83,7 +83,7 @@ SDK 不再呼叫 `IOCTL_PCIES2MM_GET_VIDEO_DONE_INDEX`,也不會在新 IOCTL
|
|||||||
```c
|
```c
|
||||||
gvfg_handle handle = NULL;
|
gvfg_handle handle = NULL;
|
||||||
gvfg_create(&handle);
|
gvfg_create(&handle);
|
||||||
gvfg_set_zero_copy_enabled(handle, 1); /* 0: copy, 1: zero-copy */
|
gvfg_set_channel_zero_copy_enabled(handle, GVFG_CHANNEL_0, 1);
|
||||||
gvfg_open_channel(handle, device_index, GVFG_CHANNEL_0);
|
gvfg_open_channel(handle, device_index, GVFG_CHANNEL_0);
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -100,8 +100,8 @@ gvfg_open_channel(handle, device_index, GVFG_CHANNEL_0);
|
|||||||
`VIDEO_DMA` 為 frame capture 必需,SDK 固定註冊。Plug-in、Unplug 與
|
`VIDEO_DMA` 為 frame capture 必需,SDK 固定註冊。Plug-in、Unplug 與
|
||||||
Format-change driver event 則依 mask 註冊;關閉它們也會停用對應的自動訊號恢復。
|
Format-change driver event 則依 mask 註冊;關閉它們也會停用對應的自動訊號恢復。
|
||||||
|
|
||||||
預設為 copy mode。Device open 後不可切換模式;如需切換,必須 destroy
|
每個 channel 預設為 copy mode。指定 channel open 後不可切換該路模式;
|
||||||
並重建 session。Zero-copy mode 仍使用相同的 `gvfg_read_channel_frame()` /
|
另一條尚未 open 的 channel 仍可獨立選擇。Zero-copy mode 仍使用相同的 `gvfg_read_channel_frame()` /
|
||||||
`gvfg_release_channel_frame()` ownership contract,每次成功 read 都必須 release。
|
`gvfg_release_channel_frame()` ownership contract,每次成功 read 都必須 release。
|
||||||
SDK 會在 open 時 enable zero-copy,並在 close/destroy 時 disable。
|
SDK 會在 open 時 enable zero-copy,並在 close/destroy 時 disable。
|
||||||
|
|
||||||
@@ -128,7 +128,9 @@ gvfg_stop(handle); /* stop both channels */
|
|||||||
runtime API 都明確要求 `channel_index`;不再保留隱含 selected-channel 的舊 API。
|
runtime API 都明確要求 `channel_index`;不再保留隱含 selected-channel 的舊 API。
|
||||||
|
|
||||||
`gvfg_qt_preview.exe` 只使用 public API,主畫面只顯示 input 與 Preview
|
`gvfg_qt_preview.exe` 只使用 public API,主畫面只顯示 input 與 Preview
|
||||||
狀態;IRQ、DMA 等資訊只存在 internal diagnostic tool。
|
狀態;CH0、CH1 各自有 Start、Stop 與獨立 Preview 視窗,可單獨測試,
|
||||||
|
也可同時啟動。第二個 channel open/start 失敗時不會停止已運作的 channel。
|
||||||
|
IRQ、DMA 等資訊只存在 internal diagnostic tool。
|
||||||
|
|
||||||
## Consumer Layout
|
## Consumer Layout
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ bin/gvfg_preview.dll
|
|||||||
```text
|
```text
|
||||||
gvfg_enumerate_devices
|
gvfg_enumerate_devices
|
||||||
-> gvfg_create
|
-> gvfg_create
|
||||||
-> gvfg_set_zero_copy_enabled (optional, before open)
|
-> gvfg_set_channel_zero_copy_enabled (optional, before channel open)
|
||||||
-> gvfg_open_channel
|
-> gvfg_open_channel
|
||||||
-> gvfg_start_channel
|
-> gvfg_start_channel
|
||||||
-> 重複:
|
-> 重複:
|
||||||
@@ -155,9 +155,10 @@ int main(void)
|
|||||||
- `gvfg_enumerate_devices(out_devices, max_devices)`:列舉裝置。傳入
|
- `gvfg_enumerate_devices(out_devices, max_devices)`:列舉裝置。傳入
|
||||||
`NULL, 0` 可只查數量;回傳值是寫入數量或可用裝置數,無裝置時為 `0`。
|
`NULL, 0` 可只查數量;回傳值是寫入數量或可用裝置數,無裝置時為 `0`。
|
||||||
- `gvfg_create(&handle)`:建立 closed session。
|
- `gvfg_create(&handle)`:建立 closed session。
|
||||||
- `gvfg_set_zero_copy_enabled(handle, enabled)`:選用 zero-copy;只能在
|
- `gvfg_set_channel_zero_copy_enabled(handle, channel, enabled)`:替指定 channel
|
||||||
`gvfg_open_channel()` 前呼叫,預設為關閉。
|
選用 zero-copy;只能在該 channel open 前呼叫,預設為關閉。
|
||||||
- `gvfg_get_zero_copy_enabled(handle, &enabled)`:查詢 session 選擇的模式。
|
- `gvfg_get_channel_zero_copy_enabled(handle, channel, &enabled)`:查詢指定
|
||||||
|
channel 選擇的模式。
|
||||||
- `gvfg_open_channel(handle, device_index, channel)`:開啟列舉所得裝置,channel
|
- `gvfg_open_channel(handle, device_index, channel)`:開啟列舉所得裝置,channel
|
||||||
必須為 `GVFG_CHANNEL_0` 或 `GVFG_CHANNEL_1`。
|
必須為 `GVFG_CHANNEL_0` 或 `GVFG_CHANNEL_1`。
|
||||||
- `gvfg_set_channel_event_mask(handle, channel, mask)`:在 open 前設定指定 channel
|
- `gvfg_set_channel_event_mask(handle, channel, mask)`:在 open 前設定指定 channel
|
||||||
|
|||||||
@@ -210,14 +210,14 @@ gvfg_status_t gvfg_get_channel_event_mask(gvfg_handle handle,
|
|||||||
### 1.18 Zero-copy mode selection
|
### 1.18 Zero-copy mode selection
|
||||||
|
|
||||||
```c
|
```c
|
||||||
gvfg_status_t gvfg_set_zero_copy_enabled(gvfg_handle handle, int enabled);
|
gvfg_status_t gvfg_set_channel_zero_copy_enabled(gvfg_handle handle, int channel, int enabled);
|
||||||
gvfg_status_t gvfg_get_zero_copy_enabled(gvfg_handle handle, int *out_enabled);
|
gvfg_status_t gvfg_get_channel_zero_copy_enabled(gvfg_handle handle, int channel, int *out_enabled);
|
||||||
```
|
```
|
||||||
|
|
||||||
- `set` 只能在 `gvfg_create()` 後、`gvfg_open_channel()` 前呼叫。
|
- `set` 只能在 `gvfg_create()` 後、指定 channel open 前呼叫。
|
||||||
- `enabled` 只接受 0(copy)或 1(zero-copy),預設為 0。
|
- `enabled` 只接受 0(copy)或 1(zero-copy);每個 channel 預設為 0。
|
||||||
- Device 已 open 時呼叫 `set` 會回傳 `GVFG_ESTATE`。
|
- 指定 channel 已 open 時呼叫 `set` 會回傳 `GVFG_ESTATE`;不影響另一條 channel。
|
||||||
- `get` 可查詢 session 選定模式;`out_enabled` 不可為 NULL。
|
- `get` 可查詢指定 channel 的模式;`out_enabled` 不可為 NULL。
|
||||||
- Zero-copy mode 的 `frame.data` 為 driver-owned pointer;仍必須以相同 descriptor
|
- Zero-copy mode 的 `frame.data` 為 driver-owned pointer;仍必須以相同 descriptor
|
||||||
呼叫 `gvfg_release_channel_frame()`,且每個 channel 同時最多持有一張 frame。
|
呼叫 `gvfg_release_channel_frame()`,且每個 channel 同時最多持有一張 frame。
|
||||||
- SDK 在 open 時 enable driver zero-copy,在 destroy/close 前 disable。
|
- SDK 在 open 時 enable driver zero-copy,在 destroy/close 前 disable。
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ flowchart LR
|
|||||||
| `channelErrors[2]` | 每條 channel 最近一次詳細錯誤 |
|
| `channelErrors[2]` | 每條 channel 最近一次詳細錯誤 |
|
||||||
| `eventMasks[2]` | open 前設定的 channel event mask |
|
| `eventMasks[2]` | open 前設定的 channel event mask |
|
||||||
| `currentIndex` | 此 handle 已綁定的 device index;`-1` 表示尚未綁定 |
|
| `currentIndex` | 此 handle 已綁定的 device index;`-1` 表示尚未綁定 |
|
||||||
| `zeroCopyRequested` | open 前選擇的共用 delivery mode |
|
| `zeroCopyRequested[2]` | 各 channel open 前獨立選擇的 delivery mode |
|
||||||
|
|
||||||
### `gvfg_channel_session_t`:公開 API facade
|
### `gvfg_channel_session_t`:公開 API facade
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ Zero-copy mode 資料路徑:
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
gvfg_create
|
gvfg_create
|
||||||
-> gvfg_set_zero_copy_enabled(1)
|
-> gvfg_set_channel_zero_copy_enabled(channel, 1)
|
||||||
-> open channel 時 IOCTL_GIGA_ENABLE_FRAME_ZEROCOPY(channel)
|
-> open channel 時 IOCTL_GIGA_ENABLE_FRAME_ZEROCOPY(channel)
|
||||||
-> DMA complete event
|
-> DMA complete event
|
||||||
-> IOCTL_GIGA_ACQUIRE_VIDEO_FRAME_ZEROCOPY(channel, 0xFFFFFFFF)
|
-> IOCTL_GIGA_ACQUIRE_VIDEO_FRAME_ZEROCOPY(channel, 0xFFFFFFFF)
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ struct gvfg_handle_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
int currentIndex = -1;
|
int currentIndex = -1;
|
||||||
bool zeroCopyRequested = false;
|
std::array<bool, 2> zeroCopyRequested{false, false};
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -36,21 +36,48 @@ protected:
|
|||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct ChannelRuntime
|
||||||
|
{
|
||||||
|
bool opened = false;
|
||||||
|
gvfg_preview_handle previewHandle = nullptr;
|
||||||
|
std::atomic<bool> running{false};
|
||||||
|
std::atomic<bool> stopRequested{false};
|
||||||
|
std::atomic<bool> frameAvailable{false};
|
||||||
|
std::thread captureThread;
|
||||||
|
std::atomic<double> getFrameAverageMs{0.0};
|
||||||
|
std::atomic<double> getFrameMaximumMs{0.0};
|
||||||
|
std::atomic<double> getFrameWindowMaximumMs{0.0};
|
||||||
|
std::atomic<uint64_t> getFrameSamples{0};
|
||||||
|
uint64_t previewFailureCount = 0;
|
||||||
|
std::atomic<double> previewCallAverageMs{0.0};
|
||||||
|
std::atomic<double> previewCallMaximumMs{0.0};
|
||||||
|
std::atomic<double> previewCallWindowMaximumMs{0.0};
|
||||||
|
std::atomic<uint64_t> previewCallSamples{0};
|
||||||
|
gvfg_signal_status_t cachedSignalStatus{};
|
||||||
|
bool haveCachedSignalStatus = false;
|
||||||
|
QString lastLoggedInputStatus;
|
||||||
|
#if GVFG_INTERNAL_DIAGNOSTICS
|
||||||
|
uint64_t lastDebugDmaErrors = 0;
|
||||||
|
bool haveDebugBaseline = false;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
void refreshDevices();
|
void refreshDevices();
|
||||||
void showPreviewWindow();
|
void showPreviewWindow(int channel);
|
||||||
void showFullscreenPreviewWindow();
|
void showFullscreenPreviewWindow(int channel);
|
||||||
bool openDevice();
|
bool openDevice();
|
||||||
bool applyOutputFormat();
|
bool openChannel(int channel);
|
||||||
|
bool applyOutputFormat(int channel);
|
||||||
void closeDevice();
|
void closeDevice();
|
||||||
void startCapture();
|
void startCapture(int channel);
|
||||||
void stopCapture();
|
void stopCapture(int channel);
|
||||||
bool applyPreview();
|
void stopAllCaptures();
|
||||||
void updatePreviewSourceSize(const gvfg_signal_status_t &signal);
|
bool applyPreview(int channel);
|
||||||
void updatePreviewSourceSize();
|
void updatePreviewSourceSize(int channel, const gvfg_signal_status_t &signal);
|
||||||
void processPendingEvents();
|
void processPendingEvents();
|
||||||
void updateSignalStatus(bool queryHardware = true);
|
void updateSignalStatus(bool queryHardware = true);
|
||||||
void updateUiState();
|
void updateUiState();
|
||||||
void showError(const QString &apiName, gvfg_status_t status);
|
void showError(const QString &apiName, gvfg_status_t status, int channel = -1);
|
||||||
void openLogFile();
|
void openLogFile();
|
||||||
bool openLogFilePart();
|
bool openLogFilePart();
|
||||||
void rotateLogFileIfNeeded();
|
void rotateLogFileIfNeeded();
|
||||||
@@ -59,40 +86,20 @@ private:
|
|||||||
void writeDiagnosticSnapshot(const QString &statusText);
|
void writeDiagnosticSnapshot(const QString &statusText);
|
||||||
#endif
|
#endif
|
||||||
void appendLog(const QString &message);
|
void appendLog(const QString &message);
|
||||||
void captureReadLoop();
|
void captureReadLoop(int channel);
|
||||||
void joinCaptureThread();
|
void joinCaptureThread(int channel);
|
||||||
|
|
||||||
static constexpr qint64 kMaxLogFileBytes = 20ll * 1024ll * 1024ll;
|
static constexpr qint64 kMaxLogFileBytes = 20ll * 1024ll * 1024ll;
|
||||||
|
|
||||||
Ui::MainWindow *ui_ = nullptr;
|
Ui::MainWindow *ui_ = nullptr;
|
||||||
PreviewWindow *previewWindow_ = nullptr;
|
std::array<PreviewWindow *, 2> previewWindows_{};
|
||||||
std::array<gvfg_device_info_t, GVFG_MAX_DEVICES> devices_{};
|
std::array<gvfg_device_info_t, GVFG_MAX_DEVICES> devices_{};
|
||||||
int deviceCount_ = 0;
|
int deviceCount_ = 0;
|
||||||
gvfg_handle handle_ = nullptr;
|
gvfg_handle handle_ = nullptr;
|
||||||
int selectedChannel_ = GVFG_CHANNEL_0;
|
int selectedDeviceIndex_ = -1;
|
||||||
gvfg_preview_handle previewHandle_ = nullptr;
|
std::array<ChannelRuntime, 2> channels_{};
|
||||||
std::atomic<bool> captureRunning_{false};
|
|
||||||
std::atomic<bool> captureStop_{false};
|
|
||||||
std::atomic<bool> frameAvailable_{false};
|
|
||||||
std::thread captureThread_;
|
|
||||||
std::atomic<double> getFrameAverageMs_{0.0};
|
|
||||||
std::atomic<double> getFrameMaximumMs_{0.0};
|
|
||||||
std::atomic<double> getFrameWindowMaximumMs_{0.0};
|
|
||||||
std::atomic<uint64_t> getFrameSamples_{0};
|
|
||||||
uint64_t previewFailureCount_ = 0;
|
|
||||||
std::atomic<double> previewCallAverageMs_{0.0};
|
|
||||||
std::atomic<double> previewCallMaximumMs_{0.0};
|
|
||||||
std::atomic<double> previewCallWindowMaximumMs_{0.0};
|
|
||||||
std::atomic<uint64_t> previewCallSamples_{0};
|
|
||||||
QTimer *runtimeStatusTimer_ = nullptr;
|
QTimer *runtimeStatusTimer_ = nullptr;
|
||||||
gvfg_signal_status_t cachedSignalStatus_{};
|
|
||||||
bool haveCachedSignalStatus_ = false;
|
|
||||||
QString lastSignalStatusText_;
|
QString lastSignalStatusText_;
|
||||||
QString lastLoggedInputStatus_;
|
|
||||||
#if GVFG_INTERNAL_DIAGNOSTICS
|
|
||||||
uint64_t lastDebugDmaErrors_ = 0;
|
|
||||||
bool haveDebugBaseline_ = false;
|
|
||||||
#endif
|
|
||||||
QFile logFile_;
|
QFile logFile_;
|
||||||
std::mutex logFileMutex_;
|
std::mutex logFileMutex_;
|
||||||
QString logDirPath_;
|
QString logDirPath_;
|
||||||
|
|||||||
@@ -52,102 +52,57 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="startButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Start</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="stopButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Stop</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="showPreviewButton">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Available after capture receives its first video frame</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Open view window</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="fullscreenPreviewButton">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Available after capture receives its first video frame</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Fullscreen window</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<layout class="QHBoxLayout" name="formatLayout">
|
<layout class="QHBoxLayout" name="channelPanelsLayout" stretch="1,1">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="outputFormatLabel">
|
<widget class="QGroupBox" name="channel0GroupBox">
|
||||||
<property name="minimumSize">
|
<property name="title"><string>CH0</string></property>
|
||||||
<size>
|
<layout class="QGridLayout" name="channel0GridLayout">
|
||||||
<width>86</width>
|
<item row="0" column="0"><widget class="QLabel" name="channel0FormatLabel"><property name="text"><string>Output format:</string></property></widget></item>
|
||||||
<height>0</height>
|
<item row="0" column="1">
|
||||||
</size>
|
<widget class="QComboBox" name="ch0OutputFormatCombo">
|
||||||
</property>
|
<property name="toolTip"><string>Requested CH0 capture output format</string></property>
|
||||||
<property name="maximumSize">
|
<item><property name="text"><string>YUY2 (8-bit 4:2:2)</string></property></item>
|
||||||
<size>
|
<item><property name="text"><string>Y210 (10-bit 4:2:2)</string></property></item>
|
||||||
<width>86</width>
|
</widget>
|
||||||
<height>16777215</height>
|
</item>
|
||||||
</size>
|
<item row="0" column="2"><widget class="QCheckBox" name="ch0ZeroCopyCheckBox"><property name="toolTip"><string>Must be selected before opening CH0</string></property><property name="text"><string>Zero-copy</string></property></widget></item>
|
||||||
</property>
|
<item row="1" column="0" colspan="3">
|
||||||
<property name="text">
|
<layout class="QHBoxLayout" name="channel0ButtonLayout">
|
||||||
<string>Output format:</string>
|
<item><widget class="QPushButton" name="ch0StartButton"><property name="text"><string>Start</string></property></widget></item>
|
||||||
</property>
|
<item><widget class="QPushButton" name="ch0StopButton"><property name="text"><string>Stop</string></property></widget></item>
|
||||||
|
<item><widget class="QPushButton" name="ch0PreviewButton"><property name="text"><string>Open view</string></property></widget></item>
|
||||||
|
<item><widget class="QPushButton" name="ch0FullscreenButton"><property name="text"><string>Fullscreen</string></property></widget></item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="outputFormatCombo">
|
<widget class="QGroupBox" name="channel1GroupBox">
|
||||||
<property name="toolTip">
|
<property name="title"><string>CH1</string></property>
|
||||||
<string>Requested capture output format</string>
|
<layout class="QGridLayout" name="channel1GridLayout">
|
||||||
</property>
|
<item row="0" column="0"><widget class="QLabel" name="channel1FormatLabel"><property name="text"><string>Output format:</string></property></widget></item>
|
||||||
<item>
|
<item row="0" column="1">
|
||||||
<property name="text">
|
<widget class="QComboBox" name="ch1OutputFormatCombo">
|
||||||
<string>YUY2 (8-bit 4:2:2)</string>
|
<property name="toolTip"><string>Requested CH1 capture output format</string></property>
|
||||||
</property>
|
<item><property name="text"><string>YUY2 (8-bit 4:2:2)</string></property></item>
|
||||||
</item>
|
<item><property name="text"><string>Y210 (10-bit 4:2:2)</string></property></item>
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Y210 (10-bit 4:2:2)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="0" column="2"><widget class="QCheckBox" name="ch1ZeroCopyCheckBox"><property name="toolTip"><string>Must be selected before opening CH1</string></property><property name="text"><string>Zero-copy</string></property></widget></item>
|
||||||
<widget class="QCheckBox" name="zeroCopyCheckBox">
|
<item row="1" column="0" colspan="3">
|
||||||
<property name="toolTip">
|
<layout class="QHBoxLayout" name="channel1ButtonLayout">
|
||||||
<string>Must be selected before opening the device</string>
|
<item><widget class="QPushButton" name="ch1StartButton"><property name="text"><string>Start</string></property></widget></item>
|
||||||
</property>
|
<item><widget class="QPushButton" name="ch1StopButton"><property name="text"><string>Stop</string></property></widget></item>
|
||||||
<property name="text">
|
<item><widget class="QPushButton" name="ch1PreviewButton"><property name="text"><string>Open view</string></property></widget></item>
|
||||||
<string>Zero-copy</string>
|
<item><widget class="QPushButton" name="ch1FullscreenButton"><property name="text"><string>Fullscreen</string></property></widget></item>
|
||||||
</property>
|
</layout>
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
</layout>
|
||||||
<spacer name="formatSpacer">
|
</widget>
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Orientation::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
|||||||
@@ -287,17 +287,20 @@ extern "C"
|
|||||||
/*
|
/*
|
||||||
* Select driver zero-copy frame delivery.
|
* Select driver zero-copy frame delivery.
|
||||||
*
|
*
|
||||||
* Call after gvfg_create() and before gvfg_open_channel(). The default is
|
* Call after gvfg_create() and before opening the selected channel. The
|
||||||
* disabled. Once a device is open the mode cannot be changed. In zero-copy
|
* default is disabled independently for each channel. Once that channel is
|
||||||
|
* open its mode cannot be changed. In zero-copy
|
||||||
* mode, gvfg_read_channel_frame() returns driver-owned memory and every
|
* mode, gvfg_read_channel_frame() returns driver-owned memory and every
|
||||||
* successful read must be paired with gvfg_release_channel_frame().
|
* successful read must be paired with gvfg_release_channel_frame().
|
||||||
*/
|
*/
|
||||||
GVFG_API gvfg_status_t gvfg_set_zero_copy_enabled(
|
GVFG_API gvfg_status_t gvfg_set_channel_zero_copy_enabled(
|
||||||
_In_ gvfg_handle handle,
|
_In_ gvfg_handle handle,
|
||||||
|
_In_ int channel_index,
|
||||||
_In_ int enabled);
|
_In_ int enabled);
|
||||||
|
|
||||||
GVFG_API gvfg_status_t gvfg_get_zero_copy_enabled(
|
GVFG_API gvfg_status_t gvfg_get_channel_zero_copy_enabled(
|
||||||
_In_ gvfg_handle handle,
|
_In_ gvfg_handle handle,
|
||||||
|
_In_ int channel_index,
|
||||||
_Out_ int *out_enabled);
|
_Out_ int *out_enabled);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -222,14 +222,6 @@ struct gvfg_channel_session_t
|
|||||||
return GVFG_OK;
|
return GVFG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
gvfg_status_t setZeroCopyEnabled(bool enabled)
|
|
||||||
{
|
|
||||||
if (backend)
|
|
||||||
return reject(GVFG_ESTATE, "set zero copy rejected: channel is already open");
|
|
||||||
zeroCopyRequested = enabled;
|
|
||||||
return GVFG_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
gvfg_status_t start()
|
gvfg_status_t start()
|
||||||
{
|
{
|
||||||
if (!backend)
|
if (!backend)
|
||||||
@@ -828,7 +820,7 @@ struct gvfg_handle_t
|
|||||||
return GVFG_OK;
|
return GVFG_OK;
|
||||||
|
|
||||||
auto channel = std::make_unique<gvfg_channel_session_t>(channelErrors[slot]);
|
auto channel = std::make_unique<gvfg_channel_session_t>(channelErrors[slot]);
|
||||||
channel->zeroCopyRequested = zeroCopyRequested;
|
channel->zeroCopyRequested = zeroCopyRequested[slot];
|
||||||
channel->eventMask = eventMasks[slot];
|
channel->eventMask = eventMasks[slot];
|
||||||
|
|
||||||
const gvfg_status_t status = channel->open(index,
|
const gvfg_status_t status = channel->open(index,
|
||||||
@@ -846,13 +838,18 @@ struct gvfg_handle_t
|
|||||||
return GVFG_OK;
|
return GVFG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
gvfg_status_t setZeroCopyEnabled(bool enabled)
|
gvfg_status_t setChannelZeroCopyEnabled(int channelIndex, bool enabled)
|
||||||
{
|
{
|
||||||
if (deviceConnection)
|
if (channelIndex != GVFG_CHANNEL_0 && channelIndex != GVFG_CHANNEL_1)
|
||||||
return rejectAllChannels(
|
return GVFG_EINVAL;
|
||||||
GVFG_ESTATE,
|
const size_t slot = static_cast<size_t>(channelIndex);
|
||||||
"gvfg_set_zero_copy_enabled rejected: a device is already open");
|
if (channels[slot])
|
||||||
zeroCopyRequested = enabled;
|
{
|
||||||
|
channelErrors[slot].set(
|
||||||
|
"gvfg_set_channel_zero_copy_enabled rejected: channel is already open");
|
||||||
|
return GVFG_ESTATE;
|
||||||
|
}
|
||||||
|
zeroCopyRequested[slot] = enabled;
|
||||||
return GVFG_OK;
|
return GVFG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -912,7 +909,7 @@ struct gvfg_handle_t
|
|||||||
std::array<std::unique_ptr<gvfg_channel_session_t>, 2> channels;
|
std::array<std::unique_ptr<gvfg_channel_session_t>, 2> channels;
|
||||||
std::array<uint32_t, 2> eventMasks{GVFG_EVENT_MASK_ALL, GVFG_EVENT_MASK_ALL};
|
std::array<uint32_t, 2> eventMasks{GVFG_EVENT_MASK_ALL, GVFG_EVENT_MASK_ALL};
|
||||||
int currentIndex = -1;
|
int currentIndex = -1;
|
||||||
bool zeroCopyRequested = false;
|
std::array<bool, 2> zeroCopyRequested{false, false};
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
@@ -987,22 +984,30 @@ extern "C"
|
|||||||
return GVFG_OK;
|
return GVFG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
gvfg_status_t gvfg_set_zero_copy_enabled(gvfg_handle handle, int enabled)
|
gvfg_status_t gvfg_set_channel_zero_copy_enabled(gvfg_handle handle,
|
||||||
|
int channel_index,
|
||||||
|
int enabled)
|
||||||
{
|
{
|
||||||
if (!handle)
|
if (!handle ||
|
||||||
|
(channel_index != GVFG_CHANNEL_0 && channel_index != GVFG_CHANNEL_1))
|
||||||
return GVFG_EINVAL;
|
return GVFG_EINVAL;
|
||||||
if (enabled != 0 && enabled != 1)
|
if (enabled != 0 && enabled != 1)
|
||||||
return handle->rejectAllChannels(
|
{
|
||||||
GVFG_EINVAL,
|
handle->channelErrors[static_cast<size_t>(channel_index)].set(
|
||||||
"gvfg_set_zero_copy_enabled rejected: enabled must be 0 or 1");
|
"gvfg_set_channel_zero_copy_enabled rejected: enabled must be 0 or 1");
|
||||||
return handle->setZeroCopyEnabled(enabled != 0);
|
return GVFG_EINVAL;
|
||||||
|
}
|
||||||
|
return handle->setChannelZeroCopyEnabled(channel_index, enabled != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
gvfg_status_t gvfg_get_zero_copy_enabled(gvfg_handle handle, int *out_enabled)
|
gvfg_status_t gvfg_get_channel_zero_copy_enabled(gvfg_handle handle,
|
||||||
|
int channel_index,
|
||||||
|
int *out_enabled)
|
||||||
{
|
{
|
||||||
if (!handle || !out_enabled)
|
if (!handle || !out_enabled ||
|
||||||
|
(channel_index != GVFG_CHANNEL_0 && channel_index != GVFG_CHANNEL_1))
|
||||||
return GVFG_EINVAL;
|
return GVFG_EINVAL;
|
||||||
*out_enabled = handle->zeroCopyRequested ? 1 : 0;
|
*out_enabled = handle->zeroCopyRequested[static_cast<size_t>(channel_index)] ? 1 : 0;
|
||||||
return GVFG_OK;
|
return GVFG_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user