summaryrefslogtreecommitdiffstats
path: root/src/AudioDriver.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-11-29 17:14:35 +0100
committerDavid Robillard <d@drobilla.net>2020-11-29 18:03:31 +0100
commit78b359c44b67f4f1fff9e31dd9243af5e996f38a (patch)
tree59aeee028fd339894e94eb21fc5cdbf53a2b8c5d /src/AudioDriver.hpp
parentd3561e8cf1d5a289ff2ce4a26e4a970437a812d5 (diff)
downloadpatchage-78b359c44b67f4f1fff9e31dd9243af5e996f38a.tar.gz
patchage-78b359c44b67f4f1fff9e31dd9243af5e996f38a.tar.bz2
patchage-78b359c44b67f4f1fff9e31dd9243af5e996f38a.zip
Add AudioDriver interface
Diffstat (limited to 'src/AudioDriver.hpp')
-rw-r--r--src/AudioDriver.hpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/AudioDriver.hpp b/src/AudioDriver.hpp
new file mode 100644
index 0000000..7e1e5a7
--- /dev/null
+++ b/src/AudioDriver.hpp
@@ -0,0 +1,48 @@
+/* This file is part of Patchage.
+ * Copyright 2007-2020 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_AUDIODRIVER_HPP
+#define PATCHAGE_AUDIODRIVER_HPP
+
+#include "Driver.hpp"
+
+#include <cstdint>
+
+/// Base class for drivers that work with an audio system
+class AudioDriver : public Driver
+{
+public:
+ explicit AudioDriver(EventSink emit_event)
+ : Driver{std::move(emit_event)}
+ {}
+
+ /// Return the number of xruns (dropouts) since the last reset
+ virtual uint32_t xruns() = 0;
+
+ /// Reset the xrun count
+ virtual void reset_xruns() = 0;
+
+ /// Return the current buffer size in frames
+ virtual uint32_t buffer_size() = 0;
+
+ /// Try to set the current buffer size in frames, return true on success
+ virtual bool set_buffer_size(uint32_t frames) = 0;
+
+ /// Return the current sample rate in Hz
+ virtual uint32_t sample_rate() = 0;
+};
+
+#endif // PATCHAGE_AUDIODRIVER_HPP