root/trunk/libffado/src/devicemanager.h

Revision 1154, 4.5 kB (checked in by ppalmers, 14 years ago)

add expat based parsing of the device cache. add compile-time selection between libxml++ and expat. will allow to get rid of the libxml++ dependency on the long run. scons SERIALIZE_USE_EXPAT=0Only compile testedscons SERIALIZE_USE_EXPAT=0

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /*
2  * Copyright (C) 2005-2008 by Daniel Wagner
3  * Copyright (C) 2005-2008 by Pieter Palmers
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 program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 2 of the License, or
13  * (at your option) version 3 of the License.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24
25 #ifndef FFADODEVICEMANAGER_H
26 #define FFADODEVICEMANAGER_H
27
28 #include "debugmodule/debugmodule.h"
29
30 #include "libieee1394/configrom.h"
31 #include "libieee1394/ieee1394service.h"
32
33 #include "libstreaming/StreamProcessorManager.h"
34
35 #include "libutil/OptionContainer.h"
36 #include "libcontrol/BasicElements.h"
37
38 #include "libutil/Functors.h"
39
40 #include <vector>
41 #include <string>
42
43 class Ieee1394Service;
44 class FFADODevice;
45 class DeviceStringParser;
46
47 namespace Streaming {
48     class StreamProcessor;
49 }
50
51 typedef std::vector< FFADODevice* > FFADODeviceVector;
52 typedef std::vector< FFADODevice* >::iterator FFADODeviceVectorIterator;
53
54 typedef std::vector< Ieee1394Service* > Ieee1394ServiceVector;
55 typedef std::vector< Ieee1394Service* >::iterator Ieee1394ServiceVectorIterator;
56
57 typedef std::vector< Util::Functor* > FunctorVector;
58 typedef std::vector< Util::Functor* >::iterator FunctorVectorIterator;
59
60 typedef std::vector< ConfigRom* > ConfigRomVector;
61 typedef std::vector< ConfigRom* >::iterator ConfigRomVectorIterator;
62
63 class DeviceManager
64     : public Util::OptionContainer,
65       public Control::Container
66 {
67 public:
68     enum eWaitResult {
69         eWR_OK,
70         eWR_Xrun,
71         eWR_Error,
72         eWR_Shutdown,
73     };
74
75     DeviceManager();
76     ~DeviceManager();
77
78     bool setThreadParameters(bool rt, int priority);
79
80     bool initialize();
81     bool deinitialize();
82
83     bool addSpecString(char *);
84     bool isSpecStringValid(std::string s);
85
86     bool discover(bool useCache=true, bool rediscover=false);
87     bool initStreaming();
88     bool prepareStreaming();
89     bool finishStreaming();
90     bool startStreaming();
91     bool stopStreaming();
92     bool resetStreaming();
93     enum eWaitResult waitForPeriod();
94     bool setStreamingParams(unsigned int period, unsigned int rate, unsigned int nb_buffers);
95
96     bool isValidNode( int node );
97     int getNbDevices();
98     int getDeviceNodeId( int deviceNr );
99
100     FFADODevice* getAvDevice( int nodeId );
101     FFADODevice* getAvDeviceByIndex( int idx );
102     unsigned int getAvDeviceCount();
103
104     Streaming::StreamProcessor *getSyncSource();
105
106     void ignoreBusResets(bool b) {m_ignore_busreset = b;};
107     bool registerBusresetNotification(Util::Functor *);
108     bool unregisterBusresetNotification(Util::Functor *);
109
110     void showDeviceInfo();
111     void showStreamingInfo();
112
113     // the Control::Container functions
114     virtual std::string getName()
115         {return "DeviceManager";};
116     virtual bool setName( std::string n )
117         { return false;};
118
119 protected:
120     FFADODevice* getDriverForDevice( std::auto_ptr<ConfigRom>( configRom ),
121                                      int id );
122     FFADODevice* getSlaveDriver( std::auto_ptr<ConfigRom>( configRom ) );
123
124     void busresetHandler();
125
126 protected:
127     // we have one service for each port
128     // found on the system. We don't allow dynamic addition of ports (yet)
129     Ieee1394ServiceVector   m_1394Services;
130     FFADODeviceVector       m_avDevices;
131     FunctorVector           m_busreset_functors;
132
133 public: // FIXME: this should be better
134     Streaming::StreamProcessorManager&  getStreamProcessorManager()
135         {return *m_processorManager;};
136 private:
137     Streaming::StreamProcessorManager*  m_processorManager;
138     DeviceStringParser*                 m_deviceStringParser;
139     bool                                m_used_cache_last_time;
140     bool                                m_ignore_busreset;
141
142     typedef std::vector< Util::Functor* > busreset_notif_vec_t;
143     busreset_notif_vec_t                m_busResetNotifiers;
144
145 protected:
146     std::vector<std::string>            m_SpecStrings;
147
148     bool m_thread_realtime;
149     int m_thread_priority;
150
151 // debug stuff
152 public:
153     void setVerboseLevel(int l);
154 private:
155     DECLARE_DEBUG_MODULE;
156 };
157
158 #endif
Note: See TracBrowser for help on using the browser.