libcm is a C development framework with an emphasis on audio signal processing applications.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

cmDspNet.h 5.0KB

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