From aa27bf95c090091c9fd3990f2587b66d0aedaea8 Mon Sep 17 00:00:00 2001 From: darkeye Date: Mon, 7 Jul 2008 14:33:34 +0000 Subject: [PATCH] added ability to specify jack device name created by darkice, thanks to Alessandro Baretta re #24 --- darkice/trunk/AUTHORS | 1 + darkice/trunk/ChangeLog | 2 ++ darkice/trunk/man/darkice.1 | 1 + darkice/trunk/man/darkice.cfg.5 | 4 ++++ darkice/trunk/src/AudioSource.cpp | 2 ++ darkice/trunk/src/AudioSource.h | 1 + darkice/trunk/src/DarkIce.cpp | 3 +++ darkice/trunk/src/JackDspSource.cpp | 7 ++++++- darkice/trunk/src/JackDspSource.h | 6 ++++++ 9 files changed, 26 insertions(+), 1 deletion(-) diff --git a/darkice/trunk/AUTHORS b/darkice/trunk/AUTHORS index 65d0adb..041920a 100644 --- a/darkice/trunk/AUTHORS +++ b/darkice/trunk/AUTHORS @@ -33,4 +33,5 @@ with contributions by: Elod Horvath Pierre Souchay Daniel Hazelbaker + Alessandro Beretta diff --git a/darkice/trunk/ChangeLog b/darkice/trunk/ChangeLog index 35930df..2c6ccd8 100644 --- a/darkice/trunk/ChangeLog +++ b/darkice/trunk/ChangeLog @@ -6,6 +6,8 @@ Darkice 0.19 to be released thanks to Pierre Souchay o enable easier finding of jack libraries on MacOS X, thanks to Daniel Hazelbaker + o added ability to specify name of jack device created by darkice, + thanks to Alessandro Beretta 26-04-2007 DarkIce 0.18.1 released diff --git a/darkice/trunk/man/darkice.1 b/darkice/trunk/man/darkice.1 index 7fb755a..3e3852d 100644 --- a/darkice/trunk/man/darkice.1 +++ b/darkice/trunk/man/darkice.1 @@ -107,6 +107,7 @@ Developed with contributions by Elod Horvath Pierre Souchay Daniel Hazelbaker + Alessandro Beretta .SH LINKS Project homepage: diff --git a/darkice/trunk/man/darkice.cfg.5 b/darkice/trunk/man/darkice.cfg.5 index 28af76c..fd1e018 100644 --- a/darkice/trunk/man/darkice.cfg.5 +++ b/darkice/trunk/man/darkice.cfg.5 @@ -90,6 +90,10 @@ Number of bits to use for each sample (e.g. 8 bits or 16 bits) .TP .I channel Number of channels to record (e.g. 1 for mono, 2 for stereo) +.TP +.I jackClientName +The name of the jack input channel created by darkice if device=jack +is specified. .PP .B [icecast-x] diff --git a/darkice/trunk/src/AudioSource.cpp b/darkice/trunk/src/AudioSource.cpp index 3b01ef5..c5a8cfa 100644 --- a/darkice/trunk/src/AudioSource.cpp +++ b/darkice/trunk/src/AudioSource.cpp @@ -60,6 +60,7 @@ static const char fileid[] = "$Id$"; *----------------------------------------------------------------------------*/ AudioSource * AudioSource :: createDspSource( const char * deviceName, + const char * jackClientName, int sampleRate, int bitsPerSample, int channel) @@ -101,6 +102,7 @@ AudioSource :: createDspSource( const char * deviceName, #if defined( SUPPORT_JACK_DSP ) Reporter::reportEvent( 1, "Using JACK audio server as input device."); return new JackDspSource( deviceName, + jackClientName, sampleRate, bitsPerSample, channel); diff --git a/darkice/trunk/src/AudioSource.h b/darkice/trunk/src/AudioSource.h index b8e5a90..5f464f0 100644 --- a/darkice/trunk/src/AudioSource.h +++ b/darkice/trunk/src/AudioSource.h @@ -272,6 +272,7 @@ class AudioSource : public Source, public virtual Reporter */ static AudioSource * createDspSource( const char * deviceName, + const char * jackClientName, int sampleRate = 44100, int bitsPerSample = 16, int channel = 2) throw ( Exception ); diff --git a/darkice/trunk/src/DarkIce.cpp b/darkice/trunk/src/DarkIce.cpp index 86b39e1..28796bb 100644 --- a/darkice/trunk/src/DarkIce.cpp +++ b/darkice/trunk/src/DarkIce.cpp @@ -139,6 +139,7 @@ DarkIce :: init ( const Config & config ) throw ( Exception ) unsigned int channel; bool reconnect; const char * device; + const char * jackClientName; // the [general] section if ( !(cs = config.get( "general")) ) { @@ -172,8 +173,10 @@ DarkIce :: init ( const Config & config ) throw ( Exception ) str = cs->getForSure( "channel", " missing in section [input]"); channel = Util::strToL( str); device = cs->getForSure( "device", " missing in section [input]"); + jackClientName = cs->get ( "jackClientName"); dsp = AudioSource::createDspSource( device, + jackClientName, sampleRate, bitsPerSample, channel ); diff --git a/darkice/trunk/src/JackDspSource.cpp b/darkice/trunk/src/JackDspSource.cpp index 1a26262..86443fa 100644 --- a/darkice/trunk/src/JackDspSource.cpp +++ b/darkice/trunk/src/JackDspSource.cpp @@ -188,7 +188,12 @@ JackDspSource :: open ( void ) throw ( Exception ) } // Register client with Jack - snprintf(client_name, 255, "darkice-%d", getpid()); + if ( jack_client_name != NULL ) { + snprintf(client_name, 255, "%s", jack_client_name); + } else { + snprintf(client_name, 255, "darkice-%d", getpid()); + } + if ((client = jack_client_new(client_name)) == NULL) { throw Exception( __FILE__, __LINE__, "JACK server not running?"); } diff --git a/darkice/trunk/src/JackDspSource.h b/darkice/trunk/src/JackDspSource.h index 73fcb70..83a2bd1 100644 --- a/darkice/trunk/src/JackDspSource.h +++ b/darkice/trunk/src/JackDspSource.h @@ -67,6 +67,10 @@ class JackDspSource : public AudioSource, public virtual Reporter { private: + /** + * The jack client name. + */ + const char * jack_client_name; /** * The jack port @@ -156,6 +160,7 @@ class JackDspSource : public AudioSource, public virtual Reporter */ inline JackDspSource ( const char * name, + const char * jackClientName, int sampleRate = 44100, int bitsPerSample = 16, int channels = 2 ) @@ -163,6 +168,7 @@ class JackDspSource : public AudioSource, public virtual Reporter : AudioSource( sampleRate, bitsPerSample, channels ) { + jack_client_name = jackClientName; init( name ); }