root/branches/echoaudio/src/bebob/bebob_avdevice.h

Revision 500, 6.3 kB (checked in by ppalmers, 17 years ago)

- renamed the IAvDevice to FFADODevice since it's not a pure 'AvDevice?' anymore and it also isn't an interface anymore.

Line 
1 /*
2  * Copyright (C) 2005-2007 by Daniel Wagner
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software Foundation;
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301 USA
22  */
23
24 #ifndef BEBOB_AVDEVICE_H
25 #define BEBOB_AVDEVICE_H
26
27 #include <stdint.h>
28
29 #include "debugmodule/debugmodule.h"
30 #include "libavc/avc_definitions.h"
31 #include "libavc/avc_extended_cmd_generic.h"
32
33 #include "bebob/bebob_avplug.h"
34 #include "bebob/bebob_avdevice_subunit.h"
35 #include "bebob/GenericMixer.h"
36
37 #include "libstreaming/AmdtpStreamProcessor.h"
38 #include "libstreaming/AmdtpPort.h"
39 #include "libstreaming/AmdtpPortInfo.h"
40
41 #include "libutil/serialize.h"
42
43 #include "ffadodevice.h"
44
45 #include <sstream>
46 #include <vector>
47
48 class ConfigRom;
49 class Ieee1394Service;
50 class SubunitPlugSpecificDataPlugAddress;
51
52 namespace BeBoB {
53
54 struct VendorModelEntry {
55     unsigned int vendor_id;
56     unsigned int model_id;
57     char *vendor_name;
58     char *model_name;
59 };
60
61 class AvDevice : public FFADODevice {
62 public:
63     AvDevice( std::auto_ptr<ConfigRom>( configRom ),
64               Ieee1394Service& ieee1394Service,
65               int nodeId );
66     virtual ~AvDevice();
67
68     void setVerboseLevel(int l);
69
70     static bool probe( ConfigRom& configRom );
71     virtual bool discover();
72
73     virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency );
74     virtual int getSamplingFrequency( );
75
76     virtual int getStreamCount();
77     virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
78
79     virtual bool prepare();
80     bool lock();
81     bool unlock();
82
83     bool startStreamByIndex(int i);
84     bool stopStreamByIndex(int i);
85
86     virtual void showDevice();
87
88     Ieee1394Service& get1394Service()
89         { return *m_p1394Service; }
90
91     AvPlugManager& getPlugManager()
92         { return *m_pPlugManager; }
93
94     struct SyncInfo {
95         SyncInfo( AvPlug& source,
96                   AvPlug& destination,
97                   std::string description )
98             : m_source( &source )
99             , m_destination( &destination )
100             , m_description( description )
101             {}
102         SyncInfo()
103             : m_source( 0 )
104             , m_destination( 0 )
105             , m_description( "" )
106             {}
107         AvPlug*     m_source;
108         AvPlug*     m_destination;
109         std::string m_description;
110     };
111
112     typedef std::vector<SyncInfo> SyncInfoVector;
113     const SyncInfoVector& getSyncInfos() const
114         { return m_syncInfos; }
115     const SyncInfo* getActiveSyncInfo() const
116         { return m_activeSyncInfo; }
117     bool setActiveSync( const SyncInfo& syncInfo );
118
119     bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;
120     static AvDevice* deserialize( Glib::ustring basePath,
121                                   Util::IODeserialize& deser,
122                   Ieee1394Service& ieee1394Service );
123     AvDeviceSubunitAudio* getAudioSubunit( subunit_id_t subunitId )
124         { return dynamic_cast<AvDeviceSubunitAudio*>(
125                    getSubunit( AVC1394_SUBUNIT_AUDIO , subunitId ));};
126
127 protected:
128
129     bool enumerateSubUnits();
130
131     bool discoverPlugs();
132     bool discoverPlugsPCR( AvPlug::EAvPlugDirection plugDirection,
133                            plug_id_t plugMaxId );
134     bool discoverPlugsExternal( AvPlug::EAvPlugDirection plugDirection,
135                                 plug_id_t plugMaxId );
136     bool discoverPlugConnections();
137     bool discoverSyncModes();
138     bool discoverSubUnitsPlugConnections();
139
140     AvDeviceSubunit* getSubunit( subunit_type_t subunitType,
141                                  subunit_id_t subunitId ) const;
142
143     unsigned int getNrOfSubunits( subunit_type_t subunitType ) const;
144     AvPlugConnection* getPlugConnection( AvPlug& srcPlug ) const;
145
146     AvPlug* getSyncPlug( int maxPlugId, AvPlug::EAvPlugDirection );
147
148     AvPlug* getPlugById( AvPlugVector& plugs,
149                          AvPlug::EAvPlugDirection plugDireciton,
150                          int id );
151     AvPlugVector getPlugsByType( AvPlugVector& plugs,
152                  AvPlug::EAvPlugDirection plugDirection,
153                  AvPlug::EAvPlugType type);
154
155     bool addPlugToProcessor( AvPlug& plug, Streaming::StreamProcessor *processor,
156                              Streaming::AmdtpAudioPort::E_Direction direction);
157
158     bool setSamplingFrequencyPlug( AvPlug& plug,
159                                    AvPlug::EAvPlugDirection direction,
160                                    ESamplingFrequency samplingFrequency );
161
162     void showAvPlugs( AvPlugVector& plugs ) const;
163
164     bool checkSyncConnectionsAndAddToList( AvPlugVector& plhs,
165                                            AvPlugVector& prhs,
166                                            std::string syncDescription );
167
168     static bool serializeSyncInfoVector( Glib::ustring basePath,
169                                          Util::IOSerialize& ser,
170                                          const SyncInfoVector& vec );
171     static bool deserializeSyncInfoVector( Glib::ustring basePath,
172                                            Util::IODeserialize& deser,
173                                            AvDevice& avDevice,
174                                            SyncInfoVector& vec );
175 protected:
176     AvPlugVector              m_pcrPlugs;
177     AvPlugVector              m_externalPlugs;
178     AvPlugConnectionVector    m_plugConnections;
179     AvDeviceSubunitVector     m_subunits;
180     AvPlugManager*            m_pPlugManager;
181     SyncInfoVector            m_syncInfos;
182     SyncInfo*                 m_activeSyncInfo;
183     struct VendorModelEntry*  m_model;
184     GenericMixer*             m_Mixer;
185
186     // streaming stuff
187     typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector;
188     StreamProcessorVector m_receiveProcessors;
189     StreamProcessorVector m_transmitProcessors;
190 };
191
192 }
193
194 #endif
Note: See TracBrowser for help on using the browser.