summaryrefslogtreecommitdiffstats
path: root/sesman/chansrv
diff options
context:
space:
mode:
authorLaxmikant Rashinkar <lk@Ubuntu-12.04-32bit>2014-10-18 11:22:24 -0700
committerLaxmikant Rashinkar <lk@Ubuntu-12.04-32bit>2014-10-18 11:22:24 -0700
commita3e017cd580f5a45af742b330cb453152e131e21 (patch)
treef0aa94ece09348f667906f63d830c98d929d3e87 /sesman/chansrv
parent4ddda1554f4de12bda15314a723bcb49d2f5dc11 (diff)
downloadxrdp-proprietary-a3e017cd580f5a45af742b330cb453152e131e21.tar.gz
xrdp-proprietary-a3e017cd580f5a45af742b330cb453152e131e21.zip
restart listener when corresponding sound source/sink connections are closed
Diffstat (limited to 'sesman/chansrv')
-rw-r--r--sesman/chansrv/sound.c81
1 files changed, 48 insertions, 33 deletions
diff --git a/sesman/chansrv/sound.c b/sesman/chansrv/sound.c
index b4e0a384..63e4f037 100644
--- a/sesman/chansrv/sound.c
+++ b/sesman/chansrv/sound.c
@@ -146,23 +146,18 @@ static int g_client_input_format_index = 0;
static int g_server_input_format_index = 0;
/* microphone related */
-static int APP_CC
-sound_send_server_input_formats(void);
-static int APP_CC
-sound_process_input_format(int aindex, int wFormatTag,
+static int APP_CC sound_send_server_input_formats(void);
+static int APP_CC sound_process_input_format(int aindex, int wFormatTag,
int nChannels, int nSamplesPerSec,
int nAvgBytesPerSec, int nBlockAlign,
int wBitsPerSample, int cbSize, char *data);
-static int APP_CC
-sound_process_input_formats(struct stream *s, int size);
-static int APP_CC
-sound_input_start_recording(void);
-static int APP_CC
-sound_input_stop_recording(void);
-static int APP_CC
-sound_process_input_data(struct stream *s, int bytes);
-static int DEFAULT_CC
-sound_sndsrvr_source_data_in(struct trans *trans);
+static int APP_CC sound_process_input_formats(struct stream *s, int size);
+static int APP_CC sound_input_start_recording(void);
+static int APP_CC sound_input_stop_recording(void);
+static int APP_CC sound_process_input_data(struct stream *s, int bytes);
+static int DEFAULT_CC sound_sndsrvr_source_data_in(struct trans *trans);
+static int APP_CC sound_start_source_listener();
+static int APP_CC sound_start_sink_listener();
/*****************************************************************************/
static int APP_CC
@@ -682,8 +677,6 @@ sound_sndsrvr_source_conn_in(struct trans *trans, struct trans *new_trans)
int APP_CC
sound_init(void)
{
- char port[256];
-
LOG(0, ("sound_init:"));
g_memset(g_sent_flag, 0, sizeof(g_sent_flag));
@@ -691,25 +684,11 @@ sound_init(void)
/* init sound output */
sound_send_server_output_formats();
-
- g_audio_l_trans_out = trans_create(TRANS_MODE_UNIX, 128 * 1024, 8192);
- g_audio_l_trans_out->is_term = g_is_term;
- g_snprintf(port, 255, CHANSRV_PORT_OUT_STR, g_display_num);
- g_audio_l_trans_out->trans_conn_in = sound_sndsrvr_sink_conn_in;
-
- if (trans_listen(g_audio_l_trans_out, port) != 0)
- LOG(0, ("sound_init: trans_listen failed"));
+ sound_start_sink_listener();
/* init sound input */
sound_send_server_input_formats();
-
- g_audio_l_trans_in = trans_create(TRANS_MODE_UNIX, 128 * 1024, 8192);
- g_audio_l_trans_in->is_term = g_is_term;
- g_snprintf(port, 255, CHANSRV_PORT_IN_STR, g_display_num);
- g_audio_l_trans_in->trans_conn_in = sound_sndsrvr_source_conn_in;
-
- if (trans_listen(g_audio_l_trans_in, port) != 0)
- LOG(0, ("sound_init: trans_listen failed"));
+ sound_start_source_listener();
/* save data from sound_server_source */
fifo_init(&in_fifo, 100);
@@ -850,7 +829,6 @@ sound_get_wait_objs(tbus *objs, int *count, int *timeout)
int APP_CC
sound_check_wait_objs(void)
{
-
if (g_audio_l_trans_out != 0)
{
if (trans_check_wait_objs(g_audio_l_trans_out) != 0)
@@ -868,6 +846,7 @@ sound_check_wait_objs(void)
LOG(10, ("sound_check_wait_objs: g_audio_c_trans_out returned non-zero"));
trans_delete(g_audio_c_trans_out);
g_audio_c_trans_out = 0;
+ sound_start_sink_listener();
}
}
@@ -888,6 +867,7 @@ sound_check_wait_objs(void)
LOG(10, ("sound_check_wait_objs: g_audio_c_trans_in returned non-zero"));
trans_delete(g_audio_c_trans_in);
g_audio_c_trans_in = 0;
+ sound_start_source_listener();
}
}
@@ -1228,3 +1208,38 @@ sound_sndsrvr_source_data_in(struct trans *trans)
return 0;
}
+
+/**
+ * Start a listener for microphone redirection connections
+ *****************************************************************************/
+static int APP_CC
+sound_start_source_listener()
+{
+ char port[1024];
+
+ g_audio_l_trans_in = trans_create(TRANS_MODE_UNIX, 128 * 1024, 8192);
+ g_audio_l_trans_in->is_term = g_is_term;
+ g_snprintf(port, 255, CHANSRV_PORT_IN_STR, g_display_num);
+ g_audio_l_trans_in->trans_conn_in = sound_sndsrvr_source_conn_in;
+ if (trans_listen(g_audio_l_trans_in, port) != 0)
+ LOG(0, ("trans_listen failed"));
+ return 0;
+}
+
+/**
+ * Start a listener for speaker redirection connections
+ *****************************************************************************/
+static int APP_CC
+sound_start_sink_listener()
+{
+ char port[1024];
+
+ g_audio_l_trans_out = trans_create(TRANS_MODE_UNIX, 128 * 1024, 8192);
+ g_audio_l_trans_out->is_term = g_is_term;
+ g_snprintf(port, 255, CHANSRV_PORT_OUT_STR, g_display_num);
+ g_audio_l_trans_out->trans_conn_in = sound_sndsrvr_sink_conn_in;
+ if (trans_listen(g_audio_l_trans_out, port) != 0)
+ LOG(0, ("trans_listen failed"));
+ return 0;
+}
+