root/branches/libfreebob-2.0/src/libstreaming/IsoHandlerManager.h

Revision 250, 3.8 kB (checked in by pieterpalmers, 18 years ago)

- removed old streaming code
- removed some obsolete files
- moved utility classes to libutil
- don't do the doxygen processing on make all, explicit make doc in doc/ is now nescessary (speed)

Line 
1 /* $Id$ */
2
3 /*
4  *   FreeBob streaming API
5  *   FreeBob = Firewire (pro-)audio for linux
6  *
7  *   http://freebob.sf.net
8  *
9  *   Copyright (C) 2006 Pieter Palmers <pieterpalmers@users.sourceforge.net>
10  *
11  *   This program is free software {} you can redistribute it and/or modify
12  *   it under the terms of the GNU General Public License as published by
13  *   the Free Software Foundation {} either version 2 of the License, or
14  *   (at your option) any later version.
15  *
16  *   This program is distributed in the hope that it will be useful,
17  *   but WITHOUT ANY WARRANTY {} without even the implied warranty of
18  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *   GNU General Public License for more details.
20  *
21  *   You should have received a copy of the GNU General Public License
22  *   along with this program {} if not, write to the Free Software
23  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  *
25  *
26  *
27  */
28 #ifndef __FREEBOB_ISOHANDLERMANAGER__
29 #define __FREEBOB_ISOHANDLERMANAGER__
30
31 #include "../debugmodule/debugmodule.h"
32 #include "../libutil/Thread.h"
33
34 #include <sys/poll.h>
35 #include <errno.h>
36
37 #include <vector>
38
39 namespace FreebobStreaming
40 {
41
42 class IsoHandler;
43 class IsoStream;
44
45 typedef std::vector<IsoHandler *> IsoHandlerVector;
46 typedef std::vector<IsoHandler *>::iterator IsoHandlerVectorIterator;
47
48 typedef std::vector<IsoStream *> IsoStreamVector;
49 typedef std::vector<IsoStream *>::iterator IsoStreamVectorIterator;
50
51
52 /*!
53 \brief The ISO Handler management class
54
55  This class manages the use of ISO handlers by ISO streams.
56  You can register an IsoStream with an IsoHandlerManager. This
57  manager will assign an IsoHandler to the stream. If nescessary
58  the manager allocates a new handler. If there is already a handler
59  that can handle the IsoStream (e.g. in case of multichannel receive),
60  it can be assigned.
61
62 */
63
64 class IsoHandlerManager : public FreebobUtil::RunnableInterface
65 {
66         friend class StreamProcessorManager;
67
68     public:
69
70         IsoHandlerManager();
71         virtual ~IsoHandlerManager();
72
73                 void setPollTimeout(int t) {m_poll_timeout=t;}; ///< set the timeout used for poll()
74                 int getPollTimeout() {return m_poll_timeout;};  ///< get the timeout used for poll()
75
76                 void setVerboseLevel(int l); ///< set the verbose level
77
78                 void dumpInfo(); ///< print some information about the manager to stdout/stderr
79
80                 bool registerStream(IsoStream *); ///< register an iso stream with the manager
81                 bool unregisterStream(IsoStream *); ///< unregister an iso stream from the manager
82
83                 bool startHandlers(); ///< start the managed ISO handlers
84                 bool startHandlers(int cycle); ///< start the managed ISO handlers
85                 bool stopHandlers(); ///< stop the managed ISO handlers
86
87                 bool reset() {return true;}; ///< reset the ISO manager and all streams
88
89                 bool prepare(); ///< prepare the ISO manager and all streams
90                
91                 void disablePolling(IsoStream *); ///< disables polling on a stream
92                 void enablePolling(IsoStream *); ///< enables polling on a stream
93
94         protected:
95                 // RunnableInterface interface
96                 bool Execute(); // note that this is called in we while(running) loop
97                 bool Init();
98
99
100                 // note: there is a disctinction between streams and handlers
101                 // because one handler can serve multiple streams (in case of
102                 // multichannel receive)
103
104                 // only streams are allowed to be registered externally.
105                 // we allocate a handler if we need one, otherwise the stream
106                 // is assigned to another handler
107
108                 // the collection of handlers
109                 IsoHandlerVector m_IsoHandlers;
110
111                 bool registerHandler(IsoHandler *);
112                 bool unregisterHandler(IsoHandler *);
113                 void pruneHandlers();
114
115                 // the collection of streams
116                 IsoStreamVector m_IsoStreams;
117
118                 // poll stuff
119                 int m_poll_timeout;
120                 struct pollfd *m_poll_fds;
121                 int m_poll_nfds;
122
123                 bool rebuildFdMap();
124
125
126             DECLARE_DEBUG_MODULE;
127
128 };
129
130 }
131
132 #endif /* __FREEBOB_ISOHANDLERMANAGER__  */
133
134
135
Note: See TracBrowser for help on using the browser.