3 name_base
= 'org.gna.home.a2jmidid'
4 control_interface_name
= name_base
+ '.control'
5 service_name
= name_base
9 from traceback
import print_exc
14 if len(sys
.argv
) == 1:
15 print "Usage: %s [command] [command] ..." % os
.path
.basename(sys
.argv
[0])
17 print " exit - exit a2j bridge dbus service"
18 print " start - start bridging"
19 print " stop - stop brdiging"
20 print " status - get bridging status"
21 print " gjcn - get JACK client name"
22 print " ma2jp <client_id> <port_id> - map ALSA to JACK playback port"
23 print " ma2jc <client_id> <port_id> - map ALSA to JACK capture port"
24 print " mj2a <jack_port_name> - map JACK port to ALSA port"
25 print " ehw - enable export of hardware ports"
26 print " dhw - disable export of hardware ports"
29 bus
= dbus
.SessionBus()
31 controller
= bus
.get_object(service_name
, "/")
32 control_iface
= dbus
.Interface(controller
, control_interface_name
)
36 while index
< len(sys
.argv
):
51 if control_iface
.is_started():
52 print "Bridging enabled"
54 print "Bridging disabled"
56 print "--- get jack client name"
57 print control_iface
.get_jack_client_name()
59 print "--- map ALSA to JACK playback port"
60 if index
+ 1 >= len(sys
.argv
):
61 print "map ALSA to JACK playback port command requires ALSA client ID and ALSA port ID arguments"
63 client_id
= sys
.argv
[index
]
65 port_id
= sys
.argv
[index
]
68 print "'%s'" % control_iface
.map_alsa_to_jack_port(client_id
, port_id
, True)
70 print "--- map ALSA to JACK capture port"
71 if index
+ 1 >= len(sys
.argv
):
72 print "map ALSA to JACK capture port command requires ALSA client ID and ALSA port ID arguments"
74 client_id
= sys
.argv
[index
]
76 port_id
= sys
.argv
[index
]
79 print "'%s'" % control_iface
.map_alsa_to_jack_port(client_id
, port_id
, False)
81 print "--- map JACK to ALSA port"
82 if index
>= len(sys
.argv
):
83 print "map JACK to ALSA port command requires JACK port name argument"
85 jack_port
= sys
.argv
[index
]
88 out
= control_iface
.map_jack_port_to_alsa(jack_port
)
89 print "%u:%u ('%s':'%s')" % (int(out
[0]), int(out
[1]), str(out
[2]), str(out
[3]))
91 print "--- enable export of hardware ports"
92 control_iface
.set_hw_export(True)
94 print "--- disable export of hardware ports"
95 control_iface
.set_hw_export(False)
97 print "Unknown command '%s'" % arg
98 except dbus
.DBusException
, e
:
99 print "DBus exception: %s" % str(e
)
101 if __name__
== '__main__':