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.

cmDspNet.h 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #ifndef cmDspNet_h
  2. #define cmDspNet_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #define cmDspSys_PARENT_SYM_TBL_BASE_ID 10000
  7. #define cmDspSys_AsSubIdx_Zero (0)
  8. typedef struct _cmDspClass_str
  9. {
  10. cmDspClass_t* classPtr;
  11. unsigned symId;
  12. struct _cmDspClass_str* linkPtr;
  13. } _cmDspClass_t;
  14. typedef struct _cmDspInst_str
  15. {
  16. cmDspInst_t* instPtr;
  17. struct _cmDspInst_str* linkPtr;
  18. } _cmDspInst_t;
  19. typedef struct
  20. {
  21. unsigned id;
  22. bool helloFl; // recv'd a sync 'hello' msg from this node
  23. bool reqDoneFl;// recv'd a synd 'requests done' msg from this node
  24. bool doneFl; // recv'd a sync 'done' msg from this node
  25. bool localFl; // this is the local node
  26. } _cmDspNetNode_t;
  27. // connections from a DSP instance on this machine - this list exists on the src machine only
  28. // to a DSP instance on another machine
  29. typedef struct _cmDspSrcConn_str
  30. {
  31. unsigned srcId; // address provided by this machine
  32. unsigned dstId; // address provided by the remote machine
  33. unsigned dstNetNodeId;
  34. cmChar_t* dstInstLabel;
  35. cmChar_t* dstVarLabel;
  36. struct _cmDspSrcConn_str* link;
  37. } _cmDspSrcConn_t;
  38. // Connection proxies for connection destinations - this list exists on the dst machine only
  39. typedef struct _cmDspDstConn_str
  40. {
  41. unsigned dstId; // address provided by this machine (same as dstId on other machine)
  42. unsigned srcNetNodeId; // net node Id of the source - srcId is unique to this machine
  43. unsigned srcId; // address provided by remote machine (same as srcId on other machine)
  44. cmDspInst_t* dstInst; // connection destination target instance/var
  45. unsigned dstVarId; //
  46. struct _cmDspDstConn_str* link; //
  47. } _cmDspDstConn_t;
  48. typedef struct
  49. {
  50. cmErr_t err;
  51. cmCtx_t cmCtx;
  52. cmDspCtx_t ctx;
  53. cmLHeapH_t lhH; // DSP system lHeap used for system memory (DSP instance memory uses ctx->lhH so that it can be removed independent of the DSP system memory)
  54. cmSymTblH_t stH; // DSP system symbol table (holds class based symbols) (DSP instances use ctx->stH)
  55. cmDspStoreH_t dsH; // DSP system global variable storate table
  56. cmJsonH_t jsH; // DSP json for use by the system
  57. const cmChar_t* rsrcFn; // name of the JSON file containing resource specific resource
  58. _cmDspClass_t* classList;
  59. _cmDspInst_t* instList;
  60. cmDspPresetMgr_t pm;
  61. unsigned nextInstId;
  62. unsigned pgmIdx;
  63. cmUdpNetH_t netH; //
  64. cmThreadH_t thH; //
  65. unsigned nextDstId; //
  66. unsigned netNodeCnt; //
  67. _cmDspNetNode_t* netNodeArray; // netNodeArray[ netNodeCnt ]
  68. _cmDspSrcConn_t* srcConnList; // linked list of all dstConn recds
  69. _cmDspDstConn_t* dstConnList; // linked list of all srcConn recds
  70. _cmDspSrcConn_t** srcConnMap; // srcConnMap[srcConnMapCnt] array of all srcConn recd ptr's mapped to srcId
  71. unsigned srcConnMapCnt; // count of records in srcConnMap[]
  72. _cmDspDstConn_t** dstConnMap; // dstConnMap[dstConnMapCnt] array of all dstConn recd ptr's mapped to dstId
  73. unsigned dstConnMapCnt; // count of record in dstConnMap[]
  74. bool netDoneSentFl; // true when this node has broadcast it's 'done' msg
  75. unsigned netVerbosity;
  76. unsigned sendWaitMs;
  77. unsigned syncState; // see kSyncXXXDspId
  78. cmDspInstSymId_t* symIdList; // sym id's which will be assigned to each new instance
  79. } cmDsp_t;
  80. // called by cmDspSysInstallNetCb()
  81. _cmDspSrcConn_t* _cmDspSysNetCreateSrcConn( cmDsp_t* p, unsigned dstNetNodeId, const cmChar_t* dstInstLabel, const cmChar_t* dstVarLabel );
  82. // called by cmDspSysInitialize()
  83. cmDspRC_t _cmDspSysNetAlloc( cmDsp_t* p );
  84. // called by cmDspSysFinalize()
  85. cmDspRC_t _cmDspSysNetFree( cmDsp_t* p );
  86. // called by cmDspSysLoad()
  87. cmDspRC_t _cmDspSysNetPreLoad( cmDsp_t* p );
  88. // called by cmDspSysUnload()
  89. cmDspRC_t _cmDspSysNetUnload( cmDsp_t* p );
  90. // Call this function to enter 'sync' mode.
  91. cmDspRC_t _cmDspSysNetSync( cmDsp_t* p );
  92. // Called from cmAudDsp.c:_cmAdUdpNetCallback() to to send an incoming msg to the DSP system.
  93. cmDspRC_t _cmDspSysNetRecv( cmDsp_t* p, const cmDspNetMsg_t* msg, unsigned msgByteCnt, unsigned remoteNetNodeId );
  94. cmDspRC_t _cmDspSysNetSendEvent( cmDspSysH_t h, unsigned dstNetNodeId, unsigned dstId, const cmDspEvt_t* evt );
  95. #ifdef __cplusplus
  96. }
  97. #endif
  98. #endif