NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public NextPVR Support Windows v
1 2 3 4 5 … 108 Next »
Standby/Sleep During Playback

 
  • 0 Vote(s) - 0 Average
Standby/Sleep During Playback
fla
Offline

Posting Freak

Posts: 910
Threads: 47
Joined: Mar 2006
#51
2025-07-06, 04:03 AM
Here's the pwrtest output matching these actions:

22:29 Start playing
22:31  no more mouse movements on server
22:46 ping timeout & playback freezes
22:48 manual wol
22:48:27 ping ok & playback resumes

PS.
Unhid the unattended sleep mode and set it to zero (it was 10). My hibernate delay is 15 min and the powercfg /sleepstudy says that the "Remaining sleep timeout source" is "Hibernate Timeout". Hibernate indeed happens 15 min after stopping any server mouse activity.


Attached Files
.zip   pwrtest.zip (Size: 636 bytes / Downloads: 2)
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 54,424
Threads: 972
Joined: May 2006
#52
2025-07-06, 04:30 AM
You need to research ES_SYSTEM_REQUIRED and see why it isn't working on your system.

Martin
fla
Offline

Posting Freak

Posts: 910
Threads: 47
Joined: Mar 2006
#53
2025-07-07, 12:35 AM
My NextPVR server is Windows 11 and resetting the system idle timer with ES_SYSTEM_REQUIRED on Windows 11 fails:

But this does not work anymore on Windows 11

But in Windows 11, that doesn't work anymore

This powershell script that keeps windows from sleeping works on Windows 10 but not on Windows 11. I set my system to sleep after one minute to test.

Code:
$passlen = 1 # seconds between passes
$passNum = 0
$maxpass = 240 # after this number of passes, timer reset is skipped
$skipstr = ""

while ($true)
{
    $code=@'
[DllImport("kernel32.dll", CharSet = CharSet.Auto,SetLastError = true)]
  public static extern void SetThreadExecutionState(uint esFlags);
'@

    $ste = Add-Type -memberDefinition $code -name System -namespace Win32 -passThru
    $ES_CONTINUOUS = [uint32]"0x80000000" #Requests that the other EXECUTION_STATE flags set remain in effect until SetThreadExecutionState is called again with the ES_CONTINUOUS flag set and one of the other EXECUTION_STATE flags cleared.
    $ES_AWAYMODE_REQUIRED = [uint32]"0x00000040" #Requests Away Mode to be enabled.
    $ES_DISPLAY_REQUIRED = [uint32]"0x00000002" #Requests display availability (display idle timeout is prevented).
    $ES_SYSTEM_REQUIRED = [uint32]"0x00000001" #Requests system availability (sleep idle timeout is prevented).

    Switch ($option)
    {
      "Away" {$setting = $ES_AWAYMODE_REQUIRED}
      "Display" {$setting = $ES_DISPLAY_REQUIRED}
      "System" {$setting = $ES_SYSTEM_REQUIRED}
      Default {$setting = $ES_SYSTEM_REQUIRED}
    }

    if ( $passNum -lt $maxpass )
    {
        #$ste::SetThreadExecutionState($ES_SYSTEM_REQUIRED -bor $ES_DISPLAY_REQUIRED) # success
        $ste::SetThreadExecutionState($ES_SYSTEM_REQUIRED) # Win10 success, Win11 Fail

        $ste::SetThreadExecutionState($ES_CONTINUOUS)
    }
    elseif ( $passNum -eq $maxpass )
    {
        $skipstr = "(skipped)"
    }
    $passNum += 1
    Write-Host "Reset timer: pass #"$passNum time ($passNum * $passlen) seconds $skipstr
    Start-Sleep -Seconds $passlen;
}

Resetting the display idle timer (commented out) works on Windows 11 too but the screen stays on.
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 54,424
Threads: 972
Joined: May 2006
#54
2025-07-07, 01:01 AM
I read your link and it appears it works when it is on a timer like sub designed.

Martin.
fla
Offline

Posting Freak

Posts: 910
Threads: 47
Joined: Mar 2006
#55
2025-07-07, 03:15 AM
I failed to give you credit but the stackoverflow link was from your post. The WinSCP author answered his own question. He had to use the ES_CONTINUOUS API as in the Example in the learn.microsoft.com link also from your same post.

If sub used the ES_CONTINUOUS API during playback then we could see the persistent active power requests with powercfg /requests instead of requiring pwrtest.exe for transient things.

Resetting the system idle timer can be done willy-nilly by many threads. The ES_CONTINUOUS API requires clearing the EXECUTION_STATE flags when we're done which makes things much more complicated in a multi-threaded scenario. He used a separate thread to create the single continuous power request on the first thread's power request and cancels it after a 5 second timer expires. Each time any thread needs new/continued power, it's request causes the 5 second timer, if still active, to start over delaying the single power request's cancellation.

The powershell script above resets the system idle timer every 1 sec (observable with pwrtest.exe) kind of like sub's one minute timer during playback and that works great on Win10 but fails on Win11.
fla
Offline

Posting Freak

Posts: 910
Threads: 47
Joined: Mar 2006
#56
2025-11-27, 04:30 AM (This post was last modified: 2025-11-27, 04:32 AM by fla.)
The power management used by NextPVR server during remote playback no longer works on Windows 11. My family now has four Windows 11 systems and the powershell script in post #53 that mimics NextPVR now fails to prevent sleep on all of them. It worked on these same systems in Windows 10 before MS ended support and we upgraded them.

Using `SetThreadExecutionState`: Doesn't work anymore without ES_CONTINUOUS for no goddamn reason.
Solution from the comments. Basically (ES_SYSTEM_REQUIRED | ES_CONTINUOUS) called repeatedly from a thread that remains alive.

"If the system wakes automatically (PBT_APMRESUMEAUTOMATIC), none of the timers are relevant." (ref. Microsoft Docs)
In that case relying on resetting the system idle timer is risky even on Windows 10 when the system isn't woken up by a user (common for a NextPVR server).

Script: pwrtest.exe /es

Code:
Execution State Changed by a process

TimeStamp: 11/26/2025 13:08:49::878

Process: \Device\HarddiskVolume3\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

PID: 0x3a78

TID: 0x21a4

RawState: 0x00000001

Continuous: 0  Display:  0  System:  1  AwayMode: 0  UserPresent: 0

NextPVR: pwrtest.exe /es

Code:
Execution State Changed by a process

TimeStamp: 11/26/2025 13:28:06::919

Process: \Device\HarddiskVolume5\Program Files\NextPVR\NextPVRServer.exe

PID: 0x1a18

TID: 0x4ce4

RawState: 0x00000001

Continuous: 0  Display:  0  System:  1  AwayMode: 0  UserPresent: 0

Test Procedure:
  • Run NextPVR and play an old recording remotely
  • Run pwrtest.exe /es (if you want to track execution state changes)

Result:
  • The server sleeps despite the calls that used to work on Windows 10
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 54,424
Threads: 972
Joined: May 2006
#57
2025-11-27, 07:51 PM (This post was last modified: 2025-11-27, 08:12 PM by mvallevand.)
I think you are repeating the same message (and I don't disagree) that ES_CONTINUOUS should also be set with ES_SYSTEM_REQUIRED

Assuming that problem is revolved you won't have much time to start another recording or Live TV before unattended sleep mode or your device timeout occurs.

Martin
fla
Offline

Posting Freak

Posts: 910
Threads: 47
Joined: Mar 2006
#58
2025-11-28, 04:03 PM
Ya I'm no expert on this and don't know the best solution in the context of the NextPVR server code. When ES_CONTINUOUS is added then the system stays awake but the code has an added responsibility of removing it later at the appropriate moment. Not necessarily easy in the NextPVR code. I'm just happy that the new Windows 11 issue is acknowledged.

PS.
Sad face replaced the Jays logo. Still a great season getting to the World Series.
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 54,424
Threads: 972
Joined: May 2006
#59
2025-11-28, 06:32 PM
The series was so close, hopefully they have a chance in my lifetime.

NextPVR seems to reset the sleep timer okay, just not sure how you can avoid the issue of the server sleeping after the video stop especially if your hidden sleep timeout is short. I envision a cycle of sleep WOL sleep WOL happening.

Martin
fla
Offline

Posting Freak

Posts: 910
Threads: 47
Joined: Mar 2006
#60
2025-11-28, 07:26 PM
I didn't like the manager pulling top hitters out for pinch runners in a couple critical games then later unable to produce the winning run without top hitters... There's hope the Jays win soon. The Leafs... I wouldn't count on it.

The pwrtest.exe /es command you showed me does show NextPVR going through the motions of keeping the server awake by resetting the system idle timer. Is there a tool to view the current value of the system idle timer? Even after a fresh reboot my Windows 11 NextPVR server (just a regular PC with a screen) still goes to sleep during remote playback despite NextPVR making the calls that used to reset the timer on Windows 10 but no longer do on Windows 11.

Can someone set the system to sleep at 2 minutes and try the powershell script in post #53 or even remotely play with NextPVR and see if sleep on the server is prevented? The links I shared seem to indicate it's a Windows 11 issue and not something special with our 4 family PC's.
« Next Oldest | Next Newest »

Users browsing this thread: 3 Guest(s)

Pages (7): « Previous 1 … 3 4 5 6 7 Next »
Jump to page 


Possibly Related Threads…
Thread Author Replies Views Last Post
  [SOLVED] Windows won't sleep after waking for EPG update fla 2 243 2025-10-30, 07:56 PM
Last Post: fla
  NextPVRServer.exe preventing sleep after watching live TV alanteague 9 1,240 2025-08-09, 05:23 PM
Last Post: Bobins
  New Installation on WIN11 Sleep Problem 12vibes 3 722 2025-07-09, 03:57 PM
Last Post: 12vibes
  nextpvr.exe playback issues? hae 7 1,652 2025-05-31, 09:02 PM
Last Post: sub
  playback issue artmetz 4 1,056 2025-03-28, 07:47 PM
Last Post: artmetz
  NextPVRServer.exe (Version 7) Preventing Sleep PVR_Convert 4 1,044 2025-02-18, 07:18 PM
Last Post: mvallevand
  No standby after update to Version 7 Escape7 163 22,049 2025-01-04, 05:27 PM
Last Post: sub
  Jerky Playback at 2160p dshorrosh 6 1,320 2024-07-17, 01:49 PM
Last Post: mvallevand
  Error at 58 minutes playback Offroad 4 1,209 2024-06-01, 01:17 PM
Last Post: Offroad
  Recording wont resume, just playback from beginning dallascowboy23 26 5,793 2024-05-15, 01:35 PM
Last Post: mvallevand

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode