root/trunk/libffado/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.h

Revision 2802, 4.4 kB (checked in by jwoithe, 3 years ago)

Cosmetic: "Firewire" becomes "FireWire?".

Officially both the "F" and "W" were capitalised in the FireWire? name, so
reflect this throughout FFADO's source tree. This mostly affects comments.

This patch originated from pander on the ffado-devel mailing list. To
maintain consistency, the committed version has been expanded to include
files not originally included in the original patch.

Line 
1 /*
2  * Copyright (C) 2005-2008 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 program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 2 of the License, or
12  * (at your option) version 3 of the License.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #ifndef __FFADO_AMDTPRECEIVESTREAMPROCESSOR__
25 #define __FFADO_AMDTPRECEIVESTREAMPROCESSOR__
26
27 /**
28  * This class implements IEC61883-6 / AM824 / AMDTP based streaming
29  */
30
31 #include "AmdtpStreamProcessor-common.h"
32
33 namespace Streaming {
34
35 class Port;
36 class AmdtpAudioPort;
37 class AmdtpMidiPort;
38 /*!
39 \brief The Base Class for an AMDTP receive stream processor
40
41  This class implements a ReceiveStreamProcessor that demultiplexes
42  AMDTP streams into Ports.
43
44 */
45 class AmdtpReceiveStreamProcessor
46     : public StreamProcessor
47 {
48
49 public:
50     /**
51      * Create a AMDTP receive StreamProcessor
52      * @param port 1394 port
53      * @param dimension number of substreams in the ISO stream
54      *                  (midi-muxed is only one stream)
55      */
56     AmdtpReceiveStreamProcessor(FFADODevice &parent, int dimension);
57     virtual ~AmdtpReceiveStreamProcessor() {};
58
59     virtual enum eChildReturnValue processPacketHeader(unsigned char *data, unsigned int length,
60                                                        unsigned char tag, unsigned char sy,
61                                                        uint32_t pkt_ctr);
62     virtual enum eChildReturnValue processPacketData(unsigned char *data, unsigned int length);
63
64     virtual bool prepareChild();
65
66 public:
67     virtual unsigned int getEventSize()
68                     {return 4;};
69     virtual unsigned int getMaxPacketSize()
70                     {return 4 * (2 + getSytInterval() * m_dimension);};
71     virtual unsigned int getEventsPerFrame()
72                     { return m_dimension; };
73     virtual unsigned int getNominalFramesPerPacket()
74                     {return getSytInterval();};
75
76
77 protected:
78     bool processReadBlock(char *data, unsigned int nevents, unsigned int offset);
79
80 protected:
81     void decodeAudioPortsFloat(quadlet_t *data, unsigned int offset, unsigned int nevents);
82     void decodeAudioPortsInt24(quadlet_t *data, unsigned int offset, unsigned int nevents);
83     void decodeMidiPorts(quadlet_t *data, unsigned int offset, unsigned int nevents);
84
85     unsigned int getSytInterval();
86
87     int m_dimension;
88     unsigned int m_syt_interval;
89
90 private: // local port caching for performance
91     struct _MBLA_port_cache {
92         AmdtpAudioPort*     port;
93         void*               buffer;
94         bool                enabled;
95 #ifdef DEBUG
96         unsigned int        buffer_size;
97 #endif
98     };
99     std::vector<struct _MBLA_port_cache> m_audio_ports;
100     unsigned int m_nb_audio_ports;
101
102     struct _MIDI_port_cache {
103         AmdtpMidiPort*      port;
104         void*               buffer;
105         bool                enabled;
106         unsigned int        position;
107         unsigned int        location;
108 #ifdef DEBUG
109         unsigned int        buffer_size;
110 #endif
111     };
112     std::vector<struct _MIDI_port_cache> m_midi_ports;
113     unsigned int m_nb_midi_ports;
114
115     /* A small MIDI buffer to cover for the case where we need to span a
116      * period - that is, if more than one MIDI byte is sent per packet.
117      * Since the long-term average data rate must be close to the MIDI spec
118      * (as it's coming from a physical MIDI port_ this buffer doesn't have
119      * to be particularly large.  The size is a power of 2 for optimisation
120      * reasons.
121      *
122      * FIXME: it is yet to be determined whether this is required for RME
123      * devices.
124      *
125      * FIXME: copied from RmeReceiveStreamProcessor.h. Needs refactoring
126      */
127 #define RX_MIDIBUFFER_SIZE_EXP 6
128 #define RX_MIDIBUFFER_SIZE     (1<<RX_MIDIBUFFER_SIZE_EXP)
129
130     unsigned int midibuffer[RX_MIDIBUFFER_SIZE];
131     unsigned mb_head, mb_tail;
132
133     bool initPortCache();
134     void updatePortCache();
135 };
136
137
138 } // end of namespace Streaming
139
140 #endif /* __FFADO_AMDTPRECEIVESTREAMPROCESSOR__ */
141
Note: See TracBrowser for help on using the browser.