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

Revision 204, 2.9 kB (checked in by pieterpalmers, 18 years ago)

- ISO streaming infrastructure starts to look good
- client side infrastructure unexistant

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 "FreebobThread.h"
33
34 #include <sys/poll.h>
35 #include <errno.h>
36
37 #include <vector>
38
39 namespace FreebobStreaming
40 {
41
42 /*!
43 \brief The ISO Handler management class
44
45  This class manages the use of ISO handlers by ISO streams
46
47 */
48
49 class IsoHandler;
50 class IsoStream;
51
52 typedef std::vector<IsoHandler *> IsoHandlerVector;
53 typedef std::vector<IsoHandler *>::iterator IsoHandlerVectorIterator;
54
55 typedef std::vector<IsoStream *> IsoStreamVector;
56 typedef std::vector<IsoStream *>::iterator IsoStreamVectorIterator;
57
58
59 class IsoHandlerManager : public FreebobRunnableInterface
60 {
61         friend class StreamRunner;
62
63     public:
64
65         IsoHandlerManager();
66         virtual ~IsoHandlerManager();
67
68                 void setPollTimeout(int t) {m_poll_timeout=t;};
69                 int getPollTimeout() {return m_poll_timeout;};
70
71                 void setVerboseLevel(int l) { setDebugLevel( l ); };
72
73                 void dumpInfo();
74
75                 int registerStream(IsoStream *);
76                 int unregisterStream(IsoStream *);
77
78                 int startHandlers();
79                 int startHandlers(int cycle);
80                 void stopHandlers();
81
82         protected:
83                 // FreebobRunnableInterface interface
84                 bool Execute(); // note that this is called in we while(running) loop
85                 bool Init();
86
87                 // note: there is a disctinction between streams and handlers
88                 // because one handler can serve multiple streams (in case of
89                 // multichannel receive)
90
91                 // only streams are allowed to be registered externally.
92                 // we allocate a handler if we need one, otherwise the stream
93                 // is assigned to another handler
94
95                 // the collection of handlers
96                 IsoHandlerVector m_IsoHandlers;
97
98                 int registerHandler(IsoHandler *);
99                 int unregisterHandler(IsoHandler *);
100                 void pruneHandlers();
101
102                 // the collection of streams
103                 IsoStreamVector m_IsoStreams;
104
105                 // poll stuff
106                 int m_poll_timeout;
107                 struct pollfd *m_poll_fds;
108                 int m_poll_nfds;
109
110                 int rebuildFdMap();
111
112
113             DECLARE_DEBUG_MODULE;
114
115 };
116
117 }
118
119 #endif /* __FREEBOB_ISOHANDLERMANAGER__  */
120
121
122
Note: See TracBrowser for help on using the browser.