mirror of
https://github.com/onyx-and-iris/voicemeeter-api-python.git
synced 2024-11-22 11:00:47 +00:00
use time.time() to steady rate of updates.
reduce loop time if waiting for new event
This commit is contained in:
parent
aefde48c98
commit
bd686ef67d
@ -18,6 +18,7 @@ class Updater(threading.Thread):
|
|||||||
Runs updates at a rate of self.ratelimit.
|
Runs updates at a rate of self.ratelimit.
|
||||||
"""
|
"""
|
||||||
while self._remote.running:
|
while self._remote.running:
|
||||||
|
start = time.time()
|
||||||
if self._remote.event.pdirty and self._remote.pdirty:
|
if self._remote.event.pdirty and self._remote.pdirty:
|
||||||
self._remote.subject.notify("pdirty")
|
self._remote.subject.notify("pdirty")
|
||||||
if self._remote.event.mdirty and self._remote.mdirty:
|
if self._remote.event.mdirty and self._remote.mdirty:
|
||||||
@ -43,4 +44,8 @@ class Updater(threading.Thread):
|
|||||||
self._remote.cache["bus_level"] = self._remote._bus_buf
|
self._remote.cache["bus_level"] = self._remote._bus_buf
|
||||||
self._remote.subject.notify("ldirty")
|
self._remote.subject.notify("ldirty")
|
||||||
|
|
||||||
time.sleep(self._remote.ratelimit if self._remote.event.any() else 0.1)
|
elapsed = time.time() - start
|
||||||
|
if self._remote.event.any() and self._remote.ratelimit - elapsed > 0:
|
||||||
|
time.sleep(self._remote.ratelimit - elapsed)
|
||||||
|
else:
|
||||||
|
time.sleep(0.1)
|
||||||
|
Loading…
Reference in New Issue
Block a user