xcb: added xcb_stop and xcb_initOptions support

Added basic functions and the necessary variables for the
`.initOptions` and `.stop` items in the capture interface.
This commit is contained in:
vmfortress 2021-10-30 14:14:18 -04:00 committed by Geoffrey McRae
parent bb74a9d9c8
commit 2824238b4d
2 changed files with 27 additions and 0 deletions

View File

@ -55,3 +55,4 @@ vroad <396351+vroad@users.noreply.github.com> (vroad)
williamvds <w.vigolodasilva@gmail.com> (williamvds)
SytheZN <sythe.zn@gmail.com> (SytheZN)
RTXUX <wyf@rtxux.xyz> (RTXUX)
Vincent LaRocca <vincentmlarocca@gmail.com> (VMFortress)

View File

@ -20,6 +20,7 @@
#include "interface/capture.h"
#include "interface/platform.h"
#include "common/option.h"
#include "common/debug.h"
#include "common/event.h"
#include <string.h>
@ -33,6 +34,7 @@
struct xcb
{
bool initialized;
bool stop;
xcb_connection_t * xcb;
xcb_screen_t * xcbScreen;
uint32_t seg;
@ -61,6 +63,16 @@ static const char * xcb_getName(void)
return "XCB";
}
static void xcb_initOptions(void)
{
struct Option options[] =
{
{0}
};
option_register(options);
}
static bool xcb_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostPointerBuffer postPointerBufferFn)
{
DEBUG_ASSERT(!this);
@ -86,6 +98,7 @@ static bool xcb_init(void)
lgResetEvent(this->frameEvent);
this->stop = false;
this->xcb = xcb_connect(NULL, NULL);
if (!this->xcb || xcb_connection_has_error(this->xcb))
{
@ -131,6 +144,17 @@ fail:
return false;
}
static void xcb_stop(void)
{
this->stop = true;
if(this->pointerThread)
{
lgJoinThread(this->pointerThread, NULL);
this->pointerThread = NULL;
}
}
static bool xcb_deinit(void)
{
DEBUG_ASSERT(this);
@ -232,9 +256,11 @@ struct CaptureInterface Capture_XCB =
{
.shortName = "XCB",
.asyncCapture = true,
.initOptions = xcb_initOptions,
.getName = xcb_getName,
.create = xcb_create,
.init = xcb_init,
.stop = xcb_stop,
.deinit = xcb_deinit,
.free = xcb_free,
.capture = xcb_capture,