summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorschmirl <schmirl>2007-04-24 10:43:40 +0000
committerschmirl <schmirl>2007-04-24 10:43:40 +0000
commitd5a38b3213e138b6e74d724198619ab5138242ff (patch)
tree044abf65357c36b8a782b2f5f3ee1cbba043ec4f /client
parent0553fce43c696295bd4b291f58397497b59f965b (diff)
downloadvdr-plugin-streamdev-d5a38b3213e138b6e74d724198619ab5138242ff.tar.gz
vdr-plugin-streamdev-d5a38b3213e138b6e74d724198619ab5138242ff.tar.bz2
client_device-vdr-1.5.1-fixes.patch by Petri Hintukainen (#219)
- VDR 1.5.0 calls some device members in different order and streamdev can't currently handle this. - do not trust in OpenDvr/CloseDvr, instead keep count of active PIDs, open data connection when it is needed and close it only when there are no active PIDs (closing data connection unsubscribes all pids at server end) - some sanity checks on server side Modified Files: client/device.c client/device.h server/connectionVTP.c
Diffstat (limited to 'client')
-rw-r--r--client/device.c85
-rw-r--r--client/device.h7
2 files changed, 76 insertions, 16 deletions
diff --git a/client/device.c b/client/device.c
index e2d857d..8b15d94 100644
--- a/client/device.c
+++ b/client/device.c
@@ -1,5 +1,5 @@
/*
- * $Id: device.c,v 1.9 2007/04/23 11:42:16 schmirl Exp $
+ * $Id: device.c,v 1.10 2007/04/24 10:43:40 schmirl Exp $
*/
#include "client/device.h"
@@ -42,6 +42,8 @@ cStreamdevDevice::cStreamdevDevice(void) {
#endif
m_Device = this;
+ m_Pids = 0;
+ m_DvrClosed = true;
if (StreamdevClientSetup.SyncEPG)
ClientSocket.SynchronizeEPG();
@@ -132,34 +134,87 @@ bool cStreamdevDevice::SetChannelDevice(const cChannel *Channel,
bool cStreamdevDevice::SetPid(cPidHandle *Handle, int Type, bool On) {
Dprintf("SetPid, Pid=%d, Type=%d, On=%d, used=%d\n", Handle->pid, Type, On,
Handle->used);
- if (Handle->pid && (On || !Handle->used))
- return ClientSocket.SetPid(Handle->pid, On);
- return true;
+ LOCK_THREAD;
+
+ if (On && !m_TSBuffer) {
+ Dprintf("SetPid: no data connection -> OpenDvr()");
+ OpenDvrInt();
+ }
+
+ bool res = true;
+ if (Handle->pid && (On || !Handle->used)) {
+ res = ClientSocket.SetPid(Handle->pid, On);
+
+ m_Pids += (!res) ? 0 : On ? 1 : -1;
+ if (m_Pids < 0)
+ m_Pids = 0;
+
+ if(m_Pids < 1 && m_DvrClosed) {
+ Dprintf("SetPid: 0 pids left -> CloseDvr()");
+ CloseDvrInt();
+ }
+ }
+
+ return res;
}
-bool cStreamdevDevice::OpenDvr(void) {
- Dprintf("OpenDvr\n");
- CloseDvr();
+bool cStreamdevDevice::OpenDvrInt(void) {
+ Dprintf("OpenDvrInt\n");
+ LOCK_THREAD;
+
+ CloseDvrInt();
+ if (m_TSBuffer) {
+ Dprintf("cStreamdevDevice::OpenDvrInt(): DVR connection already open\n");
+ return true;
+ }
+
+ Dprintf("cStreamdevDevice::OpenDvrInt(): Connecting ...\n");
if (ClientSocket.CreateDataConnection(siLive)) {
- //m_Assembler = new cStreamdevAssembler(ClientSocket.DataSocket(siLive));
- //m_TSBuffer = new cTSBuffer(m_Assembler->ReadPipe(), MEGABYTE(2), CardIndex() + 1);
m_TSBuffer = new cTSBuffer(*ClientSocket.DataSocket(siLive), MEGABYTE(2), CardIndex() + 1);
- Dprintf("waiting\n");
- //m_Assembler->WaitForFill();
- Dprintf("resuming\n");
return true;
}
+ esyslog("cStreamdevDevice::OpenDvrInt(): DVR connection FAILED");
return false;
}
-void cStreamdevDevice::CloseDvr(void) {
- Dprintf("CloseDvr\n");
+bool cStreamdevDevice::OpenDvr(void) {
+ Dprintf("OpenDvr\n");
+ LOCK_THREAD;
+
+ m_DvrClosed = false;
+ return OpenDvrInt();
+}
- //DELETENULL(m_Assembler);
+void cStreamdevDevice::CloseDvrInt(void) {
+ Dprintf("CloseDvrInt\n");
+ LOCK_THREAD;
+
+ if (ClientSocket.CheckConnection()) {
+ if (!m_DvrClosed) {
+ Dprintf("cStreamdevDevice::CloseDvrInt(): m_DvrClosed=false -> not closing yet\n");
+ return;
+ }
+ if (m_Pids > 0) {
+ Dprintf("cStreamdevDevice::CloseDvrInt(): %d active pids -> not closing yet\n", m_Pids);
+ return;
+ }
+ } else {
+ Dprintf("cStreamdevDevice::CloseDvrInt(): Control connection gone !\n");
+ }
+
+ Dprintf("cStreamdevDevice::CloseDvrInt(): Closing DVR connection\n");
DELETENULL(m_TSBuffer);
ClientSocket.CloseDvr();
}
+void cStreamdevDevice::CloseDvr(void) {
+ Dprintf("CloseDvr\n");
+ LOCK_THREAD;
+
+ m_DvrClosed = true;
+ CloseDvrInt();
+}
+
bool cStreamdevDevice::GetTSPacket(uchar *&Data) {
if (m_TSBuffer) {
Data = m_TSBuffer->Get();
diff --git a/client/device.h b/client/device.h
index 3ef146f..525c1d4 100644
--- a/client/device.h
+++ b/client/device.h
@@ -1,5 +1,5 @@
/*
- * $Id: device.h,v 1.4 2007/04/23 11:42:16 schmirl Exp $
+ * $Id: device.h,v 1.5 2007/04/24 10:43:40 schmirl Exp $
*/
#ifndef VDR_STREAMDEV_DEVICE_H
@@ -25,9 +25,14 @@ private:
#if VDRVERSNUM >= 10307
cStreamdevFilters *m_Filters;
#endif
+ int m_Pids;
+ bool m_DvrClosed;
static cStreamdevDevice *m_Device;
+ bool OpenDvrInt(void);
+ void CloseDvrInt(void);
+
protected:
virtual bool SetChannelDevice(const cChannel *Channel, bool LiveView);
virtual bool HasLock(int TimeoutMs)