root/branches/echoaudio/src/libavc/general/avc_unit.h

Revision 508, 5.2 kB (checked in by ppalmers, 16 years ago)

splitted avc_subunit.cpp into separate files per subunit type

Line 
1 /*
2  * Copyright (C)      2007 by Pieter Palmers
3  * Copyright (C) 2005-2007 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 library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License version 2.1, as published by the Free Software Foundation;
13  *
14  * This library 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 GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22  * MA 02110-1301 USA
23  */
24
25 #ifndef AVC_UNIT_H
26 #define AVC_UNIT_H
27
28 #include <stdint.h>
29
30 #include "debugmodule/debugmodule.h"
31
32 #include "../avc_definitions.h"
33 #include "../general/avc_extended_cmd_generic.h"
34 #include "../general/avc_subunit.h"
35 #include "../general/avc_plug.h"
36 #include "../musicsubunit/avc_musicsubunit.h"
37 #include "../audiosubunit/avc_audiosubunit.h"
38
39 #include "libutil/serialize.h"
40
41 #include <sstream>
42 #include <vector>
43
44 class ConfigRom;
45 class Ieee1394Service;
46
47 namespace AVC {
48
49 class Unit {
50 public:
51     Unit( std::auto_ptr<ConfigRom>( configRom ),
52               Ieee1394Service& ieee1394Service,
53               int nodeId );
54     virtual ~Unit();
55
56     virtual void setVerboseLevel(int l);
57     virtual void showDevice();
58
59     Ieee1394Service& get1394Service()
60         { return *m_pu1394Service; }
61    
62     /// Returns the ConfigRom
63     ConfigRom& getConfigRom() const
64         {return *m_puConfigRom;};
65    
66     /// Discovers the unit's internals
67     bool discover();
68
69     PlugManager& getPlugManager()
70         { return *m_pPlugManager; }
71
72     struct SyncInfo {
73         SyncInfo( Plug& source,
74                   Plug& destination,
75                   std::string description )
76             : m_source( &source )
77             , m_destination( &destination )
78             , m_description( description )
79             {}
80         SyncInfo()
81             : m_source( 0 )
82             , m_destination( 0 )
83             , m_description( "" )
84             {}
85         Plug*     m_source;
86         Plug*     m_destination;
87         std::string m_description;
88     };
89
90     typedef std::vector<SyncInfo> SyncInfoVector;
91     const SyncInfoVector& getSyncInfos() const
92         { return m_syncInfos; }
93     const SyncInfo* getActiveSyncInfo() const
94         { return m_activeSyncInfo; }
95     virtual bool setActiveSync( const SyncInfo& syncInfo ) = 0;
96
97     bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;
98     static bool deserialize( Glib::ustring basePath, Unit*,
99                                  Util::IODeserialize& deser,
100                                  Ieee1394Service& ieee1394Service );
101     SubunitAudio* getAudioSubunit( subunit_id_t subunitId )
102         { return dynamic_cast<SubunitAudio*>(
103                    getSubunit( AVC1394_SUBUNIT_AUDIO , subunitId ));};
104     SubunitMusic* getMusicSubunit( subunit_id_t subunitId )
105         { return dynamic_cast<SubunitMusic*>(
106                    getSubunit( AVC1394_SUBUNIT_MUSIC , subunitId ));};
107     Subunit* getSubunit( subunit_type_t subunitType,
108                          subunit_id_t subunitId ) const;
109 protected:
110
111     virtual bool enumerateSubUnits();
112
113     unsigned int getNrOfSubunits( subunit_type_t subunitType ) const;
114     PlugConnection* getPlugConnection( Plug& srcPlug ) const;
115
116     Plug* getSyncPlug( int maxPlugId, Plug::EPlugDirection );
117
118     Plug* getPlugById( PlugVector& plugs,
119                          Plug::EPlugDirection plugDireciton,
120                          int id );
121     PlugVector getPlugsByType( PlugVector& plugs,
122                  Plug::EPlugDirection plugDirection,
123                  Plug::EPlugType type);
124
125 //     bool setSamplingFrequencyPlug( Plug& plug,
126 //                                    Plug::EPlugDirection direction,
127 //                                    ESamplingFrequency samplingFrequency );
128
129     void showPlugs( PlugVector& plugs ) const;
130
131 //     bool checkSyncConnectionsAndAddToList( PlugVector& plhs,
132 //                                            PlugVector& prhs,
133 //                                            std::string syncDescription );
134
135     static bool serializeSyncInfoVector( Glib::ustring basePath,
136                                          Util::IOSerialize& ser,
137                                          const SyncInfoVector& vec );
138     static bool deserializeSyncInfoVector( Glib::ustring basePath,
139                                            Util::IODeserialize& deser,
140                                            Unit& avDevice,
141                                            SyncInfoVector& vec );
142 protected:
143     SubunitVector             m_subunits;
144     PlugVector                m_pcrPlugs;
145     PlugVector                m_externalPlugs;
146     PlugConnectionVector      m_plugConnections;
147     PlugManager*              m_pPlugManager;
148     SyncInfoVector            m_syncInfos;
149     SyncInfo*                 m_activeSyncInfo;
150
151 private:
152     std::auto_ptr<ConfigRom>( m_puConfigRom );
153     Ieee1394Service*          m_pu1394Service;
154    
155     DECLARE_DEBUG_MODULE;
156
157 };
158
159 }
160
161 #endif
Note: See TracBrowser for help on using the browser.