Run indent-all.sh script on source
This commit is contained in:
parent
6a14831965
commit
c16b74a974
@ -92,7 +92,8 @@ channel_send(STREAM s, VCHANNEL * channel)
|
||||
s_pop_layer(s, channel_hdr);
|
||||
length = s->end - s->p - 8;
|
||||
|
||||
logger(Protocol, Debug, "channel_send(), channel = %d, length = %d", channel->mcs_id, length);
|
||||
logger(Protocol, Debug, "channel_send(), channel = %d, length = %d", channel->mcs_id,
|
||||
length);
|
||||
|
||||
thislength = MIN(length, CHANNEL_CHUNK_LENGTH);
|
||||
/* Note: In the original clipboard implementation, this number was
|
||||
|
32
constants.h
32
constants.h
@ -128,11 +128,11 @@ enum MCS_PDU_TYPE
|
||||
Ultimatum, see mcs_send_dpu(reason) */
|
||||
enum MCS_DPU_REASON
|
||||
{
|
||||
RN_DOMAIN_DISCONNECTED = 0,
|
||||
RN_PROVIDER_INITIATED,
|
||||
RN_TOKEN_PURGED,
|
||||
RN_USER_REQUESTED,
|
||||
RN_CHANNEL_PURGED,
|
||||
RN_DOMAIN_DISCONNECTED = 0,
|
||||
RN_PROVIDER_INITIATED,
|
||||
RN_TOKEN_PURGED,
|
||||
RN_USER_REQUESTED,
|
||||
RN_CHANNEL_PURGED,
|
||||
};
|
||||
|
||||
/* RDP secure transport constants */
|
||||
@ -215,17 +215,17 @@ enum RDP_PDU_TYPE
|
||||
|
||||
enum RDP_DATA_PDU_TYPE
|
||||
{
|
||||
RDP_DATA_PDU_UPDATE = 0x02, /* PDUTYPE2_UPDATE */
|
||||
RDP_DATA_PDU_CONTROL = 0x14, /* PDUTYPE2_CONTROL */
|
||||
RDP_DATA_PDU_POINTER = 0x1b, /* PDUTYPE2_POINTER */
|
||||
RDP_DATA_PDU_INPUT = 0x1c, /* PDUTYPE2_INPUT */
|
||||
RDP_DATA_PDU_SYNCHRONISE = 0x1f, /* PDUTYPE2_SYNCHRONIZE */
|
||||
RDP_DATA_PDU_BELL = 0x22, /* PDUTYPE2_PLAY_SOUND */
|
||||
RDP_DATA_PDU_UPDATE = 0x02, /* PDUTYPE2_UPDATE */
|
||||
RDP_DATA_PDU_CONTROL = 0x14, /* PDUTYPE2_CONTROL */
|
||||
RDP_DATA_PDU_POINTER = 0x1b, /* PDUTYPE2_POINTER */
|
||||
RDP_DATA_PDU_INPUT = 0x1c, /* PDUTYPE2_INPUT */
|
||||
RDP_DATA_PDU_SYNCHRONISE = 0x1f, /* PDUTYPE2_SYNCHRONIZE */
|
||||
RDP_DATA_PDU_BELL = 0x22, /* PDUTYPE2_PLAY_SOUND */
|
||||
RDP_DATA_PDU_CLIENT_WINDOW_STATUS = 0x23, /* PDUTYPE2_SUPRESS_OUTPUT */
|
||||
RDP_DATA_PDU_LOGON = 0x26, /* PDUTYPE2_SAVE_SESSION_INFO */
|
||||
RDP_DATA_PDU_FONT2 = 0x27, /* PDUTYPE2_FONTLIST */
|
||||
RDP_DATA_PDU_KEYBOARD_INDICATORS = 0x29, /* PDUTYPE2_SET_KEYBOARD_INDICATORS */
|
||||
RDP_DATA_PDU_SET_ERROR_INFO = 0x2f, /* PDUTYPE2_SET_ERROR_INFO */
|
||||
RDP_DATA_PDU_LOGON = 0x26, /* PDUTYPE2_SAVE_SESSION_INFO */
|
||||
RDP_DATA_PDU_FONT2 = 0x27, /* PDUTYPE2_FONTLIST */
|
||||
RDP_DATA_PDU_KEYBOARD_INDICATORS = 0x29, /* PDUTYPE2_SET_KEYBOARD_INDICATORS */
|
||||
RDP_DATA_PDU_SET_ERROR_INFO = 0x2f, /* PDUTYPE2_SET_ERROR_INFO */
|
||||
RDP_DATA_PDU_AUTORECONNECT_STATUS = 0x32, /* PDUTYPE2_ARC_STATUS_PDU */
|
||||
};
|
||||
|
||||
@ -271,7 +271,7 @@ enum RDP_POINTER_PDU_TYPE
|
||||
/* [MS-RDPBCGR] 2.2.9.1.1.4.3 */
|
||||
enum RDP_SYSTEM_POINTER_TYPE
|
||||
{
|
||||
SYSPTR_NULL = 0x00000000,
|
||||
SYSPTR_NULL = 0x00000000,
|
||||
SYSPTR_DEFAULT = 0x00007F00
|
||||
};
|
||||
|
||||
|
16
disk.c
16
disk.c
@ -714,8 +714,8 @@ disk_query_information(RD_NTHANDLE handle, uint32 info_class, STREAM out)
|
||||
|
||||
case FileStandardInformation:
|
||||
|
||||
out_uint64_le(out, filestat.st_size); /* Allocation size */
|
||||
out_uint64_le(out, filestat.st_size); /* End of file */
|
||||
out_uint64_le(out, filestat.st_size); /* Allocation size */
|
||||
out_uint64_le(out, filestat.st_size); /* End of file */
|
||||
|
||||
out_uint32_le(out, filestat.st_nlink); /* Number of links */
|
||||
out_uint8(out, 0); /* Delete pending */
|
||||
@ -1162,7 +1162,7 @@ disk_query_volume_information(RD_NTHANDLE handle, uint32 info_class, STREAM out)
|
||||
out_uint32_le(out, fsinfo->serial); /* serial */
|
||||
out_uint32_le(out, s_length(&stmp)); /* length of string */
|
||||
out_uint8(out, 0); /* support objects? */
|
||||
out_stream(out, &stmp); /* fsinfo->label string*/
|
||||
out_stream(out, &stmp); /* fsinfo->label string */
|
||||
break;
|
||||
|
||||
case FileFsSizeInformation:
|
||||
@ -1191,7 +1191,7 @@ disk_query_volume_information(RD_NTHANDLE handle, uint32 info_class, STREAM out)
|
||||
out_uint32_le(out, F_NAMELEN(stat_fs)); /* max length of filename */
|
||||
|
||||
out_uint32_le(out, s_length(&stmp)); /* length of fsinfo->type string */
|
||||
out_stream(out, &stmp); /* fsinfo->typ string */
|
||||
out_stream(out, &stmp); /* fsinfo->typ string */
|
||||
break;
|
||||
|
||||
case FileFsLabelInformation:
|
||||
@ -1331,7 +1331,7 @@ disk_query_directory(RD_NTHANDLE handle, uint32 info_class, char *pattern, STREA
|
||||
out_uint32_le(out, 0); /* EaSize */
|
||||
out_uint8(out, 0); /* ShortNameLength */
|
||||
out_uint8s(out, 24); /* ShortName (8.3 name) */
|
||||
out_stream(out, &stmp); /* dir entry name string */
|
||||
out_stream(out, &stmp); /* dir entry name string */
|
||||
break;
|
||||
|
||||
|
||||
@ -1358,7 +1358,7 @@ disk_query_directory(RD_NTHANDLE handle, uint32 info_class, char *pattern, STREA
|
||||
out_uint64_le(out, filestat.st_size); /* filesize */
|
||||
out_uint32_le(out, file_attributes);
|
||||
out_uint32_le(out, s_length(&stmp)); /* dir entry name string length */
|
||||
out_stream(out, &stmp); /* dir entry name */
|
||||
out_stream(out, &stmp); /* dir entry name */
|
||||
break;
|
||||
|
||||
|
||||
@ -1386,14 +1386,14 @@ disk_query_directory(RD_NTHANDLE handle, uint32 info_class, char *pattern, STREA
|
||||
out_uint32_le(out, file_attributes);
|
||||
out_uint32_le(out, s_length(&stmp)); /* dir entry name string length */
|
||||
out_uint32_le(out, 0); /* EaSize */
|
||||
out_stream(out, &stmp); /* dir entry name */
|
||||
out_stream(out, &stmp); /* dir entry name */
|
||||
break;
|
||||
|
||||
|
||||
case FileNamesInformation:
|
||||
|
||||
out_uint32_le(out, s_length(&stmp)); /* dir entry name string length */
|
||||
out_stream(out, &stmp); /* dir entry name */
|
||||
out_stream(out, &stmp); /* dir entry name */
|
||||
break;
|
||||
|
||||
|
||||
|
21
dvc.c
21
dvc.c
@ -33,13 +33,15 @@
|
||||
#define DYNVC_SOFT_SYNC_REQUEST 0x08
|
||||
#define DYNVC_SOFT_SYNC_RESPONSE 0x09
|
||||
|
||||
typedef union dvc_hdr_t {
|
||||
uint8 data;
|
||||
struct {
|
||||
uint8 cbid:2;
|
||||
uint8 sp:2;
|
||||
uint8 cmd:4;
|
||||
} hdr;
|
||||
typedef union dvc_hdr_t
|
||||
{
|
||||
uint8 data;
|
||||
struct
|
||||
{
|
||||
uint8 cbid:2;
|
||||
uint8 sp:2;
|
||||
uint8 cmd:4;
|
||||
} hdr;
|
||||
} dvc_hdr_t;
|
||||
|
||||
typedef struct dvc_channel_t
|
||||
@ -147,7 +149,8 @@ dvc_channels_add(const char *name, dvc_channel_process_fn handler, uint32 channe
|
||||
}
|
||||
}
|
||||
|
||||
logger(Core, Warning, "dvc_channels_add(), Failed to add channel, maximum number of channels are being used");
|
||||
logger(Core, Warning,
|
||||
"dvc_channels_add(), Failed to add channel, maximum number of channels are being used");
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -429,7 +432,7 @@ dvc_process_pdu(STREAM s)
|
||||
dvc_process_close_pdu(s, hdr);
|
||||
break;
|
||||
|
||||
#if 0 /* Unimplemented */
|
||||
#if 0 /* Unimplemented */
|
||||
|
||||
case DYNVC_DATA_FIRST:
|
||||
break;
|
||||
|
14
iso.c
14
iso.c
@ -99,7 +99,7 @@ iso_send_connection_request(char *username, uint32 neg_proto)
|
||||
|
||||
/* Receive a message on the ISO layer, return code */
|
||||
static STREAM
|
||||
iso_recv_msg(uint8 * code, RD_BOOL *is_fastpath, uint8 *fastpath_hdr)
|
||||
iso_recv_msg(uint8 * code, RD_BOOL * is_fastpath, uint8 * fastpath_hdr)
|
||||
{
|
||||
STREAM s;
|
||||
uint16 length;
|
||||
@ -109,14 +109,14 @@ iso_recv_msg(uint8 * code, RD_BOOL *is_fastpath, uint8 *fastpath_hdr)
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
in_uint8(s, version); /* T.123 version or Fastpath output header */
|
||||
in_uint8(s, version); /* T.123 version or Fastpath output header */
|
||||
|
||||
/* detect if this is a slow or fast path PDU */
|
||||
*fastpath_hdr = 0x00;
|
||||
*is_fastpath = False;
|
||||
if (version == T123_HEADER_VERSION)
|
||||
{
|
||||
in_uint8s(s, 1); /* reserved */
|
||||
in_uint8s(s, 1); /* reserved */
|
||||
in_uint16_be(s, length); /* length */
|
||||
}
|
||||
else
|
||||
@ -125,7 +125,7 @@ iso_recv_msg(uint8 * code, RD_BOOL *is_fastpath, uint8 *fastpath_hdr)
|
||||
stream is a fast path pdu */
|
||||
*is_fastpath = True;
|
||||
*fastpath_hdr = version;
|
||||
in_uint8(s, length); /* length1 */
|
||||
in_uint8(s, length); /* length1 */
|
||||
if (length & 0x80)
|
||||
{
|
||||
/* length2 is only present if the most significant bit of length1 is set */
|
||||
@ -192,7 +192,7 @@ iso_send(STREAM s)
|
||||
|
||||
/* Receive ISO transport data packet */
|
||||
STREAM
|
||||
iso_recv(RD_BOOL *is_fastpath, uint8 *fastpath_hdr)
|
||||
iso_recv(RD_BOOL * is_fastpath, uint8 * fastpath_hdr)
|
||||
{
|
||||
STREAM s;
|
||||
uint8 code = 0;
|
||||
@ -285,8 +285,8 @@ iso_connect(char *server, char *username, char *domain, char *password,
|
||||
uint32 data = 0;
|
||||
|
||||
in_uint8(s, type);
|
||||
in_uint8s(s, 1); /* skip flags */
|
||||
in_uint8s(s, 2); /* skip length */
|
||||
in_uint8s(s, 1); /* skip flags */
|
||||
in_uint8s(s, 2); /* skip length */
|
||||
in_uint32(s, data);
|
||||
|
||||
if (type == RDP_NEG_FAILURE)
|
||||
|
@ -313,7 +313,7 @@ licence_process_error_alert(STREAM s)
|
||||
|
||||
in_uint32(s, error_code);
|
||||
in_uint32(s, state_transition);
|
||||
in_uint8s(s, 4); /* Skip error_info */
|
||||
in_uint8s(s, 4); /* Skip error_info */
|
||||
|
||||
/* There is a special case in the error alert handling, when licensing is all good
|
||||
and the server is not sending a license to client, a "Server License Error PDU -
|
||||
|
2
mcs.c
2
mcs.c
@ -316,7 +316,7 @@ mcs_send(STREAM s)
|
||||
|
||||
/* Receive an MCS transport data packet */
|
||||
STREAM
|
||||
mcs_recv(uint16 * channel, RD_BOOL *is_fastpath, uint8 *fastpath_hdr)
|
||||
mcs_recv(uint16 * channel, RD_BOOL * is_fastpath, uint8 * fastpath_hdr)
|
||||
{
|
||||
uint8 opcode, appid, length;
|
||||
STREAM s;
|
||||
|
14
proto.h
14
proto.h
@ -82,7 +82,7 @@ void ewmh_init(void);
|
||||
/* iso.c */
|
||||
STREAM iso_init(int length);
|
||||
void iso_send(STREAM s);
|
||||
STREAM iso_recv(RD_BOOL *is_fastpath, uint8 *fastpath_hdr);
|
||||
STREAM iso_recv(RD_BOOL * is_fastpath, uint8 * fastpath_hdr);
|
||||
RD_BOOL iso_connect(char *server, char *username, char *domain, char *password, RD_BOOL reconnect,
|
||||
uint32 * selected_protocol);
|
||||
void iso_disconnect(void);
|
||||
@ -95,7 +95,7 @@ void licence_process(STREAM s);
|
||||
STREAM mcs_init(int length);
|
||||
void mcs_send_to_channel(STREAM s, uint16 channel);
|
||||
void mcs_send(STREAM s);
|
||||
STREAM mcs_recv(uint16 * channel, RD_BOOL *is_fastpath, uint8 *fastpath_hdr);
|
||||
STREAM mcs_recv(uint16 * channel, RD_BOOL * is_fastpath, uint8 * fastpath_hdr);
|
||||
RD_BOOL mcs_connect_start(char *server, char *username, char *domain, char *password,
|
||||
RD_BOOL reconnect, uint32 * selected_protocol);
|
||||
RD_BOOL mcs_connect_finalize(STREAM s);
|
||||
@ -257,9 +257,9 @@ void rdp_send_scancode(uint32 time, uint16 flags, uint8 scancode);
|
||||
/* xwin.c */
|
||||
RD_BOOL get_key_state(unsigned int state, uint32 keysym);
|
||||
RD_BOOL ui_init(void);
|
||||
void ui_get_screen_size(uint32 *width, uint32 *height);
|
||||
void ui_get_screen_size_from_percentage(uint32 pw, uint32 ph, uint32 *width, uint32 *height);
|
||||
void ui_get_workarea_size(uint32 *width, uint32 *height);
|
||||
void ui_get_screen_size(uint32 * width, uint32 * height);
|
||||
void ui_get_screen_size_from_percentage(uint32 pw, uint32 ph, uint32 * width, uint32 * height);
|
||||
void ui_get_workarea_size(uint32 * width, uint32 * height);
|
||||
void ui_deinit(void);
|
||||
RD_BOOL ui_create_window(uint32 width, uint32 height);
|
||||
void ui_resize_window(uint32 width, uint32 height);
|
||||
@ -274,8 +274,8 @@ void ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8
|
||||
void ui_destroy_bitmap(RD_HBITMAP bmp);
|
||||
RD_HGLYPH ui_create_glyph(int width, int height, uint8 * data);
|
||||
void ui_destroy_glyph(RD_HGLYPH glyph);
|
||||
RD_HCURSOR ui_create_cursor(unsigned int x, unsigned int y, uint32 width, uint32 height, uint8 * andmask,
|
||||
uint8 * xormask, int bpp);
|
||||
RD_HCURSOR ui_create_cursor(unsigned int x, unsigned int y, uint32 width, uint32 height,
|
||||
uint8 * andmask, uint8 * xormask, int bpp);
|
||||
void ui_set_cursor(RD_HCURSOR cursor);
|
||||
void ui_destroy_cursor(RD_HCURSOR cursor);
|
||||
void ui_set_null_cursor(void);
|
||||
|
63
rdesktop.c
63
rdesktop.c
@ -118,8 +118,7 @@ RD_BOOL g_seamless_persistent_mode = True;
|
||||
RD_BOOL g_user_quit = False;
|
||||
uint32 g_embed_wnd;
|
||||
uint32 g_rdp5_performanceflags = (PERF_DISABLE_FULLWINDOWDRAG |
|
||||
PERF_DISABLE_MENUANIMATIONS |
|
||||
PERF_ENABLE_FONT_SMOOTHING);
|
||||
PERF_DISABLE_MENUANIMATIONS | PERF_ENABLE_FONT_SMOOTHING);
|
||||
/* Session Directory redirection */
|
||||
RD_BOOL g_redirect = False;
|
||||
char *g_redirect_server;
|
||||
@ -143,7 +142,7 @@ RD_BOOL g_reconnect_loop = False;
|
||||
uint8 g_client_random[SEC_RANDOM_SIZE];
|
||||
RD_BOOL g_pending_resize = False;
|
||||
RD_BOOL g_pending_resize_defer = True;
|
||||
struct timeval g_pending_resize_defer_timer = {0};
|
||||
struct timeval g_pending_resize_defer_timer = { 0 };
|
||||
|
||||
#ifdef WITH_RDPSND
|
||||
RD_BOOL g_rdpsnd = False;
|
||||
@ -479,9 +478,12 @@ handle_disconnect_reason(RD_BOOL deactivated, uint16 reason)
|
||||
retval = EXRD_UNKNOWN;
|
||||
}
|
||||
|
||||
if (reason > 0x1000 && reason < 0x7fff && retval == EXRD_UNKNOWN) {
|
||||
if (reason > 0x1000 && reason < 0x7fff && retval == EXRD_UNKNOWN)
|
||||
{
|
||||
fprintf(stderr, "Internal protocol error: %x", reason);
|
||||
} else if (reason != ERRINFO_NO_INFO) {
|
||||
}
|
||||
else if (reason != ERRINFO_NO_INFO)
|
||||
{
|
||||
fprintf(stderr, "disconnect: %s.\n", text);
|
||||
}
|
||||
|
||||
@ -598,7 +600,8 @@ parse_server_and_port(char *server)
|
||||
}
|
||||
|
||||
// [WxH|P%|W%xH%][@DPI][+X[+Y]]|workarea
|
||||
int parse_geometry_string(const char *optarg)
|
||||
int
|
||||
parse_geometry_string(const char *optarg)
|
||||
{
|
||||
sint32 value;
|
||||
const char *ps;
|
||||
@ -643,7 +646,8 @@ int parse_geometry_string(const char *optarg)
|
||||
value = strtol(ps, &pe, 10);
|
||||
if (ps == pe || value <= 0)
|
||||
{
|
||||
logger(Core, Error, "invalid geometry, expected positive integer for height");
|
||||
logger(Core, Error,
|
||||
"invalid geometry, expected positive integer for height");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -668,7 +672,7 @@ int parse_geometry_string(const char *optarg)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
if (g_window_size_type == PercentageOfScreen)
|
||||
{
|
||||
/* percentage of screen used for both width and height */
|
||||
@ -738,25 +742,26 @@ int parse_geometry_string(const char *optarg)
|
||||
static void
|
||||
setup_user_requested_session_size()
|
||||
{
|
||||
switch(g_window_size_type)
|
||||
switch (g_window_size_type)
|
||||
{
|
||||
case Fullscreen:
|
||||
ui_get_screen_size(&g_requested_session_width, &g_requested_session_height);
|
||||
break;
|
||||
case Fullscreen:
|
||||
ui_get_screen_size(&g_requested_session_width, &g_requested_session_height);
|
||||
break;
|
||||
|
||||
case Workarea:
|
||||
ui_get_workarea_size(&g_requested_session_width, &g_requested_session_height);
|
||||
break;
|
||||
case Workarea:
|
||||
ui_get_workarea_size(&g_requested_session_width,
|
||||
&g_requested_session_height);
|
||||
break;
|
||||
|
||||
case Fixed:
|
||||
break;
|
||||
case Fixed:
|
||||
break;
|
||||
|
||||
case PercentageOfScreen:
|
||||
ui_get_screen_size_from_percentage(g_requested_session_width,
|
||||
g_requested_session_height,
|
||||
&g_requested_session_width,
|
||||
&g_requested_session_height);
|
||||
break;
|
||||
case PercentageOfScreen:
|
||||
ui_get_screen_size_from_percentage(g_requested_session_width,
|
||||
g_requested_session_height,
|
||||
&g_requested_session_width,
|
||||
&g_requested_session_height);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1169,7 +1174,7 @@ main(int argc, char *argv[])
|
||||
if (g_local_cursor)
|
||||
{
|
||||
/* there is no point wasting bandwidth on cursor shadows
|
||||
* that we're just going to throw out anyway */
|
||||
* that we're just going to throw out anyway */
|
||||
g_rdp5_performanceflags |= PERF_DISABLE_CURSOR_SHADOW;
|
||||
}
|
||||
|
||||
@ -1359,7 +1364,8 @@ main(int argc, char *argv[])
|
||||
g_network_error = False;
|
||||
}
|
||||
|
||||
utils_apply_session_size_limitations(&g_requested_session_width, &g_requested_session_height);
|
||||
utils_apply_session_size_limitations(&g_requested_session_width,
|
||||
&g_requested_session_height);
|
||||
|
||||
if (!rdp_connect
|
||||
(server, flags, domain, g_password, shell, directory, g_reconnect_loop))
|
||||
@ -1413,7 +1419,7 @@ main(int argc, char *argv[])
|
||||
user initiated disconnected. Lets translate this specific
|
||||
behaviour into the same as for later versions for proper
|
||||
handling.
|
||||
*/
|
||||
*/
|
||||
if (deactivated == True && ext_disc_reason == ERRINFO_NO_INFO)
|
||||
{
|
||||
deactivated = 0;
|
||||
@ -1445,7 +1451,7 @@ main(int argc, char *argv[])
|
||||
/* If there is no auto reconnect cookie available
|
||||
for reconnect, do not enter reconnect loop. Windows
|
||||
2016 server does not send any for unknown reasons.
|
||||
*/
|
||||
*/
|
||||
logger(Core, Notice,
|
||||
"Disconnected due to network error, exiting...");
|
||||
break;
|
||||
@ -1461,7 +1467,8 @@ main(int argc, char *argv[])
|
||||
else if (g_pending_resize)
|
||||
{
|
||||
/* Enter a reconnect loop if we have a pending resize request */
|
||||
logger(Core, Verbose, "Resize reconnect loop triggered, new size %dx%d",
|
||||
logger(Core, Verbose,
|
||||
"Resize reconnect loop triggered, new size %dx%d",
|
||||
g_requested_session_width, g_requested_session_height);
|
||||
g_pending_resize = False;
|
||||
g_reconnect_loop = True;
|
||||
|
139
rdp.c
139
rdp.c
@ -98,7 +98,7 @@ static void rdp_out_unistr(STREAM s, char *string, int len);
|
||||
/* reads a TS_SHARECONTROLHEADER from stream, returns True of there is
|
||||
a PDU available otherwise False */
|
||||
static RD_BOOL
|
||||
rdp_ts_in_share_control_header(STREAM s, uint8 *type, uint16 *length)
|
||||
rdp_ts_in_share_control_header(STREAM s, uint8 * type, uint16 * length)
|
||||
{
|
||||
uint16 pdu_type;
|
||||
uint16 pdu_source;
|
||||
@ -112,7 +112,7 @@ rdp_ts_in_share_control_header(STREAM s, uint8 *type, uint16 *length)
|
||||
as a T.128 FlowPDU as described in [T128] section 8.5 (the
|
||||
ASN.1 structure definition is detailed in [T128] section
|
||||
9.1) and MUST be ignored.
|
||||
*/
|
||||
*/
|
||||
if (*length == 0x8000)
|
||||
{
|
||||
/* skip over this message in stream */
|
||||
@ -121,7 +121,7 @@ rdp_ts_in_share_control_header(STREAM s, uint8 *type, uint16 *length)
|
||||
}
|
||||
|
||||
in_uint16_le(s, pdu_type); /* pduType */
|
||||
in_uint16(s, pdu_source); /* pduSource */
|
||||
in_uint16(s, pdu_source); /* pduSource */
|
||||
|
||||
*type = pdu_type & 0xf;
|
||||
|
||||
@ -496,7 +496,8 @@ rdp_send_client_info_pdu(uint32 flags, char *domain, char *user,
|
||||
/* Client Auto-Reconnect */
|
||||
if (g_has_reconnect_random)
|
||||
{
|
||||
logger(Protocol, Debug, "rdp_send_logon_info(), Sending auto-reconnect cookie.");
|
||||
logger(Protocol, Debug,
|
||||
"rdp_send_logon_info(), Sending auto-reconnect cookie.");
|
||||
out_uint16_le(s, 28); /* cbAutoReconnectLen */
|
||||
/* ARC_CS_PRIVATE_PACKET */
|
||||
out_uint32_le(s, 28); /* cbLen */
|
||||
@ -598,7 +599,7 @@ rdp_send_suppress_output_pdu(enum RDP_SUPPRESS_STATUS allowupdates)
|
||||
case SUPPRESS_DISPLAY_UPDATES: /* shut the server up */
|
||||
break;
|
||||
|
||||
case ALLOW_DISPLAY_UPDATES: /* receive data again */
|
||||
case ALLOW_DISPLAY_UPDATES: /* receive data again */
|
||||
out_uint16_le(s, 0); /* left */
|
||||
out_uint16_le(s, 0); /* top */
|
||||
out_uint16_le(s, g_session_width); /* right */
|
||||
@ -691,17 +692,17 @@ rdp_out_ts_general_capabilityset(STREAM s)
|
||||
|
||||
out_uint16_le(s, RDP_CAPSET_GENERAL);
|
||||
out_uint16_le(s, RDP_CAPLEN_GENERAL);
|
||||
out_uint16_le(s, OSMAJORTYPE_WINDOWS); /* osMajorType */
|
||||
out_uint16_le(s, OSMAJORTYPE_WINDOWS); /* osMajorType */
|
||||
out_uint16_le(s, OSMINORTYPE_WINDOWSNT); /* osMinorType */
|
||||
out_uint16_le(s, TS_CAPS_PROTOCOLVERSION); /* protocolVersion (must be TS_CAPS_PROTOCOLVERSION) */
|
||||
out_uint16_le(s, 0); /* pad2OctetsA */
|
||||
out_uint16_le(s, 0); /* generalCompressionTypes (must be 0) */
|
||||
out_uint16_le(s, extraFlags); /* extraFlags */
|
||||
out_uint16_le(s, 0); /* updateCapabilityFlag (must be 0) */
|
||||
out_uint16_le(s, 0); /* remoteUnshareFlag (must be 0) */
|
||||
out_uint16_le(s, 0); /* generalCompressionLevel (must be 0) */
|
||||
out_uint8(s, 0); /* refreshRectSupport */
|
||||
out_uint8(s, 0); /* suppressOutputSupport */
|
||||
out_uint16_le(s, 0); /* pad2OctetsA */
|
||||
out_uint16_le(s, 0); /* generalCompressionTypes (must be 0) */
|
||||
out_uint16_le(s, extraFlags); /* extraFlags */
|
||||
out_uint16_le(s, 0); /* updateCapabilityFlag (must be 0) */
|
||||
out_uint16_le(s, 0); /* remoteUnshareFlag (must be 0) */
|
||||
out_uint16_le(s, 0); /* generalCompressionLevel (must be 0) */
|
||||
out_uint8(s, 0); /* refreshRectSupport */
|
||||
out_uint8(s, 0); /* suppressOutputSupport */
|
||||
}
|
||||
|
||||
/* Output bitmap capability set */
|
||||
@ -713,18 +714,18 @@ rdp_out_ts_bitmap_capabilityset(STREAM s)
|
||||
out_uint16_le(s, RDP_CAPSET_BITMAP);
|
||||
out_uint16_le(s, RDP_CAPLEN_BITMAP);
|
||||
out_uint16_le(s, g_server_depth); /* preferredBitsPerPixel */
|
||||
out_uint16_le(s, 1); /* receive1BitPerPixel (ignored, should be 1) */
|
||||
out_uint16_le(s, 1); /* receive4BitPerPixel (ignored, should be 1) */
|
||||
out_uint16_le(s, 1); /* receive8BitPerPixel (ignored, should be 1) */
|
||||
out_uint16_le(s, 1); /* receive1BitPerPixel (ignored, should be 1) */
|
||||
out_uint16_le(s, 1); /* receive4BitPerPixel (ignored, should be 1) */
|
||||
out_uint16_le(s, 1); /* receive8BitPerPixel (ignored, should be 1) */
|
||||
out_uint16_le(s, g_session_width); /* desktopWidth */
|
||||
out_uint16_le(s, g_session_height); /* desktopHeight */
|
||||
out_uint16_le(s, 0); /* pad2Octets */
|
||||
out_uint16_le(s, 1); /* desktopResizeFlag */
|
||||
out_uint16_le(s, 1); /* bitmapCompressionFlag (must be 1) */
|
||||
out_uint8(s, 0); /* highColorFlags (ignored, should be 0) */
|
||||
out_uint8(s, 0); /* drawingFlags */
|
||||
out_uint16_le(s, 1); /* multipleRectangleSupport (must be 1) */
|
||||
out_uint16_le(s, 0); /* pad2OctetsB */
|
||||
out_uint16_le(s, 0); /* pad2Octets */
|
||||
out_uint16_le(s, 1); /* desktopResizeFlag */
|
||||
out_uint16_le(s, 1); /* bitmapCompressionFlag (must be 1) */
|
||||
out_uint8(s, 0); /* highColorFlags (ignored, should be 0) */
|
||||
out_uint8(s, 0); /* drawingFlags */
|
||||
out_uint16_le(s, 1); /* multipleRectangleSupport (must be 1) */
|
||||
out_uint16_le(s, 0); /* pad2OctetsB */
|
||||
}
|
||||
|
||||
/* Output order capability set */
|
||||
@ -735,7 +736,7 @@ rdp_out_ts_order_capabilityset(STREAM s)
|
||||
uint16 orderflags = 0;
|
||||
uint32 cachesize = 0;
|
||||
|
||||
orderflags |= (NEGOTIATEORDERSUPPORT | ZEROBOUNDSDELTASSUPPORT); /* mandatory flags */
|
||||
orderflags |= (NEGOTIATEORDERSUPPORT | ZEROBOUNDSDELTASSUPPORT); /* mandatory flags */
|
||||
orderflags |= COLORINDEXSUPPORT;
|
||||
|
||||
memset(order_caps, 0, 32);
|
||||
@ -767,23 +768,23 @@ rdp_out_ts_order_capabilityset(STREAM s)
|
||||
|
||||
out_uint16_le(s, RDP_CAPSET_ORDER);
|
||||
out_uint16_le(s, RDP_CAPLEN_ORDER);
|
||||
out_uint8s(s, 16); /* terminalDescriptor (ignored, should be 0) */
|
||||
out_uint8s(s, 4); /* pad4OctetsA */
|
||||
out_uint16_le(s, 1); /* desktopSaveXGranularity (ignored, assumed to be 1) */
|
||||
out_uint16_le(s, 20); /* desktopSaveYGranularity (ignored, assumed to be 20) */
|
||||
out_uint16_le(s, 0); /* Pad */
|
||||
out_uint16_le(s, 1); /* maximumOrderLevel (ignored, should be 1) */
|
||||
out_uint16_le(s, 0); /* numberFonts (ignored, should be 0) */
|
||||
out_uint8s(s, 16); /* terminalDescriptor (ignored, should be 0) */
|
||||
out_uint8s(s, 4); /* pad4OctetsA */
|
||||
out_uint16_le(s, 1); /* desktopSaveXGranularity (ignored, assumed to be 1) */
|
||||
out_uint16_le(s, 20); /* desktopSaveYGranularity (ignored, assumed to be 20) */
|
||||
out_uint16_le(s, 0); /* Pad */
|
||||
out_uint16_le(s, 1); /* maximumOrderLevel (ignored, should be 1) */
|
||||
out_uint16_le(s, 0); /* numberFonts (ignored, should be 0) */
|
||||
out_uint16_le(s, orderflags); /* orderFlags */
|
||||
out_uint8p(s, order_caps, 32); /* orderSupport */
|
||||
out_uint16_le(s, 0); /* textFlags (ignored) */
|
||||
out_uint16_le(s, 0); /* orderSupportExFlags */
|
||||
out_uint32_le(s, 0); /* pad4OctetsB */
|
||||
out_uint16_le(s, 0); /* textFlags (ignored) */
|
||||
out_uint16_le(s, 0); /* orderSupportExFlags */
|
||||
out_uint32_le(s, 0); /* pad4OctetsB */
|
||||
out_uint32_le(s, cachesize); /* desktopSaveSize */
|
||||
out_uint16_le(s, 0); /* pad2OctetsC */
|
||||
out_uint16_le(s, 0); /* pad2OctetsD */
|
||||
out_uint16_le(s, 1252); /* textANSICodePage */
|
||||
out_uint16_le(s, 0); /* pad2OctetsE */
|
||||
out_uint16_le(s, 0); /* pad2OctetsC */
|
||||
out_uint16_le(s, 0); /* pad2OctetsD */
|
||||
out_uint16_le(s, 1252); /* textANSICodePage */
|
||||
out_uint16_le(s, 0); /* pad2OctetsE */
|
||||
}
|
||||
|
||||
/* Output bitmap cache capability set */
|
||||
@ -922,12 +923,12 @@ rdp_out_ts_input_capabilityset(STREAM s)
|
||||
out_uint16_le(s, RDP_CAPSET_INPUT);
|
||||
out_uint16_le(s, RDP_CAPLEN_INPUT);
|
||||
|
||||
out_uint16_le(s, inputflags); /* inputFlags */
|
||||
out_uint16_le(s, 0); /* pad2OctetsA */
|
||||
out_uint32_le(s, 0x409); /* keyboardLayout */
|
||||
out_uint32_le(s, 0x4); /* keyboardType */
|
||||
out_uint32_le(s, 0); /* keyboardSubtype */
|
||||
out_uint32_le(s, 0xC); /* keyboardFunctionKey */
|
||||
out_uint16_le(s, inputflags); /* inputFlags */
|
||||
out_uint16_le(s, 0); /* pad2OctetsA */
|
||||
out_uint32_le(s, 0x409); /* keyboardLayout */
|
||||
out_uint32_le(s, 0x4); /* keyboardType */
|
||||
out_uint32_le(s, 0); /* keyboardSubtype */
|
||||
out_uint32_le(s, 0xC); /* keyboardFunctionKey */
|
||||
out_utf16s_padded(s, "", 64, 0); /* imeFileName */
|
||||
}
|
||||
|
||||
@ -941,7 +942,7 @@ rdp_out_ts_sound_capabilityset(STREAM s)
|
||||
out_uint16_le(s, RDP_CAPLEN_SOUND);
|
||||
|
||||
out_uint16_le(s, soundflags); /* soundFlags */
|
||||
out_uint16_le(s, 0); /* pad2OctetsA */
|
||||
out_uint16_le(s, 0); /* pad2OctetsA */
|
||||
}
|
||||
|
||||
/* Output Font Capability Set */
|
||||
@ -954,7 +955,7 @@ rdp_out_ts_font_capabilityset(STREAM s)
|
||||
out_uint16_le(s, RDP_CAPLEN_FONT);
|
||||
|
||||
out_uint16_le(s, flags); /* fontSupportFlags */
|
||||
out_uint16_le(s, 0); /* pad2octets */
|
||||
out_uint16_le(s, 0); /* pad2octets */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -987,7 +988,7 @@ rdp_out_ts_glyphcache_capabilityset(STREAM s)
|
||||
|
||||
out_uint32_le(s, fragcache); /* FragCache */
|
||||
out_uint16_le(s, supportlvl); /* GlyphSupportLevel */
|
||||
out_uint16_le(s, 0); /* pad2octets */
|
||||
out_uint16_le(s, 0); /* pad2octets */
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1029,8 +1030,7 @@ rdp_send_confirm_active(void)
|
||||
RDP_CAPLEN_SOUND +
|
||||
RDP_CAPLEN_GLYPHCACHE +
|
||||
RDP_CAPLEN_MULTIFRAGMENTUPDATE +
|
||||
RDP_CAPLEN_LARGE_POINTER +
|
||||
4 /* w2k fix, sessionid */ ;
|
||||
RDP_CAPLEN_LARGE_POINTER + 4 /* w2k fix, sessionid */ ;
|
||||
|
||||
logger(Protocol, Debug, "%s()", __func__);
|
||||
|
||||
@ -1128,7 +1128,7 @@ rdp_process_bitmap_caps(STREAM s)
|
||||
|
||||
/* Detect if we can have dynamic session resize enabled, only once. */
|
||||
if (g_first_bitmap_caps == True && !(g_session_width == g_requested_session_width
|
||||
&& g_session_height == g_requested_session_height))
|
||||
&& g_session_height == g_requested_session_height))
|
||||
{
|
||||
logger(Core, Notice, "Disabling dynamic session resize");
|
||||
g_dynamic_session_resize = False;
|
||||
@ -1277,7 +1277,8 @@ process_colour_pointer_common(STREAM s, int bpp)
|
||||
/* keep hotspot within cursor bounding box */
|
||||
x = MIN(x, width - 1);
|
||||
y = MIN(y, height - 1);
|
||||
if (g_local_cursor) return ; /* don't bother creating a cursor we won't use */
|
||||
if (g_local_cursor)
|
||||
return; /* don't bother creating a cursor we won't use */
|
||||
cursor = ui_create_cursor(x, y, width, height, mask, data, bpp);
|
||||
ui_set_cursor(cursor);
|
||||
cache_put_cursor(cache_idx, cursor);
|
||||
@ -1342,8 +1343,7 @@ set_system_pointer(uint32 ptr)
|
||||
break;
|
||||
default:
|
||||
logger(Protocol, Warning,
|
||||
"set_system_pointer(), unhandled pointer type 0x%x",
|
||||
ptr);
|
||||
"set_system_pointer(), unhandled pointer type 0x%x", ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1591,20 +1591,23 @@ process_pdu_logon(STREAM s)
|
||||
uint32 infotype;
|
||||
in_uint32_le(s, infotype);
|
||||
|
||||
switch(infotype)
|
||||
switch (infotype)
|
||||
{
|
||||
case INFOTYPE_LOGON_PLAINNOTIFY: /* TS_PLAIN_NOTIFY */
|
||||
logger(Protocol, Debug, "process_pdu_logon(), Received TS_LOGIN_PLAIN_NOTIFY");
|
||||
in_uint8s(s, 576); /* pad */
|
||||
break;
|
||||
case INFOTYPE_LOGON_PLAINNOTIFY: /* TS_PLAIN_NOTIFY */
|
||||
logger(Protocol, Debug,
|
||||
"process_pdu_logon(), Received TS_LOGIN_PLAIN_NOTIFY");
|
||||
in_uint8s(s, 576); /* pad */
|
||||
break;
|
||||
|
||||
case INFOTYPE_LOGON_EXTENDED_INF: /* TS_LOGON_INFO_EXTENDED */
|
||||
logger(Protocol, Debug, "process_pdu_logon(), Received TS_LOGIN_INFO_EXTENDED");
|
||||
process_ts_logon_info_extended(s);
|
||||
break;
|
||||
case INFOTYPE_LOGON_EXTENDED_INF: /* TS_LOGON_INFO_EXTENDED */
|
||||
logger(Protocol, Debug,
|
||||
"process_pdu_logon(), Received TS_LOGIN_INFO_EXTENDED");
|
||||
process_ts_logon_info_extended(s);
|
||||
break;
|
||||
|
||||
default:
|
||||
logger(Protocol, Warning, "process_pdu_logon(), Unhandled login infotype %d", infotype);
|
||||
default:
|
||||
logger(Protocol, Warning,
|
||||
"process_pdu_logon(), Unhandled login infotype %d", infotype);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1615,7 +1618,8 @@ process_ts_set_error_info_pdu(STREAM s, uint32 * ext_disc_reason)
|
||||
{
|
||||
in_uint32_le(s, *ext_disc_reason);
|
||||
|
||||
logger(Protocol, Debug, "process_ts_set_error_info_pdu(), error info = %d", *ext_disc_reason);
|
||||
logger(Protocol, Debug, "process_ts_set_error_info_pdu(), error info = %d",
|
||||
*ext_disc_reason);
|
||||
}
|
||||
|
||||
/* Process data PDU */
|
||||
@ -1908,7 +1912,8 @@ rdp_main_loop(RD_BOOL * deactivated, uint32 * ext_disc_reason)
|
||||
{
|
||||
g_exit_mainloop = True;
|
||||
}
|
||||
} while(g_exit_mainloop == False);
|
||||
}
|
||||
while (g_exit_mainloop == False);
|
||||
}
|
||||
|
||||
/* used in uiports and rdp_main_loop, processes the RDP packets waiting */
|
||||
|
9
rdp5.c
9
rdp5.c
@ -69,8 +69,8 @@ process_ts_fp_update_by_code(STREAM s, uint8 code)
|
||||
process_new_pointer_pdu(s);
|
||||
break;
|
||||
default:
|
||||
logger(Protocol, Warning, "process_ts_fp_updates_by_code(), unhandled opcode %d",
|
||||
code);
|
||||
logger(Protocol, Warning,
|
||||
"process_ts_fp_updates_by_code(), unhandled opcode %d", code);
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,13 +129,14 @@ process_ts_fp_updates(STREAM s)
|
||||
{
|
||||
process_ts_fp_update_by_code(ts, code);
|
||||
}
|
||||
else /* Fragmented packet, we must reassemble */
|
||||
else /* Fragmented packet, we must reassemble */
|
||||
{
|
||||
if (assembled[code] == NULL)
|
||||
{
|
||||
assembled[code] = xmalloc(sizeof(struct stream));
|
||||
memset(assembled[code], 0, sizeof(struct stream));
|
||||
s_realloc(assembled[code], RDESKTOP_FASTPATH_MULTIFRAGMENT_MAX_SIZE);
|
||||
s_realloc(assembled[code],
|
||||
RDESKTOP_FASTPATH_MULTIFRAGMENT_MAX_SIZE);
|
||||
s_reset(assembled[code]);
|
||||
}
|
||||
|
||||
|
20
rdpdr.c
20
rdpdr.c
@ -210,14 +210,14 @@ rdpdr_send_client_name_request(void)
|
||||
{
|
||||
/* DR_CORE_CLIENT_NAME_REQ */
|
||||
STREAM s;
|
||||
struct stream name = {0};
|
||||
struct stream name = { 0 };
|
||||
|
||||
if (NULL == g_rdpdr_clientname)
|
||||
{
|
||||
g_rdpdr_clientname = g_hostname;
|
||||
}
|
||||
|
||||
s_realloc(&name, 512*4);
|
||||
s_realloc(&name, 512 * 4);
|
||||
s_reset(&name);
|
||||
out_utf16s(&name, g_rdpdr_clientname);
|
||||
s_mark_end(&name);
|
||||
@ -284,7 +284,9 @@ rdpdr_send_client_device_list_announce(void)
|
||||
STREAM s;
|
||||
PRINTER *printerinfo;
|
||||
DISK_DEVICE *diskinfo;
|
||||
struct stream drv = {0}, prt = {0};
|
||||
struct stream drv = { 0 }, prt =
|
||||
{
|
||||
0};
|
||||
|
||||
s = channel_init(rdpdr_channel, announcedata_size());
|
||||
out_uint16_le(s, RDPDR_CTYP_CORE);
|
||||
@ -316,12 +318,12 @@ rdpdr_send_client_device_list_announce(void)
|
||||
case DEVICE_TYPE_PRINTER:
|
||||
printerinfo = (PRINTER *) g_rdpdr_device[i].pdevice_data;
|
||||
|
||||
s_realloc(&prt, 512*4);
|
||||
s_realloc(&prt, 512 * 4);
|
||||
s_reset(&prt);
|
||||
out_utf16s(&prt, printerinfo->printer);
|
||||
s_mark_end(&prt);
|
||||
|
||||
s_realloc(&drv, 512*4);
|
||||
s_realloc(&drv, 512 * 4);
|
||||
s_reset(&drv);
|
||||
out_utf16s(&drv, printerinfo->driver);
|
||||
s_mark_end(&drv);
|
||||
@ -476,7 +478,7 @@ rdpdr_process_irp(STREAM s)
|
||||
|
||||
in_uint32_be(s, desired_access);
|
||||
in_uint8s(s, 0x08); /* unknown */
|
||||
in_uint8s(s, 4); /* skip error_mode*/
|
||||
in_uint8s(s, 4); /* skip error_mode */
|
||||
in_uint32_le(s, share_mode);
|
||||
in_uint32_le(s, disposition);
|
||||
in_uint32_le(s, flags_and_attributes);
|
||||
@ -729,7 +731,7 @@ rdpdr_process_irp(STREAM s)
|
||||
}
|
||||
|
||||
in_uint32_le(s, bytes_out);
|
||||
in_uint8s(s,4); /* skip bytes_in */
|
||||
in_uint8s(s, 4); /* skip bytes_in */
|
||||
in_uint32_le(s, request);
|
||||
in_uint8s(s, 0x14);
|
||||
|
||||
@ -971,7 +973,7 @@ rdpdr_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv, RD_BOOL
|
||||
support for reconnects. */
|
||||
|
||||
FD_SET(iorq->fd, rfds);
|
||||
*n = MAX(*n, (int)iorq->fd);
|
||||
*n = MAX(*n, (int) iorq->fd);
|
||||
|
||||
/* Check if io request timeout is smaller than current (but not 0). */
|
||||
if (iorq->timeout
|
||||
@ -1006,7 +1008,7 @@ rdpdr_add_fds(int *n, fd_set * rfds, fd_set * wfds, struct timeval *tv, RD_BOOL
|
||||
break;
|
||||
|
||||
FD_SET(iorq->fd, wfds);
|
||||
*n = MAX(*n, (int)iorq->fd);
|
||||
*n = MAX(*n, (int) iorq->fd);
|
||||
break;
|
||||
|
||||
case IRP_MJ_DEVICE_CONTROL:
|
||||
|
@ -64,7 +64,7 @@ rdpedisp_process_pdu(STREAM s)
|
||||
|
||||
/* Read DISPLAYCONTROL_HEADER */
|
||||
in_uint32_le(s, type); /* type */
|
||||
in_skip(s, 4); /* length */
|
||||
in_skip(s, 4); /* length */
|
||||
|
||||
logger(Protocol, Debug, "rdpedisp_process_pdu(), Got PDU type %d", type);
|
||||
|
||||
@ -89,8 +89,8 @@ rdpedisp_send_monitor_layout_pdu(uint32 width, uint32 height)
|
||||
|
||||
memset(&s, 0, sizeof(s));
|
||||
|
||||
logger(Protocol, Debug, "rdpedisp_send_monitor_layout_pdu(), width = %d, height = %d", width,
|
||||
height);
|
||||
logger(Protocol, Debug, "rdpedisp_send_monitor_layout_pdu(), width = %d, height = %d",
|
||||
width, height);
|
||||
|
||||
rdpedisp_init_packet(&s, DISPLAYCONTROL_PDU_TYPE_MONITOR_LAYOUT, 16 + 1 * 40);
|
||||
|
||||
|
412
rdpsnd_pulse.c
412
rdpsnd_pulse.c
@ -48,10 +48,10 @@
|
||||
/* Messages that may be sent from the PulseAudio thread */
|
||||
enum RDPSND_PULSE_MSG_TYPE
|
||||
{
|
||||
RDPSND_PULSE_OUT_AVAIL, // Output space available in output stream
|
||||
RDPSND_PULSE_IN_AVAIL, // Input data available in input stream
|
||||
RDPSND_PULSE_OUT_ERR, // An error occured in the output stream
|
||||
RDPSND_PULSE_IN_ERR // An error occured in the input strem
|
||||
RDPSND_PULSE_OUT_AVAIL, // Output space available in output stream
|
||||
RDPSND_PULSE_IN_AVAIL, // Input data available in input stream
|
||||
RDPSND_PULSE_OUT_ERR, // An error occured in the output stream
|
||||
RDPSND_PULSE_IN_ERR // An error occured in the input strem
|
||||
};
|
||||
|
||||
static pa_threaded_mainloop *mainloop;
|
||||
@ -61,7 +61,7 @@ static pa_proplist *proplist;
|
||||
static pa_context *context;
|
||||
static pa_stream *playback_stream;
|
||||
static pa_stream *capture_stream;
|
||||
static int pulse_ctl[2] = { -1, -1 }; // Pipe for comminicating with main thread
|
||||
static int pulse_ctl[2] = { -1, -1 }; // Pipe for comminicating with main thread
|
||||
|
||||
/* Streams states for the possibility of the proper reinitialization */
|
||||
static RD_BOOL playback_started = False;
|
||||
@ -88,7 +88,8 @@ static RD_BOOL pulse_init(void);
|
||||
static void pulse_deinit(void);
|
||||
static RD_BOOL pulse_context_init(void);
|
||||
static void pulse_context_deinit(void);
|
||||
static RD_BOOL pulse_stream_open(pa_stream ** stream, int channels, int samplerate, int samplewidth, pa_stream_flags_t flags);
|
||||
static RD_BOOL pulse_stream_open(pa_stream ** stream, int channels, int samplerate, int samplewidth,
|
||||
pa_stream_flags_t flags);
|
||||
static void pulse_stream_close(pa_stream ** stream);
|
||||
|
||||
static void pulse_send_msg(int fd, char message);
|
||||
@ -106,14 +107,14 @@ static RD_BOOL pulse_record(void);
|
||||
static RD_BOOL pulse_recover(pa_stream ** stream);
|
||||
|
||||
/* Callbacks for the PulseAudio events */
|
||||
static void pulse_context_state_cb(pa_context * c, void * userdata);
|
||||
static void pulse_stream_state_cb(pa_stream * p, void * userdata);
|
||||
static void pulse_write_cb(pa_stream * , size_t nbytes, void * userdata);
|
||||
static void pulse_read_cb(pa_stream * p, size_t nbytes, void * userdata);
|
||||
static void pulse_context_state_cb(pa_context * c, void *userdata);
|
||||
static void pulse_stream_state_cb(pa_stream * p, void *userdata);
|
||||
static void pulse_write_cb(pa_stream *, size_t nbytes, void *userdata);
|
||||
static void pulse_read_cb(pa_stream * p, size_t nbytes, void *userdata);
|
||||
|
||||
static void pulse_cork_cb(pa_stream * p, int success, void * userdata);
|
||||
static void pulse_flush_cb(pa_stream * p, int success, void * userdata);
|
||||
static void pulse_update_timing_cb(pa_stream * p, int success, void * userdata);
|
||||
static void pulse_cork_cb(pa_stream * p, int success, void *userdata);
|
||||
static void pulse_flush_cb(pa_stream * p, int success, void *userdata);
|
||||
static void pulse_update_timing_cb(pa_stream * p, int success, void *userdata);
|
||||
|
||||
static RD_BOOL
|
||||
pulse_init(void)
|
||||
@ -127,15 +128,17 @@ pulse_init(void)
|
||||
mainloop = pa_threaded_mainloop_new();
|
||||
if (mainloop == NULL)
|
||||
{
|
||||
logger(Sound, Error, "pulse_init(), Error creating PulseAudio threaded mainloop");
|
||||
logger(Sound, Error,
|
||||
"pulse_init(), Error creating PulseAudio threaded mainloop");
|
||||
break;
|
||||
}
|
||||
if (pa_threaded_mainloop_start(mainloop) != 0)
|
||||
{
|
||||
logger(Sound, Error, "pulse_init(), Error starting PulseAudio threaded mainloop");
|
||||
logger(Sound, Error,
|
||||
"pulse_init(), Error starting PulseAudio threaded mainloop");
|
||||
break;
|
||||
}
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
/* PulseAudio proplist initialization */
|
||||
proplist = pa_proplist_new();
|
||||
if (proplist == NULL)
|
||||
@ -145,10 +148,11 @@ pulse_init(void)
|
||||
}
|
||||
if (pa_proplist_sets(proplist, PA_PROP_APPLICATION_NAME, "rdesktop") != 0)
|
||||
{
|
||||
logger(Sound, Error, "pulse_init(), Error setting option to PulseAudio proplist");
|
||||
logger(Sound, Error,
|
||||
"pulse_init(), Error setting option to PulseAudio proplist");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (pulse_context_init() != True)
|
||||
break;
|
||||
@ -169,13 +173,13 @@ pulse_deinit(void)
|
||||
pulse_stream_close(&capture_stream);
|
||||
pulse_stream_close(&playback_stream);
|
||||
pulse_context_deinit();
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
if (proplist != NULL)
|
||||
{
|
||||
pa_proplist_free(proplist);
|
||||
proplist = NULL;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
if (mainloop != NULL)
|
||||
{
|
||||
pa_threaded_mainloop_stop(mainloop);
|
||||
@ -209,27 +213,30 @@ pulse_context_init(void)
|
||||
logger(Sound, Error, "pulse_context_init(), fcntl: %s", strerror(errno));
|
||||
break;
|
||||
}
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
context = pa_context_new_with_proplist(pa_threaded_mainloop_get_api(mainloop), NULL, proplist);
|
||||
#else
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
context =
|
||||
pa_context_new_with_proplist(pa_threaded_mainloop_get_api(mainloop), NULL,
|
||||
proplist);
|
||||
#else
|
||||
context = pa_context_new(pa_threaded_mainloop_get_api(mainloop), "rdesktop");
|
||||
#endif
|
||||
#endif
|
||||
if (context == NULL)
|
||||
{
|
||||
logger(Sound, Error, "pulse_context_init(), error creating PulseAudio context");
|
||||
logger(Sound, Error,
|
||||
"pulse_context_init(), error creating PulseAudio context");
|
||||
break;
|
||||
}
|
||||
pa_context_set_state_callback(context, pulse_context_state_cb, mainloop);
|
||||
/* PulseAudio context connection */
|
||||
#if PA_CHECK_VERSION(0,9,15)
|
||||
#if PA_CHECK_VERSION(0,9,15)
|
||||
flags = PA_CONTEXT_NOFAIL;
|
||||
#else
|
||||
#else
|
||||
flags = 0;
|
||||
#endif
|
||||
#endif
|
||||
if (pa_context_connect(context, NULL, flags, NULL) != 0)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error ,"pulse_context_init(), %s", pa_strerror(err));
|
||||
logger(Sound, Error, "pulse_context_init(), %s", pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
do
|
||||
@ -244,7 +251,7 @@ pulse_context_init(void)
|
||||
if (context_state != PA_CONTEXT_READY)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error ,"pulse_context_init(), %s", pa_strerror(err));
|
||||
logger(Sound, Error, "pulse_context_init(), %s", pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -295,7 +302,8 @@ pulse_context_deinit(void)
|
||||
}
|
||||
|
||||
static RD_BOOL
|
||||
pulse_stream_open(pa_stream ** stream, int channels, int samplerate, int samplewidth, pa_stream_flags_t flags)
|
||||
pulse_stream_open(pa_stream ** stream, int channels, int samplerate, int samplewidth,
|
||||
pa_stream_flags_t flags)
|
||||
{
|
||||
pa_sample_spec samples;
|
||||
pa_buffer_attr buffer_attr;
|
||||
@ -315,88 +323,106 @@ pulse_stream_open(pa_stream ** stream, int channels, int samplerate, int samplew
|
||||
do
|
||||
{
|
||||
/* PulseAudio sample format initialization */
|
||||
#if PA_CHECK_VERSION(0,9,13)
|
||||
#if PA_CHECK_VERSION(0,9,13)
|
||||
if (pa_sample_spec_init(&samples) == NULL)
|
||||
{
|
||||
logger(Sound, Error, "pulse_stream_open(), error initializing PulseAudio sample format");
|
||||
logger(Sound, Error,
|
||||
"pulse_stream_open(), error initializing PulseAudio sample format");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
if (samplewidth == 2)
|
||||
samples.format = PA_SAMPLE_S16LE;
|
||||
else if (samplewidth == 1)
|
||||
samples.format = PA_SAMPLE_U8;
|
||||
else
|
||||
{
|
||||
logger(Sound, Error, "pulse_stream_open(), wrong samplewidth for the PulseAudio stream: %d", samplewidth);
|
||||
logger(Sound, Error,
|
||||
"pulse_stream_open(), wrong samplewidth for the PulseAudio stream: %d",
|
||||
samplewidth);
|
||||
break;
|
||||
}
|
||||
samples.rate = samplerate;
|
||||
samples.channels = channels;
|
||||
if (!pa_sample_spec_valid(&samples))
|
||||
{
|
||||
logger(Sound, Error, "pulse_stream_open(), Invalid PulseAudio sample format");
|
||||
logger(Sound, Error,
|
||||
"pulse_stream_open(), Invalid PulseAudio sample format");
|
||||
break;
|
||||
}
|
||||
/* PulseAudio stream creation */
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
if (stream == &playback_stream)
|
||||
*stream = pa_stream_new_with_proplist(context, "Playback Stream", &samples, NULL, proplist);
|
||||
*stream =
|
||||
pa_stream_new_with_proplist(context, "Playback Stream", &samples,
|
||||
NULL, proplist);
|
||||
else
|
||||
*stream = pa_stream_new_with_proplist(context, "Capture Stream", &samples, NULL, proplist);
|
||||
#else
|
||||
*stream =
|
||||
pa_stream_new_with_proplist(context, "Capture Stream", &samples,
|
||||
NULL, proplist);
|
||||
#else
|
||||
if (stream == &playback_stream)
|
||||
*stream = pa_stream_new(context, "Playback Stream", &samples, NULL);
|
||||
else
|
||||
*stream = pa_stream_new(context, "Capture Stream", &samples, NULL);
|
||||
#endif
|
||||
#endif
|
||||
if (*stream == NULL)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_stream_open(), pa_stream_new: %s", pa_strerror(err));
|
||||
logger(Sound, Error, "pulse_stream_open(), pa_stream_new: %s",
|
||||
pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
pa_stream_set_state_callback(*stream, pulse_stream_state_cb, mainloop);
|
||||
|
||||
buffer_attr.maxlength = (uint32_t) -1;
|
||||
buffer_attr.minreq = (uint32_t) -1;
|
||||
buffer_attr.prebuf = (uint32_t) -1;
|
||||
buffer_attr.tlength = (uint32_t) -1;
|
||||
buffer_attr.fragsize = (uint32_t) -1;
|
||||
buffer_attr.maxlength = (uint32_t) - 1;
|
||||
buffer_attr.minreq = (uint32_t) - 1;
|
||||
buffer_attr.prebuf = (uint32_t) - 1;
|
||||
buffer_attr.tlength = (uint32_t) - 1;
|
||||
buffer_attr.fragsize = (uint32_t) - 1;
|
||||
|
||||
/* PulseAudio stream connection */
|
||||
if (stream == &playback_stream)
|
||||
{
|
||||
#if PA_CHECK_VERSION(0,9,0)
|
||||
buffer_attr.tlength = pa_usec_to_bytes(1000000/playback_latency_part, &samples);
|
||||
#else
|
||||
buffer_attr.tlength = (samples.rate/playback_latency_part) * samples.channels * (samples.format == PA_SAMPLE_S16LE ? 2 : 1);
|
||||
#endif
|
||||
#if PA_CHECK_VERSION(0,9,0)
|
||||
buffer_attr.tlength =
|
||||
pa_usec_to_bytes(1000000 / playback_latency_part, &samples);
|
||||
#else
|
||||
buffer_attr.tlength =
|
||||
(samples.rate / playback_latency_part) * samples.channels *
|
||||
(samples.format == PA_SAMPLE_S16LE ? 2 : 1);
|
||||
#endif
|
||||
buffer_attr.prebuf = 0;
|
||||
buffer_attr.maxlength = buffer_attr.tlength;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if PA_CHECK_VERSION(0,9,0)
|
||||
buffer_attr.fragsize = pa_usec_to_bytes(1000000/capture_latency_part, &samples);
|
||||
#else
|
||||
buffer_attr.fragsize = (samples.rate/capture_latency_part) * samples.channels * (samples.format == PA_SAMPLE_S16LE ? 2 : 1);
|
||||
#endif
|
||||
#if PA_CHECK_VERSION(0,9,0)
|
||||
buffer_attr.fragsize =
|
||||
pa_usec_to_bytes(1000000 / capture_latency_part, &samples);
|
||||
#else
|
||||
buffer_attr.fragsize =
|
||||
(samples.rate / capture_latency_part) * samples.channels *
|
||||
(samples.format == PA_SAMPLE_S16LE ? 2 : 1);
|
||||
#endif
|
||||
buffer_attr.maxlength = buffer_attr.fragsize;
|
||||
}
|
||||
|
||||
#if !PA_CHECK_VERSION(0,9,16)
|
||||
buffer_attr.minreq = (samples.rate/50) * samples.channels * (samples.format == PA_SAMPLE_S16LE ? 2 : 1); // 20 ms
|
||||
#endif
|
||||
#if !PA_CHECK_VERSION(0,9,16)
|
||||
buffer_attr.minreq = (samples.rate / 50) * samples.channels * (samples.format == PA_SAMPLE_S16LE ? 2 : 1); // 20 ms
|
||||
#endif
|
||||
|
||||
if (stream == &playback_stream)
|
||||
err = pa_stream_connect_playback(*stream, device, &buffer_attr, flags, NULL, NULL);
|
||||
err = pa_stream_connect_playback(*stream, device, &buffer_attr, flags, NULL,
|
||||
NULL);
|
||||
else
|
||||
err = pa_stream_connect_record(*stream, device, &buffer_attr, flags);
|
||||
if (err)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_stream_open(), error connecting PulseAudio stream: %s", pa_strerror(err));
|
||||
logger(Sound, Error,
|
||||
"pulse_stream_open(), error connecting PulseAudio stream: %s",
|
||||
pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
do
|
||||
@ -411,20 +437,24 @@ pulse_stream_open(pa_stream ** stream, int channels, int samplerate, int samplew
|
||||
if (state != PA_STREAM_READY)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_stream_open(), error connecting PulseAudio stream: %s", pa_strerror(err));
|
||||
logger(Sound, Error,
|
||||
"pulse_stream_open(), error connecting PulseAudio stream: %s",
|
||||
pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
|
||||
#if PA_CHECK_VERSION(0,9,8)
|
||||
#if PA_CHECK_VERSION(0,9,8)
|
||||
logger(Sound, Debug, "pulse_stream_open(), opened PulseAudio stream on device %s",
|
||||
pa_stream_get_device_name(*stream));
|
||||
#endif
|
||||
#if PA_CHECK_VERSION(0,9,0)
|
||||
#endif
|
||||
#if PA_CHECK_VERSION(0,9,0)
|
||||
const pa_buffer_attr *res_ba;
|
||||
res_ba = pa_stream_get_buffer_attr(*stream);
|
||||
logger(Sound, Debug, "pulse_stream_open(), PulseAudio stream buffer metrics: maxlength %u, minreq %u, prebuf %u, tlength %u, fragsize %u",
|
||||
res_ba->maxlength, res_ba->minreq, res_ba->prebuf, res_ba->tlength, res_ba->fragsize);
|
||||
#endif
|
||||
logger(Sound, Debug,
|
||||
"pulse_stream_open(), PulseAudio stream buffer metrics: maxlength %u, minreq %u, prebuf %u, tlength %u, fragsize %u",
|
||||
res_ba->maxlength, res_ba->minreq, res_ba->prebuf, res_ba->tlength,
|
||||
res_ba->fragsize);
|
||||
#endif
|
||||
|
||||
/* Set the data callbacks for the PulseAudio stream */
|
||||
if (stream == &playback_stream)
|
||||
@ -460,7 +490,9 @@ pulse_stream_close(pa_stream ** stream)
|
||||
if (pa_stream_disconnect(*stream) != 0)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_stream_close(), pa_stream_disconnect: %s\n", pa_strerror(err));
|
||||
logger(Sound, Error,
|
||||
"pulse_stream_close(), pa_stream_disconnect: %s\n",
|
||||
pa_strerror(err));
|
||||
}
|
||||
}
|
||||
pa_stream_unref(*stream);
|
||||
@ -480,7 +512,8 @@ pulse_send_msg(int fd, char message)
|
||||
ret = write(fd, &message, sizeof message);
|
||||
while (ret == -1 && errno == EINTR);
|
||||
if (ret == -1)
|
||||
logger(Sound, Error, "pulse_send_msg(), error writing message to the pipe: %s\n", strerror(errno));
|
||||
logger(Sound, Error, "pulse_send_msg(), error writing message to the pipe: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
static RD_BOOL
|
||||
@ -494,7 +527,8 @@ pulse_playback_start(void)
|
||||
|
||||
if (playback_stream == NULL)
|
||||
{
|
||||
logger(Sound, Warning, "pulse_playback_start(), trying to start PulseAudio stream while it's not exists");
|
||||
logger(Sound, Warning,
|
||||
"pulse_playback_start(), trying to start PulseAudio stream while it's not exists");
|
||||
return True;
|
||||
}
|
||||
|
||||
@ -504,18 +538,20 @@ pulse_playback_start(void)
|
||||
{
|
||||
if (pa_stream_get_state(playback_stream) != PA_STREAM_READY)
|
||||
{
|
||||
logger(Sound, Warning, "pulse_playback_start(), trying to start PulseAudio stream while it's not ready");
|
||||
logger(Sound, Warning,
|
||||
"pulse_playback_start(), trying to start PulseAudio stream while it's not ready");
|
||||
break;
|
||||
}
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
ret = pa_stream_is_corked(playback_stream);
|
||||
#else
|
||||
#else
|
||||
ret = 1;
|
||||
#endif
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_playback_start(), pa_stream_is_corked: %s", pa_strerror(err));
|
||||
logger(Sound, Error, "pulse_playback_start(), pa_stream_is_corked: %s",
|
||||
pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
else if (ret != 0)
|
||||
@ -524,7 +560,8 @@ pulse_playback_start(void)
|
||||
if (po == NULL)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_playback_start(), pa_stream_corked: %s", pa_strerror(err));
|
||||
logger(Sound, Error, "pulse_playback_start(), pa_stream_corked: %s",
|
||||
pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
while (pa_operation_get_state(po) == PA_OPERATION_RUNNING)
|
||||
@ -552,7 +589,8 @@ pulse_playback_stop(void)
|
||||
|
||||
if (playback_stream == NULL)
|
||||
{
|
||||
logger(Sound, Debug, "pulse_playback_stop(), trying to stop PulseAudio stream while it's not exists");
|
||||
logger(Sound, Debug,
|
||||
"pulse_playback_stop(), trying to stop PulseAudio stream while it's not exists");
|
||||
return True;
|
||||
}
|
||||
|
||||
@ -562,18 +600,20 @@ pulse_playback_stop(void)
|
||||
{
|
||||
if (pa_stream_get_state(playback_stream) != PA_STREAM_READY)
|
||||
{
|
||||
logger(Sound, Error, "pulse_playback_stop(), trying to stop PulseAudio stream while it's not ready");
|
||||
logger(Sound, Error,
|
||||
"pulse_playback_stop(), trying to stop PulseAudio stream while it's not ready");
|
||||
break;
|
||||
}
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
ret = pa_stream_is_corked(playback_stream);
|
||||
#else
|
||||
#else
|
||||
ret = 0;
|
||||
#endif
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_playback_stop(), pa_stream_is_corked: %s", pa_strerror(err));
|
||||
logger(Sound, Error, "pulse_playback_stop(), pa_stream_is_corked: %s",
|
||||
pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
else if (ret == 0)
|
||||
@ -582,7 +622,8 @@ pulse_playback_stop(void)
|
||||
if (po == NULL)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_playback_stop(), pa_stream_cork: %s", pa_strerror(err));
|
||||
logger(Sound, Error, "pulse_playback_stop(), pa_stream_cork: %s",
|
||||
pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
while (pa_operation_get_state(po) == PA_OPERATION_RUNNING)
|
||||
@ -593,7 +634,8 @@ pulse_playback_stop(void)
|
||||
if (po == NULL)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_playback_stop(), pa_stream_flush: %s", pa_strerror(err));
|
||||
logger(Sound, Error, "pulse_playback_stop(), pa_stream_flush: %s",
|
||||
pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
while (pa_operation_get_state(po) == PA_OPERATION_RUNNING)
|
||||
@ -617,10 +659,11 @@ pulse_playback_set_audio(int channels, int samplerate, int samplewidth)
|
||||
|
||||
pulse_stream_close(&playback_stream);
|
||||
|
||||
flags = PA_STREAM_START_CORKED | PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_AUTO_TIMING_UPDATE;
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
flags = PA_STREAM_START_CORKED | PA_STREAM_INTERPOLATE_TIMING |
|
||||
PA_STREAM_AUTO_TIMING_UPDATE;
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
flags |= PA_STREAM_ADJUST_LATENCY;
|
||||
#endif
|
||||
#endif
|
||||
if (pulse_stream_open(&playback_stream, channels, samplerate, samplewidth, flags) != True)
|
||||
return False;
|
||||
|
||||
@ -638,7 +681,8 @@ pulse_capture_start(void)
|
||||
|
||||
if (capture_stream == NULL)
|
||||
{
|
||||
logger(Sound, Warning, "pulse_capture_start(), trying to start PulseAudio stream while it's not exists");
|
||||
logger(Sound, Warning,
|
||||
"pulse_capture_start(), trying to start PulseAudio stream while it's not exists");
|
||||
return True;
|
||||
}
|
||||
|
||||
@ -648,18 +692,20 @@ pulse_capture_start(void)
|
||||
{
|
||||
if (pa_stream_get_state(capture_stream) != PA_STREAM_READY)
|
||||
{
|
||||
logger(Sound, Error, "pulse_capture_start(), trying to start PulseAudio stream while it's not exists");
|
||||
logger(Sound, Error,
|
||||
"pulse_capture_start(), trying to start PulseAudio stream while it's not exists");
|
||||
break;
|
||||
}
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
ret = pa_stream_is_corked(capture_stream);
|
||||
#else
|
||||
#else
|
||||
ret = 1;
|
||||
#endif
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_capture_start(), pa_stream_is_corked: %s", pa_strerror(err));
|
||||
logger(Sound, Error, "pulse_capture_start(), pa_stream_is_corked: %s",
|
||||
pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
else if (ret != 0)
|
||||
@ -668,7 +714,8 @@ pulse_capture_start(void)
|
||||
if (po == NULL)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_capture_start(), pa_stream_cork: %s\n", pa_strerror(err));
|
||||
logger(Sound, Error, "pulse_capture_start(), pa_stream_cork: %s\n",
|
||||
pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
while (pa_operation_get_state(po) == PA_OPERATION_RUNNING)
|
||||
@ -696,7 +743,8 @@ pulse_capture_stop(void)
|
||||
|
||||
if (capture_stream == NULL)
|
||||
{
|
||||
logger(Sound, Debug, "pulse_capture_stop(), trying to stop PulseAudio stream while it's not exists");
|
||||
logger(Sound, Debug,
|
||||
"pulse_capture_stop(), trying to stop PulseAudio stream while it's not exists");
|
||||
return True;
|
||||
}
|
||||
|
||||
@ -706,18 +754,20 @@ pulse_capture_stop(void)
|
||||
{
|
||||
if (pa_stream_get_state(capture_stream) != PA_STREAM_READY)
|
||||
{
|
||||
logger(Sound, Error, "pulse_capture_stop(), trying to stop PulseAudio stream while it's not exists");
|
||||
logger(Sound, Error,
|
||||
"pulse_capture_stop(), trying to stop PulseAudio stream while it's not exists");
|
||||
break;
|
||||
}
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
ret = pa_stream_is_corked(capture_stream);
|
||||
#else
|
||||
#else
|
||||
ret = 0;
|
||||
#endif
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_capture_stop(), pa_stream_is_corked: %s\n", pa_strerror(err));
|
||||
logger(Sound, Error, "pulse_capture_stop(), pa_stream_is_corked: %s\n",
|
||||
pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
else if (ret == 0)
|
||||
@ -726,7 +776,8 @@ pulse_capture_stop(void)
|
||||
if (po == NULL)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_capture_stop(), pa_stream_cork: %s\n", pa_strerror(err));
|
||||
logger(Sound, Error, "pulse_capture_stop(), pa_stream_cork: %s\n",
|
||||
pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
while (pa_operation_get_state(po) == PA_OPERATION_RUNNING)
|
||||
@ -753,9 +804,9 @@ pulse_capture_set_audio(int channels, int samplerate, int samplewidth)
|
||||
|
||||
|
||||
flags = PA_STREAM_START_CORKED;
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
flags |= PA_STREAM_ADJUST_LATENCY;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (capture_stream != NULL)
|
||||
{
|
||||
@ -763,18 +814,20 @@ pulse_capture_set_audio(int channels, int samplerate, int samplewidth)
|
||||
state = pa_stream_get_state(capture_stream);
|
||||
if (state == PA_STREAM_READY)
|
||||
{
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
#if PA_CHECK_VERSION(0,9,11)
|
||||
ret = pa_stream_is_corked(capture_stream);
|
||||
#else
|
||||
#else
|
||||
ret = (capture_started == False);
|
||||
#endif
|
||||
#endif
|
||||
if (ret == 0)
|
||||
flags &= ~PA_STREAM_START_CORKED;
|
||||
else if (ret < 0)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
logger(Sound, Error, "pulse_capture_set_audio(), pa_stream_is_corked: %s\n", pa_strerror(err));
|
||||
logger(Sound, Error,
|
||||
"pulse_capture_set_audio(), pa_stream_is_corked: %s\n",
|
||||
pa_strerror(err));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
@ -790,7 +843,7 @@ pulse_capture_set_audio(int channels, int samplerate, int samplewidth)
|
||||
}
|
||||
|
||||
static void
|
||||
pulse_context_state_cb(pa_context * c, void * userdata)
|
||||
pulse_context_state_cb(pa_context * c, void *userdata)
|
||||
{
|
||||
pa_context_state_t state;
|
||||
|
||||
@ -803,7 +856,7 @@ pulse_context_state_cb(pa_context * c, void * userdata)
|
||||
}
|
||||
|
||||
static void
|
||||
pulse_stream_state_cb(pa_stream * p, void * userdata)
|
||||
pulse_stream_state_cb(pa_stream * p, void *userdata)
|
||||
{
|
||||
pa_stream_state_t state;
|
||||
|
||||
@ -815,12 +868,14 @@ pulse_stream_state_cb(pa_stream * p, void * userdata)
|
||||
{
|
||||
if (p == playback_stream)
|
||||
{
|
||||
logger(Sound, Debug, "pulse_stream_state_cb(), PulseAudio playback stream is in a fail state");
|
||||
logger(Sound, Debug,
|
||||
"pulse_stream_state_cb(), PulseAudio playback stream is in a fail state");
|
||||
pulse_send_msg(pulse_ctl[1], RDPSND_PULSE_OUT_ERR);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger(Sound, Debug, "pulse_stream_state_cb(), PulseAudio capture stream is in a fail state");
|
||||
logger(Sound, Debug,
|
||||
"pulse_stream_state_cb(), PulseAudio capture stream is in a fail state");
|
||||
pulse_send_msg(pulse_ctl[1], RDPSND_PULSE_IN_ERR);
|
||||
}
|
||||
}
|
||||
@ -829,7 +884,7 @@ pulse_stream_state_cb(pa_stream * p, void * userdata)
|
||||
}
|
||||
|
||||
static void
|
||||
pulse_read_cb(pa_stream * p, size_t nbytes, void * userdata)
|
||||
pulse_read_cb(pa_stream * p, size_t nbytes, void *userdata)
|
||||
{
|
||||
assert(userdata != NULL);
|
||||
|
||||
@ -837,7 +892,7 @@ pulse_read_cb(pa_stream * p, size_t nbytes, void * userdata)
|
||||
}
|
||||
|
||||
static void
|
||||
pulse_write_cb(pa_stream * p, size_t nbytes, void * userdata)
|
||||
pulse_write_cb(pa_stream * p, size_t nbytes, void *userdata)
|
||||
{
|
||||
assert(userdata != NULL);
|
||||
|
||||
@ -845,7 +900,7 @@ pulse_write_cb(pa_stream * p, size_t nbytes, void * userdata)
|
||||
}
|
||||
|
||||
static void
|
||||
pulse_cork_cb(pa_stream * p, int success, void * userdata)
|
||||
pulse_cork_cb(pa_stream * p, int success, void *userdata)
|
||||
{
|
||||
assert(userdata != NULL);
|
||||
|
||||
@ -853,13 +908,15 @@ pulse_cork_cb(pa_stream * p, int success, void * userdata)
|
||||
{
|
||||
if (p == playback_stream)
|
||||
{
|
||||
logger(Sound, Warning, "pulse_cork_cb(), fail to cork/uncork the PulseAudio playback stream: %s",
|
||||
logger(Sound, Warning,
|
||||
"pulse_cork_cb(), fail to cork/uncork the PulseAudio playback stream: %s",
|
||||
pa_strerror(pa_context_errno(context)));
|
||||
pulse_send_msg(pulse_ctl[1], RDPSND_PULSE_OUT_ERR);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger(Sound, Warning, "pulse_cork_cb(), fail to cork/uncork the PulseAudio capture stream: %s",
|
||||
logger(Sound, Warning,
|
||||
"pulse_cork_cb(), fail to cork/uncork the PulseAudio capture stream: %s",
|
||||
pa_strerror(pa_context_errno(context)));
|
||||
pulse_send_msg(pulse_ctl[1], RDPSND_PULSE_IN_ERR);
|
||||
}
|
||||
@ -869,7 +926,7 @@ pulse_cork_cb(pa_stream * p, int success, void * userdata)
|
||||
}
|
||||
|
||||
static void
|
||||
pulse_flush_cb(pa_stream * p, int success, void * userdata)
|
||||
pulse_flush_cb(pa_stream * p, int success, void *userdata)
|
||||
{
|
||||
assert(userdata != NULL);
|
||||
|
||||
@ -884,13 +941,14 @@ pulse_flush_cb(pa_stream * p, int success, void * userdata)
|
||||
}
|
||||
|
||||
static void
|
||||
pulse_update_timing_cb(pa_stream * p, int success, void * userdata)
|
||||
pulse_update_timing_cb(pa_stream * p, int success, void *userdata)
|
||||
{
|
||||
assert(userdata != NULL);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
logger(Sound, Warning, "pulse_update_timing_cb(), fail to update timing info of the PulseAudio stream: %s",
|
||||
logger(Sound, Warning,
|
||||
"pulse_update_timing_cb(), fail to update timing info of the PulseAudio stream: %s",
|
||||
pa_strerror(pa_context_errno(context)));
|
||||
pulse_send_msg(pulse_ctl[1], RDPSND_PULSE_OUT_ERR);
|
||||
}
|
||||
@ -933,13 +991,15 @@ pulse_check_fds(fd_set * rfds, fd_set * wfds)
|
||||
break;
|
||||
else
|
||||
{
|
||||
logger(Sound, Error, "pulse_check_fds(), read: %s\n", strerror(errno));
|
||||
logger(Sound, Error, "pulse_check_fds(), read: %s\n",
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (n == 0)
|
||||
{
|
||||
logger(Sound, Warning, "pulse_check_fds(), audio control pipe was closed");
|
||||
logger(Sound, Warning,
|
||||
"pulse_check_fds(), audio control pipe was closed");
|
||||
break;
|
||||
}
|
||||
else
|
||||
@ -949,7 +1009,8 @@ pulse_check_fds(fd_set * rfds, fd_set * wfds)
|
||||
if (pulse_play() != True)
|
||||
if (pulse_recover(&playback_stream) != True)
|
||||
{
|
||||
logger(Sound, Error, "pulse_check_fds(), PulseAudio playback error");
|
||||
logger(Sound, Error,
|
||||
"pulse_check_fds(), PulseAudio playback error");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@ -957,26 +1018,31 @@ pulse_check_fds(fd_set * rfds, fd_set * wfds)
|
||||
if (pulse_record() != True)
|
||||
if (pulse_recover(&capture_stream) != True)
|
||||
{
|
||||
logger(Sound, Error, "pulse_check_fds(), PulseAudio capture error");
|
||||
logger(Sound, Error,
|
||||
"pulse_check_fds(), PulseAudio capture error");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case RDPSND_PULSE_OUT_ERR:
|
||||
if (pulse_recover(&playback_stream) != True)
|
||||
{
|
||||
logger(Sound, Error, "pulse_check_fds(), an error occured in audio thread with PulseAudio playback stream");
|
||||
logger(Sound, Error,
|
||||
"pulse_check_fds(), an error occured in audio thread with PulseAudio playback stream");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case RDPSND_PULSE_IN_ERR:
|
||||
if (pulse_recover(&capture_stream) != True)
|
||||
{
|
||||
logger(Sound, Error, "pulse_check_fds(), an error occured in audio thread with PulseAudio capture stream");
|
||||
logger(Sound, Error,
|
||||
"pulse_check_fds(), an error occured in audio thread with PulseAudio capture stream");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
logger(Sound, Error, "pulse_check_fds(), wrong command from the audio thread: %d", audio_cmd);
|
||||
logger(Sound, Error,
|
||||
"pulse_check_fds(), wrong command from the audio thread: %d",
|
||||
audio_cmd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1008,7 +1074,8 @@ pulse_close_out(void)
|
||||
if (playback_stream && pulse_playback_stop() != True)
|
||||
if (pulse_recover(&playback_stream) != True)
|
||||
{
|
||||
logger(Sound, Error ,"pulse_close_out(), fail to close the PulseAudio playback stream");
|
||||
logger(Sound, Error,
|
||||
"pulse_close_out(), fail to close the PulseAudio playback stream");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1030,18 +1097,20 @@ RD_BOOL
|
||||
pulse_set_format_out(RD_WAVEFORMATEX * pwfx)
|
||||
{
|
||||
if (playback_stream == NULL
|
||||
|| playback_channels != pwfx->nChannels
|
||||
|| playback_samplerate != pwfx->nSamplesPerSec
|
||||
|| playback_samplewidth != pwfx->wBitsPerSample / 8)
|
||||
|| playback_channels != pwfx->nChannels
|
||||
|| playback_samplerate != pwfx->nSamplesPerSec
|
||||
|| playback_samplewidth != pwfx->wBitsPerSample / 8)
|
||||
{
|
||||
playback_channels = pwfx->nChannels;
|
||||
playback_samplerate = pwfx->nSamplesPerSec;
|
||||
playback_samplewidth = pwfx->wBitsPerSample / 8;
|
||||
|
||||
if (pulse_playback_set_audio(pwfx->nChannels, pwfx->nSamplesPerSec, pwfx->wBitsPerSample / 8) != True)
|
||||
if (pulse_playback_set_audio
|
||||
(pwfx->nChannels, pwfx->nSamplesPerSec, pwfx->wBitsPerSample / 8) != True)
|
||||
if (pulse_recover(&playback_stream) != True)
|
||||
{
|
||||
logger(Sound, Error ,"pulse_set_format_out(), fail to open the PulseAudio playback stream");
|
||||
logger(Sound, Error,
|
||||
"pulse_set_format_out(), fail to open the PulseAudio playback stream");
|
||||
return False;
|
||||
}
|
||||
}
|
||||
@ -1051,7 +1120,8 @@ pulse_set_format_out(RD_WAVEFORMATEX * pwfx)
|
||||
if (pulse_playback_start() != True)
|
||||
if (pulse_recover(&playback_stream) != True)
|
||||
{
|
||||
logger(Sound, Error, "pulse_set_format_out(), fail to start the PulseAudio playback stream");
|
||||
logger(Sound, Error,
|
||||
"pulse_set_format_out(), fail to start the PulseAudio playback stream");
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -1090,17 +1160,21 @@ pulse_play(void)
|
||||
if (ti == NULL)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_play(), pa_stream_get_timing_info: %s", pa_strerror(err));
|
||||
logger(Sound, Error, "pulse_play(), pa_stream_get_timing_info: %s",
|
||||
pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
|
||||
if (ti->read_index_corrupt || ti->write_index_corrupt)
|
||||
{
|
||||
po = pa_stream_update_timing_info(playback_stream, pulse_update_timing_cb, mainloop);
|
||||
po = pa_stream_update_timing_info(playback_stream, pulse_update_timing_cb,
|
||||
mainloop);
|
||||
if (po == NULL)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_play(), pa_stream_update_timing_info: %s", pa_strerror(err));
|
||||
logger(Sound, Error,
|
||||
"pulse_play(), pa_stream_update_timing_info: %s",
|
||||
pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
while (pa_operation_get_state(po) == PA_OPERATION_RUNNING)
|
||||
@ -1121,10 +1195,12 @@ pulse_play(void)
|
||||
audio_size = out->end - out->p <= avail_space ? out->end - out->p : avail_space;
|
||||
if (audio_size)
|
||||
{
|
||||
if (pa_stream_write(playback_stream, out->p, audio_size, NULL, 0, playback_seek) != 0)
|
||||
if (pa_stream_write
|
||||
(playback_stream, out->p, audio_size, NULL, 0, playback_seek) != 0)
|
||||
{
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_play(), pa_stream_write: %s", pa_strerror(err));
|
||||
logger(Sound, Error, "pulse_play(), pa_stream_write: %s",
|
||||
pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
else if (playback_seek == PA_SEEK_RELATIVE_ON_READ)
|
||||
@ -1138,12 +1214,15 @@ pulse_play(void)
|
||||
ret = pa_stream_get_latency(playback_stream, &delay, NULL);
|
||||
if (ret != 0 && (err = pa_context_errno(context)) == PA_ERR_NODATA)
|
||||
{
|
||||
po = pa_stream_update_timing_info(playback_stream, pulse_update_timing_cb, mainloop);
|
||||
po = pa_stream_update_timing_info(playback_stream,
|
||||
pulse_update_timing_cb, mainloop);
|
||||
if (po == NULL)
|
||||
{
|
||||
delay = 0;
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_play(), pa_stream_update_timing_info: %s", pa_strerror(err));
|
||||
logger(Sound, Error,
|
||||
"pulse_play(), pa_stream_update_timing_info: %s",
|
||||
pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
while (pa_operation_get_state(po) == PA_OPERATION_RUNNING)
|
||||
@ -1156,11 +1235,14 @@ pulse_play(void)
|
||||
{
|
||||
delay = 0;
|
||||
err = pa_context_errno(context);
|
||||
logger(Sound, Error, "pulse_play(), pa_stream_get_latency: %s", pa_strerror(err));
|
||||
logger(Sound, Error, "pulse_play(), pa_stream_get_latency: %s",
|
||||
pa_strerror(err));
|
||||
break;
|
||||
}
|
||||
|
||||
logger(Sound, Debug, "pulse_play(), PulseAudio playback stream latency %lu usec", (long) delay);
|
||||
logger(Sound, Debug,
|
||||
"pulse_play(), PulseAudio playback stream latency %lu usec",
|
||||
(long) delay);
|
||||
}
|
||||
|
||||
result = True;
|
||||
@ -1193,7 +1275,8 @@ pulse_close_in(void)
|
||||
if (capture_stream && pulse_capture_stop() != True)
|
||||
if (pulse_recover(&capture_stream) != True)
|
||||
{
|
||||
logger(Sound, Error, "pulse_close_in(), fail to close the PulseAudio capture stream");
|
||||
logger(Sound, Error,
|
||||
"pulse_close_in(), fail to close the PulseAudio capture stream");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1202,18 +1285,20 @@ RD_BOOL
|
||||
pulse_set_format_in(RD_WAVEFORMATEX * pwfx)
|
||||
{
|
||||
if (capture_stream == NULL
|
||||
|| capture_channels != pwfx->nChannels
|
||||
|| capture_samplerate != pwfx->nSamplesPerSec
|
||||
|| capture_samplewidth != pwfx->wBitsPerSample / 8)
|
||||
|| capture_channels != pwfx->nChannels
|
||||
|| capture_samplerate != pwfx->nSamplesPerSec
|
||||
|| capture_samplewidth != pwfx->wBitsPerSample / 8)
|
||||
{
|
||||
capture_channels = pwfx->nChannels;
|
||||
capture_samplerate = pwfx->nSamplesPerSec;
|
||||
capture_samplewidth = pwfx->wBitsPerSample / 8;
|
||||
|
||||
if (pulse_capture_set_audio(pwfx->nChannels, pwfx->nSamplesPerSec, pwfx->wBitsPerSample / 8) != True)
|
||||
if (pulse_capture_set_audio
|
||||
(pwfx->nChannels, pwfx->nSamplesPerSec, pwfx->wBitsPerSample / 8) != True)
|
||||
if (pulse_recover(&capture_stream) != True)
|
||||
{
|
||||
logger(Sound, Error, "pulse_set_format_in(), fail to open the PulseAudio capture stream");
|
||||
logger(Sound, Error,
|
||||
"pulse_set_format_in(), fail to open the PulseAudio capture stream");
|
||||
return False;
|
||||
}
|
||||
}
|
||||
@ -1223,7 +1308,8 @@ pulse_set_format_in(RD_WAVEFORMATEX * pwfx)
|
||||
if (pulse_capture_start() != True)
|
||||
if (pulse_recover(&capture_stream) != True)
|
||||
{
|
||||
logger(Sound, Error, "pulse_set_format_in(), fail to start the PulseAudio capture stream");
|
||||
logger(Sound, Error,
|
||||
"pulse_set_format_in(), fail to start the PulseAudio capture stream");
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -1247,7 +1333,8 @@ pulse_record(void)
|
||||
{
|
||||
if (pa_stream_peek(capture_stream, &pulse_buf, &audio_size) != 0)
|
||||
{
|
||||
logger(Sound, Error, "pulse_record(), pa_stream_peek: %s", pa_strerror(pa_context_errno(context)));
|
||||
logger(Sound, Error, "pulse_record(), pa_stream_peek: %s",
|
||||
pa_strerror(pa_context_errno(context)));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1270,7 +1357,8 @@ pulse_record(void)
|
||||
|
||||
if (pa_stream_drop(capture_stream) != 0)
|
||||
{
|
||||
logger(Sound, Error, "pulse_record(), pa_stream_drop: %s", pa_strerror(pa_context_errno(context)));
|
||||
logger(Sound, Error, "pulse_record(), pa_stream_drop: %s",
|
||||
pa_strerror(pa_context_errno(context)));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1301,13 +1389,15 @@ pulse_recover(pa_stream ** stream)
|
||||
|
||||
if (stream == &playback_stream)
|
||||
{
|
||||
if (pulse_playback_set_audio(playback_channels, playback_samplerate, playback_samplewidth) == True)
|
||||
if (pulse_playback_set_audio
|
||||
(playback_channels, playback_samplerate, playback_samplewidth) == True)
|
||||
if (playback_started != True || pulse_playback_start() == True)
|
||||
return True;
|
||||
}
|
||||
else if (stream == &capture_stream)
|
||||
{
|
||||
if (pulse_capture_set_audio(capture_channels, capture_samplerate, capture_samplewidth) == True)
|
||||
if (pulse_capture_set_audio
|
||||
(capture_channels, capture_samplerate, capture_samplewidth) == True)
|
||||
if (capture_started != True || pulse_capture_start() == True)
|
||||
return True;
|
||||
}
|
||||
@ -1321,14 +1411,16 @@ pulse_recover(pa_stream ** stream)
|
||||
{
|
||||
if (playback == True)
|
||||
{
|
||||
if (pulse_playback_set_audio(playback_channels, playback_samplerate, playback_samplewidth) != True
|
||||
|| (playback_started == True && pulse_playback_start() != True))
|
||||
break;
|
||||
if (pulse_playback_set_audio
|
||||
(playback_channels, playback_samplerate, playback_samplewidth) != True
|
||||
|| (playback_started == True && pulse_playback_start() != True))
|
||||
break;
|
||||
}
|
||||
if (capture == True)
|
||||
{
|
||||
if (pulse_capture_set_audio(capture_channels, capture_samplerate, capture_samplewidth) != True
|
||||
|| (capture_started == True && pulse_capture_start() != True))
|
||||
if (pulse_capture_set_audio
|
||||
(capture_channels, capture_samplerate, capture_samplewidth) != True
|
||||
|| (capture_started == True && pulse_capture_start() != True))
|
||||
break;
|
||||
}
|
||||
|
||||
|
51
scard.c
51
scard.c
@ -101,15 +101,15 @@ static RD_NTSTATUS
|
||||
scard_create(uint32 device_id, uint32 accessmask, uint32 sharemode, uint32 create_disposition,
|
||||
uint32 flags_and_attributes, char *filename, RD_NTHANDLE * phandle)
|
||||
{
|
||||
UNUSED(device_id);
|
||||
UNUSED(accessmask);
|
||||
UNUSED(sharemode);
|
||||
UNUSED(create_disposition);
|
||||
UNUSED(flags_and_attributes);
|
||||
UNUSED(filename);
|
||||
UNUSED(phandle);
|
||||
UNUSED(device_id);
|
||||
UNUSED(accessmask);
|
||||
UNUSED(sharemode);
|
||||
UNUSED(create_disposition);
|
||||
UNUSED(flags_and_attributes);
|
||||
UNUSED(filename);
|
||||
UNUSED(phandle);
|
||||
|
||||
return RD_STATUS_SUCCESS;
|
||||
return RD_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static RD_NTSTATUS
|
||||
@ -1729,9 +1729,11 @@ TS_SCardStatus(STREAM in, STREAM out, RD_BOOL wide)
|
||||
"TS_SCardStatus(), hcard: 0x%08x [0x%08lx], reader len: %d bytes, atr len: %d bytes",
|
||||
(unsigned) hCard, (unsigned long) myHCard, (int) dwReaderLen, (int) dwAtrLen);
|
||||
|
||||
if (dwReaderLen == 0 || dwReaderLen == (SERVER_DWORD)SCARD_AUTOALLOCATE || dwReaderLen > SCARD_MAX_MEM)
|
||||
if (dwReaderLen == 0 || dwReaderLen == (SERVER_DWORD) SCARD_AUTOALLOCATE
|
||||
|| dwReaderLen > SCARD_MAX_MEM)
|
||||
dwReaderLen = SCARD_MAX_MEM;
|
||||
if (dwAtrLen == 0 || dwAtrLen == (SERVER_DWORD)SCARD_AUTOALLOCATE || dwAtrLen > SCARD_MAX_MEM)
|
||||
if (dwAtrLen == 0 || dwAtrLen == (SERVER_DWORD) SCARD_AUTOALLOCATE
|
||||
|| dwAtrLen > SCARD_MAX_MEM)
|
||||
dwAtrLen = SCARD_MAX_MEM;
|
||||
|
||||
#if 1
|
||||
@ -1846,7 +1848,8 @@ TS_SCardState(STREAM in, STREAM out)
|
||||
(unsigned) hCard, (unsigned long) myHCard, (int) dwAtrLen);
|
||||
|
||||
dwReaderLen = SCARD_MAX_MEM;
|
||||
if (dwAtrLen <= 0 || dwAtrLen == (SERVER_DWORD)SCARD_AUTOALLOCATE || dwAtrLen > SCARD_MAX_MEM)
|
||||
if (dwAtrLen <= 0 || dwAtrLen == (SERVER_DWORD) SCARD_AUTOALLOCATE
|
||||
|| dwAtrLen > SCARD_MAX_MEM)
|
||||
dwAtrLen = SCARD_MAX_MEM;
|
||||
|
||||
readerName = SC_xmalloc(&lcHandle, dwReaderLen + 2);
|
||||
@ -2006,16 +2009,16 @@ TS_SCardGetAttrib(STREAM in, STREAM out)
|
||||
(unsigned) hCard, (unsigned long) myHCard, (unsigned) dwAttrId, (int) dwAttrLen);
|
||||
|
||||
pbAttr = NULL;
|
||||
if (dwAttrLen != (SERVER_DWORD)SCARD_AUTOALLOCATE)
|
||||
if (dwAttrLen != (SERVER_DWORD) SCARD_AUTOALLOCATE)
|
||||
{
|
||||
if (dwAttrLen > MAX_BUFFER_SIZE)
|
||||
{
|
||||
dwAttrLen = MAX_BUFFER_SIZE;
|
||||
}
|
||||
if (dwAttrLen > MAX_BUFFER_SIZE)
|
||||
{
|
||||
dwAttrLen = MAX_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
pbAttr = SC_xmalloc(&lcHandle, dwAttrLen);
|
||||
if (!pbAttr)
|
||||
return SC_returnNoMemoryError(&lcHandle, in, out);
|
||||
pbAttr = SC_xmalloc(&lcHandle, dwAttrLen);
|
||||
if (!pbAttr)
|
||||
return SC_returnNoMemoryError(&lcHandle, in, out);
|
||||
}
|
||||
|
||||
attrLen = dwAttrLen;
|
||||
@ -2187,9 +2190,11 @@ TS_SCardControl(STREAM in, STREAM out)
|
||||
|
||||
/* ATM, I removed features code transformations */
|
||||
/* You know what to do if any problem arises in the future. */
|
||||
if ((dwControlCode & 0xff000000) != SCARD_CTL_CODE(0)) {
|
||||
if ((dwControlCode & 0xff000000) != SCARD_CTL_CODE(0))
|
||||
{
|
||||
logger(SmartCard, Warning,
|
||||
"TS_SCardControl(), bogus smart card control code 0x%08x", dwControlCode);
|
||||
"TS_SCardControl(), bogus smart card control code 0x%08x",
|
||||
dwControlCode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2729,7 +2734,8 @@ scard_reset_state()
|
||||
queueFirst = queueLast = NULL;
|
||||
}
|
||||
|
||||
void scard_release_all_contexts(void)
|
||||
void
|
||||
scard_release_all_contexts(void)
|
||||
{
|
||||
_scard_handle_list_t *item, *next;
|
||||
|
||||
@ -2749,4 +2755,3 @@ void scard_release_all_contexts(void)
|
||||
|
||||
g_scard_handle_list = NULL;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ seamless_process_line(const char *line, void *data)
|
||||
logger(Core, Debug, "seamless_process_line(), got '%s'", p);
|
||||
|
||||
tok1 = seamless_get_token(&p);
|
||||
(void)seamless_get_token(&p);
|
||||
(void) seamless_get_token(&p);
|
||||
tok3 = seamless_get_token(&p);
|
||||
tok4 = seamless_get_token(&p);
|
||||
tok5 = seamless_get_token(&p);
|
||||
|
48
secure.c
48
secure.c
@ -425,26 +425,26 @@ sec_out_mcs_connect_initial_pdu(STREAM s, uint32 selected_protocol)
|
||||
out_uint16_be(s, ((length - 14) | 0x8000)); /* remaining length */
|
||||
|
||||
/* Client information (TS_UD_CS_CORE) */
|
||||
out_uint16_le(s, CS_CORE); /* type */
|
||||
out_uint16_le(s, CS_CORE); /* type */
|
||||
out_uint16_le(s, 216 + (g_dpi > 0 ? 18 : 0)); /* length */
|
||||
out_uint32_le(s, rdpversion); /* version */
|
||||
out_uint16_le(s, g_requested_session_width); /* desktopWidth */
|
||||
out_uint16_le(s, g_requested_session_height); /* desktopHeight */
|
||||
out_uint32_le(s, rdpversion); /* version */
|
||||
out_uint16_le(s, g_requested_session_width); /* desktopWidth */
|
||||
out_uint16_le(s, g_requested_session_height); /* desktopHeight */
|
||||
out_uint16_le(s, RNS_UD_COLOR_8BPP); /* colorDepth */
|
||||
out_uint16_le(s, RNS_UD_SAS_DEL); /* SASSequence */
|
||||
out_uint32_le(s, g_keylayout); /* keyboardLayout */
|
||||
out_uint32_le(s, 2600); /* Client build. We are now 2600 compatible :-) */
|
||||
out_uint32_le(s, g_keylayout); /* keyboardLayout */
|
||||
out_uint32_le(s, 2600); /* Client build. We are now 2600 compatible :-) */
|
||||
|
||||
/* Unicode name of client, padded to 32 bytes */
|
||||
out_utf16s_padded(s, g_hostname, 32, 0x00);
|
||||
|
||||
out_uint32_le(s, g_keyboard_type); /* keyboardType */
|
||||
out_uint32_le(s, g_keyboard_subtype); /* keyboardSubtype */
|
||||
out_uint32_le(s, g_keyboard_functionkeys); /* keyboardFunctionKey */
|
||||
out_uint8s(s, 64); /* imeFileName */
|
||||
out_uint32_le(s, g_keyboard_functionkeys); /* keyboardFunctionKey */
|
||||
out_uint8s(s, 64); /* imeFileName */
|
||||
out_uint16_le(s, RNS_UD_COLOR_8BPP); /* postBeta2ColorDepth (overrides colorDepth) */
|
||||
out_uint16_le(s, 1); /* clientProductId (should be 1) */
|
||||
out_uint32_le(s, 0); /* serialNumber (should be 0) */
|
||||
out_uint16_le(s, 1); /* clientProductId (should be 1) */
|
||||
out_uint32_le(s, 0); /* serialNumber (should be 0) */
|
||||
|
||||
/* highColorDepth (overrides postBeta2ColorDepth). Capped at 24BPP.
|
||||
To get 32BPP sessions, we need to set a capability flag. */
|
||||
@ -452,18 +452,18 @@ sec_out_mcs_connect_initial_pdu(STREAM s, uint32 selected_protocol)
|
||||
if (g_server_depth == 32)
|
||||
capflags |= RNS_UD_CS_WANT_32BPP_SESSION;
|
||||
|
||||
out_uint16_le(s, colorsupport); /* supportedColorDepths */
|
||||
out_uint16_le(s, capflags); /* earlyCapabilityFlags */
|
||||
out_uint8s(s, 64); /* clientDigProductId */
|
||||
out_uint8(s, 0); /* connectionType */
|
||||
out_uint8(s, 0); /* pad */
|
||||
out_uint16_le(s, colorsupport); /* supportedColorDepths */
|
||||
out_uint16_le(s, capflags); /* earlyCapabilityFlags */
|
||||
out_uint8s(s, 64); /* clientDigProductId */
|
||||
out_uint8(s, 0); /* connectionType */
|
||||
out_uint8(s, 0); /* pad */
|
||||
out_uint32_le(s, selected_protocol); /* serverSelectedProtocol */
|
||||
if (g_dpi > 0)
|
||||
{
|
||||
/* Extended client info describing monitor geometry */
|
||||
utils_calculate_dpi_scale_factors(g_requested_session_width, g_requested_session_height, g_dpi,
|
||||
&physwidth, &physheight,
|
||||
&desktopscale, &devicescale);
|
||||
utils_calculate_dpi_scale_factors(g_requested_session_width,
|
||||
g_requested_session_height, g_dpi, &physwidth,
|
||||
&physheight, &desktopscale, &devicescale);
|
||||
out_uint32_le(s, physwidth); /* physicalwidth */
|
||||
out_uint32_le(s, physheight); /* physicalheight */
|
||||
out_uint16_le(s, ORIENTATION_LANDSCAPE); /* Orientation */
|
||||
@ -486,16 +486,16 @@ sec_out_mcs_connect_initial_pdu(STREAM s, uint32 selected_protocol)
|
||||
out_uint32(s, g_redirect_session_id);
|
||||
|
||||
/* Client encryption settings (TS_UD_CS_SEC) */
|
||||
out_uint16_le(s, CS_SECURITY); /* type */
|
||||
out_uint16_le(s, 12); /* length */
|
||||
out_uint16_le(s, CS_SECURITY); /* type */
|
||||
out_uint16_le(s, 12); /* length */
|
||||
out_uint32_le(s, g_encryption ? 0x3 : 0); /* encryptionMethods */
|
||||
out_uint32(s, 0); /* extEncryptionMethods */
|
||||
out_uint32(s, 0); /* extEncryptionMethods */
|
||||
|
||||
/* Channel definitions (TS_UD_CS_NET) */
|
||||
logger(Protocol, Debug, "sec_out_mcs_data(), g_num_channels is %d", g_num_channels);
|
||||
if (g_num_channels > 0)
|
||||
{
|
||||
out_uint16_le(s, CS_NET); /* type */
|
||||
out_uint16_le(s, CS_NET); /* type */
|
||||
out_uint16_le(s, g_num_channels * 12 + 8); /* length */
|
||||
out_uint32_le(s, g_num_channels); /* number of virtual channels */
|
||||
for (i = 0; i < g_num_channels; i++)
|
||||
@ -842,7 +842,7 @@ sec_process_mcs_data(STREAM s)
|
||||
|
||||
/* Receive secure transport packet */
|
||||
STREAM
|
||||
sec_recv(RD_BOOL *is_fastpath)
|
||||
sec_recv(RD_BOOL * is_fastpath)
|
||||
{
|
||||
uint8 fastpath_hdr, fastpath_flags;
|
||||
uint16 sec_flags;
|
||||
@ -869,7 +869,7 @@ sec_recv(RD_BOOL *is_fastpath)
|
||||
{
|
||||
/* TS_SECURITY_HEADER */
|
||||
in_uint16_le(s, sec_flags);
|
||||
in_uint8s(s, 2); /* skip sec_flags_hi */
|
||||
in_uint8s(s, 2); /* skip sec_flags_hi */
|
||||
|
||||
if (g_encryption)
|
||||
{
|
||||
|
152
stream.c
152
stream.c
@ -28,53 +28,53 @@ extern char g_codepage[16];
|
||||
void
|
||||
s_realloc(STREAM s, unsigned int size)
|
||||
{
|
||||
unsigned char *data;
|
||||
unsigned char *data;
|
||||
|
||||
if (s->size >= size)
|
||||
return;
|
||||
if (s->size >= size)
|
||||
return;
|
||||
|
||||
data = s->data;
|
||||
s->size = size;
|
||||
s->data = xrealloc(data, size);
|
||||
s->p = s->data + (s->p - data);
|
||||
s->end = s->data + (s->end - data);
|
||||
s->iso_hdr = s->data + (s->iso_hdr - data);
|
||||
s->mcs_hdr = s->data + (s->mcs_hdr - data);
|
||||
s->sec_hdr = s->data + (s->sec_hdr - data);
|
||||
s->rdp_hdr = s->data + (s->rdp_hdr - data);
|
||||
s->channel_hdr = s->data + (s->channel_hdr - data);
|
||||
data = s->data;
|
||||
s->size = size;
|
||||
s->data = xrealloc(data, size);
|
||||
s->p = s->data + (s->p - data);
|
||||
s->end = s->data + (s->end - data);
|
||||
s->iso_hdr = s->data + (s->iso_hdr - data);
|
||||
s->mcs_hdr = s->data + (s->mcs_hdr - data);
|
||||
s->sec_hdr = s->data + (s->sec_hdr - data);
|
||||
s->rdp_hdr = s->data + (s->rdp_hdr - data);
|
||||
s->channel_hdr = s->data + (s->channel_hdr - data);
|
||||
}
|
||||
|
||||
void
|
||||
s_reset(STREAM s)
|
||||
{
|
||||
struct stream tmp;
|
||||
tmp = *s;
|
||||
memset(s, 0, sizeof(struct stream));
|
||||
s->size = tmp.size;
|
||||
s->end = s->p = s->data = tmp.data;
|
||||
struct stream tmp;
|
||||
tmp = *s;
|
||||
memset(s, 0, sizeof(struct stream));
|
||||
s->size = tmp.size;
|
||||
s->end = s->p = s->data = tmp.data;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
s_free(STREAM s)
|
||||
{
|
||||
free(s->data);
|
||||
free(s);
|
||||
free(s->data);
|
||||
free(s);
|
||||
}
|
||||
|
||||
static iconv_t
|
||||
local_to_utf16()
|
||||
{
|
||||
iconv_t icv;
|
||||
icv = iconv_open(WINDOWS_CODEPAGE, g_codepage);
|
||||
if (icv == (iconv_t) - 1)
|
||||
{
|
||||
logger(Core, Error, "locale_to_utf16(), iconv_open[%s -> %s] fail %p",
|
||||
g_codepage, WINDOWS_CODEPAGE, icv);
|
||||
abort();
|
||||
}
|
||||
return icv;
|
||||
iconv_t icv;
|
||||
icv = iconv_open(WINDOWS_CODEPAGE, g_codepage);
|
||||
if (icv == (iconv_t) - 1)
|
||||
{
|
||||
logger(Core, Error, "locale_to_utf16(), iconv_open[%s -> %s] fail %p",
|
||||
g_codepage, WINDOWS_CODEPAGE, icv);
|
||||
abort();
|
||||
}
|
||||
return icv;
|
||||
}
|
||||
|
||||
/* Writes a utf16 encoded string into stream excluding null termination.
|
||||
@ -83,35 +83,35 @@ local_to_utf16()
|
||||
static inline size_t
|
||||
_out_utf16s(STREAM s, size_t maxlength, const char *string)
|
||||
{
|
||||
static iconv_t icv_local_to_utf16;
|
||||
size_t bl, ibl, obl;
|
||||
const char *pin;
|
||||
char *pout;
|
||||
static iconv_t icv_local_to_utf16;
|
||||
size_t bl, ibl, obl;
|
||||
const char *pin;
|
||||
char *pout;
|
||||
|
||||
if (string == NULL)
|
||||
return 0;
|
||||
if (string == NULL)
|
||||
return 0;
|
||||
|
||||
if (!icv_local_to_utf16)
|
||||
{
|
||||
icv_local_to_utf16 = local_to_utf16();
|
||||
}
|
||||
if (!icv_local_to_utf16)
|
||||
{
|
||||
icv_local_to_utf16 = local_to_utf16();
|
||||
}
|
||||
|
||||
ibl = strlen(string);
|
||||
obl = maxlength ? maxlength : (size_t)s_left(s);
|
||||
pin = string;
|
||||
pout = (char *) s->p;
|
||||
ibl = strlen(string);
|
||||
obl = maxlength ? maxlength : (size_t) s_left(s);
|
||||
pin = string;
|
||||
pout = (char *) s->p;
|
||||
|
||||
if (iconv(icv_local_to_utf16, (char **) &pin, &ibl, &pout, &obl) == (size_t) - 1)
|
||||
{
|
||||
logger(Protocol, Error, "out_utf16s(), iconv(2) fail, errno %d", errno);
|
||||
abort();
|
||||
}
|
||||
if (iconv(icv_local_to_utf16, (char **) &pin, &ibl, &pout, &obl) == (size_t) - 1)
|
||||
{
|
||||
logger(Protocol, Error, "out_utf16s(), iconv(2) fail, errno %d", errno);
|
||||
abort();
|
||||
}
|
||||
|
||||
bl = (unsigned char*)pout - s->p;
|
||||
bl = (unsigned char *) pout - s->p;
|
||||
|
||||
s->p = (unsigned char *)pout;
|
||||
s->p = (unsigned char *) pout;
|
||||
|
||||
return bl;
|
||||
return bl;
|
||||
}
|
||||
|
||||
/* Writes a utf16 encoded string into stream including a null
|
||||
@ -122,15 +122,15 @@ _out_utf16s(STREAM s, size_t maxlength, const char *string)
|
||||
void
|
||||
out_utf16s_padded(STREAM s, const char *string, size_t length, unsigned char pad)
|
||||
{
|
||||
size_t i, bl;
|
||||
bl = _out_utf16s(s, length - 2, string);
|
||||
size_t i, bl;
|
||||
bl = _out_utf16s(s, length - 2, string);
|
||||
|
||||
// append utf16 null termination
|
||||
out_uint16(s, 0);
|
||||
bl += 2;
|
||||
// append utf16 null termination
|
||||
out_uint16(s, 0);
|
||||
bl += 2;
|
||||
|
||||
for (i = 0; i < (length - bl); i++)
|
||||
out_uint8(s, pad);
|
||||
for (i = 0; i < (length - bl); i++)
|
||||
out_uint8(s, pad);
|
||||
}
|
||||
|
||||
/* Writes a utf16 encoded string into stream including a null
|
||||
@ -139,10 +139,10 @@ out_utf16s_padded(STREAM s, const char *string, size_t length, unsigned char pad
|
||||
void
|
||||
out_utf16s(STREAM s, const char *string)
|
||||
{
|
||||
_out_utf16s(s, 0, string);
|
||||
_out_utf16s(s, 0, string);
|
||||
|
||||
// append utf16 null termination
|
||||
out_uint16(s, 0);
|
||||
// append utf16 null termination
|
||||
out_uint16(s, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -151,7 +151,7 @@ out_utf16s(STREAM s, const char *string)
|
||||
void
|
||||
out_utf16s_no_eos(STREAM s, const char *string)
|
||||
{
|
||||
_out_utf16s(s, 0, string);
|
||||
_out_utf16s(s, 0, string);
|
||||
}
|
||||
|
||||
/* Read bytes from STREAM s into *string until a null terminator is
|
||||
@ -160,23 +160,23 @@ out_utf16s_no_eos(STREAM s, const char *string)
|
||||
size_t
|
||||
in_ansi_string(STREAM s, char *string, size_t len)
|
||||
{
|
||||
char *ps;
|
||||
size_t left;
|
||||
ps = string;
|
||||
char *ps;
|
||||
size_t left;
|
||||
ps = string;
|
||||
|
||||
left = len;
|
||||
while(left--)
|
||||
{
|
||||
if (left == 0)
|
||||
break;
|
||||
left = len;
|
||||
while (left--)
|
||||
{
|
||||
if (left == 0)
|
||||
break;
|
||||
|
||||
in_uint8(s, *ps);
|
||||
in_uint8(s, *ps);
|
||||
|
||||
if (*ps == '\0')
|
||||
break;
|
||||
if (*ps == '\0')
|
||||
break;
|
||||
|
||||
ps++;
|
||||
}
|
||||
ps++;
|
||||
}
|
||||
|
||||
return len - left;
|
||||
return len - left;
|
||||
}
|
||||
|
15
tcp.c
15
tcp.c
@ -446,8 +446,7 @@ static RD_BOOL
|
||||
tcp_connect_resolve_hostname(const char *server)
|
||||
{
|
||||
return (g_server_address == NULL ||
|
||||
g_last_server_name == NULL ||
|
||||
strcmp(g_last_server_name, server) != 0);
|
||||
g_last_server_name == NULL || strcmp(g_last_server_name, server) != 0);
|
||||
}
|
||||
|
||||
/* Establish a connection on the TCP layer
|
||||
@ -485,7 +484,8 @@ tcp_connect(char *server)
|
||||
|
||||
if ((n = getaddrinfo(server, tcp_port_rdp_s, &hints, &res)))
|
||||
{
|
||||
logger(Core, Error, "tcp_connect(), getaddrinfo() failed: %s", gai_strerror(n));
|
||||
logger(Core, Error, "tcp_connect(), getaddrinfo() failed: %s",
|
||||
gai_strerror(n));
|
||||
return False;
|
||||
}
|
||||
}
|
||||
@ -505,10 +505,12 @@ tcp_connect(char *server)
|
||||
continue;
|
||||
}
|
||||
|
||||
n = getnameinfo(addr->ai_addr, addr->ai_addrlen, buf, sizeof(buf), NULL, 0, NI_NUMERICHOST);
|
||||
n = getnameinfo(addr->ai_addr, addr->ai_addrlen, buf, sizeof(buf), NULL, 0,
|
||||
NI_NUMERICHOST);
|
||||
if (n != 0)
|
||||
{
|
||||
logger(Core, Error, "tcp_connect(), getnameinfo() failed: %s", gai_strerror(n));
|
||||
logger(Core, Error, "tcp_connect(), getnameinfo() failed: %s",
|
||||
gai_strerror(n));
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -581,8 +583,7 @@ tcp_connect(char *server)
|
||||
|
||||
logger(Core, Debug, "tcp_connect(), trying %s (%s)",
|
||||
server, inet_ntop(g_server_address->sin_family,
|
||||
&g_server_address->sin_addr,
|
||||
buf, sizeof(buf)));
|
||||
&g_server_address->sin_addr, buf, sizeof(buf)));
|
||||
|
||||
if (connect(g_sock, (struct sockaddr *) g_server_address, sizeof(struct sockaddr)) < 0)
|
||||
{
|
||||
|
3
types.h
3
types.h
@ -308,7 +308,8 @@ FILEINFO;
|
||||
|
||||
typedef RD_BOOL(*str_handle_lines_t) (const char *line, void *data);
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
Fixed,
|
||||
PercentageOfScreen,
|
||||
Workarea,
|
||||
|
10
utils.c
10
utils.c
@ -38,7 +38,7 @@ utils_djb2_hash(const char *str)
|
||||
uint8 *pstr;
|
||||
uint32 hash = 5381;
|
||||
|
||||
pstr = (uint8*)str;
|
||||
pstr = (uint8 *) str;
|
||||
while ((c = *pstr++))
|
||||
{
|
||||
hash = ((hash << 5) + hash) + c;
|
||||
@ -107,7 +107,7 @@ utils_string_unescape(const char *str)
|
||||
{
|
||||
if (sscanf(ps, "%%%2hhX", &c) == 1)
|
||||
{
|
||||
pd[0] = (char)c;
|
||||
pd[0] = (char) c;
|
||||
ps += 3;
|
||||
pd++;
|
||||
continue;
|
||||
@ -238,8 +238,8 @@ utils_locale_to_utf8(const char *src, size_t is, char *dest, size_t os)
|
||||
|
||||
void
|
||||
utils_calculate_dpi_scale_factors(uint32 width, uint32 height, uint32 dpi,
|
||||
uint32 *physwidth, uint32 *physheight,
|
||||
uint32 *desktopscale, uint32 *devicescale)
|
||||
uint32 * physwidth, uint32 * physheight,
|
||||
uint32 * desktopscale, uint32 * devicescale)
|
||||
{
|
||||
*physwidth = *physheight = *desktopscale = *devicescale = 0;
|
||||
|
||||
@ -261,7 +261,7 @@ utils_calculate_dpi_scale_factors(uint32 width, uint32 height, uint32 dpi,
|
||||
|
||||
|
||||
void
|
||||
utils_apply_session_size_limitations(uint32 *width, uint32 *height)
|
||||
utils_apply_session_size_limitations(uint32 * width, uint32 * height)
|
||||
{
|
||||
/* width MUST be even number */
|
||||
*width -= (*width) % 2;
|
||||
|
6
utils.h
6
utils.h
@ -29,9 +29,9 @@ int utils_locale_to_utf8(const char *src, size_t is, char *dest, size_t os);
|
||||
int utils_mkdir_safe(const char *path, int mask);
|
||||
int utils_mkdir_p(const char *path, int mask);
|
||||
void utils_calculate_dpi_scale_factors(uint32 width, uint32 height, uint32 dpi,
|
||||
uint32 *physwidth, uint32 *physheight,
|
||||
uint32 *desktopscale, uint32 *devicescale);
|
||||
void utils_apply_session_size_limitations(uint32 *width, uint32 *height);
|
||||
uint32 * physwidth, uint32 * physheight,
|
||||
uint32 * desktopscale, uint32 * devicescale);
|
||||
void utils_apply_session_size_limitations(uint32 * width, uint32 * height);
|
||||
|
||||
|
||||
typedef enum log_level_t
|
||||
|
125
xwin.c
125
xwin.c
@ -69,7 +69,7 @@ extern int g_server_depth;
|
||||
extern int g_win_button_size;
|
||||
|
||||
/* This is a timer used to rate limit actual resizing */
|
||||
static struct timeval g_resize_timer = {0};
|
||||
static struct timeval g_resize_timer = { 0 };
|
||||
|
||||
Display *g_display;
|
||||
Time g_last_gesturetime;
|
||||
@ -1573,7 +1573,9 @@ xwin_refresh_pointer_map(void)
|
||||
int i;
|
||||
unsigned int pointer_buttons;
|
||||
|
||||
pointer_buttons = (unsigned int)XGetPointerMapping(g_display, phys_to_log_map, sizeof(phys_to_log_map));
|
||||
pointer_buttons =
|
||||
(unsigned int) XGetPointerMapping(g_display, phys_to_log_map,
|
||||
sizeof(phys_to_log_map));
|
||||
if (pointer_buttons > sizeof(phys_to_log_map))
|
||||
pointer_buttons = sizeof(phys_to_log_map);
|
||||
|
||||
@ -1878,7 +1880,7 @@ set_wm_client_machine(Display * dpy, Window win)
|
||||
if (gethostname(hostname, sizeof(hostname)) != 0)
|
||||
return;
|
||||
|
||||
tp.value = (unsigned char *)hostname;
|
||||
tp.value = (unsigned char *) hostname;
|
||||
tp.nitems = strlen(hostname);
|
||||
tp.encoding = XA_STRING;
|
||||
tp.format = 8;
|
||||
@ -1967,23 +1969,23 @@ ui_init(void)
|
||||
}
|
||||
|
||||
void
|
||||
ui_get_screen_size(uint32 *width, uint32 *height)
|
||||
ui_get_screen_size(uint32 * width, uint32 * height)
|
||||
{
|
||||
*width = WidthOfScreen(g_screen);
|
||||
*height = HeightOfScreen(g_screen);
|
||||
*width = WidthOfScreen(g_screen);
|
||||
*height = HeightOfScreen(g_screen);
|
||||
}
|
||||
|
||||
void
|
||||
ui_get_screen_size_from_percentage(uint32 pw, uint32 ph, uint32 *width, uint32 *height)
|
||||
ui_get_screen_size_from_percentage(uint32 pw, uint32 ph, uint32 * width, uint32 * height)
|
||||
{
|
||||
uint32 sw,sh;
|
||||
uint32 sw, sh;
|
||||
ui_get_screen_size(&sw, &sh);
|
||||
*width = sw * pw / 100;
|
||||
*height = sh * ph / 100;
|
||||
}
|
||||
|
||||
void
|
||||
ui_get_workarea_size(uint32 *width, uint32 *height)
|
||||
ui_get_workarea_size(uint32 * width, uint32 * height)
|
||||
{
|
||||
uint32 x, y, w, h;
|
||||
if (get_current_workarea(&x, &y, &w, &h) == 0)
|
||||
@ -2010,7 +2012,7 @@ ui_deinit(void)
|
||||
XCloseIM(g_IM);
|
||||
|
||||
if (g_null_cursor != NULL)
|
||||
XFreeCursor(g_display, (Cursor)g_null_cursor);
|
||||
XFreeCursor(g_display, (Cursor) g_null_cursor);
|
||||
|
||||
XFreeModifiermap(g_mod_map);
|
||||
|
||||
@ -2059,7 +2061,7 @@ get_input_mask(long *input_mask)
|
||||
}
|
||||
|
||||
static void
|
||||
get_sizehints(XSizeHints *sizehints, uint32 width, uint32 height)
|
||||
get_sizehints(XSizeHints * sizehints, uint32 width, uint32 height)
|
||||
{
|
||||
if (sizehints == NULL)
|
||||
return;
|
||||
@ -2075,7 +2077,7 @@ get_sizehints(XSizeHints *sizehints, uint32 width, uint32 height)
|
||||
|
||||
/* resize increment */
|
||||
sizehints->flags |= PResizeInc;
|
||||
sizehints->width_inc = 2; /* session width must be divisible by two */
|
||||
sizehints->width_inc = 2; /* session width must be divisible by two */
|
||||
sizehints->height_inc = 1;
|
||||
|
||||
if (g_seamless_rdp || !g_dynamic_session_resize)
|
||||
@ -2242,13 +2244,14 @@ ui_resize_window(uint32 width, uint32 height)
|
||||
|
||||
XGetWindowAttributes(g_display, g_wnd, &attr);
|
||||
|
||||
if ((attr.width == (int)width && attr.height == (int)height))
|
||||
if ((attr.width == (int) width && attr.height == (int) height))
|
||||
{
|
||||
/* no-op */
|
||||
return;
|
||||
}
|
||||
|
||||
logger(GUI, Debug, "ui_resize_window(), Changing window %dx%d to match new session %dx%d size",
|
||||
logger(GUI, Debug,
|
||||
"ui_resize_window(), Changing window %dx%d to match new session %dx%d size",
|
||||
attr.width, attr.height, width, height);
|
||||
|
||||
sizehints = XAllocSizeHints();
|
||||
@ -2330,7 +2333,7 @@ xwin_toggle_fullscreen(void)
|
||||
|
||||
XTranslateCoordinates(g_display, g_wnd,
|
||||
DefaultRootWindow(g_display),
|
||||
0, 0, &dest_x, &dest_y, &unused );
|
||||
0, 0, &dest_x, &dest_y, &unused);
|
||||
|
||||
windowed_x = dest_x;
|
||||
windowed_y = dest_y;
|
||||
@ -2553,7 +2556,7 @@ xwin_process_events(void)
|
||||
case ClientMessage:
|
||||
if (xevent.xclient.message_type == g_protocol_atom)
|
||||
{
|
||||
if (xevent.xclient.data.l[0] == (long)g_kill_atom)
|
||||
if (xevent.xclient.data.l[0] == (long) g_kill_atom)
|
||||
{
|
||||
/* the window manager told us to quit */
|
||||
|
||||
@ -2566,7 +2569,8 @@ xwin_process_events(void)
|
||||
/* send seamless destroy process message */
|
||||
seamless_send_destroy(sw->id);
|
||||
}
|
||||
else if (xevent.xclient.data.l[0] == (long)g_net_wm_ping_atom)
|
||||
else if (xevent.xclient.data.l[0] ==
|
||||
(long) g_net_wm_ping_atom)
|
||||
{
|
||||
/* pass ping message further to root window */
|
||||
xevent.xclient.window =
|
||||
@ -2822,7 +2826,8 @@ xwin_process_events(void)
|
||||
g_window_width = attr.width;
|
||||
g_window_height = attr.height;
|
||||
|
||||
logger(GUI, Debug, "xwin_process_events(), Window mapped with size %dx%d",
|
||||
logger(GUI, Debug,
|
||||
"xwin_process_events(), Window mapped with size %dx%d",
|
||||
g_window_width, g_window_height);
|
||||
|
||||
is_g_wnd_mapped = True;
|
||||
@ -2851,11 +2856,12 @@ xwin_process_events(void)
|
||||
{
|
||||
/* only for fullscreen or x%-of-screen-sized windows */
|
||||
if (g_window_size_type == PercentageOfScreen
|
||||
|| g_window_size_type == Fullscreen
|
||||
|| g_fullscreen)
|
||||
|| g_window_size_type == Fullscreen || g_fullscreen)
|
||||
{
|
||||
if (xevent.xconfigure.width != WidthOfScreen(g_screen)
|
||||
|| xevent.xconfigure.height != HeightOfScreen(g_screen))
|
||||
if (xevent.xconfigure.width !=
|
||||
WidthOfScreen(g_screen)
|
||||
|| xevent.xconfigure.height !=
|
||||
HeightOfScreen(g_screen))
|
||||
{
|
||||
|
||||
logger(GUI, Debug,
|
||||
@ -2868,7 +2874,10 @@ xwin_process_events(void)
|
||||
/* Resize fullscreen window to match root window size */
|
||||
/* TODO: Handle percentage of screen */
|
||||
if (g_fullscreen)
|
||||
ui_resize_window(xevent.xconfigure.width, xevent.xconfigure.height);
|
||||
ui_resize_window(xevent.xconfigure.
|
||||
width,
|
||||
xevent.xconfigure.
|
||||
height);
|
||||
g_pending_resize = True;
|
||||
}
|
||||
}
|
||||
@ -2876,9 +2885,11 @@ xwin_process_events(void)
|
||||
XRRUpdateConfiguration(&xevent);
|
||||
XSync(g_display, False);
|
||||
|
||||
} else
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (xevent.xconfigure.window == g_wnd && !g_seamless_rdp && is_g_wnd_mapped)
|
||||
if (xevent.xconfigure.window == g_wnd && !g_seamless_rdp
|
||||
&& is_g_wnd_mapped)
|
||||
{
|
||||
|
||||
/* Update window size */
|
||||
@ -2891,21 +2902,17 @@ xwin_process_events(void)
|
||||
|
||||
utils_apply_session_size_limitations(&w, &h);
|
||||
|
||||
logger(GUI, Debug, "xwin_process_events(), ConfigureNotify: session: %dx%d, new window: %dx%d (adj: %dx%d)",
|
||||
g_session_width,
|
||||
g_session_height,
|
||||
g_window_width,
|
||||
g_window_height,
|
||||
w, h);
|
||||
logger(GUI, Debug,
|
||||
"xwin_process_events(), ConfigureNotify: session: %dx%d, new window: %dx%d (adj: %dx%d)",
|
||||
g_session_width, g_session_height, g_window_width,
|
||||
g_window_height, w, h);
|
||||
|
||||
if (g_session_width != w
|
||||
|| g_session_height != h)
|
||||
if (g_session_width != w || g_session_height != h)
|
||||
{
|
||||
logger(GUI, Debug, "xwin_process_events(), ConfigureNotify: session: %dx%d, new window: %dx%d",
|
||||
g_session_width,
|
||||
g_session_height,
|
||||
g_window_width,
|
||||
g_window_height);
|
||||
logger(GUI, Debug,
|
||||
"xwin_process_events(), ConfigureNotify: session: %dx%d, new window: %dx%d",
|
||||
g_session_width, g_session_height,
|
||||
g_window_width, g_window_height);
|
||||
|
||||
/* perform a resize */
|
||||
gettimeofday(&g_resize_timer, NULL);
|
||||
@ -2994,8 +3001,7 @@ process_fds(int rdp_socket, int ms)
|
||||
{
|
||||
if (ret == -1)
|
||||
{
|
||||
logger(GUI, Error, "process_fds(), select failed: %s",
|
||||
strerror(errno));
|
||||
logger(GUI, Error, "process_fds(), select failed: %s", strerror(errno));
|
||||
}
|
||||
#ifdef WITH_RDPSND
|
||||
rdpsnd_check_fds(&rfds, &wfds);
|
||||
@ -3037,14 +3043,14 @@ timeval_is_set(struct timeval *time)
|
||||
RDPEDISP so in this case we defer until the RDPEDISP channel is established.
|
||||
*/
|
||||
static RD_BOOL
|
||||
process_pending_resize ()
|
||||
process_pending_resize()
|
||||
{
|
||||
time_t now_ts;
|
||||
struct timeval now;
|
||||
|
||||
/* Rate limit ConfigureNotify events before performing a
|
||||
resize - enough time has to pass after the last event
|
||||
*/
|
||||
*/
|
||||
gettimeofday(&now, NULL);
|
||||
if (time_difference_in_ms(g_resize_timer, now) <= 500)
|
||||
return False;
|
||||
@ -3064,7 +3070,7 @@ process_pending_resize ()
|
||||
defer timer is cleared, so there will be no delay before
|
||||
the first resize for servers that support RDPEDISP. Other
|
||||
servers will get the initial resize delayed with 2 seconds.
|
||||
*/
|
||||
*/
|
||||
|
||||
if (timeval_is_set(&g_pending_resize_defer_timer) &&
|
||||
time_difference_in_ms(g_pending_resize_defer_timer, now) >= 2000)
|
||||
@ -3104,8 +3110,7 @@ process_pending_resize ()
|
||||
*/
|
||||
|
||||
logger(GUI, Verbose, "Window resize detected, reconnecting to new size %dx%d",
|
||||
g_requested_session_width,
|
||||
g_requested_session_height);
|
||||
g_requested_session_width, g_requested_session_height);
|
||||
|
||||
return True;
|
||||
}
|
||||
@ -3115,12 +3120,11 @@ process_pending_resize ()
|
||||
if (now_ts - g_wait_for_deactivate_ts <= 5)
|
||||
return False;
|
||||
|
||||
logger(GUI, Verbose, "Window resize detected, requesting matching session size %dx%d",
|
||||
g_requested_session_width,
|
||||
g_requested_session_height);
|
||||
logger(GUI, Verbose,
|
||||
"Window resize detected, requesting matching session size %dx%d",
|
||||
g_requested_session_width, g_requested_session_height);
|
||||
|
||||
rdpedisp_set_session_size(g_requested_session_width,
|
||||
g_requested_session_height);
|
||||
rdpedisp_set_session_size(g_requested_session_width, g_requested_session_height);
|
||||
|
||||
g_pending_resize = False;
|
||||
g_wait_for_deactivate_ts = now_ts;
|
||||
@ -3182,7 +3186,7 @@ ui_select(int rdp_socket)
|
||||
Use 60 seconds as default timeout for select. If
|
||||
there is more X11 events on queue or g_pend is set,
|
||||
use a low timeout.
|
||||
*/
|
||||
*/
|
||||
|
||||
timeout = 60000;
|
||||
|
||||
@ -3349,10 +3353,10 @@ get_pixel(uint32 idx, uint8 * andmask, uint8 * xormask, int bpp, uint8 * xor_fla
|
||||
argb = (alpha << 24) | (argb ? 0xffffff : 0x000000);
|
||||
break;
|
||||
|
||||
case 16:
|
||||
case 16:
|
||||
offs = idx * 2;
|
||||
pxor = xormask + offs;
|
||||
SPLITCOLOUR16(*((uint16*)pxor), pc);
|
||||
SPLITCOLOUR16(*((uint16 *) pxor), pc);
|
||||
alpha = GET_BIT(andmask, idx) ? 0x00 : 0xff;
|
||||
argb = (alpha << 24) | (pc.red << 16) | (pc.green << 8) | pc.blue;
|
||||
break;
|
||||
@ -3382,17 +3386,17 @@ xcursor_stencil(XcursorImage * src, XcursorImage * dst, int dx, int dy, uint32 a
|
||||
assert(src->width == dst->width);
|
||||
assert(src->height == dst->height);
|
||||
|
||||
for (y = 0; y < (int)src->height; y++)
|
||||
for (y = 0; y < (int) src->height; y++)
|
||||
{
|
||||
for (x = 0; x < (int)src->width; x++)
|
||||
for (x = 0; x < (int) src->width; x++)
|
||||
{
|
||||
si = y * src->width + x;
|
||||
if (!src->pixels[si])
|
||||
continue;
|
||||
|
||||
if ((y + dy) < 0 || (y + dy) >= (int)dst->height)
|
||||
if ((y + dy) < 0 || (y + dy) >= (int) dst->height)
|
||||
continue;
|
||||
if ((x + dx) < 0 || (x + dx) >= (int)dst->width)
|
||||
if ((x + dx) < 0 || (x + dx) >= (int) dst->width)
|
||||
continue;
|
||||
di = (y + dy) * src->width + (x + dx);
|
||||
dst->pixels[di] = argb;
|
||||
@ -3498,7 +3502,8 @@ void
|
||||
ui_set_cursor(RD_HCURSOR cursor)
|
||||
{
|
||||
extern RD_BOOL g_local_cursor;
|
||||
if (g_local_cursor) return ;
|
||||
if (g_local_cursor)
|
||||
return;
|
||||
logger(GUI, Debug, "ui_set_cursor(): g_current_cursor = %p, new = %p",
|
||||
g_current_cursor, cursor);
|
||||
|
||||
@ -4519,8 +4524,8 @@ ui_seamless_create_window(unsigned long id, unsigned long group, unsigned long p
|
||||
if (sw_parent)
|
||||
XSetTransientForHint(g_display, wnd, sw_parent->wnd);
|
||||
else
|
||||
logger(GUI, Warning, "ui_seamless_create_window(): no parent window 0x%lx\n",
|
||||
parent);
|
||||
logger(GUI, Warning,
|
||||
"ui_seamless_create_window(): no parent window 0x%lx\n", parent);
|
||||
}
|
||||
|
||||
if (flags & SEAMLESSRDP_CREATE_MODAL)
|
||||
|
Loading…
Reference in New Issue
Block a user