ratox

FIFO based tox client
git clone git://git.2f30.org/ratox
Log | Files | Refs | README | LICENSE

commit 5f895de8fdc58c4e1b51ffd982bf4c469015d0ff
parent 167560d3b43da9ebdee35374ba753280738ed4bd
Author: sin <sin@2f30.org>
Date:   Sun,  5 Oct 2014 21:43:10 +0100

Allow simultaneous tx/rx call

Diffstat:
Mratox.c | 28+++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)

diff --git a/ratox.c b/ratox.c @@ -203,6 +203,7 @@ static void cbcallrejected(void *, int32_t, void *); static void cbcallended(void *, int32_t, void *); static void cbcallinvite(void *, int32_t, void *); static void cbcallringing(void *, int32_t, void *); +static void preparetxcall(struct friend *); static void cbcallstarting(void *, int32_t, void *); static void cbcallending(void *, int32_t, void *); static void cbreqtimeout(void *, int32_t, void *); @@ -442,6 +443,21 @@ cbcallringing(void *av, int32_t cnum, void *udata) } static void +preparetxcall(struct friend *f) +{ + if (f->av.frame) + return; + f->av.frame = malloc(sizeof(int16_t) * framesize); + if (!f->av.frame) + eprintf("malloc:"); + f->av.n = 0; + f->av.incompleteframe = 0; + f->av.lastsent.tv_sec = 0; + f->av.lastsent.tv_nsec = 0; + f->av.state = av_CallActive; +} + +static void cbcallstarting(void *av, int32_t cnum, void *udata) { struct friend *f; @@ -453,15 +469,7 @@ cbcallstarting(void *av, int32_t cnum, void *udata) return; printout(" : %s : Tx AV > Started\n", f->name); - - f->av.frame = malloc(sizeof(int16_t) * framesize); - if (!f->av.frame) - eprintf("malloc:"); - f->av.n = 0; - f->av.incompleteframe = 0; - f->av.lastsent.tv_sec = 0; - f->av.lastsent.tv_nsec = 0; - f->av.state = av_CallActive; + preparetxcall(f); toxav_prepare_transmission(toxav, cnum, av_jbufdc, av_VADd, 0); } @@ -572,6 +580,8 @@ sendfriendcalldata(struct friend *f) ssize_t n, payloadsize; struct timespec now, diff; + preparetxcall(f); + n = fiforead(f->dirfd, &f->fd[FCALL_IN], ffiles[FCALL_IN], f->av.frame + f->av.incompleteframe * f->av.n, framesize * sizeof(int16_t) - f->av.incompleteframe * f->av.n);