1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-23 19:53:25 +01:00
This commit is contained in:
Jfreegman 2014-06-23 18:54:48 -04:00
commit f3ee120c48
3 changed files with 37 additions and 24 deletions

View File

@ -55,7 +55,7 @@
typedef struct _Call { typedef struct _Call {
pthread_t ttid; /* Transmission thread id */ pthread_t ttid; /* Transmission thread id */
_Bool ttas; /* Transmission thread active status (0 - stopped, 1- running) */ _Bool ttas, has_output; /* Transmission thread active status (0 - stopped, 1- running) */
int in_idx, out_idx; int in_idx, out_idx;
pthread_mutex_t mutex; pthread_mutex_t mutex;
} Call; } Call;
@ -188,19 +188,23 @@ void *transmission(void *arg)
int32_t dec_frame_len; int32_t dec_frame_len;
int16_t PCM[frame_size]; int16_t PCM[frame_size];
this_call->has_output = 1;
if ( open_primary_device(input, &this_call->in_idx) != de_None )
if ( open_primary_device(input, &this_call->in_idx) != de_None ) goto cleanup; line_info_add(self, NULL, NULL, NULL, "Failed to open input device!", SYS_MSG, 0, 0);
if ( register_device_callback(call_index, this_call->in_idx, read_device_callback, &call_index, _True) != de_None) if ( register_device_callback(call_index, this_call->in_idx, read_device_callback, &call_index, _True) != de_None)
/* Set VAD as true for all; TODO: Make it more dynamic */ /* Set VAD as true for all; TODO: Make it more dynamic */
goto cleanup; line_info_add(self, NULL, NULL, NULL, "Failed to register input handler!", SYS_MSG, 0, 0);
if ( open_primary_device(output, &this_call->out_idx) != de_None ) goto cleanup;
if ( open_primary_device(output, &this_call->out_idx) != de_None ) {
line_info_add(self, NULL, NULL, NULL, "Failed to open output device!", SYS_MSG, 0, 0);
this_call->has_output = 0;
}
/* Start transmission */ /* Start transmission */
while (this_call->ttas) { while (this_call->ttas) {
lock; lock;
if ( this_call->has_output ) {
if (playback_device_ready(this_call->out_idx) == de_Busy) { if (playback_device_ready(this_call->out_idx) == de_Busy) {
unlock; unlock;
@ -217,6 +221,7 @@ void *transmission(void *arg)
/* >implying it'll ever get an error */ /* >implying it'll ever get an error */
} }
}
unlock; unlock;
usleep(1000); usleep(1000);
@ -303,10 +308,13 @@ void callback_recv_ending ( int32_t call_index, void* arg )
{ {
CB_BODY(call_index, arg, onEnding); CB_BODY(call_index, arg, onEnding);
stop_transmission(call_index); stop_transmission(call_index);
((ToxWindow*)arg)->call_idx = -1;
} }
void callback_recv_error ( int32_t call_index, void* arg ) void callback_recv_error ( int32_t call_index, void* arg )
{ {
CB_BODY(call_index, arg, onError); CB_BODY(call_index, arg, onError);
stop_transmission(call_index);
((ToxWindow*)arg)->call_idx = -1;
} }
void callback_call_started ( int32_t call_index, void* arg ) void callback_call_started ( int32_t call_index, void* arg )
{ {
@ -327,6 +335,7 @@ void callback_call_canceled ( int32_t call_index, void* arg )
/* In case call is active */ /* In case call is active */
stop_transmission(call_index); stop_transmission(call_index);
((ToxWindow*)arg)->call_idx = -1;
} }
void callback_call_rejected ( int32_t call_index, void* arg ) void callback_call_rejected ( int32_t call_index, void* arg )
{ {
@ -336,11 +345,13 @@ void callback_call_ended ( int32_t call_index, void* arg )
{ {
CB_BODY(call_index, arg, onEnd); CB_BODY(call_index, arg, onEnd);
stop_transmission(call_index); stop_transmission(call_index);
((ToxWindow*)arg)->call_idx = -1;
} }
void callback_requ_timeout ( int32_t call_index, void* arg ) void callback_requ_timeout ( int32_t call_index, void* arg )
{ {
CB_BODY(call_index, arg, onRequestTimeout); CB_BODY(call_index, arg, onRequestTimeout);
((ToxWindow*)arg)->call_idx = -1;
} }
void callback_peer_timeout ( int32_t call_index, void* arg ) void callback_peer_timeout ( int32_t call_index, void* arg )
{ {
@ -350,6 +361,7 @@ void callback_peer_timeout ( int32_t call_index, void* arg )
* actions that one can possibly take on timeout * actions that one can possibly take on timeout
*/ */
toxav_stop_call(ASettins.av, call_index); toxav_stop_call(ASettins.av, call_index);
((ToxWindow*)arg)->call_idx = -1;
} }
/* /*
* End of Callbacks * End of Callbacks
@ -643,7 +655,8 @@ void cmd_ccur_device(WINDOW * window, ToxWindow * self, Tox *m, int argc, char (
if (type == output) { if (type == output) {
pthread_mutex_lock(&this_call->mutex); pthread_mutex_lock(&this_call->mutex);
close_device(output, this_call->out_idx); close_device(output, this_call->out_idx);
open_device(output, selection, &this_call->out_idx); this_call->has_output = open_device(output, selection, &this_call->out_idx)
== de_None ? 1 : 0;
pthread_mutex_unlock(&this_call->mutex); pthread_mutex_unlock(&this_call->mutex);
} }
else { else {

View File

@ -92,7 +92,7 @@ void sort_friendlist_index(void)
static void update_friend_last_online(int32_t num, uint64_t timestamp) static void update_friend_last_online(int32_t num, uint64_t timestamp)
{ {
friends[num].last_online.last_on = timestamp; friends[num].last_online.last_on = timestamp;
friends[num].last_online.tm = *localtime(&timestamp); friends[num].last_online.tm = *localtime((const time_t*)&timestamp);
/* if the format changes make sure TIME_STR_SIZE is the correct size */ /* if the format changes make sure TIME_STR_SIZE is the correct size */
const char *t = user_settings->time == TIME_12 ? "%I:%M %p" : "%H:%M"; const char *t = user_settings->time == TIME_12 ? "%I:%M %p" : "%H:%M";
@ -383,7 +383,7 @@ static void friendlist_onDraw(ToxWindow *self, Tox *m)
getmaxyx(self->window, y2, x2); getmaxyx(self->window, y2, x2);
uint64_t cur_time = get_unix_time(); uint64_t cur_time = get_unix_time();
struct tm cur_loc_tm = *localtime(&cur_time); struct tm cur_loc_tm = *localtime((const time_t*)&cur_time);
bool fix_statuses = x2 != self->x; /* true if window x axis has changed */ bool fix_statuses = x2 != self->x; /* true if window x axis has changed */

View File

@ -55,7 +55,7 @@ struct tm *get_time(void)
{ {
struct tm *timeinfo; struct tm *timeinfo;
uint64_t t = get_unix_time(); uint64_t t = get_unix_time();
timeinfo = localtime(&t); timeinfo = localtime((const time_t*)&t);
return timeinfo; return timeinfo;
} }