root/trunk/libffado/support/mixer-qt4/ffado/mixer/profire2626.py

Revision 2670, 3.7 kB (checked in by jwoithe, 7 years ago)

Add the "-b" / "--bypassdbus" command line option to ffado-mixer. If given,
no communication with ffado-dbus-server will be attempted. Instead, an
instance of each supported mixer module will be created with stubs providing
placeholder values in place of values obtained from hardware. This permits
rudimentary debugging of mixer modules for interfaces which the developer
does not have on hand.

This commit amounts to a minor rework of a patch originally submitted by
Xavier Forestier as part of a large series which is being slowly merged:

https://sourceforge.net/p/ffado/mailman/message/35457569/.

The most significant difference is that the bypassdbus functionality in
Xavier's patch was a compile option whereas the commit implements it as a
runtime option. It is felt that this will make things easier for developers
in the long run: mixer modules can be tested without having to reconfigure
ffado from source. Minor bug fixes were applied to the patch as it was
reworked.

Thanks to Xavier Forestier for the original patch.

Line 
1 #
2 # Copyright (C) 2009-2010 by Arnold Krille
3 #
4 # This file is part of FFADO
5 # FFADO = Free Firewire (pro-)audio drivers for linux
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 2 of the License, or
10 # (at your option) version 3 of the License.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20
21 from PyQt4 import QtGui, QtCore, Qt
22 from PyQt4.QtGui import QWidget, QScrollArea
23 import dbus
24
25 import ffado.config
26 from ffado.widgets.matrixmixer import MatrixMixer
27 from ffado.widgets.crossbarrouter import *
28 from ffado.mixer.generic_dice_eap import *
29
30 from ffado.config import *
31
32 class BooleanControl:
33     def __init__(self, hw, path):
34         if ffado.config.bypassdbus:
35             self.value = False
36             return
37         self.iface = dbus.Interface(
38                 hw.bus.get_object(hw.servername, path),
39                 dbus_interface="org.ffado.Control.Element.Boolean")
40         self.value = self.iface.selected()
41
42     def selected(self):
43         return self.value
44
45     def select(self, n):
46         if self.iface.select(n):
47             self.value = n
48             return True
49         return False
50
51 class DiscreteControl:
52     def __init__(self, hw, path):
53         if ffado.config.bypassdbus:
54             self.value = 0
55             return
56         self.iface = dbus.Interface(
57                 hw.bus.get_object(hw.servername, path),
58                 dbus_interface="org.ffado.Control.Element.Discrete")
59         self.value = self.iface.getValue()
60
61     def getvalue(self):
62         return self.value
63
64     def setvalue(self, v):
65         if v != self.value:
66             self.iface.setValue(v)
67             self.value = v
68
69 class Profire2626(Generic_Dice_EAP):
70     def __init__(self, parent=None):
71         Generic_Dice_EAP.__init__(self, parent)
72
73     def buildMixer(self):
74         #print self.hw
75         #print self.hw.getText("/Generic/Nickname")
76         Generic_Dice_EAP.buildMixer(self)
77
78         widget = QWidget()
79         uicLoad("ffado/mixer/profire2626_settings.ui", widget)
80
81         # Add Settings to ffado-mixer panels
82         scrollarea = QScrollArea(self.tabs)
83         scrollarea.setWidgetResizable(False)
84         scrollarea.setWidget(widget)
85         self.tabs.addTab(scrollarea, "Settings")
86
87         # Master volume knob
88         from collections import namedtuple
89         LineInfo = namedtuple('LineInfo', ['widget','Interface'])
90
91         # Volume Unactivating
92         self.LineUnActivates = []
93         p = LineInfo(widget.line1line2, BooleanControl(self.hw, self.hw.basepath+"/EAP/Settings/VolumeKnob/Line1Line2"))
94         self.LineUnActivates.append(p)
95         p = LineInfo(widget.line3line4, BooleanControl(self.hw, self.hw.basepath+"/EAP/Settings/VolumeKnob/Line3Line4"))
96         self.LineUnActivates.append(p)
97         p = LineInfo(widget.line5line6, BooleanControl(self.hw, self.hw.basepath+"/EAP/Settings/VolumeKnob/Line5Line6"))
98         self.LineUnActivates.append(p)
99         p = LineInfo(widget.line7line8, BooleanControl(self.hw, self.hw.basepath+"/EAP/Settings/VolumeKnob/Line7Line8"))
100         self.LineUnActivates.append(p)
101
102         for l in self.LineUnActivates:
103             l.widget.setChecked(l.Interface.selected())
104             l.widget.toggled.connect(l.Interface.select)
105
106     def getDisplayTitle(self):
107         return "M-Audio Profire 2626 Mixer"
108
109 #
110 # vim: et ts=4 sw=4
Note: See TracBrowser for help on using the browser.