File: test-echo-routing.py

package info (click to toggle)
libffado 2.4.9-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,604 kB
  • sloc: cpp: 77,151; python: 8,997; ansic: 2,951; sh: 1,429; xml: 855; makefile: 29
file content (78 lines) | stat: -rw-r--r-- 2,024 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/python

'''
This test is for checking playback-routing of devices based on Echo Fireworks.
Only two devices support this function, AudioFire2 and AudioFire4.

 AudioFire2:
	Playback stream ch1/2, 3/4, 5/6 can be assigned to analog out ch1/2,
	headphone out ch1/2, and digital out ch1/2.
	
 AudioFire4:
	Playback stream ch1/2, 3/4, 5/6 can be assigned to analog out ch1/2,
	3/4 and digital out ch1/2.

 Usage:
	To set routing, give two arguments below.

	Hardware port id as a first argument.
	id	AudioFire2		AudioFire4
	0	Analog out ch1/2	Analog out ch1/2
	1	Headphone out ch1/2	Analog out ch4/4
	2	Digital out ch1/2	Digital out ch1/2

	Playback stream id as a second argument
	0	Stream out ch1/2
	1	Stream out ch3/4
	2	Stream out ch5/6 (shown as digital out)

	Give no arguments, current state is printed.
'''

import sys
import dbus

GUID = "0014860f5a616e83" # for AudioFire4
#GUID = "001486069D5BD6CA" # for AudioFire2

servername = "org.ffado.Control"
path = "/org/ffado/Control/DeviceManager/%s/" % GUID
bus = dbus.SessionBus()

# connect to ffado-dbus-server to ask hardware information
try:
	hwinfo = dbus.Interface(bus.get_object(servername, path + 'HwInfo/PlaybackRouting'),
				dbus_interface='org.ffado.Control.Element.Discrete')
except:
	print( "'ffado-dbus-server' should be started in advance." )
	sys.exit()

# ask the device supports playback-routing
try:
	if(not hwinfo.getValue()):
		raise Exception()
except:
	print( "Your device doesn't support playback-routing." )
	sys.exit()

router = dbus.Interface(bus.get_object(servername, path + "PlaybackRouting"),
                        dbus_interface='org.ffado.Control.Element.Discrete')

argvs = sys.argv
argc = len(argvs)

# set status
if (argc == 3):
	port = int(argvs[1])
	strm = int(argvs[2])
	if ((port > 2) or (strm > 2)):
		print( 'arguments should be less than 3.' )
		sys.exit()
	s = router.setValueIdx(port, strm);
	print( s )
# get status
else:
	print( "port\tstream" )
	for i in range(3):
		print( i, "\t", router.getValueIdx(i); )