root/trunk/libffado/src/libavc/general/avc_extended_subunit_info.cpp

Revision 742, 4.6 kB (checked in by ppalmers, 13 years ago)

- Remove some obsolete support files and dirs

- Clean up the license statements in the source files. Everything is

GPL version 3 now.

- Add license and copyright notices to scons scripts

- Clean up some other text files

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*
2  * Copyright (C) 2005-2007 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 3 of the License, or
12  * (at your option) any later version.
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 #include "avc_extended_subunit_info.h"
25 #include "libutil/cmd_serialize.h"
26 #include "libieee1394/ieee1394service.h"
27
28 #include <netinet/in.h>
29
30 #define NR_OF_PAGE_DATA 5
31 #define SIZE_OF_PAGE_ENTRY 5
32
33 namespace AVC {
34
35 ExtendedSubunitInfoPageData::ExtendedSubunitInfoPageData()
36     : IBusData()
37     , m_functionBlockType( 0xff )
38     , m_functionBlockId( 0xff )
39     , m_functionBlockSpecialPupose( eSP_NoSpecialPupose )
40     , m_noOfInputPlugs( 0xff )
41     , m_noOfOutputPlugs( 0xff )
42 {
43 }
44
45 ExtendedSubunitInfoPageData::~ExtendedSubunitInfoPageData()
46 {
47 }
48
49 bool
50 ExtendedSubunitInfoPageData::serialize( Util::IOSSerialize& se )
51 {
52     se.write( m_functionBlockType, "ExtendedSubunitInfoPageData: function block type" );
53     se.write( m_functionBlockId, "ExtendedSubunitInfoPageData: function block id" );
54     se.write( m_functionBlockSpecialPupose, "ExtendedSubunitInfoPageData: function block special purpose" );
55     se.write( m_noOfInputPlugs, "ExtendedSubunitInfoPageData: number of input plugs" );
56     se.write( m_noOfOutputPlugs, "ExtendedSubunitInfoPageData: number of output plugs" );
57
58     return true;
59 }
60
61 bool
62 ExtendedSubunitInfoPageData::deserialize( Util::IISDeserialize& de )
63 {
64     de.read( &m_functionBlockType );
65     de.read( &m_functionBlockId );
66     de.read( &m_functionBlockSpecialPupose );
67     de.read( &m_noOfInputPlugs );
68     de.read( &m_noOfOutputPlugs );
69     return true;
70 }
71
72 ExtendedSubunitInfoPageData*
73 ExtendedSubunitInfoPageData::clone() const
74 {
75     return new ExtendedSubunitInfoPageData( *this );
76 }
77
78 //////////////////////////////////////////////
79
80 ExtendedSubunitInfoCmd::ExtendedSubunitInfoCmd( Ieee1394Service& ieee1394service )
81     : AVCCommand( ieee1394service, AVC1394_CMD_SUBUNIT_INFO )
82     , m_page( 0xff )
83     , m_fbType( eFBT_AllFunctinBlockType )
84 {
85 }
86
87 ExtendedSubunitInfoCmd::ExtendedSubunitInfoCmd( const ExtendedSubunitInfoCmd& rhs )
88     : AVCCommand( rhs )
89     , m_page( rhs.m_page )
90     , m_fbType( rhs.m_fbType )
91 {
92     for ( ExtendedSubunitInfoPageDataVector::const_iterator it =
93               rhs.m_infoPageDatas.begin();
94           it != rhs.m_infoPageDatas.end();
95           ++it )
96     {
97         m_infoPageDatas.push_back( ( *it )->clone() );
98     }
99 }
100
101 ExtendedSubunitInfoCmd::~ExtendedSubunitInfoCmd()
102 {
103     for ( ExtendedSubunitInfoPageDataVector::iterator it =
104               m_infoPageDatas.begin();
105           it != m_infoPageDatas.end();
106           ++it )
107     {
108         delete *it;
109     }
110 }
111
112 bool
113 ExtendedSubunitInfoCmd::serialize( Util::IOSSerialize& se )
114 {
115     bool status = false;
116     status = AVCCommand::serialize( se );
117     status &= se.write( m_page, "ExtendedSubunitInfoCmd: page" );
118     status &= se.write( m_fbType, "ExtendedSubunitInfoCmd: function block type" );
119     for ( ExtendedSubunitInfoPageDataVector::const_iterator it =
120               m_infoPageDatas.begin();
121           it != m_infoPageDatas.end();
122           ++it )
123     {
124         status &= ( *it )->serialize( se );
125     }
126
127     int startIndex = m_infoPageDatas.size() * SIZE_OF_PAGE_ENTRY;
128     int endIndex = SIZE_OF_PAGE_ENTRY * NR_OF_PAGE_DATA;
129     for ( int i = startIndex; i < endIndex; ++i ) {
130         byte_t dummy = 0xff;
131         se.write( dummy, "ExtendedSubunitInfoCmd: space fill" );
132     }
133     return status;
134 }
135
136 bool
137 ExtendedSubunitInfoCmd::deserialize( Util::IISDeserialize& de )
138 {
139     bool status = false;
140     status = AVCCommand::deserialize( de );
141     status &= de.read( &m_page );
142     status &= de.read( &m_fbType );
143     for ( int i = 0; i < 5; ++i ) {
144         byte_t next;
145         de.peek( &next );
146         if ( next != 0xff ) {
147             ExtendedSubunitInfoPageData* infoPageData =
148                 new ExtendedSubunitInfoPageData();
149             if ( !infoPageData->deserialize( de ) ) {
150                 return false;
151             }
152             m_infoPageDatas.push_back( infoPageData );
153         } else {
154             return status;
155         }
156     }
157
158     return status;
159 }
160
161 }
Note: See TracBrowser for help on using the browser.