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.

cmUiDrvr.c 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #include "cmGlobal.h"
  2. #include "cmRtSysMsg.h"
  3. #include "cmUiDrvr.h"
  4. void cmUiDriverArgSetup( cmUiDriverArg_t* a,
  5. unsigned rtSubIdx,
  6. unsigned selId,
  7. cmUiDId_t dId,
  8. unsigned appId,
  9. unsigned usrId,
  10. unsigned panelId,
  11. cmUiCId_t cId,
  12. unsigned flags,
  13. int ival,
  14. double fval,
  15. const cmChar_t* sval,
  16. int x,
  17. int y,
  18. int w,
  19. int h
  20. )
  21. {
  22. flags = cmEnaFlag(flags,kSvalUiFl,sval!=NULL);
  23. a->hdr.rtSubIdx= rtSubIdx;
  24. a->hdr.selId = selId;
  25. a->dId = dId;
  26. a->appId = appId;
  27. a->usrId = usrId;
  28. a->panelId = panelId;
  29. a->cId = cId;
  30. a->flags = flags;
  31. a->ival = ival;
  32. a->fval = fval;
  33. a->sval = sval;
  34. a->x = x;
  35. a->y = y;
  36. a->w = w;
  37. a->h = h;
  38. }
  39. unsigned cmUiDriverArgSerializeBufByteCount( const cmUiDriverArg_t* a )
  40. {
  41. unsigned n = sizeof(*a);
  42. if( cmIsFlag(a->flags,kSvalUiFl) && a->sval != NULL )
  43. n += strlen(a->sval) + 1;
  44. return n;
  45. }
  46. cmUiRC_t cmUiDriverArgSerialize( const cmUiDriverArg_t* a, void* buf, unsigned bufByteCnt )
  47. {
  48. if( bufByteCnt < cmUiDriverArgSerializeBufByteCount(a))
  49. return kBufTooSmallUiRC;
  50. memcpy(buf,a,sizeof(*a));
  51. if( cmIsFlag(a->flags,kSvalUiFl) && a->sval != NULL )
  52. strcpy( (char*)buf + sizeof(*a), a->sval );
  53. return kOkUiRC;
  54. }
  55. cmUiRC_t cmUiDriverArgDeserialize( cmUiDriverArg_t* a, const void* buf, unsigned bufByteCnt )
  56. {
  57. bool fl = bufByteCnt >= sizeof(*a);
  58. assert( fl );
  59. if( !fl )
  60. return kBufTooSmallUiRC;
  61. memcpy(a,buf,sizeof(*a));
  62. fl = a->cId < kMaxUiCId && a->dId < kMaxDId;
  63. assert(fl );
  64. if( !fl )
  65. return kBufCorruptUiRC;
  66. if( cmIsFlag(a->flags,kSvalUiFl) && a->sval != NULL )
  67. a->sval = (char*)buf + sizeof(*a);
  68. return kOkUiRC;
  69. }
  70. int cmUiDriverArgGetInt( const cmUiDriverArg_t* a )
  71. {
  72. if( a->flags & kIvalUiFl )
  73. return a->ival;
  74. if( a->flags & kFvalUiFl )
  75. return round(a->fval);
  76. assert(0);
  77. return -1;
  78. }
  79. double cmUiDriverArgGetDouble( const cmUiDriverArg_t* a )
  80. {
  81. if( a->flags & kIvalUiFl )
  82. return a->ival;
  83. if( a->flags & kFvalUiFl )
  84. return a->fval;
  85. assert(0);
  86. return -1;
  87. }
  88. const cmChar_t* cmUiDriverArgGetString( const cmUiDriverArg_t* a )
  89. {
  90. return a->flags & kSvalUiFl ? a->sval : NULL;
  91. }