root/trunk/libffado/src/libavc/audiosubunit/avc_function_block.cpp

Revision 2102, 21.7 kB (checked in by jwoithe, 12 years ago)

Remove some unused variables. They become unused in r2090.

Line 
1 /*
2  * Copyright (C) 2005-2008 by Daniel Wagner
3  * Copyright (C) 2005-2008 by Pieter Palmers
4  *
5  * This file is part of FFADO
6  * FFADO = Free Firewire (pro-)audio drivers for linux
7  *
8  * FFADO is based upon FreeBoB
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 2 of the License, or
13  * (at your option) version 3 of the License.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24
25 #include "avc_function_block.h"
26 #include "libutil/cmd_serialize.h"
27 #include "libieee1394/ieee1394service.h"
28
29 #include <cstdio>
30
31 namespace AVC {
32
33
34 /////////////////////////////////
35
36 FunctionBlockFeatureVolume::FunctionBlockFeatureVolume()
37     : IBusData()
38     , m_controlDataLength( 2 )
39     , m_volume( 0 )
40 {
41 }
42
43 FunctionBlockFeatureVolume::FunctionBlockFeatureVolume( const FunctionBlockFeatureVolume& rhs )
44     : m_controlDataLength( rhs.m_controlDataLength )
45     , m_volume( rhs.m_volume )
46 {
47 }
48
49 FunctionBlockFeatureVolume::~FunctionBlockFeatureVolume()
50 {
51 }
52
53 bool
54 FunctionBlockFeatureVolume::serialize( Util::Cmd::IOSSerialize& se )
55 {
56     bool bStatus;
57     byte_t val;
58     bStatus = se.write( m_controlDataLength,  "FunctionBlockFeatureVolume controlDataLength" );
59     val = (byte_t)(m_volume >> 8);
60     bStatus &= se.write( val,                  "FunctionBlockFeatureVolume volume high" );
61     val = m_volume & 0xff;
62     bStatus &= se.write( val,                  "FunctionBlockFeatureVolume volume low" );
63
64     return bStatus;
65 }
66
67 bool
68 FunctionBlockFeatureVolume::deserialize( Util::Cmd::IISDeserialize& de )
69 {
70     bool bStatus;
71     byte_t val;
72     bStatus = de.read( &m_controlDataLength );
73     bStatus &= de.read( &val );
74     m_volume = val << 8;
75     bStatus &= de.read( &val );
76     m_volume |= val;
77
78     return bStatus;
79 }
80
81 FunctionBlockFeatureVolume*
82 FunctionBlockFeatureVolume::clone() const
83 {
84     return new FunctionBlockFeatureVolume( *this );
85 }
86
87 /////////////////////////////////
88
89 FunctionBlockFeatureLRBalance::FunctionBlockFeatureLRBalance()
90     : IBusData()
91     , m_controlDataLength( 2 )
92     , m_lrBalance( 0 )
93 {
94 }
95
96 FunctionBlockFeatureLRBalance::FunctionBlockFeatureLRBalance( const FunctionBlockFeatureLRBalance& rhs )
97     : m_controlDataLength( rhs.m_controlDataLength )
98     , m_lrBalance( rhs.m_lrBalance )
99 {
100 }
101
102 FunctionBlockFeatureLRBalance::~FunctionBlockFeatureLRBalance()
103 {
104 }
105
106 bool
107 FunctionBlockFeatureLRBalance::serialize( Util::Cmd::IOSSerialize& se )
108 {
109     bool bStatus;
110     byte_t val;
111     bStatus = se.write( m_controlDataLength,  "FunctionBlockFeatureLRBalance controlDataLength" );
112     val = (byte_t)(m_lrBalance >> 8);
113     bStatus &= se.write( val,                 "FunctionBlockFeatureLRBalance LR Balance high" );
114     val = m_lrBalance & 0xff;
115     bStatus &= se.write( val,                 "FunctionBlockFeatureLRBalance LR Balance low" );
116
117     return bStatus;
118 }
119
120 bool
121 FunctionBlockFeatureLRBalance::deserialize( Util::Cmd::IISDeserialize& de )
122 {
123     bool bStatus;
124     byte_t val;
125     bStatus = de.read( &m_controlDataLength );
126     bStatus &= de.read( &val );
127     m_lrBalance = val << 8;
128     bStatus &= de.read( &val );
129     m_lrBalance |= val;
130
131     return bStatus;
132 }
133
134 FunctionBlockFeatureLRBalance*
135 FunctionBlockFeatureLRBalance::clone() const
136 {
137     return new FunctionBlockFeatureLRBalance( *this );
138 }
139
140 /////////////////////////////////
141
142 FunctionBlockProcessingMixer::FunctionBlockProcessingMixer()
143     : IBusData()
144     , m_controlSelector( FunctionBlockProcessing::eCSE_Processing_Mixer )
145 {
146 }
147
148 FunctionBlockProcessingMixer::FunctionBlockProcessingMixer( const FunctionBlockProcessingMixer& rhs )
149     : m_controlSelector( rhs.m_controlSelector )
150 {
151 }
152
153 FunctionBlockProcessingMixer::~FunctionBlockProcessingMixer()
154 {
155 }
156
157 bool
158 FunctionBlockProcessingMixer::serialize( Util::Cmd::IOSSerialize& se )
159 {
160     bool bStatus;
161     bStatus = se.write( m_controlSelector,    "FunctionBlockProcessingMixer controlSelector" );
162
163     return bStatus;
164 }
165
166 bool
167 FunctionBlockProcessingMixer::deserialize( Util::Cmd::IISDeserialize& de )
168 {
169     bool bStatus;
170     bStatus = de.read( &m_controlSelector );
171
172     return bStatus;
173 }
174
175 FunctionBlockProcessingMixer*
176 FunctionBlockProcessingMixer::clone() const
177 {
178     return new FunctionBlockProcessingMixer( *this );
179 }
180
181 /////////////////////////////////
182
183 FunctionBlockProcessingEnhancedMixer::FunctionBlockProcessingEnhancedMixer()
184     : IBusData()
185     , m_controlSelector( FunctionBlockProcessing::eCSE_Processing_EnhancedMixer )
186     , m_statusSelector( eSS_Level )
187     , m_controlDataLength( 0 )
188 {
189 }
190
191 FunctionBlockProcessingEnhancedMixer::FunctionBlockProcessingEnhancedMixer(
192     const FunctionBlockProcessingEnhancedMixer& rhs )
193     : m_controlSelector( rhs.m_controlSelector )
194     , m_statusSelector( rhs.m_statusSelector )
195 {
196 }
197
198 FunctionBlockProcessingEnhancedMixer::~FunctionBlockProcessingEnhancedMixer()
199 {
200 }
201
202 bool
203 FunctionBlockProcessingEnhancedMixer::serialize( Util::Cmd::IOSSerialize& se )
204 {
205     bool bStatus;
206     byte_t data_length_hi, data_length_lo;
207    
208     bStatus  = se.write( m_controlSelector, "FunctionBlockProcessingEnhancedMixer controlSelector" );
209     bStatus &= se.write( m_statusSelector,  "FunctionBlockProcessingEnhancedMixer statusSelector" );
210    
211     switch (m_statusSelector) {
212         case eSS_ProgramableState:
213                 m_controlDataLength=m_ProgramableStateData.size()/8;
214             data_length_hi=(m_controlDataLength >> 8);
215             data_length_lo=(m_controlDataLength & 0xFF);
216             bStatus &= se.write( data_length_hi,  "FunctionBlockProcessingEnhancedMixer controlDataLengthHi" );
217             bStatus &= se.write( data_length_lo,  "FunctionBlockProcessingEnhancedMixer controlDataLengthLo" );
218
219             for (int i=0;i<m_controlDataLength;i++) {
220                 byte_t value=0;
221                
222                 for (int j=0;j<8;j++) {
223                     control_data_ext_length_t bit_value=m_ProgramableStateData.at(i*8+j);
224                     value |= bit_value << (7-j);
225                 }
226                
227                 bStatus &= se.write( value,  "FunctionBlockProcessingEnhancedMixer data" );
228             }
229             break;
230         case eSS_Level:
231             m_controlDataLength=m_LevelData.size()*2;
232             data_length_hi=(m_controlDataLength >> 8);
233             data_length_lo=(m_controlDataLength & 0xFF);
234             bStatus &= se.write( data_length_hi,  "FunctionBlockProcessingEnhancedMixer controlDataLengthHi" );
235             bStatus &= se.write( data_length_lo,  "FunctionBlockProcessingEnhancedMixer controlDataLengthLo" );
236
237             for (int i=0;i<m_controlDataLength/2;i++) {
238                 mixer_level_t value=m_LevelData.at(i);
239                 byte_t value_hi=value >> 8;
240                 byte_t value_lo=value & 0xFF;
241                
242                 bStatus &= se.write( value_hi,  "FunctionBlockProcessingEnhancedMixer data" );
243                 bStatus &= se.write( value_lo,  "FunctionBlockProcessingEnhancedMixer data" );
244             }
245             break;
246     }
247     return bStatus;
248 }
249
250 bool
251 FunctionBlockProcessingEnhancedMixer::deserialize( Util::Cmd::IISDeserialize& de )
252 {
253     bool bStatus;
254     bStatus  = de.read( &m_controlSelector );
255
256     // NOTE: the returned value is currently bogus, so overwrite it
257     m_controlSelector=FunctionBlockProcessing::eCSE_Processing_EnhancedMixer;
258
259     bStatus &= de.read( &m_statusSelector );
260
261     // same here
262     m_statusSelector = eSS_Level;
263     //m_statusSelector = eSS_ProgramableState;
264
265     byte_t data_length_hi;
266     byte_t data_length_lo;
267     bStatus &= de.read( &data_length_hi );
268     bStatus &= de.read( &data_length_lo );
269
270     m_controlDataLength = (data_length_hi << 8) + data_length_lo;
271     printf("m_controlDataLength = %d\n", m_controlDataLength);
272     switch (m_statusSelector) {
273         case eSS_ProgramableState:
274             m_ProgramableStateData.clear();
275             for (int i=0;i<m_controlDataLength;i++) {
276                 byte_t value;
277                 bStatus &= de.read( &value);
278
279                 for (int j=7;j>=0;j--) {
280                     byte_t bit_value;
281                     bit_value=(((1<<j) & value) ? 1 : 0);
282                     m_ProgramableStateData.push_back(bit_value);
283                 }
284             }
285             break;
286         case eSS_Level:
287             m_LevelData.clear();
288             for (int i = 0; i < m_controlDataLength/2; i++) {
289                 byte_t mixer_value_hi = 0;
290                 byte_t mixer_value_lo = 0;
291                 bStatus &= de.read( &mixer_value_hi);
292                 bStatus &= de.read( &mixer_value_lo);
293
294                 mixer_level_t value = (mixer_value_hi << 8) + mixer_value_lo;
295
296                 printf("value = %x\n", value);
297                 m_LevelData.push_back(value);
298             }
299             break;
300     }
301
302     return bStatus;
303 }
304
305 FunctionBlockProcessingEnhancedMixer*
306 FunctionBlockProcessingEnhancedMixer::clone() const
307 {
308     return new FunctionBlockProcessingEnhancedMixer( *this );
309 }
310
311
312 /////////////////////////////////
313 /////////////////////////////////
314
315 FunctionBlockSelector::FunctionBlockSelector()
316     : IBusData()
317     , m_selectorLength( 0x02 )
318     , m_inputFbPlugNumber( 0x00 )
319     , m_controlSelector( eCSE_Selector_Selector )
320 {
321 }
322
323 FunctionBlockSelector::FunctionBlockSelector( const FunctionBlockSelector& rhs )
324     : IBusData()
325     , m_selectorLength( rhs.m_selectorLength )
326     , m_inputFbPlugNumber( rhs.m_inputFbPlugNumber )
327     , m_controlSelector( rhs.m_controlSelector )
328 {
329 }
330
331 FunctionBlockSelector::~FunctionBlockSelector()
332 {
333 }
334
335 bool
336 FunctionBlockSelector::serialize( Util::Cmd::IOSSerialize& se )
337 {
338     bool bStatus;
339     bStatus  = se.write( m_selectorLength,    "FunctionBlockSelector selectorLength" );
340     bStatus &= se.write( m_inputFbPlugNumber, "FunctionBlockSelector inputFbPlugNumber" );
341     bStatus &= se.write( m_controlSelector,   "FunctionBlockSelector controlSelector" );
342
343     return bStatus;
344 }
345
346 bool
347 FunctionBlockSelector::deserialize( Util::Cmd::IISDeserialize& de )
348 {
349     bool bStatus;
350     bStatus  = de.read( &m_selectorLength );
351     bStatus &= de.read( &m_inputFbPlugNumber );
352     bStatus &= de.read( &m_controlSelector );
353
354     return bStatus;
355 }
356
357 FunctionBlockSelector*
358 FunctionBlockSelector::clone() const
359 {
360     return new FunctionBlockSelector( *this );
361 }
362
363 /////////////////////////////////
364
365 FunctionBlockFeature::FunctionBlockFeature()
366     : IBusData()
367     , m_selectorLength( 0x02 )
368     , m_audioChannelNumber( 0x00 )
369     , m_controlSelector( eCSE_Feature_Unknown )
370     , m_pVolume( 0 )
371     , m_pLRBalance( 0 )
372 {
373 }
374
375 FunctionBlockFeature::FunctionBlockFeature( const FunctionBlockFeature& rhs )
376     : IBusData()
377     , m_selectorLength( rhs.m_selectorLength )
378     , m_audioChannelNumber( rhs.m_audioChannelNumber )
379     , m_controlSelector( rhs.m_controlSelector )
380 {
381     if ( rhs.m_pVolume ) {
382         m_pVolume = new FunctionBlockFeatureVolume( *rhs.m_pVolume );
383     } else if ( rhs.m_pLRBalance ) {
384         m_pLRBalance = new FunctionBlockFeatureLRBalance( *rhs.m_pLRBalance );
385     }
386 }
387
388 FunctionBlockFeature::~FunctionBlockFeature()
389 {
390     delete m_pVolume;
391     m_pVolume = 0;
392     delete m_pLRBalance;
393     m_pLRBalance = 0;
394 }
395
396 bool
397 FunctionBlockFeature::serialize( Util::Cmd::IOSSerialize& se )
398 {
399     bool bStatus;
400     bStatus  = se.write( m_selectorLength,     "FunctionBlockFeature selectorLength" );
401     bStatus &= se.write( m_audioChannelNumber, "FunctionBlockFeature audioChannelNumber" );
402     bStatus &= se.write( m_controlSelector,    "FunctionBlockFeature controlSelector" );
403
404     switch( m_controlSelector ) {
405     case eCSE_Feature_Volume:
406         bStatus &= m_pVolume->serialize( se );
407         break;
408     case eCSE_Feature_LRBalance:
409         bStatus &= m_pLRBalance->serialize( se );
410         break;
411     case eCSE_Feature_Mute:
412     case eCSE_Feature_FRBalance:
413     case eCSE_Feature_Bass:
414     case eCSE_Feature_Mid:
415     case eCSE_Feature_Treble:
416     case eCSE_Feature_GEQ:
417     case eCSE_Feature_AGC:
418     case eCSE_Feature_Delay:
419     case eCSE_Feature_BassBoost:
420     case eCSE_Feature_Loudness:
421     default:
422         bStatus = false;
423     }
424
425     return bStatus;
426 }
427
428 bool
429 FunctionBlockFeature::deserialize( Util::Cmd::IISDeserialize& de )
430 {
431     bool bStatus;
432     bStatus  = de.read( &m_selectorLength );
433     bStatus &= de.read( &m_audioChannelNumber );
434     bStatus &= de.read( &m_controlSelector );
435
436     switch( m_controlSelector ) {
437     case eCSE_Feature_Volume:
438         bStatus &= m_pVolume->deserialize( de );
439         break;
440     case eCSE_Feature_LRBalance:
441         bStatus &= m_pLRBalance->deserialize( de );
442         break;
443     case eCSE_Feature_Mute:
444     case eCSE_Feature_FRBalance:
445     case eCSE_Feature_Bass:
446     case eCSE_Feature_Mid:
447     case eCSE_Feature_Treble:
448     case eCSE_Feature_GEQ:
449     case eCSE_Feature_AGC:
450     case eCSE_Feature_Delay:
451     case eCSE_Feature_BassBoost:
452     case eCSE_Feature_Loudness:
453     default:
454         bStatus = false;
455     }
456
457     return bStatus;
458 }
459
460 FunctionBlockFeature*
461 FunctionBlockFeature::clone() const
462 {
463     return new FunctionBlockFeature( *this );
464 }
465
466 /////////////////////////////////
467
468 FunctionBlockProcessing::FunctionBlockProcessing()
469     : IBusData()
470     , m_selectorLength( 0x04 )
471     , m_fbInputPlugNumber( 0x00 )
472     , m_inputAudioChannelNumber( 0x00 )
473     , m_outputAudioChannelNumber( 0x00 )
474     , m_pMixer( 0 )
475     , m_pEnhancedMixer( 0 )
476 {
477 }
478
479 FunctionBlockProcessing::FunctionBlockProcessing( const FunctionBlockProcessing& rhs )
480     : m_selectorLength( rhs.m_selectorLength )
481     , m_fbInputPlugNumber( rhs.m_fbInputPlugNumber )
482     , m_inputAudioChannelNumber( rhs.m_inputAudioChannelNumber )
483     , m_outputAudioChannelNumber( rhs.m_outputAudioChannelNumber )
484 {
485     if ( rhs.m_pMixer ) {
486         m_pMixer = new FunctionBlockProcessingMixer( *rhs.m_pMixer );
487     } else if ( rhs.m_pEnhancedMixer ) {
488         m_pEnhancedMixer = new FunctionBlockProcessingEnhancedMixer( *rhs.m_pEnhancedMixer );
489     }
490 }
491
492 FunctionBlockProcessing::~FunctionBlockProcessing()
493 {
494     delete m_pMixer;
495     m_pMixer = 0;
496     delete m_pEnhancedMixer;
497     m_pEnhancedMixer = 0;
498 }
499
500 bool
501 FunctionBlockProcessing::serialize( Util::Cmd::IOSSerialize& se )
502 {
503     bool bStatus;
504     bStatus  = se.write( m_selectorLength,     "FunctionBlockProcessing selectorLength" );
505     bStatus &= se.write( m_fbInputPlugNumber,  "FunctionBlockProcessing fbInputPlugNumber" );
506     bStatus &= se.write( m_inputAudioChannelNumber,  "FunctionBlockProcessing inputAudioChannelNumber" );
507     bStatus &= se.write( m_outputAudioChannelNumber, "FunctionBlockProcessing outputAudioChannelNumber" );
508
509     if ( m_pMixer ) {
510         bStatus &= m_pMixer->serialize( se );
511     } else if ( m_pEnhancedMixer ) {
512         bStatus &= m_pEnhancedMixer->serialize( se );
513     } else {
514         bStatus = false;
515     }
516
517     return bStatus;
518 }
519
520 bool
521 FunctionBlockProcessing::deserialize( Util::Cmd::IISDeserialize& de )
522 {
523     // NOTE: apparently the fbCmd of the STATUS type,
524     // with EnhancedMixer controlSelector returns with this
525     // controlSelector type changed to Mixer, making it
526     // impossible to choose the correct response handler
527     // based upon the response only.
528    
529     // HACK: we assume that it is the same as the sent one
530     // we also look at our data structure to figure out what we sent
531     byte_t controlSelector=eCSE_Processing_Unknown;
532     if(m_pMixer) {
533         controlSelector=eCSE_Processing_Mixer;
534     } else if(m_pEnhancedMixer) {
535         controlSelector=eCSE_Processing_EnhancedMixer;
536     }
537    
538     bool bStatus;
539     bStatus  = de.read( &m_selectorLength );
540     bStatus &= de.read( &m_fbInputPlugNumber );
541     bStatus &= de.read( &m_inputAudioChannelNumber );
542     bStatus &= de.read( &m_outputAudioChannelNumber );
543
544     byte_t controlSelector_response;
545     bStatus &= de.peek( &controlSelector_response );
546 /*    debugOutput(DEBUG_LEVEL_VERBOSE,"ctrlsel: orig = %02X, resp = %02X\n",
547         controlSelector, controlSelector_response);*/
548    
549     switch( controlSelector ) {
550     case eCSE_Processing_Mixer:
551         if ( !m_pMixer ) {
552             m_pMixer = new FunctionBlockProcessingMixer;
553         }
554         bStatus &= m_pMixer->deserialize( de );
555         break;
556     case eCSE_Processing_EnhancedMixer:
557         if ( !m_pEnhancedMixer ) {
558             m_pEnhancedMixer = new FunctionBlockProcessingEnhancedMixer;
559         }
560         bStatus &= m_pEnhancedMixer->deserialize( de );
561         break;
562     case eCSE_Processing_Enable:
563     case eCSE_Processing_Mode:
564     default:
565         bStatus = false;
566     }
567
568     byte_t tmp;
569     if (de.peek(&tmp)) {
570         debugOutput(DEBUG_LEVEL_VERBOSE,"Unprocessed bytes:\n");
571         while (de.read(&tmp)) {
572             debugOutput(DEBUG_LEVEL_VERBOSE," %02X\n",tmp);
573         }
574     }
575
576     return bStatus;
577 }
578
579 FunctionBlockProcessing*
580 FunctionBlockProcessing::clone() const
581 {
582     return new FunctionBlockProcessing( *this );
583 }
584
585 /////////////////////////////////
586
587 FunctionBlockCodec::FunctionBlockCodec()
588     : IBusData()
589 {
590 }
591
592 FunctionBlockCodec::FunctionBlockCodec( const FunctionBlockCodec& rhs )
593     : IBusData()
594 {
595 }
596
597 FunctionBlockCodec::~FunctionBlockCodec()
598 {
599 }
600
601 bool
602 FunctionBlockCodec::serialize( Util::Cmd::IOSSerialize& se )
603 {
604     return false;
605 }
606
607 bool
608 FunctionBlockCodec::deserialize( Util::Cmd::IISDeserialize& de )
609 {
610     return false;
611 }
612
613 FunctionBlockCodec*
614 FunctionBlockCodec::clone() const
615 {
616     return new FunctionBlockCodec( *this );
617 }
618
619 /////////////////////////////////
620 /////////////////////////////////
621
622 FunctionBlockCmd::FunctionBlockCmd( Ieee1394Service& ieee1394service,
623                                     EFunctionBlockType eType,
624                                     function_block_id_t id,
625                                     EControlAttribute eCtrlAttrib )
626     : AVCCommand( ieee1394service, AVC1394_FUNCTION_BLOCK_CMD )
627     , m_functionBlockType( eType )
628     , m_functionBlockId( id )
629     , m_controlAttribute( eCtrlAttrib )
630     , m_pFBSelector( 0 )
631     , m_pFBFeature( 0 )
632     , m_pFBProcessing( 0 )
633     , m_pFBCodec( 0 )
634 {
635     setSubunitType( eST_Audio );
636
637     switch( m_functionBlockType ) {
638         case eFBT_Selector:
639             m_pFBSelector = new FunctionBlockSelector;
640             break;
641         case eFBT_Feature:
642             m_pFBFeature = new FunctionBlockFeature;
643             break;
644         case eFBT_Processing:
645             m_pFBProcessing = new FunctionBlockProcessing;
646             break;
647         case eFBT_Codec:
648             m_pFBCodec = new FunctionBlockCodec;
649             break;
650     }
651 }
652
653 FunctionBlockCmd::FunctionBlockCmd( const FunctionBlockCmd& rhs )
654     : AVCCommand( rhs )
655     , m_functionBlockType( rhs.m_functionBlockType )
656     , m_functionBlockId( rhs.m_functionBlockId )
657     , m_controlAttribute( rhs.m_controlAttribute )
658     , m_pFBSelector( new FunctionBlockSelector( *rhs.m_pFBSelector ) )
659     , m_pFBFeature( new FunctionBlockFeature( *rhs.m_pFBFeature ) )
660     , m_pFBProcessing( new FunctionBlockProcessing( *rhs.m_pFBProcessing ) )
661     , m_pFBCodec( new FunctionBlockCodec( *rhs.m_pFBCodec ) )
662 {
663 }
664
665 FunctionBlockCmd::~FunctionBlockCmd()
666 {
667     delete m_pFBSelector;
668     m_pFBSelector = 0;
669     delete m_pFBFeature;
670     m_pFBFeature = 0;
671     delete m_pFBProcessing;
672     m_pFBProcessing = 0;
673     delete m_pFBCodec;
674     m_pFBCodec = 0;
675 }
676
677 bool
678 FunctionBlockCmd::serialize( Util::Cmd::IOSSerialize& se )
679 {
680     bool bStatus;
681     bStatus  = AVCCommand::serialize( se );
682     bStatus &= se.write( m_functionBlockType, "FunctionBlockCmd functionBlockType" );
683     bStatus &= se.write( m_functionBlockId,   "FunctionBlockCmd functionBlockId" );
684     bStatus &= se.write( m_controlAttribute,  "FunctionBlockCmd controlAttribute" );
685
686     switch( m_functionBlockType ) {
687         case eFBT_Selector:
688             if ( m_pFBSelector ) {
689                 bStatus &= m_pFBSelector->serialize( se );
690             } else {
691                 bStatus = false;
692             }
693             break;
694         case eFBT_Feature:
695             if ( m_pFBFeature ) {
696                 bStatus &= m_pFBFeature->serialize( se );
697             } else {
698                 bStatus = false;
699             }
700             break;
701         case eFBT_Processing:
702             if ( m_pFBProcessing ) {
703                 bStatus &= m_pFBProcessing->serialize( se );
704             } else {
705                 bStatus = false;
706             }
707             break;
708         case eFBT_Codec:
709             if ( m_pFBCodec ) {
710                 bStatus &= m_pFBCodec->serialize( se );
711             } else {
712                 bStatus = false;
713             }
714             break;
715         default:
716             bStatus = false;
717     }
718
719     return bStatus;
720 }
721
722 bool
723 FunctionBlockCmd::deserialize( Util::Cmd::IISDeserialize& de )
724 {
725     bool bStatus;
726     bStatus  = AVCCommand::deserialize( de );
727
728     bStatus &= de.read( &m_functionBlockType );
729     bStatus &= de.read( &m_functionBlockId );
730     bStatus &= de.read( &m_controlAttribute );
731
732     switch( m_functionBlockType ) {
733         case eFBT_Selector:
734             if ( !m_pFBSelector ) {
735                 m_pFBSelector = new FunctionBlockSelector;
736             }
737             bStatus &= m_pFBSelector->deserialize( de );
738             break;
739         case eFBT_Feature:
740             if ( !m_pFBFeature ) {
741                 m_pFBFeature = new FunctionBlockFeature;
742             }
743             bStatus &= m_pFBFeature->deserialize( de );
744             break;
745         case eFBT_Processing:
746             if ( !m_pFBProcessing ) {
747                 m_pFBProcessing = new FunctionBlockProcessing;
748             }
749             bStatus &= m_pFBProcessing->deserialize( de );
750             break;
751         case eFBT_Codec:
752             if ( !m_pFBCodec ) {
753                 m_pFBCodec = new FunctionBlockCodec;
754             }
755             bStatus &= m_pFBCodec->deserialize( de );
756             break;
757         default:
758             bStatus = false;
759     }
760
761     return bStatus;
762 }
763
764 FunctionBlockCmd*
765 FunctionBlockCmd::clone() const
766 {
767     return new FunctionBlockCmd( *this );
768 }
769
770 }
Note: See TracBrowser for help on using the browser.