root/branches/libffado-2.0/src/libstreaming/motu/MotuTransmitStreamProcessor.h

Revision 1419, 4.9 kB (checked in by jwoithe, 15 years ago)

Remove unused and unneeded (according to Pieter on 25 Sept 2008) getAveragePacketSize() method.

Line 
1 /*
2  * Copyright (C) 2005-2008 by Jonathan Woithe
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 __FFADO_MOTUTRANSMITSTREAMPROCESSOR__
26 #define __FFADO_MOTUTRANSMITSTREAMPROCESSOR__
27
28 /**
29  * This class implements MOTU based streaming
30  */
31
32 #include "debugmodule/debugmodule.h"
33
34 #include "../generic/StreamProcessor.h"
35 #include "../util/cip.h"
36
37 namespace Streaming {
38
39 class Port;
40 class MotuAudioPort;
41 class MotuMidiPort;
42 /*!
43 \brief The Base Class for an MOTU transmit stream processor
44
45  This class implements a TransmitStreamProcessor that multiplexes Ports
46  into MOTU streams.
47
48 */
49 class MotuTransmitStreamProcessor
50     : public StreamProcessor
51 {
52
53 public:
54     /**
55      * Create a MOTU transmit StreamProcessor
56      */
57     MotuTransmitStreamProcessor(FFADODevice &parent, unsigned int event_size);
58     virtual ~MotuTransmitStreamProcessor() {};
59
60     enum eChildReturnValue generatePacketHeader(unsigned char *data, unsigned int *length,
61                                                 unsigned char *tag, unsigned char *sy,
62                                                 uint32_t pkt_ctr);
63     enum eChildReturnValue generatePacketData(unsigned char *data, unsigned int *length);
64     enum eChildReturnValue generateEmptyPacketHeader(unsigned char *data, unsigned int *length,
65                                                      unsigned char *tag, unsigned char *sy,
66                                                      uint32_t pkt_ctr);
67     enum eChildReturnValue generateEmptyPacketData(unsigned char *data, unsigned int *length);
68     enum eChildReturnValue generateSilentPacketHeader(unsigned char *data, unsigned int *length,
69                                                       unsigned char *tag, unsigned char *sy,
70                                                       uint32_t pkt_ctr);
71     enum eChildReturnValue generateSilentPacketData(unsigned char *data, unsigned int *length);
72     virtual bool prepareChild();
73
74 public:
75     virtual unsigned int getEventSize()
76                 {return m_event_size;};
77     virtual unsigned int getMaxPacketSize();
78     virtual unsigned int getEventsPerFrame()
79                     { return 1; };
80     virtual unsigned int getNominalFramesPerPacket();
81
82 protected:
83     bool processWriteBlock(char *data, unsigned int nevents, unsigned int offset);
84     bool transmitSilenceBlock(char *data, unsigned int nevents, unsigned int offset);
85
86 private:
87     unsigned int fillNoDataPacketHeader(quadlet_t *data, unsigned int* length);
88     unsigned int fillDataPacketHeader(quadlet_t *data, unsigned int* length, uint32_t ts);
89
90     int transmitBlock(char *data, unsigned int nevents,
91                         unsigned int offset);
92
93     bool encodePacketPorts(quadlet_t *data, unsigned int nevents,
94                            unsigned int dbc);
95
96     int encodePortToMotuEvents(MotuAudioPort *, quadlet_t *data,
97                                 unsigned int offset, unsigned int nevents);
98     int encodeSilencePortToMotuEvents(MotuAudioPort *, quadlet_t *data,
99                                 unsigned int offset, unsigned int nevents);
100
101     int encodePortToMotuMidiEvents(
102                        MotuMidiPort *p, quadlet_t *data,
103                        unsigned int offset, unsigned int nevents);
104     int encodeSilencePortToMotuMidiEvents(
105                        MotuMidiPort *p, quadlet_t *data,
106                        unsigned int offset, unsigned int nevents);
107
108     /*
109      * An iso packet mostly consists of multiple events.  m_event_size
110      * is the size of a single 'event' in bytes.
111      */
112     unsigned int m_event_size;
113
114     // Keep track of transmission data block count
115     unsigned int m_tx_dbc;
116
117     // A simple circular buffer for outgoing MIDI data to allow
118     // a rate control to be implemented on the data to suit the MOTU
119     // devices.  Note that this buffer's size is forced to be a power
120     // of 2 to allow for buffer manipulation optimisations.
121     #define MIDIBUFFER_SIZE_EXP 10
122     #define MIDIBUFFER_SIZE     (1<<MIDIBUFFER_SIZE_EXP)
123     unsigned int midibuffer[MIDIBUFFER_SIZE];
124     unsigned int mb_head, mb_tail;
125     unsigned int midi_lock;
126     unsigned int midi_tx_period; /* Measured in audio clock periods */
127 };
128
129 } // end of namespace Streaming
130
131 #endif /* __FFADO_MOTUTRANSMITSTREAMPROCESSOR__ */
132
Note: See TracBrowser for help on using the browser.