root/trunk/libffado/src/bebob/bebob_functionblock.h

Revision 1110, 8.6 kB (checked in by wagi, 14 years ago)

Lot's of small and big bug fixes allong the caching path.
There were several parts not correctly deserialized.

This should fix ticket #65

Line 
1 /*
2  * Copyright (C) 2005-2008 by Daniel Wagner
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 BEBOB_FUNCTION_BLOCK_H
25 #define BEBOB_FUNCTION_BLOCK_H
26
27 #include "bebob/bebob_avplug.h"
28
29 #include "libavc/avc_definitions.h"
30
31 #include "debugmodule/debugmodule.h"
32
33 namespace AVC {
34     class Subunit;
35 }
36
37 namespace BeBoB {
38
39 class FunctionBlock {
40 public:
41     enum EFunctionBlockType {
42         eFBT_AllFunctionBlockType   = 0xff,
43         eFBT_AudioSubunitSelector   = 0x80,
44         eFBT_AudioSubunitFeature    = 0x81,
45         eFBT_AudioSubunitProcessing = 0x82,
46         eFBT_AudioSubunitCodec      = 0x83,
47     };
48
49     enum ESpecialPurpose {
50         eSP_InputGain,
51         eSP_OutputVolume,
52         eSP_NoSpecialPurpose
53     };
54
55     FunctionBlock( AVC::Subunit& subunit,
56                    AVC::function_block_type_t type,
57                    AVC::function_block_type_t subtype,
58                    AVC::function_block_id_t id,
59                    ESpecialPurpose purpose,
60                    AVC::no_of_input_plugs_t nrOfInputPlugs,
61                    AVC::no_of_output_plugs_t nrOfOutputPlugs,
62                    int verbose );
63     FunctionBlock( const FunctionBlock& rhs );
64     FunctionBlock();
65     virtual ~FunctionBlock();
66
67     virtual bool discover();
68     virtual bool discoverConnections();
69
70     virtual const char* getName() = 0;
71
72     AVC::function_block_type_t getType() {return m_type;};
73     AVC::function_block_type_t getSubtype() {return m_subtype;};
74     AVC::function_block_id_t getId() {return m_id;};
75
76     AVC::no_of_input_plugs_t getNrOfInputPlugs() {return m_nrOfInputPlugs;};
77     AVC::no_of_output_plugs_t getNrOfOutputPlugs() {return m_nrOfOutputPlugs;};
78
79     bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;
80
81     static FunctionBlock* deserialize( Glib::ustring basePath,
82                                        Util::IODeserialize& deser,
83                                        AVC::Unit& unit,
84                                        AVC::Subunit& subunit );
85     bool deserializeUpdate( Glib::ustring basePath,
86                             Util::IODeserialize& deser );
87 protected:
88     bool discoverPlugs( AVC::Plug::EPlugDirection plugDirection,
89                         AVC::plug_id_t plugMaxId );
90
91 protected:
92     AVC::Subunit*      m_subunit;
93     AVC::function_block_type_t m_type;
94     AVC::function_block_type_t m_subtype;
95     AVC::function_block_id_t   m_id;
96     ESpecialPurpose       m_purpose;
97     AVC::no_of_input_plugs_t   m_nrOfInputPlugs;
98     AVC::no_of_output_plugs_t  m_nrOfOutputPlugs;
99     int                   m_verbose;
100     AVC::PlugVector          m_plugs;
101
102     DECLARE_DEBUG_MODULE;
103 };
104
105 typedef std::vector<FunctionBlock*> FunctionBlockVector;
106
107 /////////////////////////////////////
108 /////////////////////////////////////
109
110 class FunctionBlockSelector: public FunctionBlock
111 {
112 public:
113     FunctionBlockSelector(AVC::Subunit& subunit,
114                           AVC::function_block_id_t id,
115                           ESpecialPurpose purpose,
116                           AVC::no_of_input_plugs_t nrOfInputPlugs,
117                           AVC::no_of_output_plugs_t nrOfOutputPlugs,
118                           int verbose);
119     FunctionBlockSelector( const FunctionBlockSelector& rhs );
120     FunctionBlockSelector();
121     virtual ~FunctionBlockSelector();
122
123     virtual const char* getName();
124
125 protected:
126     virtual bool serializeChild( Glib::ustring basePath,
127                                  Util::IOSerialize& ser ) const;
128     virtual bool deserializeChild( Glib::ustring basePath,
129                                    Util::IODeserialize& deser,
130                                    AvDevice& avDevice );
131 };
132
133 /////////////////////////////////////
134
135 class FunctionBlockFeature: public FunctionBlock
136 {
137 public:
138     FunctionBlockFeature(AVC::Subunit& subunit,
139                          AVC::function_block_id_t id,
140                          ESpecialPurpose purpose,
141                          AVC::no_of_input_plugs_t nrOfInputPlugs,
142                          AVC::no_of_output_plugs_t nrOfOutputPlugs,
143                          int verbose);
144     FunctionBlockFeature( const FunctionBlockFeature& rhs );
145     FunctionBlockFeature();
146     virtual ~FunctionBlockFeature();
147
148     virtual const char* getName();
149
150     // FIXME: this is not pretty!
151     enum EControlSelectorEncoding {
152         eCSE_Feature_Unknown            = 0x00,
153         eCSE_Feature_Mute               = 0x01,
154         eCSE_Feature_Volume             = 0x02,
155         eCSE_Feature_LRBalance          = 0x03,
156         eCSE_Feature_FRBalance          = 0x04,
157         eCSE_Feature_Bass               = 0x05,
158         eCSE_Feature_Mid                = 0x06,
159         eCSE_Feature_Treble             = 0x07,
160         eCSE_Feature_GEQ                = 0x08,
161         eCSE_Feature_AGC                = 0x09,
162         eCSE_Feature_Delay              = 0x0a,
163         eCSE_Feature_BassBoost          = 0x0b,
164         eCSE_Feature_Loudness           = 0x0c,
165     };
166
167 protected:
168     virtual bool serializeChild( Glib::ustring basePath,
169                                  Util::IOSerialize& ser ) const;
170     virtual bool deserializeChild( Glib::ustring basePath,
171                                    Util::IODeserialize& deser,
172                                    AvDevice& avDevice );
173 };
174
175 /////////////////////////////////////
176
177 class FunctionBlockEnhancedMixer: public FunctionBlock
178 {
179 public:
180     FunctionBlockEnhancedMixer( AVC::Subunit& subunit,
181                                 AVC::function_block_id_t id,
182                                 ESpecialPurpose purpose,
183                                 AVC::no_of_input_plugs_t nrOfInputPlugs,
184                                 AVC::no_of_output_plugs_t nrOfOutputPlugs,
185                                 int verbose );
186     FunctionBlockEnhancedMixer();
187     FunctionBlockEnhancedMixer( const FunctionBlockEnhancedMixer& rhs );
188     virtual ~FunctionBlockEnhancedMixer();
189
190     virtual bool discover();
191
192     virtual const char* getName();
193
194 protected:
195     virtual bool serializeChild( Glib::ustring basePath,
196                                  Util::IOSerialize& ser ) const;
197     virtual bool deserializeChild( Glib::ustring basePath,
198                                    Util::IODeserialize& deser,
199                                    AvDevice& avDevice );
200 };
201
202 /////////////////////////////////////
203
204 class FunctionBlockProcessing: public FunctionBlock
205 {
206 public:
207     FunctionBlockProcessing( AVC::Subunit& subunit,
208                              AVC::function_block_id_t id,
209                              ESpecialPurpose purpose,
210                              AVC::no_of_input_plugs_t nrOfInputPlugs,
211                              AVC::no_of_output_plugs_t nrOfOutputPlugs,
212                              int verbose );
213     FunctionBlockProcessing( const FunctionBlockProcessing& rhs );
214     FunctionBlockProcessing();
215     virtual ~FunctionBlockProcessing();
216
217     virtual const char* getName();
218
219 protected:
220     virtual bool serializeChild( Glib::ustring basePath,
221                                  Util::IOSerialize& ser ) const;
222     virtual bool deserializeChild( Glib::ustring basePath,
223                                    Util::IODeserialize& deser,
224                                    AvDevice& avDevice );
225 };
226
227 /////////////////////////////////////
228
229 class FunctionBlockCodec: public FunctionBlock
230 {
231 public:
232     FunctionBlockCodec(AVC::Subunit& subunit,
233                        AVC::function_block_id_t id,
234                        ESpecialPurpose purpose,
235                        AVC::no_of_input_plugs_t nrOfInputPlugs,
236                        AVC::no_of_output_plugs_t nrOfOutputPlugs,
237                        int verbose);
238     FunctionBlockCodec( const FunctionBlockCodec& rhs );
239     FunctionBlockCodec();
240     virtual ~FunctionBlockCodec();
241
242     virtual const char* getName();
243
244 protected:
245     virtual bool serializeChild( Glib::ustring basePath,
246                                  Util::IOSerialize& ser ) const;
247     virtual bool deserializeChild( Glib::ustring basePath,
248                                    Util::IODeserialize& deser,
249                                    AvDevice& avDevice );
250 };
251
252 }
253
254 #endif
Note: See TracBrowser for help on using the browser.