Schedule currently running program starts too late (1 Viewer)

El Gitto

Portal Member
November 4, 2006
22
1
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:
MP log:
2009-04-19 14:57:08.797967 [Debug][MPMain]: Window: TvPlugin.TVProgramInfo init
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
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
2009-04-19 14:57:10.571967 [Debug][MPMain]: TVProgramInfo.CreateProgram - no series schedule
2009-04-19 14:57:10.651967 [Debug][MPMain]: TVProgramInfo.CreateProgram - conflicts.Count = 0
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

TV-server log:
2009-04-19 14:59:28.226967 [Scheduler timer]: Recording InFocus  added in _recordingsInProgressList
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

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
 

El Gitto

Portal Member
November 4, 2006
22
1
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
 

infinite.loop

Retired Team Member
  • Premium Supporter
  • December 26, 2004
    16,163
    4,133
    127.0.0.1
    Home Country
    Austria Austria
    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
     

    arion_p

    Retired Team Member
  • Premium Supporter
  • February 7, 2007
    3,373
    1,626
    Athens
    Home Country
    Greece Greece
    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:
       public void OnNewSchedule()
        {
          try
          {
            [B]Gentle.Common.CacheManager.ClearQueryResultsByType(typeof(Schedule));[/B]
            if (_scheduler != null)
            {
              _scheduler.ResetTimer();
            }
            Fire(this, new TvServerEventArgs(TvServerEventType.ScheduledAdded));
    
          } catch (Exception ex)
          {
            Log.Write(ex);
            return;
          }
        }

    I'm going to try it tonight when I get home.



    cheers,

    Arion
     

    El Gitto

    Portal Member
    November 4, 2006
    22
    1
    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
     

    gemx

    Retired Team Member
  • Premium Supporter
  • October 31, 2006
    1,972
    539
    Home Country
    Germany Germany
    Thanks arion_p, that is a very nice solution for this bug.
    Just uploaded the changes to SVN.

    :D
     

    Users who are viewing this thread

    Top Bottom