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.

106 lines
2.8KB

  1. /*
  2. * Carla Utility Tests
  3. * Copyright (C) 2013-2016 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 "juce_core/juce_core.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. using juce::File;
  68. using juce::String;
  69. String path = File(File::getSpecialLocation(File::currentExecutableFile)).getFullPathName();
  70. CarlaPipeServer2 p;
  71. const bool ok = p.startPipeServer(path.toRawUTF8(), "/home/falktx/Videos", "/home/falktx");
  72. CARLA_SAFE_ASSERT_RETURN(ok,1);
  73. p.lockPipe();
  74. p.writeMessage("SERVER=>CLIENT\n");
  75. p.unlockPipe();
  76. carla_msleep(500);
  77. carla_stderr2("SERVER idle start");
  78. p.idlePipe();
  79. carla_stderr2("SERVER idle end");
  80. carla_msleep(500);
  81. }
  82. return 0;
  83. }
  84. // -----------------------------------------------------------------------
  85. #include "../utils/CarlaPipeUtils.cpp"
  86. // -----------------------------------------------------------------------