[xiph-commits] r8183 - in icecast/branches/kh/ices: conf doc src
j at motherfish-iii.xiph.org
j at motherfish-iii.xiph.org
Mon Nov 8 12:11:03 PST 2004
Author: j
Date: 2004-11-08 12:11:02 -0800 (Mon, 08 Nov 2004)
New Revision: 8183
Modified:
icecast/branches/kh/ices/conf/ices-jack.xml
icecast/branches/kh/ices/doc/inputs.html
icecast/branches/kh/ices/src/im_jack.c
icecast/branches/kh/ices/src/im_jack.h
Log:
- add optional param "connect" to im_jack,
a comma-separated list of ports to connect to at startup
Modified: icecast/branches/kh/ices/conf/ices-jack.xml
===================================================================
--- icecast/branches/kh/ices/conf/ices-jack.xml 2004-11-08 17:41:00 UTC (rev 8182)
+++ icecast/branches/kh/ices/conf/ices-jack.xml 2004-11-08 20:11:02 UTC (rev 8183)
@@ -25,6 +25,7 @@
<module>jack</module>
<param name="channels">2</param> <!-- number channels that will be available as jack ports-->
<param name="clientname">ices</param> <!-- jackclient name -->
+ <param name="connect">alsa_pcm:capture_1,alsa_pcm:capture_2</param> <!-- Comma-separated list of ports to connect to at startup.(optional, it is also possible to use tools like jack.plumbing to take care of the connections) -->
<param name="metadatafilename">metadata</param>
</input>
<!-- more input section can be stated here, and can be switched manually -->
@@ -112,4 +113,3 @@
</stream>
</ices>
-
Modified: icecast/branches/kh/ices/doc/inputs.html
===================================================================
--- icecast/branches/kh/ices/doc/inputs.html 2004-11-08 17:41:00 UTC (rev 8182)
+++ icecast/branches/kh/ices/doc/inputs.html 2004-11-08 20:11:02 UTC (rev 8183)
@@ -136,6 +136,7 @@
<module>jack</module>
<param name="channels">2</param>
<param name="clientname">ices</param>
+ <param name="connect">alsa_pcm:capture_1,alsa_pcm:capture_2</param>
<param name="metadatafilename">/home/ices/metadata</param>
</pre>
<p>
@@ -154,6 +155,11 @@
<div class=indentedbox>
The name ices registers as at the jack server.
</div>
+ <h4>connect</h4>
+ <div class=indentedbox>
+ Comma-separated list of ports to connect to at startup.<br />
+ (optional, it is also possible to use tools like jack.plumbing to take care of the connections)
+ </div>
<h4>metadatafilename</h4>
<div class=indentedbox>
<p>
Modified: icecast/branches/kh/ices/src/im_jack.c
===================================================================
--- icecast/branches/kh/ices/src/im_jack.c 2004-11-08 17:41:00 UTC (rev 8182)
+++ icecast/branches/kh/ices/src/im_jack.c 2004-11-08 20:11:02 UTC (rev 8183)
@@ -157,11 +157,13 @@
jack_default_audio_sample_t **pcms;
jack_nframes_t nframes=s->samples;
size_t framebuf_size = sizeof (jack_default_audio_sample_t) * nframes;
+ size_t fb_read;
while (1)
{
/* read and process from ringbuffer has to go here. */
- if (jack_ringbuffer_read_space (s->rb[0]) > framebuf_size)
+ fb_read=framebuf_size;
+ if (jack_ringbuffer_read_space (s->rb[0]) > fb_read)
{
if ((ib = input_alloc_buffer (mod)) == NULL)
{
@@ -173,12 +175,12 @@
for (chn = 0; chn < (s->channels); chn++)
{
size_t len;
- len = jack_ringbuffer_read (s->rb[chn], (char*)pcms[chn], framebuf_size);
- if (len < framebuf_size)
- framebuf_size = len;
+ len = jack_ringbuffer_read (s->rb[chn], (char*)pcms[chn], fb_read);
+ if (len < fb_read)
+ fb_read = len;
}
- ib->samples = framebuf_size/sizeof(jack_default_audio_sample_t);
+ ib->samples = fb_read/sizeof(jack_default_audio_sample_t);
ib->samplerate = s->rate;
ib->channels = s->channels;
@@ -234,7 +236,8 @@
{
im_jack_state *s;
module_param_t *current;
- char *clientname = "ices"; /* default clientname */
+ char *clientname;
+ char *connect;
int channels, rate;
unsigned int samples;
unsigned sleep_time;
@@ -258,9 +261,10 @@
channels = 2;
samples = 4096;
sleep_time = 10000;
+ clientname = "ices";
+ connect = "";
current = mod->module_params;
-
while(current)
{
if(!strcmp(current->name, "channels"))
@@ -271,14 +275,16 @@
mod->metadata_filename = current->value;
else if(!strcmp(current->name, "sleep"))
sleep_time = atoi (current->value);
- else
+ else if(!strcmp(current->name, "connect"))
+ connect = current->value;
+ else
LOG_WARN1("Unknown parameter %s for jack module", current->name);
current = current->next;
}
s->channels = channels;
s->clientname = clientname;
-
+ s->connect = connect;
s->rate = rate;
s->samples = samples;
if (sleep_time > 0)
@@ -302,7 +308,31 @@
int i,j;
char port_name[32];
size_t rb_size;
+ const char *con_ptr=s->connect;
+ const char *ind;
+ const char connect[16][32];
+ int con_ports=0;
+ int last=0;
+ jack_port_t *input_port;
+ const char *input_port_name;
+ const char *output_port_name;
+ // Find out which ports to connect to.
+ if(strcmp(s->connect, "")) {
+ while (!last && con_ports < 16) {
+ ind=index(con_ptr,',');
+ if (ind==NULL) {
+ ind=con_ptr+strlen(con_ptr);
+ last=-1;
+ }
+ strncpy((char *)connect[con_ports],con_ptr,ind-con_ptr);
+ strncpy((char *)connect[con_ports]+(ind-con_ptr),"\0",1);
+ //LOG_DEBUG1("Found port connect param: %s", connect[con_ports]);
+ con_ptr=ind+1;
+ con_ports++;
+ }
+ }
+
if ((s->client = jack_client_new(s->clientname)) == 0)
{
LOG_ERROR0("jack server not running");
@@ -316,7 +346,7 @@
/* create the ringbuffers; one per channel, figures may need tweaking */
rb_size = 2.0 * jack_get_sample_rate (s->client) * sizeof (jack_default_audio_sample_t);
// why was with again(??)
- /* rb_size = (size_t)((s->sleep / 2000.0) *
+ /* rb_size = (size_t)((s->sleep / 1000.0) *
jack_get_buffer_size(s->client) * sizeof(jack_default_audio_sample_t));
*/
LOG_DEBUG2("creating %d ringbuffers, one per channel, of "
@@ -349,7 +379,27 @@
sprintf(port_name, "in_%d", i+1);
s->jack_ports[i] = jack_port_register(s->client, port_name,
JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput,0);
- }
+
+ }
+
+ for (i = 0; i < con_ports ; i++)
+ {
+ int j=i%(s->channels);
+
+ if ((input_port=jack_port_by_name(s->client, connect[i])) == 0)
+ {
+ LOG_DEBUG1("Can't find port %s to connect to", connect[i]);
+ goto fail;
+ }
+ input_port_name=jack_port_name(input_port);
+ output_port_name=jack_port_name(s->jack_ports[j]);
+ if (jack_connect(s->client, input_port_name, output_port_name))
+ {
+ LOG_DEBUG1("Can't connect port: %s",connect[i]);
+ goto fail;
+ }
+ LOG_INFO2("Connected port: %s to %s",input_port_name,output_port_name);
+ }
s->newtrack = 1;
Modified: icecast/branches/kh/ices/src/im_jack.h
===================================================================
--- icecast/branches/kh/ices/src/im_jack.h 2004-11-08 17:41:00 UTC (rev 8182)
+++ icecast/branches/kh/ices/src/im_jack.h 2004-11-08 20:11:02 UTC (rev 8183)
@@ -44,7 +44,7 @@
int newtrack;
int user_terminated;
unsigned sleep;
-
+ const char *connect;
int jack_shutdown;
const char *clientname;
jack_client_t *client;
More information about the commits
mailing list