diff options
author | irungentoo <irungentoo@gmail.com> | 2014-12-12 20:55:43 -0500 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-12-12 20:55:43 -0500 |
commit | 4e1e3150d3a6529a47ffb9c2ceb925f143ffea96 (patch) | |
tree | c422382ecf622871224d2bf82ddf15c9df29dcbe /toxav/codec.c | |
parent | 129f620fa5f8996bc73fd1031a8475e4c2a2f441 (diff) |
Fixed memory leaks.
Diffstat (limited to 'toxav/codec.c')
-rw-r--r-- | toxav/codec.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/toxav/codec.c b/toxav/codec.c index 6aefa0b2..2b892be7 100644 --- a/toxav/codec.c +++ b/toxav/codec.c | |||
@@ -170,7 +170,7 @@ static void jbuf_free(JitterBuffer *q) | |||
170 | free(q); | 170 | free(q); |
171 | } | 171 | } |
172 | 172 | ||
173 | static void jbuf_write(JitterBuffer *q, RTPMessage *m) | 173 | static int jbuf_write(JitterBuffer *q, RTPMessage *m) |
174 | { | 174 | { |
175 | uint16_t sequnum = m->header->sequnum; | 175 | uint16_t sequnum = m->header->sequnum; |
176 | 176 | ||
@@ -181,17 +181,18 @@ static void jbuf_write(JitterBuffer *q, RTPMessage *m) | |||
181 | q->bottom = sequnum - q->capacity; | 181 | q->bottom = sequnum - q->capacity; |
182 | q->queue[num] = m; | 182 | q->queue[num] = m; |
183 | q->top = sequnum + 1; | 183 | q->top = sequnum + 1; |
184 | return; | 184 | return 0; |
185 | } | 185 | } |
186 | 186 | ||
187 | if (q->queue[num]) | 187 | if (q->queue[num]) |
188 | return; | 188 | return -1; |
189 | 189 | ||
190 | q->queue[num] = m; | 190 | q->queue[num] = m; |
191 | 191 | ||
192 | if ((sequnum - q->bottom) >= (q->top - q->bottom)) | 192 | if ((sequnum - q->bottom) >= (q->top - q->bottom)) |
193 | q->top = sequnum + 1; | 193 | q->top = sequnum + 1; |
194 | 194 | ||
195 | return 0; | ||
195 | } | 196 | } |
196 | 197 | ||
197 | /* Success is 0 when there is nothing to dequeue, | 198 | /* Success is 0 when there is nothing to dequeue, |
@@ -384,6 +385,7 @@ void cs_do(CSSession *cs) | |||
384 | rc = opus_decode(cs->audio_decoder, 0, 0, tmp, fsize, 1); | 385 | rc = opus_decode(cs->audio_decoder, 0, 0, tmp, fsize, 1); |
385 | } else { | 386 | } else { |
386 | rc = opus_decode(cs->audio_decoder, msg->data, msg->length, tmp, fsize, 0); | 387 | rc = opus_decode(cs->audio_decoder, msg->data, msg->length, tmp, fsize, 0); |
388 | rtp_free_msg(NULL, msg); | ||
387 | } | 389 | } |
388 | 390 | ||
389 | if (rc < 0) { | 391 | if (rc < 0) { |
@@ -595,8 +597,12 @@ void queue_message(RTPSession *session, RTPMessage *msg) | |||
595 | /* Audio */ | 597 | /* Audio */ |
596 | if (session->payload_type == msi_TypeAudio % 128) { | 598 | if (session->payload_type == msi_TypeAudio % 128) { |
597 | pthread_mutex_lock(cs->queue_mutex); | 599 | pthread_mutex_lock(cs->queue_mutex); |
598 | jbuf_write(cs->j_buf, msg); | 600 | int ret = jbuf_write(cs->j_buf, msg); |
599 | pthread_mutex_unlock(cs->queue_mutex); | 601 | pthread_mutex_unlock(cs->queue_mutex); |
602 | |||
603 | if (ret == -1) { | ||
604 | rtp_free_msg(NULL, msg); | ||
605 | } | ||
600 | } | 606 | } |
601 | /* Video */ | 607 | /* Video */ |
602 | else { | 608 | else { |