Audio plugin host https://kx.studio/carla
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.

105 lines
2.8KB

  1. /*
  2. * Carla Utility Tests
  3. * Copyright (C) 2013-2014 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #include "CarlaPipeUtils.hpp"
  18. #include "CarlaSemUtils.hpp"
  19. // -----------------------------------------------------------------------
  20. class CarlaPipeClient2 : public CarlaPipeClient
  21. {
  22. public:
  23. CarlaPipeClient2()
  24. : CarlaPipeClient() {}
  25. bool msgReceived(const char* const msg) noexcept override
  26. {
  27. carla_stdout("CLIENT RECEIVED: \"%s\"", msg);
  28. return true;
  29. }
  30. sem_t sem;
  31. };
  32. class CarlaPipeServer2 : public CarlaPipeServer
  33. {
  34. public:
  35. CarlaPipeServer2()
  36. : CarlaPipeServer() {}
  37. bool msgReceived(const char* const msg) noexcept override
  38. {
  39. carla_stdout("SERVER RECEIVED: \"%s\"", msg);
  40. return true;
  41. }
  42. };
  43. // -----------------------------------------------------------------------
  44. int main(int argc, const char* argv[])
  45. {
  46. if (argc != 1)
  47. {
  48. carla_stdout("CLIENT STARTED %i", argc);
  49. CarlaPipeClient2 p;
  50. const bool ok = p.initPipeClient(argv);
  51. CARLA_SAFE_ASSERT_RETURN(ok,1);
  52. p.lockPipe();
  53. p.writeMessage("CLIENT=>SERVER\n");
  54. p.writeAndFixMessage("heheheheheh");
  55. p.unlockPipe();
  56. carla_msleep(500);
  57. carla_stderr2("CLIENT idle start");
  58. p.idlePipe();
  59. carla_stderr2("CLIENT idle end");
  60. carla_msleep(500);
  61. }
  62. else
  63. {
  64. carla_stdout("SERVER STARTED %i", argc);
  65. CarlaPipeServer2 p;
  66. #ifdef CARLA_OS_WIN
  67. const bool ok = p.startPipeServer("H:\\Source\\falkTX\\Carla\\source\\tests\\CarlaPipeUtils.exe", "/home/falktx/Videos", "/home/falktx");
  68. #else
  69. const bool ok = p.startPipeServer("/home/falktx/Source/falkTX/Carla/source/tests/CarlaPipeUtils", "/home/falktx/Videos", "/home/falktx");
  70. #endif
  71. CARLA_SAFE_ASSERT_RETURN(ok,1);
  72. p.lockPipe();
  73. p.writeMessage("SERVER=>CLIENT\n");
  74. p.unlockPipe();
  75. carla_msleep(500);
  76. carla_stderr2("SERVER idle start");
  77. p.idlePipe();
  78. carla_stderr2("SERVER idle end");
  79. carla_msleep(500);
  80. }
  81. return 0;
  82. }
  83. // -----------------------------------------------------------------------
  84. #include "../utils/CarlaPipeUtils.cpp"
  85. // -----------------------------------------------------------------------