ratox

FIFO based tox client
Log | Files | Refs | README | LICENSE

commit 60193de92f8fa09cc224a60a8758e9778d365132
parent e07cf0867e38a8dbbba1a7fcb1a91d19beb37a8e
Author: z3bra <contactatz3bradotorg>
Date:   Thu Nov 24 18:06:21 +0100

Allocate resources for outgoing call when needed

If we're not initiating the call, we might be in TRANSMITTING mode even
if call_in hasn't been openned by the user. In this case, we shouldn't
send any data.
sednfriendcalldata() should only be called when resources are allocated
for an OUTGOING call, which is triggered when the friend accepts audio.

Diffstat:
ratox.c | 26+++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/ratox.c b/ratox.c @@ -389,10 +389,23 @@ cbcallstate(ToxAV *av, uint32_t fnum, uint32_t state, void *udata) } /* - * As long as we receive a state callback, it means the peer - * accepted the call + * If we've are ringing a friend, and he sends a control that's + * not FINISHED, it means he accepted the call, so we can start + * transmitting audio frames */ if (f->av.state & RINGING) { + f->av.state &= ~RINGING; + f->av.state |= TRANSMITTING; + } + + /* + * Move on in case we're already sending audio data + */ + if (state & OUTGOING) + return; + + /* let us start sending audio */ + if (state & TOXAV_FRIEND_CALL_STATE_ACCEPTING_A) { f->av.n = 0; f->av.lastsent.tv_sec = 0; f->av.lastsent.tv_nsec = 0; @@ -401,13 +414,8 @@ cbcallstate(ToxAV *av, uint32_t fnum, uint32_t state, void *udata) if (!f->av.frame) eprintf("malloc:"); - f->av.state &= ~RINGING; - f->av.state |= TRANSMITTING; - } - - /* let us start sending audio */ - if (state & TOXAV_FRIEND_CALL_STATE_ACCEPTING_A) f->av.state |= OUTGOING; + } } static void @@ -1768,7 +1776,7 @@ loop(void) f->av.state |= RINGING; logmsg(": %s : Audio : Tx > Inviting\n", f->name); } else { - if (f->av.state & TRANSMITTING) + if (f->av.state & OUTGOING) sendfriendcalldata(f); } }