summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorschmirl <schmirl>2007-04-24 10:46:21 +0000
committerschmirl <schmirl>2007-04-24 10:46:21 +0000
commit0a59f04d60e72db367d2c087bebbf13d805b4397 (patch)
tree8853778d42fb61adb451ba0cce9db920c83c2d61 /client
parentd5a38b3213e138b6e74d724198619ab5138242ff (diff)
downloadvdr-plugin-streamdev-0a59f04d60e72db367d2c087bebbf13d805b4397.tar.gz
vdr-plugin-streamdev-0a59f04d60e72db367d2c087bebbf13d805b4397.tar.bz2
client_device-disconnect_detection-fix.patch by Petri Hintukainen
- Try to detect data stream disconnections to avoid 100% CPU-usage in cTSBuffer::Action()
Diffstat (limited to 'client')
-rw-r--r--client/device.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/client/device.c b/client/device.c
index 8b15d94..83ca3d3 100644
--- a/client/device.c
+++ b/client/device.c
@@ -1,5 +1,5 @@
/*
- * $Id: device.c,v 1.10 2007/04/24 10:43:40 schmirl Exp $
+ * $Id: device.c,v 1.11 2007/04/24 10:46:21 schmirl Exp $
*/
#include "client/device.h"
@@ -218,6 +218,30 @@ void cStreamdevDevice::CloseDvr(void) {
bool cStreamdevDevice::GetTSPacket(uchar *&Data) {
if (m_TSBuffer) {
Data = m_TSBuffer->Get();
+#if 1 // TODO: this should be fixed in vdr cTSBuffer
+ // simple disconnect detection
+ static int m_TSFails = 0;
+ if (!Data) {
+ cPoller Poller(*ClientSocket.DataSocket(siLive));
+ errno = 0;
+ if (Poller.Poll() && !errno) {
+ char tmp[1];
+ if (recv(*ClientSocket.DataSocket(siLive), tmp, 1, MSG_PEEK) == 0 && !errno) {
+esyslog("cStreamDevice::GetTSPacket: GetChecked: NOTHING (%d)", m_TSFails);
+ m_TSFails++;
+ if (m_TSFails > 10) {
+ isyslog("cStreamdevDevice::GetTSPacket(): disconnected");
+ m_Pids = 0;
+ CloseDvrInt();
+ m_TSFails = 0;
+ return false;
+ }
+ return true;
+ }
+ }
+ m_TSFails = 0;
+ }
+#endif
return true;
}
return false;