[vdr-streamdev] Apply upstream VDR 1.7.26+ patches.

Ville Skyttä scop at fedoraproject.org
Sun Mar 11 17:07:54 UTC 2012


commit 1b876a0872c211c3c76bea0f18ccb037ec1f0e11
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Sun Mar 11 19:07:45 2012 +0200

    Apply upstream VDR 1.7.26+ patches.

 vdr-streamdev-0.5.1-vdr1726.patch |  359 +++++++++++++++++++++++++++++++++++++
 vdr-streamdev.spec                |    7 +-
 2 files changed, 365 insertions(+), 1 deletions(-)
---
diff --git a/vdr-streamdev-0.5.1-vdr1726.patch b/vdr-streamdev-0.5.1-vdr1726.patch
new file mode 100644
index 0000000..9727ede
--- /dev/null
+++ b/vdr-streamdev-0.5.1-vdr1726.patch
@@ -0,0 +1,359 @@
+commit c06970123cd68bd1b2f2695326596430d236f230
+Author: Frank Schmirler <vdr at schmirler.de>
+Date:   Mon Mar 7 21:37:08 2011 +0100
+
+    Live TV must be switched in VDR main thread (fixes #568).
+
+diff --git a/server/connection.c b/server/connection.c
+index 78a023a..3bf0ad5 100644
+--- a/server/connection.c
++++ b/server/connection.c
+@@ -8,11 +8,60 @@
+ #include "common.h"
+ 
+ #include <vdr/tools.h>
++#include <vdr/thread.h>
+ #include <vdr/transfer.h>
+ #include <string.h>
+ #include <stdarg.h>
+ #include <errno.h>
+ 
++class cSwitchLive {
++private:
++	cMutex         mutex;
++	cCondWait      switched;
++	cDevice        *device;
++	const cChannel *channel;
++public:
++	cDevice* Switch(cDevice *Device, const cChannel *Channel);
++	void Switch(void);
++	cSwitchLive(void);
++};
++
++cSwitchLive::cSwitchLive(): device(NULL), channel(NULL)
++{
++}
++
++cDevice* cSwitchLive::Switch(cDevice *Device, const cChannel *Channel)
++{
++	mutex.Lock();
++	device = Device;
++	channel = Channel;
++	mutex.Unlock();
++	switched.Wait();
++	return device;
++}
++
++void cSwitchLive::Switch(void)
++{
++	mutex.Lock();
++	if (channel && device) {
++		cDevice::SetAvoidDevice(device);
++		if (!Channels.SwitchTo(cDevice::CurrentChannel())) {
++			if (StreamdevServerSetup.SuspendMode == smAlways) {
++				Channels.SwitchTo(channel->Number());
++				Skins.Message(mtInfo, tr("Streaming active"));
++			}
++			else {
++				esyslog("streamdev: Can't receive channel %d (%s) from device %d. Moving live TV to other device failed (PrimaryDevice=%d, ActualDevice=%d)", channel->Number(), channel->Name(), device->CardIndex(), cDevice::PrimaryDevice()->CardIndex(), cDevice::ActualDevice()->CardIndex());
++				device = NULL;
++			}
++		}
++		// make sure we don't come in here next time
++		channel = NULL;
++		switched.Signal();
++	}
++	mutex.Unlock();
++}
++
+ cServerConnection::cServerConnection(const char *Protocol, int Type):
+ 		cTBSocket(Type),
+ 		m_Protocol(Protocol),
+@@ -22,10 +71,12 @@ cServerConnection::cServerConnection(const char *Protocol, int Type):
+ 		m_WriteBytes(0),
+ 		m_WriteIndex(0)
+ {
++	m_SwitchLive = new cSwitchLive();
+ }
+ 
+ cServerConnection::~cServerConnection() 
+ {
++	delete m_SwitchLive;
+ }
+ 
+ const cChannel* cServerConnection::ChannelFromString(const char *String, int *Apid, int *Dpid) {
+@@ -302,34 +353,7 @@ cDevice *cServerConnection::GetDevice(const cChannel *Channel, int Priority)
+ 			&& 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(cDevice::CurrentChannel())) {
+-			if (StreamdevServerSetup.SuspendMode == smAlways) {
+-				Channels.SwitchTo(Channel->Number());
+-				Skins.QueueMessage(mtInfo, tr("Streaming active"));
+-			}
+-			else {
+-				dsyslog("streamdev: GetDevice: Live TV not suspended");
+-				device = NULL;
+-			}
+-		}
+-#else
+-		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);
+-		}
+-		else if (StreamdevServerSetup.SuspendMode == smAlways) {
+-			Channels.SwitchTo(Channel->Number());
+-			Skins.QueueMessage(mtInfo, tr("Streaming active"));
+-		}
+-		else {
+-			dsyslog("streamdev: GetDevice: Live TV not suspended");
+-			device = NULL;
+-		}
+-#endif
++		device = m_SwitchLive->Switch(device, Channel);
+ 	}
+ 
+ 	if (!device) {
+@@ -371,3 +395,8 @@ bool cServerConnection::ProvidesChannel(const cChannel *Channel, int Priority)
+ 	}
+ 	return device;
+ }
++
++void cServerConnection::MainThreadHook()
++{
++	m_SwitchLive->Switch();
++}
+diff --git a/server/connection.h b/server/connection.h
+index 01a070c..6cc6764 100644
+--- a/server/connection.h
++++ b/server/connection.h
+@@ -15,6 +15,7 @@ typedef std::pair<std::string,std::string> tStrStr;
+ 
+ class cChannel;
+ class cDevice;
++class cSwitchLive;
+ 
+ /* Basic capabilities of a straight text-based protocol, most functions
+    virtual to support more complicated protocols */
+@@ -33,6 +34,8 @@ private:
+ 	uint        m_WriteBytes;
+ 	uint        m_WriteIndex;
+ 
++	cSwitchLive *m_SwitchLive;
++
+ 	tStrStrMap  m_Headers;
+ 
+ 	/* Check if a device would be available for transfering the given
+@@ -108,6 +111,9 @@ public:
+ 	/* Test if a call to GetDevice would return a usable device. */
+ 	bool ProvidesChannel(const cChannel *Channel, int Priority);
+ 
++	/* Do things which must be done in VDR's main loop */
++	void MainThreadHook();
++
+ 	virtual void Flushed(void) {}
+ 
+ 	virtual void Detach(void) = 0;
+diff --git a/server/server.c b/server/server.c
+index 1bdb20a..c7fa96f 100644
+--- a/server/server.c
++++ b/server/server.c
+@@ -121,7 +121,9 @@ void cStreamdevServer::Action(void)
+ 				cServerConnection *client = c->Accept();
+ 				if (!client)
+ 					continue;
++				Lock();
+ 				m_Clients.Add(client);
++				Unlock();
+ 
+ 				if (m_Clients.Count() > StreamdevServerSetup.MaxClients) {
+ 					esyslog("streamdev: too many clients, rejecting %s:%d",
+@@ -153,17 +155,21 @@ void cStreamdevServer::Action(void)
+ 				isyslog("streamdev: closing streamdev connection to %s:%d", 
+ 				        s->RemoteIp().c_str(), s->RemotePort());
+ 				s->Close();
++				Lock();
+ 				m_Clients.Del(s);
++				Unlock();
+ 			}
+ 			s = next;
+ 		}
+ 	}
+ 	
++	Lock();
+ 	while (m_Clients.Count() > 0) {
+ 		cServerConnection *s = m_Clients.First();
+ 		s->Close();
+ 		m_Clients.Del(s);
+ 	}
++	Unlock();
+ 
+ 	while (m_Servers.Count() > 0) {
+ 		cServerComponent *c = m_Servers.First();
+@@ -171,3 +177,10 @@ void cStreamdevServer::Action(void)
+ 		m_Servers.Del(c);
+ 	}
+ }
++
++void cStreamdevServer::MainThreadHook(void) 
++{
++	cThreadLock lock(m_Instance);
++	for (cServerConnection *s = m_Clients.First(); s; s = m_Clients.Next(s))
++		s->MainThreadHook();
++}
+diff --git a/server/server.h b/server/server.h
+index a44df1c..dfe9cc1 100644
+--- a/server/server.h
++++ b/server/server.h
+@@ -36,6 +36,7 @@ public:
+ 	static void Initialize(void);
+ 	static void Destruct(void);
+ 	static bool Active(void);
++	static void MainThreadHook(void);
+ };
+ 
+ inline bool cStreamdevServer::Active(void) 
+diff --git a/server/streamdev-server.c b/server/streamdev-server.c
+index b444df7..f31576c 100644
+--- a/server/streamdev-server.c
++++ b/server/streamdev-server.c
+@@ -130,6 +130,11 @@ cOsdObject *cPluginStreamdevServer::MainMenuAction(void)
+ 	return NULL;
+ }
+ 
++void cPluginStreamdevServer::MainThreadHook(void)
++{
++	cStreamdevServer::MainThreadHook();
++}
++
+ cMenuSetupPage *cPluginStreamdevServer::SetupMenu(void) 
+ {
+ 	return new cStreamdevServerMenuSetupPage;
+diff --git a/server/streamdev-server.h b/server/streamdev-server.h
+index 4083689..f1be8aa 100644
+--- a/server/streamdev-server.h
++++ b/server/streamdev-server.h
+@@ -26,6 +26,7 @@ public:
+ 	virtual cString Active(void);
+ 	virtual const char *MainMenuEntry(void);
+ 	virtual cOsdObject *MainMenuAction(void);
++	virtual void MainThreadHook(void);
+ 	virtual cMenuSetupPage *SetupMenu(void);
+ 	virtual bool SetupParse(const char *Name, const char *Value);
+ };
+commit 5a3c5357781d8c8e04c28a1799d6f6a0e2065daf
+Author: Frank Schmirler <vdr at schmirler.de>
+Date:   Sat Mar 10 23:44:51 2012 +0100
+
+    API change of VDR 1.7.26: Use "occupied" instead of "avoid device".
+
+diff --git a/server/connection.c b/server/connection.c
+index 9b57980..0f1d3f3 100644
+--- a/server/connection.c
++++ b/server/connection.c
+@@ -44,7 +44,12 @@ void cSwitchLive::Switch(void)
+ {
+ 	mutex.Lock();
+ 	if (channel && device) {
++#if APIVERSNUM >= 10722
++		cDevice *d = device;
++		d->SetOccupied(10);
++#else
+ 		cDevice::SetAvoidDevice(device);
++#endif
+ 		if (!Channels.SwitchTo(cDevice::CurrentChannel())) {
+ 			if (StreamdevServerSetup.SuspendMode == smAlways) {
+ 				Channels.SwitchTo(channel->Number());
+@@ -55,6 +60,9 @@ void cSwitchLive::Switch(void)
+ 				device = NULL;
+ 			}
+ 		}
++#if APIVERSNUM >= 10722
++		d->SetOccupied(0);
++#endif
+ 		// make sure we don't come in here next time
+ 		channel = NULL;
+ 		switched.Signal();
+commit a1797719de296b381a18ae889294b00dd5850667
+Author: Frank Schmirler <vdr at schmirler.de>
+Date:   Sun Mar 11 09:41:33 2012 +0100
+
+    Using SetOccupied() won't work as it isn't considered in GetDevice(). Trying
+    to compensate the loss of SetAvoidDevice() with streamdevs CheckConnection(),
+    ignoring the current live TV device. If a new device is returned it is just
+    switched to the new channel. Hopefully the main loop will pick it up later,
+    after streamdev switched aways live TV.
+
+diff --git a/server/connection.c b/server/connection.c
+index 0f1d3f3..ced28e1 100644
+--- a/server/connection.c
++++ b/server/connection.c
+@@ -44,12 +44,24 @@ void cSwitchLive::Switch(void)
+ {
+ 	mutex.Lock();
+ 	if (channel && device) {
+-#if APIVERSNUM >= 10722
+-		cDevice *d = device;
+-		d->SetOccupied(10);
++#if APIVERSNUM >= 10726
++		cChannel *current = Channels.GetByNumber(cDevice::CurrentChannel());
++		cDevice *newdev = cServerConnection::CheckDevice(current, 0, true, device);
++		if (!newdev) { 
++			if (StreamdevServerSetup.SuspendMode == smAlways) {
++				Channels.SwitchTo(channel->Number());
++				Skins.Message(mtInfo, tr("Streaming active"));
++			}
++			else {
++				esyslog("streamdev: Can't receive channel %d (%s) from device %d. Moving live TV to other device failed (PrimaryDevice=%d, ActualDevice=%d)", channel->Number(), channel->Name(), device->CardIndex(), cDevice::PrimaryDevice()->CardIndex(), cDevice::ActualDevice()->CardIndex());
++				device = NULL;
++			}
++		}
++		else {
++			newdev->SwitchChannel(current, true);
++		}
+ #else
+ 		cDevice::SetAvoidDevice(device);
+-#endif
+ 		if (!Channels.SwitchTo(cDevice::CurrentChannel())) {
+ 			if (StreamdevServerSetup.SuspendMode == smAlways) {
+ 				Channels.SwitchTo(channel->Number());
+@@ -60,8 +72,6 @@ void cSwitchLive::Switch(void)
+ 				device = NULL;
+ 			}
+ 		}
+-#if APIVERSNUM >= 10722
+-		d->SetOccupied(0);
+ #endif
+ 		// make sure we don't come in here next time
+ 		channel = NULL;
+diff --git a/server/connection.h b/server/connection.h
+index 0d7a1a0..3c6d9a3 100644
+--- a/server/connection.h
++++ b/server/connection.h
+@@ -38,11 +38,6 @@ private:
+ 
+ 	tStrStrMap  m_Headers;
+ 
+-	/* Check if a device would be available for transfering the given
+-	   channel. This call has no side effects except for temporarily
+-           detaching this connection's receivers. */
+-	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);
+@@ -106,6 +101,10 @@ public:
+ 	/* Close the socket */
+ 	virtual bool Close(void);
+ 
++	/* Check if a device would be available for transfering the given
++	   channel. This call has no side effects. */
++	static cDevice *CheckDevice(const cChannel *Channel, int Priority, bool LiveView, const cDevice *AvoidDevice = NULL);
++
+ 	/* Will retrieve an unused device for transmitting data. Receivers have
+ 	   already been attached from the device if necessary. Use the returned
+ 	   cDevice in a following call to StartTransfer */
diff --git a/vdr-streamdev.spec b/vdr-streamdev.spec
index 1442a07..b406adf 100644
--- a/vdr-streamdev.spec
+++ b/vdr-streamdev.spec
@@ -6,7 +6,7 @@
 
 Name:           vdr-%{pname}
 Version:        0.5.1
-Release:        10%{?dist}
+Release:        11%{?dist}
 Summary:        Streaming plug-in for VDR
 
 Group:          Applications/Multimedia
@@ -20,6 +20,7 @@ Patch0:         %{name}-gpl-fsf-fix.patch
 # http://projects.vdr-developer.org/issues/786
 Patch1:         0001-Fix-build-with-liemikuutio-1.32.patch
 Patch2:         %{name}-0.5.1-vdr1725.patch
+Patch3:         %{name}-0.5.1-vdr1726.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires:  vdr-devel >= 1.5.9
@@ -51,6 +52,7 @@ VDR will then be able to work even without a DVB device.
 %patch0 -p1
 %patch1 -p1
 %patch2 -p1 -F 2
+%patch3 -p1 -F 2
 
 sed -i 's@$(VDRDIR)/device.h@%{_includedir}/vdr/device.h@' Makefile
 
@@ -99,6 +101,9 @@ rm -rf $RPM_BUILD_ROOT
 %doc CONTRIBUTORS COPYING HISTORY PROTOCOL README
 
 %changelog
+* Sun Mar 11 2012 Ville Skyttä <ville.skytta at iki.fi> - 0.5.1-11
+- Apply upstream VDR 1.7.26+ patches.
+
 * Tue Mar  6 2012 Ville Skyttä <ville.skytta at iki.fi> - 0.5.1-10
 - Apply upstream VDR 1.7.25+ patches.
 


More information about the scm-commits mailing list