libcm is a C development framework with an emphasis on audio signal processing applications.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

cmDspNet.h 4.9KB

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