summaryrefslogtreecommitdiffstats
path: root/sesman/chansrv
diff options
context:
space:
mode:
authorJay Sorg <jay.sorg@gmail.com>2013-04-28 22:37:47 -0700
committerJay Sorg <jay.sorg@gmail.com>2013-04-28 22:37:47 -0700
commit6d5ffee12b3627e724d4693366efc38fb1d121c2 (patch)
tree5642a653034bf10b7ab7f6f565489adbf85d78c1 /sesman/chansrv
parent8acdc403e3105274641c225a11129e529e7ae667 (diff)
downloadxrdp-proprietary-6d5ffee12b3627e724d4693366efc38fb1d121c2.tar.gz
xrdp-proprietary-6d5ffee12b3627e724d4693366efc38fb1d121c2.zip
work on pulse sink, added close message
Diffstat (limited to 'sesman/chansrv')
-rw-r--r--sesman/chansrv/pulse/module-xrdp-sink.c25
-rw-r--r--sesman/chansrv/sound.c40
2 files changed, 63 insertions, 2 deletions
diff --git a/sesman/chansrv/pulse/module-xrdp-sink.c b/sesman/chansrv/pulse/module-xrdp-sink.c
index 92f4b674..bcab8f1b 100644
--- a/sesman/chansrv/pulse/module-xrdp-sink.c
+++ b/sesman/chansrv/pulse/module-xrdp-sink.c
@@ -108,6 +108,8 @@ static const char* const valid_modargs[] = {
NULL
};
+static int close_send(struct userdata *u);
+
static int sink_process_msg(pa_msgobject *o, int code, void *data,
int64_t offset, pa_memchunk *chunk) {
@@ -141,6 +143,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data,
u->timestamp = pa_rtclock_now();
} else {
pa_log("sink_process_msg: not running");
+ close_send(u);
}
break;
@@ -330,6 +333,28 @@ static int data_send(struct userdata *u, pa_memchunk *chunk) {
return sent;
}
+static int close_send(struct userdata *u) {
+ struct header h;
+
+ pa_log("close_send:");
+ if (u->fd == 0) {
+ return 0;
+ }
+
+ h.code = 1;
+ h.bytes = 8;
+ if (send(u->fd, &h, 8, 0) != 8) {
+ pa_log("close_send: send failed");
+ close(u->fd);
+ u->fd = 0;
+ return 0;
+ } else {
+ //pa_log("close_send: sent header ok");
+ }
+
+ return 8;
+}
+
static void process_render(struct userdata *u, pa_usec_t now) {
pa_memchunk chunk;
int request_bytes;
diff --git a/sesman/chansrv/sound.c b/sesman/chansrv/sound.c
index 03ac8e50..9c76242d 100644
--- a/sesman/chansrv/sound.c
+++ b/sesman/chansrv/sound.c
@@ -213,6 +213,31 @@ sound_send_wave_data(char *data, int data_bytes)
}
/*****************************************************************************/
+static int
+sound_send_close(void)
+{
+ struct stream *s;
+ int bytes;
+ char *size_ptr;
+
+ print_got_here();
+
+ make_stream(s);
+ init_stream(s, 8182);
+ out_uint16_le(s, SNDC_CLOSE);
+ size_ptr = s->p;
+ out_uint16_le(s, 0); /* size, set later */
+ s_mark_end(s);
+ bytes = (int)((s->end - s->data) - 4);
+ size_ptr[0] = bytes;
+ size_ptr[1] = bytes >> 8;
+ bytes = (int)(s->end - s->data);
+ send_channel_data(g_rdpsnd_chan_id, s->data, bytes);
+ free_stream(s);
+ return 0;
+}
+
+/*****************************************************************************/
static int APP_CC
sound_process_training(struct stream *s, int size)
{
@@ -249,7 +274,18 @@ process_pcm_message(int id, int size, struct stream *s)
{
print_got_here();
- sound_send_wave_data(s->p, size);
+ switch (id)
+ {
+ case 0:
+ sound_send_wave_data(s->p, size);
+ break;
+ case 1:
+ sound_send_close();
+ break;
+ default:
+ LOG(0, ("process_pcm_message: unknown id %d", id));
+ break;
+ }
return 0;
}
@@ -277,7 +313,7 @@ sound_trans_audio_data_in(struct trans *trans)
in_uint32_le(s, id);
in_uint32_le(s, size);
- if ((id != 0) || (size > 128 * 1024 + 8) || (size < 8))
+ if ((id & 3) || (size > 128 * 1024 + 8) || (size < 8))
{
LOG(0, ("sound_trans_audio_data_in: bad message id %d size %d", id, size));
return 1;