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

Revision 560, 6.1 kB (checked in by ppalmers, 17 years ago)

- Sort the FFADODevice vector on GUID before assigning device id's

This results in the same device id for identical device setups,
independent of the way they are connected or the node numbers they
have been assigned.

- Sanitized debug message reporting a bit
- Cosmetic changes

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( );
52     virtual ~Unit();
53
54     virtual void setVerboseLevel(int l);
55     virtual void show();
56
57     // these have to be implemented by the parent class
58     /// Returns the 1394 service
59     virtual Ieee1394Service& get1394Service() = 0;
60     /// Returns the ConfigRom
61     virtual ConfigRom& getConfigRom() const = 0;
62    
63     /// Discovers the unit's internals
64     virtual bool discover();
65
66     PlugManager& getPlugManager()
67         { return *m_pPlugManager; }
68
69     struct SyncInfo {
70         SyncInfo( Plug& source,
71                   Plug& destination,
72                   std::string description )
73             : m_source( &source )
74             , m_destination( &destination )
75             , m_description( description )
76             {}
77         SyncInfo()
78             : m_source( 0 )
79             , m_destination( 0 )
80             , m_description( "" )
81             {}
82         Plug*     m_source;
83         Plug*     m_destination;
84         std::string m_description;
85     };
86
87     typedef std::vector<SyncInfo> SyncInfoVector;
88     virtual const SyncInfoVector& getSyncInfos() const
89         { return m_syncInfos; }
90     virtual const SyncInfo* getActiveSyncInfo() const
91         { return m_activeSyncInfo; }
92        
93     virtual bool setActiveSync( const SyncInfo& syncInfo );
94
95     bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;
96     bool deserialize( Glib::ustring basePath,
97                                  Util::IODeserialize& deser,
98                                  Ieee1394Service& ieee1394Service );
99     SubunitAudio* getAudioSubunit( subunit_id_t subunitId )
100         { return dynamic_cast<SubunitAudio*>(
101                    getSubunit( AVC1394_SUBUNIT_AUDIO , subunitId ));};
102     SubunitMusic* getMusicSubunit( subunit_id_t subunitId )
103         { return dynamic_cast<SubunitMusic*>(
104                    getSubunit( AVC1394_SUBUNIT_MUSIC , subunitId ));};
105     Subunit* getSubunit( subunit_type_t subunitType,
106                          subunit_id_t subunitId ) const;
107
108     virtual AVC::Subunit* createSubunit(Unit& unit,
109                                         ESubunitType type,
110                                         subunit_t id );
111     virtual AVC::Plug* createPlug( AVC::Unit* unit,
112                                    AVC::Subunit* subunit,
113                                    AVC::function_block_type_t functionBlockType,
114                                    AVC::function_block_type_t functionBlockId,
115                                    AVC::Plug::EPlugAddressType plugAddressType,
116                                    AVC::Plug::EPlugDirection plugDirection,
117                                    AVC::plug_id_t plugId );
118
119 protected:
120
121     virtual bool enumerateSubUnits();
122     virtual bool discoverPlugConnections();
123     virtual bool discoverSubUnitsPlugConnections();
124     virtual bool discoverPlugs();
125     virtual bool discoverPlugsPCR( AVC::Plug::EPlugDirection plugDirection,
126                            AVC::plug_id_t plugMaxId );
127     virtual bool discoverPlugsExternal( AVC::Plug::EPlugDirection plugDirection,
128                                 AVC::plug_id_t plugMaxId );
129     virtual bool propagatePlugInfo();
130     virtual bool discoverSyncModes();
131     virtual bool checkSyncConnectionsAndAddToList( AVC::PlugVector& plhs,
132                                            AVC::PlugVector& prhs,
133                                            std::string syncDescription );
134     virtual Plug* getSyncPlug( int maxPlugId, Plug::EPlugDirection );
135    
136     unsigned int getNrOfSubunits( subunit_type_t subunitType ) const;
137     PlugConnection* getPlugConnection( Plug& srcPlug ) const;
138
139     Plug* getPlugById( PlugVector& plugs,
140                          Plug::EPlugDirection plugDireciton,
141                          int id );
142     PlugVector getPlugsByType( PlugVector& plugs,
143                  Plug::EPlugDirection plugDirection,
144                  Plug::EPlugType type);
145
146 //     bool setSamplingFrequencyPlug( Plug& plug,
147 //                                    Plug::EPlugDirection direction,
148 //                                    ESamplingFrequency samplingFrequency );
149
150     void showPlugs( PlugVector& plugs ) const;
151
152
153     bool serializeSyncInfoVector( Glib::ustring basePath,
154                                          Util::IOSerialize& ser,
155                                          const SyncInfoVector& vec );
156     bool deserializeSyncInfoVector( Glib::ustring basePath,
157                                            Util::IODeserialize& deser,
158                                            SyncInfoVector& vec );
159 protected:
160     SubunitVector             m_subunits;
161     PlugVector                m_pcrPlugs;
162     PlugVector                m_externalPlugs;
163     PlugConnectionVector      m_plugConnections;
164     PlugManager*              m_pPlugManager;
165     SyncInfoVector            m_syncInfos;
166     SyncInfo*                 m_activeSyncInfo;
167
168 private:
169     DECLARE_DEBUG_MODULE;
170
171 };
172
173 }
174
175 #endif
Note: See TracBrowser for help on using the browser.