2011-08-15 11:08:23 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2011-08-15 11:08:23 +04:00
|
|
|
* Audio Output Virtual Channel
|
|
|
|
*
|
|
|
|
* Copyright 2009-2011 Jay Sorg
|
|
|
|
* Copyright 2010-2011 Vic Lee
|
2013-10-19 20:38:31 +04:00
|
|
|
* Copyright 2012-2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2015-07-15 10:50:35 +03:00
|
|
|
* Copyright 2015 Thincast Technologies GmbH
|
|
|
|
* Copyright 2015 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
|
2016-06-29 00:39:29 +03:00
|
|
|
* Copyright 2016 David PHAM-VAN <d.phamvan@inuvika.com>
|
2011-08-15 11:08:23 +04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:09:01 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2011-08-17 07:54:42 +04:00
|
|
|
#ifndef _WIN32
|
|
|
|
#include <sys/time.h>
|
2013-02-28 14:47:09 +04:00
|
|
|
#include <signal.h>
|
2011-08-17 07:54:42 +04:00
|
|
|
#endif
|
|
|
|
|
2011-08-15 11:08:23 +04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2017-11-14 18:10:52 +03:00
|
|
|
#include <errno.h>
|
2012-08-15 01:09:01 +04:00
|
|
|
|
2012-10-09 03:54:11 +04:00
|
|
|
#include <winpr/crt.h>
|
2013-11-20 00:31:38 +04:00
|
|
|
#include <winpr/wlog.h>
|
2013-10-20 00:20:31 +04:00
|
|
|
#include <winpr/stream.h>
|
2012-11-19 02:32:18 +04:00
|
|
|
#include <winpr/cmdline.h>
|
2013-02-20 06:21:20 +04:00
|
|
|
#include <winpr/sysinfo.h>
|
2013-02-20 07:36:04 +04:00
|
|
|
#include <winpr/collections.h>
|
2012-10-09 03:54:11 +04:00
|
|
|
|
2011-08-15 11:08:23 +04:00
|
|
|
#include <freerdp/types.h>
|
2012-11-18 07:03:04 +04:00
|
|
|
#include <freerdp/addin.h>
|
2018-02-20 14:15:30 +03:00
|
|
|
#include <freerdp/codec/dsp.h>
|
2011-08-15 11:08:23 +04:00
|
|
|
|
|
|
|
#include "rdpsnd_main.h"
|
|
|
|
|
|
|
|
struct rdpsnd_plugin
|
|
|
|
{
|
2013-10-20 00:20:31 +04:00
|
|
|
CHANNEL_DEF channelDef;
|
2016-11-22 16:47:20 +03:00
|
|
|
CHANNEL_ENTRY_POINTS_FREERDP_EX channelEntryPoints;
|
2011-08-15 11:08:23 +04:00
|
|
|
|
2013-02-21 06:34:47 +04:00
|
|
|
HANDLE thread;
|
2018-02-20 14:15:30 +03:00
|
|
|
wStreamPool* pool;
|
2013-10-20 00:20:31 +04:00
|
|
|
wStream* data_in;
|
2018-02-20 14:15:30 +03:00
|
|
|
|
2013-10-20 00:20:31 +04:00
|
|
|
void* InitHandle;
|
2014-02-17 02:27:36 +04:00
|
|
|
DWORD OpenHandle;
|
2013-10-20 00:20:31 +04:00
|
|
|
|
2013-11-20 00:31:38 +04:00
|
|
|
wLog* log;
|
2015-01-20 13:53:12 +03:00
|
|
|
HANDLE stopEvent;
|
2011-08-15 11:08:23 +04:00
|
|
|
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE cBlockNo;
|
2013-11-19 23:29:31 +04:00
|
|
|
UINT16 wQualityMode;
|
2018-02-20 14:15:30 +03:00
|
|
|
UINT16 wCurrentFormatNo;
|
2011-08-15 11:08:23 +04:00
|
|
|
|
2013-02-22 03:41:41 +04:00
|
|
|
AUDIO_FORMAT* ServerFormats;
|
|
|
|
UINT16 NumberOfServerFormats;
|
|
|
|
|
|
|
|
AUDIO_FORMAT* ClientFormats;
|
|
|
|
UINT16 NumberOfClientFormats;
|
|
|
|
|
2016-12-19 19:07:01 +03:00
|
|
|
BOOL attached;
|
2018-04-09 12:10:14 +03:00
|
|
|
BOOL connected;
|
2016-12-19 19:07:01 +03:00
|
|
|
|
2012-10-09 10:38:39 +04:00
|
|
|
BOOL expectingWave;
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE waveData[4];
|
|
|
|
UINT16 waveDataSize;
|
2013-02-26 02:49:07 +04:00
|
|
|
UINT32 wTimeStamp;
|
2018-02-20 14:15:30 +03:00
|
|
|
UINT32 wArrivalTime;
|
2011-08-15 11:08:23 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
UINT32 latency;
|
2013-02-28 00:10:35 +04:00
|
|
|
BOOL isOpen;
|
2013-02-26 20:16:33 +04:00
|
|
|
UINT16 fixedFormat;
|
|
|
|
UINT16 fixedChannel;
|
|
|
|
UINT32 fixedRate;
|
2011-08-15 11:08:23 +04:00
|
|
|
|
2012-11-19 02:32:18 +04:00
|
|
|
char* subsystem;
|
|
|
|
char* device_name;
|
|
|
|
|
2011-08-15 11:08:23 +04:00
|
|
|
/* Device plugin */
|
|
|
|
rdpsndDevicePlugin* device;
|
2015-07-15 10:50:35 +03:00
|
|
|
rdpContext* rdpcontext;
|
2018-02-20 14:15:30 +03:00
|
|
|
|
|
|
|
wQueue* queue;
|
|
|
|
FREERDP_DSP_CONTEXT* dsp_context;
|
2011-08-15 11:08:23 +04:00
|
|
|
};
|
|
|
|
|
2018-04-09 12:10:14 +03:00
|
|
|
static void rdpsnd_recv_close_pdu(rdpsndPlugin* rdpsnd);
|
|
|
|
static void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* rdpsnd);
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2018-02-20 14:15:30 +03:00
|
|
|
static UINT rdpsnd_virtual_channel_write(rdpsndPlugin* rdpsnd, wStream* s);
|
2011-08-15 11:08:23 +04:00
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rdpsnd_send_quality_mode_pdu(rdpsndPlugin* rdpsnd)
|
2011-08-15 11:08:23 +04:00
|
|
|
{
|
2013-03-21 23:19:33 +04:00
|
|
|
wStream* pdu;
|
2013-05-09 01:48:30 +04:00
|
|
|
pdu = Stream_New(NULL, 8);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
if (!pdu)
|
2015-07-15 10:50:35 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
2015-06-24 18:06:45 +03:00
|
|
|
return CHANNEL_RC_NO_MEMORY;
|
2015-07-15 10:50:35 +03:00
|
|
|
}
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(pdu, SNDC_QUALITYMODE); /* msgType */
|
|
|
|
Stream_Write_UINT8(pdu, 0); /* bPad */
|
|
|
|
Stream_Write_UINT16(pdu, 4); /* BodySize */
|
2013-11-19 23:29:31 +04:00
|
|
|
Stream_Write_UINT16(pdu, rdpsnd->wQualityMode); /* wQualityMode */
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(pdu, 0); /* Reserved */
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_Print(rdpsnd->log, WLOG_DEBUG, "QualityMode: %"PRIu16"", rdpsnd->wQualityMode);
|
2015-06-24 18:06:45 +03:00
|
|
|
return rdpsnd_virtual_channel_write(rdpsnd, pdu);
|
2013-02-21 22:25:43 +04:00
|
|
|
}
|
|
|
|
|
2015-01-20 13:53:12 +03:00
|
|
|
static void rdpsnd_select_supported_audio_formats(rdpsndPlugin* rdpsnd)
|
2013-02-22 03:41:41 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
UINT16 index;
|
2013-02-22 03:41:41 +04:00
|
|
|
rdpsnd_free_audio_formats(rdpsnd->ClientFormats, rdpsnd->NumberOfClientFormats);
|
|
|
|
rdpsnd->NumberOfClientFormats = 0;
|
|
|
|
rdpsnd->ClientFormats = NULL;
|
|
|
|
|
2013-08-30 16:19:50 +04:00
|
|
|
if (!rdpsnd->NumberOfServerFormats)
|
|
|
|
return;
|
2013-02-20 02:47:55 +04:00
|
|
|
|
2017-05-30 11:46:43 +03:00
|
|
|
rdpsnd->ClientFormats = (AUDIO_FORMAT*) calloc(
|
2017-11-14 18:10:52 +03:00
|
|
|
rdpsnd->NumberOfServerFormats,
|
|
|
|
sizeof(AUDIO_FORMAT));
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2016-10-04 11:31:04 +03:00
|
|
|
if (!rdpsnd->ClientFormats)
|
|
|
|
return;
|
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
for (index = 0; index < rdpsnd->NumberOfServerFormats; index++)
|
2011-08-15 11:08:23 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
const AUDIO_FORMAT* serverFormat = &rdpsnd->ServerFormats[index];
|
2013-02-22 03:41:41 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if ((rdpsnd->fixedFormat > 0) &&
|
|
|
|
(rdpsnd->fixedFormat != serverFormat->wFormatTag))
|
2013-02-22 03:41:41 +04:00
|
|
|
continue;
|
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if ((rdpsnd->fixedChannel > 0) &&
|
|
|
|
(rdpsnd->fixedChannel != serverFormat->nChannels))
|
2013-02-22 03:41:41 +04:00
|
|
|
continue;
|
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if ((rdpsnd->fixedRate > 0) &&
|
|
|
|
(rdpsnd->fixedRate != serverFormat->nSamplesPerSec))
|
2013-02-22 03:41:41 +04:00
|
|
|
continue;
|
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if (freerdp_dsp_supports_format(serverFormat, FALSE) ||
|
|
|
|
rdpsnd->device->FormatSupported(rdpsnd->device, serverFormat))
|
2013-02-22 03:41:41 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
AUDIO_FORMAT* clientFormat = &rdpsnd->ClientFormats[rdpsnd->NumberOfClientFormats++];
|
|
|
|
*clientFormat = *serverFormat;
|
2013-02-22 03:41:41 +04:00
|
|
|
|
|
|
|
if (serverFormat->cbSize > 0)
|
|
|
|
{
|
|
|
|
clientFormat->data = (BYTE*) malloc(serverFormat->cbSize);
|
|
|
|
CopyMemory(clientFormat->data, serverFormat->data, serverFormat->cbSize);
|
|
|
|
}
|
|
|
|
}
|
2011-08-15 11:08:23 +04:00
|
|
|
}
|
2013-02-22 03:41:41 +04:00
|
|
|
}
|
2011-08-15 11:08:23 +04:00
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rdpsnd_send_client_audio_formats(rdpsndPlugin* rdpsnd)
|
2013-02-22 03:41:41 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
UINT16 index;
|
2013-03-21 23:19:33 +04:00
|
|
|
wStream* pdu;
|
2013-02-22 03:41:41 +04:00
|
|
|
UINT16 length;
|
|
|
|
UINT32 dwVolume;
|
|
|
|
UINT16 wNumberOfFormats;
|
2018-02-20 14:15:30 +03:00
|
|
|
dwVolume = IFCALLRESULT(0, rdpsnd->device->GetVolume, rdpsnd->device);
|
2013-02-22 03:41:41 +04:00
|
|
|
wNumberOfFormats = rdpsnd->NumberOfClientFormats;
|
|
|
|
length = 4 + 20;
|
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
for (index = 0; index < wNumberOfFormats; index++)
|
2013-02-22 03:41:41 +04:00
|
|
|
length += (18 + rdpsnd->ClientFormats[index].cbSize);
|
|
|
|
|
2013-05-09 01:48:30 +04:00
|
|
|
pdu = Stream_New(NULL, length);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
if (!pdu)
|
2015-07-15 10:50:35 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
2015-06-24 18:06:45 +03:00
|
|
|
return CHANNEL_RC_NO_MEMORY;
|
2015-07-15 10:50:35 +03:00
|
|
|
}
|
2013-02-22 03:41:41 +04:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(pdu, SNDC_FORMATS); /* msgType */
|
|
|
|
Stream_Write_UINT8(pdu, 0); /* bPad */
|
|
|
|
Stream_Write_UINT16(pdu, length - 4); /* BodySize */
|
|
|
|
Stream_Write_UINT32(pdu, TSSNDCAPS_ALIVE | TSSNDCAPS_VOLUME); /* dwFlags */
|
|
|
|
Stream_Write_UINT32(pdu, dwVolume); /* dwVolume */
|
|
|
|
Stream_Write_UINT32(pdu, 0); /* dwPitch */
|
|
|
|
Stream_Write_UINT16(pdu, 0); /* wDGramPort */
|
|
|
|
Stream_Write_UINT16(pdu, wNumberOfFormats); /* wNumberOfFormats */
|
|
|
|
Stream_Write_UINT8(pdu, 0); /* cLastBlockConfirmed */
|
|
|
|
Stream_Write_UINT16(pdu, 6); /* wVersion */
|
|
|
|
Stream_Write_UINT8(pdu, 0); /* bPad */
|
2011-08-15 11:08:23 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
for (index = 0; index < wNumberOfFormats; index++)
|
2011-08-15 11:08:23 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
const AUDIO_FORMAT* clientFormat = &rdpsnd->ClientFormats[index];
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT16(pdu, clientFormat->wFormatTag);
|
|
|
|
Stream_Write_UINT16(pdu, clientFormat->nChannels);
|
|
|
|
Stream_Write_UINT32(pdu, clientFormat->nSamplesPerSec);
|
|
|
|
Stream_Write_UINT32(pdu, clientFormat->nAvgBytesPerSec);
|
|
|
|
Stream_Write_UINT16(pdu, clientFormat->nBlockAlign);
|
|
|
|
Stream_Write_UINT16(pdu, clientFormat->wBitsPerSample);
|
|
|
|
Stream_Write_UINT16(pdu, clientFormat->cbSize);
|
2013-02-22 03:41:41 +04:00
|
|
|
|
|
|
|
if (clientFormat->cbSize > 0)
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write(pdu, clientFormat->data, clientFormat->cbSize);
|
2013-02-22 03:41:41 +04:00
|
|
|
}
|
2013-02-20 02:47:55 +04:00
|
|
|
|
2013-11-20 00:31:38 +04:00
|
|
|
WLog_Print(rdpsnd->log, WLOG_DEBUG, "Client Audio Formats");
|
2015-06-24 18:06:45 +03:00
|
|
|
return rdpsnd_virtual_channel_write(rdpsnd, pdu);
|
2013-02-22 03:41:41 +04:00
|
|
|
}
|
2011-08-15 12:28:52 +04:00
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd,
|
2016-09-26 13:12:37 +03:00
|
|
|
wStream* s)
|
2013-02-22 03:41:41 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
UINT16 index;
|
2013-02-22 03:41:41 +04:00
|
|
|
UINT16 wVersion;
|
|
|
|
UINT16 wNumberOfFormats;
|
2015-08-27 15:25:09 +03:00
|
|
|
UINT ret = ERROR_BAD_LENGTH;
|
2013-02-22 03:41:41 +04:00
|
|
|
rdpsnd_free_audio_formats(rdpsnd->ServerFormats, rdpsnd->NumberOfServerFormats);
|
|
|
|
rdpsnd->NumberOfServerFormats = 0;
|
|
|
|
rdpsnd->ServerFormats = NULL;
|
2013-02-20 02:47:55 +04:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
if (Stream_GetRemainingLength(s) < 30)
|
|
|
|
return ERROR_BAD_LENGTH;
|
|
|
|
|
2014-03-12 11:04:33 +04:00
|
|
|
/* http://msdn.microsoft.com/en-us/library/cc240956.aspx */
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek_UINT32(s); /* dwFlags */
|
2014-03-12 11:04:33 +04:00
|
|
|
Stream_Seek_UINT32(s); /* dwVolume */
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek_UINT32(s); /* dwPitch */
|
|
|
|
Stream_Seek_UINT16(s); /* wDGramPort */
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, wNumberOfFormats);
|
|
|
|
Stream_Read_UINT8(s, rdpsnd->cBlockNo); /* cLastBlockConfirmed */
|
|
|
|
Stream_Read_UINT16(s, wVersion); /* wVersion */
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_Seek_UINT8(s); /* bPad */
|
2013-02-22 03:41:41 +04:00
|
|
|
rdpsnd->NumberOfServerFormats = wNumberOfFormats;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
if (Stream_GetRemainingLength(s) / 14 < wNumberOfFormats)
|
|
|
|
return ERROR_BAD_LENGTH;
|
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
rdpsnd->ServerFormats = (AUDIO_FORMAT*) calloc(wNumberOfFormats,
|
2016-09-26 13:12:37 +03:00
|
|
|
sizeof(AUDIO_FORMAT));
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
if (!rdpsnd->ServerFormats)
|
|
|
|
return CHANNEL_RC_NO_MEMORY;
|
2013-02-20 02:47:55 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
for (index = 0; index < wNumberOfFormats; index++)
|
2011-08-15 11:08:23 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
AUDIO_FORMAT* format = &rdpsnd->ServerFormats[index];
|
2013-02-22 03:41:41 +04:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
if (Stream_GetRemainingLength(s) < 14)
|
|
|
|
goto out_fail;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, format->wFormatTag); /* wFormatTag */
|
|
|
|
Stream_Read_UINT16(s, format->nChannels); /* nChannels */
|
|
|
|
Stream_Read_UINT32(s, format->nSamplesPerSec); /* nSamplesPerSec */
|
|
|
|
Stream_Read_UINT32(s, format->nAvgBytesPerSec); /* nAvgBytesPerSec */
|
|
|
|
Stream_Read_UINT16(s, format->nBlockAlign); /* nBlockAlign */
|
|
|
|
Stream_Read_UINT16(s, format->wBitsPerSample); /* wBitsPerSample */
|
|
|
|
Stream_Read_UINT16(s, format->cbSize); /* cbSize */
|
2013-02-22 03:41:41 +04:00
|
|
|
|
2013-11-04 04:10:33 +04:00
|
|
|
if (format->cbSize > 0)
|
|
|
|
{
|
2015-06-24 18:06:45 +03:00
|
|
|
if (Stream_GetRemainingLength(s) < format->cbSize)
|
|
|
|
goto out_fail;
|
|
|
|
|
2013-11-04 04:10:33 +04:00
|
|
|
format->data = (BYTE*) malloc(format->cbSize);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
if (!format->data)
|
|
|
|
{
|
|
|
|
ret = CHANNEL_RC_NO_MEMORY;
|
|
|
|
goto out_fail;
|
|
|
|
}
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2013-11-04 04:10:33 +04:00
|
|
|
Stream_Read(s, format->data, format->cbSize);
|
|
|
|
}
|
2011-08-15 11:08:23 +04:00
|
|
|
}
|
|
|
|
|
2013-02-22 03:41:41 +04:00
|
|
|
rdpsnd_select_supported_audio_formats(rdpsnd);
|
2013-11-20 00:31:38 +04:00
|
|
|
WLog_Print(rdpsnd->log, WLOG_DEBUG, "Server Audio Formats");
|
2015-06-24 18:06:45 +03:00
|
|
|
ret = rdpsnd_send_client_audio_formats(rdpsnd);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
if (ret == CHANNEL_RC_OK)
|
|
|
|
{
|
|
|
|
if (wVersion >= 6)
|
|
|
|
ret = rdpsnd_send_quality_mode_pdu(rdpsnd);
|
|
|
|
}
|
2011-08-15 11:08:23 +04:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
return ret;
|
|
|
|
out_fail:
|
2018-02-20 14:15:30 +03:00
|
|
|
rdpsnd_free_audio_formats(rdpsnd->ServerFormats, rdpsnd->NumberOfServerFormats);
|
2015-06-24 18:06:45 +03:00
|
|
|
rdpsnd->ServerFormats = NULL;
|
2018-02-20 14:15:30 +03:00
|
|
|
rdpsnd->NumberOfServerFormats = 0;
|
2015-06-24 18:06:45 +03:00
|
|
|
return ret;
|
2013-02-21 22:25:43 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rdpsnd_send_training_confirm_pdu(rdpsndPlugin* rdpsnd,
|
2016-09-26 13:12:37 +03:00
|
|
|
UINT16 wTimeStamp, UINT16 wPackSize)
|
2013-02-21 22:25:43 +04:00
|
|
|
{
|
2013-03-21 23:19:33 +04:00
|
|
|
wStream* pdu;
|
2013-05-09 01:48:30 +04:00
|
|
|
pdu = Stream_New(NULL, 8);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
if (!pdu)
|
2015-07-15 10:50:35 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
2015-06-24 18:06:45 +03:00
|
|
|
return CHANNEL_RC_NO_MEMORY;
|
2015-07-15 10:50:35 +03:00
|
|
|
}
|
2015-06-24 18:06:45 +03:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(pdu, SNDC_TRAINING); /* msgType */
|
|
|
|
Stream_Write_UINT8(pdu, 0); /* bPad */
|
|
|
|
Stream_Write_UINT16(pdu, 4); /* BodySize */
|
|
|
|
Stream_Write_UINT16(pdu, wTimeStamp);
|
|
|
|
Stream_Write_UINT16(pdu, wPackSize);
|
2016-08-09 13:04:06 +03:00
|
|
|
WLog_Print(rdpsnd->log, WLOG_DEBUG,
|
2016-12-14 00:47:08 +03:00
|
|
|
"Training Response: wTimeStamp: %"PRIu16" wPackSize: %"PRIu16"",
|
2016-09-26 13:12:37 +03:00
|
|
|
wTimeStamp, wPackSize);
|
2015-06-24 18:06:45 +03:00
|
|
|
return rdpsnd_virtual_channel_write(rdpsnd, pdu);
|
2011-08-15 11:08:23 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
|
|
|
static UINT rdpsnd_recv_training_pdu(rdpsndPlugin* rdpsnd, wStream* s)
|
2011-08-15 11:08:23 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 wTimeStamp;
|
|
|
|
UINT16 wPackSize;
|
2011-08-15 11:08:23 +04:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
if (Stream_GetRemainingLength(s) < 4)
|
|
|
|
return ERROR_BAD_LENGTH;
|
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, wTimeStamp);
|
|
|
|
Stream_Read_UINT16(s, wPackSize);
|
2016-08-09 13:04:06 +03:00
|
|
|
WLog_Print(rdpsnd->log, WLOG_DEBUG,
|
2016-12-14 00:47:08 +03:00
|
|
|
"Training Request: wTimeStamp: %"PRIu16" wPackSize: %"PRIu16"",
|
2016-09-26 13:12:37 +03:00
|
|
|
wTimeStamp, wPackSize);
|
2015-06-24 18:06:45 +03:00
|
|
|
return rdpsnd_send_training_confirm_pdu(rdpsnd, wTimeStamp, wPackSize);
|
2011-08-15 11:08:23 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rdpsnd_recv_wave_info_pdu(rdpsndPlugin* rdpsnd, wStream* s,
|
2016-09-26 13:12:37 +03:00
|
|
|
UINT16 BodySize)
|
2011-08-15 11:08:23 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
UINT16 wFormatNo;
|
2018-02-20 14:15:30 +03:00
|
|
|
const AUDIO_FORMAT* format;
|
2013-02-28 00:10:35 +04:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
if (Stream_GetRemainingLength(s) < 12)
|
|
|
|
return ERROR_BAD_LENGTH;
|
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
rdpsnd->wArrivalTime = GetTickCount();
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, rdpsnd->wTimeStamp);
|
|
|
|
Stream_Read_UINT16(s, wFormatNo);
|
2018-02-20 14:15:30 +03:00
|
|
|
|
|
|
|
if (wFormatNo >= rdpsnd->NumberOfClientFormats)
|
|
|
|
return ERROR_INVALID_DATA;
|
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, rdpsnd->cBlockNo);
|
2013-04-30 06:35:15 +04:00
|
|
|
Stream_Seek(s, 3); /* bPad */
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read(s, rdpsnd->waveData, 4);
|
2011-08-15 11:08:23 +04:00
|
|
|
rdpsnd->waveDataSize = BodySize - 8;
|
2013-02-22 03:41:41 +04:00
|
|
|
format = &rdpsnd->ClientFormats[wFormatNo];
|
2018-02-20 14:15:30 +03:00
|
|
|
WLog_Print(rdpsnd->log, WLOG_DEBUG, "WaveInfo: cBlockNo: %"PRIu8" wFormatNo: %"PRIu16" [%s]",
|
|
|
|
rdpsnd->cBlockNo, wFormatNo, rdpsnd_get_audio_tag_string(format->wFormatTag));
|
2013-11-20 00:31:38 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if (!rdpsnd->isOpen || (wFormatNo != rdpsnd->wCurrentFormatNo))
|
2011-08-15 11:08:23 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
BOOL rc;
|
|
|
|
AUDIO_FORMAT deviceFormat = *format;
|
2018-04-09 12:10:14 +03:00
|
|
|
rdpsnd_recv_close_pdu(rdpsnd);
|
2018-02-20 14:15:30 +03:00
|
|
|
rc = IFCALLRESULT(FALSE, rdpsnd->device->FormatSupported, rdpsnd->device, format);
|
2013-02-28 05:46:14 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if (!rc)
|
2012-11-26 10:15:11 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
deviceFormat.wFormatTag = WAVE_FORMAT_PCM;
|
|
|
|
deviceFormat.wBitsPerSample = 16;
|
|
|
|
deviceFormat.cbSize = 0;
|
2012-11-26 10:15:11 +04:00
|
|
|
}
|
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
rc = IFCALLRESULT(FALSE, rdpsnd->device->Open, rdpsnd->device, &deviceFormat, rdpsnd->latency);
|
|
|
|
|
|
|
|
if (!rc)
|
|
|
|
return CHANNEL_RC_INITIALIZATION_ERROR;
|
|
|
|
|
|
|
|
rc = IFCALLRESULT(FALSE, rdpsnd->device->FormatSupported, rdpsnd->device, format);
|
|
|
|
|
|
|
|
if (!rc)
|
2012-11-26 10:15:11 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
if (!freerdp_dsp_context_reset(rdpsnd->dsp_context, format))
|
2016-08-09 13:04:06 +03:00
|
|
|
return CHANNEL_RC_INITIALIZATION_ERROR;
|
2012-11-26 10:15:11 +04:00
|
|
|
}
|
2018-02-20 14:15:30 +03:00
|
|
|
|
|
|
|
rdpsnd->isOpen = TRUE;
|
|
|
|
rdpsnd->wCurrentFormatNo = wFormatNo;
|
2011-08-15 11:08:23 +04:00
|
|
|
}
|
2015-06-24 18:06:45 +03:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
rdpsnd->expectingWave = TRUE;
|
2015-06-24 18:06:45 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2011-08-15 11:08:23 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rdpsnd_send_wave_confirm_pdu(rdpsndPlugin* rdpsnd,
|
2016-09-26 13:12:37 +03:00
|
|
|
UINT16 wTimeStamp, BYTE cConfirmedBlockNo)
|
2013-02-21 22:25:43 +04:00
|
|
|
{
|
2013-03-21 23:19:33 +04:00
|
|
|
wStream* pdu;
|
2013-05-09 01:48:30 +04:00
|
|
|
pdu = Stream_New(NULL, 8);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
if (!pdu)
|
2015-07-15 10:50:35 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "Stream_New failed!");
|
2015-06-24 18:06:45 +03:00
|
|
|
return CHANNEL_RC_NO_MEMORY;
|
2015-07-15 10:50:35 +03:00
|
|
|
}
|
2015-06-24 18:06:45 +03:00
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Write_UINT8(pdu, SNDC_WAVECONFIRM);
|
|
|
|
Stream_Write_UINT8(pdu, 0);
|
|
|
|
Stream_Write_UINT16(pdu, 4);
|
|
|
|
Stream_Write_UINT16(pdu, wTimeStamp);
|
|
|
|
Stream_Write_UINT8(pdu, cConfirmedBlockNo); /* cConfirmedBlockNo */
|
|
|
|
Stream_Write_UINT8(pdu, 0); /* bPad */
|
2015-06-24 18:06:45 +03:00
|
|
|
return rdpsnd_virtual_channel_write(rdpsnd, pdu);
|
2013-02-21 22:25:43 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
|
|
|
static UINT rdpsnd_recv_wave_pdu(rdpsndPlugin* rdpsnd, wStream* s)
|
2011-08-15 11:08:23 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
size_t size;
|
2013-02-26 02:49:07 +04:00
|
|
|
BYTE* data;
|
|
|
|
AUDIO_FORMAT* format;
|
2015-08-27 15:25:09 +03:00
|
|
|
UINT status;
|
2018-02-20 14:15:30 +03:00
|
|
|
DWORD end;
|
|
|
|
DWORD diffMS;
|
|
|
|
UINT latency = 0;
|
2013-02-21 11:56:57 +04:00
|
|
|
rdpsnd->expectingWave = FALSE;
|
2013-02-21 22:25:43 +04:00
|
|
|
/**
|
|
|
|
* The Wave PDU is a special case: it is always sent after a Wave Info PDU,
|
|
|
|
* and we do not process its header. Instead, the header is pad that needs
|
|
|
|
* to be filled with the first four bytes of the audio sample data sent as
|
|
|
|
* part of the preceding Wave Info PDU.
|
|
|
|
*/
|
2013-05-09 00:27:21 +04:00
|
|
|
CopyMemory(Stream_Buffer(s), rdpsnd->waveData, 4);
|
|
|
|
data = Stream_Buffer(s);
|
2018-02-20 14:15:30 +03:00
|
|
|
size = Stream_Length(s);
|
2013-02-26 02:49:07 +04:00
|
|
|
format = &rdpsnd->ClientFormats[rdpsnd->wCurrentFormatNo];
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_Print(rdpsnd->log, WLOG_DEBUG, "Wave: cBlockNo: %"PRIu8" wTimeStamp: %"PRIu16"",
|
2018-02-20 14:15:30 +03:00
|
|
|
rdpsnd->cBlockNo, rdpsnd->wTimeStamp);
|
2013-11-20 00:31:38 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if (rdpsnd->device)
|
2013-08-29 17:30:22 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
wStream* pcmData = StreamPool_Take(rdpsnd->pool, 4096);
|
2012-11-26 10:15:11 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if (rdpsnd->device->FormatSupported(rdpsnd->device, format))
|
|
|
|
{
|
|
|
|
latency = IFCALLRESULT(0, rdpsnd->device->Play, rdpsnd->device, data, size);
|
|
|
|
status = CHANNEL_RC_OK;
|
|
|
|
}
|
|
|
|
else if (freerdp_dsp_decode(rdpsnd->dsp_context, format, data, size, pcmData))
|
|
|
|
{
|
|
|
|
Stream_SealLength(pcmData);
|
2018-04-03 12:18:22 +03:00
|
|
|
latency = IFCALLRESULT(0, rdpsnd->device->Play, rdpsnd->device, Stream_Buffer(pcmData),
|
|
|
|
Stream_Length(pcmData));
|
2018-02-20 14:15:30 +03:00
|
|
|
status = CHANNEL_RC_OK;
|
|
|
|
}
|
2013-02-26 06:46:48 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
StreamPool_Return(rdpsnd->pool, pcmData);
|
2011-08-15 11:08:23 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
return status;
|
2013-02-21 23:58:39 +04:00
|
|
|
}
|
2013-12-16 00:59:51 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
end = GetTickCount();
|
|
|
|
diffMS = end - rdpsnd->wArrivalTime + latency;
|
|
|
|
return rdpsnd_send_wave_confirm_pdu(rdpsnd, rdpsnd->wTimeStamp + diffMS, rdpsnd->cBlockNo);
|
2011-08-15 11:08:23 +04:00
|
|
|
}
|
|
|
|
|
2013-02-21 22:25:43 +04:00
|
|
|
static void rdpsnd_recv_close_pdu(rdpsndPlugin* rdpsnd)
|
2011-08-15 11:08:23 +04:00
|
|
|
{
|
2013-11-20 00:31:38 +04:00
|
|
|
WLog_Print(rdpsnd->log, WLOG_DEBUG, "Close");
|
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if (rdpsnd->isOpen)
|
2013-02-28 00:10:35 +04:00
|
|
|
IFCALL(rdpsnd->device->Close, rdpsnd->device);
|
|
|
|
|
|
|
|
rdpsnd->isOpen = FALSE;
|
2011-08-15 11:08:23 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
|
|
|
static UINT rdpsnd_recv_volume_pdu(rdpsndPlugin* rdpsnd, wStream* s)
|
2011-08-15 11:08:23 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
BOOL error;
|
2012-10-09 11:26:39 +04:00
|
|
|
UINT32 dwVolume;
|
2011-08-15 11:08:23 +04:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
if (Stream_GetRemainingLength(s) < 4)
|
|
|
|
return ERROR_BAD_LENGTH;
|
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT32(s, dwVolume);
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_Print(rdpsnd->log, WLOG_DEBUG, "Volume: 0x%08"PRIX32"", dwVolume);
|
2018-02-20 14:15:30 +03:00
|
|
|
error = IFCALLRESULT(FALSE, rdpsnd->device->SetVolume, rdpsnd->device, dwVolume);
|
2013-11-20 00:31:38 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if (error)
|
2012-11-26 10:15:11 +04:00
|
|
|
{
|
2015-06-24 18:06:45 +03:00
|
|
|
WLog_ERR(TAG, "error setting volume");
|
|
|
|
return CHANNEL_RC_INITIALIZATION_ERROR;
|
2012-11-26 10:15:11 +04:00
|
|
|
}
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2011-08-15 11:08:23 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
|
|
|
static UINT rdpsnd_recv_pdu(rdpsndPlugin* rdpsnd, wStream* s)
|
2011-08-15 11:08:23 +04:00
|
|
|
{
|
2012-10-09 11:01:37 +04:00
|
|
|
BYTE msgType;
|
|
|
|
UINT16 BodySize;
|
2015-08-27 15:25:09 +03:00
|
|
|
UINT status = CHANNEL_RC_OK;
|
2011-08-15 11:08:23 +04:00
|
|
|
|
|
|
|
if (rdpsnd->expectingWave)
|
|
|
|
{
|
2015-06-24 18:06:45 +03:00
|
|
|
status = rdpsnd_recv_wave_pdu(rdpsnd, s);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Stream_GetRemainingLength(s) < 4)
|
|
|
|
{
|
|
|
|
status = ERROR_BAD_LENGTH;
|
|
|
|
goto out;
|
2011-08-15 11:08:23 +04:00
|
|
|
}
|
|
|
|
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT8(s, msgType); /* msgType */
|
2013-05-09 00:27:21 +04:00
|
|
|
Stream_Seek_UINT8(s); /* bPad */
|
2013-05-09 00:09:16 +04:00
|
|
|
Stream_Read_UINT16(s, BodySize);
|
2011-08-15 11:08:23 +04:00
|
|
|
|
2016-12-19 19:07:01 +03:00
|
|
|
if (!rdpsnd->attached)
|
|
|
|
goto out;
|
|
|
|
|
2016-12-14 00:47:08 +03:00
|
|
|
//WLog_ERR(TAG, "msgType %"PRIu8" BodySize %"PRIu16"", msgType, BodySize);
|
2011-08-15 11:08:23 +04:00
|
|
|
|
|
|
|
switch (msgType)
|
|
|
|
{
|
|
|
|
case SNDC_FORMATS:
|
2015-06-24 18:06:45 +03:00
|
|
|
status = rdpsnd_recv_server_audio_formats_pdu(rdpsnd, s);
|
2011-08-15 11:08:23 +04:00
|
|
|
break;
|
2012-11-26 10:15:11 +04:00
|
|
|
|
2011-08-15 11:08:23 +04:00
|
|
|
case SNDC_TRAINING:
|
2015-06-24 18:06:45 +03:00
|
|
|
status = rdpsnd_recv_training_pdu(rdpsnd, s);
|
2011-08-15 11:08:23 +04:00
|
|
|
break;
|
2012-11-26 10:15:11 +04:00
|
|
|
|
2011-08-15 11:08:23 +04:00
|
|
|
case SNDC_WAVE:
|
2015-06-24 18:06:45 +03:00
|
|
|
status = rdpsnd_recv_wave_info_pdu(rdpsnd, s, BodySize);
|
2011-08-15 11:08:23 +04:00
|
|
|
break;
|
2012-11-26 10:15:11 +04:00
|
|
|
|
2011-08-15 11:08:23 +04:00
|
|
|
case SNDC_CLOSE:
|
2013-02-21 22:25:43 +04:00
|
|
|
rdpsnd_recv_close_pdu(rdpsnd);
|
2011-08-15 11:08:23 +04:00
|
|
|
break;
|
2012-11-26 10:15:11 +04:00
|
|
|
|
2011-08-15 11:08:23 +04:00
|
|
|
case SNDC_SETVOLUME:
|
2015-06-24 18:06:45 +03:00
|
|
|
status = rdpsnd_recv_volume_pdu(rdpsnd, s);
|
2011-08-15 11:08:23 +04:00
|
|
|
break;
|
2012-11-26 10:15:11 +04:00
|
|
|
|
2011-08-15 11:08:23 +04:00
|
|
|
default:
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "unknown msgType %"PRIu8"", msgType);
|
2011-08-15 11:08:23 +04:00
|
|
|
break;
|
|
|
|
}
|
2012-02-27 21:12:17 +04:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
out:
|
2018-02-20 14:15:30 +03:00
|
|
|
StreamPool_Return(rdpsnd->pool, s);
|
2015-06-24 18:06:45 +03:00
|
|
|
return status;
|
2011-08-15 11:08:23 +04:00
|
|
|
}
|
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
static void rdpsnd_register_device_plugin(rdpsndPlugin* rdpsnd,
|
2016-09-26 13:12:37 +03:00
|
|
|
rdpsndDevicePlugin* device)
|
2011-08-15 11:08:23 +04:00
|
|
|
{
|
|
|
|
if (rdpsnd->device)
|
|
|
|
{
|
2014-09-12 18:19:32 +04:00
|
|
|
WLog_ERR(TAG, "existing device, abort.");
|
2011-08-15 11:08:23 +04:00
|
|
|
return;
|
|
|
|
}
|
2013-02-21 22:25:43 +04:00
|
|
|
|
2011-08-15 11:08:23 +04:00
|
|
|
rdpsnd->device = device;
|
2013-02-21 22:25:43 +04:00
|
|
|
device->rdpsnd = rdpsnd;
|
2011-08-15 11:08:23 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-08-09 13:04:06 +03:00
|
|
|
static UINT rdpsnd_load_device_plugin(rdpsndPlugin* rdpsnd, const char* name,
|
2016-09-26 13:12:37 +03:00
|
|
|
ADDIN_ARGV* args)
|
2011-08-15 11:08:23 +04:00
|
|
|
{
|
|
|
|
PFREERDP_RDPSND_DEVICE_ENTRY entry;
|
2016-08-09 13:04:06 +03:00
|
|
|
FREERDP_RDPSND_DEVICE_ENTRY_POINTS entryPoints;
|
2015-08-27 15:25:09 +03:00
|
|
|
UINT error;
|
2016-08-09 13:04:06 +03:00
|
|
|
entry = (PFREERDP_RDPSND_DEVICE_ENTRY)
|
2016-09-26 13:12:37 +03:00
|
|
|
freerdp_load_channel_addin_entry("rdpsnd", (LPSTR) name, NULL, 0);
|
2011-08-15 11:08:23 +04:00
|
|
|
|
2013-02-21 22:25:43 +04:00
|
|
|
if (!entry)
|
2015-07-15 10:50:35 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2011-08-15 11:08:23 +04:00
|
|
|
|
|
|
|
entryPoints.rdpsnd = rdpsnd;
|
|
|
|
entryPoints.pRegisterRdpsndDevice = rdpsnd_register_device_plugin;
|
2012-11-19 02:32:18 +04:00
|
|
|
entryPoints.args = args;
|
2012-11-03 03:42:57 +04:00
|
|
|
|
2015-07-15 10:50:35 +03:00
|
|
|
if ((error = entry(&entryPoints)))
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "%s entry returns error %"PRIu32"", name, error);
|
2012-11-03 03:42:57 +04:00
|
|
|
|
2016-03-07 14:54:49 +03:00
|
|
|
WLog_INFO(TAG, "Loaded %s backend for rdpsnd", name);
|
2015-07-15 10:50:35 +03:00
|
|
|
return error;
|
2011-08-15 11:08:23 +04:00
|
|
|
}
|
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
static BOOL rdpsnd_set_subsystem(rdpsndPlugin* rdpsnd, const char* subsystem)
|
2011-08-15 11:08:23 +04:00
|
|
|
{
|
2015-05-11 10:07:39 +03:00
|
|
|
free(rdpsnd->subsystem);
|
2012-11-19 02:32:18 +04:00
|
|
|
rdpsnd->subsystem = _strdup(subsystem);
|
2015-06-24 18:06:45 +03:00
|
|
|
return (rdpsnd->subsystem != NULL);
|
2012-11-19 02:32:18 +04:00
|
|
|
}
|
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
BOOL rdpsnd_set_device_name(rdpsndPlugin* rdpsnd, const char* device_name)
|
2012-11-19 02:32:18 +04:00
|
|
|
{
|
2015-05-11 10:07:39 +03:00
|
|
|
free(rdpsnd->device_name);
|
2012-11-19 02:32:18 +04:00
|
|
|
rdpsnd->device_name = _strdup(device_name);
|
2015-06-24 18:06:45 +03:00
|
|
|
return (rdpsnd->device_name != NULL);
|
2012-11-19 02:32:18 +04:00
|
|
|
}
|
|
|
|
|
2016-03-07 14:54:49 +03:00
|
|
|
static COMMAND_LINE_ARGUMENT_A rdpsnd_args[] =
|
2012-11-19 02:32:18 +04:00
|
|
|
{
|
|
|
|
{ "sys", COMMAND_LINE_VALUE_REQUIRED, "<subsystem>", NULL, NULL, -1, NULL, "subsystem" },
|
|
|
|
{ "dev", COMMAND_LINE_VALUE_REQUIRED, "<device>", NULL, NULL, -1, NULL, "device" },
|
|
|
|
{ "format", COMMAND_LINE_VALUE_REQUIRED, "<format>", NULL, NULL, -1, NULL, "format" },
|
|
|
|
{ "rate", COMMAND_LINE_VALUE_REQUIRED, "<rate>", NULL, NULL, -1, NULL, "rate" },
|
|
|
|
{ "channel", COMMAND_LINE_VALUE_REQUIRED, "<channel>", NULL, NULL, -1, NULL, "channel" },
|
|
|
|
{ "latency", COMMAND_LINE_VALUE_REQUIRED, "<latency>", NULL, NULL, -1, NULL, "latency" },
|
2013-11-19 23:29:31 +04:00
|
|
|
{ "quality", COMMAND_LINE_VALUE_REQUIRED, "<quality mode>", NULL, NULL, -1, NULL, "quality mode" },
|
2012-11-19 02:32:18 +04:00
|
|
|
{ NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
|
|
|
|
};
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
|
|
|
static UINT rdpsnd_process_addin_args(rdpsndPlugin* rdpsnd, ADDIN_ARGV* args)
|
2012-11-19 02:32:18 +04:00
|
|
|
{
|
|
|
|
int status;
|
|
|
|
DWORD flags;
|
|
|
|
COMMAND_LINE_ARGUMENT_A* arg;
|
2013-11-19 23:29:31 +04:00
|
|
|
rdpsnd->wQualityMode = HIGH_QUALITY; /* default quality mode */
|
|
|
|
|
2015-07-20 13:28:49 +03:00
|
|
|
if (args->argc > 1)
|
|
|
|
{
|
|
|
|
flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON;
|
2016-08-09 13:04:06 +03:00
|
|
|
status = CommandLineParseArgumentsA(args->argc, (const char**) args->argv,
|
2016-09-26 13:12:37 +03:00
|
|
|
rdpsnd_args, flags, rdpsnd, NULL, NULL);
|
2013-11-19 23:29:31 +04:00
|
|
|
|
2015-07-20 13:28:49 +03:00
|
|
|
if (status < 0)
|
|
|
|
return CHANNEL_RC_INITIALIZATION_ERROR;
|
2012-11-19 02:32:18 +04:00
|
|
|
|
2015-07-20 13:28:49 +03:00
|
|
|
arg = rdpsnd_args;
|
2017-11-14 18:10:52 +03:00
|
|
|
errno = 0;
|
2012-11-19 02:32:18 +04:00
|
|
|
|
2015-07-20 13:28:49 +03:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
|
|
|
|
continue;
|
2012-11-19 02:32:18 +04:00
|
|
|
|
2015-07-20 13:28:49 +03:00
|
|
|
CommandLineSwitchStart(arg)
|
|
|
|
CommandLineSwitchCase(arg, "sys")
|
|
|
|
{
|
|
|
|
if (!rdpsnd_set_subsystem(rdpsnd, arg->Value))
|
|
|
|
return CHANNEL_RC_NO_MEMORY;
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "dev")
|
|
|
|
{
|
|
|
|
if (!rdpsnd_set_device_name(rdpsnd, arg->Value))
|
|
|
|
return CHANNEL_RC_NO_MEMORY;
|
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "format")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > UINT16_MAX))
|
|
|
|
return CHANNEL_RC_INITIALIZATION_ERROR;
|
|
|
|
|
|
|
|
rdpsnd->fixedFormat = val;
|
2015-07-20 13:28:49 +03:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "rate")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > UINT32_MAX))
|
|
|
|
return CHANNEL_RC_INITIALIZATION_ERROR;
|
|
|
|
|
|
|
|
rdpsnd->fixedRate = val;
|
2015-07-20 13:28:49 +03:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "channel")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if ((errno != 0) || (val > UINT16_MAX))
|
|
|
|
return CHANNEL_RC_INITIALIZATION_ERROR;
|
|
|
|
|
|
|
|
rdpsnd->fixedChannel = val;
|
2015-07-20 13:28:49 +03:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "latency")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
unsigned long val = strtoul(arg->Value, NULL, 0);
|
|
|
|
|
2017-11-26 16:59:37 +03:00
|
|
|
if ((errno != 0) || (val > INT32_MAX))
|
2017-11-14 18:10:52 +03:00
|
|
|
return CHANNEL_RC_INITIALIZATION_ERROR;
|
|
|
|
|
|
|
|
rdpsnd->latency = val;
|
2015-07-20 13:28:49 +03:00
|
|
|
}
|
|
|
|
CommandLineSwitchCase(arg, "quality")
|
|
|
|
{
|
2017-11-14 18:10:52 +03:00
|
|
|
long wQualityMode = DYNAMIC_QUALITY;
|
2013-11-19 23:29:31 +04:00
|
|
|
|
2015-07-20 13:28:49 +03:00
|
|
|
if (_stricmp(arg->Value, "dynamic") == 0)
|
|
|
|
wQualityMode = DYNAMIC_QUALITY;
|
|
|
|
else if (_stricmp(arg->Value, "medium") == 0)
|
|
|
|
wQualityMode = MEDIUM_QUALITY;
|
|
|
|
else if (_stricmp(arg->Value, "high") == 0)
|
|
|
|
wQualityMode = HIGH_QUALITY;
|
|
|
|
else
|
2017-11-14 18:10:52 +03:00
|
|
|
{
|
|
|
|
wQualityMode = strtol(arg->Value, NULL, 0);
|
|
|
|
|
|
|
|
if (errno != 0)
|
|
|
|
return CHANNEL_RC_INITIALIZATION_ERROR;
|
|
|
|
}
|
2013-11-19 23:29:31 +04:00
|
|
|
|
2015-07-20 13:28:49 +03:00
|
|
|
if ((wQualityMode < 0) || (wQualityMode > 2))
|
|
|
|
wQualityMode = DYNAMIC_QUALITY;
|
2013-11-19 23:29:31 +04:00
|
|
|
|
2015-07-20 13:28:49 +03:00
|
|
|
rdpsnd->wQualityMode = (UINT16) wQualityMode;
|
|
|
|
}
|
|
|
|
CommandLineSwitchDefault(arg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CommandLineSwitchEnd(arg)
|
|
|
|
}
|
|
|
|
while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
|
2011-08-15 11:08:23 +04:00
|
|
|
}
|
2015-06-24 18:06:45 +03:00
|
|
|
|
|
|
|
return CHANNEL_RC_OK;
|
2011-08-15 11:08:23 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
|
|
|
static UINT rdpsnd_process_connect(rdpsndPlugin* rdpsnd)
|
2011-08-15 11:08:23 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
const struct
|
|
|
|
{
|
|
|
|
const char* subsystem;
|
|
|
|
const char* device;
|
|
|
|
}
|
|
|
|
backends[] =
|
|
|
|
{
|
|
|
|
#if defined(WITH_IOSAUDIO)
|
|
|
|
{"ios", ""},
|
|
|
|
#endif
|
|
|
|
#if defined(WITH_OPENSLES)
|
|
|
|
{"opensles", ""},
|
|
|
|
#endif
|
|
|
|
#if defined(WITH_PULSE)
|
|
|
|
{"pulse", ""},
|
|
|
|
#endif
|
|
|
|
#if defined(WITH_ALSA)
|
|
|
|
{"alsa", "default"},
|
|
|
|
#endif
|
|
|
|
#if defined(WITH_OSS)
|
|
|
|
{"oss", ""},
|
|
|
|
#endif
|
|
|
|
#if defined(WITH_MACAUDIO)
|
|
|
|
{"mac", "default"},
|
|
|
|
#endif
|
|
|
|
#if defined(WITH_WINMM)
|
|
|
|
{ "winmm", ""},
|
|
|
|
#endif
|
|
|
|
};
|
2012-11-19 02:32:18 +04:00
|
|
|
ADDIN_ARGV* args;
|
2015-08-27 15:25:09 +03:00
|
|
|
UINT status = ERROR_INTERNAL_ERROR;
|
2018-02-20 14:15:30 +03:00
|
|
|
rdpsnd->latency = 0;
|
2013-10-20 00:20:31 +04:00
|
|
|
args = (ADDIN_ARGV*) rdpsnd->channelEntryPoints.pExtendedData;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2012-11-19 02:32:18 +04:00
|
|
|
if (args)
|
2015-06-24 18:06:45 +03:00
|
|
|
{
|
|
|
|
status = rdpsnd_process_addin_args(rdpsnd, args);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
return status;
|
|
|
|
}
|
2012-07-29 06:24:14 +04:00
|
|
|
|
2012-11-19 02:32:18 +04:00
|
|
|
if (rdpsnd->subsystem)
|
2012-11-21 18:30:06 +04:00
|
|
|
{
|
|
|
|
if (strcmp(rdpsnd->subsystem, "fake") == 0)
|
2015-06-24 18:06:45 +03:00
|
|
|
return CHANNEL_RC_OK;
|
|
|
|
|
2015-07-15 10:50:35 +03:00
|
|
|
if ((status = rdpsnd_load_device_plugin(rdpsnd, rdpsnd->subsystem, args)))
|
2013-12-16 00:59:51 +04:00
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "unable to load the %s subsystem plugin because of error %"PRIu32"",
|
2016-09-26 13:12:37 +03:00
|
|
|
rdpsnd->subsystem, status);
|
2015-07-15 10:50:35 +03:00
|
|
|
return status;
|
2013-12-16 00:59:51 +04:00
|
|
|
}
|
2012-11-21 18:30:06 +04:00
|
|
|
}
|
2015-06-24 18:06:45 +03:00
|
|
|
else
|
2011-08-15 11:08:23 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
size_t x;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
for (x = 0; x < ARRAYSIZE(backends); x++)
|
2015-06-24 18:06:45 +03:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
const char* subsystem_name = backends[x].subsystem;
|
|
|
|
const char* device_name = backends[x].device;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-07-15 10:50:35 +03:00
|
|
|
if ((status = rdpsnd_load_device_plugin(rdpsnd, subsystem_name, args)))
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "unable to load the %s subsystem plugin because of error %"PRIu32"",
|
2016-09-26 13:12:37 +03:00
|
|
|
subsystem_name, status);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if (!rdpsnd->device)
|
|
|
|
continue;
|
2013-09-19 14:01:14 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if (!rdpsnd_set_subsystem(rdpsnd, subsystem_name) ||
|
|
|
|
!rdpsnd_set_device_name(rdpsnd, device_name))
|
2015-06-24 18:06:45 +03:00
|
|
|
return CHANNEL_RC_NO_MEMORY;
|
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
break;
|
2015-07-15 10:50:35 +03:00
|
|
|
}
|
2015-06-24 18:06:45 +03:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if (!rdpsnd->device || status)
|
2015-06-24 18:06:45 +03:00
|
|
|
return CHANNEL_RC_INITIALIZATION_ERROR;
|
2013-12-16 00:59:51 +04:00
|
|
|
}
|
2015-06-24 18:06:45 +03:00
|
|
|
|
|
|
|
return CHANNEL_RC_OK;
|
2011-08-15 11:08:23 +04:00
|
|
|
}
|
|
|
|
|
2015-01-20 13:53:12 +03:00
|
|
|
static void rdpsnd_process_disconnect(rdpsndPlugin* rdpsnd)
|
|
|
|
{
|
2018-04-09 12:10:14 +03:00
|
|
|
rdpsnd_recv_close_pdu(rdpsnd);
|
2015-01-20 13:53:12 +03:00
|
|
|
}
|
2012-10-09 03:54:11 +04:00
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
|
|
|
UINT rdpsnd_virtual_channel_write(rdpsndPlugin* rdpsnd, wStream* s)
|
2013-10-20 00:20:31 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
UINT status = CHANNEL_RC_BAD_INIT_HANDLE;
|
2013-10-20 00:20:31 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if (rdpsnd)
|
2014-02-10 10:06:11 +04:00
|
|
|
{
|
2016-11-22 16:47:20 +03:00
|
|
|
status = rdpsnd->channelEntryPoints.pVirtualChannelWriteEx(rdpsnd->InitHandle, rdpsnd->OpenHandle,
|
2016-09-26 13:12:37 +03:00
|
|
|
Stream_Buffer(s), (UINT32) Stream_GetPosition(s), s);
|
2014-02-10 10:06:11 +04:00
|
|
|
}
|
2013-10-20 00:20:31 +04:00
|
|
|
|
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
{
|
|
|
|
Stream_Free(s, TRUE);
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "pVirtualChannelWriteEx failed with %s [%08"PRIX32"]",
|
2016-09-26 13:12:37 +03:00
|
|
|
WTSErrorToString(status), status);
|
2013-10-20 00:20:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
|
|
|
static UINT rdpsnd_virtual_channel_event_data_received(rdpsndPlugin* plugin,
|
2016-09-26 13:12:37 +03:00
|
|
|
void* pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
2013-10-20 00:20:31 +04:00
|
|
|
{
|
|
|
|
if ((dataFlags & CHANNEL_FLAG_SUSPEND) || (dataFlags & CHANNEL_FLAG_RESUME))
|
2015-07-15 10:50:35 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2013-10-20 00:20:31 +04:00
|
|
|
|
|
|
|
if (dataFlags & CHANNEL_FLAG_FIRST)
|
|
|
|
{
|
2015-07-15 10:50:35 +03:00
|
|
|
if (!plugin->data_in)
|
2018-02-20 14:15:30 +03:00
|
|
|
plugin->data_in = StreamPool_Take(plugin->pool, totalLength);
|
2013-10-20 00:20:31 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
Stream_SetPosition(plugin->data_in, 0);
|
|
|
|
}
|
2015-07-15 10:50:35 +03:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if (!Stream_EnsureRemainingCapacity(plugin->data_in, dataLength))
|
2015-07-15 10:50:35 +03:00
|
|
|
return CHANNEL_RC_NO_MEMORY;
|
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
Stream_Write(plugin->data_in, pData, dataLength);
|
2013-10-20 00:20:31 +04:00
|
|
|
|
|
|
|
if (dataFlags & CHANNEL_FLAG_LAST)
|
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
Stream_SealLength(plugin->data_in);
|
|
|
|
Stream_SetPosition(plugin->data_in, 0);
|
|
|
|
|
|
|
|
if (!Queue_Enqueue(plugin->queue, plugin->data_in))
|
2013-10-20 00:20:31 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
WLog_ERR(TAG, "Queue_Enqueue failed!");
|
2015-07-15 10:50:35 +03:00
|
|
|
return ERROR_INTERNAL_ERROR;
|
2013-10-20 00:20:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
plugin->data_in = NULL;
|
|
|
|
}
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-07-15 10:50:35 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2013-10-20 00:20:31 +04:00
|
|
|
}
|
|
|
|
|
2016-11-23 15:17:56 +03:00
|
|
|
static VOID VCAPITYPE rdpsnd_virtual_channel_open_event_ex(LPVOID lpUserParam, DWORD openHandle,
|
|
|
|
UINT event,
|
2016-09-26 13:12:37 +03:00
|
|
|
LPVOID pData, UINT32 dataLength, UINT32 totalLength, UINT32 dataFlags)
|
2013-10-20 00:20:31 +04:00
|
|
|
{
|
2015-08-27 15:25:09 +03:00
|
|
|
UINT error = CHANNEL_RC_OK;
|
2016-11-22 16:47:20 +03:00
|
|
|
rdpsndPlugin* rdpsnd = (rdpsndPlugin*) lpUserParam;
|
2013-10-20 00:20:31 +04:00
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
if (!rdpsnd || (rdpsnd->OpenHandle != openHandle))
|
2013-10-20 00:20:31 +04:00
|
|
|
{
|
2016-11-22 16:47:20 +03:00
|
|
|
WLog_ERR(TAG, "error no match");
|
2013-10-20 00:20:31 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (event)
|
|
|
|
{
|
|
|
|
case CHANNEL_EVENT_DATA_RECEIVED:
|
2016-08-09 13:04:06 +03:00
|
|
|
if ((error = rdpsnd_virtual_channel_event_data_received(rdpsnd, pData,
|
2016-09-26 13:12:37 +03:00
|
|
|
dataLength, totalLength, dataFlags)))
|
2016-08-09 13:04:06 +03:00
|
|
|
WLog_ERR(TAG,
|
2016-12-14 00:47:08 +03:00
|
|
|
"rdpsnd_virtual_channel_event_data_received failed with error %"PRIu32"", error);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2013-10-20 00:20:31 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CHANNEL_EVENT_WRITE_COMPLETE:
|
|
|
|
Stream_Free((wStream*) pData, TRUE);
|
|
|
|
break;
|
2015-01-20 13:53:12 +03:00
|
|
|
|
|
|
|
case CHANNEL_EVENT_USER:
|
|
|
|
break;
|
2013-10-20 00:20:31 +04:00
|
|
|
}
|
2015-07-15 10:50:35 +03:00
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
if (error && rdpsnd->rdpcontext)
|
|
|
|
setChannelError(rdpsnd->rdpcontext, error,
|
2016-11-22 16:47:20 +03:00
|
|
|
"rdpsnd_virtual_channel_open_event_ex reported an error");
|
2013-10-20 00:20:31 +04:00
|
|
|
}
|
|
|
|
|
2018-03-07 14:03:10 +03:00
|
|
|
static DWORD WINAPI rdpsnd_virtual_channel_client_thread(LPVOID arg)
|
2013-10-20 00:20:31 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
BOOL running = TRUE;
|
2014-12-27 21:50:50 +03:00
|
|
|
rdpsndPlugin* rdpsnd = (rdpsndPlugin*) arg;
|
2018-02-20 14:15:30 +03:00
|
|
|
DWORD error = CHANNEL_RC_OK;
|
|
|
|
HANDLE events[2];
|
2016-09-26 13:12:37 +03:00
|
|
|
|
2015-07-15 10:50:35 +03:00
|
|
|
if ((error = rdpsnd_process_connect(rdpsnd)))
|
2015-06-24 18:06:45 +03:00
|
|
|
{
|
|
|
|
WLog_ERR(TAG, "error connecting sound channel");
|
|
|
|
goto out;
|
|
|
|
}
|
2013-10-20 00:20:31 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
events[1] = rdpsnd->stopEvent;
|
|
|
|
events[0] = Queue_Event(rdpsnd->queue);
|
|
|
|
|
|
|
|
do
|
2013-10-20 00:20:31 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
const DWORD status = WaitForMultipleObjects(ARRAYSIZE(events), events, FALSE, INFINITE);
|
2013-10-20 00:20:31 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
switch (status)
|
2013-10-20 00:20:31 +04:00
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
case WAIT_OBJECT_0:
|
|
|
|
{
|
|
|
|
wStream* s = Queue_Dequeue(rdpsnd->queue);
|
|
|
|
error = rdpsnd_recv_pdu(rdpsnd, s);
|
|
|
|
}
|
|
|
|
break;
|
2013-10-20 00:20:31 +04:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
case WAIT_OBJECT_0 + 1:
|
|
|
|
running = FALSE;
|
|
|
|
break;
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
default:
|
|
|
|
error = status;
|
2015-07-15 10:50:35 +03:00
|
|
|
break;
|
2013-10-20 00:20:31 +04:00
|
|
|
}
|
|
|
|
}
|
2018-02-20 14:15:30 +03:00
|
|
|
while ((error == CHANNEL_RC_OK) && running);
|
2013-10-20 00:20:31 +04:00
|
|
|
|
2015-06-24 18:06:45 +03:00
|
|
|
out:
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-07-15 10:50:35 +03:00
|
|
|
if (error && rdpsnd->rdpcontext)
|
2016-08-09 13:04:06 +03:00
|
|
|
setChannelError(rdpsnd->rdpcontext, error,
|
2016-09-26 13:12:37 +03:00
|
|
|
"rdpsnd_virtual_channel_client_thread reported an error");
|
2015-07-15 10:50:35 +03:00
|
|
|
|
2015-01-20 13:53:12 +03:00
|
|
|
rdpsnd_process_disconnect(rdpsnd);
|
2018-02-20 14:15:30 +03:00
|
|
|
ExitThread((DWORD)error);
|
2018-03-07 14:03:10 +03:00
|
|
|
return error;
|
2013-10-20 00:20:31 +04:00
|
|
|
}
|
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
/* Called during cleanup.
|
|
|
|
* All streams still in the queue have been removed
|
|
|
|
* from the streampool and nead cleanup. */
|
|
|
|
static void rdpsnd_queue_free(void* data)
|
|
|
|
{
|
|
|
|
wStream* s = (wStream*)data;
|
|
|
|
Stream_Free(s, TRUE);
|
|
|
|
}
|
|
|
|
|
2018-04-09 12:10:14 +03:00
|
|
|
static UINT rdpsnd_virtual_channel_event_initialized(rdpsndPlugin* rdpsnd,
|
|
|
|
LPVOID pData, UINT32 dataLength)
|
|
|
|
{
|
|
|
|
rdpsnd->stopEvent = CreateEventA(NULL, TRUE, FALSE, "rdpsnd->stopEvent");
|
|
|
|
|
|
|
|
if (!rdpsnd->stopEvent)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
return CHANNEL_RC_OK;
|
|
|
|
fail:
|
|
|
|
rdpsnd_virtual_channel_event_terminated(rdpsnd);
|
|
|
|
return ERROR_INTERNAL_ERROR;
|
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
2016-11-14 23:23:05 +03:00
|
|
|
static UINT rdpsnd_virtual_channel_event_connected(rdpsndPlugin* rdpsnd,
|
2016-09-26 13:12:37 +03:00
|
|
|
LPVOID pData, UINT32 dataLength)
|
2013-10-20 00:20:31 +04:00
|
|
|
{
|
|
|
|
UINT32 status;
|
2016-11-22 16:47:20 +03:00
|
|
|
status = rdpsnd->channelEntryPoints.pVirtualChannelOpenEx(rdpsnd->InitHandle,
|
2016-11-14 23:23:05 +03:00
|
|
|
&rdpsnd->OpenHandle, rdpsnd->channelDef.name,
|
2016-11-22 16:47:20 +03:00
|
|
|
rdpsnd_virtual_channel_open_event_ex);
|
2013-10-20 00:20:31 +04:00
|
|
|
|
|
|
|
if (status != CHANNEL_RC_OK)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "pVirtualChannelOpenEx failed with %s [%08"PRIX32"]",
|
2016-09-26 13:12:37 +03:00
|
|
|
WTSErrorToString(status), status);
|
2015-07-15 10:50:35 +03:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
rdpsnd->dsp_context = freerdp_dsp_context_new(FALSE);
|
2016-11-14 23:23:05 +03:00
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
if (!rdpsnd->dsp_context)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
rdpsnd->queue = Queue_New(TRUE, 32, 2);
|
|
|
|
|
|
|
|
if (!rdpsnd->queue)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
rdpsnd->queue->object.fnObjectFree = rdpsnd_queue_free;
|
|
|
|
rdpsnd->pool = StreamPool_New(TRUE, 4096);
|
|
|
|
|
|
|
|
if (!rdpsnd->pool)
|
|
|
|
goto fail;
|
|
|
|
|
2018-04-09 12:10:14 +03:00
|
|
|
ResetEvent(rdpsnd->stopEvent);
|
2016-11-14 23:23:05 +03:00
|
|
|
rdpsnd->thread = CreateThread(NULL, 0,
|
2018-02-20 14:15:30 +03:00
|
|
|
rdpsnd_virtual_channel_client_thread, (void*) rdpsnd,
|
2016-09-26 13:12:37 +03:00
|
|
|
0, NULL);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2016-11-14 23:23:05 +03:00
|
|
|
if (!rdpsnd->thread)
|
2018-02-20 14:15:30 +03:00
|
|
|
goto fail;
|
2015-07-15 10:50:35 +03:00
|
|
|
|
|
|
|
return CHANNEL_RC_OK;
|
2018-02-20 14:15:30 +03:00
|
|
|
fail:
|
|
|
|
freerdp_dsp_context_free(rdpsnd->dsp_context);
|
|
|
|
StreamPool_Free(rdpsnd->pool);
|
|
|
|
Queue_Free(rdpsnd->queue);
|
|
|
|
|
|
|
|
if (rdpsnd->stopEvent)
|
|
|
|
CloseHandle(rdpsnd->stopEvent);
|
|
|
|
|
|
|
|
if (rdpsnd->thread)
|
|
|
|
CloseHandle(rdpsnd->thread);
|
|
|
|
|
|
|
|
return CHANNEL_RC_NO_MEMORY;
|
2013-10-20 00:20:31 +04:00
|
|
|
}
|
|
|
|
|
2015-08-27 15:25:09 +03:00
|
|
|
/**
|
|
|
|
* Function description
|
|
|
|
*
|
|
|
|
* @return 0 on success, otherwise a Win32 error code
|
|
|
|
*/
|
|
|
|
static UINT rdpsnd_virtual_channel_event_disconnected(rdpsndPlugin* rdpsnd)
|
2013-10-20 00:20:31 +04:00
|
|
|
{
|
2015-08-27 15:25:09 +03:00
|
|
|
UINT error;
|
2018-04-09 12:10:14 +03:00
|
|
|
|
|
|
|
if (rdpsnd->OpenHandle == 0)
|
|
|
|
return CHANNEL_RC_OK;
|
|
|
|
|
2018-02-20 14:15:30 +03:00
|
|
|
SetEvent(rdpsnd->stopEvent);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-07-30 16:49:21 +03:00
|
|
|
if (WaitForSingleObject(rdpsnd->thread, INFINITE) == WAIT_FAILED)
|
2016-08-09 13:04:06 +03:00
|
|
|
{
|
|
|
|
error = GetLastError();
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "WaitForSingleObject failed with error %"PRIu32"!", error);
|
2016-08-09 13:04:06 +03:00
|
|
|
return error;
|
|
|
|
}
|
2014-12-27 21:50:50 +03:00
|
|
|
|
2015-01-20 13:53:12 +03:00
|
|
|
CloseHandle(rdpsnd->thread);
|
2016-11-22 16:47:20 +03:00
|
|
|
error = rdpsnd->channelEntryPoints.pVirtualChannelCloseEx(rdpsnd->InitHandle, rdpsnd->OpenHandle);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-07-15 10:50:35 +03:00
|
|
|
if (CHANNEL_RC_OK != error)
|
2015-01-20 13:53:12 +03:00
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "pVirtualChannelCloseEx failed with %s [%08"PRIX32"]",
|
2016-09-26 13:12:37 +03:00
|
|
|
WTSErrorToString(error), error);
|
2015-07-15 10:50:35 +03:00
|
|
|
return error;
|
2015-01-20 13:53:12 +03:00
|
|
|
}
|
2013-10-20 00:20:31 +04:00
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
rdpsnd->OpenHandle = 0;
|
2018-02-20 14:15:30 +03:00
|
|
|
freerdp_dsp_context_free(rdpsnd->dsp_context);
|
|
|
|
StreamPool_Return(rdpsnd->pool, rdpsnd->data_in);
|
|
|
|
StreamPool_Free(rdpsnd->pool);
|
|
|
|
Queue_Free(rdpsnd->queue);
|
2015-01-20 13:53:12 +03:00
|
|
|
rdpsnd_free_audio_formats(rdpsnd->ClientFormats, rdpsnd->NumberOfClientFormats);
|
|
|
|
rdpsnd->NumberOfClientFormats = 0;
|
|
|
|
rdpsnd->ClientFormats = NULL;
|
2013-11-06 23:31:33 +04:00
|
|
|
rdpsnd_free_audio_formats(rdpsnd->ServerFormats, rdpsnd->NumberOfServerFormats);
|
|
|
|
rdpsnd->NumberOfServerFormats = 0;
|
|
|
|
rdpsnd->ServerFormats = NULL;
|
|
|
|
|
2015-01-20 13:53:12 +03:00
|
|
|
if (rdpsnd->device)
|
|
|
|
{
|
|
|
|
IFCALL(rdpsnd->device->Free, rdpsnd->device);
|
|
|
|
rdpsnd->device = NULL;
|
|
|
|
}
|
|
|
|
|
2015-07-15 10:50:35 +03:00
|
|
|
return CHANNEL_RC_OK;
|
2015-01-20 13:53:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* rdpsnd)
|
|
|
|
{
|
2018-02-20 14:15:30 +03:00
|
|
|
if (rdpsnd)
|
2018-04-09 12:10:14 +03:00
|
|
|
{
|
|
|
|
free(rdpsnd->subsystem);
|
|
|
|
free(rdpsnd->device_name);
|
|
|
|
CloseHandle(rdpsnd->stopEvent);
|
2018-02-20 14:15:30 +03:00
|
|
|
rdpsnd->InitHandle = 0;
|
2018-04-09 12:10:14 +03:00
|
|
|
}
|
2018-02-20 14:15:30 +03:00
|
|
|
|
2014-12-03 22:17:27 +03:00
|
|
|
free(rdpsnd);
|
2013-10-20 00:20:31 +04:00
|
|
|
}
|
|
|
|
|
2016-11-22 16:47:20 +03:00
|
|
|
static VOID VCAPITYPE rdpsnd_virtual_channel_init_event_ex(LPVOID lpUserParam, LPVOID pInitHandle,
|
2016-09-26 13:12:37 +03:00
|
|
|
UINT event, LPVOID pData, UINT dataLength)
|
2013-10-20 00:20:31 +04:00
|
|
|
{
|
2015-08-27 15:25:09 +03:00
|
|
|
UINT error = CHANNEL_RC_OK;
|
2016-11-22 16:47:20 +03:00
|
|
|
rdpsndPlugin* plugin = (rdpsndPlugin*) lpUserParam;
|
2013-10-20 00:20:31 +04:00
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
if (!plugin || (plugin->InitHandle != pInitHandle))
|
2013-10-20 00:20:31 +04:00
|
|
|
{
|
2016-11-22 16:47:20 +03:00
|
|
|
WLog_ERR(TAG, "error no match");
|
2016-03-14 15:19:08 +03:00
|
|
|
return;
|
2013-10-20 00:20:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (event)
|
|
|
|
{
|
2018-04-09 12:10:14 +03:00
|
|
|
case CHANNEL_EVENT_INITIALIZED:
|
|
|
|
if ((error = rdpsnd_virtual_channel_event_initialized(plugin, pData, dataLength)))
|
|
|
|
WLog_ERR(TAG, "rdpsnd_virtual_channel_event_initialized failed with error %"PRIu32"!",
|
|
|
|
error);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2013-10-20 00:20:31 +04:00
|
|
|
case CHANNEL_EVENT_CONNECTED:
|
2015-07-15 10:50:35 +03:00
|
|
|
if ((error = rdpsnd_virtual_channel_event_connected(plugin, pData, dataLength)))
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "rdpsnd_virtual_channel_event_connected failed with error %"PRIu32"!",
|
2016-09-26 13:12:37 +03:00
|
|
|
error);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2013-10-20 00:20:31 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CHANNEL_EVENT_DISCONNECTED:
|
2015-07-15 10:50:35 +03:00
|
|
|
if ((error = rdpsnd_virtual_channel_event_disconnected(plugin)))
|
2016-08-09 13:04:06 +03:00
|
|
|
WLog_ERR(TAG,
|
2016-12-14 00:47:08 +03:00
|
|
|
"rdpsnd_virtual_channel_event_disconnected failed with error %"PRIu32"!", error);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2013-10-20 00:20:31 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CHANNEL_EVENT_TERMINATED:
|
|
|
|
rdpsnd_virtual_channel_event_terminated(plugin);
|
|
|
|
break;
|
2016-12-19 19:07:01 +03:00
|
|
|
|
|
|
|
case CHANNEL_EVENT_ATTACHED:
|
|
|
|
plugin->attached = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHANNEL_EVENT_DETACHED:
|
|
|
|
plugin->attached = FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2013-10-20 00:20:31 +04:00
|
|
|
}
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2016-10-06 14:04:06 +03:00
|
|
|
if (error && plugin && plugin->rdpcontext)
|
2016-08-09 13:04:06 +03:00
|
|
|
setChannelError(plugin->rdpcontext, error,
|
2016-09-26 13:12:37 +03:00
|
|
|
"rdpsnd_virtual_channel_init_event reported an error");
|
2013-10-20 00:20:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* rdpsnd is always built-in */
|
2016-11-22 16:47:20 +03:00
|
|
|
#define VirtualChannelEntryEx rdpsnd_VirtualChannelEntryEx
|
2013-10-20 00:20:31 +04:00
|
|
|
|
2016-11-22 16:47:20 +03:00
|
|
|
BOOL VCAPITYPE VirtualChannelEntryEx(PCHANNEL_ENTRY_POINTS pEntryPoints, PVOID pInitHandle)
|
2013-10-20 00:20:31 +04:00
|
|
|
{
|
2015-01-20 13:53:12 +03:00
|
|
|
UINT rc;
|
2013-10-20 00:20:31 +04:00
|
|
|
rdpsndPlugin* rdpsnd;
|
2016-11-22 16:47:20 +03:00
|
|
|
CHANNEL_ENTRY_POINTS_FREERDP_EX* pEntryPointsEx;
|
2016-09-26 13:12:14 +03:00
|
|
|
|
|
|
|
if (!pEntryPoints)
|
|
|
|
return FALSE;
|
|
|
|
|
2014-12-03 22:17:27 +03:00
|
|
|
rdpsnd = (rdpsndPlugin*) calloc(1, sizeof(rdpsndPlugin));
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-05-18 12:28:00 +03:00
|
|
|
if (!rdpsnd)
|
2015-05-20 20:19:50 +03:00
|
|
|
return FALSE;
|
2015-05-18 12:28:00 +03:00
|
|
|
|
2016-12-19 19:07:01 +03:00
|
|
|
rdpsnd->attached = TRUE;
|
2015-05-18 12:28:00 +03:00
|
|
|
rdpsnd->channelDef.options =
|
2016-08-09 13:04:06 +03:00
|
|
|
CHANNEL_OPTION_INITIALIZED |
|
|
|
|
CHANNEL_OPTION_ENCRYPT_RDP;
|
2015-05-18 12:28:00 +03:00
|
|
|
strcpy(rdpsnd->channelDef.name, "rdpsnd");
|
2016-11-22 16:47:20 +03:00
|
|
|
pEntryPointsEx = (CHANNEL_ENTRY_POINTS_FREERDP_EX*) pEntryPoints;
|
2015-07-15 10:50:35 +03:00
|
|
|
|
2016-11-22 16:47:20 +03:00
|
|
|
if ((pEntryPointsEx->cbSize >= sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX)) &&
|
2016-08-09 13:04:06 +03:00
|
|
|
(pEntryPointsEx->MagicNumber == FREERDP_CHANNEL_MAGIC_NUMBER))
|
2015-07-15 10:50:35 +03:00
|
|
|
{
|
|
|
|
rdpsnd->rdpcontext = pEntryPointsEx->context;
|
|
|
|
}
|
|
|
|
|
2015-05-18 12:28:00 +03:00
|
|
|
rdpsnd->log = WLog_Get("com.freerdp.channels.rdpsnd.client");
|
2016-11-22 16:47:20 +03:00
|
|
|
CopyMemory(&(rdpsnd->channelEntryPoints), pEntryPoints,
|
|
|
|
sizeof(CHANNEL_ENTRY_POINTS_FREERDP_EX));
|
|
|
|
rdpsnd->InitHandle = pInitHandle;
|
2016-11-23 15:22:03 +03:00
|
|
|
rc = rdpsnd->channelEntryPoints.pVirtualChannelInitEx(rdpsnd, NULL, pInitHandle,
|
2016-09-26 13:12:37 +03:00
|
|
|
&rdpsnd->channelDef, 1, VIRTUAL_CHANNEL_VERSION_WIN2000,
|
2016-11-22 16:47:20 +03:00
|
|
|
rdpsnd_virtual_channel_init_event_ex);
|
2016-08-09 13:04:06 +03:00
|
|
|
|
2015-05-18 12:28:00 +03:00
|
|
|
if (CHANNEL_RC_OK != rc)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
WLog_ERR(TAG, "pVirtualChannelInitEx failed with %s [%08"PRIX32"]",
|
2016-09-26 13:12:37 +03:00
|
|
|
WTSErrorToString(rc), rc);
|
2015-05-18 12:28:00 +03:00
|
|
|
free(rdpsnd);
|
2015-05-20 20:19:50 +03:00
|
|
|
return FALSE;
|
2013-10-20 00:20:31 +04:00
|
|
|
}
|
2012-10-09 03:54:11 +04:00
|
|
|
|
2016-08-09 13:04:06 +03:00
|
|
|
return TRUE;
|
2012-10-09 03:54:11 +04:00
|
|
|
}
|