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

Revision 864, 5.2 kB (checked in by ppalmers, 15 years ago)

update license to GPLv2 or GPLv3 instead of GPLv2 or any later version. Update copyrights to reflect the new year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
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 #include "avc_plug_info.h"
25 #include "libutil/cmd_serialize.h"
26 #include "libieee1394/ieee1394service.h"
27
28 #include <netinet/in.h>
29 #include <iostream>
30
31 using namespace std;
32
33 namespace AVC {
34
35 PlugInfoCmd::PlugInfoCmd( Ieee1394Service& ieee1394service,
36                           ESubFunction eSubFunction )
37     : AVCCommand( ieee1394service, AVC1394_CMD_PLUG_INFO )
38     , m_serialBusIsochronousInputPlugs( 0xff )
39     , m_serialBusIsochronousOutputPlugs( 0xff )
40     , m_externalInputPlugs( 0xff )
41     , m_externalOutputPlugs( 0xff )
42     , m_serialBusAsynchronousInputPlugs( 0xff )
43     , m_serialBusAsynchronousOuputPlugs( 0xff )
44     , m_destinationPlugs( 0xff )
45     , m_sourcePlugs( 0xff )
46     , m_subFunction( eSubFunction )
47 {
48 }
49
50 PlugInfoCmd::PlugInfoCmd( const PlugInfoCmd& rhs )
51     : AVCCommand( rhs )
52     , m_serialBusIsochronousInputPlugs( rhs.m_serialBusIsochronousInputPlugs )
53     , m_serialBusIsochronousOutputPlugs( rhs.m_serialBusIsochronousOutputPlugs )
54     , m_externalInputPlugs( rhs.m_externalInputPlugs )
55     , m_externalOutputPlugs( rhs.m_externalOutputPlugs )
56     , m_serialBusAsynchronousInputPlugs( rhs.m_serialBusAsynchronousInputPlugs )
57     , m_serialBusAsynchronousOuputPlugs( rhs.m_serialBusAsynchronousOuputPlugs )
58     , m_destinationPlugs( rhs.m_destinationPlugs )
59     , m_sourcePlugs( rhs.m_sourcePlugs )
60     , m_subFunction( rhs.m_subFunction )
61 {
62 }
63
64 PlugInfoCmd::~PlugInfoCmd()
65 {
66 }
67
68 void
69 PlugInfoCmd::clear()
70 {
71     m_serialBusIsochronousInputPlugs=0xff;
72     m_serialBusIsochronousOutputPlugs=0xff;
73     m_externalInputPlugs=0xff;
74     m_externalOutputPlugs=0xff;
75     m_serialBusAsynchronousInputPlugs=0xff;
76     m_serialBusAsynchronousOuputPlugs=0xff;
77     m_destinationPlugs=0xff;
78     m_sourcePlugs=0xff;
79 }
80
81 bool
82 PlugInfoCmd::serialize( Util::Cmd::IOSSerialize& se )
83 {
84     byte_t reserved = 0xff;
85
86     AVCCommand::serialize( se );
87     se.write( m_subFunction, "PlugInfoCmd subFunction" );
88     switch( getSubunitType() ) {
89     case eST_Unit:
90         switch( m_subFunction ) {
91         case eSF_SerialBusIsochronousAndExternalPlug:
92             se.write( m_serialBusIsochronousInputPlugs, "PlugInfoCmd serialBusIsochronousInputPlugs" );
93             se.write( m_serialBusIsochronousOutputPlugs, "PlugInfoCmd serialBusIsochronousOutputPlugs" );
94             se.write( m_externalInputPlugs, "PlugInfoCmd externalInputPlugs" );
95             se.write( m_externalOutputPlugs, "PlugInfoCmd externalOutputPlugs" );
96             break;
97         case eSF_SerialBusAsynchonousPlug:
98             se.write( m_serialBusAsynchronousInputPlugs, "PlugInfoCmd serialBusAsynchronousInputPlugs" );
99             se.write( m_serialBusAsynchronousOuputPlugs, "PlugInfoCmd serialBusAsynchronousOuputPlugs" );
100             se.write( reserved, "PlugInfoCmd" );
101             se.write( reserved, "PlugInfoCmd" );
102             break;
103         default:
104             cerr << "Could not serialize with subfucntion " << m_subFunction << endl;
105             return false;
106         }
107         break;
108     default:
109         se.write( m_destinationPlugs, "PlugInfoCmd destinationPlugs" );
110         se.write( m_sourcePlugs, "PlugInfoCmd sourcePlugs" );
111         se.write( reserved, "PlugInfoCmd" );
112         se.write( reserved, "PlugInfoCmd" );
113     }
114     return true;
115 }
116
117 bool
118 PlugInfoCmd::deserialize( Util::Cmd::IISDeserialize& de )
119 {
120     byte_t reserved;
121
122     AVCCommand::deserialize( de );
123     de.read( &m_subFunction );
124     switch ( getSubunitType() ) {
125     case eST_Unit:
126         switch ( m_subFunction ) {
127         case eSF_SerialBusIsochronousAndExternalPlug:
128             de.read( &m_serialBusIsochronousInputPlugs );
129             de.read( &m_serialBusIsochronousOutputPlugs );
130             de.read( &m_externalInputPlugs );
131             de.read( &m_externalOutputPlugs );
132             break;
133         case eSF_SerialBusAsynchonousPlug:
134             de.read( &m_serialBusAsynchronousInputPlugs );
135             de.read( &m_serialBusAsynchronousOuputPlugs );
136             de.read( &reserved );
137             de.read( &reserved );
138             break;
139         default:
140             cerr << "Could not deserialize with subfunction " << m_subFunction << endl;
141             return false;
142         }
143         break;
144     default:
145         de.read( &m_destinationPlugs );
146         de.read( &m_sourcePlugs );
147         de.read( &reserved );
148         de.read( &reserved );
149     }
150     return true;
151 }
152
153 bool
154 PlugInfoCmd::setSubFunction( ESubFunction subFunction )
155 {
156     m_subFunction = subFunction;
157     return true;
158 }
159
160 }
Note: See TracBrowser for help on using the browser.