Collection of tools useful for audio production
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.

112 lines
2.6KB

  1. /*
  2. * Carla Backend
  3. * Copyright (C) 2011-2012 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * 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 COPYING file
  16. */
  17. #ifndef CARLA_THREADS_H
  18. #define CARLA_THREADS_H
  19. #include "carla_backend.hpp"
  20. #include <QtCore/QMutex>
  21. #include <QtCore/QThread>
  22. CARLA_BACKEND_START_NAMESPACE
  23. class CarlaEngine;
  24. class CarlaPlugin;
  25. CARLA_BACKEND_END_NAMESPACE
  26. // --------------------------------------------------------------------------------------------------------
  27. // CarlaCheckThread
  28. class CarlaCheckThread : public QThread
  29. {
  30. public:
  31. CarlaCheckThread(CarlaBackend::CarlaEngine* const engine, QObject* const parent = nullptr);
  32. ~CarlaCheckThread();
  33. void startNow();
  34. void stopNow();
  35. protected:
  36. void run();
  37. private:
  38. CarlaBackend::CarlaEngine* const engine;
  39. QMutex mutex;
  40. bool m_stopNow;
  41. // ----------------------------------------------
  42. class ScopedLocker
  43. {
  44. public:
  45. ScopedLocker(CarlaCheckThread* const thread)
  46. : m_thread(thread)
  47. {
  48. m_thread->mutex.lock();
  49. }
  50. ~ScopedLocker()
  51. {
  52. m_thread->mutex.unlock();
  53. }
  54. private:
  55. CarlaCheckThread* const m_thread;
  56. };
  57. };
  58. // --------------------------------------------------------------------------------------------------------
  59. // CarlaPluginThread
  60. #ifndef BUILD_BRIDGE
  61. class QProcess;
  62. class CarlaPluginThread : public QThread
  63. {
  64. public:
  65. enum PluginThreadMode {
  66. PLUGIN_THREAD_DSSI_GUI,
  67. PLUGIN_THREAD_LV2_GUI,
  68. PLUGIN_THREAD_VST_GUI,
  69. PLUGIN_THREAD_BRIDGE
  70. };
  71. CarlaPluginThread(CarlaBackend::CarlaEngine* const engine, CarlaBackend::CarlaPlugin* const plugin, const PluginThreadMode mode, QObject* const parent = nullptr);
  72. ~CarlaPluginThread();
  73. void setOscData(const char* const binary, const char* const label, const char* const data1="");
  74. protected:
  75. void run();
  76. private:
  77. CarlaBackend::CarlaEngine* const engine;
  78. CarlaBackend::CarlaPlugin* const plugin;
  79. const PluginThreadMode mode;
  80. QString m_binary;
  81. QString m_label;
  82. QString m_data1;
  83. QProcess* m_process;
  84. };
  85. #endif
  86. #endif // CARLA_THREADS_H