Переглянути джерело

cmDevCfg.h/c: Rewrite of cmDevCfg.h/c to simplify the implementation.

master
kevin 11 роки тому
джерело
коміт
bd7a9b23a0
2 змінених файлів з 892 додано та 711 видалено
  1. 841
    694
      cmDevCfg.c
  2. 51
    17
      cmDevCfg.h

+ 841
- 694
cmDevCfg.c
Різницю між файлами не показано, бо вона завелика
Переглянути файл


+ 51
- 17
cmDevCfg.h Переглянути файл

42
   enum
42
   enum
43
   {
43
   {
44
     kOkDcRC = cmOkRC,
44
     kOkDcRC = cmOkRC,
45
-    cmLabelNotFoundDcRC,
46
-    cmIdNotFoundDcRC,
47
-    kInvalidDevArgDcRC,
48
-    kEmptyLabelDcRC,
49
-    kLocNotFoundDcRC
45
+    kLHeapFailDcRC,
46
+    kLabelNotFoundDcRC,
47
+    kDuplLabelDcRC,
48
+    kBlankLabelDcRC,
49
+    kInvalidUserAppIdRC,
50
+    kInvalidUserMapIdRC,
51
+    kInvalidArgDcRC,
52
+    kInvalidCfgIdxDcRC,
53
+    kJsonFailDcRC
50
   };
54
   };
51
 
55
 
52
   typedef enum
56
   typedef enum
53
   {
57
   {
54
-    kInvalidDcmTId,
58
+    kInvalidDcmTId, // kInvalidDcmTId must be zero
55
     kMidiDcmTId,
59
     kMidiDcmTId,
56
     kAudioDcmTId,
60
     kAudioDcmTId,
57
     kNetDcmTId
61
     kNetDcmTId
60
   typedef cmRC_t     cmDcRC_t;
64
   typedef cmRC_t     cmDcRC_t;
61
   typedef cmHandle_t cmDevCfgH_t;
65
   typedef cmHandle_t cmDevCfgH_t;
62
 
66
 
67
+  typedef struct
68
+  {
69
+    cmChar_t* devLabelStr;    // Midi device label.
70
+    cmChar_t* portLabelStr;   // Midi device port label.
71
+    bool      inputFl;        // 'True' if this is an input port.
72
+    unsigned  devIdx;         // Midi device index.
73
+    unsigned  portIdx;        // Midi port index.
74
+  } cmDcmMidi_t;
75
+
76
+  typedef struct
77
+  {
78
+    cmChar_t*        inDevLabelStr;  // Input audio device label.
79
+    cmChar_t*        outDevLabelStr; // Output audio device label.
80
+    cmAudioSysArgs_t audioSysArgs;   // Audio system  cfg recd
81
+  } cmDcmAudio_t;
82
+
83
+  typedef struct              
84
+  {
85
+    cmChar_t* sockAddr;   // Remote socket address.
86
+    unsigned  portNumber; // Remote socket port number
87
+  } cmDcmNet_t;
88
+
63
   extern cmDevCfgH_t cmDevCfgNullHandle;
89
   extern cmDevCfgH_t cmDevCfgNullHandle;
64
 
90
 
65
   cmDcRC_t cmDevCfgMgrAlloc( cmCtx_t* c, cmDevCfgH_t* hp );
91
   cmDcRC_t cmDevCfgMgrAlloc( cmCtx_t* c, cmDevCfgH_t* hp );
66
   cmDcRC_t cmDevCfgMgrFree( cmDevCfgH_t* hp );
92
   cmDcRC_t cmDevCfgMgrFree( cmDevCfgH_t* hp );
67
-  cmDcRC_t cmDevCfgIsValid( cmDevCfgH_t h );
93
+  bool     cmDevCfgIsValid( cmDevCfgH_t h );
68
 
94
 
69
-  // Return the count of cfg records for the given type.
95
+  // Return the count of cfg records for the given type in the current location.
70
   unsigned cmDevCfgCount( cmDevCfgH_t h, cmTypeDcmId_t typeId );
96
   unsigned cmDevCfgCount( cmDevCfgH_t h, cmTypeDcmId_t typeId );
71
 
97
 
72
-  // Return the label for a each cfg record of a given type.
98
+  // Return the label for a each cfg record of a given type in the current location.
73
   const cmChar_t* cmDevCfgLabel( cmDevCfgH_t h, cmTypeDcmId_t typeId, unsigned index );
99
   const cmChar_t* cmDevCfgLabel( cmDevCfgH_t h, cmTypeDcmId_t typeId, unsigned index );
74
 
100
 
75
-  // Return the cfg index assoc'd with a given label.
101
+  // Return the description for a give cfg. record.
102
+  const cmChar_t* cmDevCfgDesc( cmDevCfgH_t h, cmTypeDcmId_t typeId, unsigned index );
103
+
104
+  // Return the cfg index assoc'd with a given label in the current location.
76
   unsigned cmDevCfgLabelToIndex( cmDevCfgH_t h, cmTypeDcmId_t typeId, const cmChar_t* label );
105
   unsigned cmDevCfgLabelToIndex( cmDevCfgH_t h, cmTypeDcmId_t typeId, const cmChar_t* label );
77
   
106
   
78
   // Delete a cfg record created by cmDevCfgNameMidiPort(), cmDevCfgNameAudioPort(), etc.
107
   // Delete a cfg record created by cmDevCfgNameMidiPort(), cmDevCfgNameAudioPort(), etc.
80
 
109
 
81
   // Create a map record to associate a app/dev id with a cfg. record.
110
   // Create a map record to associate a app/dev id with a cfg. record.
82
   // Note that multiple app/dev id's may be assoc'd with the same cfg. record.
111
   // Note that multiple app/dev id's may be assoc'd with the same cfg. record.
83
-  cmDcRC_t cmDevCfgCreateMap( cmDevCfgH_t h, cmTypeDcmId_t typeId, const cmChar_t* dcLabelStr, unsigned usrAppId, unsigned usrDevId );
112
+  cmDcRC_t cmDevCfgCreateMap( cmDevCfgH_t h, cmTypeDcmId_t typeId, const cmChar_t* dcLabelStr, unsigned usrAppId, unsigned usrMapId );
84
 
113
 
85
   // Delete a map record created by cmDevCfgCreateMap().
114
   // Delete a map record created by cmDevCfgCreateMap().
86
-  cmDcRC_t cmDevCfgDeleteMap( cmDevCfgH_t h, cmTypeDcmId_t typeId, unsigned usrAppId, unsigned usrDevId );
115
+  cmDcRC_t cmDevCfgDeleteMap( cmDevCfgH_t h, cmTypeDcmId_t typeId, unsigned usrAppId, unsigned usrMapId );
87
   
116
   
88
 
117
 
89
   // Create a MIDI cfg. record.
118
   // Create a MIDI cfg. record.
94
     const cmChar_t* portNameStr, 
123
     const cmChar_t* portNameStr, 
95
     bool            inputFl );
124
     bool            inputFl );
96
 
125
 
97
-  cmDcRC_t cmDevCfgMidiDevIdx(    cmDevCfgH_t h, unsigned usrAppId, unsigned usrDevId, unsigned* midiDevIdxRef, unsigned* midiPortIdxRef );
98
-
126
+  const cmDcmMidi_t* cmDevCfgMidiCfg( cmDevCfgH_t h, unsigned cfgIdx );
127
+  const cmDcmMidi_t* cmDevCfgMidiMap( cmDevCfgH_t h, unsigned usrAppId, unsigned usrMapId );
128
+  
99
 
129
 
100
   cmDcRC_t cmDevCfgNameAudioPort( 
130
   cmDcRC_t cmDevCfgNameAudioPort( 
101
     cmDevCfgH_t     h,
131
     cmDevCfgH_t     h,
109
     unsigned        audioBufCnt,
139
     unsigned        audioBufCnt,
110
     double          srate  );
140
     double          srate  );
111
 
141
 
112
-  const struct cmAudioSysArgs_str* cmDevCfgAudioSysArgs( cmDevCfgH_t h, unsigned usrAppId, unsigned usrDevId );
142
+  const cmDcmAudio_t* cmDevCfgAudioCfg( cmDevCfgH_t h, unsigned cfgIdx );
143
+  const cmDcmAudio_t* cmDevCfgAudioMap( cmDevCfgH_t h, unsigned usrAppId, unsigned usrMapId );
144
+
145
+  const struct cmAudioSysArgs_str* cmDevCfgAudioSysArgs( cmDevCfgH_t h, unsigned usrAppId, unsigned usrMapId );
113
 
146
 
114
   cmDcRC_t cmDevCfgNetPort(
147
   cmDcRC_t cmDevCfgNetPort(
115
     cmDevCfgH_t      h,
148
     cmDevCfgH_t      h,
117
     const cmChar_t* sockAddr,
150
     const cmChar_t* sockAddr,
118
     unsigned        portNumber );
151
     unsigned        portNumber );
119
 
152
 
120
-  unsigned        cmDevCfgNetNodeId(     cmDevCfgH_t h, unsigned usrAppId, unsigned usrDevId );
153
+  const cmDcmNet_t* cmDevCfgNetCfg( cmDevCfgH_t h, unsigned cfgIdx );
154
+  const cmDcmNet_t* cmDevCfgNetMap( cmDevCfgH_t h, unsigned usrAppId, unsigned usrMapId );
121
 
155
 
122
   // Location Management Functions:
156
   // Location Management Functions:
123
   // Store and recall groups cfg records.
157
   // Store and recall groups cfg records.
129
   cmDcRC_t        cmDevCfgLocDelete( cmDevCfgH_t h, const cmChar_t* locLabelStr );
163
   cmDcRC_t        cmDevCfgLocDelete( cmDevCfgH_t h, const cmChar_t* locLabelStr );
130
 
164
 
131
   // Return the current location index
165
   // Return the current location index
132
-  unsigned        cmDevCfgLocIndex(  cmDevCfgH_t h );
166
+  unsigned        cmDevCfgLocCurIndex(  cmDevCfgH_t h );
133
 
167
 
134
   cmDcRC_t cmDevCfgWrite( cmDevCfgH_t h );
168
   cmDcRC_t cmDevCfgWrite( cmDevCfgH_t h );
135
   
169
   

Завантаження…
Відмінити
Зберегти