root/trunk/libffado/src/bebob/bebob_avdevice.h

Revision 529, 6.3 kB (checked in by wagi, 15 years ago)

- saveCache and loadFromCache interface added to IAvDevice
- current implenetation of saveCache and loadFromCache moved to bebob
- config parser added for loading vendor and model ids from a file instead hardcoded (not finished yet)

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_configparser.h"
34 #include "bebob/bebob_avplug.h"
35 #include "bebob/bebob_avdevice_subunit.h"
36 #include "bebob/GenericMixer.h"
37
38 #include "libstreaming/AmdtpStreamProcessor.h"
39 #include "libstreaming/AmdtpPort.h"
40 #include "libstreaming/AmdtpPortInfo.h"
41
42 #include "libutil/serialize.h"
43
44 #include "iavdevice.h"
45
46 #include <sstream>
47 #include <vector>
48
49 class ConfigRom;
50 class Ieee1394Service;
51 class SubunitPlugSpecificDataPlugAddress;
52
53 namespace BeBoB {
54
55 class AvDevice : public IAvDevice {
56 public:
57     AvDevice( std::auto_ptr<ConfigRom>( configRom ),
58               Ieee1394Service& ieee1394Service,
59               int nodeId );
60     virtual ~AvDevice();
61
62     void setVerboseLevel(int l);
63
64     static bool probe( ConfigRom& configRom );
65     virtual bool loadFromCache();
66     virtual bool saveCache();
67     virtual bool discover();
68
69     virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency );
70     virtual int getSamplingFrequency( );
71
72     virtual int getStreamCount();
73     virtual Streaming::StreamProcessor *getStreamProcessorByIndex(int i);
74
75     virtual bool prepare();
76     virtual bool lock();
77     virtual bool unlock();
78
79     virtual bool startStreamByIndex(int i);
80     virtual bool stopStreamByIndex(int i);
81
82     virtual void showDevice();
83
84     Ieee1394Service& get1394Service()
85         { return *m_p1394Service; }
86
87     AvPlugManager& getPlugManager()
88         { return *m_pPlugManager; }
89
90     struct SyncInfo {
91         SyncInfo( AvPlug& source,
92                   AvPlug& destination,
93                   std::string description )
94             : m_source( &source )
95             , m_destination( &destination )
96             , m_description( description )
97             {}
98         SyncInfo()
99             : m_source( 0 )
100             , m_destination( 0 )
101             , m_description( "" )
102             {}
103         AvPlug*     m_source;
104         AvPlug*     m_destination;
105         std::string m_description;
106     };
107
108     typedef std::vector<SyncInfo> SyncInfoVector;
109     const SyncInfoVector& getSyncInfos() const
110         { return m_syncInfos; }
111     const SyncInfo* getActiveSyncInfo() const
112         { return m_activeSyncInfo; }
113     bool setActiveSync( const SyncInfo& syncInfo );
114
115     AvDeviceSubunitAudio* getAudioSubunit( subunit_id_t subunitId )
116         { return dynamic_cast<AvDeviceSubunitAudio*>(
117                    getSubunit( AVC1394_SUBUNIT_AUDIO , subunitId ));};
118
119 protected:
120
121     bool enumerateSubUnits();
122
123     bool discoverPlugs();
124     bool discoverPlugsPCR( AvPlug::EAvPlugDirection plugDirection,
125                            plug_id_t plugMaxId );
126     bool discoverPlugsExternal( AvPlug::EAvPlugDirection plugDirection,
127                                 plug_id_t plugMaxId );
128     bool discoverPlugConnections();
129     bool discoverSyncModes();
130     bool discoverSubUnitsPlugConnections();
131
132     AvDeviceSubunit* getSubunit( subunit_type_t subunitType,
133                                  subunit_id_t subunitId ) const;
134
135     unsigned int getNrOfSubunits( subunit_type_t subunitType ) const;
136     AvPlugConnection* getPlugConnection( AvPlug& srcPlug ) const;
137
138     AvPlug* getSyncPlug( int maxPlugId, AvPlug::EAvPlugDirection );
139
140     AvPlug* getPlugById( AvPlugVector& plugs,
141                          AvPlug::EAvPlugDirection plugDireciton,
142                          int id );
143     AvPlugVector getPlugsByType( AvPlugVector& plugs,
144                  AvPlug::EAvPlugDirection plugDirection,
145                  AvPlug::EAvPlugType type);
146
147     bool addPlugToProcessor( AvPlug& plug, Streaming::StreamProcessor *processor,
148                              Streaming::AmdtpAudioPort::E_Direction direction);
149
150     bool setSamplingFrequencyPlug( AvPlug& plug,
151                                    AvPlug::EAvPlugDirection direction,
152                                    ESamplingFrequency samplingFrequency );
153
154     void showAvPlugs( AvPlugVector& plugs ) const;
155
156     bool checkSyncConnectionsAndAddToList( AvPlugVector& plhs,
157                                            AvPlugVector& prhs,
158                                            std::string syncDescription );
159
160
161     bool serialize( Glib::ustring basePath, Util::IOSerialize& ser ) const;
162     bool deserialize( Glib::ustring basePath,
163                       Util::IODeserialize& deser );
164     bool serializeSyncInfoVector( Glib::ustring basePath,
165                                   Util::IOSerialize& ser,
166                                   const SyncInfoVector& vec ) const;
167     bool deserializeSyncInfoVector( Glib::ustring basePath,
168                                     Util::IODeserialize& deser,
169                                     SyncInfoVector& vec );
170     int getConfigurationIdSampleRate();
171     int getConfigurationIdNumberOfChannel( PlugAddress::EPlugDirection ePlugDirection );
172     int getConfigurationIdSyncMode();
173     int getConfigurationId();
174
175     Glib::ustring getCachePath();
176
177 protected:
178     AvPlugVector              m_pcrPlugs;
179     AvPlugVector              m_externalPlugs;
180     AvPlugConnectionVector    m_plugConnections;
181     AvDeviceSubunitVector     m_subunits;
182     AvPlugManager*            m_pPlugManager;
183     SyncInfoVector            m_syncInfos;
184     SyncInfo*                 m_activeSyncInfo;
185     VendorModelEntry*         m_model;
186     GenericMixer*             m_Mixer;
187
188     // streaming stuff
189     typedef std::vector< Streaming::StreamProcessor * > StreamProcessorVector;
190     StreamProcessorVector m_receiveProcessors;
191     StreamProcessorVector m_transmitProcessors;
192 };
193
194 }
195
196 #endif
Note: See TracBrowser for help on using the browser.