Fixed the code deciding if a device is in use for live TV or not. It did

not work as expected for FF cards (fixes #536)
This commit is contained in:
Frank Schmirler 2011-01-28 12:42:33 +01:00
parent 0783799826
commit 06d5418e42
4 changed files with 27 additions and 25 deletions

View File

@ -180,3 +180,4 @@ Michal Novotny
wtor wtor
for reporting that a client may interrupt replaying on FF cards for reporting that a client may interrupt replaying on FF cards
for helping to debug channel switch issues on FF cards

View File

@ -1,6 +1,8 @@
VDR Plugin 'streamdev' Revision History VDR Plugin 'streamdev' Revision History
--------------------------------------- ---------------------------------------
- fixed the code deciding if a device is in use for live TV or not. It did
not work as expected for FF cards (reported by wtor)
- increased client side timeout for TUNE command - increased client side timeout for TUNE command
- more dsyslog messages to help troubleshouting channel switch issues - more dsyslog messages to help troubleshouting channel switch issues
- improved the channel switch code trying to move live TV to different card - improved the channel switch code trying to move live TV to different card

View File

@ -285,25 +285,26 @@ cDevice* cServerConnection::CheckDevice(const cChannel *Channel, int Priority, b
return d; return d;
} }
bool cServerConnection::UsedByLiveTV(cDevice *device)
{
return device == cTransferControl::ReceiverDevice() ||
(device->IsPrimaryDevice() && device->HasDecoder() && !device->Replaying());
}
cDevice *cServerConnection::GetDevice(const cChannel *Channel, int Priority) cDevice *cServerConnection::GetDevice(const cChannel *Channel, int Priority)
{ {
const cChannel *current = Channels.GetByNumber(cDevice::CurrentChannel());
// turn off the streams of this connection // turn off the streams of this connection
Detach(); Detach();
// This call may detach receivers of the device it returns // This call may detach receivers of the device it returns
cDevice *device = cDevice::GetDevice(Channel, Priority, false); cDevice *device = cDevice::GetDevice(Channel, Priority, false);
if (device && device == cDevice::ActualDevice() if (device && !device->IsTunedToTransponder(Channel)
&& (!device->IsPrimaryDevice() || !device->Replaying()) && UsedByLiveTV(device)) {
&& !cSuspendCtl::IsActive()
&& current != NULL
&& !TRANSPONDER(Channel, current)) {
// now we would have to switch away live tv...let's see if live tv // now we would have to switch away live tv...let's see if live tv
// can be handled by another device // can be handled by another device
#if VDRVERSNUM >= 10516 #if VDRVERSNUM >= 10516
cDevice::SetAvoidDevice(device); cDevice::SetAvoidDevice(device);
if (!Channels.SwitchTo(current->Number())) { if (!Channels.SwitchTo(cDevice::CurrentChannel())) {
if (StreamdevServerSetup.SuspendMode == smAlways) { if (StreamdevServerSetup.SuspendMode == smAlways) {
Channels.SwitchTo(Channel->Number()); Channels.SwitchTo(Channel->Number());
Skins.QueueMessage(mtInfo, tr("Streaming active")); Skins.QueueMessage(mtInfo, tr("Streaming active"));
@ -314,7 +315,8 @@ cDevice *cServerConnection::GetDevice(const cChannel *Channel, int Priority)
} }
} }
#else #else
cDevice *newdev = CheckDevice(current, 0, true, device); const cChannel *current = Channels.GetByNumber(cDevice::CurrentChannel());
cDevice *newdev = current ? CheckDevice(current, 0, true, device) : NULL;
if (newdev) { if (newdev) {
dsyslog("streamdev: GetDevice: Trying to move live TV to device %d", newdev->CardIndex()); dsyslog("streamdev: GetDevice: Trying to move live TV to device %d", newdev->CardIndex());
newdev->SwitchChannel(current, true); newdev->SwitchChannel(current, true);
@ -340,29 +342,22 @@ cDevice *cServerConnection::GetDevice(const cChannel *Channel, int Priority)
bool cServerConnection::ProvidesChannel(const cChannel *Channel, int Priority) bool cServerConnection::ProvidesChannel(const cChannel *Channel, int Priority)
{ {
const cChannel *current = Channels.GetByNumber(cDevice::CurrentChannel());
cDevice *device = CheckDevice(Channel, Priority, false); cDevice *device = CheckDevice(Channel, Priority, false);
if (!device || (device == cDevice::ActualDevice() if (!device || (StreamdevServerSetup.SuspendMode != smAlways
&& (!device->IsPrimaryDevice() || !device->Replaying()) && !device->IsTunedToTransponder(Channel)
&& !cSuspendCtl::IsActive() && UsedByLiveTV(device))) {
&& StreamdevServerSetup.SuspendMode != smAlways // no device available or the device is in use for live TV and suspend mode doesn't allow us to switch it:
&& current != NULL
&& !TRANSPONDER(Channel, current))) {
// mustn't switch actual device
// maybe a device would be free if THIS connection did turn off its streams? // maybe a device would be free if THIS connection did turn off its streams?
Detach(); Detach();
device = CheckDevice(Channel, Priority, false); device = CheckDevice(Channel, Priority, false);
Attach(); Attach();
if (device && device == cDevice::ActualDevice() if (device && StreamdevServerSetup.SuspendMode != smAlways
&& (!device->IsPrimaryDevice() || !device->Replaying()) && !device->IsTunedToTransponder(Channel)
&& !cSuspendCtl::IsActive() && UsedByLiveTV(device)) {
&& StreamdevServerSetup.SuspendMode != smAlways
&& current != NULL
&& !TRANSPONDER(Channel, current)) {
// now we would have to switch away live tv...let's see if live tv // now we would have to switch away live tv...let's see if live tv
// can be handled by another device // can be handled by another device
cDevice *newdev = CheckDevice(current, 0, true, device); const cChannel *current = Channels.GetByNumber(cDevice::CurrentChannel());
cDevice *newdev = current ? CheckDevice(current, 0, true, device) : NULL;
if (newdev) { if (newdev) {
dsyslog("streamdev: Providing channel %d (%s) at priority %d requires moving live TV to device %d (PrimaryDevice=%d, ActualDevice=%d)", Channel->Number(), Channel->Name(), Priority, newdev->CardIndex(), cDevice::PrimaryDevice()->CardIndex(), cDevice::ActualDevice()->CardIndex()); dsyslog("streamdev: Providing channel %d (%s) at priority %d requires moving live TV to device %d (PrimaryDevice=%d, ActualDevice=%d)", Channel->Number(), Channel->Name(), Priority, newdev->CardIndex(), cDevice::PrimaryDevice()->CardIndex(), cDevice::ActualDevice()->CardIndex());
} }

View File

@ -40,6 +40,10 @@ private:
detaching this connection's receivers. */ detaching this connection's receivers. */
cDevice *CheckDevice(const cChannel *Channel, int Priority, bool LiveView, const cDevice *AvoidDevice = NULL); cDevice *CheckDevice(const cChannel *Channel, int Priority, bool LiveView, const cDevice *AvoidDevice = NULL);
/* Test if device is in use as the transfer mode receiver device
or a FF card, displaying live TV from internal tuner */
static bool UsedByLiveTV(cDevice *device);
protected: protected:
/* Will be called when a command terminated by a newline has been /* Will be called when a command terminated by a newline has been
received */ received */