root/trunk/libffado/support/dbus/controlserver.h

Revision 1173, 7.5 kB (checked in by ppalmers, 16 years ago)

Fix issue with the AV/C function blocks not being set correctly. Fix clocksource selection bug. Expose control of verbose level through DBUS

Line 
1 /*
2  * Copyright (C) 2005-2008 by Pieter Palmers
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 2 of the License, or
12  * (at your option) version 3 of the License.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #ifndef CONTROLSERVER_H
25 #define CONTROLSERVER_H
26
27 #include "debugmodule/debugmodule.h"
28
29 #include <dbus-c++/dbus.h>
30
31 #include "controlserver-glue.h"
32
33 #include "libcontrol/BasicElements.h"
34 #include "libieee1394/configrom.h"
35 #include "libutil/Mutex.h"
36
37 namespace Control {
38     class MatrixMixer;
39 };
40
41 namespace DBusControl {
42
43 class Element;
44 class Container;
45
46 template< typename CalleePtr, typename MemFunPtr >
47 class MemberSignalFunctor
48     : public Control::SignalFunctor
49 {
50 public:
51     MemberSignalFunctor( const CalleePtr& pCallee,
52             MemFunPtr pMemFun,
53             int pSignalId)
54         : Control::SignalFunctor( pSignalId )
55         , m_pCallee( pCallee )
56         , m_pMemFun( pMemFun )
57         {}
58
59     virtual ~MemberSignalFunctor()
60         {}
61
62     virtual void operator() (int value)
63         {
64             ( ( *m_pCallee ).*m_pMemFun )(value);
65         }
66 private:
67     CalleePtr  m_pCallee;
68     MemFunPtr  m_pMemFun;
69 };
70
71 class Element
72 : public org::ffado::Control::Element::Element
73 , public DBus::IntrospectableAdaptor
74 , public DBus::ObjectAdaptor
75 {
76 friend class Container; // This should not be necessary since Container derives from Element
77 public:
78
79     Element( DBus::Connection& connection,
80              std::string p, Element *,
81              Control::Element &slave );
82
83     DBus::UInt64 getId( );
84     DBus::String getName( );
85     DBus::String getLabel( );
86     DBus::String getDescription( );
87
88     void setVerboseLevel( const DBus::Int32 &);
89     DBus::Int32 getVerboseLevel();
90
91 protected:
92     void Lock();
93     void Unlock();
94     Util::Mutex* getLock();
95
96     Element *           m_Parent;
97     Control::Element &  m_Slave;
98 private:
99     Util::Mutex*        m_UpdateLock;
100 protected:
101     DECLARE_DEBUG_MODULE;
102 };
103 typedef std::vector<Element *> ElementVector;
104 typedef std::vector<Element *>::iterator ElementVectorIterator;
105 typedef std::vector<Element *>::const_iterator ConstElementVectorIterator;
106
107 class Container
108 : public org::ffado::Control::Element::Container
109 , public Element
110 {
111 public:
112     Container( DBus::Connection& connection,
113                   std::string p, Element *,
114                   Control::Container &slave );
115     virtual ~Container();
116
117     DBus::Int32 getNbElements( );
118     DBus::String getElementName( const DBus::Int32& );
119
120     void updated(int new_nb_elements);
121     void setVerboseLevel( const DBus::Int32 &);
122 private:
123     Element *createHandler(Element *, Control::Element& e);
124     void updateTree();
125     Element * findElementForControl(Control::Element *e);
126     void removeElement(Element *e);
127
128     Control::Container &        m_Slave;
129     ElementVector               m_Children;
130     Control::SignalFunctor *    m_updateFunctor;
131 };
132
133 class Continuous
134 : public org::ffado::Control::Element::Continuous
135 , public Element
136 {
137 public:
138     Continuous( DBus::Connection& connection,
139                   std::string p, Element *,
140                   Control::Continuous &slave );
141    
142     DBus::Double setValue( const DBus::Double & value );
143     DBus::Double getValue( );
144     DBus::Double getMinimum( );
145     DBus::Double getMaximum( );
146     DBus::Double setValueIdx( const DBus::Int32 & idx,
147                               const DBus::Double & value );
148     DBus::Double getValueIdx( const DBus::Int32 & idx );
149
150 private:
151     Control::Continuous &m_Slave;
152 };
153
154 class Discrete
155 : public org::ffado::Control::Element::Discrete
156 , public Element
157 {
158 public:
159     Discrete( DBus::Connection& connection,
160               std::string p, Element *,
161               Control::Discrete &slave );
162    
163     DBus::Int32 setValue( const DBus::Int32 & value );
164     DBus::Int32 getValue( );
165     DBus::Int32 setValueIdx( const DBus::Int32 & idx,
166                              const DBus::Int32 & value );
167     DBus::Int32 getValueIdx( const DBus::Int32 & idx );
168
169 private:
170     Control::Discrete &m_Slave;
171 };
172
173 class Text
174 : public org::ffado::Control::Element::Text
175 , public Element
176 {
177 public:
178     Text( DBus::Connection& connection,
179           std::string p, Element *,
180           Control::Text &slave );
181
182     DBus::String setValue( const DBus::String & value );
183     DBus::String getValue( );
184
185 private:
186     Control::Text &m_Slave;
187 };
188
189 class Register
190 : public org::ffado::Control::Element::Register
191 , public Element
192 {
193 public:
194     Register( DBus::Connection& connection,
195               std::string p, Element *,
196               Control::Register &slave );
197    
198     DBus::UInt64 setValue( const DBus::UInt64 & addr, const DBus::UInt64 & value );
199     DBus::UInt64 getValue( const DBus::UInt64 & addr );
200
201 private:
202     Control::Register &m_Slave;
203 };
204
205 class Enum
206 : public org::ffado::Control::Element::Enum
207 , public Element
208 {
209 public:
210     Enum( DBus::Connection& connection,
211           std::string p, Element *,
212           Control::Enum &slave );
213    
214     DBus::Int32 select( const DBus::Int32 & idx );
215     DBus::Int32 selected( );
216     DBus::Int32 count( );
217     DBus::String getEnumLabel( const DBus::Int32 & idx );
218
219 private:
220     Control::Enum &m_Slave;
221 };
222
223 class AttributeEnum
224 : public org::ffado::Control::Element::AttributeEnum
225 , public Element
226 {
227 public:
228     AttributeEnum( DBus::Connection& connection,
229                    std::string p, Element *,
230                    Control::AttributeEnum &slave );
231    
232     DBus::Int32 select( const DBus::Int32 & idx );
233     DBus::Int32 selected( );
234     DBus::Int32 count( );
235     DBus::Int32 attributeCount();
236     DBus::String getEnumLabel( const DBus::Int32 & idx );
237     DBus::String getAttributeValue( const DBus::Int32 & idx );
238     DBus::String getAttributeName( const DBus::Int32 & idx );
239
240 private:
241     Control::AttributeEnum &m_Slave;
242 };
243
244 // FIXME: to change this to a normal ConfigRom class name we have to
245 // put the 1394 config rom class into a separate namespace.
246 class ConfigRomX
247 : public org::ffado::Control::Element::ConfigRomX
248 , public Element
249 {
250 public:
251     ConfigRomX( DBus::Connection& connection,
252                   std::string p, Element *,
253                   ConfigRom &slave );
254
255     DBus::String getGUID( );
256     DBus::String getVendorName( );
257     DBus::String getModelName( );
258     DBus::Int32 getVendorId( );
259     DBus::Int32 getModelId( );
260     DBus::Int32 getUnitVersion( );
261
262 private:
263     ConfigRom &m_Slave;
264 };
265
266 class MatrixMixer
267 : public org::ffado::Control::Element::MatrixMixer
268 , public Element
269 {
270 public:
271     MatrixMixer(  DBus::Connection& connection,
272                   std::string p, Element *,
273                   Control::MatrixMixer &slave );
274
275     DBus::String getRowName( const DBus::Int32& );
276     DBus::String getColName( const DBus::Int32& );
277     DBus::Int32 canWrite( const DBus::Int32&, const DBus::Int32& );
278     DBus::Double setValue( const DBus::Int32&, const DBus::Int32&, const DBus::Double& );
279     DBus::Double getValue( const DBus::Int32&, const DBus::Int32& );
280     DBus::Int32 getRowCount( );
281     DBus::Int32 getColCount( );
282
283 private:
284     Control::MatrixMixer &m_Slave;
285 };
286
287 }
288
289 #endif // CONTROLSERVER_H
Note: See TracBrowser for help on using the browser.