2 * FreeRDP: A Remote Desktop Protocol Implementation
3 * Audio Output Virtual Channel
5 * Copyright 2009-2011 Jay Sorg
6 * Copyright 2010-2011 Vic Lee
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
33 #include <winpr/crt.h>
34 #include <winpr/synch.h>
35 #include <winpr/print.h>
36 #include <winpr/cmdline.h>
37 #include <winpr/sysinfo.h>
38 #include <winpr/collections.h>
40 #include <freerdp/types.h>
41 #include <freerdp/addin.h>
42 #include <freerdp/constants.h>
43 #include <freerdp/utils/stream.h>
44 #include <freerdp/utils/signal.h>
45 #include <freerdp/utils/svc_plugin.h>
47 #include "rdpsnd_main.h"
49 #define TIME_DELAY_MS 65
61 AUDIO_FORMAT* ServerFormats;
62 UINT16 NumberOfServerFormats;
64 AUDIO_FORMAT* ClientFormats;
65 UINT16 NumberOfClientFormats;
82 rdpsndDevicePlugin* device;
85 void rdpsnd_send_wave_confirm_pdu(rdpsndPlugin* rdpsnd, UINT16 wTimeStamp, BYTE cConfirmedBlockNo);
87 static void* rdpsnd_schedule_thread(void* arg)
94 rdpsndPlugin* rdpsnd = (rdpsndPlugin*) arg;
98 if (!MessageQueue_Wait(rdpsnd->queue))
101 if (!MessageQueue_Peek(rdpsnd->queue, &message, TRUE))
104 if (message.id == WMQ_QUIT)
107 wave = (RDPSND_WAVE*) message.wParam;
108 wCurrentTime = (UINT16) GetTickCount();
109 wTimeStamp = wave->wLocalTimeB;
111 if (wCurrentTime <= wTimeStamp)
113 wTimeDiff = wTimeStamp - wCurrentTime;
117 rdpsnd_send_wave_confirm_pdu(rdpsnd, wave->wTimeStampB, wave->cBlockNo);
124 void rdpsnd_send_quality_mode_pdu(rdpsndPlugin* rdpsnd)
129 stream_write_BYTE(pdu, SNDC_QUALITYMODE); /* msgType */
130 stream_write_BYTE(pdu, 0); /* bPad */
131 stream_write_UINT16(pdu, 4); /* BodySize */
132 stream_write_UINT16(pdu, HIGH_QUALITY); /* wQualityMode */
133 stream_write_UINT16(pdu, 0); /* Reserved */
135 svc_plugin_send((rdpSvcPlugin*) rdpsnd, pdu);
138 void rdpsnd_free_audio_formats(AUDIO_FORMAT* formats, UINT16 count)
141 AUDIO_FORMAT* format;
145 for (index = 0; index < (int) count; index++)
147 format = &formats[index];
157 char* rdpsnd_get_audio_tag_string(UINT16 wFormatTag)
161 case WAVE_FORMAT_PCM:
162 return "WAVE_FORMAT_PCM";
164 case WAVE_FORMAT_ADPCM:
165 return "WAVE_FORMAT_ADPCM";
167 case WAVE_FORMAT_ALAW:
168 return "WAVE_FORMAT_ALAW";
170 case WAVE_FORMAT_MULAW:
171 return "WAVE_FORMAT_MULAW";
173 case WAVE_FORMAT_DVI_ADPCM:
174 return "WAVE_FORMAT_DVI_ADPCM";
177 return "WAVE_FORMAT_UNKNOWN";
180 void rdpsnd_print_audio_format(AUDIO_FORMAT* format)
182 printf("%s: wFormatTag: 0x%04X nChannels: %d nSamplesPerSec: %d nAvgBytesPerSec: %d nBlockAlign: %d wBitsPerSample: %d\n",
183 rdpsnd_get_audio_tag_string(format->wFormatTag), format->wFormatTag,
184 format->nChannels, format->nSamplesPerSec, format->nAvgBytesPerSec,
185 format->nBlockAlign, format->wBitsPerSample);
188 UINT32 rdpsnd_compute_audio_time_length(AUDIO_FORMAT* format, int size)
194 * [MSDN-AUDIOFORMAT]:
195 * http://msdn.microsoft.com/en-us/library/ms713497.aspx
198 wSamples = (size * 8) / format->wBitsPerSample;
199 mstime = (((wSamples * 1000) / format->nSamplesPerSec) / format->nChannels);
204 void rdpsnd_select_supported_audio_formats(rdpsndPlugin* rdpsnd)
207 AUDIO_FORMAT* serverFormat;
208 AUDIO_FORMAT* clientFormat;
210 rdpsnd_free_audio_formats(rdpsnd->ClientFormats, rdpsnd->NumberOfClientFormats);
211 rdpsnd->NumberOfClientFormats = 0;
212 rdpsnd->ClientFormats = NULL;
214 rdpsnd->ClientFormats = (AUDIO_FORMAT*) malloc(sizeof(AUDIO_FORMAT) * rdpsnd->NumberOfServerFormats);
216 for (index = 0; index < (int) rdpsnd->NumberOfServerFormats; index++)
218 serverFormat = &rdpsnd->ServerFormats[index];
220 if (rdpsnd->fixedFormat > 0 && (rdpsnd->fixedFormat != serverFormat->wFormatTag))
223 if (rdpsnd->fixedChannel > 0 && (rdpsnd->fixedChannel != serverFormat->nChannels))
226 if (rdpsnd->fixedRate > 0 && (rdpsnd->fixedRate != serverFormat->nSamplesPerSec))
229 if (rdpsnd->device && rdpsnd->device->FormatSupported(rdpsnd->device, serverFormat))
231 clientFormat = &rdpsnd->ClientFormats[rdpsnd->NumberOfClientFormats++];
233 CopyMemory(clientFormat, serverFormat, sizeof(AUDIO_FORMAT));
234 clientFormat->cbSize = 0;
236 if (serverFormat->cbSize > 0)
238 clientFormat->data = (BYTE*) malloc(serverFormat->cbSize);
239 CopyMemory(clientFormat->data, serverFormat->data, serverFormat->cbSize);
240 clientFormat->cbSize = serverFormat->cbSize;
246 void rdpsnd_send_client_audio_formats(rdpsndPlugin* rdpsnd)
253 UINT16 dwVolumeRight;
254 UINT16 wNumberOfFormats;
255 AUDIO_FORMAT* clientFormat;
257 dwVolumeLeft = (0xFFFF); /* 100% */
258 dwVolumeRight = (0xFFFF); /* 100% */
259 dwVolume = (dwVolumeLeft << 16) | dwVolumeRight;
261 wNumberOfFormats = rdpsnd->NumberOfClientFormats;
265 for (index = 0; index < (int) wNumberOfFormats; index++)
266 length += (18 + rdpsnd->ClientFormats[index].cbSize);
268 pdu = stream_new(length);
270 stream_write_BYTE(pdu, SNDC_FORMATS); /* msgType */
271 stream_write_BYTE(pdu, 0); /* bPad */
272 stream_write_UINT16(pdu, length - 4); /* BodySize */
274 stream_write_UINT32(pdu, TSSNDCAPS_ALIVE | TSSNDCAPS_VOLUME); /* dwFlags */
275 stream_write_UINT32(pdu, dwVolume); /* dwVolume */
276 stream_write_UINT32(pdu, 0); /* dwPitch */
277 stream_write_UINT16(pdu, 0); /* wDGramPort */
278 stream_write_UINT16(pdu, wNumberOfFormats); /* wNumberOfFormats */
279 stream_write_BYTE(pdu, 0); /* cLastBlockConfirmed */
280 stream_write_UINT16(pdu, 6); /* wVersion */
281 stream_write_BYTE(pdu, 0); /* bPad */
283 for (index = 0; index < (int) wNumberOfFormats; index++)
285 clientFormat = &rdpsnd->ClientFormats[index];
287 stream_write_UINT16(pdu, clientFormat->wFormatTag);
288 stream_write_UINT16(pdu, clientFormat->nChannels);
289 stream_write_UINT32(pdu, clientFormat->nSamplesPerSec);
290 stream_write_UINT32(pdu, clientFormat->nAvgBytesPerSec);
291 stream_write_UINT16(pdu, clientFormat->nBlockAlign);
292 stream_write_UINT16(pdu, clientFormat->wBitsPerSample);
293 stream_write_UINT16(pdu, clientFormat->cbSize);
295 if (clientFormat->cbSize > 0)
296 stream_write(pdu, clientFormat->data, clientFormat->cbSize);
299 svc_plugin_send((rdpSvcPlugin*) rdpsnd, pdu);
302 void rdpsnd_recv_server_audio_formats_pdu(rdpsndPlugin* rdpsnd, STREAM* s)
306 AUDIO_FORMAT* format;
307 UINT16 wNumberOfFormats;
309 rdpsnd_free_audio_formats(rdpsnd->ServerFormats, rdpsnd->NumberOfServerFormats);
310 rdpsnd->NumberOfServerFormats = 0;
311 rdpsnd->ServerFormats = NULL;
313 stream_seek_UINT32(s); /* dwFlags */
314 stream_seek_UINT32(s); /* dwVolume */
315 stream_seek_UINT32(s); /* dwPitch */
316 stream_seek_UINT16(s); /* wDGramPort */
317 stream_read_UINT16(s, wNumberOfFormats);
318 stream_read_BYTE(s, rdpsnd->cBlockNo); /* cLastBlockConfirmed */
319 stream_read_UINT16(s, wVersion); /* wVersion */
320 stream_seek_BYTE(s); /* bPad */
322 rdpsnd->NumberOfServerFormats = wNumberOfFormats;
323 rdpsnd->ServerFormats = (AUDIO_FORMAT*) malloc(sizeof(AUDIO_FORMAT) * wNumberOfFormats);
325 for (index = 0; index < (int) wNumberOfFormats; index++)
327 format = &rdpsnd->ServerFormats[index];
329 stream_read_UINT16(s, format->wFormatTag); /* wFormatTag */
330 stream_read_UINT16(s, format->nChannels); /* nChannels */
331 stream_read_UINT32(s, format->nSamplesPerSec); /* nSamplesPerSec */
332 stream_read_UINT32(s, format->nAvgBytesPerSec); /* nAvgBytesPerSec */
333 stream_read_UINT16(s, format->nBlockAlign); /* nBlockAlign */
334 stream_read_UINT16(s, format->wBitsPerSample); /* wBitsPerSample */
335 stream_read_UINT16(s, format->cbSize); /* cbSize */
337 format->data = (BYTE*) malloc(format->cbSize);
338 stream_read(s, format->data, format->cbSize);
341 rdpsnd_select_supported_audio_formats(rdpsnd);
343 rdpsnd_send_client_audio_formats(rdpsnd);
346 rdpsnd_send_quality_mode_pdu(rdpsnd);
349 void rdpsnd_send_training_confirm_pdu(rdpsndPlugin* rdpsnd, UINT16 wTimeStamp, UINT16 wPackSize)
354 stream_write_BYTE(pdu, SNDC_TRAINING); /* msgType */
355 stream_write_BYTE(pdu, 0); /* bPad */
356 stream_write_UINT16(pdu, 4); /* BodySize */
357 stream_write_UINT16(pdu, wTimeStamp);
358 stream_write_UINT16(pdu, wPackSize);
360 svc_plugin_send((rdpSvcPlugin*) rdpsnd, pdu);
363 static void rdpsnd_recv_training_pdu(rdpsndPlugin* rdpsnd, STREAM* s)
368 stream_read_UINT16(s, wTimeStamp);
369 stream_read_UINT16(s, wPackSize);
371 rdpsnd_send_training_confirm_pdu(rdpsnd, wTimeStamp, wPackSize);
374 static void rdpsnd_recv_wave_info_pdu(rdpsndPlugin* rdpsnd, STREAM* s, UINT16 BodySize)
377 AUDIO_FORMAT* format;
379 stream_read_UINT16(s, rdpsnd->wTimeStamp);
380 stream_read_UINT16(s, wFormatNo);
381 stream_read_BYTE(s, rdpsnd->cBlockNo);
382 stream_seek(s, 3); /* bPad */
383 stream_read(s, rdpsnd->waveData, 4);
385 rdpsnd->waveDataSize = BodySize - 8;
386 rdpsnd->expectingWave = TRUE;
388 format = &rdpsnd->ClientFormats[wFormatNo];
392 rdpsnd->isOpen = TRUE;
393 rdpsnd->wCurrentFormatNo = wFormatNo;
395 rdpsnd_print_audio_format(format);
399 IFCALL(rdpsnd->device->Open, rdpsnd->device, format, rdpsnd->latency);
402 else if (wFormatNo != rdpsnd->wCurrentFormatNo)
404 rdpsnd->wCurrentFormatNo = wFormatNo;
408 IFCALL(rdpsnd->device->SetFormat, rdpsnd->device, format, rdpsnd->latency);
413 void rdpsnd_send_wave_confirm_pdu(rdpsndPlugin* rdpsnd, UINT16 wTimeStamp, BYTE cConfirmedBlockNo)
418 stream_write_BYTE(pdu, SNDC_WAVECONFIRM);
419 stream_write_BYTE(pdu, 0);
420 stream_write_UINT16(pdu, 4);
421 stream_write_UINT16(pdu, wTimeStamp);
422 stream_write_BYTE(pdu, cConfirmedBlockNo); /* cConfirmedBlockNo */
423 stream_write_BYTE(pdu, 0); /* bPad */
425 svc_plugin_send((rdpSvcPlugin*) rdpsnd, pdu);
428 void rdpsnd_device_send_wave_confirm_pdu(rdpsndDevicePlugin* device, RDPSND_WAVE* wave)
430 MessageQueue_Post(device->rdpsnd->queue, NULL, 0, (void*) wave, NULL);
433 static void rdpsnd_recv_wave_pdu(rdpsndPlugin* rdpsnd, STREAM* s)
438 AUDIO_FORMAT* format;
440 rdpsnd->expectingWave = FALSE;
443 * The Wave PDU is a special case: it is always sent after a Wave Info PDU,
444 * and we do not process its header. Instead, the header is pad that needs
445 * to be filled with the first four bytes of the audio sample data sent as
446 * part of the preceding Wave Info PDU.
449 CopyMemory(stream_get_head(s), rdpsnd->waveData, 4);
451 data = stream_get_head(s);
452 size = stream_get_size(s);
454 wave = (RDPSND_WAVE*) malloc(sizeof(RDPSND_WAVE));
456 wave->wLocalTimeA = GetTickCount();
457 wave->wTimeStampA = rdpsnd->wTimeStamp;
458 wave->wFormatNo = rdpsnd->wCurrentFormatNo;
459 wave->cBlockNo = rdpsnd->cBlockNo;
464 format = &rdpsnd->ClientFormats[rdpsnd->wCurrentFormatNo];
465 wave->wAudioLength = rdpsnd_compute_audio_time_length(format, size);
470 if (rdpsnd->device->WaveDecode)
472 IFCALL(rdpsnd->device->WaveDecode, rdpsnd->device, wave);
475 if (rdpsnd->device->WavePlay)
477 IFCALL(rdpsnd->device->WavePlay, rdpsnd->device, wave);
481 IFCALL(rdpsnd->device->Play, rdpsnd->device, data, size);
484 if (!rdpsnd->device->WavePlay)
486 wave->wTimeStampB = rdpsnd->wTimeStamp + wave->wAudioLength + TIME_DELAY_MS;
487 wave->wLocalTimeB = wave->wLocalTimeA + wave->wAudioLength + TIME_DELAY_MS;
488 rdpsnd->device->WaveConfirm(rdpsnd->device, wave);
492 static void rdpsnd_recv_close_pdu(rdpsndPlugin* rdpsnd)
494 DEBUG_SVC("server closes.");
498 IFCALL(rdpsnd->device->Start, rdpsnd->device);
502 static void rdpsnd_recv_volume_pdu(rdpsndPlugin* rdpsnd, STREAM* s)
506 stream_read_UINT32(s, dwVolume);
507 DEBUG_SVC("dwVolume 0x%X", dwVolume);
511 IFCALL(rdpsnd->device->SetVolume, rdpsnd->device, dwVolume);
515 static void rdpsnd_recv_pdu(rdpSvcPlugin* plugin, STREAM* s)
519 rdpsndPlugin* rdpsnd = (rdpsndPlugin*) plugin;
521 if (rdpsnd->expectingWave)
523 rdpsnd_recv_wave_pdu(rdpsnd, s);
528 stream_read_BYTE(s, msgType); /* msgType */
529 stream_seek_BYTE(s); /* bPad */
530 stream_read_UINT16(s, BodySize);
532 DEBUG_SVC("msgType %d BodySize %d", msgType, BodySize);
537 rdpsnd_recv_server_audio_formats_pdu(rdpsnd, s);
541 rdpsnd_recv_training_pdu(rdpsnd, s);
545 rdpsnd_recv_wave_info_pdu(rdpsnd, s, BodySize);
549 rdpsnd_recv_close_pdu(rdpsnd);
553 rdpsnd_recv_volume_pdu(rdpsnd, s);
557 DEBUG_WARN("unknown msgType %d", msgType);
564 static void rdpsnd_register_device_plugin(rdpsndPlugin* rdpsnd, rdpsndDevicePlugin* device)
568 DEBUG_WARN("existing device, abort.");
572 rdpsnd->device = device;
573 device->rdpsnd = rdpsnd;
575 device->WaveConfirm = rdpsnd_device_send_wave_confirm_pdu;
578 static BOOL rdpsnd_load_device_plugin(rdpsndPlugin* rdpsnd, const char* name, ADDIN_ARGV* args)
580 PFREERDP_RDPSND_DEVICE_ENTRY entry;
581 FREERDP_RDPSND_DEVICE_ENTRY_POINTS entryPoints;
583 entry = (PFREERDP_RDPSND_DEVICE_ENTRY) freerdp_load_channel_addin_entry("rdpsnd", (LPSTR) name, NULL, 0);
588 entryPoints.rdpsnd = rdpsnd;
589 entryPoints.pRegisterRdpsndDevice = rdpsnd_register_device_plugin;
590 entryPoints.args = args;
592 if (entry(&entryPoints) != 0)
594 DEBUG_WARN("%s entry returns error.", name);
601 void rdpsnd_set_subsystem(rdpsndPlugin* rdpsnd, char* subsystem)
603 if (rdpsnd->subsystem)
604 free(rdpsnd->subsystem);
606 rdpsnd->subsystem = _strdup(subsystem);
609 void rdpsnd_set_device_name(rdpsndPlugin* rdpsnd, char* device_name)
611 if (rdpsnd->device_name)
612 free(rdpsnd->device_name);
614 rdpsnd->device_name = _strdup(device_name);
617 COMMAND_LINE_ARGUMENT_A rdpsnd_args[] =
619 { "sys", COMMAND_LINE_VALUE_REQUIRED, "<subsystem>", NULL, NULL, -1, NULL, "subsystem" },
620 { "dev", COMMAND_LINE_VALUE_REQUIRED, "<device>", NULL, NULL, -1, NULL, "device" },
621 { "format", COMMAND_LINE_VALUE_REQUIRED, "<format>", NULL, NULL, -1, NULL, "format" },
622 { "rate", COMMAND_LINE_VALUE_REQUIRED, "<rate>", NULL, NULL, -1, NULL, "rate" },
623 { "channel", COMMAND_LINE_VALUE_REQUIRED, "<channel>", NULL, NULL, -1, NULL, "channel" },
624 { "latency", COMMAND_LINE_VALUE_REQUIRED, "<latency>", NULL, NULL, -1, NULL, "latency" },
625 { NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
628 static void rdpsnd_process_addin_args(rdpsndPlugin* rdpsnd, ADDIN_ARGV* args)
632 COMMAND_LINE_ARGUMENT_A* arg;
634 flags = COMMAND_LINE_SIGIL_NONE | COMMAND_LINE_SEPARATOR_COLON;
636 status = CommandLineParseArgumentsA(args->argc, (const char**) args->argv,
637 rdpsnd_args, flags, rdpsnd, NULL, NULL);
643 if (!(arg->Flags & COMMAND_LINE_VALUE_PRESENT))
646 CommandLineSwitchStart(arg)
648 CommandLineSwitchCase(arg, "sys")
650 rdpsnd_set_subsystem(rdpsnd, arg->Value);
652 CommandLineSwitchCase(arg, "dev")
654 rdpsnd_set_device_name(rdpsnd, arg->Value);
656 CommandLineSwitchCase(arg, "format")
658 rdpsnd->fixedFormat = atoi(arg->Value);
660 CommandLineSwitchCase(arg, "rate")
662 rdpsnd->fixedRate = atoi(arg->Value);
664 CommandLineSwitchCase(arg, "channel")
666 rdpsnd->fixedChannel = atoi(arg->Value);
668 CommandLineSwitchCase(arg, "latency")
670 rdpsnd->latency = atoi(arg->Value);
672 CommandLineSwitchDefault(arg)
677 CommandLineSwitchEnd(arg)
679 while ((arg = CommandLineFindNextArgumentA(arg)) != NULL);
682 static void rdpsnd_process_connect(rdpSvcPlugin* plugin)
685 rdpsndPlugin* rdpsnd = (rdpsndPlugin*) plugin;
687 DEBUG_SVC("connecting");
689 rdpsnd->latency = -1;
690 rdpsnd->queue = MessageQueue_New();
691 rdpsnd->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) rdpsnd_schedule_thread, (void*) plugin, 0, NULL);
693 args = (ADDIN_ARGV*) plugin->channel_entry_points.pExtendedData;
696 rdpsnd_process_addin_args(rdpsnd, args);
698 if (rdpsnd->subsystem)
700 if (strcmp(rdpsnd->subsystem, "fake") == 0)
703 rdpsnd_load_device_plugin(rdpsnd, rdpsnd->subsystem, args);
708 rdpsnd_set_subsystem(rdpsnd, "pulse");
709 rdpsnd_set_device_name(rdpsnd, "");
710 rdpsnd_load_device_plugin(rdpsnd, rdpsnd->subsystem, args);
715 rdpsnd_set_subsystem(rdpsnd, "alsa");
716 rdpsnd_set_device_name(rdpsnd, "default");
717 rdpsnd_load_device_plugin(rdpsnd, rdpsnd->subsystem, args);
722 rdpsnd_set_subsystem(rdpsnd, "macaudio");
723 rdpsnd_set_device_name(rdpsnd, "default");
724 rdpsnd_load_device_plugin(rdpsnd, rdpsnd->subsystem, args);
729 rdpsnd_set_subsystem(rdpsnd, "winmm");
730 rdpsnd_set_device_name(rdpsnd, "");
731 rdpsnd_load_device_plugin(rdpsnd, rdpsnd->subsystem, args);
736 DEBUG_WARN("no sound device.");
741 static void rdpsnd_process_event(rdpSvcPlugin* plugin, RDP_EVENT* event)
743 freerdp_event_free(event);
746 static void rdpsnd_process_terminate(rdpSvcPlugin* plugin)
748 rdpsndPlugin* rdpsnd = (rdpsndPlugin*) plugin;
751 IFCALL(rdpsnd->device->Free, rdpsnd->device);
753 MessageQueue_PostQuit(rdpsnd->queue, 0);
754 WaitForSingleObject(rdpsnd->thread, INFINITE);
756 MessageQueue_Free(rdpsnd->queue);
757 CloseHandle(rdpsnd->thread);
759 if (rdpsnd->subsystem)
760 free(rdpsnd->subsystem);
762 if (rdpsnd->device_name)
763 free(rdpsnd->device_name);
765 rdpsnd_free_audio_formats(rdpsnd->ServerFormats, rdpsnd->NumberOfServerFormats);
766 rdpsnd->NumberOfServerFormats = 0;
767 rdpsnd->ServerFormats = NULL;
769 rdpsnd_free_audio_formats(rdpsnd->ClientFormats, rdpsnd->NumberOfClientFormats);
770 rdpsnd->NumberOfClientFormats = 0;
771 rdpsnd->ClientFormats = NULL;
774 /* rdpsnd is always built-in */
775 #define VirtualChannelEntry rdpsnd_VirtualChannelEntry
777 int VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints)
781 _p = (rdpsndPlugin*) malloc(sizeof(rdpsndPlugin));
782 ZeroMemory(_p, sizeof(rdpsndPlugin));
784 _p->plugin.channel_def.options =
785 CHANNEL_OPTION_INITIALIZED |
786 CHANNEL_OPTION_ENCRYPT_RDP;
788 strcpy(_p->plugin.channel_def.name, "rdpsnd");
790 _p->plugin.connect_callback = rdpsnd_process_connect;
791 _p->plugin.receive_callback = rdpsnd_recv_pdu;
792 _p->plugin.event_callback = rdpsnd_process_event;
793 _p->plugin.terminate_callback = rdpsnd_process_terminate;
799 sigaddset(&mask, SIGIO);
800 pthread_sigmask(SIG_BLOCK, &mask, NULL);
804 svc_plugin_init((rdpSvcPlugin*) _p, pEntryPoints);