- streamer now gets stopped when connection terminates unexpectedly

- fixed recursive delete in streamer
This commit is contained in:
lordjaxom 2005-03-24 21:31:38 +00:00
parent 3aa0128266
commit 183de0e401
2 changed files with 28 additions and 14 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: connection.c,v 1.2 2005/02/08 17:22:35 lordjaxom Exp $ * $Id: connection.c,v 1.3 2005/03/24 21:31:38 lordjaxom Exp $
*/ */
#include "server/connection.h" #include "server/connection.h"
@ -130,10 +130,10 @@ cDevice *cServerConnection::GetDevice(const cChannel *Channel, int Priority) {
// maybe a device would be free if THIS connection did turn off its streams? // maybe a device would be free if THIS connection did turn off its streams?
Dprintf(" * trying again...\n"); Dprintf(" * trying again...\n");
const cChannel *current = Channels.GetByNumber(cDevice::CurrentChannel()); const cChannel *current = Channels.GetByNumber(cDevice::CurrentChannel());
isyslog("streamdev-server: Detaching current receiver"); //isyslog("streamdev-server: Detaching current receiver");
Detach(); //Detach(); XXX+
device = cDevice::GetDevice(Channel, Priority); device = cDevice::GetDevice(Channel, Priority);
Attach(); //Attach(); XXX+
Dprintf(" * Found following device: %p (%d)\n", device, Dprintf(" * Found following device: %p (%d)\n", device,
device ? device->CardIndex() + 1 : 0); device ? device->CardIndex() + 1 : 0);
if (device == cDevice::ActualDevice()) if (device == cDevice::ActualDevice())

View File

@ -1,5 +1,5 @@
/* /*
* $Id: streamer.c,v 1.8 2005/02/11 17:02:22 lordjaxom Exp $ * $Id: streamer.c,v 1.9 2005/03/24 21:31:38 lordjaxom Exp $
*/ */
#include <vdr/ringbuffer.h> #include <vdr/ringbuffer.h>
@ -11,6 +11,7 @@
#include "server/suspend.h" #include "server/suspend.h"
#include "server/setup.h" #include "server/setup.h"
#include "tools/socket.h" #include "tools/socket.h"
#include "tools/select.h"
#include "common.h" #include "common.h"
// --- cStreamdevWriter ------------------------------------------------------- // --- cStreamdevWriter -------------------------------------------------------
@ -25,12 +26,14 @@ cStreamdevWriter::cStreamdevWriter(cTBSocket *Socket, cStreamdevStreamer *Stream
cStreamdevWriter::~cStreamdevWriter() cStreamdevWriter::~cStreamdevWriter()
{ {
Dprintf("destructing writer\n");
m_Active = false; m_Active = false;
Cancel(3); Cancel(3);
} }
void cStreamdevWriter::Action(void) void cStreamdevWriter::Action(void)
{ {
cTBSelect sel;
Dprintf("Writer start\n"); Dprintf("Writer start\n");
int max = 0; int max = 0;
m_Active = true; m_Active = true;
@ -39,17 +42,28 @@ void cStreamdevWriter::Action(void)
uchar *block = m_Streamer->Get(count); uchar *block = m_Streamer->Get(count);
if (block) { if (block) {
if (!m_Socket->TimedWrite(block, count, 2000)) { sel.Clear();
sel.Add(*m_Socket, true);
if (sel.Select(500) == -1) {
esyslog("ERROR: streamdev-server: couldn't send data: %m"); esyslog("ERROR: streamdev-server: couldn't send data: %m");
break; break;
} }
if (count > max)
max = count; if (sel.CanWrite(*m_Socket)) {
m_Streamer->Del(count); int written;
if ((written = m_Socket->Write(block, count)) == -1) {
esyslog("ERROR: streamdev-server: couldn't send data: %m");
break;
}
if (count > max)
max = count;
m_Streamer->Del(written);
}
} }
} }
m_Active = false; m_Active = false;
Dprintf("Max. Transmit Blocksize was: %d\n", max); Dprintf("Max. Transmit Blocksize was: %d\n", max);
m_Streamer->Stop();
} }
// --- cStreamdevStreamer ----------------------------------------------------- // --- cStreamdevStreamer -----------------------------------------------------
@ -70,9 +84,7 @@ cStreamdevStreamer::cStreamdevStreamer(const char *Name):
cStreamdevStreamer::~cStreamdevStreamer() cStreamdevStreamer::~cStreamdevStreamer()
{ {
Dprintf("Desctructing streamer\n"); Dprintf("Desctructing streamer\n");
Stop();
delete m_RingBuffer; delete m_RingBuffer;
delete m_Writer;
delete m_SendBuffer; delete m_SendBuffer;
} }
@ -100,9 +112,11 @@ void cStreamdevStreamer::Stop(void)
m_Active = false; m_Active = false;
Cancel(3); Cancel(3);
} }
Detach(); if (m_Running) {
DELETENULL(m_Writer); Detach();
m_Running = false; m_Running = false;
DELETENULL(m_Writer);
}
} }
void cStreamdevStreamer::Action(void) void cStreamdevStreamer::Action(void)