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.

107 lines
2.5KB

  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.h"
  20. #include <QtCore/QMutex>
  21. #include <QtCore/QThread>
  22. // --------------------------------------------------------------------------------------------------------
  23. // CarlaCheckThread
  24. class CarlaCheckThread : public QThread
  25. {
  26. public:
  27. CarlaCheckThread(CarlaBackend::CarlaEngine* const engine, QObject* const parent = nullptr);
  28. ~CarlaCheckThread();
  29. void startNow();
  30. void stopNow();
  31. protected:
  32. void run();
  33. private:
  34. CarlaBackend::CarlaEngine* const engine;
  35. QMutex mutex;
  36. bool m_stopNow;
  37. // ----------------------------------------------
  38. class ScopedLocker
  39. {
  40. public:
  41. ScopedLocker(CarlaCheckThread* const thread)
  42. : m_thread(thread)
  43. {
  44. m_thread->mutex.lock();
  45. }
  46. ~ScopedLocker()
  47. {
  48. m_thread->mutex.unlock();
  49. }
  50. private:
  51. CarlaCheckThread* const m_thread;
  52. };
  53. };
  54. // --------------------------------------------------------------------------------------------------------
  55. // CarlaPluginThread
  56. #ifndef BUILD_BRIDGE
  57. class QProcess;
  58. class CarlaPluginThread : public QThread
  59. {
  60. public:
  61. enum PluginThreadMode {
  62. PLUGIN_THREAD_DSSI_GUI,
  63. PLUGIN_THREAD_LV2_GUI,
  64. PLUGIN_THREAD_VST_GUI,
  65. PLUGIN_THREAD_BRIDGE
  66. };
  67. CarlaPluginThread(CarlaBackend::CarlaEngine* const engine, CarlaBackend::CarlaPlugin* const plugin, const PluginThreadMode mode, QObject* const parent = nullptr);
  68. ~CarlaPluginThread();
  69. void setOscData(const char* const binary, const char* const label, const char* const data1="");
  70. protected:
  71. void run();
  72. private:
  73. CarlaBackend::CarlaEngine* const engine;
  74. CarlaBackend::CarlaPlugin* const plugin;
  75. const PluginThreadMode mode;
  76. QString m_binary;
  77. QString m_label;
  78. QString m_data1;
  79. QProcess* m_process;
  80. };
  81. #endif
  82. #endif // CARLA_THREADS_H