diff options
author | Jay Sorg <jay.sorg@gmail.com> | 2014-11-26 16:48:37 -0800 |
---|---|---|
committer | Jay Sorg <jay.sorg@gmail.com> | 2014-11-26 16:48:37 -0800 |
commit | bff2009147c3262024c0ac20347ea55c6d4369be (patch) | |
tree | 93972103ae329c024d33b5b19485276699726903 /sesman/chansrv/pulse/module-xrdp-source.c | |
parent | 2d514e666afdccdf370cfc92fa284b3fa4492824 (diff) | |
download | xrdp-proprietary-bff2009147c3262024c0ac20347ea55c6d4369be.tar.gz xrdp-proprietary-bff2009147c3262024c0ac20347ea55c6d4369be.zip |
chansrv: change to 44100 recording, disconnect / reconnect fixes
Diffstat (limited to 'sesman/chansrv/pulse/module-xrdp-source.c')
-rw-r--r-- | sesman/chansrv/pulse/module-xrdp-source.c | 55 |
1 files changed, 44 insertions, 11 deletions
diff --git a/sesman/chansrv/pulse/module-xrdp-source.c b/sesman/chansrv/pulse/module-xrdp-source.c index 3d73fd03..37c0bb4e 100644 --- a/sesman/chansrv/pulse/module-xrdp-source.c +++ b/sesman/chansrv/pulse/module-xrdp-source.c @@ -174,6 +174,7 @@ static int data_get(struct userdata *u, pa_memchunk *chunk) { int fd; int bytes; + int read_bytes; struct sockaddr_un s; char *data; char buf[11]; @@ -216,7 +217,12 @@ static int data_get(struct userdata *u, pa_memchunk *chunk) { buf[9] = 0; buf[10] = 0; - lsend(u->fd, buf, 11); + if (lsend(u->fd, buf, 11) != 11) { + close(u->fd); + u->fd = 0; + pa_memblock_release(chunk->memblock); + return -1; + } u->want_src_data = 1; pa_log_debug("###### started recording"); } @@ -234,10 +240,22 @@ static int data_get(struct userdata *u, pa_memchunk *chunk) { buf[9] = (unsigned char) chunk->length; buf[10] = (unsigned char) ((chunk->length >> 8) & 0xff); - lsend(u->fd, buf, 11); + if (lsend(u->fd, buf, 11) != 11) { + close(u->fd); + u->fd = 0; + pa_memblock_release(chunk->memblock); + u->want_src_data = 0; + return -1; + } /* read length of data available */ - lrecv(u->fd, (char *) ubuf, 2); + if (lrecv(u->fd, (char *) ubuf, 2) != 2) { + close(u->fd); + u->fd = 0; + pa_memblock_release(chunk->memblock); + u->want_src_data = 0; + return -1; + } bytes = ((ubuf[1] << 8) & 0xff00) | (ubuf[0] & 0xff); if (bytes == 0) { @@ -246,15 +264,22 @@ static int data_get(struct userdata *u, pa_memchunk *chunk) { } /* get data */ - bytes = lrecv(u->fd, data, bytes); - + read_bytes = lrecv(u->fd, data, bytes); + if (read_bytes != bytes) { + close(u->fd); + u->fd = 0; + pa_memblock_release(chunk->memblock); + u->want_src_data = 0; + return -1; + } pa_memblock_release(chunk->memblock); - return bytes; + return read_bytes; } static void thread_func(void *userdata) { struct userdata *u = userdata; + int bytes; pa_assert(u); pa_thread_mq_install(&u->thread_mq); @@ -271,10 +296,15 @@ static void thread_func(void *userdata) { now = pa_rtclock_now(); if ((chunk.length = pa_usec_to_bytes(now - u->timestamp, &u->source->sample_spec)) > 0) { - chunk.memblock = pa_memblock_new(u->core->mempool, (size_t) -1); /* or chunk.length? */ + chunk.length *= 4; + chunk.memblock = pa_memblock_new(u->core->mempool, chunk.length); chunk.index = 0; - data_get(u, &chunk); - pa_source_post(u->source, &chunk); + bytes = data_get(u, &chunk); + if (bytes > 0) + { + chunk.length = bytes; + pa_source_post(u->source, &chunk); + } pa_memblock_unref(chunk.memblock); u->timestamp = now; } @@ -298,7 +328,10 @@ static void thread_func(void *userdata) { buf[9] = 0; buf[10] = 0; - lsend(u->fd, buf, 11); + if (lsend(u->fd, buf, 11) != 11) { + close(u->fd); + u->fd = 0; + } u->want_src_data = 0; pa_log_debug("###### stopped recording"); } @@ -338,7 +371,7 @@ int pa__init(pa_module *m) { goto fail; } -#if 0 +#if 1 ss = m->core->default_sample_spec; #else ss.format = PA_SAMPLE_S16LE; |