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

If one PID can't be added, the whole cDevice::AttachReceiver() will now fail

This commit is contained in:
Klaus Schmidinger 2004-10-17 09:42:36 +02:00
parent 1f726846f5
commit eb18d4a5b0
3 changed files with 27 additions and 7 deletions

View File

@ -1051,6 +1051,8 @@ Marco Schl
finally lead to finding out that the basic problem causing buffer overflows was in finally lead to finding out that the basic problem causing buffer overflows was in
EnableGet()/EnablePut() being called too often EnableGet()/EnablePut() being called too often
for avoiding unnecessary section filter start/stops for avoiding unnecessary section filter start/stops
for pointing out that if one PID can't be added, the whole cDevice::AttachReceiver()
should fail and all PIDs added so far should be deleted
Jürgen Schmitz <j.schmitz@web.de> Jürgen Schmitz <j.schmitz@web.de>
for reporting a bug in displaying the current channel when switching via the SVDRP for reporting a bug in displaying the current channel when switching via the SVDRP

View File

@ -3026,3 +3026,6 @@ Video Disk Recorder Revision History
- Now skipping code table info in SI data (suggested by Milos Kapoun). - Now skipping code table info in SI data (suggested by Milos Kapoun).
- Added missing Czech characters to fontosd-iso8859-2.c (thanks to Milos Kapoun). - Added missing Czech characters to fontosd-iso8859-2.c (thanks to Milos Kapoun).
- Fixed a crash in the time search mechanism (reported by Reinhard Nissl). - Fixed a crash in the time search mechanism (reported by Reinhard Nissl).
- If one PID can't be added, the whole cDevice::AttachReceiver() will now fail
and all PIDs added so far will be deleted (thanks to Marco Schlüßler for
pointing out this one).

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: device.c 1.59 2004/10/16 13:49:35 kls Exp $ * $Id: device.c 1.60 2004/10/17 09:39:10 kls Exp $
*/ */
#include "device.h" #include "device.h"
@ -248,7 +248,11 @@ bool cDevice::AddPid(int Pid, ePidType PidType)
if (++pidHandles[n].used == 2 && n <= ptTeletext) { if (++pidHandles[n].used == 2 && n <= ptTeletext) {
// It's a special PID that may have to be switched into "tap" mode // It's a special PID that may have to be switched into "tap" mode
PRINTPIDS("A"); PRINTPIDS("A");
return SetPid(&pidHandles[n], n, true); if (!SetPid(&pidHandles[n], n, true)) {
esyslog("ERROR: can't set PID %d on device %d", Pid, CardIndex() + 1);
DelPid(Pid, PidType);
return false;
}
} }
PRINTPIDS("a"); PRINTPIDS("a");
return true; return true;
@ -261,13 +265,19 @@ bool cDevice::AddPid(int Pid, ePidType PidType)
// The Pid is not yet in use and we have a free slot // The Pid is not yet in use and we have a free slot
n = a; n = a;
} }
else else {
esyslog("ERROR: no free slot for PID %d", Pid); esyslog("ERROR: no free slot for PID %d on device %d", Pid, CardIndex() + 1);
return false;
}
if (n >= 0) { if (n >= 0) {
pidHandles[n].pid = Pid; pidHandles[n].pid = Pid;
pidHandles[n].used = 1; pidHandles[n].used = 1;
PRINTPIDS("C"); PRINTPIDS("C");
return SetPid(&pidHandles[n], n, true); if (!SetPid(&pidHandles[n], n, true)) {
esyslog("ERROR: can't set PID %d on device %d", Pid, CardIndex() + 1);
DelPid(Pid, PidType);
return false;
}
} }
} }
return true; return true;
@ -757,8 +767,13 @@ bool cDevice::AttachReceiver(cReceiver *Receiver)
return true; return true;
for (int i = 0; i < MAXRECEIVERS; i++) { for (int i = 0; i < MAXRECEIVERS; i++) {
if (!receiver[i]) { if (!receiver[i]) {
for (int n = 0; n < MAXRECEIVEPIDS; n++) for (int n = 0; n < MAXRECEIVEPIDS; n++) {
AddPid(Receiver->pids[n]);//XXX+ retval! if (!AddPid(Receiver->pids[n])) {
for ( ; n-- > 0; )
DelPid(Receiver->pids[n]);
return false;
}
}
Receiver->Activate(true); Receiver->Activate(true);
Lock(); Lock();
Receiver->device = this; Receiver->device = this;