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:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user