Example #1
0
static void* rdpsnd_server_thread(void* arg)
{
	DWORD nCount, status;
	HANDLE events[8];
	RdpsndServerContext* context;
	BOOL doRun;

	context = (RdpsndServerContext *)arg;
	nCount = 0;
	events[nCount++] = context->priv->channelEvent;
	events[nCount++] = context->priv->StopEvent;

	if (!rdpsnd_server_send_formats(context, context->priv->rdpsnd_pdu))
		goto out;

	doRun = TRUE;
	while (doRun)
	{
		status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);

		if (WaitForSingleObject(context->priv->StopEvent, 0) == WAIT_OBJECT_0)
			break;

		if (!rdpsnd_server_handle_messages(context))
			break;
	}

out:
	return NULL;
}
Example #2
0
static void* rdpsnd_server_thread(void* arg)
{
	DWORD nCount, status;
	HANDLE events[8];
	RdpsndServerContext* context;
	UINT error = CHANNEL_RC_OK;

	context = (RdpsndServerContext *)arg;
	nCount = 0;
	events[nCount++] = context->priv->channelEvent;
	events[nCount++] = context->priv->StopEvent;

	if ((error = rdpsnd_server_send_formats(context, context->priv->rdpsnd_pdu)))
	{
		WLog_ERR(TAG, "rdpsnd_server_send_formats failed with error %lu", error);
		goto out;
	}

	while (TRUE)
	{
		status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);

        if (status == WAIT_FAILED)
        {
            error = GetLastError();
            WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu!", error);
            break;
        }

        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_OBJECT_0)
			break;

		if ((error = rdpsnd_server_handle_messages(context)))
		{
			WLog_ERR(TAG, "rdpsnd_server_handle_messages failed with error %lu", error);
			break;
		}
	}

out:
	if (error && context->rdpcontext)
		setChannelError(context->rdpcontext, error, "rdpsnd_server_thread reported an error");
	ExitThread((DWORD)error);
	return NULL;
}