channels/rdpgfx: reset state on channel close

This commit is contained in:
Marc-André Moreau 2015-07-08 11:17:56 -04:00
parent 11f785290f
commit 23f9b3bbc0
1 changed files with 50 additions and 0 deletions

View File

@ -886,12 +886,62 @@ static int rdpgfx_on_open(IWTSVirtualChannelCallback* pChannelCallback)
static int rdpgfx_on_close(IWTSVirtualChannelCallback* pChannelCallback)
{
int count;
int index;
ULONG_PTR* pKeys = NULL;
RDPGFX_CHANNEL_CALLBACK* callback = (RDPGFX_CHANNEL_CALLBACK*) pChannelCallback;
RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin;
RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface;
WLog_DBG(TAG, "OnClose");
free(callback);
gfx->UnacknowledgedFrames = 0;
gfx->TotalDecodedFrames = 0;
if (gfx->zgfx)
{
zgfx_context_free(gfx->zgfx);
gfx->zgfx = zgfx_context_new(FALSE);
if (!gfx->zgfx)
return -1;
}
count = HashTable_GetKeys(gfx->SurfaceTable, &pKeys);
for (index = 0; index < count; index++)
{
RDPGFX_DELETE_SURFACE_PDU pdu;
pdu.surfaceId = ((UINT16) pKeys[index]) - 1;
if (context && context->DeleteSurface)
{
context->DeleteSurface(context, &pdu);
}
}
free(pKeys);
for (index = 0; index < gfx->MaxCacheSlot; index++)
{
if (gfx->CacheSlots[index])
{
RDPGFX_EVICT_CACHE_ENTRY_PDU pdu;
pdu.cacheSlot = (UINT16) index;
if (context && context->EvictCacheEntry)
{
context->EvictCacheEntry(context, &pdu);
}
gfx->CacheSlots[index] = NULL;
}
}
return 0;
}