summaryrefslogtreecommitdiffstats
path: root/src/Drivers.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-05-11 12:04:36 -0400
committerDavid Robillard <d@drobilla.net>2021-05-11 13:35:16 -0400
commit75ee1ed27d5d2c60e867abef09ee920446ac13de (patch)
tree7c711813cf6282de24f08c96fd6e5465ea7414e5 /src/Drivers.hpp
parent37ede19b4d1e924f954d8b16d3e071a4768ce278 (diff)
downloadpatchage-75ee1ed27d5d2c60e867abef09ee920446ac13de.tar.gz
patchage-75ee1ed27d5d2c60e867abef09ee920446ac13de.tar.bz2
patchage-75ee1ed27d5d2c60e867abef09ee920446ac13de.zip
Move drivers to a separate object
Towards eliminating dependencies on the Patchage "god object".
Diffstat (limited to 'src/Drivers.hpp')
-rw-r--r--src/Drivers.hpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/Drivers.hpp b/src/Drivers.hpp
new file mode 100644
index 0000000..0e3cdce
--- /dev/null
+++ b/src/Drivers.hpp
@@ -0,0 +1,65 @@
+/* This file is part of Patchage.
+ * Copyright 2007-2021 David Robillard <d@drobilla.net>
+ *
+ * Patchage is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Patchage is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Patchage. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PATCHAGE_DRIVERS_HPP
+#define PATCHAGE_DRIVERS_HPP
+
+#include "ClientType.hpp"
+#include "Driver.hpp"
+
+#include <memory>
+
+namespace patchage {
+
+class AudioDriver;
+class ILog;
+
+/// Manager for all drivers
+class Drivers
+{
+public:
+ Drivers(ILog& log, Driver::EventSink emit_event);
+
+ Drivers(const Drivers&) = delete;
+ Drivers& operator=(const Drivers&) = delete;
+
+ Drivers(Drivers&&) = delete;
+ Drivers& operator=(Drivers&&) = delete;
+
+ ~Drivers() = default;
+
+ /// Refresh all drivers and emit results to the event sink
+ void refresh();
+
+ /// Return a pointer to the driver for the given client type (or null)
+ Driver* driver(ClientType type);
+
+ /// Return a pointer to the ALSA driver (or null)
+ const std::unique_ptr<Driver>& alsa() { return _alsa_driver; }
+
+ /// Return a pointer to the JACK driver (or null)
+ const std::unique_ptr<AudioDriver>& jack() { return _jack_driver; }
+
+protected:
+ ILog& _log;
+ std::unique_ptr<Driver> _alsa_driver;
+ std::unique_ptr<AudioDriver> _jack_driver;
+ Driver::EventSink _emit_event;
+};
+
+} // namespace patchage
+
+#endif // PATCHAGE_DRIVER_HPP