[c-host] revert locking series, this needs more thought

Revert "[c-host] make pointer post function thread safe"

This reverts commit 3feed7ba07.

Revert "[c-hots] fix incorrect unlock timing"

This reverts commit 57f1f2d1fe.

Revert "[c-host] increase the queue length and remove debug output"

This reverts commit b0f9f15a60.

Revert "[c-host] dxgi: use low level mouse input by default"

This reverts commit dc4d820666.

Revert "[c-host] nvfbc: no need for a cursor position event with LGMP"

This reverts commit e30b54ddb2.
This commit is contained in:
Geoffrey McRae
2020-01-29 23:22:49 +11:00
parent 3feed7ba07
commit 0ca760fad6
4 changed files with 59 additions and 121 deletions

View File

@@ -20,17 +20,15 @@ Place, Suite 330, Boston, MA 02111-1307 USA
#include "interface/capture.h"
#include "interface/platform.h"
#include "common/windebug.h"
#include "windows/mousehook.h"
#include "common/option.h"
#include "common/framebuffer.h"
#include "common/event.h"
#include "common/thread.h"
#include "common/locking.h"
#include <assert.h>
#include <stdlib.h>
#include <windows.h>
#include "windows/mousehook.h"
#include <NvFBC/nvFBC.h>
#include "wrapper.h"
@@ -53,9 +51,8 @@ struct iface
NvFBCFrameGrabInfo grabInfo;
LGEvent * frameEvent;
LGEvent * cursorEvent;
LGEvent * cursorEvents[2];
LG_Lock cursorLock;
int mouseX, mouseY, mouseHotX, mouseHotY;
bool mouseVisible;
};
@@ -81,20 +78,9 @@ static void getDesktopSize(unsigned int * width, unsigned int * height)
static void on_mouseMove(int x, int y)
{
LG_LOCK(this->cursorLock);
this->mouseX = x;
this->mouseY = y;
CapturePointer pointer =
{
.positionUpdate = true,
.visible = this->mouseVisible,
.x = this->mouseX - this->mouseHotX,
.y = this->mouseY - this->mouseHotY
};
LG_UNLOCK(this->cursorLock);
this->postPointerBufferFn(pointer);
lgSignalEvent(this->cursorEvents[0]);
}
static const char * nvfbc_getName()
@@ -108,7 +94,7 @@ static void nvfbc_initOptions()
{
{
.module = "nvfbc",
.name = "decouplePointer",
.name = "decoupleCursor",
.description = "Capture the cursor seperately",
.type = OPTION_TYPE_BOOL,
.value.x_bool = true
@@ -164,12 +150,10 @@ static bool nvfbc_create(
return false;
}
this->seperateCursor = option_get_bool("nvfbc", "decouplePointer");
this->seperateCursor = option_get_bool("nvfbc", "decoupleCursor");
this->getPointerBufferFn = getPointerBufferFn;
this->postPointerBufferFn = postPointerBufferFn;
LG_LOCK_INIT(this->cursorLock);
return true;
}
@@ -195,10 +179,11 @@ static bool nvfbc_init()
return false;
}
this->cursorEvents[0] = lgCreateEvent(true, 10);
mouseHook_install(on_mouseMove);
if (this->seperateCursor)
this->cursorEvent = lgWrapEvent(event);
this->cursorEvents[1] = lgWrapEvent(event);
DEBUG_INFO("Cursor mode : %s", this->seperateCursor ? "decoupled" : "integrated");
@@ -216,6 +201,7 @@ static bool nvfbc_init()
static void nvfbc_stop()
{
this->stop = true;
lgSignalEvent(this->cursorEvents[0]);
lgSignalEvent(this->frameEvent);
if (this->pointerThread)
@@ -228,6 +214,13 @@ static void nvfbc_stop()
static bool nvfbc_deinit()
{
mouseHook_remove();
if (this->cursorEvents[0])
{
lgFreeEvent(this->cursorEvents[0]);
this->cursorEvents[0] = NULL;
}
return true;
}
@@ -238,7 +231,6 @@ static void nvfbc_free()
if (this->frameEvent)
lgFreeEvent(this->frameEvent);
LG_LOCK_FREE(this->cursorLock);
free(this);
this = NULL;
NvFBCFree();
@@ -331,40 +323,47 @@ static int pointerThread(void * unused)
{
while(!this->stop)
{
if (!lgWaitEvent(this->cursorEvent, 1000))
LGEvent * events[2];
memcpy(&events, &this->cursorEvents, sizeof(LGEvent *) * 2);
if (!lgWaitEvents(events, this->seperateCursor ? 2 : 1, false, 1000))
continue;
if (this->stop)
break;
CaptureResult result;
void * data;
uint32_t size;
if (!this->getPointerBufferFn(&data, &size))
{
DEBUG_WARN("failed to get a pointer buffer");
continue;
}
CapturePointer pointer = { 0 };
result = NvFBCToSysGetCursor(this->nvfbc, &pointer, data, size);
if (result != CAPTURE_RESULT_OK)
if (this->seperateCursor && events[1])
{
DEBUG_WARN("NvFBCToSysGetCursor failed");
continue;
void * data;
uint32_t size;
if (!this->getPointerBufferFn(&data, &size))
{
DEBUG_WARN("failed to get a pointer buffer");
continue;
}
result = NvFBCToSysGetCursor(this->nvfbc, &pointer, data, size);
if (result != CAPTURE_RESULT_OK)
{
DEBUG_WARN("NvFBCToSysGetCursor failed");
continue;
}
this->mouseVisible = pointer.visible;
this->mouseHotX = pointer.x;
this->mouseHotY = pointer.y;
}
LG_LOCK(this->cursorLock);
this->mouseVisible = pointer.visible;
this->mouseHotX = pointer.x;
this->mouseHotY = pointer.y;
if (events[0])
{
pointer.positionUpdate = true;
pointer.visible = this->mouseVisible;
pointer.x = this->mouseX - this->mouseHotX;
pointer.y = this->mouseY - this->mouseHotY;
}
pointer.positionUpdate = true;
pointer.x = this->mouseX - this->mouseHotX;
pointer.y = this->mouseY - this->mouseHotY;
LG_UNLOCK(this->cursorLock);
this->postPointerBufferFn(pointer);
}