root/trunk/libffado/src/devicemanager.h

Revision 960, 4.5 kB (checked in by ppalmers, 16 years ago)

make dbus server handle bus resets and dynamic add/remove of devices

  • 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 <glibmm/ustring.h>
39
40 #include "libutil/Functors.h"
41
42 #include <vector>
43 #include <string>
44
45 class Ieee1394Service;
46 class FFADODevice;
47 class DeviceStringParser;
48
49 namespace Streaming {
50     class StreamProcessor;
51 }
52
53 typedef std::vector< FFADODevice* > FFADODeviceVector;
54 typedef std::vector< FFADODevice* >::iterator FFADODeviceVectorIterator;
55
56 typedef std::vector< Ieee1394Service* > Ieee1394ServiceVector;
57 typedef std::vector< Ieee1394Service* >::iterator Ieee1394ServiceVectorIterator;
58
59 typedef std::vector< Util::Functor* > FunctorVector;
60 typedef std::vector< Util::Functor* >::iterator FunctorVectorIterator;
61
62 typedef std::vector< ConfigRom* > ConfigRomVector;
63 typedef std::vector< ConfigRom* >::iterator ConfigRomVectorIterator;
64
65 class DeviceManager
66     : public Util::OptionContainer,
67       public Control::Container
68 {
69 public:
70     enum eWaitResult {
71         eWR_OK,
72         eWR_Xrun,
73         eWR_Error,
74     };
75
76     DeviceManager();
77     ~DeviceManager();
78
79     bool setThreadParameters(bool rt, int priority);
80
81     bool initialize();
82     bool deinitialize();
83
84     bool addSpecString(char *);
85     bool isSpecStringValid(std::string s);
86
87     bool discover(bool useCache=true, bool rediscover=false);
88     bool initStreaming();
89     bool prepareStreaming();
90     bool finishStreaming();
91     bool startStreaming();
92     bool stopStreaming();
93     bool resetStreaming();
94     enum eWaitResult waitForPeriod();
95     bool setStreamingParams(unsigned int period, unsigned int rate, unsigned int nb_buffers);
96
97     bool isValidNode( int node );
98     int getNbDevices();
99     int getDeviceNodeId( int deviceNr );
100
101     FFADODevice* getAvDevice( int nodeId );
102     FFADODevice* getAvDeviceByIndex( int idx );
103     unsigned int getAvDeviceCount();
104
105     Streaming::StreamProcessor *getSyncSource();
106
107     void ignoreBusResets(bool b) {m_ignore_busreset = b;};
108     bool registerBusresetNotification(Util::Functor *);
109     bool unregisterBusresetNotification(Util::Functor *);
110
111     void showDeviceInfo();
112     void showStreamingInfo();
113
114     // the Control::Container functions
115     virtual std::string getName()
116         {return "DeviceManager";};
117     virtual bool setName( std::string n )
118         { return false;};
119
120 protected:
121     FFADODevice* getDriverForDevice( std::auto_ptr<ConfigRom>( configRom ),
122                                      int id );
123     FFADODevice* getSlaveDriver( std::auto_ptr<ConfigRom>( configRom ) );
124
125     void busresetHandler();
126
127 protected:
128     // we have one service for each port
129     // found on the system. We don't allow dynamic addition of ports (yet)
130     Ieee1394ServiceVector   m_1394Services;
131     FFADODeviceVector       m_avDevices;
132     FunctorVector           m_busreset_functors;
133
134 public: // FIXME: this should be better
135     Streaming::StreamProcessorManager&  getStreamProcessorManager()
136         {return *m_processorManager;};
137 private:
138     Streaming::StreamProcessorManager*  m_processorManager;
139     DeviceStringParser*                 m_deviceStringParser;
140     bool                                m_used_cache_last_time;
141     bool                                m_ignore_busreset;
142
143     typedef std::vector< Util::Functor* > busreset_notif_vec_t;
144     busreset_notif_vec_t                m_busResetNotifiers;
145
146 protected:
147     std::vector<std::string>            m_SpecStrings;
148
149     bool m_thread_realtime;
150     int m_thread_priority;
151
152 // debug stuff
153 public:
154     void setVerboseLevel(int l);
155 private:
156     DECLARE_DEBUG_MODULE;
157 };
158
159 #endif
Note: See TracBrowser for help on using the browser.