summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormannol <eniz_vukovic@hotmail.com>2015-05-12 22:16:00 +0200
committermannol <eniz_vukovic@hotmail.com>2015-05-12 22:16:00 +0200
commit64037017cc3804d9921bd9780570685871df8f0b (patch)
tree66b78681cb2fe50318d0c3fed9dba7009baafc88
parent73fbc2296117f8a507e8ed9399e1cf13f19ddb19 (diff)
Fix bug
-rw-r--r--toxav/msi.c6
-rw-r--r--toxav/toxav.c19
-rw-r--r--toxav/toxav.h4
3 files changed, 23 insertions, 6 deletions
diff --git a/toxav/msi.c b/toxav/msi.c
index d68e4a9c..65b6c4e4 100644
--- a/toxav/msi.c
+++ b/toxav/msi.c
@@ -205,6 +205,12 @@ int msi_hangup ( MSICall* call )
205 MSISession* session = call->session; 205 MSISession* session = call->session;
206 pthread_mutex_lock(session->mutex); 206 pthread_mutex_lock(session->mutex);
207 207
208 if ( call->state == msi_CallInactive ) {
209 LOGGER_ERROR("Call is in invalid state!");
210 pthread_mutex_unlock(session->mutex);
211 return -1;
212 }
213
208 MSIMessage msg; 214 MSIMessage msg;
209 msg_init(&msg, requ_pop); 215 msg_init(&msg, requ_pop);
210 216
diff --git a/toxav/toxav.c b/toxav/toxav.c
index 31629c29..5e32f196 100644
--- a/toxav/toxav.c
+++ b/toxav/toxav.c
@@ -113,7 +113,7 @@ int callback_capabilites(void* toxav_inst, MSICall* call);
113 113
114bool audio_bit_rate_invalid(uint32_t bit_rate); 114bool audio_bit_rate_invalid(uint32_t bit_rate);
115bool video_bit_rate_invalid(uint32_t bit_rate); 115bool video_bit_rate_invalid(uint32_t bit_rate);
116void invoke_call_state(ToxAV* av, uint32_t friend_number, uint32_t state); 116bool invoke_call_state(ToxAV* av, uint32_t friend_number, uint32_t state);
117ToxAVCall* call_new(ToxAV* av, uint32_t friend_number, TOXAV_ERR_CALL* error); 117ToxAVCall* call_new(ToxAV* av, uint32_t friend_number, TOXAV_ERR_CALL* error);
118ToxAVCall* call_get(ToxAV* av, uint32_t friend_number); 118ToxAVCall* call_get(ToxAV* av, uint32_t friend_number);
119ToxAVCall* call_remove(ToxAVCall* call); 119ToxAVCall* call_remove(ToxAVCall* call);
@@ -998,6 +998,11 @@ int callback_invite(void* toxav_inst, MSICall* call)
998 if (toxav->ccb.first) 998 if (toxav->ccb.first)
999 toxav->ccb.first(toxav, call->friend_number, call->peer_capabilities & msi_CapSAudio, 999 toxav->ccb.first(toxav, call->friend_number, call->peer_capabilities & msi_CapSAudio,
1000 call->peer_capabilities & msi_CapSVideo, toxav->ccb.second); 1000 call->peer_capabilities & msi_CapSVideo, toxav->ccb.second);
1001 else {
1002 /* No handler to capture the call request, send failure */
1003 pthread_mutex_unlock(toxav->mutex);
1004 return -1;
1005 }
1001 1006
1002 pthread_mutex_unlock(toxav->mutex); 1007 pthread_mutex_unlock(toxav->mutex);
1003 return 0; 1008 return 0;
@@ -1018,12 +1023,15 @@ int callback_start(void* toxav_inst, MSICall* call)
1018 1023
1019 if (!call_prepare_transmission(av_call)) { 1024 if (!call_prepare_transmission(av_call)) {
1020 callback_error(toxav_inst, call); 1025 callback_error(toxav_inst, call);
1021 call_remove(av_call);
1022 pthread_mutex_unlock(toxav->mutex); 1026 pthread_mutex_unlock(toxav->mutex);
1023 return -1; 1027 return -1;
1024 } 1028 }
1025 1029
1026 invoke_call_state(toxav, call->friend_number, call->peer_capabilities); 1030 if (!invoke_call_state(toxav, call->friend_number, call->peer_capabilities)) {
1031 callback_error(toxav_inst, call);
1032 pthread_mutex_unlock(toxav->mutex);
1033 return -1;
1034 }
1027 1035
1028 pthread_mutex_unlock(toxav->mutex); 1036 pthread_mutex_unlock(toxav->mutex);
1029 return 0; 1037 return 0;
@@ -1083,10 +1091,13 @@ bool video_bit_rate_invalid(uint32_t bit_rate)
1083 return false; 1091 return false;
1084} 1092}
1085 1093
1086void invoke_call_state(ToxAV* av, uint32_t friend_number, uint32_t state) 1094bool invoke_call_state(ToxAV* av, uint32_t friend_number, uint32_t state)
1087{ 1095{
1088 if (av->scb.first) 1096 if (av->scb.first)
1089 av->scb.first(av, friend_number, state, av->scb.second); 1097 av->scb.first(av, friend_number, state, av->scb.second);
1098 else
1099 return false;
1100 return true;
1090} 1101}
1091 1102
1092ToxAVCall* call_new(ToxAV* av, uint32_t friend_number, TOXAV_ERR_CALL* error) 1103ToxAVCall* call_new(ToxAV* av, uint32_t friend_number, TOXAV_ERR_CALL* error)
diff --git a/toxav/toxav.h b/toxav/toxav.h
index 994b3009..b0e7e37d 100644
--- a/toxav/toxav.h
+++ b/toxav/toxav.h
@@ -190,7 +190,7 @@ bool toxav_answer(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, ui
190 * :: Call state graph 190 * :: Call state graph
191 * 191 *
192 ******************************************************************************/ 192 ******************************************************************************/
193typedef enum TOXAV_CALL_STATE { 193enum TOXAV_CALL_STATE {
194 /** 194 /**
195 * The flag that marks that friend is sending audio. 195 * The flag that marks that friend is sending audio.
196 */ 196 */
@@ -218,7 +218,7 @@ typedef enum TOXAV_CALL_STATE {
218 * state will never be triggered in combination with other call states. 218 * state will never be triggered in combination with other call states.
219 */ 219 */
220 TOXAV_CALL_STATE_ERROR = 32768 220 TOXAV_CALL_STATE_ERROR = 32768
221} TOXAV_CALL_STATE; 221};
222/** 222/**
223 * The function type for the `call_state` callback. 223 * The function type for the `call_state` callback.
224 * 224 *