nickfudge Wrote:There's a couple of problems. The SET_CA_DESCR error was a code bug, which was fixed a couple of days ago, so you need to fetch the latest sources. Having done that, you should find that encrypted channels will be decrypted, but then sasc-ng will likely lock-up.
I've written the following patch which will get you a stable picture when using sasc-ng's newcamd cardclient protocol -- I haven't bothered porting the patches to the other cardclient protocols because I'm still trying to improve the overall stability of sasc-ng. I'd push these patches upstream, but I've not got an e-mail address for the author.
- Code: Select All Code
diff -r 7e4626c93174 cam.c
--- a/cam.c Thu Sep 08 07:14:07 2011 +0800
+++ b/cam.c Tue Sep 13 12:35:44 2011 +0100
@@ -65,6 +65,7 @@
#define L_HEX_HOOK LCLASS(L_HEX,32)
#define L_HEX_ALL LALL(L_HEX_HOOK)
+
static const struct LogModule lm_hex = {
(LMOD_ENABLE|L_HEX_ALL)&LOPT_MASK,
(LMOD_ENABLE)&LOPT_MASK,
@@ -2277,13 +2278,21 @@
void cCam::Tune(const cChannel *channel)
{
- cMutexLock lock(&camMutex);
- if(source!=channel->Source() || transponder!=channel->Transponder()) {
- source=channel->Source(); transponder=channel->Transponder();
- PRINTF(L_CORE_PIDS,"%s: now tuned to source %x(%s) transponder %x",devId,source,*cSource::ToString(source),transponder);
+ bool stop = false;
+ {
+ cMutexLock lock(&camMutex);
+ if(source!=channel->Source() || transponder!=channel->Transponder()) {
+ source=channel->Source(); transponder=channel->Transponder();
+ PRINTF(L_CORE_PIDS,"%s: now tuned to source %x(%s) transponder %x",devId,source,*cSource::ToString(source),transponder);
+ stop = true;
+ } else {
+ PRINTF(L_CORE_PIDS,"%s: tune to same source/transponder",devId);
+ }
+ }
+
+ if (stop) {
Stop();
- }
- else PRINTF(L_CORE_PIDS,"%s: tune to same source/transponder",devId);
+ }
}
void cCam::PostTune(void)
@@ -2500,7 +2509,7 @@
void cCam::LogEcmStatus(const cEcmInfo *ecm, bool on)
{
- cMutexLock lock(&camMutex);
+ //cMutexLock lock(&camMutex);
if(on) LogStartup();
if(logger) logger->EcmStatus(ecm,on);
}
@@ -2561,9 +2570,9 @@
bool cCam::SetCaDescr(ca_descr_t *ca_descr, bool initial)
{
-#ifndef SASC
if(!softcsa || (fullts && ca_descr->index==0))
return devplugin->SetCaDescr(device,ca_descr,initial);
+#ifndef SASC
else if(decsa)
return decsa->SetDescr(ca_descr,initial);
#endif //!SASC
@@ -2572,9 +2581,9 @@
bool cCam::SetCaPid(ca_pid_t *ca_pid)
{
-#ifndef SASC
if(!softcsa || (fullts && ca_pid->index==0))
return devplugin->SetCaPid(device,ca_pid);
+#ifndef SASC
else if(decsa)
return decsa->SetCaPid(ca_pid);
#endif //!SASC
@@ -2583,9 +2592,7 @@
void cCam::DumpAV7110(void)
{
-#ifndef SASC
devplugin->DumpAV(device);
-#endif //!SASC
}
int cCam::GetFreeIndex(void)
diff -r 7e4626c93174 contrib/sasc-ng/dvblb_plugins/plugin_cam.c
--- a/contrib/sasc-ng/dvblb_plugins/plugin_cam.c Thu Sep 08 07:14:07 2011 +0800
+++ b/contrib/sasc-ng/dvblb_plugins/plugin_cam.c Tue Sep 13 12:35:44 2011 +0100
@@ -260,6 +260,7 @@
if (sidmsg->calen == 0) {
free_sidmsg(sidmsg);
+ msg->type = MSG_PROCESSED;
return;
}
for(ch=Channels.First(); ch; ch=Channels.Next(ch)) {
@@ -280,6 +281,7 @@
}
}
free_sidmsg(sidmsg);
+ msg->type = MSG_PROCESSED;
return;
}
} else {
diff -r 7e4626c93174 contrib/sasc-ng/dvblb_plugins/plugin_ffdecsa.c
--- a/contrib/sasc-ng/dvblb_plugins/plugin_ffdecsa.c Thu Sep 08 07:14:07 2011 +0800
+++ b/contrib/sasc-ng/dvblb_plugins/plugin_ffdecsa.c Tue Sep 13 12:35:44 2011 +0100
@@ -123,11 +123,13 @@
pthread_mutex_unlock(&csa->state_lock);
return;
}
+ pthread_mutex_lock(&csa->keylock);
if(! csa->keyindex[index].valid) {
csa->keyindex[index].valid = 1;
csa->keyindex[index].status = 0;
csa->keyindex[index].queued = 0;
}
+ pthread_mutex_unlock(&csa->keylock);
pop_entry_from_queue_l(pid_ll, &pidmap_empty_queue, struct pid, &list_lock);
pid_ll->pid = pid;
pid_ll->index = index;
@@ -146,7 +148,9 @@
ll_find_elem(pid_ll, csa->pid_map, index, index, struct pid);
if(pid_ll == NULL) {
//no valid pids on this index
+ pthread_mutex_lock(&csa->keylock);
csa->keyindex[index].status = 0;
+ pthread_mutex_unlock(&csa->keylock);
if(list_empty(&csa->pid_map)) {
//state = ENCRYPTED_NOT_READY;
csa->state = NOT_ENCRYPTED;
diff -r 7e4626c93174 systems/cardclient/cc.c
--- a/systems/cardclient/cc.c Thu Sep 08 07:14:07 2011 +0800
+++ b/systems/cardclient/cc.c Tue Sep 13 12:35:44 2011 +0100
@@ -110,7 +110,7 @@
bool cCardClient::SendMsg(const unsigned char *data, int len)
{
- if(!so.Connected() && !Login()) return false;
+ if(!so.Connected() /*&& !Login()*/) return false;
if(so.Write(data,len)<0) {
PRINTF(L_CC_CORE,"send error. reconnecting...");
Logout();
@@ -121,7 +121,7 @@
int cCardClient::RecvMsg(unsigned char *data, int len, int to)
{
- if(!so.Connected() && !Login()) return -1;
+ if(!so.Connected() /*&& !Login()*/) return -1;
int n=so.Read(data,len,to);
if(n<0) {
if(errno==ETIMEDOUT && (len<0 || to==0)) return 0;
diff -r 7e4626c93174 systems/cardclient/newcamd.c
--- a/systems/cardclient/newcamd.c Thu Sep 08 07:14:07 2011 +0800
+++ b/systems/cardclient/newcamd.c Tue Sep 13 12:35:44 2011 +0100
@@ -472,9 +472,19 @@
bool cCardClientNewCamd::ProcessECM(const cEcmInfo *ecm, const unsigned char *data, unsigned char *cw)
{
- cMutexLock lock(this);
- if((!so.Connected() && !Login()) || !CanHandle(ecm->caId)) return false;
- so.Flush();
+ if (!CanHandle(ecm->caId))
+ return false;
+ //{
+ // cMutexLock lock(this);
+ // if((!so.Connected() && !Login()) || !CanHandle(ecm->caId)) return false;
+ // so.Flush();
+ //}
+ {
+ cMutexLock lock(this);
+ if (!so.Connected() && !Login())
+ return false;
+ so.Flush();
+ }
struct CustomData cd;
InitCustomData(&cd,(unsigned short)ecm->prgId,0);
@@ -502,7 +512,6 @@
bool cCardClientNewCamd::ProcessEMM(int caSys, const unsigned char *data)
{
if(emmProcessing && emmAllowed) {
- cMutexLock lock(this);
cAssembleData ad(data);
if(MatchAndAssemble(&ad,0,0)) {
while((data=ad.Assembled())) {
Hope it helps.
Regards,
Nick
Thank you soooooo much
. I tried your patch, but I had problem applying a patch to last vdr-sasc-ng source codes. Finally I made some modifications manually, but I'm not sure if everything correctly. Can you please make diff from last source codes from
http://85.17.209.13:6100/sc?
I tried the version with your patch and clean from the repository, both work, but time is a problem with communication after newcamd:
[cardclient.newcamd] 0004 msgid bad! = 0003
Sep 15 12:38:18.438 [cardclient.newcamd] sync error msg ID. Retrying ...
I'll help you to debug everything.