TVService does not call all PowerEventHandlers if Reinitialize Server is set (1 Viewer)

Charly_Brown

MP Donator
  • Premium Supporter
  • December 21, 2008
    19
    1
    Munich
    Germany Germany
    TV-Server Version: 1.0 Final
    MediaPortal Version: 1.0 Final
    MediaPortal Skin: Blue3
    Windows Version: Vista Home Premium 32bit SP1
    CPU Type: AMD Phenom X4
    HDD: Samsung 640GB
    Memory: 2GB
    Motherboard: Gigabyte MA78GPM-DS2H
    Video Card: HD3200
    Video Card Driver: Catalyst 8.12
    Sound Card:
    Sound Card AC3:
    Sound Card Driver:
    1. TV Card: Terratec Cinergy DVB-S2 HD
    1. TV Card Type:
    1. TV Card Driver:
    2. TV Card: Terratec Cinergy DVB-S2 HD CI
    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:
    MPEG2 Audio Codec:
    h.264 Video Codec:
    Satelite/CableTV Provider:
    HTPC Case:
    Cooling:
    Power Supply:
    Remote:
    TV:
    TV - HTPC Connection:

    Hi,

    I faced the same problems as reported in the threads
    Reinitalize Tuner Prevents Scheduled Recording
    and
    TV Problems In Vista


    After downloading the source from subversion I digged through Service1.cs::OnPowerEvent. The routine works fine as long as no reinitialization of the service is requested. In this case the current code calls all entries is the list of powerhandlerevents that are registered to the service. If reinitialization is requested the routine calls at first the powereventhandler of the service and there DeInit() is called. DeInit() causes all plugins to unregister from tvservice. As a consequence powerscheduler also unregisters not only from tvservice but also removes its own powereventhandler from the service. When the powereventhandler of the service returns there is no additional entry left in the list of powereventhandlers and so powerscheduler does not get informed about the shutdown.

    I modified the code to make sure that the list of powereventhandlers is worked through from the last to the first entry. This solves IMHO two problems

    1) The powereventhandler of the service is called as last and therefore all other registered powereventhandlers have been called before and have been executed. So when standby is requested the powerscheduler can set the next wakeup time
    2) If entries of a list are removed, while the program runs through the list, it might be possible that the program flow is interrupted, or parts of the list are not taken into account (At least this I faced when doing some programs in C++ and I guess there is no difference in C# ;) ).

    Okay here is the original code I'm talking about, taken from Service1.cs::OnPowerEvent
    Code:
          foreach (PowerEventHandler handler in _powerEventHandlers)
          {
              bool result = handler(powerStatus);
               if (result == false)
               {
                 accept = false;
                 powerEventPreventers.Add(handler);
               }
               else
                 powerEventAllowers.Add(handler);
          }
    And this is the modified code, where the list is worked through from the end.
    Code:
          for (int i = (_powerEventHandlers.Count - 1); i >= 0; i--)
          {
    
            PowerEventHandler handler = _powerEventHandlers[i];
    
            if (handler(powerStatus) == false)
            {
    
              accept = false;
              powerEventPreventers.Add(handler);
    
            }
            else
    
              powerEventAllowers.Add(handler);
    
          }
     

    ronilse

    Retired Team Member
  • Premium Supporter
  • July 19, 2005
    4,422
    282
    Moss
    Norway Norway
    Country flag
    Hi,
    Now confirmed & added to Mantis (I got a bit confused since it's 2 threads & early in morning, but now correct one it's updated ;) )

    Link to other thread


    Regards
    Roy
     

    ronilse

    Retired Team Member
  • Premium Supporter
  • July 19, 2005
    4,422
    282
    Moss
    Norway Norway
    Country flag
    Hi,
    With latest SVN this works here now, so please test it & give feedback(also post logs if it doesn't work).

    Regards
    Roy
     

    Charly_Brown

    MP Donator
  • Premium Supporter
  • December 21, 2008
    19
    1
    Munich
    Germany Germany
    Tested with new SVN,

    Wakeup Time is now correctly set. :D

    BTW Could someone update the SVN on sf.net :D

    Charly
     

    Users Who Are Viewing This Thread (Users: 0, Guests: 1)

    OP Similar threads Forum Replies Date
    Dark Eyes TVService locks up or fails to restart on resuming from sleep, and crashes when grabbing EPG Installation, configuration support 7
    T [solved] failed to-startup tvservice Installation, configuration support 1
    D TVService Probleme - getCards() Installationsprobleme? 1
    Requiem TVService stops Television (MyTV frontend and TV-Server) 4
    Pat Clark TVservice can't seem to initialize HDHomeRun channels Television (MyTV frontend and TV-Server) 0
    S Failed to startup tvservice Installation, configuration support 14
    M WTV Files does not play on client, MPEG files works well General 0
    D Does Schedules Direct work with mp 1.24? General Support 3
    J [solved] Blu-ray disc playback does not work. Bugreports 13
    horned_reaper [solved] When playing music Fanart does not shuffle Fanart Handler 20
    bigboss97 Does anyone has a SoundGraph imon remote file for MP2 to share? General 0
    horned_reaper [solved] When playing music Fanart does not appear immediately after downloading Fanart Handler 272
    D [solved] EPG Buddy for MP2 - Does it work? General 5
    L [solved] Why does Mediaportal 2 need access to my webcam? General 2
    R Directx 9.0 June 2010 does not install on Windows 10 x64, ends up with weird failure / no debug file Installation, configuration support 0
    M What does MP homeserver detection need at the client end, and what does the server need to transmit? General 6
    R TV menu icon does not work to return from sub-menu item Submit: Bug Reports 4
    N [confirm] Calling RemoveScheduleForProgramAsync does not stop the recording if it is currently in progress MediaPortal 2 1
    drumrob Time does not fit in white space 1.22 Pre Release 6
    N [Finished] [MP2-806] Playing a recorded radio program does not show screen to allow skipping forward, etc MediaPortal 2 141
    N [confirm] Playing a recording, then pressing stop does not leave cursor on the recording MediaPortal 2 21
    N [Finished] [MP2-783] Mapping Ctrl+Right as Next also does Right action when pressed. MediaPortal 2 21
    BlueMax1916 [Question] What does MP2 Server Service have to do with ...microsoft.com/filestreamingservice...? MediaPortal 2 3
    P Mediaportal does not allow my TV tuner to enter low power state General Support 1
    greybox 1.20 final does not update video duration automatically 1.20 10
    Similar threads

























    Top Bottom