root/trunk/libffado/src/libstreaming/motu/MotuTransmitStreamProcessor.h

Revision 857, 4.6 kB (checked in by ppalmers, 16 years ago)

Introduce distinction between empty and silent packets. When shutting down a transmit SP, we now send silent (= valid, but all audio muted) packets instead of empty (w/o
payload) packets for a while. This should solve the shutdown issue with the motu's.

Line 
1 /*
2  * Copyright (C) 2005-2007 by Jonathan Woithe
3  * Copyright (C) 2005-2007 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 3 of the License, or
13  * (at your option) any later version.
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
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                               int cycle, unsigned int dropped, unsigned int max_length);
63     enum eChildReturnValue generatePacketData(unsigned char *data, unsigned int *length,
64                             unsigned char *tag, unsigned char *sy,
65                             int cycle, unsigned int dropped, unsigned int max_length);
66     enum eChildReturnValue generateEmptyPacketHeader(unsigned char *data, unsigned int *length,
67                                     unsigned char *tag, unsigned char *sy,
68                                     int cycle, unsigned int dropped, unsigned int max_length);
69     enum eChildReturnValue generateEmptyPacketData(unsigned char *data, unsigned int *length,
70                                   unsigned char *tag, unsigned char *sy,
71                                   int cycle, unsigned int dropped, unsigned int max_length);
72     enum eChildReturnValue generateSilentPacketHeader(unsigned char *data, unsigned int *length,
73                                     unsigned char *tag, unsigned char *sy,
74                                     int cycle, unsigned int dropped, unsigned int max_length);
75     enum eChildReturnValue generateSilentPacketData(unsigned char *data, unsigned int *length,
76                                   unsigned char *tag, unsigned char *sy,
77                                   int cycle, unsigned int dropped, unsigned int max_length);
78     virtual bool prepareChild();
79
80 public:
81     virtual unsigned int getEventSize()
82                 {return m_event_size;};
83     virtual unsigned int getMaxPacketSize();
84     virtual unsigned int getEventsPerFrame()
85                     { return 1; }; // FIXME: check
86     virtual unsigned int getNominalFramesPerPacket();
87
88 protected:
89     bool processWriteBlock(char *data, unsigned int nevents, unsigned int offset);
90     bool transmitSilenceBlock(char *data, unsigned int nevents, unsigned int offset);
91
92 private:
93     unsigned int fillNoDataPacketHeader(quadlet_t *data, unsigned int* length);
94     unsigned int fillDataPacketHeader(quadlet_t *data, unsigned int* length, uint32_t ts);
95
96     int transmitBlock(char *data, unsigned int nevents,
97                         unsigned int offset);
98
99     bool encodePacketPorts(quadlet_t *data, unsigned int nevents,
100                            unsigned int dbc);
101
102     int encodePortToMotuEvents(MotuAudioPort *, quadlet_t *data,
103                                 unsigned int offset, unsigned int nevents);
104     int encodeSilencePortToMotuEvents(MotuAudioPort *, quadlet_t *data,
105                                 unsigned int offset, unsigned int nevents);
106
107     /*
108      * An iso packet mostly consists of multiple events.  m_event_size
109      * is the size of a single 'event' in bytes.
110      */
111     unsigned int m_event_size;
112
113     // Keep track of transmission data block count
114     unsigned int m_tx_dbc;
115
116 };
117
118 } // end of namespace Streaming
119
120 #endif /* __FFADO_MOTUTRANSMITSTREAMPROCESSOR__ */
121
Note: See TracBrowser for help on using the browser.