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.

102 lines
2.5KB

  1. /*
  2. * Carla Backend
  3. * Copyright (C) 2011-2012 Filipe Coelho <falktx@gmail.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 stopNow();
  30. protected:
  31. void run();
  32. private:
  33. CarlaBackend::CarlaEngine* const engine;
  34. QMutex mutex;
  35. bool m_stopNow;
  36. // ----------------------------------------------
  37. class ScopedLocker
  38. {
  39. public:
  40. ScopedLocker(CarlaCheckThread* const thread)
  41. : m_thread(thread)
  42. {
  43. m_thread->mutex.lock();
  44. }
  45. ~ScopedLocker()
  46. {
  47. m_thread->mutex.unlock();
  48. }
  49. private:
  50. CarlaCheckThread* const m_thread;
  51. };
  52. };
  53. // --------------------------------------------------------------------------------------------------------
  54. // CarlaPluginThread
  55. class QProcess;
  56. class CarlaPluginThread : public QThread
  57. {
  58. public:
  59. enum PluginThreadMode {
  60. PLUGIN_THREAD_DSSI_GUI,
  61. PLUGIN_THREAD_LV2_GUI,
  62. PLUGIN_THREAD_VST_GUI,
  63. PLUGIN_THREAD_BRIDGE
  64. };
  65. CarlaPluginThread(CarlaBackend::CarlaEngine* const engine, CarlaBackend::CarlaPlugin* const plugin, const PluginThreadMode mode, QObject* const parent = nullptr);
  66. ~CarlaPluginThread();
  67. void setOscData(const char* const binary, const char* const label, const char* const data1="");
  68. protected:
  69. void run();
  70. private:
  71. CarlaBackend::CarlaEngine* const engine;
  72. CarlaBackend::CarlaPlugin* const plugin;
  73. const PluginThreadMode mode;
  74. QString m_binary;
  75. QString m_label;
  76. QString m_data1;
  77. QProcess* m_process;
  78. };
  79. #endif // CARLA_THREADS_H