SenseApiDesc,xcbWindow: port to sscl coro framework

SenseApiDesc's exported API now uses coro pointers instead of
CPS fn pointers.
* Do not build this version of SMO with the Livox drivers enabled,
  because SMO has been changed at the smocore level to use coros
  when calling into stimbuffAPI libs. But the Livox drivers
  haven't yet been ported from CPS to coros.

xcbWindow has been ported to expose coros to SMO in its
senseApiDesc exported iface.
This commit is contained in:
2026-05-25 08:21:46 -04:00
parent b5fa20a2b8
commit 3e19d39853
10 changed files with 173 additions and 280 deletions
+2 -1
View File
@@ -28,7 +28,8 @@ if(ENABLE_STIMBUFFAPI_xcbWindow)
target_link_libraries(xcbWindow
Boost::system Boost::log
${XCB_LIBRARIES}
attachmentSupport)
attachmentSupport
spinscale)
# Install rules
install(TARGETS xcbWindow
+19 -23
View File
@@ -8,7 +8,7 @@
#include <xcb/xcb.h>
#include <user/senseApiDesc.h>
#include <user/deviceAttachmentSpec.h>
#include <spinscale/cps/callback.h>
#include <spinscale/co/invokers.h>
#include <xcbXorg/xcbXorg.h>
#include "xcbWindow.h"
@@ -214,7 +214,7 @@ AttachedWindow::~AttachedWindow()
} // namespace xcb_window
// SenseApi functions
static int xcbWindow_initializeInd(void)
static sscl::co::ViralNonPostingInvoker<int> xcbWindow_initializeCInd(void)
{
if (!smoHooksPtr)
{
@@ -257,10 +257,10 @@ static int xcbWindow_initializeInd(void)
": Failed to get required function pointers from libxcbXorg");
}
return 0;
co_return 0;
}
static int xcbWindow_finalizeInd(void)
static sscl::co::ViralNonPostingInvoker<int> xcbWindow_finalizeCInd(void)
{
g_attachedWindows.clear();
@@ -271,14 +271,13 @@ static int xcbWindow_finalizeInd(void)
xcbXorg.fns = { nullptr, nullptr, nullptr, nullptr, nullptr };
}
return 0;
co_return 0;
}
static void xcbWindow_attachDeviceReq(
static sscl::co::ViralNonPostingInvoker<smo::stim_buff::StimBuffDeviceOpResult>
xcbWindow_attachDeviceCReq(
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& desc,
const std::shared_ptr<sscl::ComponentThread>& componentThread,
sscl::cps::Callback<smo::stim_buff::sal_mlo_attachDeviceReqCbFn> cb
)
const std::shared_ptr<sscl::ComponentThread>& componentThread)
{
// Not used yet, but may be used later.
(void)componentThread;
@@ -289,21 +288,19 @@ static void xcbWindow_attachDeviceReq(
} catch (const std::exception& exc) {
std::cerr << __func__ << ": Exception while attaching X11 window: "
<< exc.what() << "\n";
cb.callbackFn(false, desc);
return;
co_return smo::stim_buff::StimBuffDeviceOpResult{false, desc};
}
std::cout << __func__ << ": Attached X11 window:\n "
<< g_attachedWindows.back()->stringify()
<< "\n";
cb.callbackFn(true, desc);
co_return smo::stim_buff::StimBuffDeviceOpResult{true, desc};
}
static void xcbWindow_detachDeviceReq(
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec,
sscl::cps::Callback<smo::stim_buff::sal_mlo_detachDeviceReqCbFn> cb
)
static sscl::co::ViralNonPostingInvoker<smo::stim_buff::StimBuffDeviceOpResult>
xcbWindow_detachDeviceCReq(
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec)
{
auto it = std::find_if(g_attachedWindows.begin(), g_attachedWindows.end(),
[&spec](const std::unique_ptr<xcb_window::AttachedWindow>& window) {
@@ -316,15 +313,14 @@ static void xcbWindow_detachDeviceReq(
std::cerr << __func__ << ": Device not found for detachment:\n"
<< spec->stringify() << "\n";
cb.callbackFn(false, spec);
return;
co_return smo::stim_buff::StimBuffDeviceOpResult{false, spec};
}
g_attachedWindows.erase(it);
std::cout << __func__ << ": Detached X11 window device:\n"
<< spec->stringify() << "\n";
cb.callbackFn(true, spec);
co_return smo::stim_buff::StimBuffDeviceOpResult{true, spec};
}
// SenseApi descriptor
@@ -332,10 +328,10 @@ static smo::stim_buff::StimBuffApiDesc xcbWindowApiDesc = {
.name = "xcb",
.exportedQualeIfaceApis = { { "visual-qualeiface" } },
.sal_mgmt_libOps = {
.initializeInd = xcbWindow_initializeInd,
.finalizeInd = xcbWindow_finalizeInd,
.attachDeviceReq = xcbWindow_attachDeviceReq,
.detachDeviceReq = xcbWindow_detachDeviceReq
.initializeCInd = xcbWindow_initializeCInd,
.finalizeCInd = xcbWindow_finalizeCInd,
.attachDeviceCReq = xcbWindow_attachDeviceCReq,
.detachDeviceCReq = xcbWindow_detachDeviceCReq
}
};