summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorschmirl <schmirl>2008-10-22 11:59:31 +0000
committerschmirl <schmirl>2008-10-22 11:59:31 +0000
commitc364a3396d155efa153cdc183591f7e5fff3d1b7 (patch)
treec476aa315cdeb4b70ca2d46b9e657bc653911792 /server
parent4a5af4f4897d6b34e232ed0e22d1fec9b57177b9 (diff)
downloadvdr-plugin-streamdev-c364a3396d155efa153cdc183591f7e5fff3d1b7.tar.gz
vdr-plugin-streamdev-c364a3396d155efa153cdc183591f7e5fff3d1b7.tar.bz2
- use cThread::Running()/Active() instead of private members
- replaced the last usleep by cCondWait thanks to Rolf Ahrenberg (#383) Modified Files: CONTRIBUTORS HISTORY server/server.c server/server.h server/streamer.c server/streamer.h server/suspend.c server/suspend.h
Diffstat (limited to 'server')
-rw-r--r--server/server.c21
-rw-r--r--server/server.h4
-rw-r--r--server/streamer.c22
-rw-r--r--server/streamer.h12
-rw-r--r--server/suspend.c14
-rw-r--r--server/suspend.h9
6 files changed, 28 insertions, 54 deletions
diff --git a/server/server.c b/server/server.c
index 9399e61..51e0ee1 100644
--- a/server/server.c
+++ b/server/server.c
@@ -1,5 +1,5 @@
/*
- * $Id: server.c,v 1.7 2008/10/14 11:05:48 schmirl Exp $
+ * $Id: server.c,v 1.8 2008/10/22 11:59:32 schmirl Exp $
*/
#include "server/server.h"
@@ -21,8 +21,7 @@ cList<cServerComponent> cStreamdevServer::m_Servers;
cList<cServerConnection> cStreamdevServer::m_Clients;
cStreamdevServer::cStreamdevServer(void):
- cThread("streamdev server"),
- m_Active(false)
+ cThread("streamdev server")
{
Start();
}
@@ -49,10 +48,8 @@ void cStreamdevServer::Destruct(void)
void cStreamdevServer::Stop(void)
{
- if (m_Active) {
- m_Active = false;
+ if (Running())
Cancel(3);
- }
}
void cStreamdevServer::Register(cServerComponent *Server)
@@ -62,8 +59,6 @@ void cStreamdevServer::Register(cServerComponent *Server)
void cStreamdevServer::Action(void)
{
- m_Active = true;
-
/* Initialize Server components, deleting those that failed */
for (cServerComponent *c = m_Servers.First(); c;) {
cServerComponent *next = m_Servers.Next(c);
@@ -74,11 +69,11 @@ void cStreamdevServer::Action(void)
if (m_Servers.Count() == 0) {
esyslog("ERROR: no streamdev server activated, exiting");
- m_Active = false;
+ Cancel(-1);
}
cTBSelect select;
- while (m_Active) {
+ while (Running()) {
select.Clear();
/* Ask all Server components to register to the selector */
@@ -104,9 +99,9 @@ void cStreamdevServer::Action(void)
sel = 0;
}
}
- } while (sel < 0 && errno == ETIMEDOUT && m_Active);
+ } while (sel < 0 && errno == ETIMEDOUT && Running());
- if (!m_Active)
+ if (!Running())
break;
if (sel < 0) {
esyslog("fatal error, server exiting: %m");
@@ -166,6 +161,4 @@ void cStreamdevServer::Action(void)
c->Destruct();
m_Servers.Del(c);
}
-
- m_Active = false;
}
diff --git a/server/server.h b/server/server.h
index 339a05d..a44df1c 100644
--- a/server/server.h
+++ b/server/server.h
@@ -1,5 +1,5 @@
/*
- * $Id: server.h,v 1.5 2008/10/14 11:05:48 schmirl Exp $
+ * $Id: server.h,v 1.6 2008/10/22 11:59:32 schmirl Exp $
*/
#ifndef VDR_STREAMDEV_SERVER_H
@@ -18,8 +18,6 @@ extern char *opt_remux;
class cStreamdevServer: public cThread {
private:
- bool m_Active;
-
static cStreamdevServer *m_Instance;
static cList<cServerComponent> m_Servers;
static cList<cServerConnection> m_Clients;
diff --git a/server/streamer.c b/server/streamer.c
index 979032a..63776cf 100644
--- a/server/streamer.c
+++ b/server/streamer.c
@@ -1,5 +1,5 @@
/*
- * $Id: streamer.c,v 1.16 2007/09/21 11:45:53 schmirl Exp $
+ * $Id: streamer.c,v 1.17 2008/10/22 11:59:32 schmirl Exp $
*/
#include <vdr/ringbuffer.h>
@@ -20,16 +20,15 @@ cStreamdevWriter::cStreamdevWriter(cTBSocket *Socket,
cStreamdevStreamer *Streamer):
cThread("streamdev-writer"),
m_Streamer(Streamer),
- m_Socket(Socket),
- m_Active(false)
+ m_Socket(Socket)
{
}
cStreamdevWriter::~cStreamdevWriter()
{
Dprintf("destructing writer\n");
- m_Active = false;
- Cancel(3);
+ if (Running())
+ Cancel(3);
}
void cStreamdevWriter::Action(void)
@@ -39,11 +38,10 @@ void cStreamdevWriter::Action(void)
int max = 0;
uchar *block = NULL;
int count, offset = 0;
- m_Active = true;
sel.Clear();
sel.Add(*m_Socket, true);
- while (m_Active) {
+ while (Running()) {
if (block == NULL) {
block = m_Streamer->Get(count);
offset = 0;
@@ -73,7 +71,6 @@ void cStreamdevWriter::Action(void)
}
}
}
- m_Active = false;
Dprintf("Max. Transmit Blocksize was: %d\n", max);
}
@@ -81,7 +78,6 @@ void cStreamdevWriter::Action(void)
cStreamdevStreamer::cStreamdevStreamer(const char *Name):
cThread(Name),
- m_Active(false),
m_Running(false),
m_Writer(NULL),
m_RingBuffer(new cRingBufferLinear(STREAMERBUFSIZE, TS_SIZE * 2,
@@ -109,7 +105,7 @@ void cStreamdevStreamer::Start(cTBSocket *Socket)
void cStreamdevStreamer::Activate(bool On)
{
- if (On && !m_Active) {
+ if (On && !Active()) {
Dprintf("activate streamer\n");
m_Writer->Start();
cThread::Start();
@@ -118,9 +114,8 @@ void cStreamdevStreamer::Activate(bool On)
void cStreamdevStreamer::Stop(void)
{
- if (m_Active) {
+ if (Running()) {
Dprintf("stopping streamer\n");
- m_Active = false;
Cancel(3);
}
if (m_Running) {
@@ -132,8 +127,7 @@ void cStreamdevStreamer::Stop(void)
void cStreamdevStreamer::Action(void)
{
- m_Active = true;
- while (m_Active) {
+ while (Running()) {
int got;
uchar *block = m_RingBuffer->Get(got);
diff --git a/server/streamer.h b/server/streamer.h
index e557d55..9deec8d 100644
--- a/server/streamer.h
+++ b/server/streamer.h
@@ -1,5 +1,5 @@
/*
- * $Id: streamer.h,v 1.8 2007/04/02 10:32:34 schmirl Exp $
+ * $Id: streamer.h,v 1.9 2008/10/22 11:59:32 schmirl Exp $
*/
#ifndef VDR_STREAMDEV_STREAMER_H
@@ -21,7 +21,6 @@ class cStreamdevWriter: public cThread {
private:
cStreamdevStreamer *m_Streamer;
cTBSocket *m_Socket;
- bool m_Active;
protected:
virtual void Action(void);
@@ -29,15 +28,12 @@ protected:
public:
cStreamdevWriter(cTBSocket *Socket, cStreamdevStreamer *Streamer);
virtual ~cStreamdevWriter();
-
- bool IsActive(void) const { return m_Active; }
};
// --- cStreamdevStreamer -----------------------------------------------------
class cStreamdevStreamer: public cThread {
private:
- bool m_Active;
bool m_Running;
cStreamdevWriter *m_Writer;
cRingBufferLinear *m_RingBuffer;
@@ -54,7 +50,7 @@ public:
virtual void Start(cTBSocket *Socket);
virtual void Stop(void);
- bool Abort(void) const;
+ bool Abort(void);
void Activate(bool On);
int Receive(uchar *Data, int Length) { return m_RingBuffer->Put(Data, Length); }
@@ -68,9 +64,9 @@ public:
virtual void Attach(void) {}
};
-inline bool cStreamdevStreamer::Abort(void) const
+inline bool cStreamdevStreamer::Abort(void)
{
- return m_Active && !m_Writer->IsActive();
+ return Active() && !m_Writer->Active();
}
#endif // VDR_STREAMDEV_STREAMER_H
diff --git a/server/suspend.c b/server/suspend.c
index 541131c..b6e1382 100644
--- a/server/suspend.c
+++ b/server/suspend.c
@@ -1,5 +1,5 @@
/*
- * $Id: suspend.c,v 1.2 2008/04/07 14:27:31 schmirl Exp $
+ * $Id: suspend.c,v 1.3 2008/10/22 11:59:32 schmirl Exp $
*/
#include "server/suspend.h"
@@ -12,6 +12,7 @@ cSuspendLive::cSuspendLive(void)
}
cSuspendLive::~cSuspendLive() {
+ Stop();
Detach();
}
@@ -24,17 +25,14 @@ void cSuspendLive::Activate(bool On) {
}
void cSuspendLive::Stop(void) {
- if (m_Active) {
- m_Active = false;
+ if (Running())
Cancel(3);
- }
}
void cSuspendLive::Action(void) {
- m_Active = true;
- while (m_Active) {
+ while (Running()) {
DeviceStillPicture(suspend_mpg, sizeof(suspend_mpg));
- usleep(100000);
+ cCondWait::SleepMs(100);
}
}
@@ -51,7 +49,7 @@ cSuspendCtl::~cSuspendCtl() {
}
eOSState cSuspendCtl::ProcessKey(eKeys Key) {
- if (!m_Suspend->IsActive() || Key == kBack) {
+ if (!m_Suspend->Active() || Key == kBack) {
DELETENULL(m_Suspend);
return osEnd;
}
diff --git a/server/suspend.h b/server/suspend.h
index f04ad42..bea25ee 100644
--- a/server/suspend.h
+++ b/server/suspend.h
@@ -1,5 +1,5 @@
/*
- * $Id: suspend.h,v 1.1 2004/12/30 22:44:26 lordjaxom Exp $
+ * $Id: suspend.h,v 1.2 2008/10/22 11:59:32 schmirl Exp $
*/
#ifndef VDR_STREAMDEV_SUSPEND_H
@@ -7,10 +7,7 @@
#include <vdr/player.h>
-class cSuspendLive: public cPlayer, cThread {
-private:
- bool m_Active;
-
+class cSuspendLive: public cPlayer, public cThread {
protected:
virtual void Activate(bool On);
virtual void Action(void);
@@ -20,8 +17,6 @@ protected:
public:
cSuspendLive(void);
virtual ~cSuspendLive();
-
- bool IsActive(void) const { return m_Active; }
};
class cSuspendCtl: public cControl {