Project

General

Profile

Feature #3793

TVheadend should care about Power

Added by Robin Mitra over 8 years ago. Updated over 6 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
2016-06-11
Due date:
% Done:

100%

Estimated time:
(Total: 0.00 h)

Description

If I understood the discussion on github https://github.com/tvheadend/tvheadend/pull/388 correctly, then it seems tvheasdend as a service doesn't care about power, instead requires some other system service to do so, and then somehow figure out if tvheadend can handle whatever power change might be appropriate now.

Since systemd is here to stay (i think), at least on these systems it now seems possible to request power (stay awake), release power (it's ok to sleep now), be notified of power changes, and, most importantly create wake timers (without directly touching the underlying HW, i.e rtc or acpi or whatever).


Subtasks

Feature #3852: Should get an Inhibitor from systemd when has active subscriptionsRejected

Actions

History

#1

Updated by Jaroslav Kysela over 8 years ago

Which systemd API do you refer?

#2

Updated by Robin Mitra over 8 years ago

I was thinking about systemd.logind dbus api. E.g. here: https://www.freedesktop.org/wiki/Software/systemd/inhibit/

I'm just not sure if the wake timers (systemd.timer with wake option) is actually programmatically accessible(modifiable). If so, then a service, that is signaled to prepare for sleep, could set this timer to the next time it needs to do something (next recording or scan or whatever).
That's how WMC works anyway. And yes,it actually works even past it's death, for now what, 11 years?

Btw, for this to work, tvh should also let go off of resources when idle (i.e. tuners, so that they can do there own power management, and need not be taken care of in the tvh suspend task), and obviously enumerate them again upon resume.
There are certain subtle things to consider, i.e.
- allow sleep with open but idle connections (selectable in windows)
- allow 'away mode', e.g. service itself is busy, but doesn't need a GUI (which is almost always the case for things like tvh)

I haven't found the time to play around with this yet. But at least it seems to be what one needs for this.

#3

Updated by Jaroslav Kysela over 8 years ago

Robin Mitra wrote:

I was thinking about systemd.logind dbus api. E.g. here: https://www.freedesktop.org/wiki/Software/systemd/inhibit/

OK. This seems like an easy addition - add locking when tvh is busy with a recording and/or streaming.

I'm just not sure if the wake timers (systemd.timer with wake option) is actually programmatically accessible(modifiable). If so, then a service, that is signaled to prepare for sleep, could set this timer to the next time it needs to do something (next recording or scan or whatever).

I've not found a way to control the system wake-up time through systemd from an application. Appearently, this can be controlled only through the timer unit. You may discuss this with systemd developers.

Also note that tvh can emit signals through dbus with the 'next' time of a DVR event, so the power management may be handled outside tvh.

That's how WMC works anyway. And yes,it actually works even past it's death, for now what, 11 years?

Btw, for this to work, tvh should also let go off of resources when idle (i.e. tuners, so that they can do there own power management, and need not be taken care of in the tvh suspend task), and obviously enumerate them again upon resume.

The linuxdvb devices are closed when they're idle - it's configurable by user - 'Power save' option per tuner settings.

There are certain subtle things to consider, i.e.
- allow sleep with open but idle connections (selectable in windows)
- allow 'away mode', e.g. service itself is busy, but doesn't need a GUI (which is almost always the case for things like tvh)

I haven't found the time to play around with this yet. But at least it seems to be what one needs for this.

TVH GUI is served through the HTTP server - so, tvh itself is only service. Also, consider, that if we put the system in the sleep state, we cannot handle the 'live' streaming requests.

#4

Updated by Robin Mitra over 8 years ago

Jaroslav Kysela wrote:

I've not found a way to control the system wake-up time through systemd from an application. Appearently, this can be controlled only through the timer unit. You may discuss this with systemd developers.

Yes, that was my first impression too. If this is only possible via editing the timer file itself, then it would require modifying the file an the nupdating the systemd database from within the sleep notification. I dunno if that works.

#5

Updated by Robin Mitra over 8 years ago

... and it seems other people have figured out this missing functionality too: https://github.com/cockpit-project/cockpit/wiki/Feature:-Systemd-timers

#6

Updated by Heinrich Lech over 8 years ago

Jaroslav Kysela wrote:

OK. This seems like an easy addition - add locking when tvh is busy with a recording and/or streaming.

Do you have this on a timeline?

For me it is very important that suspend is prevented if there are open connections and active streams.

It would be nice if suspend is also prevented a certain time before the next timer starts to avoid that the system suspends say just for a minute... HDDs would appreciate that ;)

Preventing suspend even if a hardware button is pressed is also a good idea- does the inhibit api handle this?

#7

Updated by Heinrich Lech over 6 years ago

"Also note that tvh can emit signals through dbus with the 'next' time of a DVR event, so the power management may be handled outside tvh."

What is meant by this?

Also available in: Atom PDF