Autodetach unused receiver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



So I have written an Patch that fixed that unused cReceiver will be 
detached automaticly if the source was changed.

Attach a cReceiver to Channel ABC on PID xyz.
If you switch to an other Channel on the same transponder the you can 
still receiver the data on the PID xyz. But if you switch to an other 
Channel on an other transponder, then the receiver needs to detached 
(NeedsDetachReceivers). (depends on the Prio)

For me it seems to be forgotten from Klaus.
So I hope my patch will fix it.
I need it for my Plugin.

Hope this will included in 1.5.x :-)

Greetings
Patrick
-------------- next part --------------
--- ../vdr-1.3.37_orig/device.c	2005-11-26 13:56:09.000000000 +0100
+++ device.c	2006-01-05 17:44:22.000000000 +0100
@@ -577,10 +577,15 @@
   if (LiveView)
      StopReplay();
 
+  // If this card switch to an other Channel and the attached reserver can't receiver there source, 
+  // then they will be detached. It would be irritate if the receiver with was attached for a
+  // specified PID sudden receive data from an other channel which has accidental the same PID     
+  bool NeedsDetachReceivers;
+     
   // If this card can't receive this channel, we must not actually switch
   // the channel here, because that would irritate the driver when we
   // start replaying in Transfer Mode immediately after switching the channel:
-  bool NeedsTransferMode = (LiveView && IsPrimaryDevice() && !ProvidesChannel(Channel, Setup.PrimaryLimit));
+  bool NeedsTransferMode = (LiveView && IsPrimaryDevice() && !ProvidesChannel(Channel, Setup.PrimaryLimit,&NeedsDetachReceivers));
 
   eSetChannelResult Result = scrOk;
 
@@ -588,11 +593,22 @@
   // use the card that actually can receive it and transfer data from there:
 
   if (NeedsTransferMode) {
-     cDevice *CaDevice = GetDevice(Channel, 0);
+     cDevice *CaDevice = GetDevice(Channel, 0, &NeedsDetachReceivers);
      if (CaDevice && CanReplay()) {
         cStatus::MsgChannelSwitch(this, 0); // only report status if we are actually going to switch the channel
-        if (CaDevice->SetChannel(Channel, false) == scrOk) // calling SetChannel() directly, not SwitchChannel()!
+        if (CaDevice->SetChannel(Channel, false) == scrOk){ // calling SetChannel() directly, not SwitchChannel()!
            cControl::Launch(new cTransferControl(CaDevice, Channel->Vpid(), Channel->Apids(), Channel->Dpids(), Channel->Spids()));
+           
+           //detach all receivers from device
+           if (NeedsDetachReceivers){
+             dsyslog("Need to detach all receivers from device. Source has been changed.");
+             for (int i = 0; i < MAXRECEIVERS; i++) {        
+               if (CaDevice->receiver[i]){
+                 CaDevice->receiver[i]->Detach();
+                 }
+               }
+             }
+           }
         else
            Result = scrNoTransfer;
         }
@@ -635,6 +651,16 @@
         // Start decrypting any PIDs the might have been set in SetChannelDevice():
         if (ciHandler)
            ciHandler->StartDecrypting();
+           
+        //detach all receivers from device   
+        if (NeedsDetachReceivers){
+          dsyslog("Need to detach all receivers from device. Source will be changed.");
+          for (int i = 0; i < MAXRECEIVERS; i++) {        
+            if (receiver[i]){
+                receiver[i]->Detach();
+             }
+            }
+          }           
         }
      else
         Result = scrFailed;

[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux