summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-04-28 21:29:35 +0200
committerRobin Gareus <robin@gareus.org>2014-04-28 21:29:35 +0200
commit9907d25ea572f008fcb626eb7cc7ffa4cf9e1d82 (patch)
tree5da180483ae646298b7a46b09f49611f525c5529 /libs
parentc2a376a82285fac5a72eb2fd4680978186212f37 (diff)
skeleton dummy audio-engine
Diffstat (limited to 'libs')
-rw-r--r--libs/backends/dummy/dummy_audiobackend.cc583
-rw-r--r--libs/backends/dummy/dummy_audiobackend.h169
-rw-r--r--libs/backends/dummy/wscript37
-rw-r--r--libs/backends/wscript2
4 files changed, 790 insertions, 1 deletions
diff --git a/libs/backends/dummy/dummy_audiobackend.cc b/libs/backends/dummy/dummy_audiobackend.cc
new file mode 100644
index 0000000000..1e212714b7
--- /dev/null
+++ b/libs/backends/dummy/dummy_audiobackend.cc
@@ -0,0 +1,583 @@
+/*
+ * Copyright (C) 2014 Robin Gareus <robin@gareus.org>
+ * Copyright (C) 2013 Paul Davis
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include "dummy_audiobackend.h"
+#include "pbd/error.h"
+#include "i18n.h"
+
+using namespace ARDOUR;
+
+static std::string s_instance_name;
+DummyAudioBackend::DummyAudioBackend (AudioEngine& e)
+ : AudioBackend (e)
+{
+ _instance_name = s_instance_name;
+}
+
+DummyAudioBackend::~DummyAudioBackend ()
+{
+}
+
+/* AUDIOBACKEND API */
+
+std::string
+DummyAudioBackend::name () const
+{
+ return X_("Dummy");
+}
+
+bool
+DummyAudioBackend::is_realtime () const
+{
+ return false;
+}
+
+std::vector<AudioBackend::DeviceStatus>
+DummyAudioBackend::enumerate_devices () const
+{
+ std::vector<AudioBackend::DeviceStatus> s;
+ s.push_back (DeviceStatus (_("Dummy"), true));
+ return s;
+}
+
+std::vector<float>
+DummyAudioBackend::available_sample_rates (const std::string&) const
+{
+ std::vector<float> sr;
+ sr.push_back (44100.0);
+ sr.push_back (48000.0);
+ return sr;
+}
+
+std::vector<uint32_t>
+DummyAudioBackend::available_buffer_sizes (const std::string&) const
+{
+ std::vector<uint32_t> bs;
+ bs.push_back (64);
+ bs.push_back (1024);
+ return bs;
+}
+
+uint32_t
+DummyAudioBackend::available_input_channel_count (const std::string&) const
+{
+ return 128;
+}
+
+uint32_t
+DummyAudioBackend::available_output_channel_count (const std::string&) const
+{
+ return 128;
+}
+
+bool
+DummyAudioBackend::can_change_sample_rate_when_running () const
+{
+ return false;
+}
+
+bool
+DummyAudioBackend::can_change_buffer_size_when_running () const
+{
+ return false;
+}
+
+int
+DummyAudioBackend::set_device_name (const std::string&)
+{
+ return -1;
+}
+
+int
+DummyAudioBackend::set_sample_rate (float)
+{
+ return -1;
+}
+
+int
+DummyAudioBackend::set_buffer_size (uint32_t)
+{
+ return -1;
+}
+
+int
+DummyAudioBackend::set_interleaved (bool yn)
+{
+ if (!yn) { return 0; }
+ return -1;
+}
+
+int
+DummyAudioBackend::set_input_channels (uint32_t)
+{
+ return -1;
+}
+
+int
+DummyAudioBackend::set_output_channels (uint32_t)
+{
+ return -1;
+}
+
+int
+DummyAudioBackend::set_systemic_input_latency (uint32_t)
+{
+ return -1;
+}
+
+int
+DummyAudioBackend::set_systemic_output_latency (uint32_t)
+{
+ return -1;
+}
+
+/* Retrieving parameters */
+std::string
+DummyAudioBackend::device_name () const
+{
+ return _("Dummy Device");
+}
+
+float
+DummyAudioBackend::sample_rate () const
+{
+ return 0;
+}
+
+uint32_t
+DummyAudioBackend::buffer_size () const
+{
+ return 0;
+}
+
+bool
+DummyAudioBackend::interleaved () const
+{
+ return false;
+}
+
+uint32_t
+DummyAudioBackend::input_channels () const
+{
+ return 0;
+}
+
+uint32_t
+DummyAudioBackend::output_channels () const
+{
+ return 0;
+}
+
+uint32_t
+DummyAudioBackend::systemic_input_latency () const
+{
+ return 0;
+}
+
+uint32_t
+DummyAudioBackend::systemic_output_latency () const
+{
+ return 0;
+}
+
+/* MIDI */
+std::vector<std::string>
+DummyAudioBackend::enumerate_midi_options () const
+{
+ std::vector<std::string> m;
+ m.push_back (_("None"));
+ return m;
+}
+
+int
+DummyAudioBackend::set_midi_option (const std::string&)
+{
+ return -1;
+}
+
+std::string
+DummyAudioBackend::midi_option () const
+{
+ return "";
+}
+
+/* State Control */
+
+int
+DummyAudioBackend::_start (bool /*for_latency_measurement*/)
+{
+ return -1;
+}
+
+int
+DummyAudioBackend::stop ()
+{
+ return -1;
+}
+
+int
+DummyAudioBackend::freewheel (bool)
+{
+ return 0;
+}
+
+float
+DummyAudioBackend::dsp_load () const
+{
+ return 0.0;
+}
+
+size_t
+DummyAudioBackend::raw_buffer_size (DataType t)
+{
+ return 0;
+}
+
+/* Process time */
+pframes_t
+DummyAudioBackend::sample_time ()
+{
+ return 0;
+}
+
+pframes_t
+DummyAudioBackend::sample_time_at_cycle_start ()
+{
+ return 0;
+}
+
+pframes_t
+DummyAudioBackend::samples_since_cycle_start ()
+{
+ return 0;
+}
+
+int
+DummyAudioBackend::create_process_thread (boost::function<void()> func)
+{
+ return -1;
+}
+
+int
+DummyAudioBackend::join_process_threads ()
+{
+ return -1;
+}
+
+bool
+DummyAudioBackend::in_process_thread ()
+{
+ return false;
+}
+
+uint32_t
+DummyAudioBackend::process_thread_count ()
+{
+ return 0;
+}
+
+void
+DummyAudioBackend::update_latencies ()
+{
+}
+
+/* PORTENGINE API */
+
+void*
+DummyAudioBackend::private_handle () const
+{
+ return NULL;
+}
+
+const std::string&
+DummyAudioBackend::my_name () const
+{
+ return _instance_name;
+}
+
+bool
+DummyAudioBackend::available () const
+{
+ return true;
+}
+
+uint32_t
+DummyAudioBackend::port_name_size () const
+{
+ return 256;
+}
+
+int
+DummyAudioBackend::set_port_name (PortEngine::PortHandle, const std::string&)
+{
+ return -1;
+}
+
+std::string
+DummyAudioBackend::get_port_name (PortEngine::PortHandle) const
+{
+ return "port:XXX";
+}
+
+PortEngine::PortHandle
+DummyAudioBackend::get_port_by_name (const std::string&) const
+{
+ PortEngine::PortHandle port_handle = 0;
+ return port_handle;
+}
+
+int
+DummyAudioBackend::get_ports (
+ const std::string& port_name_pattern,
+ DataType type, PortFlags flags,
+ std::vector<std::string>&) const
+{
+ return 0;
+}
+
+DataType
+DummyAudioBackend::port_data_type (PortEngine::PortHandle) const
+{
+ return DataType::AUDIO;
+}
+
+PortEngine::PortHandle
+DummyAudioBackend::register_port (
+ const std::string&,
+ ARDOUR::DataType,
+ ARDOUR::PortFlags)
+{
+ PortEngine::PortHandle port_handle = 0;
+ return port_handle;
+}
+
+void
+DummyAudioBackend::unregister_port (PortEngine::PortHandle)
+{
+}
+
+int
+DummyAudioBackend::connect (const std::string& src, const std::string& dst)
+{
+ return -1;
+}
+
+int
+DummyAudioBackend::disconnect (const std::string& src, const std::string& dst)
+{
+ return -1;
+}
+
+int
+DummyAudioBackend::connect (PortEngine::PortHandle, const std::string&)
+{
+ return -1;
+}
+
+int
+DummyAudioBackend::disconnect (PortEngine::PortHandle, const std::string&)
+{
+ return -1;
+}
+
+int
+DummyAudioBackend::disconnect_all (PortEngine::PortHandle)
+{
+ return -1;
+}
+
+bool
+DummyAudioBackend::connected (PortEngine::PortHandle, bool process_callback_safe)
+{
+ return false;
+}
+
+bool
+DummyAudioBackend::connected_to (PortEngine::PortHandle, const std::string&, bool process_callback_safe)
+{
+ return false;
+}
+
+bool
+DummyAudioBackend::physically_connected (PortEngine::PortHandle, bool process_callback_safe)
+{
+ return false;
+}
+
+int
+DummyAudioBackend::get_connections (PortEngine::PortHandle, std::vector<std::string>&, bool process_callback_safe)
+{
+ return false;
+}
+
+/* MIDI */
+int
+DummyAudioBackend::midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** buf, void* port_buffer, uint32_t event_index)
+{
+ return -1;
+}
+
+int
+DummyAudioBackend::midi_event_put (void* port_buffer, pframes_t timestamp, const uint8_t* buffer, size_t size)
+{
+ return -1;
+}
+
+uint32_t
+DummyAudioBackend::get_midi_event_count (void* port_buffer)
+{
+ return -1;
+}
+
+void
+DummyAudioBackend::midi_clear (void* port_buffer)
+{
+}
+
+/* Monitoring */
+
+bool
+DummyAudioBackend::can_monitor_input () const
+{
+ return false;
+}
+
+int
+DummyAudioBackend::request_input_monitoring (PortEngine::PortHandle, bool)
+{
+ return -1;
+}
+
+int
+DummyAudioBackend::ensure_input_monitoring (PortEngine::PortHandle, bool)
+{
+ return -1;
+}
+
+bool
+DummyAudioBackend::monitoring_input (PortEngine::PortHandle)
+{
+ return false;
+}
+
+/* Latency management */
+
+void
+DummyAudioBackend::set_latency_range (PortEngine::PortHandle, bool for_playback, LatencyRange)
+{
+}
+
+LatencyRange
+DummyAudioBackend::get_latency_range (PortEngine::PortHandle, bool for_playback)
+{
+ LatencyRange r;
+ r.min = 0;
+ r.max = 0;
+ return r;
+}
+
+/* Discovering physical ports */
+
+bool
+DummyAudioBackend::port_is_physical (PortEngine::PortHandle) const
+{
+ return false;
+}
+
+void
+DummyAudioBackend::get_physical_outputs (DataType type, std::vector<std::string>&)
+{
+}
+
+void
+DummyAudioBackend::get_physical_inputs (DataType type, std::vector<std::string>&)
+{
+}
+
+ChanCount
+DummyAudioBackend::n_physical_outputs () const
+{
+ ChanCount cc;
+ cc.set (DataType::AUDIO, 0);
+ cc.set (DataType::MIDI, 0);
+ return cc;
+}
+
+ChanCount
+DummyAudioBackend::n_physical_inputs () const
+{
+ ChanCount cc;
+ cc.set (DataType::AUDIO, 0);
+ cc.set (DataType::MIDI, 0);
+ return cc;
+}
+
+/* Getting access to the data buffer for a port */
+
+void*
+DummyAudioBackend::get_buffer (PortEngine::PortHandle, pframes_t)
+{
+ return 0;
+}
+
+/******************************************************************************/
+
+static boost::shared_ptr<DummyAudioBackend> _instance;
+
+static boost::shared_ptr<AudioBackend>
+backend_factory (AudioEngine& e)
+{
+ if (!_instance) {
+ _instance.reset (new DummyAudioBackend (e));
+ }
+ return _instance;
+}
+
+static int
+instantiate (const std::string& arg1, const std::string& /* arg2 */)
+{
+ s_instance_name = arg1;
+ return 0;
+}
+
+static int
+deinstantiate ()
+{
+ _instance.reset ();
+ return 0;
+}
+
+static bool
+already_configured ()
+{
+ return false;
+}
+
+static ARDOUR::AudioBackendInfo _descriptor = {
+ "Dummy",
+ instantiate,
+ deinstantiate,
+ backend_factory,
+ already_configured,
+};
+
+extern "C" ARDOURBACKEND_API ARDOUR::AudioBackendInfo* descriptor ()
+{
+ return &_descriptor;
+}
diff --git a/libs/backends/dummy/dummy_audiobackend.h b/libs/backends/dummy/dummy_audiobackend.h
new file mode 100644
index 0000000000..4a6e2ff30b
--- /dev/null
+++ b/libs/backends/dummy/dummy_audiobackend.h
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2014 Robin Gareus <robin@gareus.org>
+ * Copyright (C) 2013 Paul Davis
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __libbackend_dummy_audiobackend_h__
+#define __libbackend_dummy_audiobackend_h__
+
+#include <string>
+#include <vector>
+#include <map>
+#include <set>
+
+#include <stdint.h>
+
+#include "ardour/types.h"
+#include "ardour/audio_backend.h"
+
+namespace ARDOUR {
+
+class DummyAudioBackend : public AudioBackend {
+ public:
+ DummyAudioBackend (AudioEngine& e);
+ ~DummyAudioBackend ();
+
+ /* AUDIOBACKEND API */
+
+ std::string name () const;
+ bool is_realtime () const;
+
+ std::vector<DeviceStatus> enumerate_devices () const;
+ std::vector<float> available_sample_rates (const std::string& device) const;
+ std::vector<uint32_t> available_buffer_sizes (const std::string& device) const;
+ uint32_t available_input_channel_count (const std::string& device) const;
+ uint32_t available_output_channel_count (const std::string& device) const;
+
+ bool can_change_sample_rate_when_running () const;
+ bool can_change_buffer_size_when_running () const;
+
+ int set_device_name (const std::string&);
+ int set_sample_rate (float);
+ int set_buffer_size (uint32_t);
+ int set_interleaved (bool yn);
+ int set_input_channels (uint32_t);
+ int set_output_channels (uint32_t);
+ int set_systemic_input_latency (uint32_t);
+ int set_systemic_output_latency (uint32_t);
+
+ /* Retrieving parameters */
+ std::string device_name () const;
+ float sample_rate () const;
+ uint32_t buffer_size () const;
+ bool interleaved () const;
+ uint32_t input_channels () const;
+ uint32_t output_channels () const;
+ uint32_t systemic_input_latency () const;
+ uint32_t systemic_output_latency () const;
+
+ /* External control app */
+ std::string control_app_name () const { return std::string (); }
+ void launch_control_app () {}
+
+ /* MIDI */
+ std::vector<std::string> enumerate_midi_options () const;
+ int set_midi_option (const std::string&);
+ std::string midi_option () const;
+
+ /* State Control */
+ protected:
+ int _start (bool for_latency_measurement);
+ public:
+ int stop ();
+ int freewheel (bool);
+ float dsp_load () const;
+ size_t raw_buffer_size (DataType t);
+
+ /* Process time */
+ pframes_t sample_time ();
+ pframes_t sample_time_at_cycle_start ();
+ pframes_t samples_since_cycle_start ();
+
+ int create_process_thread (boost::function<void()> func);
+ int join_process_threads ();
+ bool in_process_thread ();
+ uint32_t process_thread_count ();
+
+ void update_latencies ();
+
+ /* PORTENGINE API */
+
+ void* private_handle () const;
+ const std::string& my_name () const;
+ bool available () const;
+ uint32_t port_name_size () const;
+
+ int set_port_name (PortHandle, const std::string&);
+ std::string get_port_name (PortHandle) const;
+ PortHandle get_port_by_name (const std::string&) const;
+
+ int get_ports (const std::string& port_name_pattern, DataType type, PortFlags flags, std::vector<std::string>&) const;
+
+ DataType port_data_type (PortHandle) const;
+
+ PortHandle register_port (const std::string& shortname, ARDOUR::DataType, ARDOUR::PortFlags);
+ void unregister_port (PortHandle);
+
+ int connect (const std::string& src, const std::string& dst);
+ int disconnect (const std::string& src, const std::string& dst);
+ int connect (PortHandle, const std::string&);
+ int disconnect (PortHandle, const std::string&);
+ int disconnect_all (PortHandle);
+
+ bool connected (PortHandle, bool process_callback_safe);
+ bool connected_to (PortHandle, const std::string&, bool process_callback_safe);
+ bool physically_connected (PortHandle, bool process_callback_safe);
+ int get_connections (PortHandle, std::vector<std::string>&, bool process_callback_safe);
+
+ /* MIDI */
+ int midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** buf, void* port_buffer, uint32_t event_index);
+ int midi_event_put (void* port_buffer, pframes_t timestamp, const uint8_t* buffer, size_t size);
+ uint32_t get_midi_event_count (void* port_buffer);
+ void midi_clear (void* port_buffer);
+
+ /* Monitoring */
+
+ bool can_monitor_input () const;
+ int request_input_monitoring (PortHandle, bool);
+ int ensure_input_monitoring (PortHandle, bool);
+ bool monitoring_input (PortHandle);
+
+ /* Latency management */
+
+ void set_latency_range (PortHandle, bool for_playback, LatencyRange);
+ LatencyRange get_latency_range (PortHandle, bool for_playback);
+
+ /* Discovering physical ports */
+
+ bool port_is_physical (PortHandle) const;
+ void get_physical_outputs (DataType type, std::vector<std::string>&);
+ void get_physical_inputs (DataType type, std::vector<std::string>&);
+ ChanCount n_physical_outputs () const;
+ ChanCount n_physical_inputs () const;
+
+ /* Getting access to the data buffer for a port */
+
+ void* get_buffer (PortHandle, pframes_t);
+
+
+ private:
+ std::string _instance_name;
+}; // class DummyAudioBackend
+
+} // namespace
+
+#endif /* __libbackend_dummy_audiobackend_h__ */
diff --git a/libs/backends/dummy/wscript b/libs/backends/dummy/wscript
new file mode 100644
index 0000000000..c6ac7e74b3
--- /dev/null
+++ b/libs/backends/dummy/wscript
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+from waflib.extras import autowaf as autowaf
+import os
+import sys
+import re
+
+# Library version (UNIX style major, minor, micro)
+# major increment <=> incompatible changes
+# minor increment <=> compatible changes (additions)
+# micro increment <=> no interface changes
+DUMMYBACKEND_VERSION = '0.0.1'
+I18N_PACKAGE = 'dummy-backend'
+
+# Mandatory variables
+top = '.'
+out = 'build'
+
+def options(opt):
+ autowaf.set_options(opt)
+
+def configure(conf):
+ autowaf.configure(conf)
+
+def build(bld):
+ obj = bld(features = 'cxx cxxshlib')
+ obj.source = [
+ 'dummy_audiobackend.cc',
+ ]
+ obj.includes = ['.']
+ obj.name = 'dummy_audiobackend'
+ obj.target = 'dummy_audiobackend'
+ obj.use = 'libardour libpbd'
+ obj.vnum = DUMMYBACKEND_VERSION
+ obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3', 'backends')
+ obj.defines = ['PACKAGE="' + I18N_PACKAGE + '"',
+ 'ARDOURBACKEND_DLL_EXPORTS'
+ ]
diff --git a/libs/backends/wscript b/libs/backends/wscript
index f27071127a..36ef5c1ecd 100644
--- a/libs/backends/wscript
+++ b/libs/backends/wscript
@@ -7,7 +7,7 @@ import sys
top = '.'
out = 'build'
-backends = [ 'jack' ]
+backends = [ 'jack', 'dummy' ]
if sys.platform == 'darwin':
backends += ['wavesaudio' ]