mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-13 01:38:20 +00:00
[obs] improvements to help prevent client timeouts
This commit is contained in:
parent
d899c26617
commit
f8ff3faf78
54
obs/lg.c
54
obs/lg.c
@ -30,6 +30,8 @@ typedef struct
|
|||||||
PLGMPClient lgmp;
|
PLGMPClient lgmp;
|
||||||
PLGMPClientQueue frameQueue;
|
PLGMPClientQueue frameQueue;
|
||||||
gs_texture_t * texture;
|
gs_texture_t * texture;
|
||||||
|
uint8_t * texData;
|
||||||
|
uint32_t linesize;
|
||||||
|
|
||||||
pthread_t frameThread;
|
pthread_t frameThread;
|
||||||
os_sem_t * frameSem;
|
os_sem_t * frameSem;
|
||||||
@ -89,8 +91,9 @@ static void deinit(LGPlugin * this)
|
|||||||
{
|
{
|
||||||
obs_enter_graphics();
|
obs_enter_graphics();
|
||||||
gs_texture_destroy(this->texture);
|
gs_texture_destroy(this->texture);
|
||||||
this->texture = NULL;
|
gs_texture_unmap(this->texture);
|
||||||
obs_leave_graphics();
|
obs_leave_graphics();
|
||||||
|
this->texture = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->state = STATE_STOPPED;
|
this->state = STATE_STOPPED;
|
||||||
@ -140,13 +143,13 @@ static void * frameThread(void * data)
|
|||||||
{
|
{
|
||||||
if (status != LGMP_ERR_QUEUE_EMPTY)
|
if (status != LGMP_ERR_QUEUE_EMPTY)
|
||||||
{
|
{
|
||||||
printf("lgmpClientAdvanceToLast: %s\n", lgmpStatusString(status));
|
|
||||||
os_sem_post(this->frameSem);
|
os_sem_post(this->frameSem);
|
||||||
|
printf("lgmpClientAdvanceToLast: %s\n", lgmpStatusString(status));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os_sem_post(this->frameSem);
|
os_sem_post(this->frameSem);
|
||||||
usleep(100);
|
usleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
lgmpClientUnsubscribe(&this->frameQueue);
|
lgmpClientUnsubscribe(&this->frameQueue);
|
||||||
@ -203,6 +206,16 @@ static void lgVideoTick(void * data, float seconds)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((status = lgmpClientAdvanceToLast(this->frameQueue)) != LGMP_OK)
|
||||||
|
{
|
||||||
|
if (status != LGMP_ERR_QUEUE_EMPTY)
|
||||||
|
{
|
||||||
|
os_sem_post(this->frameSem);
|
||||||
|
printf("lgmpClientAdvanceToLast: %s\n", lgmpStatusString(status));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((status = lgmpClientProcess(this->frameQueue, &msg)) != LGMP_OK)
|
if ((status = lgmpClientProcess(this->frameQueue, &msg)) != LGMP_OK)
|
||||||
{
|
{
|
||||||
if (status == LGMP_ERR_QUEUE_EMPTY)
|
if (status == LGMP_ERR_QUEUE_EMPTY)
|
||||||
@ -217,24 +230,28 @@ static void lgVideoTick(void * data, float seconds)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
obs_enter_graphics();
|
bool updateTexture = false;
|
||||||
|
|
||||||
KVMFRFrame * frame = (KVMFRFrame *)msg.mem;
|
KVMFRFrame * frame = (KVMFRFrame *)msg.mem;
|
||||||
if (this->width != frame->width ||
|
if (this->width != frame->width ||
|
||||||
this->height != frame->height ||
|
this->height != frame->height ||
|
||||||
this->type != frame->type)
|
this->type != frame->type)
|
||||||
{
|
{
|
||||||
if (this->texture)
|
updateTexture = true;
|
||||||
gs_texture_destroy(this->texture);
|
|
||||||
this->texture = NULL;
|
|
||||||
|
|
||||||
this->width = frame->width;
|
this->width = frame->width;
|
||||||
this->height = frame->height;
|
this->height = frame->height;
|
||||||
this->type = frame->type;
|
this->type = frame->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->texture)
|
if (!this->texture || updateTexture)
|
||||||
{
|
{
|
||||||
|
obs_enter_graphics();
|
||||||
|
if (this->texture)
|
||||||
|
{
|
||||||
|
gs_texture_unmap(this->texture);
|
||||||
|
gs_texture_destroy(this->texture);
|
||||||
|
}
|
||||||
|
this->texture = NULL;
|
||||||
|
|
||||||
enum gs_color_format format;
|
enum gs_color_format format;
|
||||||
switch(this->type)
|
switch(this->type)
|
||||||
{
|
{
|
||||||
@ -258,29 +275,28 @@ static void lgVideoTick(void * data, float seconds)
|
|||||||
obs_leave_graphics();
|
obs_leave_graphics();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gs_texture_map(this->texture, &this->texData, &this->linesize);
|
||||||
|
obs_leave_graphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameBuffer * fb = (FrameBuffer *)(((uint8_t*)frame) + frame->offset);
|
FrameBuffer * fb = (FrameBuffer *)(((uint8_t*)frame) + frame->offset);
|
||||||
|
|
||||||
uint8_t *texData;
|
|
||||||
uint32_t linesize;
|
|
||||||
gs_texture_map(this->texture, &texData, &linesize);
|
|
||||||
|
|
||||||
framebuffer_read(
|
framebuffer_read(
|
||||||
fb,
|
fb,
|
||||||
texData, // dst
|
this->texData, // dst
|
||||||
linesize, // dstpitch
|
this->linesize, // dstpitch
|
||||||
frame->height, // height
|
frame->height, // height
|
||||||
frame->width, // width
|
frame->width, // width
|
||||||
4, // bpp
|
4, // bpp
|
||||||
frame->pitch // linepitch
|
frame->pitch // linepitch
|
||||||
);
|
);
|
||||||
gs_texture_unmap(this->texture);
|
|
||||||
|
|
||||||
// gs_texture_set_image(this->texture, frameData, frame->pitch, false);
|
|
||||||
lgmpClientMessageDone(this->frameQueue);
|
lgmpClientMessageDone(this->frameQueue);
|
||||||
os_sem_post(this->frameSem);
|
os_sem_post(this->frameSem);
|
||||||
|
|
||||||
|
obs_enter_graphics();
|
||||||
|
gs_texture_unmap(this->texture);
|
||||||
|
gs_texture_map(this->texture, &this->texData, &this->linesize);
|
||||||
obs_leave_graphics();
|
obs_leave_graphics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user