anged internals so that now each encoding/server connection is

a separate thread
This commit is contained in:
darkeye 2002-10-19 12:24:55 +00:00
parent 0855e833a1
commit 8fd167a179
7 changed files with 57 additions and 34 deletions

View File

@ -2,6 +2,8 @@ DarkIce next release
o ported to FreeBSD (removed reference to MSG_NOSIGNAL in TcpSocket.cpp) o ported to FreeBSD (removed reference to MSG_NOSIGNAL in TcpSocket.cpp)
o bug fix: maximum bitrate setting fixed for Ogg Vorbis streams o bug fix: maximum bitrate setting fixed for Ogg Vorbis streams
o changed internals so that now each encoding/server connection is
a separate thread
20-08-2002: DarkIce 0.11 released 20-08-2002: DarkIce 0.11 released

View File

@ -3,7 +3,7 @@ o make a master config file, and a small one ?
o reconnect to server if connection is dropped o reconnect to server if connection is dropped
o add support for multiple servers for one stream ? o add support for multiple servers for one stream ?
o libtoolize ? o libtoolize ?
o revisit real-time scheduling and one-thread-per-connection o revisit real-time scheduling
o look into performance o look into performance
o create proper error-reporting module o create proper error-reporting module
o set comment fields for Ogg Vorbis streams as in o set comment fields for Ogg Vorbis streams as in

View File

@ -11,7 +11,7 @@ dnl AC_STDC_HEADERS
AC_HAVE_HEADERS(errno.h fcntl.h stdio.h stdlib.h string.h unistd.h limits.h) AC_HAVE_HEADERS(errno.h fcntl.h stdio.h stdlib.h string.h unistd.h limits.h)
AC_HAVE_HEADERS(signal.h time.h sys/time.h sys/types.h sys/wait.h math.h) AC_HAVE_HEADERS(signal.h time.h sys/time.h sys/types.h sys/wait.h math.h)
AC_HAVE_HEADERS(netdb.h netinet/in.h sys/ioctl.h sys/socket.h sys/stat.h) AC_HAVE_HEADERS(netdb.h netinet/in.h sys/ioctl.h sys/socket.h sys/stat.h)
AC_HAVE_HEADERS(sched.h) AC_HAVE_HEADERS(sched.h pthread.h)
AC_HAVE_HEADERS(sys/soundcard.h sys/audio.h) AC_HAVE_HEADERS(sys/soundcard.h sys/audio.h)
AC_HEADER_SYS_WAIT() AC_HEADER_SYS_WAIT()
@ -21,6 +21,7 @@ AC_TYPE_SIZE_T()
AC_CHECK_LIB( socket, socket) AC_CHECK_LIB( socket, socket)
AC_CHECK_LIB( nsl, gethostbyname) AC_CHECK_LIB( nsl, gethostbyname)
AC_CHECK_LIB( rt, sched_getscheduler) AC_CHECK_LIB( rt, sched_getscheduler)
AC_CHECK_LIB( pthread, pthread_create)
SYSTEM_INCLUDE=/usr/include SYSTEM_INCLUDE=/usr/include

View File

@ -161,6 +161,10 @@ Connector :: detach ( Sink * sink ) throw ( Exception )
} else if ( numSinks == 1 ) { } else if ( numSinks == 1 ) {
if ( sinks[0].get() != sink ) {
return false;
}
sinks[0] = 0; sinks[0] = 0;
delete[] sinks; delete[] sinks;
sinks = 0; sinks = 0;
@ -286,6 +290,7 @@ Connector :: transfer ( unsigned long bytes,
if ( sinks[u]->canWrite( sec, usec) ) { if ( sinks[u]->canWrite( sec, usec) ) {
try { try {
/* we expect the sink to accept all data written */
e = sinks[u]->write( buf, d); e = sinks[u]->write( buf, d);
} catch ( Exception & e ) { } catch ( Exception & e ) {
sinks[u]->close(); sinks[u]->close();
@ -341,6 +346,10 @@ Connector :: close ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.10 2002/10/19 12:24:55 darkeye
anged internals so that now each encoding/server connection is
a separate thread
Revision 1.9 2002/08/02 17:59:17 darkeye Revision 1.9 2002/08/02 17:59:17 darkeye
bug fix: when the last server dropped connection, darkice crashed bug fix: when the last server dropped connection, darkice crashed

View File

@ -61,21 +61,6 @@ class Connector : public virtual Referable, public virtual Reporter
{ {
private: private:
/**
* The source to read from.
*/
Ref<Source> source;
/**
* The sinks to connect the source to.
*/
Ref<Sink> * sinks;
/**
* Total number of sinks.
*/
unsigned int numSinks;
/** /**
* Initialize the object. * Initialize the object.
* *
@ -96,6 +81,21 @@ class Connector : public virtual Referable, public virtual Reporter
protected: protected:
/**
* The source to read from.
*/
Ref<Source> source;
/**
* The sinks to connect the source to.
*/
Ref<Sink> * sinks;
/**
* Total number of sinks.
*/
unsigned int numSinks;
/** /**
* Default constructor. Always throws an Exception. * Default constructor. Always throws an Exception.
* *
@ -107,6 +107,16 @@ class Connector : public virtual Referable, public virtual Reporter
throw Exception( __FILE__, __LINE__); throw Exception( __FILE__, __LINE__);
} }
/**
* Detach an already attached Sink from the Source of this Connector.
*
* @param sink the Sink to detach.
* @return true if the detachment was successful, false otherwise.
* @exception Exception
*/
virtual bool
detach ( Sink * sink ) throw ( Exception );
public: public:
@ -172,7 +182,7 @@ class Connector : public virtual Referable, public virtual Reporter
* @return the number of Sinks in the Connector. * @return the number of Sinks in the Connector.
* @exception Exception * @exception Exception
*/ */
inline unsigned int inline virtual unsigned int
getNumSinks ( void ) const throw () getNumSinks ( void ) const throw ()
{ {
return numSinks; return numSinks;
@ -184,26 +194,16 @@ class Connector : public virtual Referable, public virtual Reporter
* @param sink the Sink to attach. * @param sink the Sink to attach.
* @exception Exception * @exception Exception
*/ */
void virtual void
attach ( Sink * sink ) throw ( Exception ); attach ( Sink * sink ) throw ( Exception );
/**
* Detach an already attached Sink from the Source of this Connector.
*
* @param sink the Sink to detach.
* @return true if the detachment was successful, false otherwise.
* @exception Exception
*/
bool
detach ( Sink * sink ) throw ( Exception );
/** /**
* Open the connector. Opens the Source and the Sinks if necessary. * Open the connector. Opens the Source and the Sinks if necessary.
* *
* @return true if opening was successful, false otherwise. * @return true if opening was successful, false otherwise.
* @exception Exception * @exception Exception
*/ */
bool virtual bool
open ( void ) throw ( Exception ); open ( void ) throw ( Exception );
/** /**
@ -222,13 +222,13 @@ class Connector : public virtual Referable, public virtual Reporter
* @param sec the number of seconds to wait for the Source to have * @param sec the number of seconds to wait for the Source to have
* data available in each turn, and the number of seconds * data available in each turn, and the number of seconds
* to wait for the Sinks to accept data. * to wait for the Sinks to accept data.
* @param usec the number of micros seconds to wait for the Source to * @param usec the number of micro seconds to wait for the Source to
* have data available in each turn, and the number of * have data available in each turn, and the number of
* micro seconds to wait for the Sinks to accept data. * micro seconds to wait for the Sinks to accept data.
* @return the number of bytes read from the Source. * @return the number of bytes read from the Source.
* @exception Exception * @exception Exception
*/ */
unsigned int virtual unsigned int
transfer ( unsigned long bytes, transfer ( unsigned long bytes,
unsigned int bufSize, unsigned int bufSize,
unsigned int sec, unsigned int sec,
@ -239,7 +239,7 @@ class Connector : public virtual Referable, public virtual Reporter
* *
* @exception Exception * @exception Exception
*/ */
void virtual void
close ( void ) throw ( Exception ); close ( void ) throw ( Exception );
}; };
@ -259,6 +259,10 @@ class Connector : public virtual Referable, public virtual Reporter
$Source$ $Source$
$Log$ $Log$
Revision 1.6 2002/10/19 12:24:55 darkeye
anged internals so that now each encoding/server connection is
a separate thread
Revision 1.5 2001/08/26 20:44:30 darkeye Revision 1.5 2001/08/26 20:44:30 darkeye
removed external command-line encoder support removed external command-line encoder support
replaced it with a shared-object support for lame with the possibility replaced it with a shared-object support for lame with the possibility

View File

@ -77,6 +77,7 @@
#include "IceCast2.h" #include "IceCast2.h"
#include "ShoutCast.h" #include "ShoutCast.h"
#include "FileCast.h" #include "FileCast.h"
#include "MultiThreadedConnector.h"
#include "DarkIce.h" #include "DarkIce.h"
#ifdef HAVE_LAME_LIB #ifdef HAVE_LAME_LIB
@ -157,7 +158,7 @@ DarkIce :: init ( const Config & config ) throw ( Exception )
sampleRate, sampleRate,
bitsPerSample, bitsPerSample,
channel ); channel );
encConnector = new Connector( dsp.get()); encConnector = new MultiThreadedConnector( dsp.get());
noAudioOuts = 0; noAudioOuts = 0;
configIceCast( config, bufferSecs); configIceCast( config, bufferSecs);
@ -964,6 +965,10 @@ DarkIce :: run ( void ) throw ( Exception )
$Source$ $Source$
$Log$ $Log$
Revision 1.32 2002/10/19 12:24:55 darkeye
anged internals so that now each encoding/server connection is
a separate thread
Revision 1.31 2002/08/20 19:35:37 darkeye Revision 1.31 2002/08/20 19:35:37 darkeye
added possibility to specify maximum bitrate for Ogg Vorbis streams added possibility to specify maximum bitrate for Ogg Vorbis streams

View File

@ -13,6 +13,8 @@ darkice_SOURCES = AudioEncoder.h\
FileSink.cpp\ FileSink.cpp\
Connector.cpp\ Connector.cpp\
Connector.h\ Connector.h\
MultiThreadedConnector.cpp\
MultiThreadedConnector.h\
DarkIce.cpp\ DarkIce.cpp\
DarkIce.h\ DarkIce.h\
Exception.cpp\ Exception.cpp\