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

Revision 509, 5.1 kB (checked in by ppalmers, 17 years ago)

- Moved all generic stuff but the functionblocks over to libavc
- compiles and works

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 showDevice();
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     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     const SyncInfoVector& getSyncInfos() const
89         { return m_syncInfos; }
90     const SyncInfo* getActiveSyncInfo() const
91         { return m_activeSyncInfo; }
92     virtual bool setActiveSync( const SyncInfo& syncInfo ) = 0;
93
94     bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;
95     static bool deserialize( Glib::ustring basePath, Unit*,
96                                  Util::IODeserialize& deser,
97                                  Ieee1394Service& ieee1394Service );
98     SubunitAudio* getAudioSubunit( subunit_id_t subunitId )
99         { return dynamic_cast<SubunitAudio*>(
100                    getSubunit( AVC1394_SUBUNIT_AUDIO , subunitId ));};
101     SubunitMusic* getMusicSubunit( subunit_id_t subunitId )
102         { return dynamic_cast<SubunitMusic*>(
103                    getSubunit( AVC1394_SUBUNIT_MUSIC , subunitId ));};
104     Subunit* getSubunit( subunit_type_t subunitType,
105                          subunit_id_t subunitId ) const;
106 protected:
107
108     virtual bool enumerateSubUnits();
109
110     unsigned int getNrOfSubunits( subunit_type_t subunitType ) const;
111     PlugConnection* getPlugConnection( Plug& srcPlug ) const;
112
113     Plug* getSyncPlug( int maxPlugId, Plug::EPlugDirection );
114
115     Plug* getPlugById( PlugVector& plugs,
116                          Plug::EPlugDirection plugDireciton,
117                          int id );
118     PlugVector getPlugsByType( PlugVector& plugs,
119                  Plug::EPlugDirection plugDirection,
120                  Plug::EPlugType type);
121
122 //     bool setSamplingFrequencyPlug( Plug& plug,
123 //                                    Plug::EPlugDirection direction,
124 //                                    ESamplingFrequency samplingFrequency );
125
126     void showPlugs( PlugVector& plugs ) const;
127
128 //     bool checkSyncConnectionsAndAddToList( PlugVector& plhs,
129 //                                            PlugVector& prhs,
130 //                                            std::string syncDescription );
131
132     static bool serializeSyncInfoVector( Glib::ustring basePath,
133                                          Util::IOSerialize& ser,
134                                          const SyncInfoVector& vec );
135     static bool deserializeSyncInfoVector( Glib::ustring basePath,
136                                            Util::IODeserialize& deser,
137                                            Unit& avDevice,
138                                            SyncInfoVector& vec );
139 protected:
140     SubunitVector             m_subunits;
141     PlugVector                m_pcrPlugs;
142     PlugVector                m_externalPlugs;
143     PlugConnectionVector      m_plugConnections;
144     PlugManager*              m_pPlugManager;
145     SyncInfoVector            m_syncInfos;
146     SyncInfo*                 m_activeSyncInfo;
147
148 private:
149     DECLARE_DEBUG_MODULE;
150
151 };
152
153 }
154
155 #endif
Note: See TracBrowser for help on using the browser.