root/trunk/libffado/src/devicemanager.h

Revision 2803, 6.2 kB (checked in by jwoithe, 1 year ago)

Cosmetic: capitalise "L" in "Linux".

"Linux" is a proper noun so it should start with a capital letter. These
changes are almost all within comments.

This patch was originally proposed by pander on the ffado-devel mailing
list. It has been expanded to cover all similar cases to maintain
consistency throughout the source tree.

  • 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 #include "libutil/Mutex.h"
40 #include "libutil/Configuration.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         eWR_Shutdown,
75     };
76
77     DeviceManager();
78     ~DeviceManager();
79
80     bool setThreadParameters(bool rt, int priority);
81
82     bool initialize();
83     bool deinitialize();
84
85     bool addSpecString(char *);
86     bool isSpecStringValid(std::string s);
87
88     bool discover(bool useCache=true, bool rediscover=false);
89     bool initStreaming();
90     bool prepareStreaming();
91     bool finishStreaming();
92     bool startStreamingOnDevice(FFADODevice *device);
93     bool startStreaming();
94     bool stopStreamingOnDevice(FFADODevice *device);
95     bool stopStreaming();
96     bool resetStreaming();
97     enum eWaitResult waitForPeriod();
98     bool setPeriodSize(unsigned int period);
99     bool setStreamingParams(unsigned int period, unsigned int rate, unsigned int nb_buffers);
100
101     bool isValidNode( int node );
102     int getNbDevices();
103     int getDeviceNodeId( int deviceNr );
104
105     FFADODevice* getAvDevice( int nodeId );
106     FFADODevice* getAvDeviceByIndex( int idx );
107     unsigned int getAvDeviceCount();
108
109     Streaming::StreamProcessor *getSyncSource();
110
111     /**
112      * prevents the busreset handler from running. use with care!
113      */
114     void lockBusResetHandler() {m_BusResetLock->Lock();};
115     /**
116      * releases the busreset handlers
117      */
118     void unlockBusResetHandler() {m_BusResetLock->Unlock();};
119     bool registerBusresetNotification(Util::Functor *f)
120         {return registerNotification(m_busResetNotifiers, f);};
121     bool unregisterBusresetNotification(Util::Functor *f)
122         {return unregisterNotification(m_busResetNotifiers, f);};
123
124     bool registerPreUpdateNotification(Util::Functor *f)
125         {return registerNotification(m_preUpdateNotifiers, f);};
126     bool unregisterPreUpdateNotification(Util::Functor *f)
127         {return unregisterNotification(m_preUpdateNotifiers, f);};
128
129     bool registerPostUpdateNotification(Util::Functor *f)
130         {return registerNotification(m_postUpdateNotifiers, f);};
131     bool unregisterPostUpdateNotification(Util::Functor *f)
132         {return unregisterNotification(m_postUpdateNotifiers, f);};
133
134
135     Util::Configuration& getConfiguration() {return *m_configuration;};
136
137     void showDeviceInfo();
138     void showStreamingInfo();
139
140     // the Control::Container functions
141     virtual std::string getName()
142         {return "DeviceManager";};
143     virtual bool setName( std::string n )
144         { return false;};
145
146 protected:
147     FFADODevice* getDriverForDeviceDo( ConfigRom *configRom,
148                                        int id, bool generic );
149     FFADODevice* getDriverForDevice( ConfigRom *configRom,
150                                      int id );
151     FFADODevice* getSlaveDriver( ffado_smartptr<ConfigRom>( configRom ) );
152
153     void busresetHandler(Ieee1394Service &);
154
155 protected:
156     // we have one service for each port
157     // found on the system. We don't allow dynamic addition of ports (yet)
158     Ieee1394ServiceVector   m_1394Services;
159     FFADODeviceVector       m_avDevices;
160     FunctorVector           m_busreset_functors;
161
162     // the lock protecting the device list
163     Util::Mutex*            m_DeviceListLock;
164     // the lock to serialize bus reset handling
165     Util::Mutex*            m_BusResetLock;
166
167 public: // FIXME: this should be better
168     Streaming::StreamProcessorManager&  getStreamProcessorManager()
169         {return *m_processorManager;};
170 private:
171     Streaming::StreamProcessorManager*  m_processorManager;
172     DeviceStringParser*                 m_deviceStringParser;
173     Util::Configuration*                m_configuration;
174     bool                                m_used_cache_last_time;
175
176     typedef std::vector< Util::Functor* > notif_vec_t;
177     notif_vec_t                           m_busResetNotifiers;
178     notif_vec_t                           m_preUpdateNotifiers;
179     notif_vec_t                           m_postUpdateNotifiers;
180
181     bool registerNotification(notif_vec_t&, Util::Functor *);
182     bool unregisterNotification(notif_vec_t&, Util::Functor *);
183     void signalNotifiers(notif_vec_t& list);
184
185 protected:
186     std::vector<std::string>            m_SpecStrings;
187
188     bool m_thread_realtime;
189     int m_thread_priority;
190
191 // debug stuff
192 public:
193     void setVerboseLevel(int l);
194 private:
195     DECLARE_DEBUG_MODULE;
196 };
197
198 #endif
Note: See TracBrowser for help on using the browser.