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
|
||||
gvfg_handle handle = NULL;
|
||||
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);
|
||||
```
|
||||
|
||||
@@ -100,8 +100,8 @@ gvfg_open_channel(handle, device_index, GVFG_CHANNEL_0);
|
||||
`VIDEO_DMA` 為 frame capture 必需,SDK 固定註冊。Plug-in、Unplug 與
|
||||
Format-change driver event 則依 mask 註冊;關閉它們也會停用對應的自動訊號恢復。
|
||||
|
||||
預設為 copy mode。Device open 後不可切換模式;如需切換,必須 destroy
|
||||
並重建 session。Zero-copy mode 仍使用相同的 `gvfg_read_channel_frame()` /
|
||||
每個 channel 預設為 copy mode。指定 channel open 後不可切換該路模式;
|
||||
另一條尚未 open 的 channel 仍可獨立選擇。Zero-copy mode 仍使用相同的 `gvfg_read_channel_frame()` /
|
||||
`gvfg_release_channel_frame()` ownership contract,每次成功 read 都必須 release。
|
||||
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。
|
||||
|
||||
`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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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。
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -126,7 +126,7 @@ struct gvfg_handle_t
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
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 showPreviewWindow();
|
||||
void showFullscreenPreviewWindow();
|
||||
void showPreviewWindow(int channel);
|
||||
void showFullscreenPreviewWindow(int channel);
|
||||
bool openDevice();
|
||||
bool applyOutputFormat();
|
||||
bool openChannel(int channel);
|
||||
bool applyOutputFormat(int channel);
|
||||
void closeDevice();
|
||||
void startCapture();
|
||||
void stopCapture();
|
||||
bool applyPreview();
|
||||
void updatePreviewSourceSize(const gvfg_signal_status_t &signal);
|
||||
void updatePreviewSourceSize();
|
||||
void startCapture(int channel);
|
||||
void stopCapture(int channel);
|
||||
void stopAllCaptures();
|
||||
bool applyPreview(int channel);
|
||||
void updatePreviewSourceSize(int channel, const gvfg_signal_status_t &signal);
|
||||
void processPendingEvents();
|
||||
void updateSignalStatus(bool queryHardware = true);
|
||||
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();
|
||||
bool openLogFilePart();
|
||||
void rotateLogFileIfNeeded();
|
||||
@@ -59,40 +86,20 @@ private:
|
||||
void writeDiagnosticSnapshot(const QString &statusText);
|
||||
#endif
|
||||
void appendLog(const QString &message);
|
||||
void captureReadLoop();
|
||||
void joinCaptureThread();
|
||||
void captureReadLoop(int channel);
|
||||
void joinCaptureThread(int channel);
|
||||
|
||||
static constexpr qint64 kMaxLogFileBytes = 20ll * 1024ll * 1024ll;
|
||||
|
||||
Ui::MainWindow *ui_ = nullptr;
|
||||
PreviewWindow *previewWindow_ = nullptr;
|
||||
std::array<PreviewWindow *, 2> previewWindows_{};
|
||||
std::array<gvfg_device_info_t, GVFG_MAX_DEVICES> devices_{};
|
||||
int deviceCount_ = 0;
|
||||
gvfg_handle handle_ = nullptr;
|
||||
int selectedChannel_ = GVFG_CHANNEL_0;
|
||||
gvfg_preview_handle previewHandle_ = nullptr;
|
||||
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};
|
||||
int selectedDeviceIndex_ = -1;
|
||||
std::array<ChannelRuntime, 2> channels_{};
|
||||
QTimer *runtimeStatusTimer_ = nullptr;
|
||||
gvfg_signal_status_t cachedSignalStatus_{};
|
||||
bool haveCachedSignalStatus_ = false;
|
||||
QString lastSignalStatusText_;
|
||||
QString lastLoggedInputStatus_;
|
||||
#if GVFG_INTERNAL_DIAGNOSTICS
|
||||
uint64_t lastDebugDmaErrors_ = 0;
|
||||
bool haveDebugBaseline_ = false;
|
||||
#endif
|
||||
QFile logFile_;
|
||||
std::mutex logFileMutex_;
|
||||
QString logDirPath_;
|
||||
|
||||
@@ -52,102 +52,57 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="formatLayout">
|
||||
<layout class="QHBoxLayout" name="channelPanelsLayout" stretch="1,1">
|
||||
<item>
|
||||
<widget class="QLabel" name="outputFormatLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>86</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>86</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Output format:</string>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="channel0GroupBox">
|
||||
<property name="title"><string>CH0</string></property>
|
||||
<layout class="QGridLayout" name="channel0GridLayout">
|
||||
<item row="0" column="0"><widget class="QLabel" name="channel0FormatLabel"><property name="text"><string>Output format:</string></property></widget></item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="ch0OutputFormatCombo">
|
||||
<property name="toolTip"><string>Requested CH0 capture output format</string></property>
|
||||
<item><property name="text"><string>YUY2 (8-bit 4:2:2)</string></property></item>
|
||||
<item><property name="text"><string>Y210 (10-bit 4:2:2)</string></property></item>
|
||||
</widget>
|
||||
</item>
|
||||
<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>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="channel0ButtonLayout">
|
||||
<item><widget class="QPushButton" name="ch0StartButton"><property name="text"><string>Start</string></property></widget></item>
|
||||
<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>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="outputFormatCombo">
|
||||
<property name="toolTip">
|
||||
<string>Requested capture output format</string>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>YUY2 (8-bit 4:2:2)</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Y210 (10-bit 4:2:2)</string>
|
||||
</property>
|
||||
</item>
|
||||
<widget class="QGroupBox" name="channel1GroupBox">
|
||||
<property name="title"><string>CH1</string></property>
|
||||
<layout class="QGridLayout" name="channel1GridLayout">
|
||||
<item row="0" column="0"><widget class="QLabel" name="channel1FormatLabel"><property name="text"><string>Output format:</string></property></widget></item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="ch1OutputFormatCombo">
|
||||
<property name="toolTip"><string>Requested CH1 capture output format</string></property>
|
||||
<item><property name="text"><string>YUY2 (8-bit 4:2:2)</string></property></item>
|
||||
<item><property name="text"><string>Y210 (10-bit 4:2:2)</string></property></item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="zeroCopyCheckBox">
|
||||
<property name="toolTip">
|
||||
<string>Must be selected before opening the device</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Zero-copy</string>
|
||||
</property>
|
||||
</widget>
|
||||
<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>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="channel1ButtonLayout">
|
||||
<item><widget class="QPushButton" name="ch1StartButton"><property name="text"><string>Start</string></property></widget></item>
|
||||
<item><widget class="QPushButton" name="ch1StopButton"><property name="text"><string>Stop</string></property></widget></item>
|
||||
<item><widget class="QPushButton" name="ch1PreviewButton"><property name="text"><string>Open view</string></property></widget></item>
|
||||
<item><widget class="QPushButton" name="ch1FullscreenButton"><property name="text"><string>Fullscreen</string></property></widget></item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="formatSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Orientation::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
@@ -287,17 +287,20 @@ extern "C"
|
||||
/*
|
||||
* Select driver zero-copy frame delivery.
|
||||
*
|
||||
* Call after gvfg_create() and before gvfg_open_channel(). The default is
|
||||
* disabled. Once a device is open the mode cannot be changed. In zero-copy
|
||||
* Call after gvfg_create() and before opening the selected channel. The
|
||||
* 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
|
||||
* 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_ int channel_index,
|
||||
_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_ int channel_index,
|
||||
_Out_ int *out_enabled);
|
||||
|
||||
/*
|
||||
|
||||
@@ -222,14 +222,6 @@ struct gvfg_channel_session_t
|
||||
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()
|
||||
{
|
||||
if (!backend)
|
||||
@@ -828,7 +820,7 @@ struct gvfg_handle_t
|
||||
return GVFG_OK;
|
||||
|
||||
auto channel = std::make_unique<gvfg_channel_session_t>(channelErrors[slot]);
|
||||
channel->zeroCopyRequested = zeroCopyRequested;
|
||||
channel->zeroCopyRequested = zeroCopyRequested[slot];
|
||||
channel->eventMask = eventMasks[slot];
|
||||
|
||||
const gvfg_status_t status = channel->open(index,
|
||||
@@ -846,13 +838,18 @@ struct gvfg_handle_t
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
gvfg_status_t setZeroCopyEnabled(bool enabled)
|
||||
gvfg_status_t setChannelZeroCopyEnabled(int channelIndex, bool enabled)
|
||||
{
|
||||
if (deviceConnection)
|
||||
return rejectAllChannels(
|
||||
GVFG_ESTATE,
|
||||
"gvfg_set_zero_copy_enabled rejected: a device is already open");
|
||||
zeroCopyRequested = enabled;
|
||||
if (channelIndex != GVFG_CHANNEL_0 && channelIndex != GVFG_CHANNEL_1)
|
||||
return GVFG_EINVAL;
|
||||
const size_t slot = static_cast<size_t>(channelIndex);
|
||||
if (channels[slot])
|
||||
{
|
||||
channelErrors[slot].set(
|
||||
"gvfg_set_channel_zero_copy_enabled rejected: channel is already open");
|
||||
return GVFG_ESTATE;
|
||||
}
|
||||
zeroCopyRequested[slot] = enabled;
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
@@ -912,7 +909,7 @@ struct gvfg_handle_t
|
||||
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};
|
||||
int currentIndex = -1;
|
||||
bool zeroCopyRequested = false;
|
||||
std::array<bool, 2> zeroCopyRequested{false, false};
|
||||
};
|
||||
|
||||
extern "C"
|
||||
@@ -987,22 +984,30 @@ extern "C"
|
||||
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;
|
||||
if (enabled != 0 && enabled != 1)
|
||||
return handle->rejectAllChannels(
|
||||
GVFG_EINVAL,
|
||||
"gvfg_set_zero_copy_enabled rejected: enabled must be 0 or 1");
|
||||
return handle->setZeroCopyEnabled(enabled != 0);
|
||||
{
|
||||
handle->channelErrors[static_cast<size_t>(channel_index)].set(
|
||||
"gvfg_set_channel_zero_copy_enabled rejected: enabled must be 0 or 1");
|
||||
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;
|
||||
*out_enabled = handle->zeroCopyRequested ? 1 : 0;
|
||||
*out_enabled = handle->zeroCopyRequested[static_cast<size_t>(channel_index)] ? 1 : 0;
|
||||
return GVFG_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user