Now that dmix is working well, I felt like trying something new. :) This patch changes the JACK plugin to use a unique client name, which allows for multiple ALSA streams to share a JACK server.
Unfortunately, as reported earlier, some apps hang with the JACK plugin, and some even fail, e.g. ogg123: pcm_plug.c:884: snd_pcm_plug_hw_params: Assertion `err >= 0' failed. I can provide output from pcm_params.c built with RULES_DEBUG defined if that's useful. -- Earthling Michel DÃnzer | Debian (powerpc), X and DRI developer Libre software enthusiast | http://svcs.affero.net/rm.php?r=daenzer
Index: src/pcm/ext/pcm_jack.c =================================================================== RCS file: /cvsroot/alsa/alsa-lib/src/pcm/ext/pcm_jack.c,v retrieving revision 1.4 diff -p -u -r1.4 pcm_jack.c --- src/pcm/ext/pcm_jack.c 28 Oct 2003 18:19:09 -0000 1.4 +++ src/pcm/ext/pcm_jack.c 4 Feb 2004 19:18:07 -0000 @@ -697,6 +697,8 @@ int snd_pcm_jack_open(snd_pcm_t **pcmp, snd_pcm_jack_t *jack; int err; int fd[2]; + static unsigned int num = 0; + char jack_client_name[32]; assert(pcmp); #ifdef PCM_JACK_DEBUG @@ -723,17 +725,24 @@ int snd_pcm_jack_open(snd_pcm_t **pcmp, if (stream == SND_PCM_STREAM_PLAYBACK) { jack->channels = jack->playback_ports_n; - jack->client = jack_client_new("alsaP"); } else { jack->channels = jack->capture_ports_n; - jack->client = jack_client_new("alsaC"); } if (jack->channels == 0) { SNDERR("define the %s_ports section\n", stream == SND_PCM_STREAM_PLAYBACK ? "playback" : "capture"); goto _free; } + + if (snprintf(jack_client_name, sizeof(jack_client_name), "alsa%s.%d.%d", + stream == SND_PCM_STREAM_PLAYBACK ? "P" : "C", getpid(), num++) + >= sizeof(jack_client_name)) { + fprintf(stderr, "%s: WARNING: JACK client name '%s' truncated to %d characters, might not be unique\n", + __func__, jack_client_name, strlen(jack_client_name)); + } + + jack->client = jack_client_new(jack_client_name); if (jack->client==0) { err = -ENOENT;