Browse Source

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

master
kevin 11 years ago
parent
commit
bd7a9b23a0
2 changed files with 892 additions and 711 deletions
  1. 841
    694
      cmDevCfg.c
  2. 51
    17
      cmDevCfg.h

+ 841
- 694
cmDevCfg.c
File diff suppressed because it is too large
View File


+ 51
- 17
cmDevCfg.h View File

@@ -42,16 +42,20 @@ extern "C" {
42 42
   enum
43 43
   {
44 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 56
   typedef enum
53 57
   {
54
-    kInvalidDcmTId,
58
+    kInvalidDcmTId, // kInvalidDcmTId must be zero
55 59
     kMidiDcmTId,
56 60
     kAudioDcmTId,
57 61
     kNetDcmTId
@@ -60,19 +64,44 @@ extern "C" {
60 64
   typedef cmRC_t     cmDcRC_t;
61 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 89
   extern cmDevCfgH_t cmDevCfgNullHandle;
64 90
 
65 91
   cmDcRC_t cmDevCfgMgrAlloc( cmCtx_t* c, cmDevCfgH_t* hp );
66 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 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 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 105
   unsigned cmDevCfgLabelToIndex( cmDevCfgH_t h, cmTypeDcmId_t typeId, const cmChar_t* label );
77 106
   
78 107
   // Delete a cfg record created by cmDevCfgNameMidiPort(), cmDevCfgNameAudioPort(), etc.
@@ -80,10 +109,10 @@ extern "C" {
80 109
 
81 110
   // Create a map record to associate a app/dev id with a cfg. record.
82 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 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 118
   // Create a MIDI cfg. record.
@@ -94,8 +123,9 @@ extern "C" {
94 123
     const cmChar_t* portNameStr, 
95 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 130
   cmDcRC_t cmDevCfgNameAudioPort( 
101 131
     cmDevCfgH_t     h,
@@ -109,7 +139,10 @@ extern "C" {
109 139
     unsigned        audioBufCnt,
110 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 147
   cmDcRC_t cmDevCfgNetPort(
115 148
     cmDevCfgH_t      h,
@@ -117,7 +150,8 @@ extern "C" {
117 150
     const cmChar_t* sockAddr,
118 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 156
   // Location Management Functions:
123 157
   // Store and recall groups cfg records.
@@ -129,7 +163,7 @@ extern "C" {
129 163
   cmDcRC_t        cmDevCfgLocDelete( cmDevCfgH_t h, const cmChar_t* locLabelStr );
130 164
 
131 165
   // Return the current location index
132
-  unsigned        cmDevCfgLocIndex(  cmDevCfgH_t h );
166
+  unsigned        cmDevCfgLocCurIndex(  cmDevCfgH_t h );
133 167
 
134 168
   cmDcRC_t cmDevCfgWrite( cmDevCfgH_t h );
135 169
   

Loading…
Cancel
Save