Bladeren bron

cmAudioSys.c,cmAudioSysMsg.h,cmMsgProtocol.h: Removed cmAudioSys.c dependency on cmDspValue().

Removed cmAudioSys.c dependency on cmDspValue.h by changing the
host to audio system message format from cmDspUiHdr_t to cmAudioSysMstr_t.
All audio system message records are now isolated in cmAudioSysMsg.h
which cmMsgProtocol directly includes.
master
kevin 11 jaren geleden
bovenliggende
commit
2bc819afb9
3 gewijzigde bestanden met toevoegingen van 128 en 102 verwijderingen
  1. 13
    17
      cmAudioSys.c
  2. 113
    0
      cmAudioSysMsg.h
  3. 2
    85
      cmMsgProtocol.h

+ 13
- 17
cmAudioSys.c Bestand weergeven

@@ -9,15 +9,11 @@
9 9
 #include "cmAudioPort.h"
10 10
 #include "cmAudioPortFile.h"
11 11
 #include "cmApBuf.h"
12
-
13
-#include "cmJson.h"          // these files are 
14
-#include "dsp/cmDspValue.h"  // only required for
15
-#include "dsp/cmDspUi.h"     // UI building
16
-
12
+#include "cmJson.h"
17 13
 #include "cmThread.h"
18 14
 #include "cmUdpPort.h"
19 15
 #include "cmUdpNet.h"
20
-#include "cmMsgProtocol.h"
16
+#include "cmAudioSysMsg.h"
21 17
 #include "cmAudioSys.h"
22 18
 #include "cmMidi.h"
23 19
 #include "cmMidiPort.h"
@@ -155,10 +151,10 @@ cmAsRC_t _cmAsHostInitNotify( cmAs_t* p )
155 151
   return rc;
156 152
 }
157 153
 
158
-cmAsRC_t  _cmAsDispatchNonSubSysMsg(  cmAs_t* p, const void* msg, unsigned msgByteCnt )
154
+cmAsRC_t  _cmAsParseNonSubSysMsg(  cmAs_t* p, const void* msg, unsigned msgByteCnt )
159 155
 {
160 156
   cmAsRC_t rc = kOkAsRC;
161
-  cmDspUiHdr_t* h = (cmDspUiHdr_t*)msg;
157
+  cmAudioSysMstr_t* h = (cmAudioSysMstr_t*)msg;
162 158
   unsigned devIdx = cmAudioSysUiInstIdToDevIndex(h->instId);
163 159
   unsigned chIdx  = cmAudioSysUiInstIdToChIndex(h->instId);
164 160
   unsigned inFl   = cmAudioSysUiInstIdToInFlag(h->instId);
@@ -166,8 +162,8 @@ cmAsRC_t  _cmAsDispatchNonSubSysMsg(  cmAs_t* p, const void* msg, unsigned msgBy
166 162
 
167 163
   // if the valuu associated with this msg is a mtx then set
168 164
   // its mtx data area pointer to just after the msg header.
169
-  if( cmDsvIsMtx(&h->value) )
170
-    h->value.u.m.u.vp = ((char*)msg) + sizeof(cmDspUiHdr_t);
165
+  //if( cmDsvIsMtx(&h->value) )
166
+  //  h->value.u.m.u.vp = ((char*)msg) + sizeof(cmDspUiHdr_t);
171 167
 
172 168
   unsigned flags = inFl ? kInApFl : kOutApFl;
173 169
   
@@ -175,24 +171,24 @@ cmAsRC_t  _cmAsDispatchNonSubSysMsg(  cmAs_t* p, const void* msg, unsigned msgBy
175 171
   {
176 172
     
177 173
     case kSliderUiAsId: // slider
178
-      cmApBufSetGain(devIdx,chIdx, flags, cmDsvGetDouble(&h->value)); 
174
+      cmApBufSetGain(devIdx,chIdx, flags, h->value); 
179 175
       break;
180 176
       
181 177
     case kMeterUiAsId: // meter
182 178
       break;
183 179
       
184 180
     case kMuteUiAsId: // mute
185
-      flags += cmDsvGetDouble(&h->value) == 0 ? kEnableApFl : 0;
181
+      flags += h->value == 0 ? kEnableApFl : 0;
186 182
       cmApBufEnableChannel(devIdx,chIdx,flags);
187 183
       break;
188 184
 
189 185
     case kToneUiAsId: // tone
190
-      flags += cmDsvGetDouble(&h->value) > 0 ? kEnableApFl : 0;
186
+      flags += h->value > 0 ? kEnableApFl : 0;
191 187
       cmApBufEnableTone(devIdx,chIdx,flags);
192 188
       break;
193 189
 
194 190
     case kPassUiAsId: // pass
195
-      flags += cmDsvGetDouble(&h->value) > 0 ? kEnableApFl : 0;
191
+      flags += h->value > 0 ? kEnableApFl : 0;
196 192
       cmApBufEnablePass(devIdx,chIdx,flags);
197 193
       break;
198 194
 
@@ -210,7 +206,7 @@ cmAsRC_t  _cmAsHandleNonSubSysMsg(  cmAs_t* p, const void* msgDataPtrArray[], un
210 206
 
211 207
   // if the message is contained in a single segment it can be dispatched immediately ...
212 208
   if( msgSegCnt == 1 )
213
-    rc = _cmAsDispatchNonSubSysMsg(p,msgDataPtrArray[0],msgByteCntArray[0]);
209
+    rc = _cmAsParseNonSubSysMsg(p,msgDataPtrArray[0],msgByteCntArray[0]);
214 210
   else
215 211
   {
216 212
     // ... otherwise deserialize the message into contiguous memory ....
@@ -228,7 +224,7 @@ cmAsRC_t  _cmAsHandleNonSubSysMsg(  cmAs_t* p, const void* msgDataPtrArray[], un
228 224
       b += msgByteCntArray[i];
229 225
     }
230 226
     // ... and then dispatch it
231
-    rc = _cmAsDispatchNonSubSysMsg(p,buf,byteCnt);
227
+    rc = _cmAsParseNonSubSysMsg(p,buf,byteCnt);
232 228
 
233 229
   }
234 230
   
@@ -970,7 +966,7 @@ cmAsRC_t  cmAudioSysDeliverSegMsg(  cmAudioSysH_t h, const void* msgDataPtrArray
970 966
 
971 967
   // BUG BUG BUG - there is no reason that both the asSubIdx and the selId must
972 968
   // be in the first segment but it would be nice.
973
-  assert( msgByteCntArray[0] >= 2*sizeof(unsigned) );
969
+  assert( msgByteCntArray[0] >= 2*sizeof(unsigned) || (msgSegCnt>1 && msgByteCntArray[0]==sizeof(unsigned) && msgByteCntArray[1]>=sizeof(unsigned)) );
974 970
 
975 971
   // The audio sub-system index is always the first field of the msg 
976 972
   // and the msg selector id is always the second field

+ 113
- 0
cmAudioSysMsg.h Bestand weergeven

@@ -0,0 +1,113 @@
1
+#ifndef cmAudioSysMsg_h
2
+#define cmAudioSysMsg_h
3
+
4
+#ifdef __cplusplus
5
+extern "C" {
6
+#endif
7
+
8
+  /// Reserved DSP message selector id's (second field of all host<->audio system messages)
9
+  enum
10
+  {
11
+    kMidiMsgArraySelAsId = 1000,
12
+    kMidiSysExSelAsId,
13
+    kUiSelAsId,      // indicates a cmDspUiHdr_t msg
14
+    kUiMstrSelAsId,  // indicates a cmDspUiHdr_t msg containing master control information for the audio system
15
+    kSsInitSelAsId,  // indicates the msg is of type cmAudioSysSsInitMsg_t
16
+    kStatusSelAsId,  // indicates the msg is of type cmAudioSysStatus_t
17
+    kNetSyncSelAsId,   // sent with a cmDspNetMsg_t object  
18
+  };
19
+
20
+
21
+
22
+  // All of the UI messages that create a UI control contain an array of integers
23
+  // as in the 'value' field. The array contains the id's associated with
24
+  // the different programmable paramters which are part of the control.
25
+  // For example a slider control has minimum,maximum, step size, and value 
26
+  // parameters. The location in the array is hard coded according to the
27
+  // parameters meaning but the actual value of the id is left up to the 
28
+  // engine. This allows the engine to use whatever values work best for
29
+  // it on a per instance basis. 
30
+
31
+
32
+  // Header record for all messages between the host and the DSP controllers.
33
+  typedef struct
34
+  {
35
+    unsigned     asSubIdx;  // the audio sub-system this UI belongs to
36
+    unsigned     uiId;      // msg type kXXXAsId 
37
+    unsigned     selId;     // action to perform see above
38
+    unsigned     flags;     //
39
+    unsigned     instId;    // DSP instance id
40
+    unsigned     instVarId; // DSP instance var id
41
+    unsigned     rsrvd;
42
+    double       value;
43
+  } cmAudioSysMstr_t;
44
+
45
+
46
+  /// The cmDspUiHdr_t.instId of UI control messages associated with master
47
+  /// control encode the device,channel,in/out, and control type. These macros
48
+  /// should be used for encoding and decoding.
49
+#define cmAudioSysFormUiInstId(dev,ch,ifl,ctl) (((dev)<<16) + ((ch)<<4) + ((ifl)<<3) + (ctl))
50
+#define cmAudioSysUiInstIdToDevIndex(instId)  ( (instId) >> 16)
51
+#define cmAudioSysUiInstIdToChIndex(instId)   (((instId) &  0x0000ffff) >> 4)
52
+#define cmAudioSysUiInstIdToInFlag(instId)    ( (instId) &  0x08)
53
+#define cmAudioSysUiInstIdToCtlId(instId)     ( (instId) &  0x07)
54
+
55
+  /// Control id's used to identify the control type of master contols.
56
+  enum
57
+  {
58
+    kSliderUiAsId = 0,
59
+    kMeterUiAsId  = 1,
60
+    kMuteUiAsId   = 2,
61
+    kToneUiAsId   = 3,
62
+    kPassUiAsId   = 4
63
+  };
64
+
65
+
66
+  /// This message is transmitted to the host application just prior to returning
67
+  /// from cmAudioSysInitialize().
68
+  /// When transmitted to the host this record acts as a message header.
69
+  /// This header is followed by two zero terminated char arrays containing the device
70
+  /// labels associated with the input and output devices.
71
+  /// Message Layout: [ cmAudioSysInitMsg_t "In Device Label" "Out Device Label"]
72
+  typedef struct
73
+  {
74
+    unsigned asSubIdx;  ///< asSubIdx of this sub-system
75
+    unsigned selId;     ///< always kSsInitAsId
76
+    unsigned asSubCnt;  ///< count of sub-systems
77
+    unsigned inDevIdx;  ///< input device index
78
+    unsigned outDevIdx; ///< output device index
79
+    unsigned inChCnt;   ///< input device channel count
80
+    unsigned outChCnt;  ///< outut device channel count
81
+  } cmAudioSysSsInitMsg_t;
82
+
83
+  /// Audio sub-system status record - this message can be transmitted to the host at
84
+  /// periodic intervals.  See cmAudioSysStatusNotifyEnable().
85
+  /// When transmitted to the host this record acts as the message header.
86
+  /// This header is followed by two arrays of doubles containing the input and output meter values
87
+  /// associated with the input and output audio devices.
88
+  /// Message Layout: [ asSubIdx kStatusSelId cmAudioSysStatus_t iMeterArray[iMeterCnt] oMeterArray[oMeterCnt] ]
89
+  typedef struct
90
+  {
91
+    unsigned asSubIdx;     ///< originating audio sub-system
92
+
93
+    unsigned updateCnt;    ///< count of callbacks from the audio devices.
94
+    unsigned wakeupCnt;    ///< count of times the audio system thread has woken up after the cond. var has been signaled by the audio update thread.
95
+    unsigned msgCbCnt;     ///< count of msgs delivered via cmAsCallback() .
96
+    unsigned audioCbCnt;   ///< count of times the DSP execution was requested via cmAsCallback().    
97
+
98
+    unsigned iDevIdx;      ///< Input device index
99
+    unsigned oDevIdx;      ///< Output device index
100
+
101
+    unsigned overflowCnt;  ///< count of times the audio input buffers overflowed
102
+    unsigned underflowCnt; ///< count of times the audio output buffers underflowed
103
+    unsigned iMeterCnt;    ///< count of input meter channels
104
+    unsigned oMeterCnt;    ///< count of output meter channels
105
+    
106
+  } cmAudioSysStatus_t;
107
+
108
+
109
+#ifdef __cplusplus
110
+}
111
+#endif
112
+
113
+#endif

+ 2
- 85
cmMsgProtocol.h Bestand weergeven

@@ -1,6 +1,8 @@
1 1
 #ifndef cmMsgProtocol_h
2 2
 #define cmMsgProtocol_h
3 3
 
4
+#include "cmAudioSysMsg.h"
5
+
4 6
 #ifdef __cplusplus
5 7
 extern "C" {
6 8
 #endif
@@ -8,19 +10,6 @@ extern "C" {
8 10
   #define cmAudDspSys_FILENAME "aud_dsp.js"
9 11
 
10 12
 
11
-  /// Reserved DSP message selector id's (second field of all host<->audio system messages)
12
-  enum
13
-  {
14
-    kMidiMsgArraySelAsId = 1000,
15
-    kMidiSysExSelAsId,
16
-    kUiSelAsId,      // indicates a cmDspUiHdr_t msg
17
-    kUiMstrSelAsId,  // indicates a cmDspUiHdr_t msg containing master control information for the audio system
18
-    kSsInitSelAsId,  // indicates the msg is of type cmAudioSysSsInitMsg_t
19
-    kStatusSelAsId,  // indicates the msg is of type cmAudioSysStatus_t
20
-    kNetSyncSelAsId,   // sent with a cmDspNetMsg_t object  
21
-  };
22
-
23
-
24 13
 
25 14
   // UI seletor id's used in the cmDspUiHdr_t selId field
26 15
   enum 
@@ -84,78 +73,6 @@ extern "C" {
84 73
     cmDspValue_t value;     // Data value associated with this msg.                             
85 74
   } cmDspUiHdr_t;
86 75
 
87
-  // All of the UI messages that create a UI control contain an array of integers
88
-  // as in the 'value' field. The array contains the id's associated with
89
-  // the different programmable paramters which are part of the control.
90
-  // For example a slider control has minimum,maximum, step size, and value 
91
-  // parameters. The location in the array is hard coded according to the
92
-  // parameters meaning but the actual value of the id is left up to the 
93
-  // engine. This allows the engine to use whatever values work best for
94
-  // it on a per instance basis. 
95
-
96
-
97
-
98
-  /// The cmDspUiHdr_t.instId of UI control messages associated with master
99
-  /// control encode the device,channel,in/out, and control type. These macros
100
-  /// should be used for encoding and decoding.
101
-#define cmAudioSysFormUiInstId(dev,ch,ifl,ctl) (((dev)<<16) + ((ch)<<4) + ((ifl)<<3) + (ctl))
102
-#define cmAudioSysUiInstIdToDevIndex(instId)  ( (instId) >> 16)
103
-#define cmAudioSysUiInstIdToChIndex(instId)   (((instId) &  0x0000ffff) >> 4)
104
-#define cmAudioSysUiInstIdToInFlag(instId)    ( (instId) &  0x08)
105
-#define cmAudioSysUiInstIdToCtlId(instId)     ( (instId) &  0x07)
106
-
107
-  /// Control id's used to identify the control type of master contols.
108
-  enum
109
-  {
110
-    kSliderUiAsId = 0,
111
-    kMeterUiAsId  = 1,
112
-    kMuteUiAsId   = 2,
113
-    kToneUiAsId   = 3,
114
-    kPassUiAsId   = 4
115
-  };
116
-
117
-
118
-  /// This message is transmitted to the host application just prior to returning
119
-  /// from cmAudioSysInitialize().
120
-  /// When transmitted to the host this record acts as a message header.
121
-  /// This header is followed by two zero terminated char arrays containing the device
122
-  /// labels associated with the input and output devices.
123
-  /// Message Layout: [ cmAudioSysInitMsg_t "In Device Label" "Out Device Label"]
124
-  typedef struct
125
-  {
126
-    unsigned asSubIdx;  ///< asSubIdx of this sub-system
127
-    unsigned selId;     ///< always kSsInitAsId
128
-    unsigned asSubCnt;  ///< count of sub-systems
129
-    unsigned inDevIdx;  ///< input device index
130
-    unsigned outDevIdx; ///< output device index
131
-    unsigned inChCnt;   ///< input device channel count
132
-    unsigned outChCnt;  ///< outut device channel count
133
-  } cmAudioSysSsInitMsg_t;
134
-
135
-  /// Audio sub-system status record - this message can be transmitted to the host at
136
-  /// periodic intervals.  See cmAudioSysStatusNotifyEnable().
137
-  /// When transmitted to the host this record acts as the message header.
138
-  /// This header is followed by two arrays of doubles containing the input and output meter values
139
-  /// associated with the input and output audio devices.
140
-  /// Message Layout: [ asSubIdx kStatusSelId cmAudioSysStatus_t iMeterArray[iMeterCnt] oMeterArray[oMeterCnt] ]
141
-  typedef struct
142
-  {
143
-    unsigned asSubIdx;     ///< originating audio sub-system
144
-
145
-    unsigned updateCnt;    ///< count of callbacks from the audio devices.
146
-    unsigned wakeupCnt;    ///< count of times the audio system thread has woken up after the cond. var has been signaled by the audio update thread.
147
-    unsigned msgCbCnt;     ///< count of msgs delivered via cmAsCallback() .
148
-    unsigned audioCbCnt;   ///< count of times the DSP execution was requested via cmAsCallback().    
149
-
150
-    unsigned iDevIdx;      ///< Input device index
151
-    unsigned oDevIdx;      ///< Output device index
152
-
153
-    unsigned overflowCnt;  ///< count of times the audio input buffers overflowed
154
-    unsigned underflowCnt; ///< count of times the audio output buffers underflowed
155
-    unsigned iMeterCnt;    ///< count of input meter channels
156
-    unsigned oMeterCnt;    ///< count of output meter channels
157
-    
158
-  } cmAudioSysStatus_t;
159 76
 
160 77
   // cmDspNetMsg_t sub-selector id's
161 78
   enum {

Laden…
Annuleren
Opslaan