summaryrefslogtreecommitdiff
path: root/toxav
diff options
context:
space:
mode:
authormannol <eniz_vukovic@hotmail.com>2014-03-14 23:10:10 +0100
committermannol <eniz_vukovic@hotmail.com>2014-03-14 23:10:10 +0100
commite990f058171276e93e4a20547e763726d889d457 (patch)
tree6193ba585c242abc5643f26a49606f4cb76214f0 /toxav
parent3acf43b76accbe0285e9cec0ff3536efeb3f8d8c (diff)
Added new callback
Diffstat (limited to 'toxav')
-rwxr-xr-xtoxav/msi.c17
-rwxr-xr-xtoxav/msi.h3
-rwxr-xr-xtoxav/phone.c19
-rwxr-xr-xtoxav/toxav.h4
4 files changed, 23 insertions, 20 deletions
diff --git a/toxav/msi.c b/toxav/msi.c
index 4bae076f..978989ce 100755
--- a/toxav/msi.c
+++ b/toxav/msi.c
@@ -117,7 +117,7 @@ typedef struct _MSIMessage {
117static struct _Callbacks { 117static struct _Callbacks {
118 MSICallback function; 118 MSICallback function;
119 void* data; 119 void* data;
120} callbacks[10] = {0}; 120} callbacks[11] = {0};
121 121
122inline__ void invoke_callback(MSICallbackID id) 122inline__ void invoke_callback(MSICallbackID id)
123{ 123{
@@ -653,7 +653,8 @@ void handle_remote_connection_change(Messenger *messenger, int friend_num, uint8
653 653
654 for ( ; i < session->call->peer_count; i ++ ) 654 for ( ; i < session->call->peer_count; i ++ )
655 if ( session->call->peers[i] == friend_num ) { 655 if ( session->call->peers[i] == friend_num ) {
656 msi_stopcall(session); /* Stop the call for now */ 656 invoke_callback(MSI_OnPeerTimeout);
657 /*msi_stopcall(session); /* Stop the call for now */
657 return; 658 return;
658 } 659 }
659 } 660 }
@@ -747,10 +748,9 @@ void *handle_timeout ( void *arg )
747 748
748 } 749 }
749 750
750 return NULL; 751 pthread_exit(NULL);
751} 752}
752 753
753
754/** 754/**
755 * @brief Add peer to peer list. 755 * @brief Add peer to peer list.
756 * 756 *
@@ -1244,13 +1244,12 @@ int msi_terminate_session ( MSISession *session )
1244 assert ( session ); 1244 assert ( session );
1245 1245
1246 int _status = 0; 1246 int _status = 0;
1247 1247
1248 terminate_call ( session ); 1248 /* If have call, cancel it */
1249 if ( session->call ) msi_cancel(session, 0, "MSI session terminated!");
1250
1249 m_callback_msi_packet((struct Messenger *) session->messenger_handle, NULL, NULL); 1251 m_callback_msi_packet((struct Messenger *) session->messenger_handle, NULL, NULL);
1250 1252
1251
1252 /* TODO: Clean it up more? */
1253
1254 free ( session ); 1253 free ( session );
1255 return _status; 1254 return _status;
1256} 1255}
diff --git a/toxav/msi.h b/toxav/msi.h
index fcc24b4a..37fc07a3 100755
--- a/toxav/msi.h
+++ b/toxav/msi.h
@@ -131,7 +131,8 @@ typedef enum {
131 131
132 /* Protocol */ 132 /* Protocol */
133 MSI_OnError, 133 MSI_OnError,
134 MSI_OnRequestTimeout 134 MSI_OnRequestTimeout,
135 MSI_OnPeerTimeout
135 136
136} MSICallbackID; 137} MSICallbackID;
137 138
diff --git a/toxav/phone.c b/toxav/phone.c
index 43d24a2f..fb159f57 100755
--- a/toxav/phone.c
+++ b/toxav/phone.c
@@ -1147,18 +1147,21 @@ failed_init_ffmpeg: ;
1147 1147
1148int av_terminate_session(av_session_t *_phone) 1148int av_terminate_session(av_session_t *_phone)
1149{ 1149{
1150 toxav_hangup(_phone->av); 1150 _phone->running_decaud = 0;
1151 1151 usleep(100000); /* Wait for tox_poll to end */
1152 free(_phone->_friends); 1152
1153 pthread_mutex_destroy ( &_phone->_mutex ); 1153 toxav_kill(_phone->av);
1154 1154 printf("\r[i] KILLED AV ARGH!\n");
1155
1156 usleep(1000000); /* Wait for cancel request to be sent */
1155 Tox *_p = _phone->_messenger; 1157 Tox *_p = _phone->_messenger;
1156 _phone->_messenger = NULL; 1158 _phone->_messenger = NULL;
1157 usleep(100000); /* Wait for tox_poll to end */
1158
1159 tox_kill(_p); 1159 tox_kill(_p);
1160 toxav_kill(_phone->av);
1161 1160
1161
1162 free(_phone->_friends);
1163 pthread_mutex_destroy ( &_phone->_mutex );
1164
1162 free(_phone); 1165 free(_phone);
1163 1166
1164 printf("\r[i] Quit!\n"); 1167 printf("\r[i] Quit!\n");
diff --git a/toxav/toxav.h b/toxav/toxav.h
index ffe79249..b67e82f8 100755
--- a/toxav/toxav.h
+++ b/toxav/toxav.h
@@ -70,8 +70,8 @@ typedef enum {
70 70
71 /* Protocol */ 71 /* Protocol */
72 av_OnError, 72 av_OnError,
73 av_OnRequestTimeout 73 av_OnRequestTimeout,
74 74 av_OnPeerTimeout
75} ToxAvCallbackID; 75} ToxAvCallbackID;
76 76
77 77