1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

The MTD mapper now avoids immediately reusing unique PIDs when switching channels

This commit is contained in:
Klaus Schmidinger 2017-10-31 12:20:56 +01:00
parent 19275aa8bb
commit c08ed3ce44
3 changed files with 14 additions and 2 deletions

View File

@ -3514,3 +3514,6 @@ Frank Richter <kulpstur@t-online.de>
Daniel Scheller <d.scheller@gmx.net> Daniel Scheller <d.scheller@gmx.net>
for reporting a problem with detecting whether a CAM replies to queries, which didn't for reporting a problem with detecting whether a CAM replies to queries, which didn't
work on some systems since the implementation of RI_HOST_CONTROL work on some systems since the implementation of RI_HOST_CONTROL
Onur Sentürk <onur@sentek.org>
for making the MTD mapper avoid immediately reusing unique PIDs when switching channels

View File

@ -9174,3 +9174,5 @@ Video Disk Recorder Revision History
of low disk space. of low disk space.
- Now making sure that AssertFreeDiskSpace() is called with the maximum timer - Now making sure that AssertFreeDiskSpace() is called with the maximum timer
priority in case there are several timers recording with different priorities. priority in case there are several timers recording with different priorities.
- The MTD mapper now avoids immediately reusing unique PIDs when switching channels,
to prevent possible problems with old data in buffers (thanks to Onur Sentürk).

11
mtd.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: mtd.c 1.11 2017/05/01 09:19:52 kls Exp $ * $Id: mtd.c 1.12 2017/10/31 12:16:39 kls Exp $
*/ */
#include "mtd.h" #include "mtd.h"
@ -148,6 +148,7 @@ class cMtdMapper {
private: private:
int number; int number;
int masterCamSlotNumber; int masterCamSlotNumber;
int nextUniqPid;
uint16_t uniqPids[MAX_REAL_PIDS]; // maps a real PID to a unique PID uint16_t uniqPids[MAX_REAL_PIDS]; // maps a real PID to a unique PID
uint16_t realPids[MAX_UNIQ_PIDS]; // maps a unique PID to a real PID uint16_t realPids[MAX_UNIQ_PIDS]; // maps a unique PID to a real PID
cVector<uint16_t> uniqSids; cVector<uint16_t> uniqSids;
@ -165,6 +166,7 @@ cMtdMapper::cMtdMapper(int Number, int MasterCamSlotNumber)
{ {
number = Number; number = Number;
masterCamSlotNumber = MasterCamSlotNumber; masterCamSlotNumber = MasterCamSlotNumber;
nextUniqPid = 0;
Clear(); Clear();
} }
@ -179,11 +181,15 @@ uint16_t cMtdMapper::MakeUniqPid(uint16_t RealPid)
DBGMTD("CAM %d/%d: mapped PID %d (%04X) to %d (%04X)", masterCamSlotNumber, number, RealPid, RealPid, uniqPids[RealPid], uniqPids[RealPid]); DBGMTD("CAM %d/%d: mapped PID %d (%04X) to %d (%04X)", masterCamSlotNumber, number, RealPid, RealPid, uniqPids[RealPid], uniqPids[RealPid]);
return uniqPids[RealPid]; return uniqPids[RealPid];
#else #else
for (int i = 0; i < MAX_UNIQ_PIDS; i++) { for (int p = 0; p < MAX_UNIQ_PIDS; p++) {
int i = nextUniqPid + p;
if (i >= MAX_UNIQ_PIDS)
i -= MAX_UNIQ_PIDS;
if (realPids[i] == MTD_INVALID_PID) { // 0x0000 is a valid PID (PAT)! if (realPids[i] == MTD_INVALID_PID) { // 0x0000 is a valid PID (PAT)!
realPids[i] = RealPid; realPids[i] = RealPid;
uniqPids[RealPid] = (number << UNIQ_PID_SHIFT) | i; uniqPids[RealPid] = (number << UNIQ_PID_SHIFT) | i;
DBGMTD("CAM %d/%d: mapped PID %d (%04X) to %d (%04X)", masterCamSlotNumber, number, RealPid, RealPid, uniqPids[RealPid], uniqPids[RealPid]); DBGMTD("CAM %d/%d: mapped PID %d (%04X) to %d (%04X)", masterCamSlotNumber, number, RealPid, RealPid, uniqPids[RealPid], uniqPids[RealPid]);
nextUniqPid = i + 1;
return uniqPids[RealPid]; return uniqPids[RealPid];
} }
} }
@ -212,6 +218,7 @@ void cMtdMapper::Clear(void)
DBGMTD("CAM %d/%d: MTD mapper cleared", masterCamSlotNumber, number); DBGMTD("CAM %d/%d: MTD mapper cleared", masterCamSlotNumber, number);
memset(uniqPids, 0, sizeof(uniqPids)); memset(uniqPids, 0, sizeof(uniqPids));
memset(realPids, MTD_INVALID_PID, sizeof(realPids)); memset(realPids, MTD_INVALID_PID, sizeof(realPids));
// do not reset nextUniqPid here!
uniqSids.Clear(); uniqSids.Clear();
} }