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.

91 lines
2.2KB

  1. /*
  2. * Carla External UI
  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. #ifndef CARLA_EXTERNAL_UI_HPP_INCLUDED
  18. #define CARLA_EXTERNAL_UI_HPP_INCLUDED
  19. #include "CarlaPipeUtils.hpp"
  20. // -----------------------------------------------------------------------
  21. class CarlaExternalUI : public CarlaPipeServer
  22. {
  23. public:
  24. enum UiState {
  25. UiNone = 0,
  26. UiHide,
  27. UiShow,
  28. UiCrashed
  29. };
  30. CarlaExternalUI()
  31. : fUiState(UiNone)
  32. {
  33. }
  34. ~CarlaExternalUI() override
  35. {
  36. CARLA_SAFE_ASSERT_INT(fUiState == UiNone, fUiState);
  37. }
  38. UiState getAndResetUiState() noexcept
  39. {
  40. const UiState uiState(fUiState);
  41. fUiState = UiNone;
  42. return uiState;
  43. }
  44. void setData(const char* const filename, const double sampleRate, const char* const uiTitle) noexcept
  45. {
  46. fFilename = filename;
  47. fSampleRate = CarlaString(sampleRate);
  48. fUiTitle = uiTitle;
  49. }
  50. void start() noexcept
  51. {
  52. CarlaPipeServer::start(fFilename, fSampleRate, fUiTitle);
  53. writeMsg("show\n", 5);
  54. }
  55. protected:
  56. // returns true if msg was handled
  57. bool msgReceived(const char* const msg) noexcept override
  58. {
  59. if (std::strcmp(msg, "exiting") == 0)
  60. {
  61. waitChildClose();
  62. fUiState = UiHide;
  63. return true;
  64. }
  65. return false;
  66. }
  67. private:
  68. CarlaString fFilename;
  69. CarlaString fSampleRate;
  70. CarlaString fUiTitle;
  71. UiState fUiState;
  72. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaExternalUI)
  73. };
  74. // -----------------------------------------------------------------------
  75. #endif // CARLA_EXTERNAL_UI_HPP_INCLUDED