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

Revision 516, 6.7 kB (checked in by wagi, 15 years ago)

- some de/serialing bugs found and fixed
- caching enabled for bebob devices

(finally online again! big thanks to my free wireless internet provider. s/he is finally back from
her/his holiday :)

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