summaryrefslogtreecommitdiff
path: root/device.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2006-01-06 13:55:57 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2006-01-06 13:55:57 +0100
commit16f037e3c23efadcc846fd7dc780b42036fabf01 (patch)
tree832b252f3b85885884b013f08a9de53cf5bae273 /device.c
parente87e649991adfceba8462fb642c57619131efb06 (diff)
downloadvdr-16f037e3c23efadcc846fd7dc780b42036fabf01.tar.gz
vdr-16f037e3c23efadcc846fd7dc780b42036fabf01.tar.bz2
Any cReceivers still attached to a cDevice when that device switches to a different transponder are now automatically detached
Diffstat (limited to 'device.c')
-rw-r--r--device.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/device.c b/device.c
index 5fad4d96..53320335 100644
--- a/device.c
+++ b/device.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: device.c 1.116 2006/01/06 12:56:44 kls Exp $
+ * $Id: device.c 1.117 2006/01/06 13:50:00 kls Exp $
*/
#include "device.h"
@@ -604,10 +604,14 @@ eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView)
if (LiveView)
StopReplay();
+ // If this card is switched to an other transponder, any receivers still
+ // attached to it ineed to be automatically detached:
+ bool NeedsDetachReceivers = false;
+
// 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;
@@ -615,11 +619,14 @@ eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView)
// 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()!
+ if (NeedsDetachReceivers)
+ CaDevice->DetachAllReceivers();
cControl::Launch(new cTransferControl(CaDevice, Channel->Vpid(), Channel->Apids(), Channel->Dpids(), Channel->Spids()));
+ }
else
Result = scrNoTransfer;
}
@@ -653,6 +660,8 @@ eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView)
}
#endif
}
+ if (NeedsDetachReceivers)
+ DetachAllReceivers();
if (SetChannelDevice(Channel, LiveView)) {
// Start section handling:
if (sectionHandler) {
@@ -1269,6 +1278,15 @@ void cDevice::DetachAll(int Pid)
}
}
+void cDevice::DetachAllReceivers(void)
+{
+ cMutexLock MutexLock(&mutexReceiver);
+ for (int i = 0; i < MAXRECEIVERS; i++) {
+ if (receiver[i])
+ Detach(receiver[i]);
+ }
+}
+
// --- cTSBuffer -------------------------------------------------------------
cTSBuffer::cTSBuffer(int File, int Size, int CardIndex)