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

Revision 824, 2.3 kB (checked in by wagi, 15 years ago)

- moved cmd_serialize.h Util:: namespace to Util::Cmd:: in order to avoid ambiguities with serialize.h
- bebob: enhanced mixer stuff added (not finished)

  • 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_unit_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
36 UnitInfoCmd::UnitInfoCmd( Ieee1394Service& ieee1349service )
37     : AVCCommand( ieee1349service, AVC1394_CMD_UNIT_INFO )
38     , m_reserved( 0xff )
39     , m_unit_type( 0xff )
40     , m_unit( 0xff )
41     , m_company_id( 0xffffffff )
42 {
43 }
44
45 UnitInfoCmd::~UnitInfoCmd()
46 {
47 }
48
49 bool
50 UnitInfoCmd::serialize( Util::Cmd::IOSSerialize& se )
51 {
52     AVCCommand::serialize( se );
53
54     se.write( m_reserved, "UnitInfoCmd reserved" );
55     byte_t operand = ( m_unit_type << 3 ) | ( m_unit & 0x7 );
56     se.write( operand, "UnitInfoCmd unit_type and unit" );
57     operand = ( m_company_id >> 16 ) & 0xff;
58     se.write( operand, "UnitInfoCmd company_ID (2)" );
59     operand = ( m_company_id >> 8 ) & 0xff;
60     se.write( operand, "UnitInfoCmd company_ID (1)" );
61     operand = ( m_company_id >> 0 ) & 0xff;
62     se.write( operand, "UnitInfoCmd company_ID (0)" );
63
64     return true;
65 }
66
67 bool
68 UnitInfoCmd::deserialize( Util::Cmd::IISDeserialize& de )
69 {
70     AVCCommand::deserialize( de );
71
72     de.read( &m_reserved );
73
74     byte_t operand;
75     de.read( &operand );
76     m_unit_type = ( operand >> 3 );
77     m_unit = ( operand & 0x7 );
78
79     de.read( &operand );
80     m_company_id = 0;
81     m_company_id |= operand << 16;
82     de.read( &operand );
83     m_company_id |= operand << 8;
84     de.read( &operand );
85     m_company_id |= operand;
86
87     return true;
88 }
89
90 }
Note: See TracBrowser for help on using the browser.