|
@@ -1,57 +1,57 @@
|
1
|
|
-/// \file cmAudioSys.h
|
2
|
|
-/// \brief Implements a real-time audio processing engine.
|
3
|
|
-///
|
4
|
|
-/// The audio system is composed a collection of independent sub-systems.
|
5
|
|
-/// Each sub-system maintains a thread which runs asynchrounsly
|
6
|
|
-/// from the application, the MIDI devices, and the audio devices.
|
7
|
|
-/// To faciliate communication between these components each sub-system maintains
|
8
|
|
-/// two thread-safe data buffers one for control information and a second
|
9
|
|
-/// for audio data.
|
10
|
|
-///
|
11
|
|
-/// The audio devices are the primary driver for the system.
|
12
|
|
-/// Callbacks from the audio devices (See #cmApCallbackPtr_t)
|
13
|
|
-/// inserts incoming audio samples into the audio
|
14
|
|
-/// record buffers and extracts samples from the playback buffer.
|
15
|
|
-/// When sufficient incoming samples and outgoing empty buffer space exists
|
16
|
|
-/// a sub-system thread is waken up by the callback. This triggers a DSP audio
|
17
|
|
-/// processing cycle which empties/fills the audio buffers. During a DSP
|
18
|
|
-/// processing cycle control messages from the application and MIDI are blocked and
|
19
|
|
-/// buffered. Upon completetion of the DSP cycle a control message
|
20
|
|
-/// transfer cycles occurs - buffered incoming messages are passed to
|
21
|
|
-/// the DSP system and messages originating in the DSP system are
|
22
|
|
-/// buffered by the audio system for later pickup by the application
|
23
|
|
-/// or MIDI system.
|
24
|
|
-///
|
25
|
|
-/// Note that control messages that arrive when the DSP cycle is not
|
26
|
|
-/// occurring can pass directly through to the DSP system.
|
27
|
|
-///
|
28
|
|
-/// The DSP system sends messages back to the host by calling
|
29
|
|
-/// cmAsDspToHostFunc_t provided by cmAudioSysCtx_t. These
|
30
|
|
-/// calls are always made from within an audio system call to
|
31
|
|
-/// audio or control update within cmAsCallback_t. cmAsDspToHostFunc_t
|
32
|
|
-/// simply stores the message in a message buffer. The host picks
|
33
|
|
-/// up the message at some later time when it notices that messages
|
34
|
|
-/// are waiting via polling cmAudioSysIsMsgWaiting().
|
35
|
|
-///
|
36
|
|
-/// Implementation: \n
|
37
|
|
-/// The audio sub-systems work by maintaining an internal thread
|
38
|
|
-/// which blocks on a mutex condition variable.
|
39
|
|
-/// While the thread is blocked the mutex is unlocked allowing messages
|
40
|
|
-/// to pass directly through to the DSP procedure via cmAsCallback().
|
41
|
|
-///
|
42
|
|
-/// Periodic calls from running audio devices update the audio buffer.
|
43
|
|
-/// When the audio buffer has input samples waiting and output space
|
44
|
|
-/// available the condition variable is signaled, the mutex is
|
45
|
|
-/// then automatically locked by the system, and the DSP execution
|
46
|
|
-/// procedure is called via cmAsCallback().
|
47
|
|
-///
|
48
|
|
-/// Messages arriving while the mutex is locked are queued and
|
49
|
|
-/// delivered to the DSP procedure at the end of the DSP execution
|
50
|
|
-/// procedure.
|
51
|
|
-///
|
52
|
|
-/// Usage example and testing code:
|
53
|
|
-/// See cmAudioSysTest().
|
54
|
|
-/// \snippet cmAudioSys.c cmAudioSysTest
|
|
1
|
+// cmAudioSys.h
|
|
2
|
+// Implements a real-time audio processing engine.
|
|
3
|
+//
|
|
4
|
+// The audio system is composed a collection of independent sub-systems.
|
|
5
|
+// Each sub-system maintains a thread which runs asynchrounsly
|
|
6
|
+// from the application, the MIDI devices, and the audio devices.
|
|
7
|
+// To faciliate communication between these components each sub-system maintains
|
|
8
|
+// two thread-safe data buffers one for control information and a second
|
|
9
|
+// for audio data.
|
|
10
|
+//
|
|
11
|
+// The audio devices are the primary driver for the system.
|
|
12
|
+// Callbacks from the audio devices (See #cmApCallbackPtr_t)
|
|
13
|
+// inserts incoming audio samples into the audio
|
|
14
|
+// record buffers and extracts samples from the playback buffer.
|
|
15
|
+// When sufficient incoming samples and outgoing empty buffer space exists
|
|
16
|
+// a sub-system thread is waken up by the callback. This triggers a DSP audio
|
|
17
|
+// processing cycle which empties/fills the audio buffers. During a DSP
|
|
18
|
+// processing cycle control messages from the application and MIDI are blocked and
|
|
19
|
+// buffered. Upon completetion of the DSP cycle a control message
|
|
20
|
+// transfer cycles occurs - buffered incoming messages are passed to
|
|
21
|
+// the DSP system and messages originating in the DSP system are
|
|
22
|
+// buffered by the audio system for later pickup by the application
|
|
23
|
+// or MIDI system.
|
|
24
|
+//
|
|
25
|
+// Note that control messages that arrive when the DSP cycle is not
|
|
26
|
+// occurring can pass directly through to the DSP system.
|
|
27
|
+//
|
|
28
|
+// The DSP system sends messages back to the host by calling
|
|
29
|
+// cmAsDspToHostFunc_t provided by cmAudioSysCtx_t. These
|
|
30
|
+// calls are always made from within an audio system call to
|
|
31
|
+// audio or control update within cmAsCallback_t. cmAsDspToHostFunc_t
|
|
32
|
+// simply stores the message in a message buffer. The host picks
|
|
33
|
+// up the message at some later time when it notices that messages
|
|
34
|
+// are waiting via polling cmAudioSysIsMsgWaiting().
|
|
35
|
+//
|
|
36
|
+// Implementation: \n
|
|
37
|
+// The audio sub-systems work by maintaining an internal thread
|
|
38
|
+// which blocks on a mutex condition variable.
|
|
39
|
+// While the thread is blocked the mutex is unlocked allowing messages
|
|
40
|
+// to pass directly through to the DSP procedure via cmAsCallback().
|
|
41
|
+//
|
|
42
|
+// Periodic calls from running audio devices update the audio buffer.
|
|
43
|
+// When the audio buffer has input samples waiting and output space
|
|
44
|
+// available the condition variable is signaled, the mutex is
|
|
45
|
+// then automatically locked by the system, and the DSP execution
|
|
46
|
+// procedure is called via cmAsCallback().
|
|
47
|
+//
|
|
48
|
+// Messages arriving while the mutex is locked are queued and
|
|
49
|
+// delivered to the DSP procedure at the end of the DSP execution
|
|
50
|
+// procedure.
|
|
51
|
+//
|
|
52
|
+// Usage example and testing code:
|
|
53
|
+// See cmAudioSysTest().
|
|
54
|
+// \snippet cmAudioSys.c cmAudioSysTest
|
55
|
55
|
|
56
|
56
|
#ifndef cmAudioSys_h
|
57
|
57
|
#define cmAudioSys_h
|
|
@@ -60,7 +60,7 @@
|
60
|
60
|
extern "C" {
|
61
|
61
|
#endif
|
62
|
62
|
|
63
|
|
- /// Audio system result codes
|
|
63
|
+ // Audio system result codes
|
64
|
64
|
enum
|
65
|
65
|
{
|
66
|
66
|
kOkAsRC = cmOkRC,
|
|
@@ -81,213 +81,204 @@ extern "C" {
|
81
|
81
|
kNotInitAsRC
|
82
|
82
|
};
|
83
|
83
|
|
84
|
|
- typedef cmHandle_t cmAudioSysH_t; ///< Audio system handle type
|
85
|
|
- typedef unsigned cmAsRC_t; ///< Audio system result code
|
|
84
|
+ typedef cmHandle_t cmAudioSysH_t; //< Audio system handle type
|
|
85
|
+ typedef unsigned cmAsRC_t; //< Audio system result code
|
86
|
86
|
|
87
|
87
|
struct cmAudioSysCtx_str;
|
88
|
88
|
|
89
|
|
- ///
|
90
|
|
- /// DSP system callback function.
|
91
|
|
- ///
|
92
|
|
- /// This is the sole point of entry into the DSP system while the audio system is running.
|
93
|
|
- ///
|
94
|
|
- /// ctxPtr is pointer to a cmAudioSysCtx_t record.
|
95
|
|
- ///
|
96
|
|
- /// This function is called under two circumstances:
|
97
|
|
- ///
|
98
|
|
- /// 1) To notify the DSP system that the audio input/output buffers need to be serviced.
|
99
|
|
- /// This is a perioidic request which the DSP system uses as its execution trigger.
|
100
|
|
- /// The msgByteCnt argument is set to zero to indicate this type of call.
|
101
|
|
- ///
|
102
|
|
- /// 2) To pass messages from the host application to the DSP system.
|
103
|
|
- /// The DSP system is asyncronous with the host because it executes in the audio system thread
|
104
|
|
- /// rather than the host thread. The cmAudioSysDeliverMsg() function synchronizes incoming
|
105
|
|
- /// messages with the internal audio system thread to prevent thread collisions.
|
106
|
|
- ///
|
107
|
|
- /// Notes:
|
108
|
|
- /// This callback is always made with the internal audio system mutex locked.
|
109
|
|
- ///
|
110
|
|
- /// The signal time covered by the callback is from
|
111
|
|
- /// ctx->begSmpIdx to ctx->begSmpIdx+cfg->dspFramesPerCycle.
|
112
|
|
- ///
|
113
|
|
- /// The return value is currently not used.
|
|
89
|
+ //
|
|
90
|
+ // DSP system callback function.
|
|
91
|
+ //
|
|
92
|
+ // This is the sole point of entry into the DSP system while the audio system is running.
|
|
93
|
+ //
|
|
94
|
+ // ctxPtr is pointer to a cmAudioSysCtx_t record.
|
|
95
|
+ //
|
|
96
|
+ // This function is called under two circumstances:
|
|
97
|
+ //
|
|
98
|
+ // 1) To notify the DSP system that the audio input/output buffers need to be serviced.
|
|
99
|
+ // This is a perioidic request which the DSP system uses as its execution trigger.
|
|
100
|
+ // cmAudioSysCtx_t.audioRateFl is set to true to indicate this type of callback.
|
|
101
|
+ //
|
|
102
|
+ // 2) To pass messages from the host application to the DSP system.
|
|
103
|
+ // The DSP system is asyncronous with the host because it executes in the
|
|
104
|
+ // audio system thread rather than the host thread. The cmAudioSysDeliverMsg()
|
|
105
|
+ // function synchronizes incoming messages with the internal audio system
|
|
106
|
+ // thread to prevent thread collisions.
|
|
107
|
+ //
|
|
108
|
+ // Notes:
|
|
109
|
+ // This callback is always made with the internal audio system mutex locked.
|
|
110
|
+ //
|
|
111
|
+ // The signal time covered by the callback is from
|
|
112
|
+ // ctx->begSmpIdx to ctx->begSmpIdx+cfg->dspFramesPerCycle.
|
|
113
|
+ //
|
|
114
|
+ // The return value is currently not used.
|
114
|
115
|
typedef cmRC_t (*cmAsCallback_t)(void* ctxPtr, unsigned msgByteCnt, const void* msgDataPtr );
|
115
|
116
|
|
116
|
117
|
|
117
|
|
- /// Audio device sub-sytem configuration record
|
118
|
|
- typedef struct
|
|
118
|
+ // Audio device sub-sytem configuration record
|
|
119
|
+ typedef struct cmAudioSysArgs_str
|
119
|
120
|
{
|
120
|
|
- cmRpt_t* rpt; ///< system console object
|
121
|
|
- unsigned inDevIdx; ///< input audio device
|
122
|
|
- unsigned outDevIdx; ///< output audio device
|
123
|
|
- bool syncInputFl; ///< true/false sync the DSP update callbacks with audio input/output
|
124
|
|
- unsigned msgQueueByteCnt; ///< Size of the internal msg queue used to buffer msgs arriving via cmAudioSysDeliverMsg().
|
125
|
|
- unsigned devFramesPerCycle; ///< (512) Audio device samples per channel per device update buffer.
|
126
|
|
- unsigned dspFramesPerCycle; ///< (64) Audio samples per channel per DSP cycle.
|
127
|
|
- unsigned audioBufCnt; ///< (3) Audio device buffers.
|
128
|
|
- double srate; ///< Audio sample rate.
|
|
121
|
+ cmRpt_t* rpt; // system console object
|
|
122
|
+ unsigned inDevIdx; // input audio device
|
|
123
|
+ unsigned outDevIdx; // output audio device
|
|
124
|
+ bool syncInputFl; // true/false sync the DSP update callbacks with audio input/output
|
|
125
|
+ unsigned msgQueueByteCnt; // Size of the internal msg queue used to buffer msgs arriving via cmAudioSysDeliverMsg().
|
|
126
|
+ unsigned devFramesPerCycle; // (512) Audio device samples per channel per device update buffer.
|
|
127
|
+ unsigned dspFramesPerCycle; // (64) Audio samples per channel per DSP cycle.
|
|
128
|
+ unsigned audioBufCnt; // (3) Audio device buffers.
|
|
129
|
+ double srate; // Audio sample rate.
|
129
|
130
|
} cmAudioSysArgs_t;
|
130
|
131
|
|
131
|
|
- /// Audio sub-system configuration record.
|
132
|
|
- /// This record is provided by the host to configure the audio system
|
133
|
|
- /// via cmAudioSystemAllocate() or cmAudioSystemInitialize().
|
|
132
|
+ // Audio sub-system configuration record.
|
|
133
|
+ // This record is provided by the host to configure the audio system
|
|
134
|
+ // via cmAudioSystemAllocate() or cmAudioSystemInitialize().
|
134
|
135
|
typedef struct cmAudioSysSubSys_str
|
135
|
136
|
{
|
136
|
|
- cmAudioSysArgs_t args; ///< Audio device configuration
|
137
|
|
- cmAsCallback_t cbFunc; ///< DSP system entry point function.
|
138
|
|
- void* cbDataPtr; ///< Host provided data for the DSP system callback.
|
|
137
|
+ cmAudioSysArgs_t args; // Audio device configuration
|
|
138
|
+ cmAsCallback_t cbFunc; // DSP system entry point function.
|
|
139
|
+ void* cbDataPtr; // Host provided data for the DSP system callback.
|
139
|
140
|
} cmAudioSysSubSys_t;
|
140
|
141
|
|
141
|
142
|
|
142
|
|
- /// Signature of a callback function provided by the audio system to receive messages
|
143
|
|
- /// from the DSP system for later dispatch to the host application.
|
144
|
|
- /// This declaration is used by the DSP system implementation and the audio system.
|
145
|
|
- /// Note that this function is intended to convey one message broken into multiple parts.
|
146
|
|
- /// See cmTsQueueEnqueueSegMsg() for the equivalent interface.
|
|
143
|
+ // Signature of a callback function provided by the audio system to receive messages
|
|
144
|
+ // from the DSP system for later dispatch to the host application.
|
|
145
|
+ // This declaration is used by the DSP system implementation and the audio system.
|
|
146
|
+ // Note that this function is intended to convey one message broken into multiple parts.
|
|
147
|
+ // See cmTsQueueEnqueueSegMsg() for the equivalent interface.
|
147
|
148
|
typedef cmAsRC_t (*cmAsDspToHostFunc_t)(struct cmAudioSysCtx_str* p, const void* msgDataPtrArray[], unsigned msgByteCntArray[], unsigned msgSegCnt);
|
148
|
149
|
|
149
|
|
- /// Informational record passed with each call to the DSP callback function cmAsCallback_t
|
|
150
|
+ // Record passed with each call to the DSP callback function cmAsCallback_t
|
150
|
151
|
typedef struct cmAudioSysCtx_str
|
151
|
152
|
{
|
152
|
|
- void* reserved; ///< used internally by the system
|
|
153
|
+ void* reserved; // used internally by the audio system
|
153
|
154
|
|
154
|
|
- bool audioRateFl;
|
|
155
|
+ bool audioRateFl; // true if this is an audio update callback
|
155
|
156
|
|
156
|
|
- unsigned srcNetNodeId; ///<
|
157
|
|
- unsigned asSubIdx; ///< index of the sub-system this DSP process is serving
|
|
157
|
+ unsigned srcNetNodeId; // Source net node if this is a msg callback originating from a remote network node.
|
|
158
|
+ unsigned asSubIdx; // index of the sub-system this DSP process is serving
|
158
|
159
|
|
159
|
|
- cmAudioSysSubSys_t* ss; ///< ptr to a copy of the cfg recd used to initialize the audio system
|
160
|
|
- unsigned begSmpIdx; ///< gives signal time as a sample count
|
|
160
|
+ cmAudioSysSubSys_t* ss; // ptr to a copy of the cfg recd used to initialize the audio system
|
|
161
|
+ unsigned begSmpIdx; // gives signal time as a sample count
|
161
|
162
|
|
162
|
|
- cmAsDspToHostFunc_t dspToHostFunc; ///< Callback used by the DSP process to send messages to the host
|
163
|
|
- ///< via the audio system. Returns a cmAsRC_t result code.
|
|
163
|
+ cmAsDspToHostFunc_t dspToHostFunc; // Callback used by the DSP process to send messages to the host
|
|
164
|
+ // via the audio system. Returns a cmAsRC_t result code.
|
164
|
165
|
|
165
|
|
- ///< output (playback) buffers
|
166
|
|
- cmSample_t** oChArray; ///< each ele is a ptr to buffer with cfg.dspFramesPerCycle samples
|
167
|
|
- unsigned oChCnt; ///< count of output channels (ele's in oChArray[])
|
|
166
|
+ // output (playback) buffers
|
|
167
|
+ cmSample_t** oChArray; // each ele is a ptr to buffer with cfg.dspFramesPerCycle samples
|
|
168
|
+ unsigned oChCnt; // count of output channels (ele's in oChArray[])
|
168
|
169
|
|
169
|
|
- ///< input (recording) buffers
|
170
|
|
- cmSample_t** iChArray; ///< each ele is a ptr to buffer with cfg.dspFramesPerCycle samples
|
171
|
|
- unsigned iChCnt; ///< count of input channels (ele's in iChArray[])
|
|
170
|
+ // input (recording) buffers
|
|
171
|
+ cmSample_t** iChArray; // each ele is a ptr to buffer with cfg.dspFramesPerCycle samples
|
|
172
|
+ unsigned iChCnt; // count of input channels (ele's in iChArray[])
|
172
|
173
|
|
173
|
174
|
} cmAudioSysCtx_t;
|
174
|
175
|
|
175
|
|
- /*
|
176
|
|
- typedef struct
|
177
|
|
- {
|
178
|
|
- const cmChar_t* devLabel;
|
179
|
|
- const cmChar_t* inAudioFn;
|
180
|
|
- const cmChar_t* outAudioFn;
|
181
|
|
- unsigned oBits;
|
182
|
|
- unsigned oChCnt;
|
183
|
|
- } cmAudioSysFilePort_t;
|
184
|
|
- */
|
185
|
|
-
|
186
|
|
- /// Audio system configuration record used by cmAudioSysAllocate().
|
|
176
|
+
|
|
177
|
+ // Audio system configuration record used by cmAudioSysAllocate().
|
187
|
178
|
typedef struct cmAudioSysCfg_str
|
188
|
179
|
{
|
189
|
|
- cmAudioSysSubSys_t* ssArray; ///< sub-system cfg record array
|
190
|
|
- unsigned ssCnt; ///< count of sub-systems
|
191
|
|
- //cmAudioSysFilePort_t* afpArray; ///< audio port file cfg recd array
|
192
|
|
- //unsigned afpCnt; ///< audio port file cnt
|
193
|
|
- unsigned meterMs; ///< Meter sample period in milliseconds
|
194
|
|
- void* clientCbData; ///< User arg. for clientCbFunc().
|
195
|
|
- cmTsQueueCb_t clientCbFunc; ///< Called by cmAudioSysReceiveMsg() to deliver internally generated msg's to the host.
|
196
|
|
- /// Set to NULL if msg's will be directly returned by buffers passed to cmAudioSysReceiveMsg().
|
|
180
|
+ cmAudioSysSubSys_t* ssArray; // sub-system cfg record array
|
|
181
|
+ unsigned ssCnt; // count of sub-systems
|
|
182
|
+ unsigned meterMs; // Meter sample period in milliseconds
|
|
183
|
+ void* clientCbData; // User arg. for clientCbFunc().
|
|
184
|
+ cmTsQueueCb_t clientCbFunc; // Called by cmAudioSysReceiveMsg() to deliver internally generated msg's to the host.
|
|
185
|
+ // Set to NULL if msg's will be directly returned by buffers passed to cmAudioSysReceiveMsg().
|
197
|
186
|
cmUdpNetH_t netH;
|
198
|
187
|
} cmAudioSysCfg_t;
|
199
|
188
|
|
200
|
189
|
extern cmAudioSysH_t cmAudioSysNullHandle;
|
201
|
190
|
|
202
|
|
- /// Allocate and initialize an audio system as a collection of 'cfgCnt' sub-systems.
|
203
|
|
- /// Notes:
|
204
|
|
- /// The audio ports system must be initalized (via cmApInitialize()) prior to calling cmAudioSysAllocate().
|
205
|
|
- /// The MIDI port system must be initialized (via cmMpInitialize()) prior to calling cmAudioSysAllocate().
|
206
|
|
- /// Furthermore cmApFinalize() and cmMpFinalize() cannot be called prior to cmAudioSysFree().
|
207
|
|
- /// See cmAudioSystemTest() for a complete example.
|
|
191
|
+ // Allocate and initialize an audio system as a collection of 'cfgCnt' sub-systems.
|
|
192
|
+ // Prior to call this function the audio audio ports system must be initalized
|
|
193
|
+ // (via cmApInitialize()) and the MIDI port system must be initialized
|
|
194
|
+ // (via cmMpInitialize()). Note also that cmApFinalize() and cmMpFinalize()
|
|
195
|
+ // cannot be called prior to cmAudioSysFree().
|
|
196
|
+ // See cmAudioSystemTest() for a complete example.
|
208
|
197
|
cmAsRC_t cmAudioSysAllocate( cmAudioSysH_t* hp, cmRpt_t* rpt, const cmAudioSysCfg_t* cfg );
|
209
|
198
|
|
210
|
|
- /// Finalize and release any resources held by the audio system.
|
|
199
|
+ // Finalize and release any resources held by the audio system.
|
211
|
200
|
cmAsRC_t cmAudioSysFree( cmAudioSysH_t* hp );
|
212
|
201
|
|
213
|
|
- /// Returns true if 'h' is a handle which was successfully allocated by cmAudioSysAllocate().
|
|
202
|
+ // Returns true if 'h' is a handle which was successfully allocated by
|
|
203
|
+ // cmAudioSysAllocate().
|
214
|
204
|
bool cmAudioSysHandleIsValid( cmAudioSysH_t h );
|
215
|
205
|
|
216
|
|
- /// Reinitialize a previously allocated audio system. This function
|
217
|
|
- /// begins with a call to cmAudioSysFinalize().
|
218
|
|
- /// Use cmAudioSysEnable(h,true) to begin processing audio following this call.
|
|
206
|
+ // Reinitialize a previously allocated audio system. This function
|
|
207
|
+ // begins with a call to cmAudioSysFinalize().
|
|
208
|
+ // Use cmAudioSysEnable(h,true) to begin processing audio following this call.
|
219
|
209
|
cmAsRC_t cmAudioSysInitialize( cmAudioSysH_t h, const cmAudioSysCfg_t* cfg );
|
220
|
210
|
|
221
|
|
- /// Complements cmAudioSysInitialize(). In general there is no need to call this function
|
222
|
|
- /// since calls to cmAudioSysInitialize() and cmAudioSysFree() automaticatically call it.
|
|
211
|
+ // Complements cmAudioSysInitialize(). In general there is no need to call this function
|
|
212
|
+ // since calls to cmAudioSysInitialize() and cmAudioSysFree() automaticatically call it.
|
223
|
213
|
cmAsRC_t cmAudioSysFinalize( cmAudioSysH_t h );
|
224
|
214
|
|
225
|
|
- /// Returns true if the audio system has been successfully initialized.
|
|
215
|
+ // Returns true if the audio system has been successfully initialized.
|
226
|
216
|
bool cmAudioSysIsInitialized( cmAudioSysH_t );
|
227
|
217
|
|
228
|
|
- /// Returns true if the audio system is enabled.
|
|
218
|
+ // Returns true if the audio system is enabled.
|
229
|
219
|
bool cmAudioSysIsEnabled( cmAudioSysH_t h );
|
230
|
220
|
|
231
|
|
- /// Enable/disable the audio system. Enabling the starts audio stream
|
232
|
|
- /// in/out of the system.
|
|
221
|
+ // Enable/disable the audio system. Enabling the starts audio stream
|
|
222
|
+ // in/out of the system.
|
233
|
223
|
cmAsRC_t cmAudioSysEnable( cmAudioSysH_t h, bool enableFl );
|
234
|
224
|
|
235
|
|
- /// \name Host to DSP delivery functions
|
236
|
|
- /// @{
|
237
|
|
-
|
238
|
|
- /// Deliver a message from the host application to the DSP process. (host -> DSP);
|
239
|
|
- /// The message is formed as a concatenation of the bytes in each of the segments
|
240
|
|
- /// pointed to by 'msgDataPtrArrary[segCnt][msgByteCntArray[segCnt]'.
|
241
|
|
- /// This is the canonical msg delivery function in so far as the other host->DSP
|
242
|
|
- /// msg delivery function are written in terms of this function.
|
243
|
|
- /// The first 4 bytes in the first segment must contain the index of the audio sub-system
|
244
|
|
- /// which is to receive the message.
|
|
225
|
+ //
|
|
226
|
+ // Host to DSP delivery functions
|
|
227
|
+ //
|
|
228
|
+
|
|
229
|
+ // Deliver a message from the host application to the DSP process. (host -> DSP);
|
|
230
|
+ // The message is formed as a concatenation of the bytes in each of the segments
|
|
231
|
+ // pointed to by 'msgDataPtrArrary[segCnt][msgByteCntArray[segCnt]'.
|
|
232
|
+ // This is the canonical msg delivery function in so far as the other host->DSP
|
|
233
|
+ // msg delivery function are written in terms of this function.
|
|
234
|
+ // The first 4 bytes in the first segment must contain the index of the audio sub-system
|
|
235
|
+ // which is to receive the message.
|
245
|
236
|
cmAsRC_t cmAudioSysDeliverSegMsg( cmAudioSysH_t h, const void* msgDataPtrArray[], unsigned msgByteCntArray[], unsigned msgSegCnt, unsigned srcNetNodeId );
|
246
|
237
|
|
247
|
|
- /// Deliver a single message from the host to the DSP system.
|
|
238
|
+ // Deliver a single message from the host to the DSP system.
|
248
|
239
|
cmAsRC_t cmAudioSysDeliverMsg( cmAudioSysH_t h, const void* msgPtr, unsigned msgByteCnt, unsigned srcNetNodeId );
|
249
|
240
|
|
250
|
|
- /// Deliver a single message from the host to the DSP system.
|
251
|
|
- /// Prior to delivery the 'id' is prepended to the message.
|
|
241
|
+ // Deliver a single message from the host to the DSP system.
|
|
242
|
+ // Prior to delivery the 'id' is prepended to the message.
|
252
|
243
|
cmAsRC_t cmAudioSysDeliverIdMsg( cmAudioSysH_t h, unsigned asSubIdx, unsigned id, const void* msgPtr, unsigned msgByteCnt, unsigned srcNetNodeId );
|
253
|
|
- ///@}
|
254
|
244
|
|
255
|
|
- /// \name DSP to Host message functions
|
256
|
|
- /// @{
|
257
|
245
|
|
258
|
|
- /// Is a msg from the DSP waiting to be picked up by the host? (host <- DSP)
|
259
|
|
- /// 0 = no msgs are waiting or the msg queue is locked by the DSP process.
|
260
|
|
- /// >0 = the size of the buffer required to hold the next msg returned via
|
261
|
|
- /// cmAudioSysReceiveMsg().
|
|
246
|
+ //
|
|
247
|
+ // DSP to Host message functions
|
|
248
|
+ //
|
|
249
|
+
|
|
250
|
+ // Is a msg from the DSP waiting to be picked up by the host? (host <- DSP)
|
|
251
|
+ // 0 = no msgs are waiting or the msg queue is locked by the DSP process.
|
|
252
|
+ // >0 = the size of the buffer required to hold the next msg returned via
|
|
253
|
+ // cmAudioSysReceiveMsg().
|
262
|
254
|
unsigned cmAudioSysIsMsgWaiting( cmAudioSysH_t h );
|
263
|
255
|
|
264
|
|
- /// Copy the next available msg sent from the DSP process to the host into the host supplied msg buffer
|
265
|
|
- /// pointed to by 'msgBufPtr'. Set 'msgDataPtr' to NULL to receive msg by callback from cmAudioSysCfg_t.clientCbFunc.
|
266
|
|
- /// Returns kBufTooSmallAsRC if msgDataPtr[msgByteCnt] is too small to hold the msg.
|
267
|
|
- /// Returns kNoMsgWaitingAsRC if no messages are waiting for delivery or the msg queue is locked by the DSP process.
|
268
|
|
- /// Returns kOkAsRC if a msg was delivered.
|
269
|
|
- /// Call cmAudioSysIsMsgWaiting() prior to calling this function to get
|
270
|
|
- /// the size of the data buffer required to hold the next message.
|
|
256
|
+ // Copy the next available msg sent from the DSP process to the host into the host supplied msg buffer
|
|
257
|
+ // pointed to by 'msgBufPtr'. Set 'msgDataPtr' to NULL to receive msg by callback from cmAudioSysCfg_t.clientCbFunc.
|
|
258
|
+ // Returns kBufTooSmallAsRC if msgDataPtr[msgByteCnt] is too small to hold the msg.
|
|
259
|
+ // Returns kNoMsgWaitingAsRC if no messages are waiting for delivery or the msg queue is locked by the DSP process.
|
|
260
|
+ // Returns kOkAsRC if a msg was delivered.
|
|
261
|
+ // Call cmAudioSysIsMsgWaiting() prior to calling this function to get
|
|
262
|
+ // the size of the data buffer required to hold the next message.
|
271
|
263
|
cmAsRC_t cmAudioSysReceiveMsg( cmAudioSysH_t h, void* msgDataPtr, unsigned msgByteCnt );
|
272
|
|
- /// @}
|
273
|
264
|
|
274
|
265
|
|
275
|
|
- /// Fill an audio system status record.
|
|
266
|
+ // Fill an audio system status record.
|
276
|
267
|
void cmAudioSysStatus( cmAudioSysH_t h, unsigned asSubIdx, cmAudioSysStatus_t* statusPtr );
|
277
|
268
|
|
278
|
|
- /// Enable cmAudioSysStatus_t notifications to be sent periodically to the host.
|
279
|
|
- /// Set asSubIdx to cmInvalidIdx to enable/disable all sub-systems.
|
280
|
|
- /// The notifications occur approximately every cmAudioSysCfg_t.meterMs milliseconds.
|
|
269
|
+ // Enable cmAudioSysStatus_t notifications to be sent periodically to the host.
|
|
270
|
+ // Set asSubIdx to cmInvalidIdx to enable/disable all sub-systems.
|
|
271
|
+ // The notifications occur approximately every cmAudioSysCfg_t.meterMs milliseconds.
|
281
|
272
|
void cmAudioSysStatusNotifyEnable( cmAudioSysH_t, unsigned asSubIdx, bool enableFl );
|
282
|
273
|
|
283
|
|
- /// Return a pointer the context record associated with a sub-system
|
|
274
|
+ // Return a pointer the context record associated with a sub-system
|
284
|
275
|
cmAudioSysCtx_t* cmAudioSysContext( cmAudioSysH_t h, unsigned asSubIdx );
|
285
|
276
|
|
286
|
|
- /// Return the count of audio sub-systems.
|
287
|
|
- /// This is the same as the count of cfg recds passed to cmAudioSystemInitialize().
|
|
277
|
+ // Return the count of audio sub-systems.
|
|
278
|
+ // This is the same as the count of cfg recds passed to cmAudioSystemInitialize().
|
288
|
279
|
unsigned cmAudioSysSubSystemCount( cmAudioSysH_t h );
|
289
|
280
|
|
290
|
|
- /// Audio system test and example function.
|
|
281
|
+ // Audio system test and example function.
|
291
|
282
|
void cmAudioSysTest( cmRpt_t* rpt, int argc, const char* argv[] );
|
292
|
283
|
|
293
|
284
|
|