mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-26 22:43:26 +01:00
fix
This commit is contained in:
parent
c455e79604
commit
9fe75fbc47
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user