summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorz3bra <contactatz3bradotorg>2016-11-24 22:36:20 +0100
committerz3bra <contactatz3bradotorg>2016-11-24 22:36:20 +0100
commit5b755787f801ac79c51316d95aaa100d47209a3f (patch)
tree24afd8114ad51827a3468b636125a61b53f0a270
parent60193de92f8fa09cc224a60a8758e9778d365132 (diff)
Let the caller hang up while call is ringing
-rw-r--r--ratox.c40
1 files changed, 15 insertions, 25 deletions
diff --git a/ratox.c b/ratox.c
index 207b0e2..daa6c8f 100644
--- a/ratox.c
+++ b/ratox.c
@@ -397,25 +397,6 @@ cbcallstate(ToxAV *av, uint32_t fnum, uint32_t state, void *udata)
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;
-
- f->av.frame = malloc(sizeof(int16_t) * framesize);
- if (!f->av.frame)
- eprintf("malloc:");
-
- f->av.state |= OUTGOING;
- }
}
static void
@@ -501,7 +482,8 @@ sendfriendcalldata(struct friend *f)
if (n == 0) {
f->av.state &= ~OUTGOING;
return;
- } else if (n < 0) {
+ } else if (n < 0 || state & RINGING) {
+ /* discard data as long as the call is not established */
return;
} else if (n == (framesize * sizeof(int16_t) - (f->av.state & INCOMPLETE ? f->av.n : 0))) {
f->av.state &= ~INCOMPLETE;
@@ -1616,7 +1598,7 @@ loop(void)
if (f->tx.state == TRANSFER_NONE)
FD_APPEND(f->fd[FFILE_IN]);
- if (!f->av.state || (f->av.state & TRANSMITTING))
+ if (!f->av.state || (f->av.state & OUTGOING))
FD_APPEND(f->fd[FCALL_IN]);
}
FD_APPEND(f->fd[FREMOVE]);
@@ -1686,10 +1668,9 @@ loop(void)
f->fd[FCALL_OUT] = fd;
}
- if (f->av.state & TRANSMITTING) {
- if (!(f->av.state & INCOMING) && !(f->av.state & OUTGOING))
- cancelcall(f, "Hung up");
- }
+ if (!(f->av.state & INCOMING) && !(f->av.state & OUTGOING))
+ cancelcall(f, "Hung up");
+
if (f->av.state & RINGING) {
if (!(f->av.state & INCOMING))
continue;
@@ -1773,6 +1754,15 @@ loop(void)
fiforeset(f->dirfd, &f->fd[FCALL_IN], ffiles[FCALL_IN]);
break;
}
+ f->av.n = 0;
+ f->av.lastsent.tv_sec = 0;
+ f->av.lastsent.tv_nsec = 0;
+
+ f->av.frame = malloc(sizeof(int16_t) * framesize);
+ if (!f->av.frame)
+ eprintf("malloc:");
+
+ f->av.state |= OUTGOING;
f->av.state |= RINGING;
logmsg(": %s : Audio : Tx > Inviting\n", f->name);
} else {