1 |
/* bebob_functionblock.cpp |
---|
2 |
* Copyright (C) 2006,07 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 |
int 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 |
setDebugLevel( verbose ); |
---|
47 |
} |
---|
48 |
|
---|
49 |
FunctionBlock::FunctionBlock( const FunctionBlock& rhs ) |
---|
50 |
: m_subunit( rhs.m_subunit ) |
---|
51 |
, m_type( rhs.m_type ) |
---|
52 |
, m_id( rhs.m_id ) |
---|
53 |
, m_purpose( rhs.m_purpose ) |
---|
54 |
, m_nrOfInputPlugs( rhs.m_nrOfInputPlugs ) |
---|
55 |
, m_nrOfOutputPlugs( rhs.m_nrOfOutputPlugs ) |
---|
56 |
, m_verbose( rhs.m_verbose ) |
---|
57 |
{ |
---|
58 |
} |
---|
59 |
|
---|
60 |
FunctionBlock::~FunctionBlock() |
---|
61 |
{ |
---|
62 |
for ( AvPlugVector::iterator it = m_plugs.begin(); |
---|
63 |
it != m_plugs.end(); |
---|
64 |
++it ) |
---|
65 |
{ |
---|
66 |
delete *it; |
---|
67 |
} |
---|
68 |
|
---|
69 |
} |
---|
70 |
|
---|
71 |
bool |
---|
72 |
FunctionBlock::discover() |
---|
73 |
{ |
---|
74 |
debugOutput( DEBUG_LEVEL_VERBOSE, |
---|
75 |
"discover function block %s (nr of input plugs = %d, " |
---|
76 |
"nr of output plugs = %d)\n", |
---|
77 |
getName(), |
---|
78 |
m_nrOfInputPlugs, |
---|
79 |
m_nrOfOutputPlugs ); |
---|
80 |
|
---|
81 |
if ( !discoverPlugs( AvPlug::eAPD_Input, m_nrOfInputPlugs ) ) { |
---|
82 |
debugError( "Could not discover input plug for '%s'\n", |
---|
83 |
getName() ); |
---|
84 |
return false; |
---|
85 |
} |
---|
86 |
|
---|
87 |
if ( !discoverPlugs( AvPlug::eAPD_Output, m_nrOfOutputPlugs ) ) { |
---|
88 |
debugError( "Could not discover output plugs for '%s'\n", |
---|
89 |
getName() ); |
---|
90 |
return false; |
---|
91 |
} |
---|
92 |
|
---|
93 |
return true; |
---|
94 |
} |
---|
95 |
|
---|
96 |
bool |
---|
97 |
FunctionBlock::discoverPlugs( AvPlug::EAvPlugDirection plugDirection, |
---|
98 |
plug_id_t plugMaxId ) |
---|
99 |
{ |
---|
100 |
for ( int plugId = 0; plugId < plugMaxId; ++plugId ) { |
---|
101 |
AvPlug* plug = new AvPlug( |
---|
102 |
*( m_subunit->getAvDevice().get1394Service() ), |
---|
103 |
m_subunit->getAvDevice().getConfigRom(), |
---|
104 |
m_subunit->getAvDevice().getPlugManager(), |
---|
105 |
m_subunit->getSubunitType(), |
---|
106 |
m_subunit->getSubunitId(), |
---|
107 |
m_type, |
---|
108 |
m_id, |
---|
109 |
AvPlug::eAPA_FunctionBlockPlug, |
---|
110 |
plugDirection, |
---|
111 |
plugId, |
---|
112 |
m_verbose ); |
---|
113 |
|
---|
114 |
if ( !plug || !plug->discover() ) { |
---|
115 |
debugError( "plug discovering failed for plug %d\n", |
---|
116 |
plugId ); |
---|
117 |
delete plug; |
---|
118 |
return false; |
---|
119 |
} |
---|
120 |
|
---|
121 |
debugOutput( DEBUG_LEVEL_NORMAL, "plug '%s' found\n", |
---|
122 |
plug->getName() ); |
---|
123 |
m_plugs.push_back( plug ); |
---|
124 |
} |
---|
125 |
|
---|
126 |
return true; |
---|
127 |
} |
---|
128 |
|
---|
129 |
bool |
---|
130 |
FunctionBlock::discoverConnections() |
---|
131 |
{ |
---|
132 |
debugOutput( DEBUG_LEVEL_VERBOSE, |
---|
133 |
"discover connections function block %s\n", |
---|
134 |
getName() ); |
---|
135 |
|
---|
136 |
for ( AvPlugVector::iterator it = m_plugs.begin(); |
---|
137 |
it != m_plugs.end(); |
---|
138 |
++it ) |
---|
139 |
{ |
---|
140 |
AvPlug* plug = *it; |
---|
141 |
if ( !plug->discoverConnections() ) { |
---|
142 |
debugError( "Could not discover plug connections\n" ); |
---|
143 |
return false; |
---|
144 |
} |
---|
145 |
} |
---|
146 |
return true; |
---|
147 |
} |
---|
148 |
|
---|
149 |
/////////////////////// |
---|
150 |
|
---|
151 |
FunctionBlockSelector::FunctionBlockSelector( |
---|
152 |
AvDeviceSubunit& subunit, |
---|
153 |
function_block_id_t id, |
---|
154 |
ESpecialPurpose purpose, |
---|
155 |
no_of_input_plugs_t nrOfInputPlugs, |
---|
156 |
no_of_output_plugs_t nrOfOutputPlugs, |
---|
157 |
int verbose ) |
---|
158 |
: FunctionBlock( subunit, |
---|
159 |
eFBT_AudioSubunitSelector, |
---|
160 |
id, |
---|
161 |
purpose, |
---|
162 |
nrOfInputPlugs, |
---|
163 |
nrOfOutputPlugs, |
---|
164 |
verbose ) |
---|
165 |
{ |
---|
166 |
} |
---|
167 |
|
---|
168 |
FunctionBlockSelector::FunctionBlockSelector( |
---|
169 |
const FunctionBlockSelector& rhs ) |
---|
170 |
: FunctionBlock( rhs ) |
---|
171 |
{ |
---|
172 |
} |
---|
173 |
|
---|
174 |
FunctionBlockSelector::~FunctionBlockSelector() |
---|
175 |
{ |
---|
176 |
} |
---|
177 |
|
---|
178 |
const char* |
---|
179 |
FunctionBlockSelector::getName() |
---|
180 |
{ |
---|
181 |
return "Selector"; |
---|
182 |
} |
---|
183 |
|
---|
184 |
/////////////////////// |
---|
185 |
|
---|
186 |
FunctionBlockFeature::FunctionBlockFeature( |
---|
187 |
AvDeviceSubunit& subunit, |
---|
188 |
function_block_id_t id, |
---|
189 |
ESpecialPurpose purpose, |
---|
190 |
no_of_input_plugs_t nrOfInputPlugs, |
---|
191 |
no_of_output_plugs_t nrOfOutputPlugs, |
---|
192 |
int verbose ) |
---|
193 |
: FunctionBlock( subunit, |
---|
194 |
eFBT_AudioSubunitFeature, |
---|
195 |
id, |
---|
196 |
purpose, |
---|
197 |
nrOfInputPlugs, |
---|
198 |
nrOfOutputPlugs, |
---|
199 |
verbose ) |
---|
200 |
{ |
---|
201 |
} |
---|
202 |
|
---|
203 |
FunctionBlockFeature::FunctionBlockFeature( |
---|
204 |
const FunctionBlockFeature& rhs ) |
---|
205 |
: FunctionBlock( rhs ) |
---|
206 |
{ |
---|
207 |
} |
---|
208 |
|
---|
209 |
FunctionBlockFeature::~FunctionBlockFeature() |
---|
210 |
{ |
---|
211 |
} |
---|
212 |
|
---|
213 |
const char* |
---|
214 |
FunctionBlockFeature::getName() |
---|
215 |
{ |
---|
216 |
return "Feature"; |
---|
217 |
} |
---|
218 |
|
---|
219 |
/////////////////////// |
---|
220 |
|
---|
221 |
FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer( |
---|
222 |
AvDeviceSubunit& subunit, |
---|
223 |
function_block_id_t id, |
---|
224 |
ESpecialPurpose purpose, |
---|
225 |
no_of_input_plugs_t nrOfInputPlugs, |
---|
226 |
no_of_output_plugs_t nrOfOutputPlugs, |
---|
227 |
int verbose ) |
---|
228 |
: FunctionBlock( subunit, |
---|
229 |
eFBT_AudioSubunitProcessing, |
---|
230 |
id, |
---|
231 |
purpose, |
---|
232 |
nrOfInputPlugs, |
---|
233 |
nrOfOutputPlugs, |
---|
234 |
verbose ) |
---|
235 |
{ |
---|
236 |
} |
---|
237 |
|
---|
238 |
FunctionBlockEnhancedMixer::FunctionBlockEnhancedMixer( |
---|
239 |
const FunctionBlockEnhancedMixer& rhs ) |
---|
240 |
: FunctionBlock( rhs ) |
---|
241 |
{ |
---|
242 |
} |
---|
243 |
|
---|
244 |
FunctionBlockEnhancedMixer::~FunctionBlockEnhancedMixer() |
---|
245 |
{ |
---|
246 |
} |
---|
247 |
|
---|
248 |
const char* |
---|
249 |
FunctionBlockEnhancedMixer::getName() |
---|
250 |
{ |
---|
251 |
return "EnhancedMixer"; |
---|
252 |
} |
---|
253 |
|
---|
254 |
/////////////////////// |
---|
255 |
|
---|
256 |
FunctionBlockProcessing::FunctionBlockProcessing( |
---|
257 |
AvDeviceSubunit& subunit, |
---|
258 |
function_block_id_t id, |
---|
259 |
ESpecialPurpose purpose, |
---|
260 |
no_of_input_plugs_t nrOfInputPlugs, |
---|
261 |
no_of_output_plugs_t nrOfOutputPlugs, |
---|
262 |
int verbose ) |
---|
263 |
: FunctionBlock( subunit, |
---|
264 |
eFBT_AudioSubunitProcessing, |
---|
265 |
id, |
---|
266 |
purpose, |
---|
267 |
nrOfInputPlugs, |
---|
268 |
nrOfOutputPlugs, |
---|
269 |
verbose ) |
---|
270 |
{ |
---|
271 |
} |
---|
272 |
|
---|
273 |
FunctionBlockProcessing::FunctionBlockProcessing( |
---|
274 |
const FunctionBlockProcessing& rhs ) |
---|
275 |
: FunctionBlock( rhs ) |
---|
276 |
{ |
---|
277 |
} |
---|
278 |
|
---|
279 |
FunctionBlockProcessing::~FunctionBlockProcessing() |
---|
280 |
{ |
---|
281 |
} |
---|
282 |
|
---|
283 |
const char* |
---|
284 |
FunctionBlockProcessing::getName() |
---|
285 |
{ |
---|
286 |
return "Dummy Processing"; |
---|
287 |
} |
---|
288 |
|
---|
289 |
/////////////////////// |
---|
290 |
|
---|
291 |
FunctionBlockCodec::FunctionBlockCodec( |
---|
292 |
AvDeviceSubunit& subunit, |
---|
293 |
function_block_id_t id, |
---|
294 |
ESpecialPurpose purpose, |
---|
295 |
no_of_input_plugs_t nrOfInputPlugs, |
---|
296 |
no_of_output_plugs_t nrOfOutputPlugs, |
---|
297 |
int verbose ) |
---|
298 |
: FunctionBlock( subunit, |
---|
299 |
eFBT_AudioSubunitCodec, |
---|
300 |
id, |
---|
301 |
purpose, |
---|
302 |
nrOfInputPlugs, |
---|
303 |
nrOfOutputPlugs, |
---|
304 |
verbose ) |
---|
305 |
{ |
---|
306 |
} |
---|
307 |
|
---|
308 |
FunctionBlockCodec::FunctionBlockCodec( const FunctionBlockCodec& rhs ) |
---|
309 |
: FunctionBlock( rhs ) |
---|
310 |
{ |
---|
311 |
} |
---|
312 |
|
---|
313 |
FunctionBlockCodec::~FunctionBlockCodec() |
---|
314 |
{ |
---|
315 |
} |
---|
316 |
|
---|
317 |
const char* |
---|
318 |
FunctionBlockCodec::getName() |
---|
319 |
{ |
---|
320 |
return "Dummy Codec"; |
---|
321 |
} |
---|
322 |
|
---|
323 |
} |
---|