Programmable real-time audio signal processing application
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.

main.cpp 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #include <FL/Fl.H>
  2. #include <Fl/fl_draw.H>
  3. #include <FL/Fl_Double_Window.H>
  4. #include "cmPrefix.h"
  5. #include "cmGlobal.h"
  6. #include "cmFloatTypes.h"
  7. #include "cmRpt.h"
  8. #include "cmErr.h"
  9. #include "cmCtx.h"
  10. #include "cmMem.h"
  11. #include "cmMallocDebug.h"
  12. #include "cmLinkedHeap.h"
  13. #include "cmThread.h"
  14. #include "cmFileSys.h"
  15. #include "cmText.h"
  16. #include "appErr.h"
  17. #include "app.h"
  18. void print( void*, const cmChar_t* text)
  19. { puts(text); }
  20. cmRC_t print_queue_cb(void* userCbPtr, unsigned msgByteCnt, const void* msgDataPtr )
  21. {
  22. print(NULL,(const char*)msgDataPtr);
  23. return cmOkRC;
  24. }
  25. int main( int argc, char* argv[] )
  26. {
  27. cmCtx_t ctx;
  28. cmTsMp1cH_t printqH = cmTsMp1cNullHandle;
  29. int appWndW = 1000;
  30. int appWndH = 750;
  31. const char* appPrefDir = "gv";
  32. const char* appTitle = "GV Console";
  33. bool memDebugFl = cmDEBUG_FL;
  34. unsigned memPadByteCnt = memDebugFl ? 8 : 0;
  35. unsigned memAlignByteCnt = 16;
  36. unsigned memFlags = memDebugFl ? (kTrackMmFl | kDeferFreeMmFl | kFillUninitMmFl) : 0;
  37. cmCtxSetup(&ctx,appTitle,print,print,NULL,memPadByteCnt,memAlignByteCnt,memFlags);
  38. // initialize the memory mgr
  39. if(cmMdInitialize( memPadByteCnt, memAlignByteCnt, memFlags, &ctx.rpt ) != kOkMmRC )
  40. {
  41. cmErrMsg(&ctx.err,kMemFailAppRC,"Heap initialization failed.");
  42. goto errLabel;
  43. }
  44. // initialize the file system
  45. if( cmFsInitialize( &ctx, appPrefDir ) != kOkFsRC )
  46. cmErrMsg(&ctx.err,kFileSysFailAppRC,"File system initialization failed.");
  47. // initialize the text system
  48. if( cmTsInitialize(&ctx) != kOkTxRC )
  49. cmErrMsg(&ctx.err,kTextSysFailAppRC,"Text system initialization failed.");
  50. // create the print queue
  51. if( cmTsMp1cCreate( &printqH, 8192, print_queue_cb, NULL, NULL ) != kOkThRC )
  52. cmErrMsg(&ctx.err,kQueueFailAppRC,"Print queue creation failed.");
  53. if( cmErrLastRC(&ctx.err) == kOkAppRC )
  54. {
  55. app proj(&ctx, printqH, appWndW, appWndH, appTitle, argc, argv);
  56. Fl::run();
  57. // reset the pgm context and print queue console output to stdout
  58. cmRptSetup(&ctx.rpt,print,print,NULL);
  59. cmTsMp1cSetCbFunc(printqH, print_queue_cb, NULL );
  60. }
  61. // empty any pending text to stdout
  62. while( cmTsMp1cMsgWaiting(printqH) )
  63. if( cmTsMp1cDequeueMsg(printqH, NULL, 0) != kOkThRC )
  64. cmErrMsg(&ctx.err,kQueueFailAppRC,"Print dequeue failed.");
  65. // destroy the print queue
  66. if( cmTsMp1cDestroy(&printqH) != kOkThRC )
  67. cmErrMsg(&ctx.err,kQueueFailAppRC,"Print queue destroy failed.");
  68. // finalize the text system
  69. if( cmTsFinalize() != kOkTxRC )
  70. cmErrMsg(&ctx.err,kTextSysFailAppRC,"Text system finalization failed.");
  71. // finalize the file system
  72. if( cmFsFinalize() != kOkFsRC )
  73. cmErrMsg(&ctx.err,kFileSysFailAppRC,"File system finalize failed.");
  74. // report memory mgr errors
  75. if( cmMdIsValid() )
  76. cmMdReport( kIgnoreNormalMmFl );
  77. // finalize the memory manager
  78. if( cmMdFinalize() != kOkMmRC )
  79. cmErrMsg(&ctx.err,kMemFailAppRC,"Heap finalization failed.");
  80. errLabel:
  81. return 0;
  82. }