root/branches/libffado-2.0/src/libstreaming/amdtp/AmdtpReceiveStreamProcessor.h

Revision 1556, 3.7 kB (checked in by ppalmers, 12 years ago)

fixes #207

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     enum eChildReturnValue processPacketHeader(unsigned char *data, unsigned int length,
60                                                unsigned char tag, unsigned char sy,
61                                                uint32_t pkt_ctr);
62     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 protected:
77     bool processReadBlock(char *data, unsigned int nevents, unsigned int offset);
78
79 private:
80     void decodeAudioPortsFloat(quadlet_t *data, unsigned int offset, unsigned int nevents);
81     void decodeAudioPortsInt24(quadlet_t *data, unsigned int offset, unsigned int nevents);
82     void decodeMidiPorts(quadlet_t *data, unsigned int offset, unsigned int nevents);
83
84     unsigned int getSytInterval();
85
86     int m_dimension;
87     unsigned int m_syt_interval;
88
89 private: // local port caching for performance
90     struct _MBLA_port_cache {
91         AmdtpAudioPort*     port;
92         void*               buffer;
93         bool                enabled;
94 #ifdef DEBUG
95         unsigned int        buffer_size;
96 #endif
97     };
98     std::vector<struct _MBLA_port_cache> m_audio_ports;
99     unsigned int m_nb_audio_ports;
100
101     struct _MIDI_port_cache {
102         AmdtpMidiPort*      port;
103         void*               buffer;
104         bool                enabled;
105         unsigned int        position;
106         unsigned int        location;
107 #ifdef DEBUG
108         unsigned int        buffer_size;
109 #endif
110     };
111     std::vector<struct _MIDI_port_cache> m_midi_ports;
112     unsigned int m_nb_midi_ports;
113
114     bool initPortCache();
115     void updatePortCache();
116 };
117
118
119 } // end of namespace Streaming
120
121 #endif /* __FFADO_AMDTPRECEIVESTREAMPROCESSOR__ */
122
Note: See TracBrowser for help on using the browser.