fixed some memory leaks arround DVC and RDPEGFX

This commit is contained in:
erbth
2014-08-08 15:19:49 +02:00
parent 64501b895b
commit a8257b5201
6 changed files with 56 additions and 13 deletions

View File

@@ -429,6 +429,8 @@ int dvcman_close_channel(IWTSVirtualChannelManager* pChannelMgr, UINT32 ChannelI
IWTSVirtualChannel* ichannel;
DrdynvcClientContext* context;
DVCMAN* dvcman = (DVCMAN*) pChannelMgr;
printf("\t\tdvcman_close_channel\n");
channel = (DVCMAN_CHANNEL*) dvcman_find_channel_by_id(pChannelMgr, ChannelId);
@@ -476,7 +478,7 @@ int dvcman_receive_channel_data_first(IWTSVirtualChannelManager* pChannelMgr, UI
Stream_Release(channel->dvc_data);
channel->dvc_data = StreamPool_Take(channel->dvcman->pool, length);
Stream_AddRef(channel->dvc_data);
//Stream_AddRef(channel->dvc_data);
return 0;
}
@@ -498,7 +500,8 @@ int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 C
if (channel->dvc_data)
{
/* Fragmented data */
if (Stream_GetPosition(channel->dvc_data) + dataSize > (UINT32) Stream_Capacity(channel->dvc_data))
//if (Stream_GetPosition(channel->dvc_data) + dataSize > (UINT32) Stream_Capacity(channel->dvc_data))
if (Stream_GetPosition(channel->dvc_data) + dataSize > (UINT32) Stream_Length(channel->dvc_data))
{
DEBUG_WARN("data exceeding declared length!");
Stream_Release(channel->dvc_data);
@@ -508,7 +511,8 @@ int dvcman_receive_channel_data(IWTSVirtualChannelManager* pChannelMgr, UINT32 C
Stream_Write(channel->dvc_data, Stream_Pointer(data), dataSize);
if (((size_t) Stream_GetPosition(channel->dvc_data)) >= Stream_Capacity(channel->dvc_data))
//if (((size_t) Stream_GetPosition(channel->dvc_data)) >= Stream_Capacity(channel->dvc_data)-1)
if (((size_t) Stream_GetPosition(channel->dvc_data)) >= Stream_Length(channel->dvc_data)-1)
{
Stream_SealLength(channel->dvc_data);
Stream_SetPosition(channel->dvc_data, 0);

View File

@@ -129,6 +129,8 @@ int rdpgfx_recv_caps_confirm_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
Stream_Read_UINT32(s, capsSet.version); /* version (4 bytes) */
Stream_Read_UINT32(s, capsDataLength); /* capsDataLength (4 bytes) */
Stream_Read_UINT32(s, capsSet.flags); /* capsData (4 bytes) */
/*TODO: interpret this answer*/
WLog_Print(gfx->log, WLOG_DEBUG, "RecvCapsConfirmPdu: version: 0x%04X flags: 0x%04X",
capsSet.version, capsSet.flags);
@@ -545,6 +547,8 @@ int rdpgfx_recv_solid_fill_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s)
{
context->SolidFill(context, &pdu);
}
free(pdu.fillRects);
return 1;
}
@@ -590,6 +594,8 @@ int rdpgfx_recv_surface_to_surface_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStrea
context->SurfaceToSurface(context, &pdu);
}
free(pdu.destPts);
return 1;
}
@@ -855,6 +861,9 @@ static int rdpgfx_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
}
Stream_Free(s, TRUE);
//free(Stream_Buffer(data));
//Stream_Free(data,TRUE);
return status;
}
@@ -1056,6 +1065,10 @@ int rdpgfx_DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
return -1;
gfx->log = WLog_Get("com.freerdp.gfx.client");
#if 0
WLog_SetLogLevel(gfx->log, WLOG_DEBUG);
#endif
gfx->settings = (rdpSettings*) pEntryPoints->GetRdpSettings(pEntryPoints);
gfx->iface.Initialize = rdpgfx_plugin_initialize;

View File

@@ -138,6 +138,9 @@ int xf_OutputUpdate(xfContext* xfc)
int xf_OutputExpose(xfContext* xfc, int x, int y, int width, int height)
{
/** *********************************
* to be improved
* *********************************/
RECTANGLE_16 invalidRect;
invalidRect.left = x;
@@ -393,11 +396,9 @@ int xf_SurfaceCommand_H264(xfContext* xfc, RdpgfxClientContext* context, RDPGFX_
status = h264_decompress(xfc->h264, bs->data, bs->length, &DstData,
PIXEL_FORMAT_XRGB32, surface->scanline, cmd->left, cmd->top, cmd->width, cmd->height);
gettimeofday(&TDEC2,NULL);
printf("decoding took %d sec %d usec\n",(int)(TDEC2.tv_sec-TDEC1.tv_sec),(int)(TDEC2.tv_usec-TDEC1.tv_usec));
free(bs->data);
//printf("decoding took %d sec %d usec\n",(int)(TDEC2.tv_sec-TDEC1.tv_sec),(int)(TDEC2.tv_usec-TDEC1.tv_usec));
printf("xf_SurfaceCommand_H264: status: %d\n", status);
//printf("xf_SurfaceCommand_H264: status: %d\n", status);
if (status < 0)
return -1;
@@ -454,6 +455,7 @@ int xf_SurfaceCommand_H264(xfContext* xfc, RdpgfxClientContext* context, RDPGFX_
}
region16_uninit(&updateRegion);
region16_uninit(&clippingRects);
#if 0
/* fill with red for now to distinguish from the rest */
@@ -700,6 +702,7 @@ int xf_SurfaceToSurface(RdpgfxClientContext* context, RDPGFX_SURFACE_TO_SURFACE_
rectSrc = &(surfaceToSurface->rectSrc);
destPt = &surfaceToSurface->destPts[0];
/**not needed?*/
surfaceSrc = (xfGfxSurface*) context->GetSurfaceData(context, surfaceToSurface->surfaceIdSrc);
@@ -726,6 +729,8 @@ int xf_SurfaceToSurface(RdpgfxClientContext* context, RDPGFX_SURFACE_TO_SURFACE_
invalidRect.top = destPt->y;
invalidRect.right = destPt->x + rectSrc->right;
invalidRect.bottom = destPt->y + rectSrc->bottom;
/**width,height?*/
region16_union_rect(&(xfc->invalidRegion), &(xfc->invalidRegion), &invalidRect);
}
@@ -759,7 +764,7 @@ int xf_SurfaceToCache(RdpgfxClientContext* context, RDPGFX_SURFACE_TO_CACHE_PDU*
cacheEntry->alpha = surface->alpha;
cacheEntry->scanline = (cacheEntry->width + (cacheEntry->width % 4)) * 4;
cacheEntry->data = (BYTE*) calloc(1, surface->scanline * surface->height);
cacheEntry->data = (BYTE*) calloc(1, cacheEntry->scanline * cacheEntry->height);
if (!cacheEntry->data)
return -1;

View File

@@ -28,6 +28,12 @@
#include <freerdp/codec/color.h>
#include <freerdp/codec/h264.h>
#include <sys/time.h>
#ifdef WITH_OPENH264_ASM
extern int freerdp_image_yuv_to_xrgb_asm(BYTE *pDstData,BYTE **pSrcData,int nWidth,int nHeight,int iStride0,int iStride1);
#endif
#define USE_GRAY_SCALE 0
#define USE_UPCONVERT 0
@@ -340,6 +346,8 @@ static int openh264_decompress(H264_CONTEXT* h264, BYTE* pSrcData, UINT32 SrcSiz
SBufferInfo sBufferInfo;
SSysMEMBuffer* pSystemBuffer;
BYTE* pYUVData[3];
struct timeval T1,T2;
if (!h264->pDecoder)
return -1;
@@ -354,6 +362,7 @@ static int openh264_decompress(H264_CONTEXT* h264, BYTE* pSrcData, UINT32 SrcSiz
ZeroMemory(&sBufferInfo, sizeof(sBufferInfo));
gettimeofday(&T1,NULL);
state = (*h264->pDecoder)->DecodeFrame2(
h264->pDecoder,
pSrcData,
@@ -370,10 +379,13 @@ static int openh264_decompress(H264_CONTEXT* h264, BYTE* pSrcData, UINT32 SrcSiz
if (sBufferInfo.iBufferStatus != 1)
state = (*h264->pDecoder)->DecodeFrame2(h264->pDecoder, NULL, 0, pYUVData, &sBufferInfo);
gettimeofday(&T2,NULL);
printf("\tdecoding took: %u sec %u usec\n",(unsigned int)(T2.tv_sec-T1.tv_sec),(unsigned int)(T2.tv_usec-T1.tv_usec));
pSystemBuffer = &sBufferInfo.UsrData.sSystemBuffer;
#if 1
#if 0
printf("h264_decompress: state=%u, pYUVData=[%p,%p,%p], bufferStatus=%d, width=%d, height=%d, format=%d, stride=[%d,%d]\n",
state, pYUVData[0], pYUVData[1], pYUVData[2], sBufferInfo.iBufferStatus,
pSystemBuffer->iWidth, pSystemBuffer->iHeight, pSystemBuffer->iFormat,
@@ -404,8 +416,15 @@ static int openh264_decompress(H264_CONTEXT* h264, BYTE* pSrcData, UINT32 SrcSiz
if (h264_prepare_rgb_buffer(h264, pSystemBuffer->iWidth, pSystemBuffer->iHeight) < 0)
return -1;
#ifdef WITH_OPENH264_ASM
gettimeofday(&T1,NULL);
freerdp_image_yuv_to_xrgb_asm(h264->data,pYUVData,h264->width,h264->height,pSystemBuffer->iStride[0],pSystemBuffer->iStride[1]);
gettimeofday(&T2,NULL);
printf("\tconverting took: %u sec %u usec\n",(unsigned int)(T2.tv_sec-T1.tv_sec),(unsigned int)(T2.tv_usec-T1.tv_usec));
#else
freerdp_image_copy_yuv420p_to_xrgb(h264->data, h264->scanline, 0, 0,
h264->width, h264->height, pYUVData, pSystemBuffer->iStride, 0, 0);
#endif
return 1;
}
@@ -630,7 +649,7 @@ int h264_decompress(H264_CONTEXT* h264, BYTE* pSrcData, UINT32 SrcSize,
pSrcData = h264_strip_nal_unit_au_delimiter(pSrcData, &SrcSize);
#endif
#if 1
#if 0
printf("h264_decompress: pSrcData=%p, SrcSize=%u, pDstData=%p, nDstStep=%d, nXDst=%d, nYDst=%d, nWidth=%d, nHeight=%d)\n",
pSrcData, SrcSize, *ppDstData, nDstStep, nXDst, nYDst, nWidth, nHeight);
#endif

View File

@@ -106,7 +106,7 @@ static void svc_plugin_process_received(rdpSvcPlugin* plugin, void* pData, UINT3
Stream_Release(plugin->data_in);
plugin->data_in = StreamPool_Take(plugin->pool, totalLength);
Stream_AddRef(plugin->data_in);
//Stream_AddRef(plugin->data_in);
}
s = plugin->data_in;
@@ -115,7 +115,7 @@ static void svc_plugin_process_received(rdpSvcPlugin* plugin, void* pData, UINT3
if (dataFlags & CHANNEL_FLAG_LAST)
{
if (Stream_Capacity(s) != Stream_GetPosition(s))
if (Stream_Length(s) != Stream_GetPosition(s))
{
fprintf(stderr, "svc_plugin_process_received: read error\n");
}
@@ -250,7 +250,7 @@ static void svc_plugin_process_terminated(rdpSvcPlugin* plugin)
if (plugin->data_in)
{
Stream_Free(plugin->data_in, TRUE);
Stream_Release(plugin->data_in);
plugin->data_in = NULL;
}

View File

@@ -155,6 +155,8 @@ wStream* StreamPool_Take(wStreamPool* pool, size_t size)
Stream_SetPosition(s, 0);
Stream_EnsureCapacity(s, size);
Stream_SetLength(s,size);
}
s->pool = pool;