no-shutdown-if-pvr-is-not-idle
#1
Hi there, maybe someone can help: If my kodi is recording (TV) (dvblink pvr) it is possible to shut down that pc. I all control it with a harmony one, so it is a one button switch off.
In MCE it wasn't the case, the htpc stayed on during recording and puts the htpc into sleep after the recording was finish. Now in kodi it isn't? Wake from sleep to do a recording works, and it also goback into sleep after finish if i don't interfear.
Maybe someone can help?
Reply
#2
did a test with awaymode on in mce standbytool and now pc stays on during recording but than the windows pc doesn't shut down after recording has finished, must i set something else in the energy settings from windows? Pc goes to sleep after 20 min without user activity. But when i set awaymode in mce standbytool it doesn't.
Reply
#3
nobody have this problem?
Reply
#4
I don't power down my media centre. Instead I send it to sleep. The DVBLogic stuff keeps the PC running even though I request it to sleep. I have a short timeout (3 minutes) so sleep happens automatically and quickly after recording finishes. I also use a simple utility to prevent sleep at other times (it resets after waking from sleep so that wake-ups during the night don't keep the PC running).

If I know there's a recording happening (or something else I want to keep running), I switch off my utility and leave the media centre to go to sleep automatically when the activity finishes.

Not much help to you, but explains why I don't have the issue.

Andy
Reply
#5
Ok thanks, i did that also before, but i remember from when i was using mce that wasn't so, mce did go automatically into sleep after no userinput from 6 min. If a recording was goin on and i switched off tv, receiver and pc( sleep mode) with my harmony one than the pc would stayed on until the recording was finish. But now with kodi i haven't got this goin well, kodi starts ok from sleep to do recording and goes into sleep after that, but when i have all on and a recording has started i can switch the pc into sleep mode.mso this than result in incomplete recordings. I have tried mce standbytool and set there awaymode on, than it works: if i switch during recording all off ( pc sleepmode) than the pc stays on but it will not go into sleep automatically after the recording has finished, what utility do you use.?
Reply
#6
I wrote my own utility.The key fragments of C# are:

Code:
...
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags);
[FlagsAttribute]
public enum EXECUTION_STATE : uint
{
    ES_AWAYMODE_REQUIRED = 0x00000040,
    ES_CONTINUOUS = 0x80000000,
    ES_DISPLAY_REQUIRED = 0x00000002,
    ES_SYSTEM_REQUIRED = 0x00000001
}
...
protected override void WndProc(ref Message message)
{
    // Process messages for this form
    if (message.Msg == Pinvoke.WM_POWERBROADCAST)
    {
        // This is a power broadcast, see if we've returned from suspension
        if ((UInt32)message.WParam == Pinvoke.PBT_APMRESUMEAUTOMATIC ||
            (UInt32)message.WParam == Pinvoke.PBT_APMRESUMECRITICAL ||
            (UInt32)message.WParam == Pinvoke.PBT_APMRESUMESUSPEND)
        {
            // We've woken up from suspend.
            // Reset the launcher so we're not preventing suspend any more
            EnableSleep();
        }
    }
base.WndProc(ref message);
}
...
// Routines EnableSleep() and DisableSleep start and stop a timer that calls ...
private void timerPreventSleep_Tick(object sender, EventArgs e)
{
      // Wakes up every 30 seconds to reset the idle timer
      SetThreadExecutionState(EXECUTION_STATE.ES_SYSTEM_REQUIRED);
}
...
static class Pinvoke
{
...
        public const UInt32 WM_POWERBROADCAST = 536;
        public const UInt32 PBT_APMRESUMEAUTOMATIC = 18;
        public const UInt32 PBT_APMRESUMECRITICAL = 6;
        public const UInt32 PBT_APMRESUMESUSPEND = 7;
...
}
...

Andy
Reply
#7
ok where do i put this code?
Reply
#8
Sorry, not a good place for a C# / .NET tutorial. If you're not already into that environment the code is no help.

Andy
Reply

Logout Mark Read Team Forum Stats Members Help
no-shutdown-if-pvr-is-not-idle0