Initializing channel context in each thread.
This commit is contained in:
parent
d55690db23
commit
88a3b8dd76
@ -140,14 +140,14 @@ static UINT audin_alsa_thread_receive(AudinALSADevice* alsa, BYTE* src, int size
|
||||
|
||||
while (frames > 0)
|
||||
{
|
||||
status = WaitForSingleObject(alsa->stopEvent, 0);
|
||||
status = WaitForSingleObject(alsa->stopEvent, 0);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
ret = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", ret);
|
||||
break;
|
||||
}
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
ret = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", ret);
|
||||
break;
|
||||
}
|
||||
|
||||
if (status == WAIT_OBJECT_0)
|
||||
break;
|
||||
@ -185,16 +185,16 @@ static UINT audin_alsa_thread_receive(AudinALSADevice* alsa, BYTE* src, int size
|
||||
encoded_size = alsa->buffer_frames * tbytes_per_frame;
|
||||
}
|
||||
|
||||
status = WaitForSingleObject(alsa->stopEvent, 0);
|
||||
status = WaitForSingleObject(alsa->stopEvent, 0);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
ret = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", ret);
|
||||
break;
|
||||
}
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
ret = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", ret);
|
||||
break;
|
||||
}
|
||||
|
||||
if (status == WAIT_OBJECT_0)
|
||||
if (status == WAIT_OBJECT_0)
|
||||
break;
|
||||
else
|
||||
{
|
||||
@ -225,68 +225,70 @@ static void* audin_alsa_thread_func(void* arg)
|
||||
int tbytes_per_frame;
|
||||
snd_pcm_t* capture_handle = NULL;
|
||||
AudinALSADevice* alsa = (AudinALSADevice*) arg;
|
||||
DWORD status;
|
||||
DWORD status;
|
||||
|
||||
DEBUG_DVC("in");
|
||||
|
||||
freerdp_channel_init_thread_context(alsa->rdpcontext);
|
||||
|
||||
rbytes_per_frame = alsa->actual_channels * alsa->bytes_per_channel;
|
||||
tbytes_per_frame = alsa->target_channels * alsa->bytes_per_channel;
|
||||
buffer = (BYTE*) calloc(1, rbytes_per_frame * alsa->frames_per_packet);
|
||||
if (!buffer)
|
||||
{
|
||||
WLog_ERR(TAG, "calloc failed!");
|
||||
error = CHANNEL_RC_NO_MEMORY;
|
||||
error = CHANNEL_RC_NO_MEMORY;
|
||||
if (alsa->rdpcontext)
|
||||
setChannelError(alsa->rdpcontext, error, "calloc failed!");
|
||||
goto out;
|
||||
goto out;
|
||||
}
|
||||
|
||||
freerdp_dsp_context_reset_adpcm(alsa->dsp_context);
|
||||
|
||||
if ((error = snd_pcm_open(&capture_handle, alsa->device_name, SND_PCM_STREAM_CAPTURE, 0)) < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "snd_pcm_open (%s)", snd_strerror(error));
|
||||
goto out;
|
||||
WLog_ERR(TAG, "snd_pcm_open (%s)", snd_strerror(error));
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!audin_alsa_set_params(alsa, capture_handle))
|
||||
{
|
||||
WLog_ERR(TAG, "audin_alsa_set_params failed");
|
||||
goto out;
|
||||
WLog_ERR(TAG, "audin_alsa_set_params failed");
|
||||
goto out;
|
||||
}
|
||||
|
||||
while(1)
|
||||
{
|
||||
status = WaitForSingleObject(alsa->stopEvent, 0);
|
||||
status = WaitForSingleObject(alsa->stopEvent, 0);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
break;
|
||||
}
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
break;
|
||||
}
|
||||
|
||||
if (status == WAIT_OBJECT_0)
|
||||
break;
|
||||
if (status == WAIT_OBJECT_0)
|
||||
break;
|
||||
|
||||
error = snd_pcm_readi(capture_handle, buffer, alsa->frames_per_packet);
|
||||
error = snd_pcm_readi(capture_handle, buffer, alsa->frames_per_packet);
|
||||
|
||||
if (error == -EPIPE)
|
||||
{
|
||||
snd_pcm_recover(capture_handle, error, 0);
|
||||
continue;
|
||||
}
|
||||
else if (error < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "snd_pcm_readi (%s)", snd_strerror(error));
|
||||
break;
|
||||
}
|
||||
if (error == -EPIPE)
|
||||
{
|
||||
snd_pcm_recover(capture_handle, error, 0);
|
||||
continue;
|
||||
}
|
||||
else if (error < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "snd_pcm_readi (%s)", snd_strerror(error));
|
||||
break;
|
||||
}
|
||||
|
||||
if ((error = audin_alsa_thread_receive(alsa, buffer, error * rbytes_per_frame)))
|
||||
{
|
||||
WLog_ERR(TAG, "audin_alsa_thread_receive failed with error %lu", error);
|
||||
break;
|
||||
}
|
||||
if ((error = audin_alsa_thread_receive(alsa, buffer, error * rbytes_per_frame)))
|
||||
{
|
||||
WLog_ERR(TAG, "audin_alsa_thread_receive failed with error %lu", error);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -415,7 +417,7 @@ static UINT audin_alsa_open(IAudinDevice* device, AudinReceive receive, void* us
|
||||
return ERROR_NOT_ENOUGH_MEMORY;
|
||||
}
|
||||
alsa->buffer_frames = 0;
|
||||
|
||||
|
||||
if (!(alsa->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
|
||||
{
|
||||
WLog_ERR(TAG, "CreateEvent failed!");
|
||||
@ -450,11 +452,11 @@ static UINT audin_alsa_close(IAudinDevice* device)
|
||||
{
|
||||
SetEvent(alsa->stopEvent);
|
||||
if (WaitForSingleObject(alsa->thread, INFINITE) == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
}
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
CloseHandle(alsa->stopEvent);
|
||||
alsa->stopEvent = NULL;
|
||||
|
@ -185,6 +185,8 @@ static void* audin_oss_thread_func(void* arg)
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
freerdp_channel_init_thread_context(oss->rdpcontext);
|
||||
|
||||
if (oss->dev_unit != -1)
|
||||
{
|
||||
sprintf_s(dev_name, (PATH_MAX - 1), "/dev/dsp%i", oss->dev_unit);
|
||||
|
@ -240,7 +240,7 @@ static UINT audin_server_recv_formats(audin_server* audin, wStream* s, UINT32 le
|
||||
|
||||
IFCALLRET(audin->context.Opening, success, &audin->context);
|
||||
if (success)
|
||||
WLog_ERR(TAG, "context.Opening failed with error %lu", success);
|
||||
WLog_ERR(TAG, "context.Opening failed with error %lu", success);
|
||||
return success;
|
||||
}
|
||||
|
||||
@ -304,7 +304,7 @@ static UINT audin_server_recv_open_reply(audin_server* audin, wStream* s, UINT32
|
||||
IFCALLRET(audin->context.OpenResult, success, &audin->context, Result);
|
||||
|
||||
if (success)
|
||||
WLog_ERR(TAG, "context.OpenResult failed with error %lu", success);
|
||||
WLog_ERR(TAG, "context.OpenResult failed with error %lu", success);
|
||||
|
||||
return success;
|
||||
}
|
||||
@ -375,7 +375,7 @@ static UINT audin_server_recv_data(audin_server* audin, wStream* s, UINT32 lengt
|
||||
IFCALLRET(audin->context.ReceiveSamples, success, &audin->context, src, frames);
|
||||
|
||||
if (success)
|
||||
WLog_ERR(TAG, "context.ReceiveSamples failed with error %lu", success);
|
||||
WLog_ERR(TAG, "context.ReceiveSamples failed with error %lu", success);
|
||||
|
||||
return success;
|
||||
}
|
||||
@ -398,6 +398,7 @@ static void* audin_server_thread_func(void* arg)
|
||||
BytesReturned = 0;
|
||||
ChannelEvent = NULL;
|
||||
|
||||
freerdp_channel_init_thread_context(audin->context.rdpcontext);
|
||||
if (WTSVirtualChannelQuery(audin->audin_channel, WTSVirtualEventHandle, &buffer, &BytesReturned) == TRUE)
|
||||
{
|
||||
if (BytesReturned == sizeof(HANDLE))
|
||||
@ -425,7 +426,7 @@ static void* audin_server_thread_func(void* arg)
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu", error);
|
||||
goto out;
|
||||
}
|
||||
@ -470,9 +471,9 @@ static void* audin_server_thread_func(void* arg)
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu", error);
|
||||
goto out;
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu", error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
Stream_SetPosition(s, 0);
|
||||
@ -503,9 +504,9 @@ static void* audin_server_thread_func(void* arg)
|
||||
case MSG_SNDIN_VERSION:
|
||||
if ((error = audin_server_recv_version(audin, s, BytesReturned)))
|
||||
{
|
||||
WLog_ERR(TAG, "audin_server_recv_version failed with error %lu!", error);
|
||||
goto out_capacity;
|
||||
}
|
||||
WLog_ERR(TAG, "audin_server_recv_version failed with error %lu!", error);
|
||||
goto out_capacity;
|
||||
}
|
||||
if ((error = audin_server_send_formats(audin, s)))
|
||||
{
|
||||
WLog_ERR(TAG, "audin_server_send_formats failed with error %lu!", error);
|
||||
@ -622,10 +623,10 @@ static BOOL audin_server_close(audin_server_context* context)
|
||||
{
|
||||
SetEvent(audin->stopEvent);
|
||||
if (WaitForSingleObject(audin->thread, INFINITE) == WAIT_FAILED)
|
||||
{
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
{
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", GetLastError());
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
CloseHandle(audin->thread);
|
||||
CloseHandle(audin->stopEvent);
|
||||
|
@ -64,7 +64,7 @@ CliprdrClientContext* cliprdr_get_client_interface(cliprdrPlugin* cliprdr)
|
||||
}
|
||||
|
||||
static wStream* cliprdr_packet_new(UINT16 msgType, UINT16 msgFlags,
|
||||
UINT32 dataLen)
|
||||
UINT32 dataLen)
|
||||
{
|
||||
wStream* s;
|
||||
s = Stream_New(NULL, dataLen + 8);
|
||||
@ -109,12 +109,12 @@ static UINT cliprdr_packet_send(cliprdrPlugin* cliprdr, wStream* s)
|
||||
else
|
||||
{
|
||||
status = cliprdr->channelEntryPoints.pVirtualChannelWrite(cliprdr->OpenHandle,
|
||||
Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
|
||||
Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
|
||||
}
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
WTSErrorToString(status), status);
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -144,7 +144,7 @@ static void cliprdr_print_general_capability_flags(UINT32 flags)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_process_general_capability(cliprdrPlugin* cliprdr,
|
||||
wStream* s)
|
||||
wStream* s)
|
||||
{
|
||||
UINT32 version;
|
||||
UINT32 generalFlags;
|
||||
@ -168,15 +168,15 @@ static UINT cliprdr_process_general_capability(cliprdrPlugin* cliprdr,
|
||||
|
||||
if (cliprdr->useLongFormatNames)
|
||||
cliprdr->useLongFormatNames = (generalFlags & CB_USE_LONG_FORMAT_NAMES) ? TRUE :
|
||||
FALSE;
|
||||
FALSE;
|
||||
|
||||
if (cliprdr->streamFileClipEnabled)
|
||||
cliprdr->streamFileClipEnabled = (generalFlags & CB_STREAM_FILECLIP_ENABLED) ?
|
||||
TRUE : FALSE;
|
||||
TRUE : FALSE;
|
||||
|
||||
if (cliprdr->fileClipNoFilePaths)
|
||||
cliprdr->fileClipNoFilePaths = (generalFlags & CB_FILECLIP_NO_FILE_PATHS) ?
|
||||
TRUE : FALSE;
|
||||
TRUE : FALSE;
|
||||
|
||||
if (cliprdr->canLockClipData)
|
||||
cliprdr->canLockClipData = (generalFlags & CB_CAN_LOCK_CLIPDATA) ? TRUE : FALSE;
|
||||
@ -191,7 +191,7 @@ static UINT cliprdr_process_general_capability(cliprdrPlugin* cliprdr,
|
||||
|
||||
capabilities.cCapabilitiesSets = 1;
|
||||
capabilities.capabilitySets = (CLIPRDR_CAPABILITY_SET*) &
|
||||
(generalCapabilitySet);
|
||||
(generalCapabilitySet);
|
||||
generalCapabilitySet.capabilitySetType = CB_CAPSTYPE_GENERAL;
|
||||
generalCapabilitySet.capabilitySetLength = 12;
|
||||
generalCapabilitySet.version = version;
|
||||
@ -210,7 +210,7 @@ static UINT cliprdr_process_general_capability(cliprdrPlugin* cliprdr,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s,
|
||||
UINT16 length, UINT16 flags)
|
||||
UINT16 length, UINT16 flags)
|
||||
{
|
||||
UINT16 index;
|
||||
UINT16 lengthCapability;
|
||||
@ -232,7 +232,7 @@ static UINT cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s,
|
||||
if ((error = cliprdr_process_general_capability(cliprdr, s)))
|
||||
{
|
||||
WLog_ERR(TAG, "cliprdr_process_general_capability failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -254,7 +254,7 @@ static UINT cliprdr_process_clip_caps(cliprdrPlugin* cliprdr, wStream* s,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr, wStream* s,
|
||||
UINT16 length, UINT16 flags)
|
||||
UINT16 length, UINT16 flags)
|
||||
{
|
||||
CLIPRDR_MONITOR_READY monitorReady;
|
||||
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
|
||||
@ -298,7 +298,7 @@ static UINT cliprdr_process_monitor_ready(cliprdrPlugin* cliprdr, wStream* s,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_process_filecontents_request(cliprdrPlugin* cliprdr,
|
||||
wStream* s, UINT32 length, UINT16 flags)
|
||||
wStream* s, UINT32 length, UINT16 flags)
|
||||
{
|
||||
CLIPRDR_FILE_CONTENTS_REQUEST request;
|
||||
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
|
||||
@ -346,7 +346,7 @@ static UINT cliprdr_process_filecontents_request(cliprdrPlugin* cliprdr,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_process_filecontents_response(cliprdrPlugin* cliprdr,
|
||||
wStream* s, UINT32 length, UINT16 flags)
|
||||
wStream* s, UINT32 length, UINT16 flags)
|
||||
{
|
||||
CLIPRDR_FILE_CONTENTS_RESPONSE response;
|
||||
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
|
||||
@ -385,7 +385,7 @@ static UINT cliprdr_process_filecontents_response(cliprdrPlugin* cliprdr,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_process_lock_clipdata(cliprdrPlugin* cliprdr, wStream* s,
|
||||
UINT32 length, UINT16 flags)
|
||||
UINT32 length, UINT16 flags)
|
||||
{
|
||||
CLIPRDR_LOCK_CLIPBOARD_DATA lockClipboardData;
|
||||
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
|
||||
@ -422,7 +422,7 @@ static UINT cliprdr_process_lock_clipdata(cliprdrPlugin* cliprdr, wStream* s,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_process_unlock_clipdata(cliprdrPlugin* cliprdr, wStream* s,
|
||||
UINT32 length, UINT16 flags)
|
||||
UINT32 length, UINT16 flags)
|
||||
{
|
||||
CLIPRDR_UNLOCK_CLIPBOARD_DATA unlockClipboardData;
|
||||
CliprdrClientContext* context = cliprdr_get_client_interface(cliprdr);
|
||||
@ -445,9 +445,9 @@ static UINT cliprdr_process_unlock_clipdata(cliprdrPlugin* cliprdr, wStream* s,
|
||||
unlockClipboardData.msgFlags = flags;
|
||||
unlockClipboardData.dataLen = length;
|
||||
Stream_Read_UINT32(s,
|
||||
unlockClipboardData.clipDataId); /* clipDataId (4 bytes) */
|
||||
unlockClipboardData.clipDataId); /* clipDataId (4 bytes) */
|
||||
IFCALLRET(context->ServerUnlockClipboardData, error, context,
|
||||
&unlockClipboardData);
|
||||
&unlockClipboardData);
|
||||
|
||||
if (error)
|
||||
WLog_ERR(TAG, "ServerUnlockClipboardData failed with error %lu!", error);
|
||||
@ -471,7 +471,7 @@ static UINT cliprdr_order_recv(cliprdrPlugin* cliprdr, wStream* s)
|
||||
Stream_Read_UINT32(s, dataLen); /* dataLen (4 bytes) */
|
||||
#ifdef WITH_DEBUG_CLIPRDR
|
||||
WLog_DBG(TAG, "msgType: %s (%d), msgFlags: %d dataLen: %d",
|
||||
CB_MSG_TYPE_STRINGS[msgType], msgType, msgFlags, dataLen);
|
||||
CB_MSG_TYPE_STRINGS[msgType], msgType, msgFlags, dataLen);
|
||||
winpr_HexDump(TAG, WLOG_DEBUG, Stream_Buffer(s), dataLen + 8);
|
||||
#endif
|
||||
|
||||
@ -497,41 +497,41 @@ static UINT cliprdr_order_recv(cliprdrPlugin* cliprdr, wStream* s)
|
||||
|
||||
case CB_FORMAT_LIST_RESPONSE:
|
||||
if ((error = cliprdr_process_format_list_response(cliprdr, s, dataLen,
|
||||
msgFlags)))
|
||||
msgFlags)))
|
||||
WLog_ERR(TAG, "cliprdr_process_format_list_response failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
|
||||
break;
|
||||
|
||||
case CB_FORMAT_DATA_REQUEST:
|
||||
if ((error = cliprdr_process_format_data_request(cliprdr, s, dataLen,
|
||||
msgFlags)))
|
||||
msgFlags)))
|
||||
WLog_ERR(TAG, "cliprdr_process_format_data_request failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
|
||||
break;
|
||||
|
||||
case CB_FORMAT_DATA_RESPONSE:
|
||||
if ((error = cliprdr_process_format_data_response(cliprdr, s, dataLen,
|
||||
msgFlags)))
|
||||
msgFlags)))
|
||||
WLog_ERR(TAG, "cliprdr_process_format_data_response failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
|
||||
break;
|
||||
|
||||
case CB_FILECONTENTS_REQUEST:
|
||||
if ((error = cliprdr_process_filecontents_request(cliprdr, s, dataLen,
|
||||
msgFlags)))
|
||||
msgFlags)))
|
||||
WLog_ERR(TAG, "cliprdr_process_filecontents_request failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
|
||||
break;
|
||||
|
||||
case CB_FILECONTENTS_RESPONSE:
|
||||
if ((error = cliprdr_process_filecontents_response(cliprdr, s, dataLen,
|
||||
msgFlags)))
|
||||
msgFlags)))
|
||||
WLog_ERR(TAG, "cliprdr_process_filecontents_response failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
|
||||
break;
|
||||
|
||||
@ -567,7 +567,7 @@ static UINT cliprdr_order_recv(cliprdrPlugin* cliprdr, wStream* s)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_client_capabilities(CliprdrClientContext* context,
|
||||
CLIPRDR_CAPABILITIES* capabilities)
|
||||
CLIPRDR_CAPABILITIES* capabilities)
|
||||
{
|
||||
wStream* s;
|
||||
CLIPRDR_GENERAL_CAPABILITY_SET* generalCapabilitySet;
|
||||
@ -583,11 +583,11 @@ static UINT cliprdr_client_capabilities(CliprdrClientContext* context,
|
||||
Stream_Write_UINT16(s, 1); /* cCapabilitiesSets */
|
||||
Stream_Write_UINT16(s, 0); /* pad1 */
|
||||
generalCapabilitySet = (CLIPRDR_GENERAL_CAPABILITY_SET*)
|
||||
capabilities->capabilitySets;
|
||||
capabilities->capabilitySets;
|
||||
Stream_Write_UINT16(s,
|
||||
generalCapabilitySet->capabilitySetType); /* capabilitySetType */
|
||||
generalCapabilitySet->capabilitySetType); /* capabilitySetType */
|
||||
Stream_Write_UINT16(s,
|
||||
generalCapabilitySet->capabilitySetLength); /* lengthCapability */
|
||||
generalCapabilitySet->capabilitySetLength); /* lengthCapability */
|
||||
Stream_Write_UINT32(s, generalCapabilitySet->version); /* version */
|
||||
Stream_Write_UINT32(s, generalCapabilitySet->generalFlags); /* generalFlags */
|
||||
WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientCapabilities");
|
||||
@ -600,7 +600,7 @@ static UINT cliprdr_client_capabilities(CliprdrClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_temp_directory(CliprdrClientContext* context,
|
||||
CLIPRDR_TEMP_DIRECTORY* tempDirectory)
|
||||
CLIPRDR_TEMP_DIRECTORY* tempDirectory)
|
||||
{
|
||||
int length;
|
||||
wStream* s;
|
||||
@ -615,7 +615,7 @@ static UINT cliprdr_temp_directory(CliprdrClientContext* context,
|
||||
}
|
||||
|
||||
length = ConvertToUnicode(CP_UTF8, 0, tempDirectory->szTempDir, -1, &wszTempDir,
|
||||
0);
|
||||
0);
|
||||
|
||||
if (length < 0)
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
@ -627,7 +627,7 @@ static UINT cliprdr_temp_directory(CliprdrClientContext* context,
|
||||
Stream_Zero(s, (520 - length) * 2);
|
||||
free(wszTempDir);
|
||||
WLog_Print(cliprdr->log, WLOG_DEBUG, "TempDirectory: %s",
|
||||
tempDirectory->szTempDir);
|
||||
tempDirectory->szTempDir);
|
||||
return cliprdr_packet_send(cliprdr, s);
|
||||
}
|
||||
|
||||
@ -637,7 +637,7 @@ static UINT cliprdr_temp_directory(CliprdrClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_client_format_list(CliprdrClientContext* context,
|
||||
CLIPRDR_FORMAT_LIST* formatList)
|
||||
CLIPRDR_FORMAT_LIST* formatList)
|
||||
{
|
||||
wStream* s;
|
||||
UINT32 index;
|
||||
@ -688,7 +688,7 @@ static UINT cliprdr_client_format_list(CliprdrClientContext* context,
|
||||
|
||||
if (szFormatName)
|
||||
formatNameSize = ConvertToUnicode(CP_UTF8, 0, szFormatName, -1, &wszFormatName,
|
||||
0);
|
||||
0);
|
||||
|
||||
if (formatNameSize > 15)
|
||||
formatNameSize = 15;
|
||||
@ -711,7 +711,7 @@ static UINT cliprdr_client_format_list(CliprdrClientContext* context,
|
||||
|
||||
if (format->formatName)
|
||||
formatNameSize = MultiByteToWideChar(CP_UTF8, 0, format->formatName, -1, NULL,
|
||||
0) * 2;
|
||||
0) * 2;
|
||||
|
||||
length += formatNameSize;
|
||||
}
|
||||
@ -734,7 +734,7 @@ static UINT cliprdr_client_format_list(CliprdrClientContext* context,
|
||||
lpWideCharStr = (LPWSTR) Stream_Pointer(s);
|
||||
cchWideChar = (Stream_Capacity(s) - Stream_GetPosition(s)) / 2;
|
||||
formatNameSize = MultiByteToWideChar(CP_UTF8, 0,
|
||||
format->formatName, -1, lpWideCharStr, cchWideChar) * 2;
|
||||
format->formatName, -1, lpWideCharStr, cchWideChar) * 2;
|
||||
Stream_Seek(s, formatNameSize);
|
||||
}
|
||||
else
|
||||
@ -745,7 +745,7 @@ static UINT cliprdr_client_format_list(CliprdrClientContext* context,
|
||||
}
|
||||
|
||||
WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientFormatList: numFormats: %d",
|
||||
formatList->numFormats);
|
||||
formatList->numFormats);
|
||||
return cliprdr_packet_send(cliprdr, s);
|
||||
}
|
||||
|
||||
@ -755,14 +755,14 @@ static UINT cliprdr_client_format_list(CliprdrClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_client_format_list_response(CliprdrClientContext* context,
|
||||
CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
|
||||
CLIPRDR_FORMAT_LIST_RESPONSE* formatListResponse)
|
||||
{
|
||||
wStream* s;
|
||||
cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
|
||||
formatListResponse->msgType = CB_FORMAT_LIST_RESPONSE;
|
||||
formatListResponse->dataLen = 0;
|
||||
s = cliprdr_packet_new(formatListResponse->msgType,
|
||||
formatListResponse->msgFlags, formatListResponse->dataLen);
|
||||
formatListResponse->msgFlags, formatListResponse->dataLen);
|
||||
|
||||
if (!s)
|
||||
{
|
||||
@ -780,7 +780,7 @@ static UINT cliprdr_client_format_list_response(CliprdrClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_client_lock_clipboard_data(CliprdrClientContext* context,
|
||||
CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData)
|
||||
CLIPRDR_LOCK_CLIPBOARD_DATA* lockClipboardData)
|
||||
{
|
||||
wStream* s;
|
||||
cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
|
||||
@ -793,10 +793,10 @@ static UINT cliprdr_client_lock_clipboard_data(CliprdrClientContext* context,
|
||||
}
|
||||
|
||||
Stream_Write_UINT32(s,
|
||||
lockClipboardData->clipDataId); /* clipDataId (4 bytes) */
|
||||
lockClipboardData->clipDataId); /* clipDataId (4 bytes) */
|
||||
WLog_Print(cliprdr->log, WLOG_DEBUG,
|
||||
"ClientLockClipboardData: clipDataId: 0x%04X",
|
||||
lockClipboardData->clipDataId);
|
||||
"ClientLockClipboardData: clipDataId: 0x%04X",
|
||||
lockClipboardData->clipDataId);
|
||||
return cliprdr_packet_send(cliprdr, s);;
|
||||
}
|
||||
|
||||
@ -806,7 +806,7 @@ static UINT cliprdr_client_lock_clipboard_data(CliprdrClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_client_unlock_clipboard_data(CliprdrClientContext* context,
|
||||
CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)
|
||||
CLIPRDR_UNLOCK_CLIPBOARD_DATA* unlockClipboardData)
|
||||
{
|
||||
wStream* s;
|
||||
cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
|
||||
@ -819,10 +819,10 @@ static UINT cliprdr_client_unlock_clipboard_data(CliprdrClientContext* context,
|
||||
}
|
||||
|
||||
Stream_Write_UINT32(s,
|
||||
unlockClipboardData->clipDataId); /* clipDataId (4 bytes) */
|
||||
unlockClipboardData->clipDataId); /* clipDataId (4 bytes) */
|
||||
WLog_Print(cliprdr->log, WLOG_DEBUG,
|
||||
"ClientUnlockClipboardData: clipDataId: 0x%04X",
|
||||
unlockClipboardData->clipDataId);
|
||||
"ClientUnlockClipboardData: clipDataId: 0x%04X",
|
||||
unlockClipboardData->clipDataId);
|
||||
return cliprdr_packet_send(cliprdr, s);
|
||||
}
|
||||
|
||||
@ -832,7 +832,7 @@ static UINT cliprdr_client_unlock_clipboard_data(CliprdrClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_client_format_data_request(CliprdrClientContext* context,
|
||||
CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
|
||||
CLIPRDR_FORMAT_DATA_REQUEST* formatDataRequest)
|
||||
{
|
||||
wStream* s;
|
||||
cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
|
||||
@ -840,7 +840,7 @@ static UINT cliprdr_client_format_data_request(CliprdrClientContext* context,
|
||||
formatDataRequest->msgFlags = 0;
|
||||
formatDataRequest->dataLen = 4;
|
||||
s = cliprdr_packet_new(formatDataRequest->msgType, formatDataRequest->msgFlags,
|
||||
formatDataRequest->dataLen);
|
||||
formatDataRequest->dataLen);
|
||||
|
||||
if (!s)
|
||||
{
|
||||
@ -849,7 +849,7 @@ static UINT cliprdr_client_format_data_request(CliprdrClientContext* context,
|
||||
}
|
||||
|
||||
Stream_Write_UINT32(s,
|
||||
formatDataRequest->requestedFormatId); /* requestedFormatId (4 bytes) */
|
||||
formatDataRequest->requestedFormatId); /* requestedFormatId (4 bytes) */
|
||||
WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientFormatDataRequest");
|
||||
return cliprdr_packet_send(cliprdr, s);
|
||||
}
|
||||
@ -860,13 +860,13 @@ static UINT cliprdr_client_format_data_request(CliprdrClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_client_format_data_response(CliprdrClientContext* context,
|
||||
CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
|
||||
CLIPRDR_FORMAT_DATA_RESPONSE* formatDataResponse)
|
||||
{
|
||||
wStream* s;
|
||||
cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
|
||||
formatDataResponse->msgType = CB_FORMAT_DATA_RESPONSE;
|
||||
s = cliprdr_packet_new(formatDataResponse->msgType,
|
||||
formatDataResponse->msgFlags, formatDataResponse->dataLen);
|
||||
formatDataResponse->msgFlags, formatDataResponse->dataLen);
|
||||
|
||||
if (!s)
|
||||
{
|
||||
@ -875,7 +875,7 @@ static UINT cliprdr_client_format_data_response(CliprdrClientContext* context,
|
||||
}
|
||||
|
||||
Stream_Write(s, formatDataResponse->requestedFormatData,
|
||||
formatDataResponse->dataLen);
|
||||
formatDataResponse->dataLen);
|
||||
WLog_Print(cliprdr->log, WLOG_DEBUG, "ClientFormatDataResponse");
|
||||
return cliprdr_packet_send(cliprdr, s);
|
||||
}
|
||||
@ -886,7 +886,7 @@ static UINT cliprdr_client_format_data_response(CliprdrClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_client_file_contents_request(CliprdrClientContext* context,
|
||||
CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
|
||||
CLIPRDR_FILE_CONTENTS_REQUEST* fileContentsRequest)
|
||||
{
|
||||
wStream* s;
|
||||
cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
|
||||
@ -900,19 +900,19 @@ static UINT cliprdr_client_file_contents_request(CliprdrClientContext* context,
|
||||
|
||||
Stream_Write_UINT32(s, fileContentsRequest->streamId); /* streamId (4 bytes) */
|
||||
Stream_Write_UINT32(s,
|
||||
fileContentsRequest->listIndex); /* listIndex (4 bytes) */
|
||||
fileContentsRequest->listIndex); /* listIndex (4 bytes) */
|
||||
Stream_Write_UINT32(s, fileContentsRequest->dwFlags); /* dwFlags (4 bytes) */
|
||||
Stream_Write_UINT32(s,
|
||||
fileContentsRequest->nPositionLow); /* nPositionLow (4 bytes) */
|
||||
fileContentsRequest->nPositionLow); /* nPositionLow (4 bytes) */
|
||||
Stream_Write_UINT32(s,
|
||||
fileContentsRequest->nPositionHigh); /* nPositionHigh (4 bytes) */
|
||||
fileContentsRequest->nPositionHigh); /* nPositionHigh (4 bytes) */
|
||||
Stream_Write_UINT32(s,
|
||||
fileContentsRequest->cbRequested); /* cbRequested (4 bytes) */
|
||||
fileContentsRequest->cbRequested); /* cbRequested (4 bytes) */
|
||||
Stream_Write_UINT32(s,
|
||||
fileContentsRequest->clipDataId); /* clipDataId (4 bytes) */
|
||||
fileContentsRequest->clipDataId); /* clipDataId (4 bytes) */
|
||||
WLog_Print(cliprdr->log, WLOG_DEBUG,
|
||||
"ClientFileContentsRequest: streamId: 0x%04X",
|
||||
fileContentsRequest->streamId);
|
||||
"ClientFileContentsRequest: streamId: 0x%04X",
|
||||
fileContentsRequest->streamId);
|
||||
return cliprdr_packet_send(cliprdr, s);
|
||||
}
|
||||
|
||||
@ -922,7 +922,7 @@ static UINT cliprdr_client_file_contents_request(CliprdrClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_client_file_contents_response(CliprdrClientContext* context,
|
||||
CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse)
|
||||
CLIPRDR_FILE_CONTENTS_RESPONSE* fileContentsResponse)
|
||||
{
|
||||
wStream* s;
|
||||
cliprdrPlugin* cliprdr = (cliprdrPlugin*) context->handle;
|
||||
@ -931,7 +931,7 @@ static UINT cliprdr_client_file_contents_response(CliprdrClientContext* context,
|
||||
fileContentsResponse->cbRequested = sizeof(UINT64);
|
||||
|
||||
s = cliprdr_packet_new(CB_FILECONTENTS_RESPONSE, fileContentsResponse->msgFlags,
|
||||
4 + fileContentsResponse->cbRequested);
|
||||
4 + fileContentsResponse->cbRequested);
|
||||
|
||||
if (!s)
|
||||
{
|
||||
@ -946,10 +946,10 @@ static UINT cliprdr_client_file_contents_response(CliprdrClientContext* context,
|
||||
* FILECONTENTS_RANGE: file data from requested range
|
||||
*/
|
||||
Stream_Write(s, fileContentsResponse->requestedData,
|
||||
fileContentsResponse->cbRequested);
|
||||
fileContentsResponse->cbRequested);
|
||||
WLog_Print(cliprdr->log, WLOG_DEBUG,
|
||||
"ClientFileContentsResponse: streamId: 0x%04X",
|
||||
fileContentsResponse->streamId);
|
||||
"ClientFileContentsResponse: streamId: 0x%04X",
|
||||
fileContentsResponse->streamId);
|
||||
return cliprdr_packet_send(cliprdr, s);
|
||||
}
|
||||
|
||||
@ -959,7 +959,7 @@ static UINT cliprdr_client_file_contents_response(CliprdrClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_virtual_channel_event_data_received(cliprdrPlugin* cliprdr,
|
||||
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
{
|
||||
wStream* data_in;
|
||||
|
||||
@ -1014,8 +1014,8 @@ static UINT cliprdr_virtual_channel_event_data_received(cliprdrPlugin* cliprdr,
|
||||
}
|
||||
|
||||
static VOID VCAPITYPE cliprdr_virtual_channel_open_event(DWORD openHandle,
|
||||
UINT event,
|
||||
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
UINT event,
|
||||
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
{
|
||||
cliprdrPlugin* cliprdr = s_TLSPluginContext;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
@ -1030,7 +1030,7 @@ static VOID VCAPITYPE cliprdr_virtual_channel_open_event(DWORD openHandle,
|
||||
{
|
||||
case CHANNEL_EVENT_DATA_RECEIVED:
|
||||
error = cliprdr_virtual_channel_event_data_received(cliprdr, pData, dataLength,
|
||||
totalLength, dataFlags);
|
||||
totalLength, dataFlags);
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_WRITE_COMPLETE:
|
||||
@ -1043,7 +1043,7 @@ static VOID VCAPITYPE cliprdr_virtual_channel_open_event(DWORD openHandle,
|
||||
|
||||
if (error && cliprdr->context->rdpcontext)
|
||||
setChannelError(cliprdr->context->rdpcontext, error,
|
||||
"cliprdr_virtual_channel_open_event reported an error");
|
||||
"cliprdr_virtual_channel_open_event reported an error");
|
||||
}
|
||||
|
||||
static void* cliprdr_virtual_channel_client_thread(void* arg)
|
||||
@ -1053,6 +1053,8 @@ static void* cliprdr_virtual_channel_client_thread(void* arg)
|
||||
cliprdrPlugin* cliprdr = (cliprdrPlugin*) arg;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
freerdp_channel_init_thread_context(cliprdr->context->rdpcontext);
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (!MessageQueue_Wait(cliprdr->queue))
|
||||
@ -1086,7 +1088,7 @@ static void* cliprdr_virtual_channel_client_thread(void* arg)
|
||||
|
||||
if (error && cliprdr->context->rdpcontext)
|
||||
setChannelError(cliprdr->context->rdpcontext, error,
|
||||
"cliprdr_virtual_channel_client_thread reported an error");
|
||||
"cliprdr_virtual_channel_client_thread reported an error");
|
||||
|
||||
ExitThread((DWORD)error);
|
||||
return NULL;
|
||||
@ -1098,17 +1100,17 @@ static void* cliprdr_virtual_channel_client_thread(void* arg)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT cliprdr_virtual_channel_event_connected(cliprdrPlugin* cliprdr,
|
||||
LPVOID pData, UINT32 dataLength)
|
||||
LPVOID pData, UINT32 dataLength)
|
||||
{
|
||||
UINT32 status;
|
||||
status = cliprdr->channelEntryPoints.pVirtualChannelOpen(cliprdr->InitHandle,
|
||||
&cliprdr->OpenHandle, cliprdr->channelDef.name,
|
||||
cliprdr_virtual_channel_open_event);
|
||||
&cliprdr->OpenHandle, cliprdr->channelDef.name,
|
||||
cliprdr_virtual_channel_open_event);
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
WTSErrorToString(status), status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -1121,8 +1123,8 @@ static UINT cliprdr_virtual_channel_event_connected(cliprdrPlugin* cliprdr,
|
||||
}
|
||||
|
||||
if (!(cliprdr->thread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) cliprdr_virtual_channel_client_thread, (void*) cliprdr,
|
||||
0, NULL)))
|
||||
(LPTHREAD_START_ROUTINE) cliprdr_virtual_channel_client_thread, (void*) cliprdr,
|
||||
0, NULL)))
|
||||
{
|
||||
WLog_ERR(TAG, "CreateThread failed!");
|
||||
MessageQueue_Free(cliprdr->queue);
|
||||
@ -1157,7 +1159,7 @@ static UINT cliprdr_virtual_channel_event_disconnected(cliprdrPlugin* cliprdr)
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
WTSErrorToString(rc), rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -1184,8 +1186,8 @@ static UINT cliprdr_virtual_channel_event_terminated(cliprdrPlugin* cliprdr)
|
||||
}
|
||||
|
||||
static VOID VCAPITYPE cliprdr_virtual_channel_init_event(LPVOID pInitHandle,
|
||||
UINT event, LPVOID pData,
|
||||
UINT dataLength)
|
||||
UINT event, LPVOID pData,
|
||||
UINT dataLength)
|
||||
{
|
||||
cliprdrPlugin* cliprdr = s_TLSPluginContext;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
@ -1200,30 +1202,30 @@ static VOID VCAPITYPE cliprdr_virtual_channel_init_event(LPVOID pInitHandle,
|
||||
{
|
||||
case CHANNEL_EVENT_CONNECTED:
|
||||
if ((error = cliprdr_virtual_channel_event_connected(cliprdr, pData,
|
||||
dataLength)))
|
||||
dataLength)))
|
||||
WLog_ERR(TAG, "cliprdr_virtual_channel_event_connected failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_DISCONNECTED:
|
||||
if ((error = cliprdr_virtual_channel_event_disconnected(cliprdr)))
|
||||
WLog_ERR(TAG,
|
||||
"cliprdr_virtual_channel_event_disconnected failed with error %lu!", error);
|
||||
"cliprdr_virtual_channel_event_disconnected failed with error %lu!", error);
|
||||
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_TERMINATED:
|
||||
if ((error = cliprdr_virtual_channel_event_terminated(cliprdr)))
|
||||
WLog_ERR(TAG, "cliprdr_virtual_channel_event_terminated failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (error && cliprdr->context->rdpcontext)
|
||||
setChannelError(cliprdr->context->rdpcontext, error,
|
||||
"cliprdr_virtual_channel_init_event reported an error");
|
||||
"cliprdr_virtual_channel_init_event reported an error");
|
||||
}
|
||||
|
||||
/* cliprdr is always built-in */
|
||||
@ -1287,24 +1289,24 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
cliprdr->canLockClipData = FALSE;
|
||||
WLog_Print(cliprdr->log, WLOG_DEBUG, "VirtualChannelEntry");
|
||||
CopyMemory(&(cliprdr->channelEntryPoints), pEntryPoints,
|
||||
sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
rc = cliprdr->channelEntryPoints.pVirtualChannelInit(&cliprdr->InitHandle,
|
||||
&cliprdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
||||
cliprdr_virtual_channel_init_event);
|
||||
&cliprdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
||||
cliprdr_virtual_channel_init_event);
|
||||
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
WTSErrorToString(rc), rc);
|
||||
free(cliprdr->context);
|
||||
free(cliprdr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
cliprdr->channelEntryPoints.pInterface = *
|
||||
(cliprdr->channelEntryPoints.ppInterface);
|
||||
(cliprdr->channelEntryPoints.ppInterface);
|
||||
cliprdr->channelEntryPoints.ppInterface = &
|
||||
(cliprdr->channelEntryPoints.pInterface);
|
||||
(cliprdr->channelEntryPoints.pInterface);
|
||||
s_TLSPluginContext = cliprdr;
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -1191,17 +1191,17 @@ UINT cliprdr_server_read(CliprdrServerContext* context)
|
||||
BytesReturned = 0;
|
||||
BytesToRead = CLIPRDR_HEADER_LENGTH - Stream_GetPosition(s);
|
||||
|
||||
status = WaitForSingleObject(cliprdr->ChannelEvent, 0);
|
||||
status = WaitForSingleObject(cliprdr->ChannelEvent, 0);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
}
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
if (status == WAIT_TIMEOUT)
|
||||
return CHANNEL_RC_OK;
|
||||
if (status == WAIT_TIMEOUT)
|
||||
return CHANNEL_RC_OK;
|
||||
|
||||
if (!WTSVirtualChannelRead(cliprdr->ChannelHandle, 0,
|
||||
(PCHAR) Stream_Pointer(s), BytesToRead, &BytesReturned))
|
||||
@ -1235,17 +1235,17 @@ UINT cliprdr_server_read(CliprdrServerContext* context)
|
||||
BytesReturned = 0;
|
||||
BytesToRead = (header.dataLen + CLIPRDR_HEADER_LENGTH) - Stream_GetPosition(s);
|
||||
|
||||
status = WaitForSingleObject(cliprdr->ChannelEvent, 0);
|
||||
status = WaitForSingleObject(cliprdr->ChannelEvent, 0);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
}
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
if (status == WAIT_TIMEOUT)
|
||||
return CHANNEL_RC_OK;
|
||||
if (status == WAIT_TIMEOUT)
|
||||
return CHANNEL_RC_OK;
|
||||
|
||||
if (!WTSVirtualChannelRead(cliprdr->ChannelHandle, 0,
|
||||
(PCHAR) Stream_Pointer(s), BytesToRead, &BytesReturned))
|
||||
@ -1273,17 +1273,17 @@ UINT cliprdr_server_read(CliprdrServerContext* context)
|
||||
|
||||
/* check for trailing zero bytes */
|
||||
|
||||
status = WaitForSingleObject(cliprdr->ChannelEvent, 0);
|
||||
status = WaitForSingleObject(cliprdr->ChannelEvent, 0);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
}
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
if (status == WAIT_TIMEOUT)
|
||||
return CHANNEL_RC_OK;
|
||||
if (status == WAIT_TIMEOUT)
|
||||
return CHANNEL_RC_OK;
|
||||
|
||||
BytesReturned = 0;
|
||||
BytesToRead = 4;
|
||||
@ -1326,6 +1326,7 @@ static void* cliprdr_server_thread(void* arg)
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
|
||||
UINT error;
|
||||
|
||||
freerdp_channel_init_thread_context(context->rdpcontext);
|
||||
ChannelEvent = context->GetEventHandle(context);
|
||||
|
||||
nCount = 0;
|
||||
@ -1344,31 +1345,31 @@ static void* cliprdr_server_thread(void* arg)
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu", error);
|
||||
goto out;
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu", error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
status = WaitForSingleObject(cliprdr->StopEvent, 0);
|
||||
status = WaitForSingleObject(cliprdr->StopEvent, 0);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
goto out;
|
||||
}
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (status == WAIT_OBJECT_0)
|
||||
break;
|
||||
|
||||
status = WaitForSingleObject(ChannelEvent, 0);
|
||||
status = WaitForSingleObject(ChannelEvent, 0);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
goto out;
|
||||
}
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (status == WAIT_OBJECT_0)
|
||||
{
|
||||
@ -1499,11 +1500,11 @@ static UINT cliprdr_server_stop(CliprdrServerContext* context)
|
||||
{
|
||||
SetEvent(cliprdr->StopEvent);
|
||||
if (WaitForSingleObject(cliprdr->Thread, INFINITE) == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
}
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
}
|
||||
CloseHandle(cliprdr->Thread);
|
||||
CloseHandle(cliprdr->StopEvent);
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ static void* drdynvc_server_thread(void* arg)
|
||||
BytesReturned = 0;
|
||||
ChannelEvent = NULL;
|
||||
|
||||
freerdp_channel_init_thread_context(context->rdpcontext);
|
||||
s = Stream_New(NULL, 4096);
|
||||
if (!s)
|
||||
{
|
||||
@ -155,9 +156,9 @@ static UINT drdynvc_server_stop(DrdynvcServerContext* context)
|
||||
|
||||
if (WaitForSingleObject(context->priv->Thread, INFINITE) == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
return error;
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
return error;
|
||||
}
|
||||
CloseHandle(context->priv->Thread);
|
||||
|
||||
|
@ -687,6 +687,7 @@ static void* drive_thread_func(void* arg)
|
||||
DRIVE_DEVICE* drive = (DRIVE_DEVICE*) arg;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
freerdp_channel_init_thread_context(drive->rdpcontext);
|
||||
while (1)
|
||||
{
|
||||
if (!MessageQueue_Wait(drive->IrpQueue))
|
||||
@ -750,9 +751,9 @@ static UINT drive_free(DEVICE* device)
|
||||
|
||||
if (MessageQueue_PostQuit(drive->IrpQueue, 0) && (WaitForSingleObject(drive->thread, INFINITE) == WAIT_FAILED))
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
CloseHandle(drive->thread);
|
||||
|
@ -82,11 +82,11 @@ static UINT echo_server_open_channel(echo_server* echo)
|
||||
while (echo->echo_channel == NULL)
|
||||
{
|
||||
if (WaitForSingleObject(hEvent, 1000) == WAIT_FAILED)
|
||||
{
|
||||
Error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", Error);
|
||||
return Error;
|
||||
}
|
||||
{
|
||||
Error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", Error);
|
||||
return Error;
|
||||
}
|
||||
|
||||
echo->echo_channel = WTSVirtualChannelOpenEx(echo->SessionId,
|
||||
"ECHO", WTS_CHANNEL_OPTION_DYNAMIC);
|
||||
@ -118,6 +118,7 @@ static void* echo_server_thread_func(void* arg)
|
||||
UINT error;
|
||||
DWORD status;
|
||||
|
||||
freerdp_channel_init_thread_context(echo->context.rdpcontext);
|
||||
if ((error = echo_server_open_channel(echo)))
|
||||
{
|
||||
UINT error2 = 0;
|
||||
@ -197,16 +198,16 @@ static void* echo_server_thread_func(void* arg)
|
||||
|
||||
while (ready)
|
||||
{
|
||||
status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
|
||||
status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu", error);
|
||||
break;
|
||||
}
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu", error);
|
||||
break;
|
||||
}
|
||||
|
||||
if (status == WAIT_OBJECT_0)
|
||||
if (status == WAIT_OBJECT_0)
|
||||
break;
|
||||
|
||||
Stream_SetPosition(s, 0);
|
||||
@ -290,11 +291,11 @@ static UINT echo_server_close(echo_server_context* context)
|
||||
SetEvent(echo->stopEvent);
|
||||
|
||||
if (WaitForSingleObject(echo->thread, INFINITE) == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
}
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
CloseHandle(echo->thread);
|
||||
CloseHandle(echo->stopEvent);
|
||||
|
@ -121,11 +121,11 @@ static UINT encomsp_virtual_channel_write(encomspPlugin* encomsp, wStream* s)
|
||||
winpr_HexDump(Stream_Buffer(s), Stream_Length(s));
|
||||
#endif
|
||||
status = encomsp->channelEntryPoints.pVirtualChannelWrite(encomsp->OpenHandle,
|
||||
Stream_Buffer(s), (UINT32) Stream_Length(s), s);
|
||||
Stream_Buffer(s), (UINT32) Stream_Length(s), s);
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
WTSErrorToString(status), status);
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -136,7 +136,7 @@ static UINT encomsp_virtual_channel_write(encomspPlugin* encomsp, wStream* s)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT encomsp_recv_filter_updated_pdu(encomspPlugin* encomsp, wStream* s,
|
||||
ENCOMSP_ORDER_HEADER* header)
|
||||
ENCOMSP_ORDER_HEADER* header)
|
||||
{
|
||||
int beg, end;
|
||||
EncomspClientContext* context;
|
||||
@ -190,7 +190,7 @@ static UINT encomsp_recv_filter_updated_pdu(encomspPlugin* encomsp, wStream* s,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT encomsp_recv_application_created_pdu(encomspPlugin* encomsp,
|
||||
wStream* s, ENCOMSP_ORDER_HEADER* header)
|
||||
wStream* s, ENCOMSP_ORDER_HEADER* header)
|
||||
{
|
||||
int beg, end;
|
||||
EncomspClientContext* context;
|
||||
@ -252,7 +252,7 @@ static UINT encomsp_recv_application_created_pdu(encomspPlugin* encomsp,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT encomsp_recv_application_removed_pdu(encomspPlugin* encomsp,
|
||||
wStream* s, ENCOMSP_ORDER_HEADER* header)
|
||||
wStream* s, ENCOMSP_ORDER_HEADER* header)
|
||||
{
|
||||
int beg, end;
|
||||
EncomspClientContext* context;
|
||||
@ -306,7 +306,7 @@ static UINT encomsp_recv_application_removed_pdu(encomspPlugin* encomsp,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT encomsp_recv_window_created_pdu(encomspPlugin* encomsp, wStream* s,
|
||||
ENCOMSP_ORDER_HEADER* header)
|
||||
ENCOMSP_ORDER_HEADER* header)
|
||||
{
|
||||
int beg, end;
|
||||
EncomspClientContext* context;
|
||||
@ -369,7 +369,7 @@ static UINT encomsp_recv_window_created_pdu(encomspPlugin* encomsp, wStream* s,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT encomsp_recv_window_removed_pdu(encomspPlugin* encomsp, wStream* s,
|
||||
ENCOMSP_ORDER_HEADER* header)
|
||||
ENCOMSP_ORDER_HEADER* header)
|
||||
{
|
||||
int beg, end;
|
||||
EncomspClientContext* context;
|
||||
@ -423,7 +423,7 @@ static UINT encomsp_recv_window_removed_pdu(encomspPlugin* encomsp, wStream* s,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT encomsp_recv_show_window_pdu(encomspPlugin* encomsp, wStream* s,
|
||||
ENCOMSP_ORDER_HEADER* header)
|
||||
ENCOMSP_ORDER_HEADER* header)
|
||||
{
|
||||
int beg, end;
|
||||
EncomspClientContext* context;
|
||||
@ -477,7 +477,7 @@ static UINT encomsp_recv_show_window_pdu(encomspPlugin* encomsp, wStream* s,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT encomsp_recv_participant_created_pdu(encomspPlugin* encomsp,
|
||||
wStream* s, ENCOMSP_ORDER_HEADER* header)
|
||||
wStream* s, ENCOMSP_ORDER_HEADER* header)
|
||||
{
|
||||
int beg, end;
|
||||
EncomspClientContext* context;
|
||||
@ -540,7 +540,7 @@ static UINT encomsp_recv_participant_created_pdu(encomspPlugin* encomsp,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT encomsp_recv_participant_removed_pdu(encomspPlugin* encomsp,
|
||||
wStream* s, ENCOMSP_ORDER_HEADER* header)
|
||||
wStream* s, ENCOMSP_ORDER_HEADER* header)
|
||||
{
|
||||
int beg, end;
|
||||
EncomspClientContext* context;
|
||||
@ -641,7 +641,7 @@ static UINT encomsp_recv_change_participant_control_level_pdu(
|
||||
|
||||
if (error)
|
||||
WLog_ERR(TAG, "context->ChangeParticipantControlLevel failed with error %lu",
|
||||
error);
|
||||
error);
|
||||
|
||||
return error;
|
||||
}
|
||||
@ -687,7 +687,7 @@ static UINT encomsp_send_change_participant_control_level_pdu(
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT encomsp_recv_graphics_stream_paused_pdu(encomspPlugin* encomsp,
|
||||
wStream* s, ENCOMSP_ORDER_HEADER* header)
|
||||
wStream* s, ENCOMSP_ORDER_HEADER* header)
|
||||
{
|
||||
int beg, end;
|
||||
EncomspClientContext* context;
|
||||
@ -733,7 +733,7 @@ static UINT encomsp_recv_graphics_stream_paused_pdu(encomspPlugin* encomsp,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT encomsp_recv_graphics_stream_resumed_pdu(encomspPlugin* encomsp,
|
||||
wStream* s, ENCOMSP_ORDER_HEADER* header)
|
||||
wStream* s, ENCOMSP_ORDER_HEADER* header)
|
||||
{
|
||||
int beg, end;
|
||||
EncomspClientContext* context;
|
||||
@ -808,7 +808,7 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
|
||||
if ((error = encomsp_recv_application_removed_pdu(encomsp, s, &header)))
|
||||
{
|
||||
WLog_ERR(TAG, "encomsp_recv_application_removed_pdu failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -818,7 +818,7 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
|
||||
if ((error = encomsp_recv_application_created_pdu(encomsp, s, &header)))
|
||||
{
|
||||
WLog_ERR(TAG, "encomsp_recv_application_removed_pdu failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -855,7 +855,7 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
|
||||
if ((error = encomsp_recv_participant_removed_pdu(encomsp, s, &header)))
|
||||
{
|
||||
WLog_ERR(TAG, "encomsp_recv_participant_removed_pdu failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -865,7 +865,7 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
|
||||
if ((error = encomsp_recv_participant_created_pdu(encomsp, s, &header)))
|
||||
{
|
||||
WLog_ERR(TAG, "encomsp_recv_participant_created_pdu failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -873,11 +873,11 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
|
||||
|
||||
case ODTYPE_PARTICIPANT_CTRL_CHANGED:
|
||||
if ((error = encomsp_recv_change_participant_control_level_pdu(encomsp, s,
|
||||
&header)))
|
||||
&header)))
|
||||
{
|
||||
WLog_ERR(TAG,
|
||||
"encomsp_recv_change_participant_control_level_pdu failed with error %lu!",
|
||||
error);
|
||||
"encomsp_recv_change_participant_control_level_pdu failed with error %lu!",
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -887,7 +887,7 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
|
||||
if ((error = encomsp_recv_graphics_stream_paused_pdu(encomsp, s, &header)))
|
||||
{
|
||||
WLog_ERR(TAG, "encomsp_recv_graphics_stream_paused_pdu failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -897,7 +897,7 @@ static UINT encomsp_process_receive(encomspPlugin* encomsp, wStream* s)
|
||||
if ((error = encomsp_recv_graphics_stream_resumed_pdu(encomsp, s, &header)))
|
||||
{
|
||||
WLog_ERR(TAG, "encomsp_recv_graphics_stream_resumed_pdu failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -929,14 +929,14 @@ static int encomsp_send(encomspPlugin* encomsp, wStream* s)
|
||||
else
|
||||
{
|
||||
status = plugin->channelEntryPoints.pVirtualChannelWrite(plugin->OpenHandle,
|
||||
Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
|
||||
Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
|
||||
}
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
Stream_Free(s, TRUE);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
WTSErrorToString(status), status);
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -948,7 +948,7 @@ static int encomsp_send(encomspPlugin* encomsp, wStream* s)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT encomsp_virtual_channel_event_data_received(encomspPlugin* encomsp,
|
||||
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
{
|
||||
wStream* data_in;
|
||||
|
||||
@ -1002,8 +1002,8 @@ static UINT encomsp_virtual_channel_event_data_received(encomspPlugin* encomsp,
|
||||
}
|
||||
|
||||
static VOID VCAPITYPE encomsp_virtual_channel_open_event(DWORD openHandle,
|
||||
UINT event,
|
||||
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
UINT event,
|
||||
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
{
|
||||
encomspPlugin* encomsp = s_TLSPluginContext;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
@ -1018,9 +1018,9 @@ static VOID VCAPITYPE encomsp_virtual_channel_open_event(DWORD openHandle,
|
||||
{
|
||||
case CHANNEL_EVENT_DATA_RECEIVED:
|
||||
if ((error = encomsp_virtual_channel_event_data_received(encomsp, pData,
|
||||
dataLength, totalLength, dataFlags)))
|
||||
dataLength, totalLength, dataFlags)))
|
||||
WLog_ERR(TAG,
|
||||
"encomsp_virtual_channel_event_data_received failed with error %lu", error);
|
||||
"encomsp_virtual_channel_event_data_received failed with error %lu", error);
|
||||
|
||||
break;
|
||||
|
||||
@ -1034,7 +1034,7 @@ static VOID VCAPITYPE encomsp_virtual_channel_open_event(DWORD openHandle,
|
||||
|
||||
if (error && encomsp->rdpcontext)
|
||||
setChannelError(encomsp->rdpcontext, error,
|
||||
"encomsp_virtual_channel_open_event reported an error");
|
||||
"encomsp_virtual_channel_open_event reported an error");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1045,6 +1045,8 @@ static void* encomsp_virtual_channel_client_thread(void* arg)
|
||||
wMessage message;
|
||||
encomspPlugin* encomsp = (encomspPlugin*) arg;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
freerdp_channel_init_thread_context(encomsp->rdpcontext);
|
||||
encomsp_process_connect(encomsp);
|
||||
|
||||
while (1)
|
||||
@ -1080,7 +1082,7 @@ static void* encomsp_virtual_channel_client_thread(void* arg)
|
||||
|
||||
if (error && encomsp->rdpcontext)
|
||||
setChannelError(encomsp->rdpcontext, error,
|
||||
"encomsp_virtual_channel_client_thread reported an error");
|
||||
"encomsp_virtual_channel_client_thread reported an error");
|
||||
|
||||
ExitThread((DWORD)error);
|
||||
return NULL;
|
||||
@ -1092,17 +1094,17 @@ static void* encomsp_virtual_channel_client_thread(void* arg)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT encomsp_virtual_channel_event_connected(encomspPlugin* encomsp,
|
||||
LPVOID pData, UINT32 dataLength)
|
||||
LPVOID pData, UINT32 dataLength)
|
||||
{
|
||||
UINT32 status;
|
||||
status = encomsp->channelEntryPoints.pVirtualChannelOpen(encomsp->InitHandle,
|
||||
&encomsp->OpenHandle, encomsp->channelDef.name,
|
||||
encomsp_virtual_channel_open_event);
|
||||
&encomsp->OpenHandle, encomsp->channelDef.name,
|
||||
encomsp_virtual_channel_open_event);
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
WTSErrorToString(status), status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -1115,8 +1117,8 @@ static UINT encomsp_virtual_channel_event_connected(encomspPlugin* encomsp,
|
||||
}
|
||||
|
||||
if (!(encomsp->thread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) encomsp_virtual_channel_client_thread, (void*) encomsp,
|
||||
0, NULL)))
|
||||
(LPTHREAD_START_ROUTINE) encomsp_virtual_channel_client_thread, (void*) encomsp,
|
||||
0, NULL)))
|
||||
{
|
||||
WLog_ERR(TAG, "CreateThread failed!");
|
||||
MessageQueue_Free(encomsp->queue);
|
||||
@ -1152,7 +1154,7 @@ static UINT encomsp_virtual_channel_event_disconnected(encomspPlugin* encomsp)
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
WTSErrorToString(rc), rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -1181,8 +1183,8 @@ static UINT encomsp_virtual_channel_event_terminated(encomspPlugin* encomsp)
|
||||
}
|
||||
|
||||
static VOID VCAPITYPE encomsp_virtual_channel_init_event(LPVOID pInitHandle,
|
||||
UINT event, LPVOID pData,
|
||||
UINT dataLength)
|
||||
UINT event, LPVOID pData,
|
||||
UINT dataLength)
|
||||
{
|
||||
encomspPlugin* encomsp = s_TLSPluginContext;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
@ -1197,16 +1199,16 @@ static VOID VCAPITYPE encomsp_virtual_channel_init_event(LPVOID pInitHandle,
|
||||
{
|
||||
case CHANNEL_EVENT_CONNECTED:
|
||||
if ((error = encomsp_virtual_channel_event_connected(encomsp, pData,
|
||||
dataLength)))
|
||||
dataLength)))
|
||||
WLog_ERR(TAG, "encomsp_virtual_channel_event_connected failed with error %lu",
|
||||
error);
|
||||
error);
|
||||
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_DISCONNECTED:
|
||||
if ((error = encomsp_virtual_channel_event_disconnected(encomsp)))
|
||||
WLog_ERR(TAG,
|
||||
"encomsp_virtual_channel_event_disconnected failed with error %lu", error);
|
||||
"encomsp_virtual_channel_event_disconnected failed with error %lu", error);
|
||||
|
||||
break;
|
||||
|
||||
@ -1220,7 +1222,7 @@ static VOID VCAPITYPE encomsp_virtual_channel_init_event(LPVOID pInitHandle,
|
||||
|
||||
if (error && encomsp->rdpcontext)
|
||||
setChannelError(encomsp->rdpcontext, error,
|
||||
"encomsp_virtual_channel_init_event reported an error");
|
||||
"encomsp_virtual_channel_init_event reported an error");
|
||||
}
|
||||
|
||||
/* encomsp is always built-in */
|
||||
@ -1280,22 +1282,22 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
}
|
||||
|
||||
CopyMemory(&(encomsp->channelEntryPoints), pEntryPoints,
|
||||
sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
rc = encomsp->channelEntryPoints.pVirtualChannelInit(&encomsp->InitHandle,
|
||||
&encomsp->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
||||
encomsp_virtual_channel_init_event);
|
||||
&encomsp->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
||||
encomsp_virtual_channel_init_event);
|
||||
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
WTSErrorToString(rc), rc);
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
encomsp->channelEntryPoints.pInterface = *
|
||||
(encomsp->channelEntryPoints.ppInterface);
|
||||
(encomsp->channelEntryPoints.ppInterface);
|
||||
encomsp->channelEntryPoints.ppInterface = &
|
||||
(encomsp->channelEntryPoints.pInterface);
|
||||
(encomsp->channelEntryPoints.pInterface);
|
||||
s_TLSPluginContext = encomsp;
|
||||
return TRUE;
|
||||
error_out:
|
||||
|
@ -187,6 +187,7 @@ static void* encomsp_server_thread(void* arg)
|
||||
|
||||
context = (EncomspServerContext*) arg;
|
||||
|
||||
freerdp_channel_init_thread_context(context->rdpcontext);
|
||||
buffer = NULL;
|
||||
BytesReturned = 0;
|
||||
ChannelEvent = NULL;
|
||||
@ -213,23 +214,23 @@ static void* encomsp_server_thread(void* arg)
|
||||
|
||||
while (1)
|
||||
{
|
||||
status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
|
||||
status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu", error);
|
||||
break;
|
||||
}
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu", error);
|
||||
break;
|
||||
}
|
||||
|
||||
status = WaitForSingleObject(context->priv->StopEvent, 0);
|
||||
status = WaitForSingleObject(context->priv->StopEvent, 0);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
break;
|
||||
}
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
break;
|
||||
}
|
||||
|
||||
if (status == WAIT_OBJECT_0)
|
||||
{
|
||||
@ -322,9 +323,9 @@ static UINT encomsp_server_stop(EncomspServerContext* context)
|
||||
|
||||
if (WaitForSingleObject(context->priv->Thread, INFINITE) == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
}
|
||||
CloseHandle(context->priv->Thread);
|
||||
|
||||
|
@ -316,6 +316,7 @@ static void* parallel_thread_func(void* arg)
|
||||
PARALLEL_DEVICE* parallel = (PARALLEL_DEVICE*) arg;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
freerdp_channel_init_thread_context(parallel->rdpcontext);
|
||||
while (1)
|
||||
{
|
||||
if (!MessageQueue_Wait(parallel->queue))
|
||||
@ -379,9 +380,9 @@ static UINT parallel_free(DEVICE* device)
|
||||
|
||||
if (MessageQueue_PostQuit(parallel->queue, 0) && (WaitForSingleObject(parallel->thread, INFINITE) == WAIT_FAILED))
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
return error;
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
return error;
|
||||
}
|
||||
CloseHandle(parallel->thread);
|
||||
|
||||
|
@ -230,15 +230,16 @@ static void* printer_thread_func(void* arg)
|
||||
HANDLE obj[] = {printer_dev->event, printer_dev->stopEvent};
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
freerdp_channel_init_thread_context(printer_dev->rdpcontext);
|
||||
while (1)
|
||||
{
|
||||
DWORD rc = WaitForMultipleObjects(2, obj, FALSE, INFINITE);
|
||||
if (rc == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu!", error);
|
||||
break;
|
||||
}
|
||||
if (rc == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu!", error);
|
||||
break;
|
||||
}
|
||||
|
||||
if (rc == WAIT_OBJECT_0 + 1)
|
||||
break;
|
||||
@ -299,9 +300,9 @@ static UINT printer_free(DEVICE* device)
|
||||
SetEvent(printer_dev->stopEvent);
|
||||
if (WaitForSingleObject(printer_dev->thread, INFINITE) == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
while ((irp = (IRP*) InterlockedPopEntrySList(printer_dev->pIrpList)) != NULL)
|
||||
|
@ -58,14 +58,14 @@ static UINT rail_send(railPlugin* rail, wStream* s)
|
||||
else
|
||||
{
|
||||
status = rail->channelEntryPoints.pVirtualChannelWrite(rail->OpenHandle,
|
||||
Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
|
||||
Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
|
||||
}
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
Stream_Free(s, TRUE);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
WTSErrorToString(status), status);
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -101,7 +101,7 @@ UINT rail_send_channel_data(railPlugin* rail, void* data, size_t length)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_client_execute(RailClientContext* context,
|
||||
RAIL_EXEC_ORDER* exec)
|
||||
RAIL_EXEC_ORDER* exec)
|
||||
{
|
||||
char* exeOrFile;
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
@ -117,11 +117,11 @@ static UINT rail_client_execute(RailClientContext* context,
|
||||
}
|
||||
|
||||
rail_string_to_unicode_string(exec->RemoteApplicationProgram,
|
||||
&exec->exeOrFile); /* RemoteApplicationProgram */
|
||||
&exec->exeOrFile); /* RemoteApplicationProgram */
|
||||
rail_string_to_unicode_string(exec->RemoteApplicationWorkingDir,
|
||||
&exec->workingDir); /* ShellWorkingDirectory */
|
||||
&exec->workingDir); /* ShellWorkingDirectory */
|
||||
rail_string_to_unicode_string(exec->RemoteApplicationArguments,
|
||||
&exec->arguments); /* RemoteApplicationCmdLine */
|
||||
&exec->arguments); /* RemoteApplicationCmdLine */
|
||||
return rail_send_client_exec_order(rail, exec);
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ static UINT rail_client_execute(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_client_activate(RailClientContext* context,
|
||||
RAIL_ACTIVATE_ORDER* activate)
|
||||
RAIL_ACTIVATE_ORDER* activate)
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
return rail_send_client_activate_order(rail, activate);
|
||||
@ -143,7 +143,7 @@ static UINT rail_client_activate(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_send_client_sysparam(RailClientContext* context,
|
||||
RAIL_SYSPARAM_ORDER* sysparam)
|
||||
RAIL_SYSPARAM_ORDER* sysparam)
|
||||
{
|
||||
wStream* s;
|
||||
int length;
|
||||
@ -201,7 +201,7 @@ static UINT rail_send_client_sysparam(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_client_system_param(RailClientContext* context,
|
||||
RAIL_SYSPARAM_ORDER* sysparam)
|
||||
RAIL_SYSPARAM_ORDER* sysparam)
|
||||
{
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
@ -291,7 +291,7 @@ static UINT rail_client_system_param(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_server_system_param(RailClientContext* context,
|
||||
RAIL_SYSPARAM_ORDER* sysparam)
|
||||
RAIL_SYSPARAM_ORDER* sysparam)
|
||||
{
|
||||
return CHANNEL_RC_OK; /* stub - should be registered by client */
|
||||
}
|
||||
@ -302,7 +302,7 @@ static UINT rail_server_system_param(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_client_system_command(RailClientContext* context,
|
||||
RAIL_SYSCOMMAND_ORDER* syscommand)
|
||||
RAIL_SYSCOMMAND_ORDER* syscommand)
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
return rail_send_client_syscommand_order(rail, syscommand);
|
||||
@ -314,7 +314,7 @@ static UINT rail_client_system_command(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_client_handshake(RailClientContext* context,
|
||||
RAIL_HANDSHAKE_ORDER* handshake)
|
||||
RAIL_HANDSHAKE_ORDER* handshake)
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
return rail_send_handshake_order(rail, handshake);
|
||||
@ -326,7 +326,7 @@ static UINT rail_client_handshake(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_server_handshake(RailClientContext* context,
|
||||
RAIL_HANDSHAKE_ORDER* handshake)
|
||||
RAIL_HANDSHAKE_ORDER* handshake)
|
||||
{
|
||||
return CHANNEL_RC_OK; /* stub - should be registered by client */
|
||||
}
|
||||
@ -337,7 +337,7 @@ static UINT rail_server_handshake(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_client_handshake_ex(RailClientContext* context,
|
||||
RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
|
||||
RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
return rail_send_handshake_ex_order(rail, handshakeEx);
|
||||
@ -349,7 +349,7 @@ static UINT rail_client_handshake_ex(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_server_handshake_ex(RailClientContext* context,
|
||||
RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
|
||||
RAIL_HANDSHAKE_EX_ORDER* handshakeEx)
|
||||
{
|
||||
return CHANNEL_RC_OK; /* stub - should be registered by client */
|
||||
}
|
||||
@ -360,7 +360,7 @@ static UINT rail_server_handshake_ex(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_client_notify_event(RailClientContext* context,
|
||||
RAIL_NOTIFY_EVENT_ORDER* notifyEvent)
|
||||
RAIL_NOTIFY_EVENT_ORDER* notifyEvent)
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
return rail_send_client_notify_event_order(rail, notifyEvent);
|
||||
@ -372,7 +372,7 @@ static UINT rail_client_notify_event(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_client_window_move(RailClientContext* context,
|
||||
RAIL_WINDOW_MOVE_ORDER* windowMove)
|
||||
RAIL_WINDOW_MOVE_ORDER* windowMove)
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
return rail_send_client_window_move_order(rail, windowMove);
|
||||
@ -384,7 +384,7 @@ static UINT rail_client_window_move(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_server_local_move_size(RailClientContext* context,
|
||||
RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
|
||||
RAIL_LOCALMOVESIZE_ORDER* localMoveSize)
|
||||
{
|
||||
return CHANNEL_RC_OK; /* stub - should be registered by client */
|
||||
}
|
||||
@ -395,7 +395,7 @@ static UINT rail_server_local_move_size(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_server_min_max_info(RailClientContext* context,
|
||||
RAIL_MINMAXINFO_ORDER* minMaxInfo)
|
||||
RAIL_MINMAXINFO_ORDER* minMaxInfo)
|
||||
{
|
||||
return CHANNEL_RC_OK; /* stub - should be registered by client */
|
||||
}
|
||||
@ -406,7 +406,7 @@ static UINT rail_server_min_max_info(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_client_information(RailClientContext* context,
|
||||
RAIL_CLIENT_STATUS_ORDER* clientStatus)
|
||||
RAIL_CLIENT_STATUS_ORDER* clientStatus)
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
return rail_send_client_status_order(rail, clientStatus);
|
||||
@ -418,7 +418,7 @@ static UINT rail_client_information(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_client_system_menu(RailClientContext* context,
|
||||
RAIL_SYSMENU_ORDER* sysmenu)
|
||||
RAIL_SYSMENU_ORDER* sysmenu)
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
return rail_send_client_sysmenu_order(rail, sysmenu);
|
||||
@ -430,7 +430,7 @@ static UINT rail_client_system_menu(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_client_language_bar_info(RailClientContext* context,
|
||||
RAIL_LANGBAR_INFO_ORDER* langBarInfo)
|
||||
RAIL_LANGBAR_INFO_ORDER* langBarInfo)
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
return rail_send_client_langbar_info_order(rail, langBarInfo);
|
||||
@ -442,7 +442,7 @@ static UINT rail_client_language_bar_info(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_server_language_bar_info(RailClientContext* context,
|
||||
RAIL_LANGBAR_INFO_ORDER* langBarInfo)
|
||||
RAIL_LANGBAR_INFO_ORDER* langBarInfo)
|
||||
{
|
||||
return CHANNEL_RC_OK; /* stub - should be registered by client */
|
||||
}
|
||||
@ -453,7 +453,7 @@ static UINT rail_server_language_bar_info(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_server_execute_result(RailClientContext* context,
|
||||
RAIL_EXEC_RESULT_ORDER* execResult)
|
||||
RAIL_EXEC_RESULT_ORDER* execResult)
|
||||
{
|
||||
return CHANNEL_RC_OK; /* stub - should be registered by client */
|
||||
}
|
||||
@ -464,7 +464,7 @@ static UINT rail_server_execute_result(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_client_get_appid_request(RailClientContext* context,
|
||||
RAIL_GET_APPID_REQ_ORDER* getAppIdReq)
|
||||
RAIL_GET_APPID_REQ_ORDER* getAppIdReq)
|
||||
{
|
||||
railPlugin* rail = (railPlugin*) context->handle;
|
||||
return rail_send_client_get_appid_req_order(rail, getAppIdReq);
|
||||
@ -476,7 +476,7 @@ static UINT rail_client_get_appid_request(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_server_get_appid_response(RailClientContext* context,
|
||||
RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
|
||||
RAIL_GET_APPID_RESP_ORDER* getAppIdResp)
|
||||
{
|
||||
return CHANNEL_RC_OK; /* stub - should be registered by client */
|
||||
}
|
||||
@ -487,7 +487,7 @@ static UINT rail_server_get_appid_response(RailClientContext* context,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_virtual_channel_event_data_received(railPlugin* rail,
|
||||
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
{
|
||||
wStream* data_in;
|
||||
|
||||
@ -543,8 +543,8 @@ static UINT rail_virtual_channel_event_data_received(railPlugin* rail,
|
||||
}
|
||||
|
||||
static VOID VCAPITYPE rail_virtual_channel_open_event(DWORD openHandle,
|
||||
UINT event,
|
||||
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
UINT event,
|
||||
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
{
|
||||
railPlugin* rail = s_TLSPluginContext;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
@ -559,9 +559,9 @@ static VOID VCAPITYPE rail_virtual_channel_open_event(DWORD openHandle,
|
||||
{
|
||||
case CHANNEL_EVENT_DATA_RECEIVED:
|
||||
if ((error = rail_virtual_channel_event_data_received(rail, pData, dataLength,
|
||||
totalLength, dataFlags)))
|
||||
totalLength, dataFlags)))
|
||||
WLog_ERR(TAG, "rail_virtual_channel_event_data_received failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
|
||||
break;
|
||||
|
||||
@ -575,7 +575,7 @@ static VOID VCAPITYPE rail_virtual_channel_open_event(DWORD openHandle,
|
||||
|
||||
if (error && rail->rdpcontext)
|
||||
setChannelError(rail->rdpcontext, error,
|
||||
"rail_virtual_channel_open_event reported an error");
|
||||
"rail_virtual_channel_open_event reported an error");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -587,6 +587,7 @@ static void* rail_virtual_channel_client_thread(void* arg)
|
||||
railPlugin* rail = (railPlugin*) arg;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
freerdp_channel_init_thread_context(rail->rdpcontext);
|
||||
while (1)
|
||||
{
|
||||
if (!MessageQueue_Wait(rail->queue))
|
||||
@ -620,7 +621,7 @@ static void* rail_virtual_channel_client_thread(void* arg)
|
||||
|
||||
if (error && rail->rdpcontext)
|
||||
setChannelError(rail->rdpcontext, error,
|
||||
"rail_virtual_channel_client_thread reported an error");
|
||||
"rail_virtual_channel_client_thread reported an error");
|
||||
|
||||
ExitThread((DWORD)error);
|
||||
return NULL;
|
||||
@ -632,16 +633,16 @@ static void* rail_virtual_channel_client_thread(void* arg)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rail_virtual_channel_event_connected(railPlugin* rail, LPVOID pData,
|
||||
UINT32 dataLength)
|
||||
UINT32 dataLength)
|
||||
{
|
||||
UINT status;
|
||||
status = rail->channelEntryPoints.pVirtualChannelOpen(rail->InitHandle,
|
||||
&rail->OpenHandle, rail->channelDef.name, rail_virtual_channel_open_event);
|
||||
&rail->OpenHandle, rail->channelDef.name, rail_virtual_channel_open_event);
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
WTSErrorToString(status), status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -654,8 +655,8 @@ static UINT rail_virtual_channel_event_connected(railPlugin* rail, LPVOID pData,
|
||||
}
|
||||
|
||||
if (!(rail->thread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) rail_virtual_channel_client_thread, (void*) rail, 0,
|
||||
NULL)))
|
||||
(LPTHREAD_START_ROUTINE) rail_virtual_channel_client_thread, (void*) rail, 0,
|
||||
NULL)))
|
||||
{
|
||||
WLog_ERR(TAG, "CreateThread failed!");
|
||||
MessageQueue_Free(rail->queue);
|
||||
@ -692,7 +693,7 @@ static UINT rail_virtual_channel_event_disconnected(railPlugin* rail)
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
WTSErrorToString(rc), rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -714,7 +715,7 @@ static void rail_virtual_channel_event_terminated(railPlugin* rail)
|
||||
}
|
||||
|
||||
static VOID VCAPITYPE rail_virtual_channel_init_event(LPVOID pInitHandle,
|
||||
UINT event, LPVOID pData, UINT dataLength)
|
||||
UINT event, LPVOID pData, UINT dataLength)
|
||||
{
|
||||
railPlugin* rail = s_TLSPluginContext;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
@ -730,14 +731,14 @@ static VOID VCAPITYPE rail_virtual_channel_init_event(LPVOID pInitHandle,
|
||||
case CHANNEL_EVENT_CONNECTED:
|
||||
if ((error = rail_virtual_channel_event_connected(rail, pData, dataLength)))
|
||||
WLog_ERR(TAG, "rail_virtual_channel_event_connected failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_DISCONNECTED:
|
||||
if ((error = rail_virtual_channel_event_disconnected(rail)))
|
||||
WLog_ERR(TAG, "rail_virtual_channel_event_disconnected failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
|
||||
break;
|
||||
|
||||
@ -748,7 +749,7 @@ static VOID VCAPITYPE rail_virtual_channel_init_event(LPVOID pInitHandle,
|
||||
|
||||
if (error && rail->rdpcontext)
|
||||
setChannelError(rail->rdpcontext, error,
|
||||
"rail_virtual_channel_init_event reported an error");
|
||||
"rail_virtual_channel_init_event reported an error");
|
||||
}
|
||||
|
||||
/* rail is always built-in */
|
||||
@ -821,15 +822,15 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
rail->log = WLog_Get("com.freerdp.channels.rail.client");
|
||||
WLog_Print(rail->log, WLOG_DEBUG, "VirtualChannelEntry");
|
||||
CopyMemory(&(rail->channelEntryPoints), pEntryPoints,
|
||||
sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
rc = rail->channelEntryPoints.pVirtualChannelInit(&rail->InitHandle,
|
||||
&rail->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
||||
rail_virtual_channel_init_event);
|
||||
&rail->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
||||
rail_virtual_channel_init_event);
|
||||
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
WTSErrorToString(rc), rc);
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ static WINPR_TLS rdpdrPlugin* s_TLSPluginContext = NULL;
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr,
|
||||
BOOL userLoggedOn);
|
||||
BOOL userLoggedOn);
|
||||
|
||||
/**
|
||||
* Function description
|
||||
@ -91,7 +91,7 @@ static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rdpdr_send_device_list_remove_request(rdpdrPlugin* rdpdr,
|
||||
UINT32 count, UINT32 ids[])
|
||||
UINT32 count, UINT32 ids[])
|
||||
{
|
||||
UINT32 i;
|
||||
wStream* s;
|
||||
@ -165,7 +165,7 @@ void first_hotplug(rdpdrPlugin* rdpdr)
|
||||
drive_path[1] = '\0';
|
||||
drive->Name = _strdup(drive_path);
|
||||
devman_load_device_service(rdpdr->devman, (RDPDR_DEVICE*)drive,
|
||||
rdpdr->rdpcontext);
|
||||
rdpdr->rdpcontext);
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ LRESULT CALLBACK hotplug_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
drive_path[1] = '\0';
|
||||
drive->Name = _strdup(drive_path);
|
||||
devman_load_device_service(rdpdr->devman, (RDPDR_DEVICE*)drive,
|
||||
rdpdr->rdpcontext);
|
||||
rdpdr->rdpcontext);
|
||||
rdpdr_send_device_list_announce_request(rdpdr, TRUE);
|
||||
}
|
||||
}
|
||||
@ -243,7 +243,7 @@ LRESULT CALLBACK hotplug_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
for (j = 0; j < count; j++)
|
||||
{
|
||||
device_ext = (DEVICE_DRIVE_EXT*)ListDictionary_GetItemValue(
|
||||
rdpdr->devman->devices, (void*)keys[j]);
|
||||
rdpdr->devman->devices, (void*)keys[j]);
|
||||
|
||||
if (device_ext->path[0] == drive_name_upper
|
||||
|| device_ext->path[0] == drive_name_lower)
|
||||
@ -255,7 +255,7 @@ LRESULT CALLBACK hotplug_proc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// dont end on error, just report ?
|
||||
WLog_ERR(TAG, "rdpdr_send_device_list_remove_request failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
}
|
||||
|
||||
break;
|
||||
@ -308,15 +308,15 @@ static void* drive_hotplug_thread_func(void* arg)
|
||||
RegisterClassEx(&wnd_cls);
|
||||
/* create window */
|
||||
hwnd = CreateWindowEx(0, L"DRIVE_HOTPLUG", NULL,
|
||||
0, 0, 0, 0, 0,
|
||||
NULL, NULL, NULL, NULL);
|
||||
0, 0, 0, 0, 0,
|
||||
NULL, NULL, NULL, NULL);
|
||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)rdpdr);
|
||||
rdpdr->hotplug_wnd = hwnd;
|
||||
/* register device interface to hwnd */
|
||||
NotificationFilter.dbch_size = sizeof(DEV_BROADCAST_HANDLE);
|
||||
NotificationFilter.dbch_devicetype = DBT_DEVTYP_HANDLE;
|
||||
hDevNotify = RegisterDeviceNotification(hwnd, &NotificationFilter,
|
||||
DEVICE_NOTIFY_WINDOW_HANDLE);
|
||||
DEVICE_NOTIFY_WINDOW_HANDLE);
|
||||
|
||||
/* message loop */
|
||||
while ((bRet = GetMessage(&msg, 0, 0, 0)) != 0)
|
||||
@ -424,7 +424,7 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr)
|
||||
{
|
||||
BOOL dev_found = FALSE;
|
||||
device_ext = (DEVICE_DRIVE_EXT*)ListDictionary_GetItemValue(
|
||||
rdpdr->devman->devices, (void*)keys[j]);
|
||||
rdpdr->devman->devices, (void*)keys[j]);
|
||||
|
||||
if (!device_ext)
|
||||
continue;
|
||||
@ -454,7 +454,7 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr)
|
||||
if ((error = rdpdr_send_device_list_remove_request(rdpdr, 1, ids)))
|
||||
{
|
||||
WLog_ERR(TAG, "rdpdr_send_device_list_remove_request failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
@ -493,7 +493,7 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr)
|
||||
}
|
||||
|
||||
if ((error = devman_load_device_service(rdpdr->devman, (RDPDR_DEVICE*)drive,
|
||||
rdpdr->rdpcontext)))
|
||||
rdpdr->rdpcontext)))
|
||||
{
|
||||
WLog_ERR(TAG, "devman_load_device_service failed!");
|
||||
free(drive->Path);
|
||||
@ -515,9 +515,9 @@ cleanup:
|
||||
|
||||
|
||||
static void drive_hotplug_fsevent_callback(ConstFSEventStreamRef streamRef,
|
||||
void* clientCallBackInfo,
|
||||
size_t numEvents, void* eventPaths, const FSEventStreamEventFlags eventFlags[],
|
||||
const FSEventStreamEventId eventIds[])
|
||||
void* clientCallBackInfo,
|
||||
size_t numEvents, void* eventPaths, const FSEventStreamEventFlags eventFlags[],
|
||||
const FSEventStreamEventId eventIds[])
|
||||
{
|
||||
rdpdrPlugin* rdpdr;
|
||||
int i;
|
||||
@ -558,13 +558,13 @@ static void* drive_hotplug_thread_func(void* arg)
|
||||
rdpdr = (rdpdrPlugin*) arg;
|
||||
CFStringRef path = CFSTR("/Volumes/");
|
||||
CFArrayRef pathsToWatch = CFArrayCreate(kCFAllocatorMalloc, (const void**)&path,
|
||||
1, NULL);
|
||||
1, NULL);
|
||||
FSEventStreamContext ctx;
|
||||
ZeroMemory(&ctx, sizeof(ctx));
|
||||
ctx.info = arg;
|
||||
fsev = FSEventStreamCreate(kCFAllocatorMalloc, drive_hotplug_fsevent_callback,
|
||||
&ctx, pathsToWatch, kFSEventStreamEventIdSinceNow, 1,
|
||||
kFSEventStreamCreateFlagNone);
|
||||
&ctx, pathsToWatch, kFSEventStreamEventIdSinceNow, 1,
|
||||
kFSEventStreamCreateFlagNone);
|
||||
rdpdr->runLoop = CFRunLoopGetCurrent();
|
||||
FSEventStreamScheduleWithRunLoop(fsev, rdpdr->runLoop, kCFRunLoopDefaultMode);
|
||||
FSEventStreamStart(fsev);
|
||||
@ -758,7 +758,7 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr)
|
||||
{
|
||||
BOOL dev_found = FALSE;
|
||||
device_ext = (DEVICE_DRIVE_EXT*)ListDictionary_GetItemValue(
|
||||
rdpdr->devman->devices, (void*)keys[j]);
|
||||
rdpdr->devman->devices, (void*)keys[j]);
|
||||
|
||||
if (!device_ext || !device_ext->path)
|
||||
continue;
|
||||
@ -786,7 +786,7 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr)
|
||||
if ((error = rdpdr_send_device_list_remove_request(rdpdr, 1, ids)))
|
||||
{
|
||||
WLog_ERR(TAG, "rdpdr_send_device_list_remove_request failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
@ -825,7 +825,7 @@ static UINT handle_hotplug(rdpdrPlugin* rdpdr)
|
||||
}
|
||||
|
||||
if ((error = devman_load_device_service(rdpdr->devman, (RDPDR_DEVICE*)drive,
|
||||
rdpdr->rdpcontext)))
|
||||
rdpdr->rdpcontext)))
|
||||
{
|
||||
WLog_ERR(TAG, "devman_load_device_service failed!");
|
||||
free(drive->Path);
|
||||
@ -865,6 +865,7 @@ static void* drive_hotplug_thread_func(void* arg)
|
||||
DWORD status;
|
||||
rdpdr = (rdpdrPlugin*) arg;
|
||||
|
||||
freerdp_channel_init_thread_context(rdpdr->rdpcontext);
|
||||
if (!(rdpdr->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL)))
|
||||
{
|
||||
WLog_ERR(TAG, "CreateEvent failed!");
|
||||
@ -922,7 +923,7 @@ out:
|
||||
|
||||
if (error && rdpdr->rdpcontext)
|
||||
setChannelError(rdpdr->rdpcontext, error,
|
||||
"drive_hotplug_thread_func reported an error");
|
||||
"drive_hotplug_thread_func reported an error");
|
||||
|
||||
CloseHandle(rdpdr->stopEvent);
|
||||
ExitThread((DWORD)error);
|
||||
@ -982,10 +983,10 @@ static UINT rdpdr_process_connect(rdpdrPlugin* rdpdr)
|
||||
|
||||
if (settings->ClientHostname)
|
||||
strncpy(rdpdr->computerName, settings->ClientHostname,
|
||||
sizeof(rdpdr->computerName) - 1);
|
||||
sizeof(rdpdr->computerName) - 1);
|
||||
else
|
||||
strncpy(rdpdr->computerName, settings->ComputerName,
|
||||
sizeof(rdpdr->computerName) - 1);
|
||||
sizeof(rdpdr->computerName) - 1);
|
||||
|
||||
for (index = 0; index < settings->DeviceCount; index++)
|
||||
{
|
||||
@ -996,7 +997,7 @@ static UINT rdpdr_process_connect(rdpdrPlugin* rdpdr)
|
||||
first_hotplug(rdpdr);
|
||||
|
||||
if (!(rdpdr->hotplugThread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) drive_hotplug_thread_func, rdpdr, 0, NULL)))
|
||||
(LPTHREAD_START_ROUTINE) drive_hotplug_thread_func, rdpdr, 0, NULL)))
|
||||
{
|
||||
WLog_ERR(TAG, "CreateThread failed!");
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
@ -1006,7 +1007,7 @@ static UINT rdpdr_process_connect(rdpdrPlugin* rdpdr)
|
||||
}
|
||||
|
||||
if ((error = devman_load_device_service(rdpdr->devman, device,
|
||||
rdpdr->rdpcontext)))
|
||||
rdpdr->rdpcontext)))
|
||||
{
|
||||
WLog_ERR(TAG, "devman_load_device_service failed with error %lu!", error);
|
||||
return error;
|
||||
@ -1017,7 +1018,7 @@ static UINT rdpdr_process_connect(rdpdrPlugin* rdpdr)
|
||||
}
|
||||
|
||||
static UINT rdpdr_process_server_announce_request(rdpdrPlugin* rdpdr,
|
||||
wStream* s)
|
||||
wStream* s)
|
||||
{
|
||||
if (Stream_GetRemainingLength(s) < 8)
|
||||
return ERROR_INVALID_DATA;
|
||||
@ -1068,7 +1069,7 @@ static UINT rdpdr_send_client_name_request(rdpdrPlugin* rdpdr)
|
||||
gethostname(rdpdr->computerName, sizeof(rdpdr->computerName) - 1);
|
||||
|
||||
computerNameLenW = ConvertToUnicode(CP_UTF8, 0, rdpdr->computerName, -1,
|
||||
&computerNameW, 0) * 2;
|
||||
&computerNameW, 0) * 2;
|
||||
s = Stream_New(NULL, 16 + computerNameLenW + 2);
|
||||
|
||||
if (!s)
|
||||
@ -1082,7 +1083,7 @@ static UINT rdpdr_send_client_name_request(rdpdrPlugin* rdpdr)
|
||||
Stream_Write_UINT32(s, 1); /* unicodeFlag, 0 for ASCII and 1 for Unicode */
|
||||
Stream_Write_UINT32(s, 0); /* codePage, must be set to zero */
|
||||
Stream_Write_UINT32(s, computerNameLenW +
|
||||
2); /* computerNameLen, including null terminator */
|
||||
2); /* computerNameLen, including null terminator */
|
||||
Stream_Write(s, computerNameW, computerNameLenW);
|
||||
Stream_Write_UINT16(s, 0); /* null terminator */
|
||||
free(computerNameW);
|
||||
@ -1090,7 +1091,7 @@ static UINT rdpdr_send_client_name_request(rdpdrPlugin* rdpdr)
|
||||
}
|
||||
|
||||
static UINT rdpdr_process_server_clientid_confirm(rdpdrPlugin* rdpdr,
|
||||
wStream* s)
|
||||
wStream* s)
|
||||
{
|
||||
UINT16 versionMajor;
|
||||
UINT16 versionMinor;
|
||||
@ -1121,7 +1122,7 @@ static UINT rdpdr_process_server_clientid_confirm(rdpdrPlugin* rdpdr,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr,
|
||||
BOOL userLoggedOn)
|
||||
BOOL userLoggedOn)
|
||||
{
|
||||
int i;
|
||||
BYTE c;
|
||||
@ -1153,7 +1154,7 @@ static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr,
|
||||
for (index = 0; index < keyCount; index++)
|
||||
{
|
||||
device = (DEVICE*) ListDictionary_GetItemValue(rdpdr->devman->devices,
|
||||
(void*) pKeys[index]);
|
||||
(void*) pKeys[index]);
|
||||
|
||||
/**
|
||||
* 1. versionMinor 0x0005 doesn't send PAKID_CORE_USER_LOGGEDON
|
||||
@ -1194,7 +1195,7 @@ static UINT rdpdr_send_device_list_announce_request(rdpdrPlugin* rdpdr,
|
||||
|
||||
count++;
|
||||
WLog_INFO(TAG, "registered device #%d: %s (type=%d id=%d)",
|
||||
count, device->name, device->type, device->id);
|
||||
count, device->name, device->type, device->id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1250,7 +1251,7 @@ static UINT rdpdr_process_init(rdpdrPlugin* rdpdr)
|
||||
for (index = 0; index < keyCount; index++)
|
||||
{
|
||||
device = (DEVICE*) ListDictionary_GetItemValue(rdpdr->devman->devices,
|
||||
(void*) pKeys[index]);
|
||||
(void*) pKeys[index]);
|
||||
IFCALLRET(device->Init, error, device);
|
||||
|
||||
if (error != CHANNEL_RC_OK)
|
||||
@ -1334,7 +1335,7 @@ static UINT rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s)
|
||||
if ((error = rdpdr_send_device_list_announce_request(rdpdr, FALSE)))
|
||||
{
|
||||
WLog_ERR(TAG, "rdpdr_send_device_list_announce_request failed with error %lu",
|
||||
error);
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -1344,7 +1345,7 @@ static UINT rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s)
|
||||
if ((error = rdpdr_send_device_list_announce_request(rdpdr, TRUE)))
|
||||
{
|
||||
WLog_ERR(TAG, "rdpdr_send_device_list_announce_request failed with error %lu",
|
||||
error);
|
||||
error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -1389,7 +1390,7 @@ static UINT rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s)
|
||||
|
||||
Stream_Read_UINT32(s, eventID);
|
||||
WLog_ERR(TAG,
|
||||
"Ignoring unhandled message PAKID_PRN_CACHE_DATA (EventID: 0x%04X)", eventID);
|
||||
"Ignoring unhandled message PAKID_PRN_CACHE_DATA (EventID: 0x%04X)", eventID);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -1405,7 +1406,7 @@ static UINT rdpdr_process_receive(rdpdrPlugin* rdpdr, wStream* s)
|
||||
else
|
||||
{
|
||||
WLog_ERR(TAG, "Unknown message: Component: 0x%04X PacketId: 0x%04X", component,
|
||||
packetId);
|
||||
packetId);
|
||||
return ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
@ -1431,14 +1432,14 @@ UINT rdpdr_send(rdpdrPlugin* rdpdr, wStream* s)
|
||||
else
|
||||
{
|
||||
status = plugin->channelEntryPoints.pVirtualChannelWrite(plugin->OpenHandle,
|
||||
Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
|
||||
Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
|
||||
}
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
Stream_Free(s, TRUE);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
WTSErrorToString(status), status);
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -1450,7 +1451,7 @@ UINT rdpdr_send(rdpdrPlugin* rdpdr, wStream* s)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rdpdr_virtual_channel_event_data_received(rdpdrPlugin* rdpdr,
|
||||
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
{
|
||||
wStream* data_in;
|
||||
|
||||
@ -1512,8 +1513,8 @@ static UINT rdpdr_virtual_channel_event_data_received(rdpdrPlugin* rdpdr,
|
||||
}
|
||||
|
||||
static VOID VCAPITYPE rdpdr_virtual_channel_open_event(DWORD openHandle,
|
||||
UINT event,
|
||||
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
UINT event,
|
||||
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
{
|
||||
rdpdrPlugin* rdpdr = s_TLSPluginContext;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
@ -1528,9 +1529,9 @@ static VOID VCAPITYPE rdpdr_virtual_channel_open_event(DWORD openHandle,
|
||||
{
|
||||
case CHANNEL_EVENT_DATA_RECEIVED:
|
||||
if ((error = rdpdr_virtual_channel_event_data_received(rdpdr, pData,
|
||||
dataLength, totalLength, dataFlags)))
|
||||
dataLength, totalLength, dataFlags)))
|
||||
WLog_ERR(TAG,
|
||||
"rdpdr_virtual_channel_event_data_received failed with error %lu!", error);
|
||||
"rdpdr_virtual_channel_event_data_received failed with error %lu!", error);
|
||||
|
||||
break;
|
||||
|
||||
@ -1544,7 +1545,7 @@ static VOID VCAPITYPE rdpdr_virtual_channel_open_event(DWORD openHandle,
|
||||
|
||||
if (error && rdpdr->rdpcontext)
|
||||
setChannelError(rdpdr->rdpcontext, error,
|
||||
"rdpdr_virtual_channel_open_event reported an error");
|
||||
"rdpdr_virtual_channel_open_event reported an error");
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1562,13 +1563,15 @@ static void* rdpdr_virtual_channel_client_thread(void* arg)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
freerdp_channel_init_thread_context(rdpdr->rdpcontext);
|
||||
s_TLSPluginContext = rdpdr;
|
||||
if ((error = rdpdr_process_connect(rdpdr)))
|
||||
{
|
||||
WLog_ERR(TAG, "rdpdr_process_connect failed with error %lu!", error);
|
||||
|
||||
if (rdpdr->rdpcontext)
|
||||
setChannelError(rdpdr->rdpcontext, error,
|
||||
"rdpdr_virtual_channel_client_thread reported an error");
|
||||
"rdpdr_virtual_channel_client_thread reported an error");
|
||||
|
||||
ExitThread((DWORD) error);
|
||||
return NULL;
|
||||
@ -1594,7 +1597,7 @@ static void* rdpdr_virtual_channel_client_thread(void* arg)
|
||||
|
||||
if (rdpdr->rdpcontext)
|
||||
setChannelError(rdpdr->rdpcontext, error,
|
||||
"rdpdr_virtual_channel_client_thread reported an error");
|
||||
"rdpdr_virtual_channel_client_thread reported an error");
|
||||
|
||||
ExitThread((DWORD) error);
|
||||
return NULL;
|
||||
@ -1613,16 +1616,16 @@ static void* rdpdr_virtual_channel_client_thread(void* arg)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rdpdr_virtual_channel_event_connected(rdpdrPlugin* rdpdr,
|
||||
LPVOID pData, UINT32 dataLength)
|
||||
LPVOID pData, UINT32 dataLength)
|
||||
{
|
||||
UINT32 status;
|
||||
status = rdpdr->channelEntryPoints.pVirtualChannelOpen(rdpdr->InitHandle,
|
||||
&rdpdr->OpenHandle, rdpdr->channelDef.name, rdpdr_virtual_channel_open_event);
|
||||
&rdpdr->OpenHandle, rdpdr->channelDef.name, rdpdr_virtual_channel_open_event);
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
WTSErrorToString(status), status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -1635,8 +1638,8 @@ static UINT rdpdr_virtual_channel_event_connected(rdpdrPlugin* rdpdr,
|
||||
}
|
||||
|
||||
if (!(rdpdr->thread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) rdpdr_virtual_channel_client_thread, (void*) rdpdr, 0,
|
||||
NULL)))
|
||||
(LPTHREAD_START_ROUTINE) rdpdr_virtual_channel_client_thread, (void*) rdpdr, 0,
|
||||
NULL)))
|
||||
{
|
||||
WLog_ERR(TAG, "CreateThread failed!");
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
@ -1678,7 +1681,7 @@ static UINT rdpdr_virtual_channel_event_disconnected(rdpdrPlugin* rdpdr)
|
||||
if (CHANNEL_RC_OK != error)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08X]",
|
||||
WTSErrorToString(error), error);
|
||||
WTSErrorToString(error), error);
|
||||
}
|
||||
|
||||
rdpdr->OpenHandle = 0;
|
||||
@ -1704,8 +1707,8 @@ static void rdpdr_virtual_channel_event_terminated(rdpdrPlugin* rdpdr)
|
||||
}
|
||||
|
||||
static VOID VCAPITYPE rdpdr_virtual_channel_init_event(LPVOID pInitHandle,
|
||||
UINT event,
|
||||
LPVOID pData, UINT dataLength)
|
||||
UINT event,
|
||||
LPVOID pData, UINT dataLength)
|
||||
{
|
||||
rdpdrPlugin* rdpdr = s_TLSPluginContext;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
@ -1724,14 +1727,14 @@ static VOID VCAPITYPE rdpdr_virtual_channel_init_event(LPVOID pInitHandle,
|
||||
case CHANNEL_EVENT_CONNECTED:
|
||||
if ((error = rdpdr_virtual_channel_event_connected(rdpdr, pData, dataLength)))
|
||||
WLog_ERR(TAG, "rdpdr_virtual_channel_event_connected failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_DISCONNECTED:
|
||||
if ((error = rdpdr_virtual_channel_event_disconnected(rdpdr)))
|
||||
WLog_ERR(TAG, "rdpdr_virtual_channel_event_disconnected failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
|
||||
break;
|
||||
|
||||
@ -1747,7 +1750,7 @@ static VOID VCAPITYPE rdpdr_virtual_channel_init_event(LPVOID pInitHandle,
|
||||
|
||||
if (error && rdpdr->rdpcontext)
|
||||
setChannelError(rdpdr->rdpcontext, error,
|
||||
"rdpdr_virtual_channel_init_event reported an error");
|
||||
"rdpdr_virtual_channel_init_event reported an error");
|
||||
}
|
||||
|
||||
/* rdpdr is always built-in */
|
||||
@ -1781,15 +1784,15 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
}
|
||||
|
||||
CopyMemory(&(rdpdr->channelEntryPoints), pEntryPoints,
|
||||
sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
rc = rdpdr->channelEntryPoints.pVirtualChannelInit(&rdpdr->InitHandle,
|
||||
&rdpdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
||||
rdpdr_virtual_channel_init_event);
|
||||
&rdpdr->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
||||
rdpdr_virtual_channel_init_event);
|
||||
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
WTSErrorToString(rc), rc);
|
||||
free(rdpdr);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1101,6 +1101,7 @@ static void* rdpdr_server_thread(void* arg)
|
||||
BytesReturned = 0;
|
||||
ChannelEvent = NULL;
|
||||
|
||||
freerdp_channel_init_thread_context(context->rdpcontext);
|
||||
s = Stream_New(NULL, 4096);
|
||||
if (!s)
|
||||
{
|
||||
@ -1131,24 +1132,24 @@ static void* rdpdr_server_thread(void* arg)
|
||||
BytesReturned = 0;
|
||||
status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu!", error);
|
||||
goto out_stream;
|
||||
}
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu!", error);
|
||||
goto out_stream;
|
||||
}
|
||||
|
||||
status = WaitForSingleObject(context->priv->StopEvent, 0);
|
||||
status = WaitForSingleObject(context->priv->StopEvent, 0);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
goto out_stream;
|
||||
}
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
goto out_stream;
|
||||
}
|
||||
|
||||
|
||||
if (status == WAIT_OBJECT_0)
|
||||
if (status == WAIT_OBJECT_0)
|
||||
break;
|
||||
|
||||
if (!WTSVirtualChannelRead(context->priv->ChannelHandle, 0,
|
||||
@ -1231,11 +1232,11 @@ static UINT rdpdr_server_stop(RdpdrServerContext* context)
|
||||
{
|
||||
SetEvent(context->priv->StopEvent);
|
||||
if (WaitForSingleObject(context->priv->Thread, INFINITE) == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
return error;
|
||||
}
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
return error;
|
||||
}
|
||||
CloseHandle(context->priv->Thread);
|
||||
context->priv->Thread = NULL;
|
||||
CloseHandle(context->priv->StopEvent);
|
||||
|
@ -176,6 +176,7 @@ static void* rdpei_schedule_thread(void* arg)
|
||||
HANDLE hdl[] = {rdpei->event, rdpei->stopEvent};
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
freerdp_channel_init_thread_context(rdpei->rdpcontext);
|
||||
if (!rdpei)
|
||||
{
|
||||
error = ERROR_INVALID_PARAMETER;
|
||||
@ -193,12 +194,12 @@ static void* rdpei_schedule_thread(void* arg)
|
||||
{
|
||||
status = WaitForMultipleObjects(2, hdl, FALSE, 20);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu!", error);
|
||||
break;
|
||||
}
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu!", error);
|
||||
break;
|
||||
}
|
||||
|
||||
if (status == WAIT_OBJECT_0 + 1)
|
||||
break;
|
||||
@ -700,9 +701,9 @@ static UINT rdpei_plugin_terminated(IWTSPlugin* pPlugin)
|
||||
|
||||
if (WaitForSingleObject(rdpei->thread, INFINITE) == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
return error;
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
CloseHandle(rdpei->stopEvent);
|
||||
|
@ -1313,6 +1313,8 @@ static void* rdpgfx_server_thread_func(void* arg)
|
||||
buffer = NULL;
|
||||
BytesReturned = 0;
|
||||
nCount = 0;
|
||||
|
||||
freerdp_channel_init_thread_context(context->rdpcontext);
|
||||
events[nCount++] = priv->stopEvent;
|
||||
events[nCount++] = priv->channelEvent;
|
||||
|
||||
|
@ -113,6 +113,8 @@ static void* rdpsnd_schedule_thread(void* arg)
|
||||
HANDLE events[2];
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
DWORD status;
|
||||
|
||||
freerdp_channel_init_thread_context(rdpsnd->rdpcontext);
|
||||
events[0] = MessageQueue_Event(rdpsnd->MsgPipe->Out);
|
||||
events[1] = rdpsnd->stopEvent;
|
||||
|
||||
@ -180,7 +182,7 @@ static void* rdpsnd_schedule_thread(void* arg)
|
||||
|
||||
if (error && rdpsnd->rdpcontext)
|
||||
setChannelError(rdpsnd->rdpcontext, error,
|
||||
"rdpsnd_schedule_thread reported an error");
|
||||
"rdpsnd_schedule_thread reported an error");
|
||||
|
||||
ExitThread((DWORD)error);
|
||||
return NULL;
|
||||
@ -224,7 +226,7 @@ static void rdpsnd_select_supported_audio_formats(rdpsndPlugin* rdpsnd)
|
||||
return;
|
||||
|
||||
rdpsnd->ClientFormats = (AUDIO_FORMAT*) malloc(sizeof(AUDIO_FORMAT) *
|
||||
rdpsnd->NumberOfServerFormats);
|
||||
rdpsnd->NumberOfServerFormats);
|
||||
|
||||
for (index = 0; index < (int) rdpsnd->NumberOfServerFormats; index++)
|
||||
{
|
||||
@ -261,11 +263,11 @@ static void rdpsnd_select_supported_audio_formats(rdpsndPlugin* rdpsnd)
|
||||
#if 0
|
||||
WLog_ERR(TAG, "Server ");
|
||||
rdpsnd_print_audio_formats(rdpsnd->ServerFormats,
|
||||
rdpsnd->NumberOfServerFormats);
|
||||
rdpsnd->NumberOfServerFormats);
|
||||
WLog_ERR(TAG, "");
|
||||
WLog_ERR(TAG, "Client ");
|
||||
rdpsnd_print_audio_formats(rdpsnd->ClientFormats,
|
||||
rdpsnd->NumberOfClientFormats);
|
||||
rdpsnd->NumberOfClientFormats);
|
||||
WLog_ERR(TAG, "");
|
||||
#endif
|
||||
}
|
||||
@ -346,7 +348,7 @@ static UINT rdpsnd_send_client_audio_formats(rdpsndPlugin* rdpsnd)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd,
|
||||
wStream* s)
|
||||
wStream* s)
|
||||
{
|
||||
int index;
|
||||
UINT16 wVersion;
|
||||
@ -375,7 +377,7 @@ static UINT rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd,
|
||||
return ERROR_BAD_LENGTH;
|
||||
|
||||
rdpsnd->ServerFormats = (AUDIO_FORMAT*) calloc(wNumberOfFormats,
|
||||
sizeof(AUDIO_FORMAT));
|
||||
sizeof(AUDIO_FORMAT));
|
||||
|
||||
if (!rdpsnd->ServerFormats)
|
||||
return CHANNEL_RC_NO_MEMORY;
|
||||
@ -439,7 +441,7 @@ out_fail:
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rdpsnd_send_training_confirm_pdu(rdpsndPlugin* rdpsnd,
|
||||
UINT16 wTimeStamp, UINT16 wPackSize)
|
||||
UINT16 wTimeStamp, UINT16 wPackSize)
|
||||
{
|
||||
wStream* pdu;
|
||||
pdu = Stream_New(NULL, 8);
|
||||
@ -456,8 +458,8 @@ static UINT rdpsnd_send_training_confirm_pdu(rdpsndPlugin* rdpsnd,
|
||||
Stream_Write_UINT16(pdu, wTimeStamp);
|
||||
Stream_Write_UINT16(pdu, wPackSize);
|
||||
WLog_Print(rdpsnd->log, WLOG_DEBUG,
|
||||
"Training Response: wTimeStamp: %d wPackSize: %d",
|
||||
wTimeStamp, wPackSize);
|
||||
"Training Response: wTimeStamp: %d wPackSize: %d",
|
||||
wTimeStamp, wPackSize);
|
||||
return rdpsnd_virtual_channel_write(rdpsnd, pdu);
|
||||
}
|
||||
|
||||
@ -477,8 +479,8 @@ static UINT rdpsnd_recv_training_pdu(rdpsndPlugin* rdpsnd, wStream* s)
|
||||
Stream_Read_UINT16(s, wTimeStamp);
|
||||
Stream_Read_UINT16(s, wPackSize);
|
||||
WLog_Print(rdpsnd->log, WLOG_DEBUG,
|
||||
"Training Request: wTimeStamp: %d wPackSize: %d",
|
||||
wTimeStamp, wPackSize);
|
||||
"Training Request: wTimeStamp: %d wPackSize: %d",
|
||||
wTimeStamp, wPackSize);
|
||||
return rdpsnd_send_training_confirm_pdu(rdpsnd, wTimeStamp, wPackSize);
|
||||
}
|
||||
|
||||
@ -488,7 +490,7 @@ static UINT rdpsnd_recv_training_pdu(rdpsndPlugin* rdpsnd, wStream* s)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rdpsnd_recv_wave_info_pdu(rdpsndPlugin* rdpsnd, wStream* s,
|
||||
UINT16 BodySize)
|
||||
UINT16 BodySize)
|
||||
{
|
||||
UINT16 wFormatNo;
|
||||
AUDIO_FORMAT* format;
|
||||
@ -505,7 +507,7 @@ static UINT rdpsnd_recv_wave_info_pdu(rdpsndPlugin* rdpsnd, wStream* s,
|
||||
rdpsnd->waveDataSize = BodySize - 8;
|
||||
format = &rdpsnd->ClientFormats[wFormatNo];
|
||||
WLog_Print(rdpsnd->log, WLOG_DEBUG, "WaveInfo: cBlockNo: %d wFormatNo: %d",
|
||||
rdpsnd->cBlockNo, wFormatNo);
|
||||
rdpsnd->cBlockNo, wFormatNo);
|
||||
|
||||
if (!rdpsnd->isOpen)
|
||||
{
|
||||
@ -541,7 +543,7 @@ static UINT rdpsnd_recv_wave_info_pdu(rdpsndPlugin* rdpsnd, wStream* s,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rdpsnd_send_wave_confirm_pdu(rdpsndPlugin* rdpsnd,
|
||||
UINT16 wTimeStamp, BYTE cConfirmedBlockNo)
|
||||
UINT16 wTimeStamp, BYTE cConfirmedBlockNo)
|
||||
{
|
||||
wStream* pdu;
|
||||
pdu = Stream_New(NULL, 8);
|
||||
@ -569,8 +571,8 @@ static UINT rdpsnd_send_wave_confirm_pdu(rdpsndPlugin* rdpsnd,
|
||||
static UINT rdpsnd_confirm_wave(rdpsndPlugin* rdpsnd, RDPSND_WAVE* wave)
|
||||
{
|
||||
WLog_Print(rdpsnd->log, WLOG_DEBUG,
|
||||
"WaveConfirm: cBlockNo: %d wTimeStamp: %d wTimeDiff: %d",
|
||||
wave->cBlockNo, wave->wTimeStampB, wave->wTimeStampB - wave->wTimeStampA);
|
||||
"WaveConfirm: cBlockNo: %d wTimeStamp: %d wTimeDiff: %d",
|
||||
wave->cBlockNo, wave->wTimeStampB, wave->wTimeStampB - wave->wTimeStampA);
|
||||
return rdpsnd_send_wave_confirm_pdu(rdpsnd, wave->wTimeStampB, wave->cBlockNo);
|
||||
}
|
||||
|
||||
@ -580,13 +582,13 @@ static UINT rdpsnd_confirm_wave(rdpsndPlugin* rdpsnd, RDPSND_WAVE* wave)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rdpsnd_device_send_wave_confirm_pdu(rdpsndDevicePlugin* device,
|
||||
RDPSND_WAVE* wave)
|
||||
RDPSND_WAVE* wave)
|
||||
{
|
||||
if (device->DisableConfirmThread)
|
||||
return rdpsnd_confirm_wave(device->rdpsnd, wave);
|
||||
|
||||
if (!MessageQueue_Post(device->rdpsnd->MsgPipe->Out, NULL, 0, (void*) wave,
|
||||
NULL))
|
||||
NULL))
|
||||
{
|
||||
WLog_ERR(TAG, "MessageQueue_Post failed!");
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
@ -635,7 +637,7 @@ static UINT rdpsnd_recv_wave_pdu(rdpsndPlugin* rdpsnd, wStream* s)
|
||||
format = &rdpsnd->ClientFormats[rdpsnd->wCurrentFormatNo];
|
||||
wave->wAudioLength = rdpsnd_compute_audio_time_length(format, size);
|
||||
WLog_Print(rdpsnd->log, WLOG_DEBUG, "Wave: cBlockNo: %d wTimeStamp: %d",
|
||||
wave->cBlockNo, wave->wTimeStampA);
|
||||
wave->cBlockNo, wave->wTimeStampA);
|
||||
|
||||
if (!rdpsnd->device)
|
||||
{
|
||||
@ -775,7 +777,7 @@ out:
|
||||
}
|
||||
|
||||
static void rdpsnd_register_device_plugin(rdpsndPlugin* rdpsnd,
|
||||
rdpsndDevicePlugin* device)
|
||||
rdpsndDevicePlugin* device)
|
||||
{
|
||||
if (rdpsnd->device)
|
||||
{
|
||||
@ -794,14 +796,14 @@ static void rdpsnd_register_device_plugin(rdpsndPlugin* rdpsnd,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rdpsnd_load_device_plugin(rdpsndPlugin* rdpsnd, const char* name,
|
||||
ADDIN_ARGV* args)
|
||||
ADDIN_ARGV* args)
|
||||
{
|
||||
PFREERDP_RDPSND_DEVICE_ENTRY entry;
|
||||
FREERDP_RDPSND_DEVICE_ENTRY_POINTS entryPoints;
|
||||
\
|
||||
UINT error;
|
||||
entry = (PFREERDP_RDPSND_DEVICE_ENTRY)
|
||||
freerdp_load_channel_addin_entry("rdpsnd", (LPSTR) name, NULL, 0);
|
||||
freerdp_load_channel_addin_entry("rdpsnd", (LPSTR) name, NULL, 0);
|
||||
|
||||
if (!entry)
|
||||
return ERROR_INTERNAL_ERROR;
|
||||
@ -859,7 +861,7 @@ static UINT rdpsnd_process_addin_args(rdpsndPlugin* rdpsnd, ADDIN_ARGV* args)
|
||||
{
|
||||
flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON;
|
||||
status = CommandLineParseArgumentsA(args->argc, (const char**) args->argv,
|
||||
rdpsnd_args, flags, rdpsnd, NULL, NULL);
|
||||
rdpsnd_args, flags, rdpsnd, NULL, NULL);
|
||||
|
||||
if (status < 0)
|
||||
return CHANNEL_RC_INITIALIZATION_ERROR;
|
||||
@ -956,7 +958,7 @@ static UINT rdpsnd_process_connect(rdpsndPlugin* rdpsnd)
|
||||
if ((status = rdpsnd_load_device_plugin(rdpsnd, rdpsnd->subsystem, args)))
|
||||
{
|
||||
WLog_ERR(TAG, "unable to load the %s subsystem plugin because of error %lu",
|
||||
rdpsnd->subsystem, status);
|
||||
rdpsnd->subsystem, status);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@ -971,7 +973,7 @@ static UINT rdpsnd_process_connect(rdpsndPlugin* rdpsnd)
|
||||
|
||||
if ((status = rdpsnd_load_device_plugin(rdpsnd, subsystem_name, args)))
|
||||
WLog_ERR(TAG, "unable to load the %s subsystem plugin because of error %lu",
|
||||
subsystem_name, status);
|
||||
subsystem_name, status);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -984,7 +986,7 @@ static UINT rdpsnd_process_connect(rdpsndPlugin* rdpsnd)
|
||||
|
||||
if ((status = rdpsnd_load_device_plugin(rdpsnd, subsystem_name, args)))
|
||||
WLog_ERR(TAG, "unable to load the %s subsystem plugin because of error %lu",
|
||||
subsystem_name, status);
|
||||
subsystem_name, status);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -997,7 +999,7 @@ static UINT rdpsnd_process_connect(rdpsndPlugin* rdpsnd)
|
||||
|
||||
if ((status = rdpsnd_load_device_plugin(rdpsnd, subsystem_name, args)))
|
||||
WLog_ERR(TAG, "unable to load the %s subsystem plugin because of error %lu",
|
||||
subsystem_name, status);
|
||||
subsystem_name, status);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1010,7 +1012,7 @@ static UINT rdpsnd_process_connect(rdpsndPlugin* rdpsnd)
|
||||
|
||||
if ((status = rdpsnd_load_device_plugin(rdpsnd, subsystem_name, args)))
|
||||
WLog_ERR(TAG, "unable to load the %s subsystem plugin because of error %lu",
|
||||
subsystem_name, status);
|
||||
subsystem_name, status);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1023,7 +1025,7 @@ static UINT rdpsnd_process_connect(rdpsndPlugin* rdpsnd)
|
||||
|
||||
if ((status = rdpsnd_load_device_plugin(rdpsnd, subsystem_name, args)))
|
||||
WLog_ERR(TAG, "unable to load the %s subsystem plugin because of error %lu",
|
||||
subsystem_name, status);
|
||||
subsystem_name, status);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1036,7 +1038,7 @@ static UINT rdpsnd_process_connect(rdpsndPlugin* rdpsnd)
|
||||
|
||||
if ((status = rdpsnd_load_device_plugin(rdpsnd, subsystem_name, args)))
|
||||
WLog_ERR(TAG, "unable to load the %s subsystem plugin because of error %lu",
|
||||
subsystem_name, status);
|
||||
subsystem_name, status);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1049,7 +1051,7 @@ static UINT rdpsnd_process_connect(rdpsndPlugin* rdpsnd)
|
||||
|
||||
if ((status = rdpsnd_load_device_plugin(rdpsnd, subsystem_name, args)))
|
||||
WLog_ERR(TAG, "unable to load the %s subsystem plugin because of error %lu",
|
||||
subsystem_name, status);
|
||||
subsystem_name, status);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1082,8 +1084,8 @@ static UINT rdpsnd_process_connect(rdpsndPlugin* rdpsnd)
|
||||
}
|
||||
|
||||
rdpsnd->ScheduleThread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) rdpsnd_schedule_thread,
|
||||
(void*) rdpsnd, 0, NULL);
|
||||
(LPTHREAD_START_ROUTINE) rdpsnd_schedule_thread,
|
||||
(void*) rdpsnd, 0, NULL);
|
||||
|
||||
if (!rdpsnd->ScheduleThread)
|
||||
{
|
||||
@ -1128,14 +1130,14 @@ UINT rdpsnd_virtual_channel_write(rdpsndPlugin* rdpsnd, wStream* s)
|
||||
else
|
||||
{
|
||||
status = rdpsnd->channelEntryPoints.pVirtualChannelWrite(rdpsnd->OpenHandle,
|
||||
Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
|
||||
Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
|
||||
}
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
Stream_Free(s, TRUE);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
WTSErrorToString(status), status);
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -1147,7 +1149,7 @@ UINT rdpsnd_virtual_channel_write(rdpsndPlugin* rdpsnd, wStream* s)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rdpsnd_virtual_channel_event_data_received(rdpsndPlugin* plugin,
|
||||
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
{
|
||||
wStream* s;
|
||||
|
||||
@ -1203,8 +1205,8 @@ static UINT rdpsnd_virtual_channel_event_data_received(rdpsndPlugin* plugin,
|
||||
}
|
||||
|
||||
static VOID VCAPITYPE rdpsnd_virtual_channel_open_event(DWORD openHandle,
|
||||
UINT event,
|
||||
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
UINT event,
|
||||
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
{
|
||||
rdpsndPlugin* rdpsnd = s_TLSPluginContext;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
@ -1219,9 +1221,9 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_open_event(DWORD openHandle,
|
||||
{
|
||||
case CHANNEL_EVENT_DATA_RECEIVED:
|
||||
if ((error = rdpsnd_virtual_channel_event_data_received(rdpsnd, pData,
|
||||
dataLength, totalLength, dataFlags)))
|
||||
dataLength, totalLength, dataFlags)))
|
||||
WLog_ERR(TAG,
|
||||
"rdpsnd_virtual_channel_event_data_received failed with error %lu", error);
|
||||
"rdpsnd_virtual_channel_event_data_received failed with error %lu", error);
|
||||
|
||||
break;
|
||||
|
||||
@ -1235,7 +1237,7 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_open_event(DWORD openHandle,
|
||||
|
||||
if (error && rdpsnd->rdpcontext)
|
||||
setChannelError(rdpsnd->rdpcontext, error,
|
||||
"rdpsnd_virtual_channel_open_event reported an error");
|
||||
"rdpsnd_virtual_channel_open_event reported an error");
|
||||
}
|
||||
|
||||
static void* rdpsnd_virtual_channel_client_thread(void* arg)
|
||||
@ -1245,6 +1247,7 @@ static void* rdpsnd_virtual_channel_client_thread(void* arg)
|
||||
rdpsndPlugin* rdpsnd = (rdpsndPlugin*) arg;
|
||||
UINT error;
|
||||
|
||||
freerdp_channel_init_thread_context(rdpsnd->rdpcontext);
|
||||
if ((error = rdpsnd_process_connect(rdpsnd)))
|
||||
{
|
||||
WLog_ERR(TAG, "error connecting sound channel");
|
||||
@ -1286,7 +1289,7 @@ out:
|
||||
|
||||
if (error && rdpsnd->rdpcontext)
|
||||
setChannelError(rdpsnd->rdpcontext, error,
|
||||
"rdpsnd_virtual_channel_client_thread reported an error");
|
||||
"rdpsnd_virtual_channel_client_thread reported an error");
|
||||
|
||||
rdpsnd_process_disconnect(rdpsnd);
|
||||
ExitThread((DWORD)error);
|
||||
@ -1299,17 +1302,17 @@ out:
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT rdpsnd_virtual_channel_event_connected(rdpsndPlugin* plugin,
|
||||
LPVOID pData, UINT32 dataLength)
|
||||
LPVOID pData, UINT32 dataLength)
|
||||
{
|
||||
UINT32 status;
|
||||
status = plugin->channelEntryPoints.pVirtualChannelOpen(plugin->InitHandle,
|
||||
&plugin->OpenHandle, plugin->channelDef.name,
|
||||
rdpsnd_virtual_channel_open_event);
|
||||
&plugin->OpenHandle, plugin->channelDef.name,
|
||||
rdpsnd_virtual_channel_open_event);
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
WTSErrorToString(status), status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -1322,8 +1325,8 @@ static UINT rdpsnd_virtual_channel_event_connected(rdpsndPlugin* plugin,
|
||||
}
|
||||
|
||||
plugin->thread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) rdpsnd_virtual_channel_client_thread, (void*) plugin,
|
||||
0, NULL);
|
||||
(LPTHREAD_START_ROUTINE) rdpsnd_virtual_channel_client_thread, (void*) plugin,
|
||||
0, NULL);
|
||||
|
||||
if (!plugin->thread)
|
||||
{
|
||||
@ -1360,7 +1363,7 @@ static UINT rdpsnd_virtual_channel_event_disconnected(rdpsndPlugin* rdpsnd)
|
||||
if (CHANNEL_RC_OK != error)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08X]",
|
||||
WTSErrorToString(error), error);
|
||||
WTSErrorToString(error), error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -1409,7 +1412,7 @@ static void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* rdpsnd)
|
||||
}
|
||||
|
||||
static VOID VCAPITYPE rdpsnd_virtual_channel_init_event(LPVOID pInitHandle,
|
||||
UINT event, LPVOID pData, UINT dataLength)
|
||||
UINT event, LPVOID pData, UINT dataLength)
|
||||
{
|
||||
rdpsndPlugin* plugin = s_TLSPluginContext;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
@ -1425,14 +1428,14 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_init_event(LPVOID pInitHandle,
|
||||
case CHANNEL_EVENT_CONNECTED:
|
||||
if ((error = rdpsnd_virtual_channel_event_connected(plugin, pData, dataLength)))
|
||||
WLog_ERR(TAG, "rdpsnd_virtual_channel_event_connected failed with error %lu!",
|
||||
error);
|
||||
error);
|
||||
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_DISCONNECTED:
|
||||
if ((error = rdpsnd_virtual_channel_event_disconnected(plugin)))
|
||||
WLog_ERR(TAG,
|
||||
"rdpsnd_virtual_channel_event_disconnected failed with error %lu!", error);
|
||||
"rdpsnd_virtual_channel_event_disconnected failed with error %lu!", error);
|
||||
|
||||
break;
|
||||
|
||||
@ -1446,7 +1449,7 @@ static VOID VCAPITYPE rdpsnd_virtual_channel_init_event(LPVOID pInitHandle,
|
||||
|
||||
if (error && plugin->rdpcontext)
|
||||
setChannelError(plugin->rdpcontext, error,
|
||||
"rdpsnd_virtual_channel_init_event reported an error");
|
||||
"rdpsnd_virtual_channel_init_event reported an error");
|
||||
}
|
||||
|
||||
/* rdpsnd is always built-in */
|
||||
@ -1486,16 +1489,16 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
}
|
||||
|
||||
CopyMemory(&(rdpsnd->channelEntryPoints), pEntryPoints,
|
||||
sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
rdpsnd->log = WLog_Get("com.freerdp.channels.rdpsnd.client");
|
||||
rc = rdpsnd->channelEntryPoints.pVirtualChannelInit(&rdpsnd->InitHandle,
|
||||
&rdpsnd->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
||||
rdpsnd_virtual_channel_init_event);
|
||||
&rdpsnd->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
||||
rdpsnd_virtual_channel_init_event);
|
||||
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
WTSErrorToString(rc), rc);
|
||||
free(rdpsnd);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ UINT rdpsnd_server_send_formats(RdpsndServerContext* context, wStream* s)
|
||||
Stream_Write_UINT8(s, context->block_no); /* cLastBlockConfirmed */
|
||||
Stream_Write_UINT16(s, 0x06); /* wVersion */
|
||||
Stream_Write_UINT8(s, 0); /* bPad */
|
||||
|
||||
|
||||
for (i = 0; i < context->num_server_formats; i++)
|
||||
{
|
||||
Stream_Write_UINT16(s, context->server_formats[i].wFormatTag); /* wFormatTag (WAVE_FORMAT_PCM) */
|
||||
@ -126,7 +126,7 @@ static UINT rdpsnd_server_recv_waveconfirm(RdpsndServerContext* context, wStream
|
||||
static UINT rdpsnd_server_recv_quality_mode(RdpsndServerContext* context, wStream* s)
|
||||
{
|
||||
UINT16 quality;
|
||||
|
||||
|
||||
if (Stream_GetRemainingLength(s) < 4)
|
||||
{
|
||||
WLog_ERR(TAG, "not enought data in stream!");
|
||||
@ -245,6 +245,8 @@ static void* rdpsnd_server_thread(void* arg)
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
context = (RdpsndServerContext *)arg;
|
||||
|
||||
freerdp_channel_init_thread_context(context->rdpcontext);
|
||||
nCount = 0;
|
||||
events[nCount++] = context->priv->channelEvent;
|
||||
events[nCount++] = context->priv->StopEvent;
|
||||
@ -259,21 +261,21 @@ static void* rdpsnd_server_thread(void* arg)
|
||||
{
|
||||
status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu!", error);
|
||||
break;
|
||||
}
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu!", error);
|
||||
break;
|
||||
}
|
||||
|
||||
status = WaitForSingleObject(context->priv->StopEvent, 0);
|
||||
status = WaitForSingleObject(context->priv->StopEvent, 0);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
break;
|
||||
}
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (status == WAIT_OBJECT_0)
|
||||
@ -321,7 +323,7 @@ static UINT rdpsnd_server_select_format(RdpsndServerContext* context, int client
|
||||
WLog_ERR(TAG, "index %d is not correct.", client_format_index);
|
||||
return ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
|
||||
EnterCriticalSection(&context->priv->lock);
|
||||
|
||||
context->priv->src_bytes_per_sample = context->src_format.wBitsPerSample / 8;
|
||||
@ -329,7 +331,7 @@ static UINT rdpsnd_server_select_format(RdpsndServerContext* context, int client
|
||||
|
||||
context->selected_client_format = client_format_index;
|
||||
format = &context->client_formats[client_format_index];
|
||||
|
||||
|
||||
if (format->nSamplesPerSec == 0)
|
||||
{
|
||||
WLog_ERR(TAG, "invalid Client Sound Format!!");
|
||||
@ -361,7 +363,7 @@ static UINT rdpsnd_server_select_format(RdpsndServerContext* context, int client
|
||||
context->priv->out_pending_frames = 0;
|
||||
|
||||
out_buffer_size = context->priv->out_frames * context->priv->src_bytes_per_frame;
|
||||
|
||||
|
||||
if (context->priv->out_buffer_size < out_buffer_size)
|
||||
{
|
||||
BYTE *newBuffer;
|
||||
@ -597,7 +599,7 @@ static UINT rdpsnd_server_close(RdpsndServerContext* context)
|
||||
{
|
||||
WLog_ERR(TAG, "Pending audio frame exists while no format selected.");
|
||||
error = ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
else if ((error = rdpsnd_server_send_audio_pdu(context, 0)))
|
||||
{
|
||||
WLog_ERR(TAG, "rdpsnd_server_send_audio_pdu failed with error %lu", error);
|
||||
@ -720,11 +722,11 @@ static UINT rdpsnd_server_stop(RdpsndServerContext* context)
|
||||
SetEvent(context->priv->StopEvent);
|
||||
|
||||
if (WaitForSingleObject(context->priv->Thread, INFINITE) == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
return error;
|
||||
}
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
return error;
|
||||
}
|
||||
CloseHandle(context->priv->Thread);
|
||||
CloseHandle(context->priv->StopEvent);
|
||||
}
|
||||
|
@ -59,11 +59,11 @@ static UINT remdesk_virtual_channel_write(remdeskPlugin* remdesk, wStream* s)
|
||||
}
|
||||
|
||||
status = remdesk->channelEntryPoints.pVirtualChannelWrite(remdesk->OpenHandle,
|
||||
Stream_Buffer(s), (UINT32) Stream_Length(s), s);
|
||||
Stream_Buffer(s), (UINT32) Stream_Length(s), s);
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
WTSErrorToString(status), status);
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -100,7 +100,7 @@ static UINT remdesk_generate_expert_blob(remdeskPlugin* remdesk)
|
||||
name = "Expert";
|
||||
|
||||
remdesk->EncryptedPassStub = freerdp_assistance_encrypt_pass_stub(password,
|
||||
settings->RemoteAssistancePassStub, &(remdesk->EncryptedPassStubSize));
|
||||
settings->RemoteAssistancePassStub, &(remdesk->EncryptedPassStubSize));
|
||||
|
||||
if (!remdesk->EncryptedPassStub)
|
||||
{
|
||||
@ -109,7 +109,7 @@ static UINT remdesk_generate_expert_blob(remdeskPlugin* remdesk)
|
||||
}
|
||||
|
||||
pass = freerdp_assistance_bin_to_hex_string(remdesk->EncryptedPassStub,
|
||||
remdesk->EncryptedPassStubSize);
|
||||
remdesk->EncryptedPassStubSize);
|
||||
|
||||
if (!pass)
|
||||
{
|
||||
@ -134,7 +134,7 @@ static UINT remdesk_generate_expert_blob(remdeskPlugin* remdesk)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT remdesk_read_channel_header(wStream* s,
|
||||
REMDESK_CHANNEL_HEADER* header)
|
||||
REMDESK_CHANNEL_HEADER* header)
|
||||
{
|
||||
int status;
|
||||
UINT32 ChannelNameLen;
|
||||
@ -170,7 +170,7 @@ static UINT remdesk_read_channel_header(wStream* s,
|
||||
ZeroMemory(header->ChannelName, sizeof(header->ChannelName));
|
||||
pChannelName = (char*) header->ChannelName;
|
||||
status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) Stream_Pointer(s),
|
||||
ChannelNameLen / 2, &pChannelName, 32, NULL, NULL);
|
||||
ChannelNameLen / 2, &pChannelName, 32, NULL, NULL);
|
||||
Stream_Seek(s, ChannelNameLen);
|
||||
|
||||
if (status <= 0)
|
||||
@ -188,7 +188,7 @@ static UINT remdesk_read_channel_header(wStream* s,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT remdesk_write_channel_header(wStream* s,
|
||||
REMDESK_CHANNEL_HEADER* header)
|
||||
REMDESK_CHANNEL_HEADER* header)
|
||||
{
|
||||
int index;
|
||||
UINT32 ChannelNameLen;
|
||||
@ -225,7 +225,7 @@ static UINT remdesk_write_ctl_header(wStream* s, REMDESK_CTL_HEADER* ctlHeader)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT remdesk_prepare_ctl_header(REMDESK_CTL_HEADER* ctlHeader,
|
||||
UINT32 msgType, UINT32 msgSize)
|
||||
UINT32 msgType, UINT32 msgSize)
|
||||
{
|
||||
ctlHeader->msgType = msgType;
|
||||
strcpy(ctlHeader->ChannelName, REMDESK_CHANNEL_CTL_NAME);
|
||||
@ -239,7 +239,7 @@ static UINT remdesk_prepare_ctl_header(REMDESK_CTL_HEADER* ctlHeader,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT remdesk_recv_ctl_server_announce_pdu(remdeskPlugin* remdesk,
|
||||
wStream* s, REMDESK_CHANNEL_HEADER* header)
|
||||
wStream* s, REMDESK_CHANNEL_HEADER* header)
|
||||
{
|
||||
return CHANNEL_RC_OK;
|
||||
}
|
||||
@ -250,7 +250,7 @@ static UINT remdesk_recv_ctl_server_announce_pdu(remdeskPlugin* remdesk,
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT remdesk_recv_ctl_version_info_pdu(remdeskPlugin* remdesk,
|
||||
wStream* s, REMDESK_CHANNEL_HEADER* header)
|
||||
wStream* s, REMDESK_CHANNEL_HEADER* header)
|
||||
{
|
||||
UINT32 versionMajor;
|
||||
UINT32 versionMinor;
|
||||
@ -308,7 +308,7 @@ static UINT remdesk_send_ctl_version_info_pdu(remdeskPlugin* remdesk)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT remdesk_recv_ctl_result_pdu(remdeskPlugin* remdesk, wStream* s,
|
||||
REMDESK_CHANNEL_HEADER* header, UINT32* pResult)
|
||||
REMDESK_CHANNEL_HEADER* header, UINT32* pResult)
|
||||
{
|
||||
UINT32 result;
|
||||
|
||||
@ -349,7 +349,7 @@ static UINT remdesk_send_ctl_authenticate_pdu(remdeskPlugin* remdesk)
|
||||
pdu.expertBlob = remdesk->ExpertBlob;
|
||||
pdu.raConnectionString = remdesk->settings->RemoteAssistanceRCTicket;
|
||||
status = ConvertToUnicode(CP_UTF8, 0, pdu.raConnectionString, -1,
|
||||
&raConnectionStringW, 0);
|
||||
&raConnectionStringW, 0);
|
||||
|
||||
if (status <= 0)
|
||||
{
|
||||
@ -369,7 +369,7 @@ static UINT remdesk_send_ctl_authenticate_pdu(remdeskPlugin* remdesk)
|
||||
|
||||
cbExpertBlobW = status * 2;
|
||||
remdesk_prepare_ctl_header(&(pdu.ctlHeader), REMDESK_CTL_AUTHENTICATE,
|
||||
cbRaConnectionStringW + cbExpertBlobW);
|
||||
cbRaConnectionStringW + cbExpertBlobW);
|
||||
s = Stream_New(NULL, REMDESK_CHANNEL_CTL_SIZE + pdu.ctlHeader.DataLength);
|
||||
|
||||
if (!s)
|
||||
@ -412,7 +412,7 @@ static UINT remdesk_send_ctl_remote_control_desktop_pdu(remdeskPlugin* remdesk)
|
||||
REMDESK_CTL_REMOTE_CONTROL_DESKTOP_PDU pdu;
|
||||
pdu.raConnectionString = remdesk->settings->RemoteAssistanceRCTicket;
|
||||
status = ConvertToUnicode(CP_UTF8, 0, pdu.raConnectionString, -1,
|
||||
&raConnectionStringW, 0);
|
||||
&raConnectionStringW, 0);
|
||||
|
||||
if (status <= 0)
|
||||
{
|
||||
@ -422,7 +422,7 @@ static UINT remdesk_send_ctl_remote_control_desktop_pdu(remdeskPlugin* remdesk)
|
||||
|
||||
cbRaConnectionStringW = status * 2;
|
||||
remdesk_prepare_ctl_header(&(pdu.ctlHeader), REMDESK_CTL_REMOTE_CONTROL_DESKTOP,
|
||||
cbRaConnectionStringW);
|
||||
cbRaConnectionStringW);
|
||||
s = Stream_New(NULL, REMDESK_CHANNEL_CTL_SIZE + pdu.ctlHeader.DataLength);
|
||||
|
||||
if (!s)
|
||||
@ -479,7 +479,7 @@ static UINT remdesk_send_ctl_verify_password_pdu(remdeskPlugin* remdesk)
|
||||
|
||||
cbExpertBlobW = status * 2;
|
||||
remdesk_prepare_ctl_header(&(pdu.ctlHeader), REMDESK_CTL_VERIFY_PASSWORD,
|
||||
cbExpertBlobW);
|
||||
cbExpertBlobW);
|
||||
s = Stream_New(NULL, REMDESK_CHANNEL_CTL_SIZE + pdu.ctlHeader.DataLength);
|
||||
|
||||
if (!s)
|
||||
@ -525,7 +525,7 @@ static UINT remdesk_send_ctl_expert_on_vista_pdu(remdeskPlugin* remdesk)
|
||||
pdu.EncryptedPasswordLength = remdesk->EncryptedPassStubSize;
|
||||
pdu.EncryptedPassword = remdesk->EncryptedPassStub;
|
||||
remdesk_prepare_ctl_header(&(pdu.ctlHeader), REMDESK_CTL_EXPERT_ON_VISTA,
|
||||
pdu.EncryptedPasswordLength);
|
||||
pdu.EncryptedPasswordLength);
|
||||
s = Stream_New(NULL, REMDESK_CHANNEL_CTL_SIZE + pdu.ctlHeader.DataLength);
|
||||
|
||||
if (!s)
|
||||
@ -546,7 +546,7 @@ static UINT remdesk_send_ctl_expert_on_vista_pdu(remdeskPlugin* remdesk)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT remdesk_recv_ctl_pdu(remdeskPlugin* remdesk, wStream* s,
|
||||
REMDESK_CHANNEL_HEADER* header)
|
||||
REMDESK_CHANNEL_HEADER* header)
|
||||
{
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
UINT32 msgType = 0;
|
||||
@ -579,7 +579,7 @@ static UINT remdesk_recv_ctl_pdu(remdeskPlugin* remdesk, wStream* s,
|
||||
case REMDESK_CTL_SERVER_ANNOUNCE:
|
||||
if ((error = remdesk_recv_ctl_server_announce_pdu(remdesk, s, header)))
|
||||
WLog_ERR(TAG, "remdesk_recv_ctl_server_announce_pdu failed with error %lu",
|
||||
error);
|
||||
error);
|
||||
|
||||
break;
|
||||
|
||||
@ -610,7 +610,7 @@ static UINT remdesk_recv_ctl_pdu(remdeskPlugin* remdesk, wStream* s,
|
||||
if ((error = remdesk_send_ctl_remote_control_desktop_pdu(remdesk)))
|
||||
{
|
||||
WLog_ERR(TAG,
|
||||
"remdesk_send_ctl_remote_control_desktop_pdu failed with error %lu", error);
|
||||
"remdesk_send_ctl_remote_control_desktop_pdu failed with error %lu", error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -619,14 +619,14 @@ static UINT remdesk_recv_ctl_pdu(remdeskPlugin* remdesk, wStream* s,
|
||||
if ((error = remdesk_send_ctl_expert_on_vista_pdu(remdesk)))
|
||||
{
|
||||
WLog_ERR(TAG, "remdesk_send_ctl_expert_on_vista_pdu failed with error %lu",
|
||||
error);
|
||||
error);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((error = remdesk_send_ctl_verify_password_pdu(remdesk)))
|
||||
{
|
||||
WLog_ERR(TAG, "remdesk_send_ctl_verify_password_pdu failed with error %lu",
|
||||
error);
|
||||
error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -728,14 +728,14 @@ static UINT remdesk_send(remdeskPlugin* remdesk, wStream* s)
|
||||
else
|
||||
{
|
||||
status = plugin->channelEntryPoints.pVirtualChannelWrite(plugin->OpenHandle,
|
||||
Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
|
||||
Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
|
||||
}
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
Stream_Free(s, TRUE);
|
||||
WLog_ERR(TAG, "VirtualChannelWrite failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
WTSErrorToString(status), status);
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -747,7 +747,7 @@ static UINT remdesk_send(remdeskPlugin* remdesk, wStream* s)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT remdesk_virtual_channel_event_data_received(remdeskPlugin* remdesk,
|
||||
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
{
|
||||
wStream* data_in;
|
||||
|
||||
@ -803,8 +803,8 @@ static UINT remdesk_virtual_channel_event_data_received(remdeskPlugin* remdesk,
|
||||
}
|
||||
|
||||
static VOID VCAPITYPE remdesk_virtual_channel_open_event(DWORD openHandle,
|
||||
UINT event,
|
||||
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
UINT event,
|
||||
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
||||
{
|
||||
remdeskPlugin* remdesk = s_TLSPluginContext;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
@ -819,9 +819,9 @@ static VOID VCAPITYPE remdesk_virtual_channel_open_event(DWORD openHandle,
|
||||
{
|
||||
case CHANNEL_EVENT_DATA_RECEIVED:
|
||||
if ((error = remdesk_virtual_channel_event_data_received(remdesk, pData,
|
||||
dataLength, totalLength, dataFlags)))
|
||||
dataLength, totalLength, dataFlags)))
|
||||
WLog_ERR(TAG,
|
||||
"remdesk_virtual_channel_event_data_received failed with error %lu!", error);
|
||||
"remdesk_virtual_channel_event_data_received failed with error %lu!", error);
|
||||
|
||||
break;
|
||||
|
||||
@ -839,7 +839,7 @@ static VOID VCAPITYPE remdesk_virtual_channel_open_event(DWORD openHandle,
|
||||
|
||||
if (error && remdesk->rdpcontext)
|
||||
setChannelError(remdesk->rdpcontext, error,
|
||||
"remdesk_virtual_channel_open_event reported an error");
|
||||
"remdesk_virtual_channel_open_event reported an error");
|
||||
}
|
||||
|
||||
static void* remdesk_virtual_channel_client_thread(void* arg)
|
||||
@ -848,6 +848,8 @@ static void* remdesk_virtual_channel_client_thread(void* arg)
|
||||
wMessage message;
|
||||
remdeskPlugin* remdesk = (remdeskPlugin*) arg;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
freerdp_channel_init_thread_context(remdesk->rdpcontext);
|
||||
remdesk_process_connect(remdesk);
|
||||
|
||||
while (1)
|
||||
@ -883,7 +885,7 @@ static void* remdesk_virtual_channel_client_thread(void* arg)
|
||||
|
||||
if (error && remdesk->rdpcontext)
|
||||
setChannelError(remdesk->rdpcontext, error,
|
||||
"remdesk_virtual_channel_client_thread reported an error");
|
||||
"remdesk_virtual_channel_client_thread reported an error");
|
||||
|
||||
ExitThread((DWORD)error);
|
||||
return NULL;
|
||||
@ -895,18 +897,18 @@ static void* remdesk_virtual_channel_client_thread(void* arg)
|
||||
* @return 0 on success, otherwise a Win32 error code
|
||||
*/
|
||||
static UINT remdesk_virtual_channel_event_connected(remdeskPlugin* remdesk,
|
||||
LPVOID pData, UINT32 dataLength)
|
||||
LPVOID pData, UINT32 dataLength)
|
||||
{
|
||||
UINT32 status;
|
||||
UINT error;
|
||||
status = remdesk->channelEntryPoints.pVirtualChannelOpen(remdesk->InitHandle,
|
||||
&remdesk->OpenHandle, remdesk->channelDef.name,
|
||||
remdesk_virtual_channel_open_event);
|
||||
&remdesk->OpenHandle, remdesk->channelDef.name,
|
||||
remdesk_virtual_channel_open_event);
|
||||
|
||||
if (status != CHANNEL_RC_OK)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelOpen failed with %s [%08X]",
|
||||
WTSErrorToString(status), status);
|
||||
WTSErrorToString(status), status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -920,8 +922,8 @@ static UINT remdesk_virtual_channel_event_connected(remdeskPlugin* remdesk,
|
||||
}
|
||||
|
||||
remdesk->thread = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE) remdesk_virtual_channel_client_thread, (void*) remdesk,
|
||||
0, NULL);
|
||||
(LPTHREAD_START_ROUTINE) remdesk_virtual_channel_client_thread, (void*) remdesk,
|
||||
0, NULL);
|
||||
|
||||
if (!remdesk->thread)
|
||||
{
|
||||
@ -963,7 +965,7 @@ static UINT remdesk_virtual_channel_event_disconnected(remdeskPlugin* remdesk)
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelClose failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
WTSErrorToString(rc), rc);
|
||||
}
|
||||
|
||||
remdesk->OpenHandle = 0;
|
||||
@ -984,8 +986,8 @@ static void remdesk_virtual_channel_event_terminated(remdeskPlugin* remdesk)
|
||||
}
|
||||
|
||||
static VOID VCAPITYPE remdesk_virtual_channel_init_event(LPVOID pInitHandle,
|
||||
UINT event, LPVOID pData,
|
||||
UINT dataLength)
|
||||
UINT event, LPVOID pData,
|
||||
UINT dataLength)
|
||||
{
|
||||
remdeskPlugin* remdesk = s_TLSPluginContext;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
@ -1000,16 +1002,16 @@ static VOID VCAPITYPE remdesk_virtual_channel_init_event(LPVOID pInitHandle,
|
||||
{
|
||||
case CHANNEL_EVENT_CONNECTED:
|
||||
if ((error = remdesk_virtual_channel_event_connected(remdesk, pData,
|
||||
dataLength)))
|
||||
dataLength)))
|
||||
WLog_ERR(TAG, "remdesk_virtual_channel_event_connected failed with error %lu",
|
||||
error);
|
||||
error);
|
||||
|
||||
break;
|
||||
|
||||
case CHANNEL_EVENT_DISCONNECTED:
|
||||
if ((error = remdesk_virtual_channel_event_disconnected(remdesk)))
|
||||
WLog_ERR(TAG,
|
||||
"remdesk_virtual_channel_event_disconnected failed with error %lu", error);
|
||||
"remdesk_virtual_channel_event_disconnected failed with error %lu", error);
|
||||
|
||||
break;
|
||||
|
||||
@ -1020,7 +1022,7 @@ static VOID VCAPITYPE remdesk_virtual_channel_init_event(LPVOID pInitHandle,
|
||||
|
||||
if (error && remdesk->rdpcontext)
|
||||
setChannelError(remdesk->rdpcontext, error,
|
||||
"remdesk_virtual_channel_init_event reported an error");
|
||||
"remdesk_virtual_channel_init_event reported an error");
|
||||
}
|
||||
|
||||
/* remdesk is always built-in */
|
||||
@ -1067,22 +1069,22 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
|
||||
}
|
||||
|
||||
CopyMemory(&(remdesk->channelEntryPoints), pEntryPoints,
|
||||
sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
sizeof(CHANNEL_ENTRY_POINTS_FREERDP));
|
||||
rc = remdesk->channelEntryPoints.pVirtualChannelInit(&remdesk->InitHandle,
|
||||
&remdesk->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
||||
remdesk_virtual_channel_init_event);
|
||||
&remdesk->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
||||
remdesk_virtual_channel_init_event);
|
||||
|
||||
if (CHANNEL_RC_OK != rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pVirtualChannelInit failed with %s [%08X]",
|
||||
WTSErrorToString(rc), rc);
|
||||
WTSErrorToString(rc), rc);
|
||||
goto error_out;
|
||||
}
|
||||
|
||||
remdesk->channelEntryPoints.pInterface = *
|
||||
(remdesk->channelEntryPoints.ppInterface);
|
||||
(remdesk->channelEntryPoints.ppInterface);
|
||||
remdesk->channelEntryPoints.ppInterface = &
|
||||
(remdesk->channelEntryPoints.pInterface);
|
||||
(remdesk->channelEntryPoints.pInterface);
|
||||
s_TLSPluginContext = remdesk;
|
||||
return TRUE;
|
||||
error_out:
|
||||
|
@ -600,6 +600,7 @@ static void* remdesk_server_thread(void* arg)
|
||||
|
||||
context = (RemdeskServerContext*) arg;
|
||||
|
||||
freerdp_channel_init_thread_context(context->rdpcontext);
|
||||
buffer = NULL;
|
||||
BytesReturned = 0;
|
||||
ChannelEvent = NULL;
|
||||
@ -640,21 +641,21 @@ static void* remdesk_server_thread(void* arg)
|
||||
{
|
||||
status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu", error);
|
||||
break;
|
||||
}
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu", error);
|
||||
break;
|
||||
}
|
||||
|
||||
status = WaitForSingleObject(context->priv->StopEvent, 0);
|
||||
status = WaitForSingleObject(context->priv->StopEvent, 0);
|
||||
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
break;
|
||||
}
|
||||
if (status == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (status == WAIT_OBJECT_0)
|
||||
@ -752,9 +753,9 @@ static UINT remdesk_server_stop(RemdeskServerContext* context)
|
||||
|
||||
if (WaitForSingleObject(context->priv->Thread, INFINITE) == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
return error;
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
return error;
|
||||
}
|
||||
CloseHandle(context->priv->Thread);
|
||||
|
||||
|
@ -47,7 +47,7 @@
|
||||
/* TODO: all #ifdef __linux__ could be removed once only some generic
|
||||
* functions will be used. Replace CommReadFile by ReadFile,
|
||||
* CommWriteFile by WriteFile etc.. */
|
||||
#if defined __linux__ && !defined ANDROID
|
||||
#if defined __linux__ && !defined ANDROID
|
||||
|
||||
#define MAX_IRP_THREADS 5
|
||||
|
||||
@ -468,6 +468,8 @@ static void* irp_thread_func(void* arg)
|
||||
IRP_THREAD_DATA *data = (IRP_THREAD_DATA*)arg;
|
||||
UINT error;
|
||||
|
||||
freerdp_channel_init_thread_context(data->serial->rdpcontext);
|
||||
|
||||
/* blocks until the end of the request */
|
||||
if ((error = serial_process_irp(data->serial, data->irp)))
|
||||
{
|
||||
@ -552,7 +554,7 @@ static void create_irp_thread(SERIAL_DEVICE *serial, IRP *irp)
|
||||
serial->IrpThreadToBeTerminatedCount--;
|
||||
}
|
||||
else if (waitResult != WAIT_TIMEOUT)
|
||||
{
|
||||
{
|
||||
/* unexpected thread state */
|
||||
|
||||
WLog_Print(serial->log, WLOG_WARN, "WaitForSingleObject, got an unexpected result=0x%lX\n", waitResult);
|
||||
@ -690,10 +692,10 @@ static void terminate_pending_irp_threads(SERIAL_DEVICE *serial)
|
||||
TerminateThread(irpThread, 0);
|
||||
|
||||
if (WaitForSingleObject(irpThread, INFINITE) == WAIT_FAILED)
|
||||
{
|
||||
WLog_ERR(TAG,"WaitForSingleObject failed!");
|
||||
continue;
|
||||
}
|
||||
{
|
||||
WLog_ERR(TAG,"WaitForSingleObject failed!");
|
||||
continue;
|
||||
}
|
||||
|
||||
CloseHandle(irpThread);
|
||||
|
||||
@ -711,6 +713,7 @@ static void* serial_thread_func(void* arg)
|
||||
SERIAL_DEVICE* serial = (SERIAL_DEVICE*) arg;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
freerdp_channel_init_thread_context(serial->rdpcontext);
|
||||
while (1)
|
||||
{
|
||||
if (!MessageQueue_Wait(serial->MainIrpQueue))
|
||||
@ -790,9 +793,9 @@ static UINT serial_free(DEVICE* device)
|
||||
MessageQueue_PostQuit(serial->MainIrpQueue, 0);
|
||||
if (WaitForSingleObject(serial->MainThread, INFINITE) == WAIT_FAILED)
|
||||
{
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
return error;
|
||||
error = GetLastError();
|
||||
WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
|
||||
return error;
|
||||
}
|
||||
CloseHandle(serial->MainThread);
|
||||
|
||||
|
@ -46,6 +46,7 @@ void* smartcard_context_thread(SMARTCARD_CONTEXT* pContext)
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
smartcard = pContext->smartcard;
|
||||
freerdp_channel_init_thread_context(smartcard->rdpcontext);
|
||||
|
||||
nCount = 0;
|
||||
hEvents[nCount++] = MessageQueue_Event(pContext->IrpQueue);
|
||||
@ -515,6 +516,8 @@ static void* smartcard_thread_func(void* arg)
|
||||
SMARTCARD_DEVICE* smartcard = (SMARTCARD_DEVICE*) arg;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
freerdp_channel_init_thread_context(smartcard->rdpcontext);
|
||||
|
||||
nCount = 0;
|
||||
hEvents[nCount++] = MessageQueue_Event(smartcard->IrpQueue);
|
||||
hEvents[nCount++] = Queue_Event(smartcard->CompletedIrpQueue);
|
||||
|
@ -115,7 +115,7 @@ struct _TSMF_STREAM
|
||||
UINT32 bits_per_sample;
|
||||
|
||||
/* The start time of last played sample */
|
||||
UINT64 last_start_time;
|
||||
UINT64 last_start_time;
|
||||
/* The end_time of last played sample */
|
||||
UINT64 last_end_time;
|
||||
/* Next sample should not start before this system time. */
|
||||
@ -540,7 +540,7 @@ static BOOL tsmf_sample_playback(TSMF_SAMPLE* sample)
|
||||
* render times. So, we try to adjust timestamps on the video buffer to match those on the audio buffer.
|
||||
*/
|
||||
if (stream->major_type == TSMF_MAJOR_TYPE_VIDEO)
|
||||
{
|
||||
{
|
||||
TSMF_STREAM* temp_stream = NULL;
|
||||
TSMF_PRESENTATION* presentation = stream->presentation;
|
||||
ArrayList_Lock(presentation->stream_list);
|
||||
@ -701,6 +701,7 @@ static void* tsmf_stream_ack_func(void *arg)
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
DEBUG_TSMF("in %d", stream->stream_id);
|
||||
|
||||
freerdp_channel_init_thread_context(stream->rdpcontext);
|
||||
hdl[0] = stream->stopEvent;
|
||||
hdl[1] = Queue_Event(stream->sample_ack_list);
|
||||
|
||||
@ -784,6 +785,8 @@ static void* tsmf_stream_playback_func(void *arg)
|
||||
|
||||
DEBUG_TSMF("in %d", stream->stream_id);
|
||||
|
||||
freerdp_channel_init_thread_context(stream->rdpcontext);
|
||||
|
||||
if (stream->major_type == TSMF_MAJOR_TYPE_AUDIO &&
|
||||
stream->sample_rate && stream->channels && stream->bits_per_sample)
|
||||
{
|
||||
@ -1079,7 +1082,7 @@ BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation,
|
||||
if (!width || !height)
|
||||
return TRUE;
|
||||
|
||||
/* Streams can be added/removed from the presentation and the server will resend geometry info when a new stream is
|
||||
/* Streams can be added/removed from the presentation and the server will resend geometry info when a new stream is
|
||||
* added to the presentation. Also, num_rects is used to indicate whether or not the window is visible.
|
||||
* So, always process a valid message with unchanged position/size and/or no visibility rects.
|
||||
*/
|
||||
@ -1088,7 +1091,7 @@ BOOL tsmf_presentation_set_geometry_info(TSMF_PRESENTATION* presentation,
|
||||
presentation->y = y;
|
||||
presentation->width = width;
|
||||
presentation->height = height;
|
||||
|
||||
|
||||
tmp_rects = realloc(presentation->rects, sizeof(RDP_RECT) * num_rects);
|
||||
|
||||
presentation->nr_rects = num_rects;
|
||||
|
Loading…
Reference in New Issue
Block a user