From e990f058171276e93e4a20547e763726d889d457 Mon Sep 17 00:00:00 2001 From: mannol Date: Fri, 14 Mar 2014 23:10:10 +0100 Subject: Added new callback --- toxav/msi.c | 17 ++++++++--------- toxav/msi.h | 3 ++- toxav/phone.c | 19 +++++++++++-------- toxav/toxav.h | 4 ++-- 4 files changed, 23 insertions(+), 20 deletions(-) (limited to 'toxav') 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 { static struct _Callbacks { MSICallback function; void* data; -} callbacks[10] = {0}; +} callbacks[11] = {0}; inline__ void invoke_callback(MSICallbackID id) { @@ -653,7 +653,8 @@ void handle_remote_connection_change(Messenger *messenger, int friend_num, uint8 for ( ; i < session->call->peer_count; i ++ ) if ( session->call->peers[i] == friend_num ) { - msi_stopcall(session); /* Stop the call for now */ + invoke_callback(MSI_OnPeerTimeout); + /*msi_stopcall(session); /* Stop the call for now */ return; } } @@ -747,10 +748,9 @@ void *handle_timeout ( void *arg ) } - return NULL; + pthread_exit(NULL); } - /** * @brief Add peer to peer list. * @@ -1244,13 +1244,12 @@ int msi_terminate_session ( MSISession *session ) assert ( session ); int _status = 0; - - terminate_call ( session ); + + /* If have call, cancel it */ + if ( session->call ) msi_cancel(session, 0, "MSI session terminated!"); + m_callback_msi_packet((struct Messenger *) session->messenger_handle, NULL, NULL); - - /* TODO: Clean it up more? */ - free ( session ); return _status; } 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 { /* Protocol */ MSI_OnError, - MSI_OnRequestTimeout + MSI_OnRequestTimeout, + MSI_OnPeerTimeout } MSICallbackID; 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: ; int av_terminate_session(av_session_t *_phone) { - toxav_hangup(_phone->av); - - free(_phone->_friends); - pthread_mutex_destroy ( &_phone->_mutex ); - + _phone->running_decaud = 0; + usleep(100000); /* Wait for tox_poll to end */ + + toxav_kill(_phone->av); + printf("\r[i] KILLED AV ARGH!\n"); + + usleep(1000000); /* Wait for cancel request to be sent */ Tox *_p = _phone->_messenger; _phone->_messenger = NULL; - usleep(100000); /* Wait for tox_poll to end */ - tox_kill(_p); - toxav_kill(_phone->av); + + free(_phone->_friends); + pthread_mutex_destroy ( &_phone->_mutex ); + free(_phone); 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 { /* Protocol */ av_OnError, - av_OnRequestTimeout - + av_OnRequestTimeout, + av_OnPeerTimeout } ToxAvCallbackID; -- cgit v1.2.3