Index: trunk/libs/libmythtv/dvbdev/dvbci.cpp
===================================================================
--- trunk/libs/libmythtv/dvbdev/dvbci.cpp	(revision 46)
+++ trunk/libs/libmythtv/dvbdev/dvbci.cpp	(working copy)
@@ -980,7 +980,8 @@
 {
   dbgprotocol("New Conditional Access Support (session id %d)\n", SessionId);
   state = 0;
-  caSystemIds[numCaSystemIds = 0] = 0;
+  numCaSystemIds = 0;
+  memset(caSystemIds, 0, sizeof(caSystemIds));
   needCaPmt = false;
 }
 
@@ -992,20 +993,29 @@
        case AOT_CA_INFO: {
             dbgprotocol("%d: <== Ca Info", SessionId());
             int l = 0;
+            int i;
             const uint8_t *d = GetData(Data, l);
             while (l > 1) {
                   unsigned short id = ((unsigned short)(*d) << 8) | *(d + 1);
                   dbgprotocol(" %04X", id);
                   d += 2;
                   l -= 2;
-                  fprintf(stderr, "XXX YYY ZZZ - Got ca system id %hu\n", id);
-                  if (numCaSystemIds < MAXCASYSTEMIDS) {
-                     caSystemIds[numCaSystemIds++] = id;
-                     caSystemIds[numCaSystemIds] = 0;
-                     }
-                  else
-                     esyslog("ERROR: too many CA system IDs!");
-                    }
+
+                  if (numCaSystemIds >= MAXCASYSTEMIDS) {
+                    esyslog("ERROR: too many CA system IDs!");
+                    break;
+                  }
+
+                  // Make sure the id is not already present
+                  for (i = 0; i < numCaSystemIds; i++)
+                    if (caSystemIds[i] == id)
+                      break;
+                  
+                  if (i < numCaSystemIds)
+                    continue;
+
+                  caSystemIds[numCaSystemIds++] = id;
+            }
             dbgprotocol("\n");
             }
             state = 2;
