[other] MPII - PowerScheduler (1 Viewer)

jameson_uk

Retired Team Member
  • Premium Supporter
  • January 27, 2005
    7,258
    2,528
    Birmingham
    Home Country
    United Kingdom United Kingdom
    Ever since about 1.0 RC1 I have had issues with standby. There is nothing with the hardware, this works every time and when MP is out of the equation. I think I have narrowed the issues down to the client plugin but that is where the fun starts. If you browse the forums there are hundreds of posts about problems with standby

    I had a look at the whole powerscheduler code and this is fairly horrendous. I am guessing there is still a lot of code in the clientside plugin left over from when the TV engine was in the client? Also the TV server side appears to still be using Win32 code that was deprecated with Vista. (trying to catch and handle shutdown messages). I can not reallly see why the clientside plugin still has things about waketimes etc.

    Anyway my suggestion for MPII is to have a seperate windows service handling standby. This would mean a single thread to actually handle putting the machine into standby (I am sure some of the problems I have are with the client plugin triggering a standby just as the TV server plugin does etc) and also make the code a million times more simple. All this would need is a plugin on both client and TV server that responded to "CanIGoToSleep" type message and a "WhatTimeDoYouWantMeToWakeYouUp" type message.

    The standby service code could then just be as simple as a timer which fires every so often and sends the message to all the registered plugins (could be extended for other things including those outside of MP). If all the registered plugins respond yes then the service could then kick off the standby process. The plugin code becomes simple too as you have a client plugin which when asked "CanIGoToSleep" just needs to check if anything is playing (and if needed whether on the home screen) and the TV server just needs to check whether it is timeshifting / recording or whether a new recording is due to start within the timeout period.

    Once the service has decided to put the system to sleep it could then ask when to wake and again be a single point of setting the next wake time. Also at this point it would be relatively simple to close MP client if that is what users want.

    I was going to code up this for MP I but since I have turned off the client plugin (and close MP when I am done) I have not had any more issues and I am not sure I can spend the time on doing this properly. In the meantime I think I will create an alternative client plugin which will force the machine to stay awake using SetThreadExecutionState() with ES_CONTINUOUS | ES_DISPLAY_REQUIRED values to prevent standby by default. I will then set a timer and just check there is nothing playing on the global player and we are in home screen. Then after 10 mins I will reset SetThreadExecutionState() to normal values allowing the TV server to take over standby duties

    Anyway make sure you use the correct API calls
    SetThreadExecutionState Function (Windows)

    and not the deprecated method of catching PBT_APMQUERYSUSPEND window messages which is used now
     

    JoeSmith

    Portal Pro
    November 17, 2007
    314
    44
    Home Country
    Germany Germany
    i'm by far not an expert on standby, but i really don't understand why we need something like powerscheduler. I've used it in the past but when i switched to ForTheRecord i started to only use windows for standby and it works 100%. A lot of people seem to struggle with powerscheduler so this should be done in MP. I guess right now it's too early to talk about MPII, but collecting ideas is never wrong.
     

    jameson_uk

    Retired Team Member
  • Premium Supporter
  • January 27, 2005
    7,258
    2,528
    Birmingham
    Home Country
    United Kingdom United Kingdom
    i'm by far not an expert on standby, but i really don't understand why we need something like powerscheduler. I've used it in the past but when i switched to ForTheRecord i started to only use windows for standby and it works 100%. A lot of people seem to struggle with powerscheduler so this should be done in MP. I guess right now it's too early to talk about MPII, but collecting ideas is never wrong.

    If you set the power options in windows to go to sleep after 10 minutes of inactivity it treats many things (video /music playback and TV recording being the main ones we are interested in) as not being active. So if you put a DVD on then after 10 minutes it will put the system to sleep which would be kind of annoying...

    4TR has its own powerscheduler type functionality built in
     

    Users who are viewing this thread

    Top Bottom