[LAD] Tiny mplayer patch

Fons Adriaensen fons at kokkinizita.net
Fri Apr 25 22:54:07 UTC 2008


The attached small patch provides somewhat more flexible
jack connections for mplayer, e.g.

mplayer -ao jack:dest=ardour:port="Audio 2" 

willl make mplayer connect to the inputs of track "Audio 2".

You can also connect to e.g. system:playback_3,4 if you
set an alias for them first.

When used without 'dest', 'port' behaves as before i.e.
it selects an application. But the obvious way to do this
now is to use 'dest' of course.

Not a perfect solution but it helps.

Ciao,

-- 
FA

Laboratorio di Acustica ed Elettroacustica
Parma, Italia

Lascia la spina, cogli la rosa.

-------------- next part --------------
--- libao2/ao_jack.c.orig	2007-10-07 21:49:27.000000000 +0200
+++ libao2/ao_jack.c	2008-04-26 00:26:55.000000000 +0200
@@ -207,11 +207,15 @@
 {
   mp_msg (MSGT_AO, MSGL_FATAL,
            "\n-ao jack commandline help:\n"
-           "Example: mplayer -ao jack:port=myout\n"
-           "  connects MPlayer to the jack ports named myout\n"
+           "Example: mplayer -ao jack:dest=myapp\n"
+           "  connects MPlayer to the first ports of 'myapp'\n"
+           "Example: mplayer -ao jack:dest=myapp:port=input\n"
+           "  connects MPlayer to the ports named 'input' of 'myapp'\n"
            "\nOptions:\n"
-           "  port=<port name>\n"
-           "    Connects to the given ports instead of the default physical ones\n"
+           "  dest=<destination name>\n"
+           "    Connects to the named destination instead of the sound card\n"
+           "  port=<port name prefix>\n"
+           "    Connects only ports with names starting with the given prefix\n"
            "  name=<client name>\n"
            "    Client name to pass to JACK\n"
            "  estimate\n"
@@ -220,9 +224,12 @@
 
 static int init(int rate, int channels, int format, int flags) {
   const char **matching_ports = NULL;
+  char *dest_name = NULL;
   char *port_name = NULL;
+  char patt [256];
   char *client_name = NULL;
   opt_t subopts[] = {
+    {"dest", OPT_ARG_MSTRZ, &dest_name, NULL},
     {"port", OPT_ARG_MSTRZ, &port_name, NULL},
     {"name", OPT_ARG_MSTRZ, &client_name, NULL},
     {"estimate", OPT_ARG_BOOL, &estimate, NULL},
@@ -252,9 +259,20 @@
   jack_set_process_callback(client, outputaudio, 0);
 
   // list matching ports
-  if (!port_name)
-    port_flags |= JackPortIsPhysical;
-  matching_ports = jack_get_ports(client, port_name, NULL, port_flags);
+  if (dest_name && port_name) {
+      sprintf (patt, "%s:%s", dest_name, port_name);
+  }
+  else if (dest_name) {
+      strcpy (patt, dest_name);
+  }
+  else if (port_name) {
+      strcpy (patt, port_name);
+  }
+  else {
+      port_flags |= JackPortIsPhysical;
+      *patt = 0;
+  }
+  matching_ports = jack_get_ports(client, patt, JACK_DEFAULT_AUDIO_TYPE, port_flags);
   for (num_ports = 0; matching_ports && matching_ports[num_ports]; num_ports++) ;
   if (!num_ports) {
     mp_msg(MSGT_AO, MSGL_FATAL, "[JACK] no physical ports available\n");


More information about the Linux-audio-dev mailing list