root/trunk/libffado/src/libavc/general/avc_subunit.h

Revision 1110, 3.4 kB (checked in by wagi, 14 years ago)

Lot's of small and big bug fixes allong the caching path.
There were several parts not correctly deserialized.

This should fix ticket #65

Line 
1 /*
2  * Copyright (C) 2005-2008 by Pieter Palmers
3  * Copyright (C) 2005-2008 by Daniel Wagner
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 #ifndef AVC_SUBUNIT_H
26 #define AVC_SUBUNIT_H
27
28 #include "debugmodule/debugmodule.h"
29
30 #include "../avc_definitions.h"
31 #include "../general/avc_plug.h"
32 #include "../general/avc_extended_subunit_info.h"
33 #include "../general/avc_generic.h"
34 #include "../audiosubunit/avc_function_block.h"
35
36 #include <vector>
37
38 namespace AVC {
39
40 class Unit;
41
42 class Subunit {
43  public:
44     Subunit( Unit& avDevice,
45              ESubunitType type,
46              subunit_t id );
47     virtual ~Subunit();
48
49     virtual bool discover();
50     virtual bool discoverConnections();
51     virtual const char* getName() = 0;
52
53     subunit_t getSubunitId()
54     { return m_sbId; }
55     ESubunitType getSubunitType()
56     { return m_sbType; }
57
58     Unit& getUnit() const
59         { return *m_unit; }
60     Subunit& getSubunit()
61         { return *this; }
62
63     virtual Plug *createPlug( AVC::Unit* unit,
64                               AVC::Subunit* subunit,
65                               AVC::function_block_type_t functionBlockType,
66                               AVC::function_block_type_t functionBlockId,
67                               AVC::Plug::EPlugAddressType plugAddressType,
68                               AVC::Plug::EPlugDirection plugDirection,
69                               AVC::plug_id_t plugId );
70
71     bool addPlug( Plug& plug );
72     virtual bool initPlugFromDescriptor( Plug& plug );
73
74     PlugVector& getPlugs()
75         { return m_plugs; }
76     Plug* getPlug(Plug::EPlugDirection direction, plug_id_t plugId);
77
78     virtual void setVerboseLevel(int l);
79
80     bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;
81     static Subunit* deserialize( Glib::ustring basePath,
82                                  Util::IODeserialize& deser, Unit& avDevice );
83     bool deserializeUpdate( Glib::ustring basePath,
84                             Util::IODeserialize& deser );
85
86  protected:
87     Subunit();
88
89     virtual bool serializeChild( Glib::ustring basePath,
90                                  Util::IOSerialize& ser ) const = 0;
91     virtual bool deserializeChild( Glib::ustring basePath,
92                                    Util::IODeserialize& deser,
93                                    Unit& avDevice ) = 0;
94     virtual bool deserializeUpdateChild( Glib::ustring basePath,
95                                          Util::IODeserialize& deser ) = 0;
96
97     bool discoverPlugs();
98     bool discoverPlugs(Plug::EPlugDirection plugDirection,
99                        AVC::plug_id_t plugMaxId );
100
101  protected:
102     Unit*           m_unit;
103     ESubunitType    m_sbType;
104     subunit_t       m_sbId;
105
106     PlugVector      m_plugs;
107
108     DECLARE_DEBUG_MODULE;
109 };
110
111 typedef std::vector<Subunit*> SubunitVector;
112
113 }
114
115 #endif
Note: See TracBrowser for help on using the browser.