Comment 6 for bug 1908832

Revision history for this message
Christian Schoenebeck (schoenebeck) wrote :

c->opt->connect_ports is an optional user supplied configuration argument which allows the user to specify a regular expression pattern which is used by QEMU's JACK audio driver to automatically connect its JACK ports to. From qapi/audio.json:

##
# @AudiodevJackPerDirectionOptions:
#
# Options of the JACK backend that are used for both playback and
# recording.
#
# @server-name: select from among several possible concurrent server instances
# (default: environment variable $JACK_DEFAULT_SERVER if set, else "default")
#
# @client-name: the client name to use. The server will modify this name to
# create a unique variant, if needed unless @exact-name is true (default: the
# guest's name)
#
# @connect-ports: if set, a regular expression of JACK client port name(s) to
# monitor for and automatically connect to
#
# @start-server: start a jack server process if one is not already present
# (default: false)
#
# @exact-name: use the exact name requested otherwise JACK automatically
# generates a unique one, if needed (default: false)
#
# Since: 5.1
##
{ 'struct': 'AudiodevJackPerDirectionOptions',
  'base': 'AudiodevPerDirectionOptions',
  'data': {
    '*server-name': 'str',
    '*client-name': 'str',
    '*connect-ports': 'str',
    '*start-server': 'bool',
    '*exact-name': 'bool' } }

I agree with you that it would be more user friendly to auto connect QEMU's output ports to system:playback_1, system:playback_2 and QEMU's input ports to system:capture_1, system:capture_2 respectively if the user did not specify any argument for "connect-ports".

However I think your patch is a bit too simple, i.e. it is more or less luck that the system ports end up as the first two members in the lookup array "ports". It is working right now, but there is no guarantee about the order of the ports returned by jack_get_ports():

https://jackaudio.org/api/group__PortSearching.html

So I would suggest changing your patch a bit by passing a lookup pattern like "system:playback_.*" to jack_get_ports() for QEMU output ports and a pattern like "system:capture_.*" for QEMU input ports, if c->opt->connect_ports is empty that is.

Would you try to send a patch like this? And if yes, would you mind sending your patch directly to the qemu-devel mailing list? That would allow us to merge your patch more efficiently & quickly.

https://wiki.qemu.org/Contribute/SubmitAPatch