root/branches/ppalmers-streaming/src/libstreaming/motu/MotuTransmitStreamProcessor.h

Revision 733, 4.0 kB (checked in by ppalmers, 13 years ago)

adapt motu code to new SP base class (compiles, needs real testing)

Line 
1 /*
2  * Copyright (C) 2005-2007 by Pieter Palmers
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License version 2.1, as published by the Free Software Foundation;
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21  * MA 02110-1301 USA
22  */
23
24 #ifndef __FFADO_MOTUTRANSMITSTREAMPROCESSOR__
25 #define __FFADO_MOTUTRANSMITSTREAMPROCESSOR__
26
27 /**
28  * This class implements MOTU based streaming
29  */
30
31 #include "debugmodule/debugmodule.h"
32
33 #include "../generic/StreamProcessor.h"
34 #include "../util/cip.h"
35
36 namespace Streaming {
37
38 class Port;
39 class MotuAudioPort;
40
41 /*!
42 \brief The Base Class for an MOTU transmit stream processor
43
44  This class implements a TransmitStreamProcessor that multiplexes Ports
45  into MOTU streams.
46
47 */
48 class MotuTransmitStreamProcessor
49     : public StreamProcessor
50 {
51
52 public:
53     /**
54      * Create a MOTU transmit StreamProcessor
55      */
56     MotuTransmitStreamProcessor(int port, unsigned int event_size);
57     virtual ~MotuTransmitStreamProcessor() {};
58
59     enum eChildReturnValue generatePacketHeader(unsigned char *data, unsigned int *length,
60                               unsigned char *tag, unsigned char *sy,
61                               int cycle, unsigned int dropped, unsigned int max_length);
62     enum eChildReturnValue generatePacketData(unsigned char *data, unsigned int *length,
63                             unsigned char *tag, unsigned char *sy,
64                             int cycle, unsigned int dropped, unsigned int max_length);
65     enum eChildReturnValue generateSilentPacketHeader(unsigned char *data, unsigned int *length,
66                                     unsigned char *tag, unsigned char *sy,
67                                     int cycle, unsigned int dropped, unsigned int max_length);
68     enum eChildReturnValue generateSilentPacketData(unsigned char *data, unsigned int *length,
69                                   unsigned char *tag, unsigned char *sy,
70                                   int cycle, unsigned int dropped, unsigned int max_length);
71     virtual bool prepareChild();
72
73 public:
74     virtual unsigned int getEventSize()
75                 {return m_event_size;};
76     virtual unsigned int getMaxPacketSize();
77     virtual unsigned int getEventsPerFrame()
78                     { return 1; }; // FIXME: check
79     virtual unsigned int getNominalFramesPerPacket();
80
81 protected:
82     bool processWriteBlock(char *data, unsigned int nevents, unsigned int offset);
83     bool transmitSilenceBlock(char *data, unsigned int nevents, unsigned int offset);
84
85 private:
86     unsigned int fillNoDataPacketHeader(quadlet_t *data, unsigned int* length);
87     unsigned int fillDataPacketHeader(quadlet_t *data, unsigned int* length, uint32_t ts);
88
89     int transmitBlock(char *data, unsigned int nevents,
90                         unsigned int offset);
91
92     bool encodePacketPorts(quadlet_t *data, unsigned int nevents,
93                            unsigned int dbc);
94
95     int encodePortToMotuEvents(MotuAudioPort *, quadlet_t *data,
96                                 unsigned int offset, unsigned int nevents);
97     int encodeSilencePortToMotuEvents(MotuAudioPort *, quadlet_t *data,
98                                 unsigned int offset, unsigned int nevents);
99
100     /*
101      * An iso packet mostly consists of multiple events.  m_event_size
102      * is the size of a single 'event' in bytes.
103      */
104     unsigned int m_event_size;
105
106     // Keep track of transmission data block count
107     unsigned int m_tx_dbc;
108
109 };
110
111 } // end of namespace Streaming
112
113 #endif /* __FFADO_MOTUTRANSMITSTREAMPROCESSOR__ */
114
Note: See TracBrowser for help on using the browser.