1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-23 12:13:24 +01:00
This commit is contained in:
Jfreegman 2014-08-01 15:05:10 -04:00
parent c455e79604
commit 9fe75fbc47
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63

View File

@ -597,16 +597,16 @@ static int init_data_files(void)
#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 */
useconds_t optimal_msleepval(uint64_t *looptimer, uint64_t *loopcount, uint64_t cur_time, useconds_t msleepval)
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 || *loopcount == REC_TOX_DO_LOOPS_PER_SEC)
if (*looptimer == cur_time)
return new_sleep;
double d = (double) *loopcount / REC_TOX_DO_LOOPS_PER_SEC;
new_sleep *= d;
if (*loopcount != REC_TOX_DO_LOOPS_PER_SEC)
new_sleep *= (double) *loopcount / REC_TOX_DO_LOOPS_PER_SEC;
*looptimer = cur_time;
*loopcount = 0;