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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. cmJsonH_t jsH; // DSP json for use by the system
  56. const cmChar_t* rsrcFn; // name of the JSON file containing resource specific resource
  57. _cmDspClass_t* classList;
  58. _cmDspInst_t* instList;
  59. cmDspPresetMgr_t pm;
  60. unsigned nextInstId;
  61. unsigned pgmIdx;
  62. cmUdpNetH_t netH; //
  63. cmThreadH_t thH; //
  64. unsigned nextDstId; //
  65. unsigned netNodeCnt; //
  66. _cmDspNetNode_t* netNodeArray; // netNodeArray[ netNodeCnt ]
  67. _cmDspSrcConn_t* srcConnList; // linked list of all dstConn recds
  68. _cmDspDstConn_t* dstConnList; // linked list of all srcConn recds
  69. _cmDspSrcConn_t** srcConnMap; // srcConnMap[srcConnMapCnt] array of all srcConn recd ptr's mapped to srcId
  70. unsigned srcConnMapCnt; // count of records in srcConnMap[]
  71. _cmDspDstConn_t** dstConnMap; // dstConnMap[dstConnMapCnt] array of all dstConn recd ptr's mapped to dstId
  72. unsigned dstConnMapCnt; // count of record in dstConnMap[]
  73. bool netDoneSentFl; // true when this node has broadcast it's 'done' msg
  74. unsigned netVerbosity;
  75. unsigned sendWaitMs;
  76. unsigned syncState; // see kSyncXXXDspId
  77. cmDspInstSymId_t* symIdList; // sym id's which will be assigned to each new instance
  78. } cmDsp_t;
  79. // called by cmDspSysInstallNetCb()
  80. _cmDspSrcConn_t* _cmDspSysNetCreateSrcConn( cmDsp_t* p, unsigned dstNetNodeId, const cmChar_t* dstInstLabel, const cmChar_t* dstVarLabel );
  81. // called by cmDspSysInitialize()
  82. cmDspRC_t _cmDspSysNetAlloc( cmDsp_t* p );
  83. // called by cmDspSysFinalize()
  84. cmDspRC_t _cmDspSysNetFree( cmDsp_t* p );
  85. // called by cmDspSysLoad()
  86. cmDspRC_t _cmDspSysNetPreLoad( cmDsp_t* p );
  87. // called by cmDspSysUnload()
  88. cmDspRC_t _cmDspSysNetUnload( cmDsp_t* p );
  89. // Call this function to enter 'sync' mode.
  90. cmDspRC_t _cmDspSysNetSync( cmDsp_t* p );
  91. // Called from cmAudDsp.c:_cmAdUdpNetCallback() to to send an incoming msg to the DSP system.
  92. cmDspRC_t _cmDspSysNetRecv( cmDsp_t* p, const cmDspNetMsg_t* msg, unsigned msgByteCnt, unsigned remoteNetNodeId );
  93. cmDspRC_t _cmDspSysNetSendEvent( cmDspSysH_t h, unsigned dstNetNodeId, unsigned dstId, const cmDspEvt_t* evt );
  94. #ifdef __cplusplus
  95. }
  96. #endif
  97. #endif