libcm is a C development framework with an emphasis on audio signal processing applications.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

cmDspNet.h 4.8KB

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