summaryrefslogtreecommitdiff
path: root/server/connection.c
diff options
context:
space:
mode:
authorFrank Schmirler <vdr@schmirler.de>2011-01-28 12:42:33 +0100
committerFrank Schmirler <vdr@schmirler.de>2011-01-28 12:42:33 +0100
commit1b5285b26db690659e6adc5fd72477ccffa9549e (patch)
tree7d3b4a505bd581d0858142962a3bd95a4f7b6a03 /server/connection.c
parentbbaf3aa12cff7791f87a1775ad0dc2d2729903d1 (diff)
downloadvdr-plugin-streamdev-1b5285b26db690659e6adc5fd72477ccffa9549e.tar.gz
vdr-plugin-streamdev-1b5285b26db690659e6adc5fd72477ccffa9549e.tar.bz2
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)
Diffstat (limited to 'server/connection.c')
-rw-r--r--server/connection.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/server/connection.c b/server/connection.c
index de00d90..824ba97 100644
--- a/server/connection.c
+++ b/server/connection.c
@@ -285,25 +285,26 @@ cDevice* cServerConnection::CheckDevice(const cChannel *Channel, int Priority, b
return d;
}
-cDevice *cServerConnection::GetDevice(const cChannel *Channel, int Priority)
+bool cServerConnection::UsedByLiveTV(cDevice *device)
{
- const cChannel *current = Channels.GetByNumber(cDevice::CurrentChannel());
+ return device == cTransferControl::ReceiverDevice() ||
+ (device->IsPrimaryDevice() && device->HasDecoder() && !device->Replaying());
+}
+cDevice *cServerConnection::GetDevice(const cChannel *Channel, int Priority)
+{
// turn off the streams of this connection
Detach();
// This call may detach receivers of the device it returns
cDevice *device = cDevice::GetDevice(Channel, Priority, false);
- if (device && device == cDevice::ActualDevice()
- && (!device->IsPrimaryDevice() || !device->Replaying())
- && !cSuspendCtl::IsActive()
- && current != NULL
- && !TRANSPONDER(Channel, current)) {
+ if (device && !device->IsTunedToTransponder(Channel)
+ && UsedByLiveTV(device)) {
// now we would have to switch away live tv...let's see if live tv
// can be handled by another device
#if VDRVERSNUM >= 10516
cDevice::SetAvoidDevice(device);
- if (!Channels.SwitchTo(current->Number())) {
+ if (!Channels.SwitchTo(cDevice::CurrentChannel())) {
if (StreamdevServerSetup.SuspendMode == smAlways) {
Channels.SwitchTo(Channel->Number());
Skins.QueueMessage(mtInfo, tr("Streaming active"));
@@ -314,7 +315,8 @@ cDevice *cServerConnection::GetDevice(const cChannel *Channel, int Priority)
}
}
#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) {
dsyslog("streamdev: GetDevice: Trying to move live TV to device %d", newdev->CardIndex());
newdev->SwitchChannel(current, true);
@@ -340,29 +342,22 @@ cDevice *cServerConnection::GetDevice(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);
- if (!device || (device == cDevice::ActualDevice()
- && (!device->IsPrimaryDevice() || !device->Replaying())
- && !cSuspendCtl::IsActive()
- && StreamdevServerSetup.SuspendMode != smAlways
- && current != NULL
- && !TRANSPONDER(Channel, current))) {
- // mustn't switch actual device
+ if (!device || (StreamdevServerSetup.SuspendMode != smAlways
+ && !device->IsTunedToTransponder(Channel)
+ && UsedByLiveTV(device))) {
+ // no device available or the device is in use for live TV and suspend mode doesn't allow us to switch it:
// maybe a device would be free if THIS connection did turn off its streams?
Detach();
device = CheckDevice(Channel, Priority, false);
Attach();
- if (device && device == cDevice::ActualDevice()
- && (!device->IsPrimaryDevice() || !device->Replaying())
- && !cSuspendCtl::IsActive()
- && StreamdevServerSetup.SuspendMode != smAlways
- && current != NULL
- && !TRANSPONDER(Channel, current)) {
+ if (device && StreamdevServerSetup.SuspendMode != smAlways
+ && !device->IsTunedToTransponder(Channel)
+ && UsedByLiveTV(device)) {
// now we would have to switch away live tv...let's see if live tv
// 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) {
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());
}