video+geometry: fixed leaks, a segfault and concurrent accesses

This commit is contained in:
David Fort 2018-01-26 15:21:49 +01:00
parent 6e022ae07c
commit 4b240dad0e
4 changed files with 29 additions and 8 deletions

View File

@ -384,6 +384,11 @@ static UINT geometry_plugin_initialize(IWTSPlugin* pPlugin, IWTSVirtualChannelMa
static UINT geometry_plugin_terminated(IWTSPlugin* pPlugin)
{
GEOMETRY_PLUGIN* geometry = (GEOMETRY_PLUGIN*) pPlugin;
GeometryClientContext* context = (GeometryClientContext *)geometry->iface.pInterface;
if (context)
HashTable_Free(context->geometries);
free(geometry->listener_callback);
free(geometry->iface.pInterface);
free(pPlugin);

View File

@ -204,7 +204,7 @@ static UINT video_control_on_data_received(IWTSVirtualChannelCallback* pChannelC
static UINT video_control_send_client_notification(VideoClientContext *context, TSMM_CLIENT_NOTIFICATION *notif)
{
BYTE buf[30];
BYTE buf[100];
wStream *s;
VIDEO_PLUGIN* video = (VIDEO_PLUGIN *)context->handle;
IWTSVirtualChannel* channel;
@ -240,10 +240,10 @@ static UINT video_control_send_client_notification(VideoClientContext *context,
Stream_SealLength(s);
Stream_SetPosition(s, 0);
Stream_Write_UINT32(s, cbSize);
Stream_Free(s, FALSE);
channel = video->control_callback->channel_callback->channel;
ret = channel->Write(channel, cbSize, buf, NULL);
Stream_Free(s, FALSE);
return ret;
}
@ -440,7 +440,9 @@ static UINT video_plugin_initialize(IWTSPlugin* plugin, IWTSVirtualChannelManage
static UINT video_plugin_terminated(IWTSPlugin* pPlugin)
{
VIDEO_PLUGIN* video = (VIDEO_PLUGIN*) pPlugin;
free(video->control_callback);
free(video->data_callback);
free(video->wtsPlugin.pInterface);
free(pPlugin);
return CHANNEL_RC_OK;

View File

@ -115,4 +115,13 @@ void xf_OnChannelDisconnectedEventHandler(rdpContext* context, ChannelDisconnect
{
xf_encomsp_uninit(xfc, (EncomspClientContext*) e->pInterface);
}
else if (strcmp(e->name, VIDEO_CONTROL_DVC_CHANNEL_NAME) == 0)
{
xf_video_control_uninit(xfc, (VideoClientContext*)e->pInterface);
}
else if (strcmp(e->name, VIDEO_DATA_DVC_CHANNEL_NAME) == 0)
{
xf_video_data_uninit(xfc, (VideoClientContext*)e->pInterface);
}
}

View File

@ -315,6 +315,8 @@ static UINT xf_video_PresentationRequest(VideoClientContext* context, TSMM_PRESE
}
xfVideo->currentPresentation = NULL;
xfVideo->droppedFrames = 0;
xfVideo->publishedFrames = 0;
xfPresentationContext_unref(presentation);
}
@ -359,9 +361,6 @@ static void xf_video_timer(xfContext *xfc, TimerEventArgs *timer)
xfPresentationContext *presentation;
xfVideoFrame *peekFrame, *frame = NULL;
if (!xfVideo->currentPresentation)
return;
EnterCriticalSection(&xfVideo->framesLock);
do
{
@ -404,11 +403,15 @@ static void xf_video_timer(xfContext *xfc, TimerEventArgs *timer)
treat_feedback:
if (xfVideo->nextFeedbackTime < timer->now)
{
/* we can compute some feedback only if we have some published frames */
if (xfVideo->publishedFrames)
/* we can compute some feedback only if we have some published frames and
* a current presentation
*/
if (xfVideo->publishedFrames && xfVideo->currentPresentation)
{
UINT32 computedRate;
InterlockedIncrement(&xfVideo->currentPresentation->refCounter);
if (xfVideo->droppedFrames)
{
/**
@ -444,7 +447,7 @@ treat_feedback:
if (computedRate != xfVideo->lastSentRate)
{
TSMM_CLIENT_NOTIFICATION notif;
notif.PresentationId = presentation->PresentationId;
notif.PresentationId = xfVideo->currentPresentation->PresentationId;
notif.NotificationType = TSMM_CLIENT_NOTIFICATION_TYPE_FRAMERATE_OVERRIDE;
if (computedRate == XF_VIDEO_UNLIMITED_RATE)
{
@ -463,6 +466,8 @@ treat_feedback:
WLog_DBG(TAG, "server notified with rate %d published=%d dropped=%d", xfVideo->lastSentRate,
xfVideo->publishedFrames, xfVideo->droppedFrames);
}
xfPresentationContext_unref(xfVideo->currentPresentation);
}
WLog_DBG(TAG, "currentRate=%d published=%d dropped=%d", xfVideo->lastSentRate,