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...
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
Last edited by a moderator: