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%>
<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);
</pre></td></tr></table><p>

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* 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"
@ -117,12 +117,12 @@ cDevice *cDevice::GetDevice(int Index)
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;
for (int i = 0; i < numDevices; i++) {
bool nsc;
if (device[i]->ProvidesChannel(Channel, Priority, &nsc) // this device is basicly able to do the job
bool ndr;
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...
|| device[i]->Priority() < d->Priority() // ...this one has an even lower Priority, or...
|| device[i]->Priority() == d->Priority() // ...same Priority...
@ -130,8 +130,8 @@ cDevice *cDevice::GetDevice(const cChannel *Channel, int Priority, bool *NeedsSw
)
) {
d = device[i];
if (NeedsSwitchChannel)
*NeedsSwitchChannel = nsc;
if (NeedsDetachReceivers)
*NeedsDetachReceivers = ndr;
}
}
/*XXX+ too complex with multiple recordings per device
@ -257,7 +257,7 @@ bool cDevice::SetPid(cPidHandle *Handle, int Type, bool On)
return false;
}
bool cDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsSwitchChannel)
bool cDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers)
{
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:
if (NeedsTransferMode) {
bool NeedsSwitchChannel = false;
cDevice *CaDevice = GetDevice(Channel, 0, &NeedsSwitchChannel);
cDevice *CaDevice = GetDevice(Channel, 0);
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+
else
Result = scrNoTransfer;

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* 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
@ -72,10 +72,10 @@ public:
static cDevice *GetDevice(int Index);
// Returns the device with the Index (if Index is in the range
// 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
// 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);
// Sets the CaCaps of the given device according to the Setup data.
// By default the CaCaps of all devices are set.
@ -134,7 +134,7 @@ public:
protected:
int currentChannel;
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.
// 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
@ -142,12 +142,10 @@ public:
// The special Priority value -1 will tell the caller whether this device
// is principally able to provide the given Channel, regardless of any
// attached cReceivers.
// If NeedsSwitchChannel is given, the resulting value in it will tell the
// caller whether or not it shall call SwitchChannel to actually switch the
// device to the desired channel. If NeedsSwitchChannel returns false, the
// caller must not call SwitchChannel, since there are receivers attached
// to the device and it is already switched to the given channel. Note
// that the return value in NeedsSwitchChannel is only meaningful if the
// If NeedsDetachReceivers is given, the resulting value in it will tell the
// caller whether or not it will have to detach any currently attached
// receivers from this device before calling SwitchChannel. Note
// that the return value in NeedsDetachReceivers is only meaningful if the
// function itself actually returns true.
// The default implementation always returns false, so a derived cDevice
// 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
* 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"
@ -338,19 +338,19 @@ bool cDvbDevice::SetPid(cPidHandle *Handle, int Type, bool On)
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 hasPriority = Priority < 0 || Priority > this->Priority();
bool needsSwitchChannel = true;
bool needsDetachReceivers = true;
if (ProvidesCa(Channel->ca)) {
if (Receiving()) {
if (frequency == Channel->frequency) {
needsSwitchChannel = false;
needsDetachReceivers = false;
if (!HasPid(Channel->vpid)) {
if (Channel->ca > CACONFBASE) {
needsSwitchChannel = true;
needsDetachReceivers = true;
result = hasPriority;
}
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
#ifdef DVB_DRIVER_VERSION
#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;
#endif
#else
@ -378,8 +376,8 @@ bool cDvbDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *Ne
else
result = hasPriority;
}
if (NeedsSwitchChannel)
*NeedsSwitchChannel = needsSwitchChannel;
if (NeedsDetachReceivers)
*NeedsDetachReceivers = needsDetachReceivers;
return result;
}

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* 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
@ -59,7 +59,7 @@ public:
private:
int frequency;
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:
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
* 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"
@ -2519,15 +2519,14 @@ bool cRecordControls::Start(cTimer *Timer)
cChannel *channel = Channels.GetByNumber(ch);
if (channel) {
bool NeedsSwitchChannel = false;
cDevice *device = cDevice::GetDevice(channel, Timer ? Timer->priority : Setup.DefaultPriority, &NeedsSwitchChannel);
bool NeedsDetachReceivers = false;
cDevice *device = cDevice::GetDevice(channel, Timer ? Timer->priority : Setup.DefaultPriority, &NeedsDetachReceivers);
if (device) {
if (NeedsSwitchChannel) {
if (NeedsDetachReceivers)
Stop(device);
if (!device->SwitchChannel(channel, false)) {
cThread::EmergencyExit(true);
return false;
}
if (!device->SwitchChannel(channel, false)) {
cThread::EmergencyExit(true);
return false;
}
for (int i = 0; i < MAXRECORDCONTROLS; i++) {
if (!RecordControls[i]) {