root/branches/streaming-rework/src/iavdevice.h

Revision 415, 7.0 kB (checked in by pieterpalmers, 16 years ago)

ieee1394service:
- implemented 64bit compare-swap-lock operation (needed for DICE)
- small name change of (un)registerARMhandler to (un)registerARMHandler

iavdevice.h:
- made the stream start/stop functions return bool instead of int
- updated function documentation for consistency and to reflect changes

BeBoB avdevice:
- replaced the 2 fixed streamprocessor pointers with a 2 vectors of streamprocessors
- implemented the 'snoop mode' (cannot be activated yet)

libstreaming:
- removed unused 'type' attribute from AmdtpPortInfo? & children

mh_avdevice, motu_avdevice, rme_avdevice:
- replaced m_1394service with m_p1394service for consistence

maudio_avdevice.cpp:
- removed unused code

Line 
1 /* iavdevice.h
2  * Copyright (C) 2006 by Daniel Wagner
3  *
4  * This file is part of FreeBoB.
5  *
6  * FreeBoB is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * FreeBoB is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with FreeBoB; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18  * MA 02111-1307 USA.
19  */
20
21 #ifndef IAVDEVICE_H
22 #define IAVDEVICE_H
23
24 #include "libfreebobavc/avc_definitions.h"
25 #include "libfreebob/xmlparser.h"
26
27 class ConfigRom;
28 class Ieee1394Service;
29
30 namespace FreebobStreaming {
31         class StreamProcessor;
32 }
33 /*!
34 @brief Interface that is to be implemented to support a device.
35
36  This interface should be used to implement freebob support
37  for a specific device.
38
39 */
40 class IAvDevice {
41 public:
42         virtual ~IAvDevice() {}
43        
44         /// Returns the ConfigRom object of the device node.
45         virtual ConfigRom& getConfigRom() const = 0;
46        
47         /**
48          * @brief This is called by the DeviceManager to discover & configure the device
49          *
50          * @return true if the device was discovered successfuly
51          */
52         virtual bool discover() = 0;
53        
54         /**
55          * @brief Set the samping frequency
56          * @param samplingFrequency
57          * @return true if successful
58          */
59         virtual bool setSamplingFrequency( ESamplingFrequency samplingFrequency ) = 0;
60         /**
61          * @brief get the samplingfrequency as an integer
62          * @return the sampling frequency as integer
63          */
64         virtual int getSamplingFrequency( ) = 0;
65        
66     /**
67      * @brief This is called by the device manager to give the device a unique ID.
68      *
69      * The purpose of this is to allow for unique port naming
70      * in case there are multiple identical devices on the bus.
71      * Some audio API's (e.g. jack) don't work properly when the
72      * port names are not unique.
73      *
74      * Say you have two devices having a port named OutputLeft.
75      * This can cause the streaming
76      * part to present two OutputLeft ports to the audio API,
77      * which won't work. This ID will allow you to construct
78      * the port names as 'dev1_OutputLeft' and 'dev2_OutputLeft'
79      *
80      * @note Currently this is a simple integer that is equal to
81      *       the position of the device in the devicemanager's
82      *       device list. Therefore it is dependant on the order
83      *       in which the devices are detected. The side-effect
84      *       of this is that it is dependant on the bus topology
85      *       and history (e.g. busresets etc). This makes that
86      *       these ID's are not fixed to a specific physical device.
87      *       At some point, we will replaced this with a GUID based
88      *       approach, which is tied to a physiscal device and is
89      *       bus & time independant.
90      *
91      * @param id
92      * @return true if successful
93      */
94     virtual bool setId(unsigned int id) = 0;
95        
96         /**
97          * @brief Constructs an XML description of the device [obsolete]
98          *
99          * this is a leftover from v1.0 and isn't used
100          * just provide an empty implementation that returns true
101          * untill it is removed
102          *
103          * @param deviceNode
104          * @return true if successful, false if not
105          */
106         virtual bool addXmlDescription( xmlNodePtr deviceNode ) = 0;
107        
108         /**
109          * @brief Outputs the device configuration to stderr/stdout [debug helper]
110          *
111          * This function prints out a (detailed) description of the
112          * device detected, and its configuration.
113          */
114         virtual void showDevice() const = 0;
115
116         /**
117          * @brief Lock the device
118          *
119          * This is called by the streaming layer before we start manipulating
120          * and/or using the device.
121          *
122          * It should implement the mechanisms provided by the device to
123          * make sure that no other controller claims control of the device.
124          *
125          * @return true if successful, false if not
126          */
127         virtual bool lock() = 0;
128        
129         /**
130          * @brief Unlock the device
131          *
132          * This is called by the streaming layer after we finish manipulating
133          * and/or using the device.
134          *
135          * It should implement the mechanisms provided by the device to
136          * give up exclusive control of the device.
137          *
138          * @return true if successful, false if not
139          */
140         virtual bool unlock() = 0;
141
142         /**
143          * @brief Prepare the device
144          *
145          * This is called by the streaming layer after the configuration
146          * parameters (e.g. sample rate) are set, and before
147          * getStreamProcessor[*] functions are called.
148          *
149          * It should be used to prepare the device's streamprocessors
150          * based upon the device's current configuration. Normally
151          * the streaming layer will not change the device's configuration
152          * after calling this function.
153          *
154          * @return true if successful, false if not
155          */
156         virtual bool prepare() = 0;
157        
158         /**
159          * @brief Returns the number of ISO streams implemented/used by this device
160          *
161          * Most likely this is 2 streams, i.e. one transmit stream and one
162          * receive stream. However there are devices that implement more, for
163          * example BeBoB's implement 4 streams:
164          * - 2 audio streams (1 xmit/1 recv)
165          * - 2 sync streams (1 xmit/1 recv), which are an optional sync source
166          *   for the device.
167          *
168          * @note you have to have a StreamProcessor for every stream. I.e.
169          *       getStreamProcessorByIndex(i) should return a valid StreamProcessor
170          *       for i=0 to i=getStreamCount()-1
171          *
172          * @return number of streams available (both transmit and receive)
173          */
174         virtual int getStreamCount() = 0;
175        
176         /**
177          * @brief Returns the StreamProcessor object for the stream with index i
178          *
179          * @note a streamprocessor returned by getStreamProcessorByIndex(i)
180          *       cannot be the same object as one returned by
181          *       getStreamProcessorByIndex(j) if i isn't equal to j
182          * @note you cannot have two streamprocessors handling the same ISO
183          *       channel (on the same port)
184          *
185          * @param i : Stream index
186          * @pre @ref i smaller than getStreamCount()
187          * @return a StreamProcessor object if successful, NULL otherwise
188          */
189         virtual FreebobStreaming::StreamProcessor *getStreamProcessorByIndex(int i) = 0;
190        
191         /**
192          * @brief starts the stream with index i
193          *
194          * This function is called by the streaming layer when this stream should
195          * be started, i.e. the device should start sending data or should be prepared to
196          * be ready to receive data.
197          *
198          * It returns the channel number that was assigned for this stream.
199          * Channel allocation should be done using the allocation functions provided by the
200          * Ieee1394Service object that is passed in the constructor.
201          *
202          * @param i : Stream index
203          * @pre @ref i smaller than getStreamCount()
204          * @return true if successful, false if not
205          */
206         virtual bool startStreamByIndex(int i) = 0;
207        
208         /**
209          * @brief stops the stream with index @ref i
210          *
211          * @param i : Stream index
212          * @pre @ref i smaller than getStreamCount()
213          * @return true if successful, false if not
214          */
215         virtual bool stopStreamByIndex(int i) = 0;
216
217 };
218
219 #endif
Note: See TracBrowser for help on using the browser.