Schedule currently running program starts too late

Discussion in '1.0.1 and SVN Builds' started by El Gitto, April 19, 2009.

  1. El Gitto

    El Gitto Portal Member

    Joined:
    November 4, 2006
    Messages:
    22
    Likes Received:
    1
    Ratings:
    +1 / 0
    Home Country:
    Netherlands Netherlands
    TV-Server Version: 1.0.1
    MediaPortal Version: 1.0.1
    MediaPortal Skin: Blue3wide
    Windows Version: Vista SP1
    CPU Type: Intel P4 3Ghz
    HDD: WD 500GB
    Memory: 2GB DDR2
    Motherboard: Intel
    Video Card: MSI Radeon X300
    Video Card Driver: 7.14.10.8333
    Sound Card: Onboard HD audio
    Sound Card AC3:
    Sound Card Driver:
    1. TV Card: FloppyDTV
    1. TV Card Type: DVB-C
    1. TV Card Driver: 4.8.0.0
    2. TV Card: FloppyDTV
    2. TV Card Type: DVB-C
    2. TV Card Driver: 4.8.0.0
    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: Vista default
    h.264 Video Codec:
    Satelite/CableTV Provider:
    HTPC Case:
    Cooling:
    Power Supply:
    Remote:
    TV:
    TV - HTPC Connection:

    When I schedule a TV program that is currently running, sometimes the recording starts too late. I believe the recording should start immediately. Description:
    1) Go the the TV guide;
    2) Right click on a current running program;
    3) Select "3 Record" in the popup window;
    4) Select "Record" on the top left;



    In the attached logs, the recording started after one minute, but the gap has been more than 10 minutes at several occasions. Here's a log entry where the gap was 2.5 minutes:

    Code (Text):
    1.  
    2. MP log:
    3. 2009-04-19 14:57:08.797967 [Debug][MPMain]: Window: TvPlugin.TVProgramInfo init
    4. 2009-04-19 14:57:10.558967 [Debug][MPMain]: TVProgammInfo.OnRecordProgram - programm = InFocus(ID:0) on 138 19-4-2009 14:25:00 - 19-4-2009 15:00:00
    5. 2009-04-19 14:57:10.570967 [Debug][MPMain]: TVProgramInfo.CreateProgram: program = InFocus(ID:0) on 138 19-4-2009 14:25:00 - 19-4-2009 15:00:00
    6. 2009-04-19 14:57:10.571967 [Debug][MPMain]: TVProgramInfo.CreateProgram - no series schedule
    7. 2009-04-19 14:57:10.651967 [Debug][MPMain]: TVProgramInfo.CreateProgram - conflicts.Count = 0
    8. 2009-04-19 14:57:10.651967 [Debug][MPMain]: TVProgramInfo.CreateProgram - create schedule = InFocus on 138 19-4-2009 14:25:00 - 19-4-2009 15:00:00  ID=0
    9.  
    10. TV-server log:
    11. 2009-04-19 14:59:28.226967 [Scheduler timer]: Recording InFocus  added in _recordingsInProgressList
    12. 2009-04-19 14:59:28.228967 [Scheduler timer]: Scheduler : time to record TvDatabase.Channel 19-4-2009 14:59:28-19-4-2009 15:00:00 InFocus
    13.  
    Like I said, the recording should start right away and this should be handled by the TV-server, not the client. After the OnNewSchedule() function has been called, the TV-server should check if it should start recording.

    Thanks for looking into this. I think the new tv server is working great, and very reliable, except for this one issue.

    Chris
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. El Gitto

    El Gitto Portal Member

    Joined:
    November 4, 2006
    Messages:
    22
    Likes Received:
    1
    Ratings:
    +1 / 0
    Home Country:
    Netherlands Netherlands
    OK, there doesn't seem to be much interest in this bug, so I decided to debug the tvserver myself. And I found out there's a problem in the coding that gets the schedules from the database. It's in scheduler.cs, method DoSchedule(). This executes the following line: IList<Schedule> schedules = Schedule.ListAll();
    For my testing I add a schedule using the tv client and I check the database table "schedule" using MySQL Query Browser and I see the record is there. But the Schedule.ListAll() returns an empty IList. It can take several minutes for this to change (the check is done every 15 seconds).
    Could this be some kind of cashing error of the database? Btw, the MS SQL has the same problem.

    I hope I've interested a developer to take a look at this. This issue isn't solved in release 1.0.2.

    Chris
     
  4. 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
    I have seen this "issue" myselfe on the live system that it can take several minutes until the recording of an in-progress tv-show starts.

    will add that to mantis. :)

    :D
     
  5. arion_p
    • Premium Supporter

    arion_p Retired Team Member

    Joined:
    February 7, 2007
    Messages:
    3,352
    Likes Received:
    1,447
    Occupation:
    Developer
    Location:
    Athens
    Ratings:
    +1,522 / 0
    Home Country:
    Greece Greece
    Show System Specs
    Hi,

    I think El, Gitto is right. It is a caching issue. The caching is done by the Gentle framework.
    I took a quick look at the code of TvServer and TvPlugin. Cacheing is enabled in TvServer so Schedule.ListAll() will return cached data. Normally this is not a problem because when Schedule objects are persisted in TvServer, the framework automatically invalidates the cache.

    But when a new schedule is created in TvPlugin, TvPlugin.TVProgramInfo.CreateProgram(...) uses it own instance of the Gentle framework to insert the new schedule in the database. The Gentle framework in TvServer does not invalidate its cache because it is unaware of the new schedule. CreateProgram(...) in TvPlugin also calls server.OnNewSchedule() which in turn calls TvService.TVController.OnNewSchedule() on the TvServer which in turn resets the scheduler timer but does not clear the Gentle cache.

    I think the following change in TvController would fix the problem:
    Code (Text):
    1.  
    2.    public void OnNewSchedule()
    3.     {
    4.       try
    5.       {
    6.         [B]Gentle.Common.CacheManager.ClearQueryResultsByType(typeof(Schedule));[/B]
    7.         if (_scheduler != null)
    8.         {
    9.           _scheduler.ResetTimer();
    10.         }
    11.         Fire(this, new TvServerEventArgs(TvServerEventType.ScheduledAdded));
    12.  
    13.       } catch (Exception ex)
    14.       {
    15.         Log.Write(ex);
    16.         return;
    17.       }
    18.     }
    19.  
    I'm going to try it tonight when I get home.



    cheers,

    Arion
     
    • Like Like x 3
  6. El Gitto

    El Gitto Portal Member

    Joined:
    November 4, 2006
    Messages:
    22
    Likes Received:
    1
    Ratings:
    +1 / 0
    Home Country:
    Netherlands Netherlands
    This is great news, guys. Thanks for your help. I just tested Arion's suggestion and this seems to work fine.

    Chris
     
    • Like Like x 1
  7. gemx
    • Premium Supporter

    gemx Retired Team Member

    Joined:
    October 31, 2006
    Messages:
    1,972
    Likes Received:
    541
    Ratings:
    +541 / 0
    Home Country:
    Germany Germany
    Show System Specs
    Thanks arion_p, that is a very nice solution for this bug.
    Just uploaded the changes to SVN.

    :D
     
    • Like Like x 1
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!