From 1f16250a7b700cf7d8844fd7b99d08aa634ef424 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 15 Dec 2022 14:12:59 +0100 Subject: [PATCH] [channels,rdpsnd] prevend multiple OnOpen calls due to the nature of the sound channel there are multiple listeners waiting for the server to open the channel and most of them are called by the server. Only open the channel once. --- channels/rdpsnd/client/rdpsnd_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index 9ae393682..c009507c3 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -112,6 +112,7 @@ struct rdpsnd_plugin BOOL applyVolume; size_t references; + BOOL OnOpenCalled; }; static const char* rdpsnd_is_dyn_str(BOOL dynamic) @@ -1603,6 +1604,10 @@ static UINT rdpsnd_on_open(IWTSVirtualChannelCallback* pChannelCallback) rdpsnd = (rdpsndPlugin*)callback->plugin; WINPR_ASSERT(rdpsnd); + if (rdpsnd->OnOpenCalled) + return CHANNEL_RC_OK; + rdpsnd->OnOpenCalled = TRUE; + if (!allocate_internals(rdpsnd)) return ERROR_OUTOFMEMORY; @@ -1649,6 +1654,7 @@ static UINT rdpsnd_on_close(IWTSVirtualChannelCallback* pChannelCallback) rdpsnd = (rdpsndPlugin*)callback->plugin; WINPR_ASSERT(rdpsnd); + rdpsnd->OnOpenCalled = FALSE; if (rdpsnd->device) IFCALL(rdpsnd->device->Close, rdpsnd->device);