summaryrefslogtreecommitdiffstats
path: root/xorg/server/module/rdpXv.c
diff options
context:
space:
mode:
authorJay Sorg <jay.sorg@gmail.com>2014-09-29 19:41:11 -0700
committerJay Sorg <jay.sorg@gmail.com>2014-09-29 19:41:11 -0700
commit6fc9b8dd8c5aa45eef031f00f4c02634cba8e40c (patch)
treeb0e9016695faaaf60fc23b0024081b2a0885834f /xorg/server/module/rdpXv.c
parent372f2477131ba51c91be8b40a36b4e79297e5d01 (diff)
downloadxrdp-proprietary-6fc9b8dd8c5aa45eef031f00f4c02634cba8e40c.tar.gz
xrdp-proprietary-6fc9b8dd8c5aa45eef031f00f4c02634cba8e40c.zip
Xorg: avoid excessive malloc / free
Diffstat (limited to 'xorg/server/module/rdpXv.c')
-rw-r--r--xorg/server/module/rdpXv.c49
1 files changed, 38 insertions, 11 deletions
diff --git a/xorg/server/module/rdpXv.c b/xorg/server/module/rdpXv.c
index d055c68b..0a9bc867 100644
--- a/xorg/server/module/rdpXv.c
+++ b/xorg/server/module/rdpXv.c
@@ -420,6 +420,22 @@ stretch_RGB32_RGB32(int *src, int src_width, int src_height,
return 0;
}
+/******************************************************************************/
+/* returns error */
+static CARD32
+rdpDeferredXv(OsTimerPtr timer, CARD32 now, pointer arg)
+{
+ rdpPtr dev;
+
+ LLOGLN(0, ("rdpDeferredXv:"));
+ dev = (rdpPtr) arg;
+ dev->xv_timer_schedualed = 0;
+ dev->xv_data_bytes = 0;
+ g_free(dev->xv_data);
+ dev->xv_data = 0;
+ return 0;
+}
+
/*****************************************************************************/
/* see hw/xfree86/common/xf86xv.c for info */
static int
@@ -442,7 +458,6 @@ xrdpVidPutImage(ScrnInfoPtr pScrn,
int jndex;
int num_clips;
int error;
- void *mem;
RegionRec dreg;
BoxRec box;
@@ -450,14 +465,31 @@ xrdpVidPutImage(ScrnInfoPtr pScrn,
LLOGLN(10, ("xrdpVidPutImage: src_x %d srcy_y %d", src_x, src_y));
dev = XRDPPTR(pScrn);
+ if (dev->xv_timer_schedualed)
+ {
+ TimerCancel(dev->xv_timer);
+ dev->xv_timer = TimerSet(dev->xv_timer, 0, 2000, rdpDeferredXv, dev);
+ }
+ else
+ {
+ dev->xv_timer_schedualed = 1;
+ dev->xv_timer = TimerSet(dev->xv_timer, 0, 2000, rdpDeferredXv, dev);
+ }
+
index = width * height * 4 + drw_w * drw_h * 4 + 64;
- mem = g_malloc(index, 0);
- if (mem == NULL)
+ if (index > dev->xv_data_bytes)
{
- LLOGLN(0, ("xrdpVidPutImage: memory alloc error"));
- return Success;
+ g_free(dev->xv_data);
+ dev->xv_data = g_malloc(index, 0);
+ if (dev->xv_data == NULL)
+ {
+ LLOGLN(0, ("xrdpVidPutImage: memory alloc error"));
+ dev->xv_data_bytes = 0;
+ return Success;
+ }
+ dev->xv_data_bytes = index;
}
- rgborg32 = (int *) RDPALIGN(mem, 16);
+ rgborg32 = (int *) RDPALIGN(dev->xv_data, 16);
rgbend32 = rgborg32 + width * height;
rgbend32 = (int *) RDPALIGN(rgbend32, 16);
error = 0;
@@ -481,12 +513,10 @@ xrdpVidPutImage(ScrnInfoPtr pScrn,
break;
default:
LLOGLN(0, ("xrdpVidPutImage: unknown format 0x%8.8x", format));
- g_free(mem);
return Success;
}
if (error != 0)
{
- g_free(mem);
return Success;
}
error = stretch_RGB32_RGB32(rgborg32, width, height,
@@ -494,7 +524,6 @@ xrdpVidPutImage(ScrnInfoPtr pScrn,
rgbend32, drw_w, drw_h);
if (error != 0)
{
- g_free(mem);
return Success;
}
@@ -533,8 +562,6 @@ xrdpVidPutImage(ScrnInfoPtr pScrn,
rdpClientConAddAllReg(dev, &dreg, dst);
rdpRegionUninit(&dreg);
- g_free(mem);
-
return Success;
}