Match the GigabyteLib event model

Compared with 82933f8:

- remove the public event-mask setter, getter, mask type, exports, and per-channel mask state

- always register and forward the complete event set created by GvfgCreateEvents

- keep audio enablement as the only event-creation choice exposed to applications

- preserve event polling, signal recovery, format notifications, capture, format switching, zero-copy, and register access

- update customer and architecture documentation to remove the obsolete event-mask controls
This commit is contained in:
Mark.lin
2026-09-14 12:16:53 +08:00
parent 82933f8967
commit 2a3ad7aa6d
9 changed files with 7 additions and 115 deletions
-2
View File
@@ -5,8 +5,6 @@ EXPORTS
gvfg_create
gvfg_destroy
gvfg_open_channel
gvfg_set_channel_event_mask
gvfg_get_channel_event_mask
gvfg_set_channel_zero_copy_enabled
gvfg_get_channel_zero_copy_enabled
gvfg_set_channel_video_format
-26
View File
@@ -231,16 +231,6 @@ extern "C"
GVFG_EVENT_FORMAT_CHANGE_BEGIN = 4
} gvfg_event_type_t;
typedef enum
{
GVFG_EVENT_MASK_NONE = 0,
GVFG_EVENT_MASK_SIGNAL_CONNECTED = 1u << 0,
GVFG_EVENT_MASK_SIGNAL_DISCONNECTED = 1u << 1,
GVFG_EVENT_MASK_STREAM_READY = 1u << 2,
GVFG_EVENT_MASK_FORMAT_CHANGE_BEGIN = 1u << 3,
GVFG_EVENT_MASK_ALL = (1u << 4) - 1u
} gvfg_event_mask_t;
typedef struct
{
/* Set to sizeof(gvfg_event_t) before calling gvfg_poll_channel_event(). */
@@ -321,22 +311,6 @@ extern "C"
_In_ int device_index,
_In_ int channel_index);
/*
* Select events for one channel before gvfg_open_channel(). VIDEO_DMA is
* always registered because frame capture requires it. Disabling plug,
* unplug, or format-change events also disables the corresponding automatic
* signal/format recovery path.
*/
GVFG_API gvfg_status_t gvfg_set_channel_event_mask(
_In_ gvfg_handle handle,
_In_ int channel_index,
_In_ uint32_t event_mask);
GVFG_API gvfg_status_t gvfg_get_channel_event_mask(
_In_ gvfg_handle handle,
_In_ int channel_index,
_Out_ uint32_t *out_event_mask);
/*
* A handle may open both channels of the same device. The first call opens
* the Windows device; the second channel shares that device connection and
@@ -305,12 +305,11 @@ gvfg_status_t GigabyteCaptureSession::get_audio_format(GigabyteAudioInfo &out) c
}
gvfg_status_t GigabyteCaptureSession::set_event_callback(
GigabyteEventCallback callback, void *user, uint32_t eventMask)
GigabyteEventCallback callback, void *user)
{
std::lock_guard<std::mutex> lock(callback_mutex_);
event_callback_ = callback;
event_callback_user_ = user;
event_mask_filter_ = eventMask;
return GVFG_OK;
}
@@ -590,12 +589,7 @@ void GigabyteCaptureSession::event_thread_proc()
void GigabyteCaptureSession::emit_event(gvfg_event_type_t type) const
{
std::lock_guard<std::mutex> lock(callback_mutex_);
uint32_t bit = 0;
if (type == GVFG_EVENT_SIGNAL_CONNECTED) bit = GVFG_EVENT_MASK_SIGNAL_CONNECTED;
if (type == GVFG_EVENT_SIGNAL_DISCONNECTED) bit = GVFG_EVENT_MASK_SIGNAL_DISCONNECTED;
if (type == GVFG_EVENT_STREAM_READY) bit = GVFG_EVENT_MASK_STREAM_READY;
if (type == GVFG_EVENT_FORMAT_CHANGE_BEGIN) bit = GVFG_EVENT_MASK_FORMAT_CHANGE_BEGIN;
if (event_callback_ && (event_mask_filter_ & bit) != 0)
if (event_callback_)
event_callback_(type, event_callback_user_);
}
@@ -50,7 +50,7 @@ namespace gvfg::internal
gvfg_status_t get_device_capabilities(gvfg_device_capabilities_t &out) const;
gvfg_status_t get_sdi_info(gvfg_sdi_info_t &out) const;
gvfg_status_t get_audio_format(GigabyteAudioInfo &out) const;
gvfg_status_t set_event_callback(GigabyteEventCallback callback, void *user, uint32_t eventMask);
gvfg_status_t set_event_callback(GigabyteEventCallback callback, void *user);
gvfg_status_t configure_stream();
gvfg_status_t start_stream();
gvfg_status_t stop_stream();
@@ -96,7 +96,6 @@ namespace gvfg::internal
mutable std::mutex callback_mutex_;
GigabyteEventCallback event_callback_ = nullptr;
void *event_callback_user_ = nullptr;
uint32_t event_mask_filter_ = GVFG_EVENT_MASK_ALL;
mutable std::mutex state_mutex_;
std::vector<uint8_t> copy_buffer_;
bool frame_held_ = false;
+2 -47
View File
@@ -237,7 +237,7 @@ struct gvfg_channel_session_t
stop();
if (session)
{
session->set_event_callback(nullptr, nullptr, 0);
session->set_event_callback(nullptr, nullptr);
session->close();
session.reset();
}
@@ -285,8 +285,7 @@ struct gvfg_channel_session_t
if (!session)
return;
session->set_event_callback(&gvfg_channel_session_t::onSessionEvent,
this,
eventMask);
this);
}
static void onSessionEvent(gvfg_event_type_t event, void *user)
@@ -746,7 +745,6 @@ struct gvfg_channel_session_t
uint32_t selectedChannel = GVFG_CHANNEL_0;
bool zeroCopyRequested = false;
bool audioEnabled = false;
uint32_t eventMask = GVFG_EVENT_MASK_ALL;
uint32_t width = 0;
uint32_t height = 0;
@@ -845,7 +843,6 @@ struct gvfg_handle_t
auto channel = std::make_unique<gvfg_channel_session_t>(channelErrors[slot]);
channel->zeroCopyRequested = zeroCopyRequested[slot];
channel->eventMask = eventMasks[slot];
const gvfg_status_t status = channel->open(index,
channelIndex,
@@ -875,27 +872,6 @@ struct gvfg_handle_t
return GVFG_OK;
}
gvfg_status_t setChannelEventMask(int channelIndex, uint32_t eventMask)
{
if (channelIndex != GVFG_CHANNEL_0 && channelIndex != GVFG_CHANNEL_1)
return GVFG_EINVAL;
if ((eventMask & ~static_cast<uint32_t>(GVFG_EVENT_MASK_ALL)) != 0)
{
channelErrors[static_cast<size_t>(channelIndex)].set(
"gvfg_set_channel_event_mask rejected: event mask contains unsupported bits");
return GVFG_EINVAL;
}
const size_t slot = static_cast<size_t>(channelIndex);
if (channels[slot])
{
channelErrors[slot].set(
"gvfg_set_channel_event_mask rejected: channel is already open");
return GVFG_ESTATE;
}
eventMasks[slot] = eventMask;
return GVFG_OK;
}
gvfg_status_t setChannelVideoFormat(int channelIndex, gvfg_pixel_format_t format)
{
gvfg_channel_session_t *channel = findChannel(channelIndex);
@@ -951,7 +927,6 @@ struct gvfg_handle_t
std::array<ChannelErrorState, 2> channelErrors;
std::wstring devicePath;
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;
std::array<bool, 2> zeroCopyRequested{false, false};
std::array<gvfg_pixel_format_t, 2> requestedFormats{GVFG_PIXFMT_YUY2, GVFG_PIXFMT_YUY2};
@@ -1017,26 +992,6 @@ extern "C"
return handle->openChannel(device_index, channel_index);
}
gvfg_status_t gvfg_set_channel_event_mask(gvfg_handle handle,
int channel_index,
uint32_t event_mask)
{
if (!handle)
return GVFG_EINVAL;
return handle->setChannelEventMask(channel_index, event_mask);
}
gvfg_status_t gvfg_get_channel_event_mask(gvfg_handle handle,
int channel_index,
uint32_t *out_event_mask)
{
if (!handle || !out_event_mask ||
(channel_index != GVFG_CHANNEL_0 && channel_index != GVFG_CHANNEL_1))
return GVFG_EINVAL;
*out_event_mask = handle->eventMasks[static_cast<size_t>(channel_index)];
return GVFG_OK;
}
gvfg_status_t gvfg_set_channel_zero_copy_enabled(gvfg_handle handle,
int channel_index,
int enabled)