Browse Source

pass sockets names via environment variable

now this module no longer depends on xrdp headers.
pull/15/head
Koichiro IWAO 6 years ago
parent
commit
6509fea778
2 changed files with 20 additions and 10 deletions
  1. +10
    -5
      src/module-xrdp-sink.c
  2. +10
    -5
      src/module-xrdp-source.c

+ 10
- 5
src/module-xrdp-sink.c View File

@ -59,9 +59,6 @@
#include <pulsecore/thread-mq.h> #include <pulsecore/thread-mq.h>
#include <pulsecore/rtpoll.h> #include <pulsecore/rtpoll.h>
#include <xrdp_sockets.h>
/* defined in pulse/version.h */ /* defined in pulse/version.h */
#if PA_PROTOCOL_VERSION > 28 #if PA_PROTOCOL_VERSION > 28
/* these used to be defined in pulsecore/macro.h */ /* these used to be defined in pulsecore/macro.h */
@ -297,6 +294,7 @@ static int lsend(int fd, char *data, int bytes) {
static int data_send(struct userdata *u, pa_memchunk *chunk) { static int data_send(struct userdata *u, pa_memchunk *chunk) {
char *data; char *data;
char *socket_dir; char *socket_dir;
char *sink_socket;
int bytes; int bytes;
int sent; int sent;
int fd; int fd;
@ -318,9 +316,16 @@ static int data_send(struct userdata *u, pa_memchunk *chunk) {
{ {
socket_dir = "/tmp/.xrdp"; socket_dir = "/tmp/.xrdp";
} }
snprintf(s.sun_path, bytes, "%s/" CHANSRV_PORT_OUT_BASE_STR,
socket_dir, u->display_num);
sink_socket = getenv("CHANSRV_PULSE_SINK_SOCKET");
if (sink_socket == NULL || sink_socket[0] == '\0')
{
/* usually it doesn't reach here. if the socket name is not given
via environment variable, use hardcoded name as fallback */
snprintf(sink_socket, bytes, "xrdp_chansrv_audio_out_socket_%d", u->display_num);
}
snprintf(s.sun_path, bytes, "%s/%s", socket_dir, sink_socket);
pa_log_debug("trying to connect to %s", s.sun_path); pa_log_debug("trying to connect to %s", s.sun_path);
if (connect(fd, (struct sockaddr *)&s, if (connect(fd, (struct sockaddr *)&s,
sizeof(struct sockaddr_un)) != 0) { sizeof(struct sockaddr_un)) != 0) {
u->failed_connect_time = pa_rtclock_now(); u->failed_connect_time = pa_rtclock_now();


+ 10
- 5
src/module-xrdp-source.c View File

@ -46,9 +46,6 @@
#include <pulsecore/thread-mq.h> #include <pulsecore/thread-mq.h>
#include <pulsecore/thread.h> #include <pulsecore/thread.h>
#include <xrdp_sockets.h>
/* defined in pulse/version.h */ /* defined in pulse/version.h */
#if PA_PROTOCOL_VERSION > 28 #if PA_PROTOCOL_VERSION > 28
/* these used to be defined in pulsecore/macro.h */ /* these used to be defined in pulsecore/macro.h */
@ -181,6 +178,7 @@ static int data_get(struct userdata *u, pa_memchunk *chunk) {
struct sockaddr_un s; struct sockaddr_un s;
char *data; char *data;
char *socket_dir; char *socket_dir;
char *source_socket;
char buf[11]; char buf[11];
unsigned char ubuf[10]; unsigned char ubuf[10];
@ -195,8 +193,15 @@ static int data_get(struct userdata *u, pa_memchunk *chunk) {
{ {
socket_dir = "/tmp/.xrdp"; socket_dir = "/tmp/.xrdp";
} }
snprintf(s.sun_path, bytes, "%s/" CHANSRV_PORT_IN_BASE_STR,
socket_dir, u->display_num);
source_socket = getenv("CHANSRV_PULSE_SINK_SOCKET");
if (source_socket == NULL || source_socket[0] == '\0')
{
/* usually it doesn't reach here. if the socket name is not given
via environment variable, use hardcoded name as fallback */
snprintf(source_socket, bytes, "xrdp_chansrv_audio_in_socket_%d", u->display_num);
}
snprintf(s.sun_path, bytes, "%s/%s", socket_dir, source_socket);
pa_log_debug("Trying to connect to %s", s.sun_path); pa_log_debug("Trying to connect to %s", s.sun_path);
if (connect(fd, (struct sockaddr *) &s, sizeof(struct sockaddr_un)) != 0) { if (connect(fd, (struct sockaddr *) &s, sizeof(struct sockaddr_un)) != 0) {


Loading…
Cancel
Save