voc / voctomix

Full-HD Software Live-Video-Mixer in python
https://c3voc.de/
MIT License
575 stars 104 forks source link

use GLib.timeout_add rather then GLib.timeout_add_seconds #219

Closed MaZderMind closed 6 years ago

MaZderMind commented 6 years ago

it seems to stop the lagging in the audio-level widget. I also reduced the clock-redraw to twice a second, as I don't see a need for redrawing 10 times a second. Second-Accuracy is not really required here anyway.

fixes #218

fightling commented 6 years ago

I didn't realize this on my laptop but it really seems that GLib.timeout_add_seconds() is more than I thought. Described here, there is more about what this function does and about it's CPU efficiency:

The grouping of timers to fire at the same time results in a more power and CPU efficient behavior so if your timer is in multiples of seconds and you don't require the first timer exactly one second from now, the use of g_timeout_add_seconds() is preferred over g_timeout_add().

This internally creates a main loop source using g_timeout_source_new_seconds() and attaches it to the main loop context using g_source_attach(). You can do these steps manually if you need greater control.

So this seems to have this ugly side effect because of that crazy idea to save CPU power by bundling timers. I don't really get it but I like your solution.