Changed NeedsSwitchChannel to NeedsDetachReceivers

This commit is contained in:
Klaus Schmidinger 2002-09-06 14:10:17 +02:00
parent 3e58bc64fe
commit f24f820e7d
6 changed files with 34 additions and 40 deletions

View File

@ -1189,7 +1189,7 @@ selecting which channel it shall tune to:
<!--X1.1.9--><table width=100%><tr><td bgcolor=#FF0000>&nbsp;</td><td width=100%> <!--X1.1.9--><table width=100%><tr><td bgcolor=#FF0000>&nbsp;</td><td width=100%>
<p><table><tr><td bgcolor=#F0F0F0><pre><br> <p><table><tr><td bgcolor=#F0F0F0><pre><br>
virtual bool ProvidesChannel(const cChannel *Channel, int Priority = -1, bool *NeedsSwitchChannel = NULL); virtual bool ProvidesChannel(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL);
virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView); virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
</pre></td></tr></table><p> </pre></td></tr></table><p>

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: device.c 1.14 2002/09/04 17:26:02 kls Exp $ * $Id: device.c 1.15 2002/09/06 14:02:19 kls Exp $
*/ */
#include "device.h" #include "device.h"
@ -117,12 +117,12 @@ cDevice *cDevice::GetDevice(int Index)
return (0 <= Index && Index < numDevices) ? device[Index] : NULL; return (0 <= Index && Index < numDevices) ? device[Index] : NULL;
} }
cDevice *cDevice::GetDevice(const cChannel *Channel, int Priority, bool *NeedsSwitchChannel) cDevice *cDevice::GetDevice(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers)
{ {
cDevice *d = NULL; cDevice *d = NULL;
for (int i = 0; i < numDevices; i++) { for (int i = 0; i < numDevices; i++) {
bool nsc; bool ndr;
if (device[i]->ProvidesChannel(Channel, Priority, &nsc) // this device is basicly able to do the job if (device[i]->ProvidesChannel(Channel, Priority, &ndr) // this device is basicly able to do the job
&& (!d // we don't have a device yet, or... && (!d // we don't have a device yet, or...
|| device[i]->Priority() < d->Priority() // ...this one has an even lower Priority, or... || device[i]->Priority() < d->Priority() // ...this one has an even lower Priority, or...
|| device[i]->Priority() == d->Priority() // ...same Priority... || device[i]->Priority() == d->Priority() // ...same Priority...
@ -130,8 +130,8 @@ cDevice *cDevice::GetDevice(const cChannel *Channel, int Priority, bool *NeedsSw
) )
) { ) {
d = device[i]; d = device[i];
if (NeedsSwitchChannel) if (NeedsDetachReceivers)
*NeedsSwitchChannel = nsc; *NeedsDetachReceivers = ndr;
} }
} }
/*XXX+ too complex with multiple recordings per device /*XXX+ too complex with multiple recordings per device
@ -257,7 +257,7 @@ bool cDevice::SetPid(cPidHandle *Handle, int Type, bool On)
return false; return false;
} }
bool cDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsSwitchChannel) bool cDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers)
{ {
return false; return false;
} }
@ -302,10 +302,9 @@ eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView)
// use the card that actually can receive it and transfer data from there: // use the card that actually can receive it and transfer data from there:
if (NeedsTransferMode) { if (NeedsTransferMode) {
bool NeedsSwitchChannel = false; cDevice *CaDevice = GetDevice(Channel, 0);
cDevice *CaDevice = GetDevice(Channel, 0, &NeedsSwitchChannel);
if (CaDevice) { if (CaDevice) {
if (!NeedsSwitchChannel || 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->apid1, 0, 0, 0));//XXX+ cControl::Launch(new cTransferControl(CaDevice, Channel->vpid, Channel->apid1, 0, 0, 0));//XXX+
else else
Result = scrNoTransfer; Result = scrNoTransfer;

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: device.h 1.11 2002/09/04 11:33:12 kls Exp $ * $Id: device.h 1.12 2002/09/06 14:04:52 kls Exp $
*/ */
#ifndef __DEVICE_H #ifndef __DEVICE_H
@ -72,10 +72,10 @@ public:
static cDevice *GetDevice(int Index); static cDevice *GetDevice(int Index);
// Returns the device with the Index (if Index is in the range // Returns the device with the Index (if Index is in the range
// 0..numDevices-1, NULL otherwise). // 0..numDevices-1, NULL otherwise).
static cDevice *GetDevice(const cChannel *Channel, int Priority = -1, bool *NeedsSwitchChannel = NULL); static cDevice *GetDevice(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL);
// Returns a device that is able to receive the given Channel at the // Returns a device that is able to receive the given Channel at the
// given Priority (see ProvidesChannel() for more information on how // given Priority (see ProvidesChannel() for more information on how
// priorities are handled, and the meaning of NeedsSwitchChannel). // priorities are handled, and the meaning of NeedsDetachReceivers).
static void SetCaCaps(int Index = -1); static void SetCaCaps(int Index = -1);
// Sets the CaCaps of the given device according to the Setup data. // Sets the CaCaps of the given device according to the Setup data.
// By default the CaCaps of all devices are set. // By default the CaCaps of all devices are set.
@ -134,7 +134,7 @@ public:
protected: protected:
int currentChannel; int currentChannel;
public: public:
virtual bool ProvidesChannel(const cChannel *Channel, int Priority = -1, bool *NeedsSwitchChannel = NULL); virtual bool ProvidesChannel(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL);
// Returns true if this device can provide the given channel. // Returns true if this device can provide the given channel.
// In case the device has cReceivers attached to it or it is the primary // In case the device has cReceivers attached to it or it is the primary
// device, Priority is used to decide whether the caller's request can // device, Priority is used to decide whether the caller's request can
@ -142,12 +142,10 @@ public:
// The special Priority value -1 will tell the caller whether this device // The special Priority value -1 will tell the caller whether this device
// is principally able to provide the given Channel, regardless of any // is principally able to provide the given Channel, regardless of any
// attached cReceivers. // attached cReceivers.
// If NeedsSwitchChannel is given, the resulting value in it will tell the // If NeedsDetachReceivers is given, the resulting value in it will tell the
// caller whether or not it shall call SwitchChannel to actually switch the // caller whether or not it will have to detach any currently attached
// device to the desired channel. If NeedsSwitchChannel returns false, the // receivers from this device before calling SwitchChannel. Note
// caller must not call SwitchChannel, since there are receivers attached // that the return value in NeedsDetachReceivers is only meaningful if the
// to the device and it is already switched to the given channel. Note
// that the return value in NeedsSwitchChannel is only meaningful if the
// function itself actually returns true. // function itself actually returns true.
// The default implementation always returns false, so a derived cDevice // The default implementation always returns false, so a derived cDevice
// class that can provide channels must implement this function. // class that can provide channels must implement this function.

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: dvbdevice.c 1.9 2002/09/04 13:46:03 kls Exp $ * $Id: dvbdevice.c 1.10 2002/09/06 14:09:55 kls Exp $
*/ */
#include "dvbdevice.h" #include "dvbdevice.h"
@ -338,19 +338,19 @@ bool cDvbDevice::SetPid(cPidHandle *Handle, int Type, bool On)
return true; return true;
} }
bool cDvbDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsSwitchChannel) bool cDvbDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers)
{ {
bool result = false; bool result = false;
bool hasPriority = Priority < 0 || Priority > this->Priority(); bool hasPriority = Priority < 0 || Priority > this->Priority();
bool needsSwitchChannel = true; bool needsDetachReceivers = true;
if (ProvidesCa(Channel->ca)) { if (ProvidesCa(Channel->ca)) {
if (Receiving()) { if (Receiving()) {
if (frequency == Channel->frequency) { if (frequency == Channel->frequency) {
needsSwitchChannel = false; needsDetachReceivers = false;
if (!HasPid(Channel->vpid)) { if (!HasPid(Channel->vpid)) {
if (Channel->ca > CACONFBASE) { if (Channel->ca > CACONFBASE) {
needsSwitchChannel = true; needsDetachReceivers = true;
result = hasPriority; result = hasPriority;
} }
else if (!HasDecoder()) else if (!HasDecoder())
@ -360,8 +360,6 @@ bool cDvbDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *Ne
#define MIN_DVB_DRIVER_VERSION_FOR_TIMESHIFT 2002090101 #define MIN_DVB_DRIVER_VERSION_FOR_TIMESHIFT 2002090101
#ifdef DVB_DRIVER_VERSION #ifdef DVB_DRIVER_VERSION
#if (DVB_DRIVER_VERSION >= MIN_DVB_DRIVER_VERSION_FOR_TIMESHIFT) #if (DVB_DRIVER_VERSION >= MIN_DVB_DRIVER_VERSION_FOR_TIMESHIFT)
if (pidHandles[ptVideo].used)
needsSwitchChannel = true; // to have it turn off the live PIDs
result = !IsPrimaryDevice() || Priority >= Setup.PrimaryLimit; result = !IsPrimaryDevice() || Priority >= Setup.PrimaryLimit;
#endif #endif
#else #else
@ -378,8 +376,8 @@ bool cDvbDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *Ne
else else
result = hasPriority; result = hasPriority;
} }
if (NeedsSwitchChannel) if (NeedsDetachReceivers)
*NeedsSwitchChannel = needsSwitchChannel; *NeedsDetachReceivers = needsDetachReceivers;
return result; return result;
} }

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: dvbdevice.h 1.7 2002/09/04 13:31:42 kls Exp $ * $Id: dvbdevice.h 1.8 2002/09/06 14:10:17 kls Exp $
*/ */
#ifndef __DVBDEVICE_H #ifndef __DVBDEVICE_H
@ -59,7 +59,7 @@ public:
private: private:
int frequency; int frequency;
public: public:
virtual bool ProvidesChannel(const cChannel *Channel, int Priority = -1, bool *NeedsSwitchChannel = NULL); virtual bool ProvidesChannel(const cChannel *Channel, int Priority = -1, bool *NeedsDetachReceivers = NULL);
protected: protected:
virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView); virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);

15
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: menu.c 1.207 2002/09/04 13:27:13 kls Exp $ * $Id: menu.c 1.208 2002/09/06 14:07:58 kls Exp $
*/ */
#include "menu.h" #include "menu.h"
@ -2519,15 +2519,14 @@ bool cRecordControls::Start(cTimer *Timer)
cChannel *channel = Channels.GetByNumber(ch); cChannel *channel = Channels.GetByNumber(ch);
if (channel) { if (channel) {
bool NeedsSwitchChannel = false; bool NeedsDetachReceivers = false;
cDevice *device = cDevice::GetDevice(channel, Timer ? Timer->priority : Setup.DefaultPriority, &NeedsSwitchChannel); cDevice *device = cDevice::GetDevice(channel, Timer ? Timer->priority : Setup.DefaultPriority, &NeedsDetachReceivers);
if (device) { if (device) {
if (NeedsSwitchChannel) { if (NeedsDetachReceivers)
Stop(device); Stop(device);
if (!device->SwitchChannel(channel, false)) { if (!device->SwitchChannel(channel, false)) {
cThread::EmergencyExit(true); cThread::EmergencyExit(true);
return false; return false;
}
} }
for (int i = 0; i < MAXRECORDCONTROLS; i++) { for (int i = 0; i < MAXRECORDCONTROLS; i++) {
if (!RecordControls[i]) { if (!RecordControls[i]) {