From b24c5d8cf831af26cfc6555f8a1f38c51ba06343 Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Thu, 19 Nov 2015 23:49:58 -0500 Subject: [PATCH] Fix AV bug Pending call now properly hangs up when you use the /hangup command or close the chat window --- src/audio_call.c | 35 +++++++++++++++++------------------ src/chat.c | 10 +++++----- src/name_lookup.c | 2 +- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/audio_call.c b/src/audio_call.c index 6003a8a..d88ae6b 100644 --- a/src/audio_call.c +++ b/src/audio_call.c @@ -570,8 +570,8 @@ void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[ { const char *error_str = NULL; - if ( !self->is_call ) { - error_str = "Not in a call."; + if ( !CallControl.av ) { + error_str = "Audio not supported!"; goto on_error; } @@ -580,8 +580,8 @@ void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[ goto on_error; } - if ( !CallControl.av ) { - error_str = "Audio not supported!"; + if ( !self->is_call && !CallControl.pending_call ) { + error_str = "Not in a call."; goto on_error; } @@ -589,18 +589,7 @@ void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[ callback_video_end(self->num); #endif /* VIDEO */ - if ( CallControl.pending_call ) { - /* Manually send a cancel call control because call hasn't started */ - toxav_call_control(CallControl.av, self->num, TOXAV_CALL_CONTROL_CANCEL, NULL); - callback_call_canceled(self->num); - } - else { - stop_transmission(&CallControl.calls[self->num], self->num); - callback_call_ended(self->num); - } - - CallControl.pending_call = false; - + stop_current_call(self); return; on_error: print_err (self, error_str); @@ -835,6 +824,16 @@ void stop_current_call(ToxWindow* self) { Call *this_call = &CallControl.calls[self->num]; - if (this_call && self->is_call) - stop_transmission(this_call, self->num); + if ( !this_call ) + return; + + if ( CallControl.pending_call ) { + toxav_call_control(CallControl.av, self->num, TOXAV_CALL_CONTROL_CANCEL, NULL); + callback_call_canceled(self->num); + } else { + stop_transmission(&CallControl.calls[self->num], self->num); + callback_call_ended(self->num); + } + + CallControl.pending_call = false; } diff --git a/src/chat.c b/src/chat.c index 0e59c85..b3e293e 100644 --- a/src/chat.c +++ b/src/chat.c @@ -126,11 +126,6 @@ void kill_chat_window(ToxWindow *self, Tox *m) ChatContext *ctx = self->chatwin; StatusBar *statusbar = self->stb; - kill_all_file_transfers_friend(m, self->num); - log_disable(ctx->log); - line_info_cleanup(ctx->hst); - cqueue_cleanup(ctx->cqueue); - #ifdef AUDIO #ifdef VIDEO stop_video_stream(self); @@ -138,6 +133,11 @@ void kill_chat_window(ToxWindow *self, Tox *m) stop_current_call(self); #endif /* AUDIO */ + kill_all_file_transfers_friend(m, self->num); + log_disable(ctx->log); + line_info_cleanup(ctx->hst); + cqueue_cleanup(ctx->cqueue); + delwin(ctx->linewin); delwin(ctx->history); delwin(statusbar->topline); diff --git a/src/name_lookup.c b/src/name_lookup.c index fad4c9e..3fc7e36 100644 --- a/src/name_lookup.c +++ b/src/name_lookup.c @@ -329,7 +329,7 @@ void *lookup_thread_func(void *data) curl_easy_setopt(c_handle, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(c_handle, CURLOPT_URL, real_domain); curl_easy_setopt(c_handle, CURLOPT_WRITEFUNCTION, write_lookup_data); - curl_easy_setopt(c_handle, CURLOPT_WRITEDATA, (void *) &recv_data); + curl_easy_setopt(c_handle, CURLOPT_WRITEDATA, &recv_data); curl_easy_setopt(c_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0"); curl_easy_setopt(c_handle, CURLOPT_POSTFIELDS, post_data);