libcm is a C development framework with an emphasis on audio signal processing applications.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cmDevCfg.h 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #ifndef cmDevCfg_h
  2. #define cmDevCfg_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /*
  7. IMPLEMENTATION:
  8. 1) A 'cfg' record is a device reference with a 'cfg label'.
  9. There are three kinds of cfg records MIDI,Audio,Net.
  10. The device record identifies a particlar device
  11. end-point or pre-configured setup. The 'cfg label'
  12. associated with this setup allows an application
  13. to refer to the setup by name. This releives the
  14. application from having to handle the details of
  15. forming, storing, and maintaining device configurations.
  16. 2) A 'map' record is a record which links an
  17. application and reference id to a cfg record.
  18. The goal of this is to allow applications to refer to
  19. pre-configured device setups by name and then to
  20. associate a numeric id with this setup.
  21. The application can then send data to the device using
  22. only the numeric id. Likewise data arriving from the
  23. device to the application is tagged with
  24. id of the of the device.
  25. NOTES:
  26. 1) usrAppId's must be unique among all app.s'.
  27. 2) usrDevId's must be unique among all usrDevId's for particular app.
  28. In other words the same 'usrDevId' may not be used by devices
  29. of different types.
  30. 3) The usrAppId's and usrDevIds' are used internally as index
  31. locations. They should therefore be low numbers and
  32. densely packed.
  33. */
  34. struct cmAudioSysArgs_str;
  35. enum
  36. {
  37. kOkDcRC = cmOkRC,
  38. kLHeapFailDcRC,
  39. kLabelNotFoundDcRC,
  40. kDuplLabelDcRC,
  41. kBlankLabelDcRC,
  42. kInvalidUserAppIdRC,
  43. kInvalidUserMapIdRC,
  44. kInvalidArgDcRC,
  45. kInvalidCfgIdxDcRC,
  46. kJsonFailDcRC
  47. };
  48. typedef enum
  49. {
  50. kInvalidDcmTId, // kInvalidDcmTId must be zero
  51. kMidiDcmTId,
  52. kAudioDcmTId,
  53. kNetDcmTId
  54. } cmTypeDcmId_t;
  55. typedef cmRC_t cmDcRC_t;
  56. typedef cmHandle_t cmDevCfgH_t;
  57. typedef struct
  58. {
  59. cmChar_t* devLabelStr; // Midi device label.
  60. cmChar_t* portLabelStr; // Midi device port label.
  61. bool inputFl; // 'True' if this is an input port.
  62. unsigned devIdx; // Midi device index.
  63. unsigned portIdx; // Midi port index.
  64. } cmDcmMidi_t;
  65. typedef struct
  66. {
  67. cmChar_t* inDevLabelStr; // Input audio device label.
  68. cmChar_t* outDevLabelStr; // Output audio device label.
  69. cmAudioSysArgs_t audioSysArgs; // Audio system cfg recd
  70. } cmDcmAudio_t;
  71. typedef struct
  72. {
  73. cmChar_t* sockAddr; // Remote socket address.
  74. unsigned portNumber; // Remote socket port number
  75. } cmDcmNet_t;
  76. extern cmDevCfgH_t cmDevCfgNullHandle;
  77. cmDcRC_t cmDevCfgMgrAlloc( cmCtx_t* c, cmDevCfgH_t* hp );
  78. cmDcRC_t cmDevCfgMgrFree( cmDevCfgH_t* hp );
  79. bool cmDevCfgIsValid( cmDevCfgH_t h );
  80. // Return the count of cfg records for the given type in the current location.
  81. unsigned cmDevCfgCount( cmDevCfgH_t h, cmTypeDcmId_t typeId );
  82. // Return the label for a each cfg record of a given type in the current location.
  83. const cmChar_t* cmDevCfgLabel( cmDevCfgH_t h, cmTypeDcmId_t typeId, unsigned index );
  84. // Return the description for a give cfg. record.
  85. const cmChar_t* cmDevCfgDesc( cmDevCfgH_t h, cmTypeDcmId_t typeId, unsigned index );
  86. // Return the cfg index assoc'd with a given label in the current location.
  87. unsigned cmDevCfgLabelToIndex( cmDevCfgH_t h, cmTypeDcmId_t typeId, const cmChar_t* label );
  88. // Delete a cfg record created by cmDevCfgNameMidiPort(), cmDevCfgNameAudioPort(), etc.
  89. cmDcRC_t cmDevCfgDeleteCfg( cmDevCfgH_t h, cmTypeDcmId_t typeId, const cmChar_t* dcLabelStr );
  90. // Create a map record to associate a app/dev id with a cfg. record.
  91. // Note that multiple app/dev id's may be assoc'd with the same cfg. record.
  92. cmDcRC_t cmDevCfgCreateMap( cmDevCfgH_t h, cmTypeDcmId_t typeId, const cmChar_t* dcLabelStr, unsigned usrAppId, unsigned usrMapId );
  93. // Delete a map record created by cmDevCfgCreateMap().
  94. cmDcRC_t cmDevCfgDeleteMap( cmDevCfgH_t h, cmTypeDcmId_t typeId, unsigned usrAppId, unsigned usrMapId );
  95. // Create a MIDI cfg. record.
  96. cmDcRC_t cmDevCfgNameMidiPort(
  97. cmDevCfgH_t h,
  98. const cmChar_t* dcLabelStr,
  99. const cmChar_t* devNameStr,
  100. const cmChar_t* portNameStr,
  101. bool inputFl );
  102. const cmDcmMidi_t* cmDevCfgMidiCfg( cmDevCfgH_t h, unsigned cfgIdx );
  103. const cmDcmMidi_t* cmDevCfgMidiMap( cmDevCfgH_t h, unsigned usrAppId, unsigned usrMapId );
  104. cmDcRC_t cmDevCfgNameAudioPort(
  105. cmDevCfgH_t h,
  106. const cmChar_t* dcLabelStr,
  107. const cmChar_t* inDevNameStr,
  108. const cmChar_t* outDevNameStr,
  109. bool syncInputFl,
  110. unsigned msgQueueByteCnt,
  111. unsigned devFramesPerCycle,
  112. unsigned dspFramesPerCycle,
  113. unsigned audioBufCnt,
  114. double srate );
  115. const cmDcmAudio_t* cmDevCfgAudioCfg( cmDevCfgH_t h, unsigned cfgIdx );
  116. const cmDcmAudio_t* cmDevCfgAudioMap( cmDevCfgH_t h, unsigned usrAppId, unsigned usrMapId );
  117. const struct cmAudioSysArgs_str* cmDevCfgAudioSysArgs( cmDevCfgH_t h, unsigned usrAppId, unsigned usrMapId );
  118. cmDcRC_t cmDevCfgNetPort(
  119. cmDevCfgH_t h,
  120. const cmChar_t* dcLabelStr,
  121. const cmChar_t* sockAddr,
  122. unsigned portNumber );
  123. const cmDcmNet_t* cmDevCfgNetCfg( cmDevCfgH_t h, unsigned cfgIdx );
  124. const cmDcmNet_t* cmDevCfgNetMap( cmDevCfgH_t h, unsigned usrAppId, unsigned usrMapId );
  125. // Location Management Functions:
  126. // Store and recall groups cfg records.
  127. unsigned cmDevCfgLocCount( cmDevCfgH_t h );
  128. const cmChar_t* cmDevCfgLocLabel( cmDevCfgH_t h, unsigned locIdx );
  129. cmDcRC_t cmDevCfgLocStore( cmDevCfgH_t h, const cmChar_t* locLabelStr );
  130. cmDcRC_t cmDevCfgLocRecall( cmDevCfgH_t h, const cmChar_t* locLabelStr );
  131. cmDcRC_t cmDevCfgLocDelete( cmDevCfgH_t h, const cmChar_t* locLabelStr );
  132. // Return the current location index
  133. unsigned cmDevCfgLocCurIndex( cmDevCfgH_t h );
  134. cmDcRC_t cmDevCfgWrite( cmDevCfgH_t h );
  135. #ifdef __cplusplus
  136. }
  137. #endif
  138. #endif