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 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. cmLabelNotFoundDcRC,
  39. cmIdNotFoundDcRC,
  40. kInvalidDevArgDcRC,
  41. kEmptyLabelDcRC,
  42. kLocNotFoundDcRC
  43. };
  44. typedef enum
  45. {
  46. kInvalidDcmTId,
  47. kMidiDcmTId,
  48. kAudioDcmTId,
  49. kNetDcmTId
  50. } cmTypeDcmId_t;
  51. typedef cmRC_t cmDcRC_t;
  52. typedef cmHandle_t cmDevCfgH_t;
  53. extern cmDevCfgH_t cmDevCfgNullHandle;
  54. cmDcRC_t cmDevCfgMgrAlloc( cmCtx_t* c, cmDevCfgH_t* hp );
  55. cmDcRC_t cmDevCfgMgrFree( cmDevCfgH_t* hp );
  56. cmDcRC_t cmDevCfgIsValid( cmDevCfgH_t h );
  57. // Return the count of cfg records for the given type.
  58. unsigned cmDevCfgCount( cmDevCfgH_t h, cmTypeDcmId_t typeId );
  59. // Return the label for a each cfg record of a given type.
  60. const cmChar_t* cmDevCfgLabel( cmDevCfgH_t h, cmTypeDcmId_t typeId, unsigned index );
  61. // Return the cfg index assoc'd with a given label.
  62. unsigned cmDevCfgLabelToIndex( cmDevCfgH_t h, cmTypeDcmId_t typeId, const cmChar_t* label );
  63. // Delete a cfg record created by cmDevCfgNameMidiPort(), cmDevCfgNameAudioPort(), etc.
  64. cmDcRC_t cmDevCfgDeleteCfg( cmDevCfgH_t h, cmTypeDcmId_t typeId, const cmChar_t* dcLabelStr );
  65. // Create a map record to associate a app/dev id with a cfg. record.
  66. // Note that multiple app/dev id's may be assoc'd with the same cfg. record.
  67. cmDcRC_t cmDevCfgCreateMap( cmDevCfgH_t h, cmTypeDcmId_t typeId, const cmChar_t* dcLabelStr, unsigned usrAppId, unsigned usrDevId );
  68. // Delete a map record created by cmDevCfgCreateMap().
  69. cmDcRC_t cmDevCfgDeleteMap( cmDevCfgH_t h, cmTypeDcmId_t typeId, unsigned usrAppId, unsigned usrDevId );
  70. // Create a MIDI cfg. record.
  71. cmDcRC_t cmDevCfgNameMidiPort(
  72. cmDevCfgH_t h,
  73. const cmChar_t* dcLabelStr,
  74. const cmChar_t* devNameStr,
  75. const cmChar_t* portNameStr,
  76. bool inputFl );
  77. cmDcRC_t cmDevCfgMidiDevIdx( cmDevCfgH_t h, unsigned usrAppId, unsigned usrDevId, unsigned* midiDevIdxRef, unsigned* midiPortIdxRef );
  78. cmDcRC_t cmDevCfgNameAudioPort(
  79. cmDevCfgH_t h,
  80. const cmChar_t* dcLabelStr,
  81. const cmChar_t* inDevNameStr,
  82. const cmChar_t* outDevNameStr,
  83. bool syncInputFl,
  84. unsigned msgQueueByteCnt,
  85. unsigned devFramesPerCycle,
  86. unsigned dspFramesPerCycle,
  87. unsigned audioBufCnt,
  88. double srate );
  89. const struct cmAudioSysArgs_str* cmDevCfgAudioSysArgs( cmDevCfgH_t h, unsigned usrAppId, unsigned usrDevId );
  90. cmDcRC_t cmDevCfgNetPort(
  91. cmDevCfgH_t h,
  92. const cmChar_t* dcLabelStr,
  93. const cmChar_t* sockAddr,
  94. unsigned portNumber );
  95. unsigned cmDevCfgNetNodeId( cmDevCfgH_t h, unsigned usrAppId, unsigned usrDevId );
  96. // Location Management Functions:
  97. // Store and recall groups cfg records.
  98. unsigned cmDevCfgLocCount( cmDevCfgH_t h );
  99. const cmChar_t* cmDevCfgLocLabel( cmDevCfgH_t h, unsigned locIdx );
  100. cmDcRC_t cmDevCfgLocStore( cmDevCfgH_t h, const cmChar_t* locLabelStr );
  101. cmDcRC_t cmDevCfgLocRecall( cmDevCfgH_t h, const cmChar_t* locLabelStr );
  102. cmDcRC_t cmDevCfgLocDelete( cmDevCfgH_t h, const cmChar_t* locLabelStr );
  103. // Return the current location index
  104. unsigned cmDevCfgLocIndex( cmDevCfgH_t h );
  105. cmDcRC_t cmDevCfgWrite( cmDevCfgH_t h );
  106. #ifdef __cplusplus
  107. }
  108. #endif
  109. #endif