--- device.c.orig 2008-12-21 15:46:20.000000000 +0100 +++ device.c 2008-12-21 15:51:44.000000000 +0100 @@ -384,6 +384,8 @@ cCamSlot *s = NULL; uint32_t Impact = 0xFFFFFFFF; // we're looking for a device with the least impact + printf("Impact: LiDeReTrPriPrcNdPrCiDeDc\n"); + int besti=0, bestj=0; for (int j = 0; j < NumCamSlots || !NumUsableSlots; j++) { if (NumUsableSlots && SlotPriority[j] > MAXPRIORITY) continue; // there is no CAM available in this slot @@ -419,10 +421,29 @@ imp <<= 1; imp |= NumUsableSlots ? 0 : device[i]->HasCi(); // avoid cards with Common Interface for FTA channels imp <<= 1; imp |= device[i]->HasDecoder(); // avoid full featured cards imp <<= 1; imp |= NumUsableSlots ? !ChannelCamRelations.CamDecrypt(Channel->GetChannelID(), j + 1) : 0; // prefer CAMs that are known to decrypt this channel + + #define bitextract(u, bit, len) (((u) >> (bit)) & ((1 << (len)) - 1)) + printf("Dev %2i.%02i: %i %i %i %i %02x %02x %i %i %i %i %i\n", + i, + j, + bitextract(imp, 24, 1), + bitextract(imp, 23, 1), + bitextract(imp, 22, 1), + bitextract(imp, 21, 1), + bitextract(imp, 13, 8), + bitextract(imp, 5, 8), + bitextract(imp, 4, 1), + bitextract(imp, 3, 1), + bitextract(imp, 2, 1), + bitextract(imp, 1, 1), + bitextract(imp, 0, 1)); + if (imp < Impact) { // This device has less impact than any previous one, so we take it. Impact = imp; d = device[i]; + besti=i; + bestj=j; NeedsDetachReceivers = ndr; if (NumUsableSlots) s = CamSlots.Get(j); @@ -433,6 +454,7 @@ break; // no CAM necessary, so just one loop over the devices } if (d) { + printf("Device %2i.%02i wins\n", besti,bestj); if (NeedsDetachReceivers) d->DetachAllReceivers(); if (s) {