root/trunk/libfreebob/src/bebob/bebob_functionblock.cpp

Revision 241, 7.8 kB (checked in by pieterpalmers, 18 years ago)

* configure.ac: Version bump to 1.0.0

* Changed all FreeBob? to FreeBoB
* Removed all .cvsignore
* Added Pieter to AUTHORS
* Updated NEWS and README (release canditate date added)

by Daniel Wagner

Line 
1 /* bebob_functionblock.cpp
2  * Copyright (C) 2006 by Daniel Wagner
3  *
4  * This file is part of FreeBoB.
5  *
6  * FreeBoB is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * FreeBoB is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with FreeBoB; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18  * MA 02111-1307 USA.
19  */
20
21 #include "bebob/bebob_functionblock.h"
22 #include "bebob/bebob_avdevice_subunit.h"
23 #include "bebob/bebob_avdevice.h"
24 #include "configrom.h"
25
26 namespace BeBoB {
27
28 IMPL_DEBUG_MODULE( FunctionBlock, FunctionBlock, DEBUG_LEVEL_NORMAL );
29
30 FunctionBlock::FunctionBlock(
31     AvDeviceSubunit& subunit,
32     function_block_type_t type,
33     function_block_id_t id,
34     ESpecialPurpose purpose,
35     no_of_input_plugs_t nrOfInputPlugs,
36     no_of_output_plugs_t nrOfOutputPlugs,
37     bool verbose )
38     : m_subunit( &subunit )
39     , m_type( type )
40     , m_id( id )
41     , m_purpose( purpose )
42     , m_nrOfInputPlugs( nrOfInputPlugs )
43     , m_nrOfOutputPlugs( nrOfOutputPlugs )
44     , m_verbose( verbose )
45 {
46     if ( m_verbose ) {
47         setDebugLevel( DEBUG_LEVEL_VERBOSE );
48     }
49 }
50
51 FunctionBlock::FunctionBlock( const FunctionBlock& rhs )
52     : m_subunit( rhs.m_subunit )
53     , m_type( rhs.m_type )
54     , m_id( rhs.m_id )
55     , m_purpose( rhs.m_purpose )
56     , m_nrOfInputPlugs( rhs.m_nrOfInputPlugs )
57     , m_nrOfOutputPlugs( rhs.m_nrOfOutputPlugs )
58     , m_verbose( rhs.m_verbose )
59 {
60 }
61
62 FunctionBlock::~FunctionBlock()
63 {
64     for ( AvPlugVector::iterator it = m_plugs.begin();
65           it != m_plugs.end();
66           ++it )
67     {
68         delete *it;
69     }
70
71 }
72
73 bool
74 FunctionBlock::discover()
75 {
76     debugOutput( DEBUG_LEVEL_VERBOSE,
77                  "discover function block %s (nr of input plugs = %d, "
78                  "nr of output plugs = %d)\n",
79                  getName(),
80                  m_nrOfInputPlugs,
81                  m_nrOfOutputPlugs );
82
83     if ( !discoverPlugs( AvPlug::eAPD_Input, m_nrOfInputPlugs ) ) {
84         debugError( "Could not discover input plug for '%s'\n",
85                     getName() );
86         return false;
87     }
88
89     if ( !discoverPlugs( AvPlug::eAPD_Output, m_nrOfOutputPlugs ) ) {
90         debugError( "Could not discover output plugs for '%s'\n",
91                     getName() );
92         return false;
93     }
94
95     return true;
96 }
97
98 bool
99 FunctionBlock::discoverPlugs( AvPlug::EAvPlugDirection plugDirection,
100                               plug_id_t plugMaxId )
101 {
102     for ( int plugId = 0; plugId < plugMaxId; ++plugId ) {
103         AvPlug* plug = new AvPlug(
104             *( m_subunit->getAvDevice().get1394Service() ),
105             m_subunit->getAvDevice().getConfigRom().getNodeId(),
106             m_subunit->getAvDevice().getPlugManager(),
107             m_subunit->getSubunitType(),
108             m_subunit->getSubunitId(),
109             m_type,
110             m_id,
111             AvPlug::eAPA_FunctionBlockPlug,
112             plugDirection,
113             plugId,
114             m_verbose );
115
116         if ( !plug || !plug->discover() ) {
117             debugError( "plug discovering failed for plug %d\n",
118                         plugId );
119             delete plug;
120             return false;
121         }
122
123         debugOutput( DEBUG_LEVEL_NORMAL, "plug '%s' found\n",
124                      plug->getName() );
125         m_plugs.push_back( plug );
126     }
127
128     return true;
129 }
130
131 bool
132 FunctionBlock::discoverConnections()
133 {
134     debugOutput( DEBUG_LEVEL_VERBOSE,
135                  "discover connections function block %s\n",
136                  getName() );
137
138     for ( AvPlugVector::iterator it = m_plugs.begin();
139           it != m_plugs.end();
140           ++it )
141     {
142         AvPlug* plug = *it;
143         if ( !plug->discoverConnections() ) {
144             debugError( "Could not discover plug connections\n" );
145             return false;
146         }
147     }
148     return true;
149 }
150
151 ///////////////////////
152
153 FunctionBlockSelector::FunctionBlockSelector(
154     AvDeviceSubunit& subunit,
155     function_block_id_t id,
156     ESpecialPurpose purpose,
157     no_of_input_plugs_t nrOfInputPlugs,
158     no_of_output_plugs_t nrOfOutputPlugs,
159     bool verbose )
160     : FunctionBlock( subunit,
161                      eFBT_AudioSubunitSelector,
162                      id,
163                      purpose,
164                      nrOfInputPlugs,
165                      nrOfOutputPlugs,
166                      verbose )
167 {
168 }
169
170 FunctionBlockSelector::FunctionBlockSelector(
171     const FunctionBlockSelector& rhs )
172     : FunctionBlock( rhs )
173 {
174 }
175
176 FunctionBlockSelector::~FunctionBlockSelector()
177 {
178 }
179
180 const char*
181 FunctionBlockSelector::getName()
182 {
183     return "Selector";
184 }
185
186 ///////////////////////
187
188 FunctionBlockFeature::FunctionBlockFeature(
189     AvDeviceSubunit& subunit,
190     function_block_id_t id,
191     ESpecialPurpose purpose,
192     no_of_input_plugs_t nrOfInputPlugs,
193     no_of_output_plugs_t nrOfOutputPlugs,
194     bool verbose )
195     : FunctionBlock( subunit,
196                      eFBT_AudioSubunitFeature,
197                      id,
198                      purpose,
199                      nrOfInputPlugs,
200                      nrOfOutputPlugs,
201                      verbose )
202 {
203 }
204
205 FunctionBlockFeature::FunctionBlockFeature(
206     const FunctionBlockFeature& rhs )
207     : FunctionBlock( rhs )
208 {
209 }
210
211 FunctionBlockFeature::~FunctionBlockFeature()
212 {
213 }
214
215 const char*
216 FunctionBlockFeature::getName()
217 {
218     return "Feature";
219 }
220
221 ///////////////////////
222
223 FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer(
224     AvDeviceSubunit& subunit,
225     function_block_id_t id,
226     ESpecialPurpose purpose,
227     no_of_input_plugs_t nrOfInputPlugs,
228     no_of_output_plugs_t nrOfOutputPlugs,
229     bool verbose )
230     : FunctionBlock( subunit,
231                      eFBT_AudioSubunitProcessing,
232                      id,
233                      purpose,
234                      nrOfInputPlugs,
235                      nrOfOutputPlugs,
236                      verbose )
237 {
238 }
239
240 FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer(
241     const FunctionBlockEnhancedMixer& rhs )
242     : FunctionBlock( rhs )
243 {
244 }
245
246 FunctionBlockEnhancedMixer::~FunctionBlockEnhancedMixer()
247 {
248 }
249
250 const char*
251 FunctionBlockEnhancedMixer::getName()
252 {
253     return "EnhancedMixer";
254 }
255
256 ///////////////////////
257
258 FunctionBlockProcessing::FunctionBlockProcessing(
259     AvDeviceSubunit& subunit,
260     function_block_id_t id,
261     ESpecialPurpose purpose,
262     no_of_input_plugs_t nrOfInputPlugs,
263     no_of_output_plugs_t nrOfOutputPlugs,
264     bool verbose )
265     : FunctionBlock( subunit,
266                      eFBT_AudioSubunitProcessing,
267                      id,
268                      purpose,
269                      nrOfInputPlugs,
270                      nrOfOutputPlugs,
271                      verbose )
272 {
273 }
274
275 FunctionBlockProcessing::FunctionBlockProcessing(
276     const FunctionBlockProcessing& rhs )
277     : FunctionBlock( rhs )
278 {
279 }
280
281 FunctionBlockProcessing::~FunctionBlockProcessing()
282 {
283 }
284
285 const char*
286 FunctionBlockProcessing::getName()
287 {
288     return "Dummy Processing";
289 }
290
291 ///////////////////////
292
293 FunctionBlockCodec::FunctionBlockCodec(
294     AvDeviceSubunit& subunit,
295     function_block_id_t id,
296     ESpecialPurpose purpose,
297     no_of_input_plugs_t nrOfInputPlugs,
298     no_of_output_plugs_t nrOfOutputPlugs,
299     bool verbose )
300     : FunctionBlock( subunit,
301                      eFBT_AudioSubunitCodec,
302                      id,
303                      purpose,
304                      nrOfInputPlugs,
305                      nrOfOutputPlugs,
306                      verbose )
307 {
308 }
309
310 FunctionBlockCodec::FunctionBlockCodec( const FunctionBlockCodec& rhs )
311     : FunctionBlock( rhs )
312 {
313 }
314
315 FunctionBlockCodec::~FunctionBlockCodec()
316 {
317 }
318
319 const char*
320 FunctionBlockCodec::getName()
321 {
322     return "Dummy Codec";
323 }
324
325 }
Note: See TracBrowser for help on using the browser.