diff --git a/client/X11/xf_gfx.c b/client/X11/xf_gfx.c index cb3423ea0..ec62665fa 100644 --- a/client/X11/xf_gfx.c +++ b/client/X11/xf_gfx.c @@ -253,7 +253,7 @@ static UINT xf_CreateSurface(RdpgfxClientContext* context, if (!surface) return CHANNEL_RC_NO_MEMORY; - surface->gdi.codecs = gdi->context->codecs; + surface->gdi.codecs = context->codecs; if (!surface->gdi.codecs) { diff --git a/include/freerdp/client/rdpgfx.h b/include/freerdp/client/rdpgfx.h index 9cb6c6309..7adbabb9f 100644 --- a/include/freerdp/client/rdpgfx.h +++ b/include/freerdp/client/rdpgfx.h @@ -22,6 +22,7 @@ #ifndef FREERDP_CHANNEL_RDPGFX_CLIENT_RDPGFX_H #define FREERDP_CHANNEL_RDPGFX_CLIENT_RDPGFX_H +#include #include #include @@ -147,6 +148,7 @@ struct _rdpgfx_client_context pcRdpgfxUnmapWindowForSurface UnmapWindowForSurface; CRITICAL_SECTION mux; + rdpCodecs* codecs; PROFILER_DEFINE(SurfaceProfiler) }; diff --git a/libfreerdp/gdi/gfx.c b/libfreerdp/gdi/gfx.c index c9896ff6a..2ac3a2012 100644 --- a/libfreerdp/gdi/gfx.c +++ b/libfreerdp/gdi/gfx.c @@ -96,8 +96,7 @@ static UINT gdi_ResetGraphics(RdpgfxClientContext* context, free(pSurfaceIds); - if (!freerdp_client_codecs_reset(gdi->context->codecs, FREERDP_CODEC_ALL, gdi->width, - gdi->height)) + if (!freerdp_client_codecs_reset(context->codecs, FREERDP_CODEC_ALL, gdi->width, gdi->height)) goto fail; rc = CHANNEL_RC_OK; @@ -950,14 +949,13 @@ static UINT gdi_CreateSurface(RdpgfxClientContext* context, { UINT rc = ERROR_INTERNAL_ERROR; gdiGfxSurface* surface; - rdpGdi* gdi = (rdpGdi*)context->custom; EnterCriticalSection(&context->mux); surface = (gdiGfxSurface*)calloc(1, sizeof(gdiGfxSurface)); if (!surface) goto fail; - surface->codecs = gdi->context->codecs; + surface->codecs = context->codecs; if (!surface->codecs) { @@ -1472,9 +1470,6 @@ BOOL gdi_graphics_pipeline_init_ex(rdpGdi* gdi, RdpgfxClientContext* gfx, return FALSE; context = gdi->context; - freerdp_client_codecs_prepare(context->codecs, FREERDP_CODEC_ALL, - context->settings->DesktopWidth, - context->settings->DesktopHeight); gdi->gfx = gfx; gfx->custom = (void*)gdi; @@ -1499,6 +1494,12 @@ BOOL gdi_graphics_pipeline_init_ex(rdpGdi* gdi, RdpgfxClientContext* gfx, gfx->MapWindowForSurface = map; gfx->UnmapWindowForSurface = unmap; gfx->UpdateSurfaceArea = update; + + gfx->codecs = codecs_new(context); + if (!gfx->codecs) + return FALSE; + freerdp_client_codecs_prepare(gfx->codecs, FREERDP_CODEC_ALL, context->settings->DesktopWidth, + context->settings->DesktopHeight); InitializeCriticalSection(&gfx->mux); PROFILER_CREATE(gfx->SurfaceProfiler, "GFX-PROFILER"); @@ -1522,6 +1523,7 @@ void gdi_graphics_pipeline_uninit(rdpGdi* gdi, RdpgfxClientContext* gfx) return; gfx->custom = NULL; + codecs_free(gfx->codecs); DeleteCriticalSection(&gfx->mux); PROFILER_PRINT_HEADER PROFILER_PRINT(gfx->SurfaceProfiler)