[confirm] - Powersaving kicks in if videos run too long

Discussion in 'MediaPortal 1.1.0 RC 1 & 2' started by Flaamwing, March 5, 2010.

  1. Flaamwing

    Flaamwing New Member

    Joined:
    March 5, 2010
    Messages:
    3
    Likes Received:
    0
    Ratings:
    +0 / 0
    Windows power saving has turned off my monitors and TV while I'm in the middle of watching a video. I suggest, and have tested, the following patch. I ask that you please implement it or a variant to let windows know that something is happening, so it doesn't stop the system.

    Thanks

    Index: g_player.cs
    ===================================================================
    --- g_player.cs (revision 25174)
    +++ g_player.cs (working copy)
    @@ -24,6 +24,7 @@
    using System.Globalization;
    using System.IO;
    using System.Runtime.CompilerServices;
    +using System.Runtime.InteropServices;
    using System.Text;
    using System.Windows.Forms;
    using MediaPortal.Configuration;
    @@ -39,8 +40,27 @@
    {
    public class g_Player
    {
    + [DllImport("Kernel32.DLL", CharSet = CharSet.Auto, SetLastError = true)]
    + private extern static EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE state);
    +
    #region enums

    + [FlagsAttribute]
    + public enum EXECUTION_STATE : uint
    + {
    + ES_SYSTEM_REQUIRED = 0x00000001,
    + ES_DISPLAY_REQUIRED = 0x00000002,
    + // Legacy flag, should not be used.
    + // ES_USER_PRESENT = 0x00000004,
    + ES_CONTINUOUS = 0x80000000,
    + }
    +
    + public enum SPI : uint
    + {
    + SPI_GETPOWEROFFACTIVE = 0x0054,
    + SPI_SETPOWEROFFACTIVE = 0x0056
    + }
    +
    public enum MediaType
    {
    Video,
    @@ -484,6 +504,7 @@
    currentFileName = String.Empty;
    _mediaInfo = null;
    }
    + SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS);
    }
    }



    @@ -499,6 +520,7 @@
    RefreshRateChanger.AdaptRefreshRate();
    currentFileName = String.Empty;
    _mediaInfo = null;
    + SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS);
    }
    }

    @@ -538,6 +560,13 @@
    {
    PlayBackStarted(_currentMedia, _currentFilePlaying);
    }
    +
    + // If we have Video of some sort
    + if(HasVideo || HasViz)
    + {
    + // Disable the screensaver/powersaving
    + SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS | EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_DISPLAY_REQUIRED);
    + }
    }
    }




    MediaPortal Version: 1.1 rc1
    MediaPortal Skin: Blue Wide
    Windows Version: 7
    CPU Type: Intel i7
    HDD: 2
    Memory: 12 gb
    Motherboard: dont remember
    Video Card: nVidia
    Video Card Driver: nVidia
    Sound Card: built into motherboard
    Sound Card AC3: no idea
    Sound Card Driver: no idea
    1. TV Card: none
    1. TV Card Type:
    1. TV Card Driver:
    2. TV Card:
    2. TV Card Type:
    2. TV Card Driver:
    3. TV Card:
    3. TV Card Type:
    3. TV Card Driver:
    4. TV Card:
    4. TV Card Type:
    4. TV Card Driver:
    MPEG2 Video Codec: ffmpg
    MPEG2 Audio Codec: ffmpg
    h.264 Video Codec: ffmpg
    Satelite/CableTV Provider: none
    HTPC Case:
    Cooling: yes?
    Power Supply: yes?
    Remote: usbuirt
    TV: none
    TV - HTPC Connection: none
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. bugmenot

    bugmenot Portal Pro

    Joined:
    January 13, 2007
    Messages:
    130
    Likes Received:
    2
    Ratings:
    +2 / 0
    have not tried this out yet with MP. But i had the problem with a friends app. (believe but havent checked that screen stays on in older versions)
    but for win 7: SC_MONITORPOWER in Windows 7?

    agree that SetThreadExecutionState() would be nice
     
  4. Terra

    Terra Portal Pro

    Joined:
    August 25, 2009
    Messages:
    230
    Likes Received:
    36
    Ratings:
    +55 / 1
    Home Country:
    Austria Austria
    Show System Specs
    Maybe my problem is related to this. After watching a video, the monitor/beamer instantly looses the video signal at the end and goes into standby. A click on the remote brings the signal back but it's really annoying.
     
  5. jameson_uk
    • Premium Supporter

    jameson_uk Retired Team Member

    Joined:
    January 27, 2005
    Messages:
    7,258
    Likes Received:
    2,228
    Gender:
    Male
    Occupation:
    Data Warehousing Consultant
    Location:
    Birmingham
    Ratings:
    +2,405 / 0
    Home Country:
    United Kingdom United Kingdom
    Show System Specs
    I am not at home to check but IIRC the issue with that code is it will not work under XP (Win32 power code changed a lot between XP and Vista)

    Do you have the PowerScheduler plugin enabled? I think you need to have this enabled to prevent standby
     
  6. bugmenot

    bugmenot Portal Pro

    Joined:
    January 13, 2007
    Messages:
    130
    Likes Received:
    2
    Ratings:
    +2 / 0
    That sounds like it keeps the screen away for the time Video is running, but the counter is not reset at the end so windows turns screen off.

    => sounds like a different problem. But i think with Flaamwings code it would be solved as well.

    i disagree. would work for win 2000 and up
    Code (Text):
    1. SetThreadExecutionState:
    2. Minimum supported client:   Windows 2000 Professional
     
  7. jameson_uk
    • Premium Supporter

    jameson_uk Retired Team Member

    Joined:
    January 27, 2005
    Messages:
    7,258
    Likes Received:
    2,228
    Gender:
    Male
    Occupation:
    Data Warehousing Consultant
    Location:
    Birmingham
    Ratings:
    +2,405 / 0
    Home Country:
    United Kingdom United Kingdom
    Show System Specs
    I think it was more the integration into the Powerscheduler code which for XP still intercepts requests to standby and then tries to block them. I seem to recall getting some very odd unexpected results combining this (good code) with the XP powerscheduler code

    Also as I said above, I belive the MP design is for power to be controlled via PowerScheduler. I guess some peope might want it to time out and go to sleep if they fall asleep whilst watching TV (indeed I would imagine this code will break the plugin which acts as a sleep timer)
     
  8. infinite.loop
    • Premium Supporter

    infinite.loop Retired Team Member

    Joined:
    December 26, 2004
    Messages:
    16,163
    Likes Received:
    3,861
    Gender:
    Male
    Location:
    127.0.0.1
    Ratings:
    +4,154 / 7
    Home Country:
    Austria Austria
    Show System Specs
    Flaamwing

    Can you please post this in the "submit patches" section?
    That would be the right way to get patches evaluated by our devs. :)
     
  9. Flaamwing

    Flaamwing New Member

    Joined:
    March 5, 2010
    Messages:
    3
    Likes Received:
    0
    Ratings:
    +0 / 0
  10. bobbyd87

    bobbyd87 Portal Pro

    Joined:
    January 28, 2007
    Messages:
    61
    Likes Received:
    5
    Ratings:
    +5 / 0
    Home Country:
    United States of America United States of America
    I have this issue as well. I have monitor blanking at 5 minutes. If i do not touch my keyboard/mouse for the last 5 or more minutes of a video, it will immediately blank when it is finished.
     
  11. infinite.loop
    • Premium Supporter

    infinite.loop Retired Team Member

    Joined:
    December 26, 2004
    Messages:
    16,163
    Likes Received:
    3,861
    Gender:
    Male
    Location:
    127.0.0.1
    Ratings:
    +4,154 / 7
    Home Country:
    Austria Austria
    Show System Specs
    Just sent a reminder to our devs to take care about the patch. :)
     
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!