- 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
This commit is contained in:
schmirl 2008-10-22 11:59:31 +00:00
parent 4a5af4f489
commit c364a3396d
8 changed files with 31 additions and 54 deletions

View File

@ -27,6 +27,7 @@ Rolf Ahrenberg
for removing pre VDR 1.4 legacy code
for adding gettext support
for fixing output format of some debug messages
for replacing private members by cThread::Running()/Active()
Rantanen Teemu
for providing vdr-incompletesections.diff

View File

@ -1,6 +1,8 @@
VDR Plugin 'streamdev' Revision History
---------------------------------------
- use cThread::Running()/Active() instead of private members (thanks to
Rolf Ahrenberg)
- fixed output format of some debug messages (thanks to Rolf Ahrenberg)
- added HTTP authentication
- compatibility for VDR 1.7.1 (thanks to Udo Richter)

View File

@ -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;
}

View File

@ -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;

View File

@ -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,15 +20,14 @@ 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;
if (Running())
Cancel(3);
}
@ -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);

View File

@ -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

View File

@ -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;
}

View File

@ -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 {