mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 23:07:18 +00:00
[c-host] revert locking series, this needs more thought
Revert "[c-host] make pointer post function thread safe" This reverts commit3feed7ba07
. Revert "[c-hots] fix incorrect unlock timing" This reverts commit57f1f2d1fe
. Revert "[c-host] increase the queue length and remove debug output" This reverts commitb0f9f15a60
. Revert "[c-host] dxgi: use low level mouse input by default" This reverts commitdc4d820666
. Revert "[c-host] nvfbc: no need for a cursor position event with LGMP" This reverts commite30b54ddb2
.
This commit is contained in:
parent
3feed7ba07
commit
0ca760fad6
@ -25,8 +25,6 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include "common/locking.h"
|
||||
#include "common/event.h"
|
||||
|
||||
#include "windows/mousehook.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <dxgi.h>
|
||||
#include <d3d11.h>
|
||||
@ -84,9 +82,6 @@ struct iface
|
||||
unsigned int stride;
|
||||
CaptureFormat format;
|
||||
|
||||
LG_Lock pointerLock;
|
||||
bool decouplePointer;
|
||||
int hotspotX , hotspotY;
|
||||
int lastPointerX, lastPointerY;
|
||||
bool lastPointerVisible;
|
||||
};
|
||||
@ -101,27 +96,6 @@ static CaptureResult dxgi_releaseFrame();
|
||||
|
||||
// implementation
|
||||
|
||||
static void on_mouseMove(int x, int y)
|
||||
{
|
||||
LG_LOCK(this->pointerLock);
|
||||
|
||||
x -= this->hotspotX;
|
||||
y -= this->hotspotY;
|
||||
|
||||
this->lastPointerX = x;
|
||||
this->lastPointerY = y;
|
||||
|
||||
CapturePointer pointer =
|
||||
{
|
||||
.positionUpdate = true,
|
||||
.visible = this->lastPointerVisible,
|
||||
.x = x,
|
||||
.y = y
|
||||
};
|
||||
LG_UNLOCK(this->pointerLock);
|
||||
this->postPointerBufferFn(pointer);
|
||||
}
|
||||
|
||||
static const char * dxgi_getName()
|
||||
{
|
||||
return "DXGI";
|
||||
@ -159,14 +133,6 @@ static void dxgi_initOptions()
|
||||
.type = OPTION_TYPE_BOOL,
|
||||
.value.x_bool = false
|
||||
},
|
||||
{
|
||||
.module = "dxgi",
|
||||
.name = "decouplePointer",
|
||||
.description = "Use a low level hook to obtain cursor position information",
|
||||
.type = OPTION_TYPE_BOOL,
|
||||
.value.x_bool = true
|
||||
},
|
||||
|
||||
{0}
|
||||
};
|
||||
|
||||
@ -195,18 +161,10 @@ static bool dxgi_create(CaptureGetPointerBuffer getPointerBufferFn, CapturePostP
|
||||
if (this->maxTextures <= 0)
|
||||
this->maxTextures = 1;
|
||||
|
||||
this->useAcquireLock = option_get_bool("dxgi", "useAcquireLock" );
|
||||
this->decouplePointer = option_get_bool("dxgi", "decouplePointer");
|
||||
|
||||
this->useAcquireLock = option_get_bool("dxgi", "useAcquireLock");
|
||||
this->texture = calloc(sizeof(struct Texture), this->maxTextures);
|
||||
this->getPointerBufferFn = getPointerBufferFn;
|
||||
this->postPointerBufferFn = postPointerBufferFn;
|
||||
|
||||
LG_LOCK_INIT(this->pointerLock);
|
||||
|
||||
if (this->decouplePointer)
|
||||
mouseHook_install(on_mouseMove);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -571,8 +529,6 @@ static bool dxgi_deinit()
|
||||
{
|
||||
assert(this);
|
||||
|
||||
mouseHook_remove();
|
||||
|
||||
for(int i = 0; i < this->maxTextures; ++i)
|
||||
{
|
||||
this->texture[i].state = TEXTURE_STATE_UNUSED;
|
||||
@ -756,20 +712,22 @@ static CaptureResult dxgi_capture()
|
||||
frameInfo.PointerPosition.Visible != this->lastPointerVisible
|
||||
)
|
||||
{
|
||||
LG_LOCK(this->pointerLock);
|
||||
|
||||
/* the pointer position is invalid if the pointer is not visible */
|
||||
if (!this->decouplePointer && frameInfo.PointerPosition.Visible)
|
||||
if (frameInfo.PointerPosition.Visible)
|
||||
{
|
||||
pointer.positionUpdate = true;
|
||||
this->lastPointerX = frameInfo.PointerPosition.Position.x;
|
||||
this->lastPointerY = frameInfo.PointerPosition.Position.y;
|
||||
pointer.x =
|
||||
this->lastPointerX =
|
||||
frameInfo.PointerPosition.Position.x;
|
||||
pointer.y =
|
||||
this->lastPointerY =
|
||||
frameInfo.PointerPosition.Position.y;
|
||||
}
|
||||
|
||||
this->lastPointerVisible = frameInfo.PointerPosition.Visible;
|
||||
pointer.visible =
|
||||
this->lastPointerVisible =
|
||||
frameInfo.PointerPosition.Visible;
|
||||
postPointer = true;
|
||||
|
||||
LG_UNLOCK(this->pointerLock);
|
||||
}
|
||||
}
|
||||
|
||||
@ -800,12 +758,6 @@ static CaptureResult dxgi_capture()
|
||||
return CAPTURE_RESULT_ERROR;
|
||||
}
|
||||
|
||||
// needed in decouple mode
|
||||
LG_LOCK(this->pointerLock);
|
||||
this->hotspotX = shapeInfo.HotSpot.x;
|
||||
this->hotspotY = shapeInfo.HotSpot.y;
|
||||
LG_UNLOCK(this->pointerLock);
|
||||
|
||||
pointer.shapeUpdate = true;
|
||||
pointer.width = shapeInfo.Width;
|
||||
pointer.height = shapeInfo.Height;
|
||||
@ -816,12 +768,7 @@ static CaptureResult dxgi_capture()
|
||||
|
||||
// post back the pointer information
|
||||
if (postPointer)
|
||||
{
|
||||
LG_LOCK(this->pointerLock);
|
||||
pointer.visible = this->lastPointerVisible;
|
||||
LG_UNLOCK(this->pointerLock);
|
||||
this->postPointerBufferFn(pointer);
|
||||
}
|
||||
|
||||
return CAPTURE_RESULT_OK;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#define ALIGN_UP(x) ALIGN_DN(x + 0x7F)
|
||||
|
||||
#define LGMP_Q_FRAME_LEN 2
|
||||
#define LGMP_Q_POINTER_LEN 40
|
||||
#define LGMP_Q_POINTER_LEN 20
|
||||
|
||||
static const struct LGMPQueueConfig FRAME_QUEUE_CONFIG =
|
||||
{
|
||||
@ -63,7 +63,6 @@ struct app
|
||||
{
|
||||
PLGMPHost lgmp;
|
||||
|
||||
LG_Lock pointerPostLock;
|
||||
PLGMPHostQueue pointerQueue;
|
||||
PLGMPMemory pointerMemory[LGMP_Q_POINTER_LEN];
|
||||
PLGMPMemory pointerShape;
|
||||
@ -289,6 +288,7 @@ bool captureGetPointerBuffer(void ** data, uint32_t * size)
|
||||
// spin until there is room
|
||||
while(lgmpHostQueuePending(app.pointerQueue) == LGMP_Q_POINTER_LEN)
|
||||
{
|
||||
DEBUG_INFO("pending");
|
||||
if (!app.running)
|
||||
return false;
|
||||
}
|
||||
@ -301,8 +301,6 @@ bool captureGetPointerBuffer(void ** data, uint32_t * size)
|
||||
|
||||
void capturePostPointerBuffer(CapturePointer pointer)
|
||||
{
|
||||
LG_LOCK(app.pointerPostLock);
|
||||
|
||||
PLGMPMemory mem;
|
||||
const bool newClient = lgmpHostQueueNewSubs(app.pointerQueue) > 0;
|
||||
|
||||
@ -353,7 +351,6 @@ void capturePostPointerBuffer(CapturePointer pointer)
|
||||
|
||||
default:
|
||||
DEBUG_ERROR("Invalid pointer type");
|
||||
LG_UNLOCK(app.pointerPostLock);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -363,8 +360,6 @@ void capturePostPointerBuffer(CapturePointer pointer)
|
||||
if ((pointer.shapeUpdate || newClient) && app.pointerShapeValid)
|
||||
flags |= CURSOR_FLAG_SHAPE;
|
||||
|
||||
LG_UNLOCK(app.pointerPostLock);
|
||||
|
||||
LGMP_STATUS status;
|
||||
while ((status = lgmpHostQueuePost(app.pointerQueue, flags, mem)) != LGMP_OK)
|
||||
{
|
||||
@ -422,8 +417,6 @@ int app_main(int argc, char * argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
LG_LOCK_INIT(app.pointerPostLock);
|
||||
|
||||
int exitcode = 0;
|
||||
DEBUG_INFO("IVSHMEM Size : %u MiB", shmDev.size / 1048576);
|
||||
DEBUG_INFO("IVSHMEM Address : 0x%" PRIXPTR, (uintptr_t)shmDev.mem);
|
||||
@ -562,7 +555,6 @@ fail:
|
||||
lgmpHostFree(&app.lgmp);
|
||||
|
||||
ivshmemClose(&shmDev);
|
||||
LG_LOCK_FREE(app.pointerPostLock);
|
||||
return exitcode;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user