1 |
#!/usr/bin/python |
---|
2 |
# |
---|
3 |
# Copyright (C) 2005-2007 by Pieter Palmers |
---|
4 |
# |
---|
5 |
# This file is part of FFADO |
---|
6 |
# FFADO = Free Firewire (pro-)audio drivers for linux |
---|
7 |
# |
---|
8 |
# FFADO is based upon FreeBoB. |
---|
9 |
# |
---|
10 |
# This program is free software: you can redistribute it and/or modify |
---|
11 |
# it under the terms of the GNU General Public License as published by |
---|
12 |
# the Free Software Foundation, either version 3 of the License, or |
---|
13 |
# (at your option) any later version. |
---|
14 |
# |
---|
15 |
# This program is distributed in the hope that it will be useful, |
---|
16 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 |
# GNU General Public License for more details. |
---|
19 |
# |
---|
20 |
# You should have received a copy of the GNU General Public License |
---|
21 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
22 |
# |
---|
23 |
|
---|
24 |
import sys |
---|
25 |
# Add the path of the installed ffado-mixer-modules |
---|
26 |
sys.path.append( "$PYTHONDIR" ) |
---|
27 |
|
---|
28 |
import os |
---|
29 |
import time |
---|
30 |
import dbus |
---|
31 |
from qt import * |
---|
32 |
|
---|
33 |
from mixer_phase88 import * |
---|
34 |
from mixer_phase24 import * |
---|
35 |
from mixer_saffirepro import * |
---|
36 |
from mixer_saffire import * |
---|
37 |
from mixer_af2 import * |
---|
38 |
from mixer_bcoaudio5 import * |
---|
39 |
from mixer_edirolfa66 import * |
---|
40 |
|
---|
41 |
SupportedDevices=[ |
---|
42 |
[(0x000aac, 0x00000003),'Phase88Control'], |
---|
43 |
[(0x000aac, 0x00000004),'PhaseX24Control'], |
---|
44 |
[(0x000aac, 0x00000007),'PhaseX24Control'], |
---|
45 |
[(0x00130e, 0x00000003),'SaffireProMixer'], |
---|
46 |
[(0x00130e, 0x00000006),'SaffireProMixer'], |
---|
47 |
[(0x00130e, 0x00000000),'SaffireMixer'], |
---|
48 |
[(0x001486, 0x00000af2),'AudioFire2Mixer'], |
---|
49 |
[(0x0007f5, 0x00010049),'BCoAudio5Control'], |
---|
50 |
[(0x0040AB, 0x00010049),'EdirolFa66Control'], |
---|
51 |
] |
---|
52 |
|
---|
53 |
class ControlInterface: |
---|
54 |
def __init__(self, servername, basepath): |
---|
55 |
self.basepath=basepath |
---|
56 |
self.servername=servername |
---|
57 |
self.bus=dbus.SessionBus() |
---|
58 |
|
---|
59 |
def setContignuous(self, subpath, v): |
---|
60 |
try: |
---|
61 |
path = self.basepath + subpath |
---|
62 |
dev = self.bus.get_object(self.servername, path) |
---|
63 |
dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Continuous') |
---|
64 |
dev_cont.setValue(v) |
---|
65 |
except: |
---|
66 |
print "Failed to set Continuous %s on server %s" % (path, self.servername) |
---|
67 |
|
---|
68 |
def getContignuous(self, subpath): |
---|
69 |
try: |
---|
70 |
path = self.basepath + subpath |
---|
71 |
dev = self.bus.get_object(self.servername, path) |
---|
72 |
dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Continuous') |
---|
73 |
return dev_cont.getValue() |
---|
74 |
except: |
---|
75 |
print "Failed to get Continuous %s on server %s" % (path, self.servername) |
---|
76 |
return 0 |
---|
77 |
|
---|
78 |
def setDiscrete(self, subpath, v): |
---|
79 |
try: |
---|
80 |
path = self.basepath + subpath |
---|
81 |
dev = self.bus.get_object(self.servername, path) |
---|
82 |
dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Discrete') |
---|
83 |
dev_cont.setValue(v) |
---|
84 |
except: |
---|
85 |
print "Failed to set Discrete %s on server %s" % (path, self.servername) |
---|
86 |
|
---|
87 |
def getDiscrete(self, subpath): |
---|
88 |
try: |
---|
89 |
path = self.basepath + subpath |
---|
90 |
dev = self.bus.get_object(self.servername, path) |
---|
91 |
dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.Discrete') |
---|
92 |
return dev_cont.getValue() |
---|
93 |
except: |
---|
94 |
print "Failed to get Discrete %s on server %s" % (path, self.servername) |
---|
95 |
return 0 |
---|
96 |
|
---|
97 |
def setMatrixMixerValue(self, subpath, row, col, v): |
---|
98 |
try: |
---|
99 |
path = self.basepath + subpath |
---|
100 |
dev = self.bus.get_object(self.servername, path) |
---|
101 |
dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.MatrixMixer') |
---|
102 |
dev_cont.setValue(row, col, v) |
---|
103 |
except: |
---|
104 |
print "Failed to set MatrixMixer %s on server %s" % (path, self.servername) |
---|
105 |
|
---|
106 |
def getMatrixMixerValue(self, subpath, row, col): |
---|
107 |
try: |
---|
108 |
path = self.basepath + subpath |
---|
109 |
dev = self.bus.get_object(self.servername, path) |
---|
110 |
dev_cont = dbus.Interface(dev, dbus_interface='org.ffado.Control.Element.MatrixMixer') |
---|
111 |
return dev_cont.getValue(row, col) |
---|
112 |
except: |
---|
113 |
print "Failed to get MatrixMixer %s on server %s" % (path, self.servername) |
---|
114 |
return 0 |
---|
115 |
|
---|
116 |
class DeviceManagerInterface: |
---|
117 |
def __init__(self, servername, basepath): |
---|
118 |
self.basepath=basepath + '/DeviceManager' |
---|
119 |
self.servername=servername |
---|
120 |
self.bus=dbus.SessionBus() |
---|
121 |
self.dev = self.bus.get_object(self.servername, self.basepath) |
---|
122 |
self.iface = dbus.Interface(self.dev, dbus_interface='org.ffado.Control.Element.Container') |
---|
123 |
|
---|
124 |
def getNbDevices(self): |
---|
125 |
return self.iface.getNbElements() |
---|
126 |
def getDeviceName(self, idx): |
---|
127 |
return self.iface.getElementName(idx) |
---|
128 |
|
---|
129 |
class ConfigRomInterface: |
---|
130 |
def __init__(self, servername, devicepath): |
---|
131 |
self.basepath=devicepath + '/ConfigRom' |
---|
132 |
self.servername=servername |
---|
133 |
self.bus=dbus.SessionBus() |
---|
134 |
self.dev = self.bus.get_object(self.servername, self.basepath) |
---|
135 |
self.iface = dbus.Interface(self.dev, dbus_interface='org.ffado.Control.Element.ConfigRomX') |
---|
136 |
def getGUID(self): |
---|
137 |
return self.iface.getGUID() |
---|
138 |
def getVendorName(self): |
---|
139 |
return self.iface.getVendorName() |
---|
140 |
def getModelName(self): |
---|
141 |
return self.iface.getModelName() |
---|
142 |
def getVendorId(self): |
---|
143 |
return self.iface.getVendorId() |
---|
144 |
def getModelId(self): |
---|
145 |
return self.iface.getModelId() |
---|
146 |
|
---|
147 |
|
---|
148 |
if __name__ == "__main__": |
---|
149 |
|
---|
150 |
server='org.ffado.Control' |
---|
151 |
basepath='/org/ffado/Control' |
---|
152 |
|
---|
153 |
app = QApplication(sys.argv) |
---|
154 |
|
---|
155 |
msg = QMessageBox() |
---|
156 |
|
---|
157 |
repeat = 1 |
---|
158 |
while repeat > 0: |
---|
159 |
try: |
---|
160 |
devmgr=DeviceManagerInterface(server, basepath) |
---|
161 |
repeat -= 1 |
---|
162 |
except dbus.DBusException, ex: |
---|
163 |
print "\n" |
---|
164 |
print "===========================================================" |
---|
165 |
print "ERROR: Could not communicate with the FFADO DBus service..." |
---|
166 |
print "===========================================================" |
---|
167 |
print "\n" |
---|
168 |
tmp = msg.question( msg, "FFADO-DBus not found", "<qt><b>The connection to FFADOs DBus service could not be established.</b><p>Probably you didn't start the ffado-dbus-server. Should I try this now?</qt>", QMessageBox.Yes, QMessageBox.No ) |
---|
169 |
if tmp == 4: |
---|
170 |
sys.exit(-1) |
---|
171 |
else: |
---|
172 |
os.spawnlp( os.P_NOWAIT, "ffado-dbus-server" ) |
---|
173 |
time.sleep( 2.5 ) |
---|
174 |
|
---|
175 |
|
---|
176 |
nbDevices=devmgr.getNbDevices() |
---|
177 |
|
---|
178 |
forms=[]; |
---|
179 |
for idx in range(nbDevices): |
---|
180 |
path=devmgr.getDeviceName(idx) |
---|
181 |
print "Found device %d: %s" % (idx, path) |
---|
182 |
|
---|
183 |
cfgrom=ConfigRomInterface(server, basepath+'/DeviceManager/'+path) |
---|
184 |
vendorId=cfgrom.getVendorId() |
---|
185 |
modelId=cfgrom.getModelId() |
---|
186 |
|
---|
187 |
print "Found (%X, %X) %s %s" % (vendorId, modelId, cfgrom.getVendorName() , cfgrom.getModelName()) |
---|
188 |
|
---|
189 |
thisdev=(vendorId, modelId); |
---|
190 |
|
---|
191 |
for dev in SupportedDevices: |
---|
192 |
if dev[0]==thisdev: |
---|
193 |
print dev[1] |
---|
194 |
exec('forms.append('+dev[1]+'())') |
---|
195 |
forms[idx].hw=ControlInterface(server, basepath+'/DeviceManager/'+path) |
---|
196 |
forms[idx].initValues() |
---|
197 |
forms[idx].show() |
---|
198 |
app.setMainWidget(forms[idx]) |
---|
199 |
|
---|
200 |
if forms: |
---|
201 |
QObject.connect(app,SIGNAL("lastWindowClosed()"),app,SLOT("quit()")) |
---|
202 |
|
---|
203 |
app.exec_loop() |
---|
204 |
else: |
---|
205 |
print "No supported device found..." |
---|
206 |
msg.information( msg, "No mixer found", "Your device doesn't seem to have a supported mixer." ) |
---|