mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-10 08:38:20 +00:00
[c-host] make pointer post function thread safe
This commit is contained in:
parent
57f1f2d1fe
commit
3feed7ba07
@ -63,6 +63,7 @@ struct app
|
|||||||
{
|
{
|
||||||
PLGMPHost lgmp;
|
PLGMPHost lgmp;
|
||||||
|
|
||||||
|
LG_Lock pointerPostLock;
|
||||||
PLGMPHostQueue pointerQueue;
|
PLGMPHostQueue pointerQueue;
|
||||||
PLGMPMemory pointerMemory[LGMP_Q_POINTER_LEN];
|
PLGMPMemory pointerMemory[LGMP_Q_POINTER_LEN];
|
||||||
PLGMPMemory pointerShape;
|
PLGMPMemory pointerShape;
|
||||||
@ -300,6 +301,8 @@ bool captureGetPointerBuffer(void ** data, uint32_t * size)
|
|||||||
|
|
||||||
void capturePostPointerBuffer(CapturePointer pointer)
|
void capturePostPointerBuffer(CapturePointer pointer)
|
||||||
{
|
{
|
||||||
|
LG_LOCK(app.pointerPostLock);
|
||||||
|
|
||||||
PLGMPMemory mem;
|
PLGMPMemory mem;
|
||||||
const bool newClient = lgmpHostQueueNewSubs(app.pointerQueue) > 0;
|
const bool newClient = lgmpHostQueueNewSubs(app.pointerQueue) > 0;
|
||||||
|
|
||||||
@ -350,6 +353,7 @@ void capturePostPointerBuffer(CapturePointer pointer)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
DEBUG_ERROR("Invalid pointer type");
|
DEBUG_ERROR("Invalid pointer type");
|
||||||
|
LG_UNLOCK(app.pointerPostLock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,6 +363,8 @@ void capturePostPointerBuffer(CapturePointer pointer)
|
|||||||
if ((pointer.shapeUpdate || newClient) && app.pointerShapeValid)
|
if ((pointer.shapeUpdate || newClient) && app.pointerShapeValid)
|
||||||
flags |= CURSOR_FLAG_SHAPE;
|
flags |= CURSOR_FLAG_SHAPE;
|
||||||
|
|
||||||
|
LG_UNLOCK(app.pointerPostLock);
|
||||||
|
|
||||||
LGMP_STATUS status;
|
LGMP_STATUS status;
|
||||||
while ((status = lgmpHostQueuePost(app.pointerQueue, flags, mem)) != LGMP_OK)
|
while ((status = lgmpHostQueuePost(app.pointerQueue, flags, mem)) != LGMP_OK)
|
||||||
{
|
{
|
||||||
@ -416,6 +422,8 @@ int app_main(int argc, char * argv[])
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LG_LOCK_INIT(app.pointerPostLock);
|
||||||
|
|
||||||
int exitcode = 0;
|
int exitcode = 0;
|
||||||
DEBUG_INFO("IVSHMEM Size : %u MiB", shmDev.size / 1048576);
|
DEBUG_INFO("IVSHMEM Size : %u MiB", shmDev.size / 1048576);
|
||||||
DEBUG_INFO("IVSHMEM Address : 0x%" PRIXPTR, (uintptr_t)shmDev.mem);
|
DEBUG_INFO("IVSHMEM Address : 0x%" PRIXPTR, (uintptr_t)shmDev.mem);
|
||||||
@ -554,6 +562,7 @@ fail:
|
|||||||
lgmpHostFree(&app.lgmp);
|
lgmpHostFree(&app.lgmp);
|
||||||
|
|
||||||
ivshmemClose(&shmDev);
|
ivshmemClose(&shmDev);
|
||||||
|
LG_LOCK_FREE(app.pointerPostLock);
|
||||||
return exitcode;
|
return exitcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user