[Approved] Fix for TsReader problems with TS files with PCR rollover (1 Viewer)

asselin

MP Donator
  • Premium Supporter
  • May 29, 2010
    9
    11
    Home Country
    United States of America United States of America
    Continuing this from the thread I started over here: https://forum.team-mediaportal.com/...ies-when-dealing-ts-files-pcr-rollover-97975/.

    TsReader has 2 bugs in it when dealing with TS files that have PCR rollover:
    1. When you start playback, MediaPortal freezes, HDD light goes solid, and after a while (could be minutes), the file starts playing back.
    2. While playing, if you try to skip forward or backward, the HDD light goes solid again, and then after a while, the recording restarts from the beginning.

    Problem #1 is a bug in TsDuration. It calculates the duration of the TS file by looking for the max PCR in the TS file before the rollover happens, and does this by a sequential (!) backwards (!!) file search. All that is unnecessary-- the code should just use a constant value (the MAX possible PCR of all binary 1s) as the value. The patch to TsDuration{.cpp,.h} below fixes this.

    Problem #2 is a bug in TsFileSeek. Here, there's a section of code specifically for scanning a TS file with PCR rollover in it, and there's an if() statement where the logic is backwards. Fixing the if() fixes the problem, but beyond that, there's a whole other algorithm in it to deal with skipping around in TS files with PCR rollover that is unnecessary. The standard binary search algorithm works just fine, and is in fact faster. The patch to TsFileSeek below fixes both of these.

    This is my first patch submission for MediaPortal, so if there are some rules (written or unwritten) that I haven't followed for patch submission, please let me know, and I'd be happy to work on the patches to get them into proper shape for inclusion.

    Thanks...
     

    Attachments

    • TsFileSeek.patch
      10.7 KB
    • TsDuration.simple.cpp.patch
      1.4 KB
    • TsDuration.h.patch
      311 bytes
    Last edited by a moderator:

    Owlsroost

    Retired Team Member
  • Premium Supporter
  • October 28, 2008
    5,540
    5,038
    Cambridge
    Home Country
    United Kingdom United Kingdom
    I keep getting "The patch seems outdated!" error messages from TortoiseSVN when I try to apply some of the patch files - is anyone else seeing this ?

    Tony
     

    asselin

    MP Donator
  • Premium Supporter
  • May 29, 2010
    9
    11
    Home Country
    United States of America United States of America
    I'm at work and don't have access to my dev PC right now, but I'll take a look at it tonight. I manually trimmed down the patch files before submitting because there were quite a few lines of just whitespace differences; I probably messed something up. Sorry for the wasted time-- I'll be more careful before submitting next time. :oops:
     

    Owlsroost

    Retired Team Member
  • Premium Supporter
  • October 28, 2008
    5,540
    5,038
    Cambridge
    Home Country
    United Kingdom United Kingdom
    No problem :) - I think you have to leave the .patch files untouched after generation (it was mis-matched whitespace-only lines generating the error message, as far as I can tell)

    Tony
     

    disaster123

    MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: Fix for TsReader problems with TS files with PCR rollover

    For me this results in non working seeking for live TV.
     

    asselin

    MP Donator
  • Premium Supporter
  • May 29, 2010
    9
    11
    Home Country
    United States of America United States of America
    OK, take 2, being more careful this time not to introduce stupid mistakes :oops: (sorry disaster123) and not edit patches after SVN creates them.

    Thanks...
     

    Attachments

    • TsDuration fix for PCR rollover.patch
      1.7 KB
    • TsFileSeek fix for PCR rollover.patch
      10.7 KB

    disaster123

    MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: Fix for TsReader problems with TS files with PCR rollover

    So seeking should work niw on LiveTV even when the ts buffer rollover happens?
     

    asselin

    MP Donator
  • Premium Supporter
  • May 29, 2010
    9
    11
    Home Country
    United States of America United States of America
    disaster123,

    From what tourettes explained to me on the other thread, PCR rollover should never occur when playing TS files recorded with MediaPortal because TsWriter modifies the PCR it writes into the TS file.

    There was a silly bug in the original patch I submitted that completely broke seek in all cases. I fixed that in the patch I just submitted.

    So in short, yes, this should work for you. If it doesn't, can you post the TsReader.log file?

    Thanks...
     

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    From what tourettes explained to me on the other thread, PCR rollover should never occur when playing TS files recorded with MediaPortal because TsWriter modifies the PCR it writes into the TS file.

    True. TsWriter will produce TS buffer files that start always from the 0 PCR value. So it will take 26+ hours to reach the PCR rollover in timeshifting buffer. It is highly likely that the 26+ hour mark is having similar issues as asselin has seen in the local TS files. It is even possible that asselin's fix allows more than 26+ hours of continuous live tv watching (as long as the buffer timespan itself is not bigger than 26+ hours).
     

    disaster123

    MP Donator
  • Premium Supporter
  • May 14, 2008
    3,558
    434
    Home Country
    Germany Germany
    AW: Fix for TsReader problems with TS files with PCR rollover

    OK will try again. Could it be that the Streamingserver component needs the same patch?
     

    Users who are viewing this thread

    Top Bottom