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.

93 lines
2.3KB

  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. const CarlaMutexLocker cml(fWriteLock);
  54. writeMsg("show\n", 5);
  55. }
  56. protected:
  57. // returns true if msg was handled
  58. bool msgReceived(const char* const msg) noexcept override
  59. {
  60. if (std::strcmp(msg, "exiting") == 0)
  61. {
  62. waitChildClose();
  63. fUiState = UiHide;
  64. return true;
  65. }
  66. return false;
  67. }
  68. private:
  69. CarlaString fFilename;
  70. CarlaString fSampleRate;
  71. CarlaString fUiTitle;
  72. UiState fUiState;
  73. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaExternalUI)
  74. };
  75. // -----------------------------------------------------------------------
  76. #endif // CARLA_EXTERNAL_UI_HPP_INCLUDED