summaryrefslogtreecommitdiff
path: root/ratox.c
diff options
context:
space:
mode:
Diffstat (limited to 'ratox.c')
-rw-r--r--ratox.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/ratox.c b/ratox.c
index fc6b563..decc73d 100644
--- 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);