1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-12-07 02:46:36 +01:00

group audio almost works

This commit is contained in:
Jfreegman
2014-11-26 15:22:34 -05:00
parent 751b5f9943
commit 09bbec79cf
10 changed files with 98 additions and 95 deletions

View File

@@ -957,25 +957,6 @@ static int init_default_data_files(void)
return config_err;
}
#define REC_TOX_DO_LOOPS_PER_SEC 25
/* Adjusts usleep value so that tox_do runs close to the recommended number of times per second */
static useconds_t optimal_msleepval(uint64_t *looptimer, uint64_t *loopcount, uint64_t cur_time, useconds_t msleepval)
{
useconds_t new_sleep = msleepval;
++(*loopcount);
if (*looptimer == cur_time)
return new_sleep;
if (*loopcount != REC_TOX_DO_LOOPS_PER_SEC)
new_sleep *= (double) *loopcount / REC_TOX_DO_LOOPS_PER_SEC;
*looptimer = cur_time;
*loopcount = 0;
return new_sleep;
}
#ifdef X11
void cb(const char* asdv, DropType dt)
{
@@ -1086,9 +1067,6 @@ int main(int argc, char *argv[])
execute(prompt->chatwin->history, prompt, m, avatarstr, GLOBAL_COMMAND_MODE);
uint64_t last_save = (uint64_t) time(NULL);
uint64_t looptimer = last_save;
useconds_t msleepval = 40000;
uint64_t loopcount = 0;
while (true) {
update_unix_time();
@@ -1097,15 +1075,16 @@ int main(int argc, char *argv[])
if (timed_out(last_save, cur_time, AUTOSAVE_FREQ)) {
pthread_mutex_lock(&Winthread.lock);
if (store_data(m, DATA_FILE) != 0)
line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, RED, "WARNING: Failed to save to data file");
pthread_mutex_unlock(&Winthread.lock);
last_save = cur_time;
}
msleepval = optimal_msleepval(&looptimer, &loopcount, cur_time, msleepval);
usleep(msleepval);
usleep((MIN(tox_do_interval(m), toxav_do_interval(av))));
}
return 0;