summaryrefslogtreecommitdiff
path: root/toxav/toxav.c
diff options
context:
space:
mode:
authorEniz Vukovic <eniz_vukovic@hotmail.com>2015-10-24 01:56:49 +0200
committerEniz Vukovic <eniz_vukovic@hotmail.com>2015-10-24 01:56:49 +0200
commit87828a1b425fb46d3276f6166f9de49744b8e583 (patch)
tree05d36f38bbcbc0cce0899cea7d54b7623b07c0be /toxav/toxav.c
parent7972db5c41b1cd573e4ba362d5d76ad4cd691c9f (diff)
Add synchronization protection for send_frame API functions
Diffstat (limited to 'toxav/toxav.c')
-rw-r--r--toxav/toxav.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/toxav/toxav.c b/toxav/toxav.c
index a88a6cf4..fac6b0bc 100644
--- a/toxav/toxav.c
+++ b/toxav/toxav.c
@@ -649,7 +649,11 @@ bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t *pc
649 goto END; 649 goto END;
650 } 650 }
651 651
652 pthread_mutex_lock(av->mutex); 652 if (pthread_mutex_trylock(av->mutex) != 0) {
653 rc = TOXAV_ERR_SEND_FRAME_SYNC;
654 goto END;
655 }
656
653 call = call_get(av, friend_number); 657 call = call_get(av, friend_number);
654 658
655 if (call == NULL || !call->active || call->msi_call->state != msi_CallActive) { 659 if (call == NULL || !call->active || call->msi_call->state != msi_CallActive) {
@@ -728,7 +732,11 @@ bool toxav_video_send_frame(ToxAV *av, uint32_t friend_number, uint16_t width, u
728 goto END; 732 goto END;
729 } 733 }
730 734
731 pthread_mutex_lock(av->mutex); 735 if (pthread_mutex_trylock(av->mutex) != 0) {
736 rc = TOXAV_ERR_SEND_FRAME_SYNC;
737 goto END;
738 }
739
732 call = call_get(av, friend_number); 740 call = call_get(av, friend_number);
733 741
734 if (call == NULL || !call->active || call->msi_call->state != msi_CallActive) { 742 if (call == NULL || !call->active || call->msi_call->state != msi_CallActive) {