summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/audio_backend.h31
-rw-r--r--libs/ardour/ardour/audioengine.h10
-rw-r--r--libs/ardour/ardour/jack_audiobackend.h6
-rw-r--r--libs/ardour/audioengine.cc12
-rw-r--r--libs/ardour/jack_api.cc7
-rw-r--r--libs/ardour/jack_audiobackend.cc24
6 files changed, 65 insertions, 25 deletions
diff --git a/libs/ardour/ardour/audio_backend.h b/libs/ardour/ardour/audio_backend.h
index 18c8cb8931..08dd7fb0b5 100644
--- a/libs/ardour/ardour/audio_backend.h
+++ b/libs/ardour/ardour/audio_backend.h
@@ -68,6 +68,33 @@ class AudioBackend {
/* Discovering devices and parameters */
+ /** Return true if this backend requires the selection of a "driver"
+ * before any device can be selected. Return false otherwise.
+ *
+ * Intended mainly to differentiate between meta-APIs like JACK
+ * which can still expose different backends (such as ALSA or CoreAudio
+ * or FFADO or netjack) and those like ASIO or CoreAudio which
+ * do not.
+ */
+ virtual bool requires_driver_selection() const { return false; }
+
+ /** If the return value of requires_driver_selection() is true,
+ * then this function can return the list of known driver names.
+ *
+ * If the return value of requires_driver_selection() is false,
+ * then this function should not be called. If it is called
+ * its return value is an empty vector of strings.
+ */
+ virtual std::vector<std::string> enumerate_drivers() const { return std::vector<std::string>(); }
+
+ /** Returns zero if the backend can successfully use @param name as the
+ * driver, non-zero otherwise.
+ *
+ * Should not be used unless the backend returns true from
+ * requires_driver_selection()
+ */
+ virtual int set_driver (const std::string& /*drivername*/) { return 0; }
+
/** Returns a collection of strings identifying devices known
* to this backend. Any of these strings may be used to identify a
* device in other calls to the backend, though any of them may become
@@ -358,8 +385,8 @@ struct AudioBackendInfo {
* configured and does not need (re)configuration in order
* to be usable. Return false otherwise.
*
- * Note that this may return true if (re)configuration is possible,
- * but not required.
+ * Note that this may return true if (re)configuration, even though
+ * not currently required, is still possible.
*/
bool (*already_configured)();
};
diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h
index 5046206542..6fb13b7ae0 100644
--- a/libs/ardour/ardour/audioengine.h
+++ b/libs/ardour/ardour/audioengine.h
@@ -74,7 +74,8 @@ public:
int discover_backends();
std::vector<const AudioBackendInfo*> available_backends() const;
std::string current_backend_name () const;
- int set_backend (const std::string&, const std::string& arg1, const std::string& arg2);
+ boost::shared_ptr<AudioBackend> set_backend (const std::string&, const std::string& arg1, const std::string& arg2);
+ boost::shared_ptr<AudioBackend> current_backend() const { return _backend; }
bool setup_required () const;
ProcessThread* main_thread() const { return _main_thread; }
@@ -172,13 +173,6 @@ public:
PBD::Signal0<void> Running;
PBD::Signal0<void> Stopped;
- /* these two are emitted as we create backends that
- can actually be used to do stuff (e.g. register ports)
- */
-
- PBD::Signal0<void> BackendAvailable;
- PBD::Signal0<void> BackendRemoved;
-
static AudioEngine* instance() { return _instance; }
static void destroy();
void died ();
diff --git a/libs/ardour/ardour/jack_audiobackend.h b/libs/ardour/ardour/jack_audiobackend.h
index 4fef602119..59b5b88105 100644
--- a/libs/ardour/ardour/jack_audiobackend.h
+++ b/libs/ardour/ardour/jack_audiobackend.h
@@ -49,7 +49,12 @@ class JACKAudioBackend : public AudioBackend {
bool connected() const;
bool is_realtime () const;
+ bool requires_driver_selection() const;
+ std::vector<std::string> enumerate_drivers () const;
+ int set_driver (const std::string&);
+
std::vector<std::string> 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;
@@ -151,6 +156,7 @@ class JACKAudioBackend : public AudioBackend {
/* pffooo */
+ std::string _target_driver;
std::string _target_device;
float _target_sample_rate;
uint32_t _target_buffer_size;
diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc
index f9bdffb94b..0c88e7c0fd 100644
--- a/libs/ardour/audioengine.cc
+++ b/libs/ardour/audioengine.cc
@@ -561,18 +561,16 @@ AudioEngine::drop_backend ()
if (_backend) {
_backend->stop ();
_backend.reset ();
-
- BackendRemoved(); /* EMIT SIGNAL */
}
}
-int
+boost::shared_ptr<AudioBackend>
AudioEngine::set_backend (const std::string& name, const std::string& arg1, const std::string& arg2)
{
BackendMap::iterator b = _backends.find (name);
if (b == _backends.end()) {
- return -1;
+ return boost::shared_ptr<AudioBackend>();
}
drop_backend ();
@@ -590,12 +588,10 @@ AudioEngine::set_backend (const std::string& name, const std::string& arg1, cons
} catch (exception& e) {
error << string_compose (_("Could not create backend for %1: %2"), name, e.what()) << endmsg;
- return -1;
+ return boost::shared_ptr<AudioBackend>();
}
- BackendAvailable (); /* EMIT SIGNAL */
-
- return 0;
+ return _backend;
}
/* BACKEND PROXY WRAPPERS */
diff --git a/libs/ardour/jack_api.cc b/libs/ardour/jack_api.cc
index b6cf3693b5..fcfc499107 100644
--- a/libs/ardour/jack_api.cc
+++ b/libs/ardour/jack_api.cc
@@ -90,16 +90,13 @@ extern "C" {
* must be non-mangled.
*/
- using namespace ARDOUR;
-
- AudioBackendInfo descriptor = {
+ ARDOUR::AudioBackendInfo descriptor = {
"JACK",
instantiate,
deinstantiate,
backend_factory,
portengine_factory,
- already_configured
+ already_configured,
};
-
}
diff --git a/libs/ardour/jack_audiobackend.cc b/libs/ardour/jack_audiobackend.cc
index ed412f3f5a..97031cfaff 100644
--- a/libs/ardour/jack_audiobackend.cc
+++ b/libs/ardour/jack_audiobackend.cc
@@ -88,11 +88,31 @@ JACKAudioBackend::is_realtime () const
return jack_is_realtime (_priv_jack);
}
+bool
+JACKAudioBackend::requires_driver_selection() const
+{
+ return true;
+}
+
+vector<string>
+JACKAudioBackend::enumerate_drivers () const
+{
+ vector<string> s;
+ get_jack_audio_driver_names (s);
+ return s;
+}
+
+int
+JACKAudioBackend::set_driver (const std::string& name)
+{
+ _target_driver = name;
+ return 0;
+}
+
vector<string>
JACKAudioBackend::enumerate_devices () const
{
- vector<string> devices;
- return devices;
+ return get_jack_device_names_for_audio_driver (_target_driver);
}
vector<float>