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

Revision 507, 5.1 kB (checked in by ppalmers, 16 years ago)

[Temporary commit: compiles but doesn't run]

First pass on AV/C code refactoring. Generic code and data structures
are moved to libavc classes. Implementation/vendor specific stuff remains
in specific classes.

In this case all 'Extended' commands and the discovery procedures remain in
the bebob/ classes, while the remainder goes into the libavc classes.

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 "avc_subunit.h"
35 #include "avc_plug.h"
36
37 #include "libutil/serialize.h"
38
39 #include <sstream>
40 #include <vector>
41
42 class ConfigRom;
43 class Ieee1394Service;
44
45 namespace AVC {
46
47 class Unit {
48 public:
49     Unit( std::auto_ptr<ConfigRom>( configRom ),
50               Ieee1394Service& ieee1394Service,
51               int nodeId );
52     virtual ~Unit();
53
54     virtual void setVerboseLevel(int l);
55     virtual void showDevice();
56
57     Ieee1394Service& get1394Service()
58         { return *m_pu1394Service; }
59    
60     /// Returns the ConfigRom
61     ConfigRom& getConfigRom() const
62         {return *m_puConfigRom;};
63    
64     /// Discovers the unit's internals
65     bool discover();
66
67     PlugManager& getPlugManager()
68         { return *m_pPlugManager; }
69
70     struct SyncInfo {
71         SyncInfo( Plug& source,
72                   Plug& destination,
73                   std::string description )
74             : m_source( &source )
75             , m_destination( &destination )
76             , m_description( description )
77             {}
78         SyncInfo()
79             : m_source( 0 )
80             , m_destination( 0 )
81             , m_description( "" )
82             {}
83         Plug*     m_source;
84         Plug*     m_destination;
85         std::string m_description;
86     };
87
88     typedef std::vector<SyncInfo> SyncInfoVector;
89     const SyncInfoVector& getSyncInfos() const
90         { return m_syncInfos; }
91     const SyncInfo* getActiveSyncInfo() const
92         { return m_activeSyncInfo; }
93     virtual bool setActiveSync( const SyncInfo& syncInfo ) = 0;
94
95     bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;
96     static bool deserialize( Glib::ustring basePath, Unit*,
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 protected:
108
109     virtual bool enumerateSubUnits();
110
111     unsigned int getNrOfSubunits( subunit_type_t subunitType ) const;
112     PlugConnection* getPlugConnection( Plug& srcPlug ) const;
113
114     Plug* getSyncPlug( int maxPlugId, Plug::EPlugDirection );
115
116     Plug* getPlugById( PlugVector& plugs,
117                          Plug::EPlugDirection plugDireciton,
118                          int id );
119     PlugVector getPlugsByType( PlugVector& plugs,
120                  Plug::EPlugDirection plugDirection,
121                  Plug::EPlugType type);
122
123 //     bool setSamplingFrequencyPlug( Plug& plug,
124 //                                    Plug::EPlugDirection direction,
125 //                                    ESamplingFrequency samplingFrequency );
126
127     void showPlugs( PlugVector& plugs ) const;
128
129 //     bool checkSyncConnectionsAndAddToList( PlugVector& plhs,
130 //                                            PlugVector& prhs,
131 //                                            std::string syncDescription );
132
133     static bool serializeSyncInfoVector( Glib::ustring basePath,
134                                          Util::IOSerialize& ser,
135                                          const SyncInfoVector& vec );
136     static bool deserializeSyncInfoVector( Glib::ustring basePath,
137                                            Util::IODeserialize& deser,
138                                            Unit& avDevice,
139                                            SyncInfoVector& vec );
140 protected:
141     SubunitVector             m_subunits;
142     PlugVector                m_pcrPlugs;
143     PlugVector                m_externalPlugs;
144     PlugConnectionVector      m_plugConnections;
145     PlugManager*              m_pPlugManager;
146     SyncInfoVector            m_syncInfos;
147     SyncInfo*                 m_activeSyncInfo;
148
149 private:
150     std::auto_ptr<ConfigRom>( m_puConfigRom );
151     Ieee1394Service*          m_pu1394Service;
152    
153     DECLARE_DEBUG_MODULE;
154
155 };
156
157 }
158
159 #endif
Note: See TracBrowser for help on using the browser.