GNOME Bugzilla – Bug 600922
gst-launch: wake up less often to check for Ctrl-C
Last modified: 2009-11-16 08:10:22 UTC
By default, when I play a media file via gstreamer command line (i.e. gst-launch), and check wakeups-from-idle per second from Powertop, I see 20 wakes from gstreamer. To be power friendly, we can enhance it by replaing g_timeout_add (50, (GSourceFunc) check_intr, pipeline); with: g_timeout_add_seconds (1, (GSourceFunc) check_intr, pipeline); in function "static EventLoopResult event_loop()" of file gstreamer/tools/gst-launch.c. The one second checking interval is enough to capture user CTRL+C without perceivable lag. This will bring power saving because CPU can reside in deep C state for a longer time.
gst-launch is primarily a debugging and testing tool and as such it is not supposed to be memory or cpu efficient or even provide exemplary code. I don't quite share your assertion that a one-second interval is enough to capture Ctrl-C "without perceivable lag". 250ms, however, seemed quite acceptable and should reduce wakeups a lot. g_timeout_add_seconds() makes sense in a more complex scenario where multiple timeouts that are multiples of 1s are in use, but this is not the case in gst-launch, so I don't see a strong case for using it here. I hope reducing the wakeups to 4 times per second is acceptable to you. commit ed86995cd80e390e6e4e0f78350b386b1d7797d5 Author: Tim-Philipp Müller <tim.muller@collabora.co.uk> Date: Sat Nov 7 20:22:49 2009 +0000 gst-launch: wake up less often to check if we've been interrupted Check if we've been interrupted only four times per second instead of twenty times per second, to wake up the cpu less often and save power (see bug #600922).
This sounds good to me. Thanks!