summaryrefslogtreecommitdiff
path: root/toxav/codec.c
diff options
context:
space:
mode:
authormannol <eniz_vukovic@hotmail.com>2014-07-05 15:11:25 +0200
committermannol <eniz_vukovic@hotmail.com>2014-07-05 15:11:25 +0200
commit8b9d3992a44fcac66979b847dc2ff488f3ff614a (patch)
treeae73e54964442d23125a21528e9fb05db294e275 /toxav/codec.c
parenta8fa360547ccefef3694c5d185414874539769c1 (diff)
Make rtp & codec actions thread-safe
Diffstat (limited to 'toxav/codec.c')
-rw-r--r--toxav/codec.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/toxav/codec.c b/toxav/codec.c
index 3e6de803..4abb7f8c 100644
--- a/toxav/codec.c
+++ b/toxav/codec.c
@@ -80,8 +80,12 @@ JitterBuffer *create_queue(int capacity)
80 80
81void terminate_queue(JitterBuffer *q) 81void terminate_queue(JitterBuffer *q)
82{ 82{
83 if (!q) return;
84
83 empty_queue(q); 85 empty_queue(q);
84 free(q->queue); 86 free(q->queue);
87
88 LOGGER_DEBUG("Terminated jitter buffer: %p", q);
85 free(q); 89 free(q);
86} 90}
87 91
@@ -314,6 +318,8 @@ CodecState *codec_init_session ( uint32_t audio_bitrate,
314 318
315void codec_terminate_session ( CodecState *cs ) 319void codec_terminate_session ( CodecState *cs )
316{ 320{
321 if (!cs) return;
322
317 if ( cs->audio_encoder ) 323 if ( cs->audio_encoder )
318 opus_encoder_destroy(cs->audio_encoder); 324 opus_encoder_destroy(cs->audio_encoder);
319 325
@@ -325,6 +331,9 @@ void codec_terminate_session ( CodecState *cs )
325 331
326 if ( cs->capabilities & v_encoding ) 332 if ( cs->capabilities & v_encoding )
327 vpx_codec_destroy(&cs->v_encoder); 333 vpx_codec_destroy(&cs->v_encoder);
334
335 LOGGER_DEBUG("Terminated codec state: %p", cs);
336 free(cs);
328} 337}
329 338
330inline float calculate_sum_sq (int16_t *n, uint16_t k) 339inline float calculate_sum_sq (int16_t *n, uint16_t k)