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.

120 lines
3.0KB

  1. /*
  2. * Carla Utility Tests
  3. * Copyright (C) 2013-2018 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 "../modules/water/files/File.h"
  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. };
  31. class CarlaPipeServer2 : public CarlaPipeServer
  32. {
  33. public:
  34. CarlaPipeServer2()
  35. : CarlaPipeServer() {}
  36. bool msgReceived(const char* const msg) noexcept override
  37. {
  38. carla_stdout("SERVER RECEIVED: \"%s\"", msg);
  39. return true;
  40. }
  41. };
  42. // -----------------------------------------------------------------------
  43. int main(int argc, const char* argv[])
  44. {
  45. if (argc != 1)
  46. {
  47. carla_stdout("CLIENT STARTED %i", argc);
  48. std::fflush(stdout);
  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. std::fflush(stdout);
  59. p.idlePipe();
  60. carla_stderr2("CLIENT idle end");
  61. std::fflush(stdout);
  62. carla_msleep(500);
  63. }
  64. else
  65. {
  66. carla_stdout("SERVER STARTED %i", argc);
  67. std::fflush(stdout);
  68. using water::File;
  69. using water::String;
  70. String path = File(File::getSpecialLocation(File::currentExecutableFile)).getFullPathName();
  71. #ifdef CARLA_OS_WINDOWS
  72. path = "wine " + path;
  73. #endif
  74. CarlaPipeServer2 p;
  75. const bool ok = p.startPipeServer(path.toRawUTF8(), "/home/falktx/Videos", "/home/falktx");
  76. CARLA_SAFE_ASSERT_RETURN(ok,1);
  77. p.lockPipe();
  78. p.writeMessage("SERVER=>CLIENT\n");
  79. p.unlockPipe();
  80. carla_msleep(500);
  81. carla_stderr2("SERVER idle start");
  82. std::fflush(stdout);
  83. p.idlePipe();
  84. carla_stderr2("SERVER idle end");
  85. std::fflush(stdout);
  86. carla_msleep(500);
  87. }
  88. return 0;
  89. }
  90. // -----------------------------------------------------------------------
  91. #include "../utils/CarlaPipeUtils.cpp"
  92. // -----------------------------------------------------------------------