Fixed missing lock during buffer submit.

This commit is contained in:
akallabeth 2020-06-18 08:42:24 +02:00
parent 1bc48b058f
commit c902f583d0
2 changed files with 15 additions and 10 deletions

View File

@ -304,6 +304,7 @@ static void wl_post_disconnect(freerdp* instance)
static BOOL handle_uwac_events(freerdp* instance, UwacDisplay* display)
{
BOOL rc;
UwacEvent event;
wlfContext* context;
@ -329,9 +330,11 @@ static BOOL handle_uwac_events(freerdp* instance, UwacDisplay* display)
break;
case UWAC_EVENT_FRAME_DONE:
if (UwacWindowSubmitBuffer(context->window, false) != UWAC_SUCCESS)
EnterCriticalSection(&context->critical);
rc = UwacWindowSubmitBuffer(context->window, false);
LeaveCriticalSection(&context->critical);
if (rc != UWAC_SUCCESS)
return FALSE;
break;
case UWAC_EVENT_POINTER_ENTER:

View File

@ -737,27 +737,29 @@ UwacReturnCode UwacWindowGetDrawingBufferGeometry(UwacWindow* window, UwacSize*
UwacReturnCode UwacWindowSubmitBuffer(UwacWindow* window, bool copyContentForNextFrame)
{
UwacBuffer* drawingBuffer;
UwacBuffer* nextBuffer;
UwacBuffer* currentDrawingBuffer;
UwacBuffer* nextDrawingBuffer;
UwacBuffer* pendingBuffer;
if (window->drawingBufferIdx < 0)
return UWAC_ERROR_INTERNAL;
drawingBuffer = &window->buffers[window->drawingBufferIdx];
currentDrawingBuffer = &window->buffers[window->drawingBufferIdx];
if ((window->pendingBufferIdx >= 0) || !drawingBuffer->dirty)
if ((window->pendingBufferIdx >= 0) || !currentDrawingBuffer->dirty)
return UWAC_SUCCESS;
window->pendingBufferIdx = window->drawingBufferIdx;
nextBuffer = UwacWindowFindFreeBuffer(window, &window->drawingBufferIdx);
nextDrawingBuffer = UwacWindowFindFreeBuffer(window, &window->drawingBufferIdx);
pendingBuffer = &window->buffers[window->pendingBufferIdx];
if ((!nextBuffer) || (window->drawingBufferIdx < 0))
if ((!nextDrawingBuffer) || (window->drawingBufferIdx < 0))
return UWAC_ERROR_NOMEMORY;
if (copyContentForNextFrame)
memcpy(nextBuffer->data, drawingBuffer->data, window->stride * window->height);
memcpy(nextDrawingBuffer->data, pendingBuffer->data, window->stride * window->height);
UwacSubmitBufferPtr(window, drawingBuffer);
UwacSubmitBufferPtr(window, pendingBuffer);
return UWAC_SUCCESS;
}