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

Revision 445, 4.8 kB (checked in by pieterpalmers, 17 years ago)

* name change from FreeBoB to FFADO
* replaced tabs by 4 spaces
* got rid of end-of-line spaces
* made all license and copyrights conform

library becomes LGPL, apps become GPL
explicitly state LGPL v2.1 and GPL v2 (don't like v3 draft)

copyrights are 2005-2007 Daniel & Pieter
except for the MotU stuff (C) Jonathan, Pieter

  • 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 library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software Foundation;
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301 USA
22  */
23
24 #include "avc_plug_info.h"
25 #include "avc_serialize.h"
26 #include "libieee1394/ieee1394service.h"
27
28 #include <netinet/in.h>
29 #include <iostream>
30
31 using namespace std;
32
33 PlugInfoCmd::PlugInfoCmd( Ieee1394Service& ieee1394service,
34                           ESubFunction eSubFunction )
35     : AVCCommand( ieee1394service, AVC1394_CMD_PLUG_INFO )
36     , m_serialBusIsochronousInputPlugs( 0xff )
37     , m_serialBusIsochronousOutputPlugs( 0xff )
38     , m_externalInputPlugs( 0xff )
39     , m_externalOutputPlugs( 0xff )
40     , m_serialBusAsynchronousInputPlugs( 0xff )
41     , m_serialBusAsynchronousOuputPlugs( 0xff )
42     , m_destinationPlugs( 0xff )
43     , m_sourcePlugs( 0xff )
44     , m_subFunction( eSubFunction )
45 {
46 }
47
48 PlugInfoCmd::PlugInfoCmd( const PlugInfoCmd& rhs )
49     : AVCCommand( rhs )
50     , m_serialBusIsochronousInputPlugs( rhs.m_serialBusIsochronousInputPlugs )
51     , m_serialBusIsochronousOutputPlugs( rhs.m_serialBusIsochronousOutputPlugs )
52     , m_externalInputPlugs( rhs.m_externalInputPlugs )
53     , m_externalOutputPlugs( rhs.m_externalOutputPlugs )
54     , m_serialBusAsynchronousInputPlugs( rhs.m_serialBusAsynchronousInputPlugs )
55     , m_serialBusAsynchronousOuputPlugs( rhs.m_serialBusAsynchronousOuputPlugs )
56     , m_destinationPlugs( rhs.m_destinationPlugs )
57     , m_sourcePlugs( rhs.m_sourcePlugs )
58     , m_subFunction( rhs.m_subFunction )
59 {
60 }
61
62 PlugInfoCmd::~PlugInfoCmd()
63 {
64 }
65
66 bool
67 PlugInfoCmd::serialize( IOSSerialize& se )
68 {
69     byte_t reserved = 0xff;
70
71     AVCCommand::serialize( se );
72     se.write( m_subFunction, "PlugInfoCmd subFunction" );
73     switch( getSubunitType() ) {
74     case eST_Unit:
75         switch( m_subFunction ) {
76         case eSF_SerialBusIsochronousAndExternalPlug:
77             se.write( m_serialBusIsochronousInputPlugs, "PlugInfoCmd serialBusIsochronousInputPlugs" );
78             se.write( m_serialBusIsochronousOutputPlugs, "PlugInfoCmd serialBusIsochronousOutputPlugs" );
79             se.write( m_externalInputPlugs, "PlugInfoCmd externalInputPlugs" );
80             se.write( m_externalOutputPlugs, "PlugInfoCmd externalOutputPlugs" );
81             break;
82         case eSF_SerialBusAsynchonousPlug:
83             se.write( m_serialBusAsynchronousInputPlugs, "PlugInfoCmd serialBusAsynchronousInputPlugs" );
84             se.write( m_serialBusAsynchronousOuputPlugs, "PlugInfoCmd serialBusAsynchronousOuputPlugs" );
85             se.write( reserved, "PlugInfoCmd" );
86             se.write( reserved, "PlugInfoCmd" );
87             break;
88         default:
89             cerr << "Could not serialize with subfucntion " << m_subFunction << endl;
90             return false;
91         }
92         break;
93     default:
94         se.write( m_destinationPlugs, "PlugInfoCmd destinationPlugs" );
95         se.write( m_sourcePlugs, "PlugInfoCmd sourcePlugs" );
96         se.write( reserved, "PlugInfoCmd" );
97         se.write( reserved, "PlugInfoCmd" );
98     }
99     return true;
100 }
101
102 bool
103 PlugInfoCmd::deserialize( IISDeserialize& de )
104 {
105     byte_t reserved;
106
107     AVCCommand::deserialize( de );
108     de.read( &m_subFunction );
109     switch ( getSubunitType() ) {
110     case eST_Unit:
111         switch ( m_subFunction ) {
112         case eSF_SerialBusIsochronousAndExternalPlug:
113             de.read( &m_serialBusIsochronousInputPlugs );
114             de.read( &m_serialBusIsochronousOutputPlugs );
115             de.read( &m_externalInputPlugs );
116             de.read( &m_externalOutputPlugs );
117             break;
118         case eSF_SerialBusAsynchonousPlug:
119             de.read( &m_serialBusAsynchronousInputPlugs );
120             de.read( &m_serialBusAsynchronousOuputPlugs );
121             de.read( &reserved );
122             de.read( &reserved );
123             break;
124         default:
125             cerr << "Could not deserialize with subfunction " << m_subFunction << endl;
126             return false;
127         }
128         break;
129     default:
130         de.read( &m_destinationPlugs );
131         de.read( &m_sourcePlugs );
132         de.read( &reserved );
133         de.read( &reserved );
134     }
135     return true;
136 }
137
138 bool
139 PlugInfoCmd::setSubFunction( ESubFunction subFunction )
140 {
141     m_subFunction = subFunction;
142     return true;
143 }
Note: See TracBrowser for help on using the browser.