summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2013-09-17 21:23:30 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2013-09-17 21:23:30 -0400
commitfd23ebd0886cd61f8ee68d52d6576d00a16c9032 (patch)
tree3266dfd8b1deefc1b8ec60f0c9098d99ecac966c /libs
parent5e0e41e068a04603198a4e50464d794156f42c47 (diff)
parent402d92889a358949af3ea7ad0dd5be88a5652626 (diff)
Merge branch 'master' into cairocanvas
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/audio_backend.h5
-rw-r--r--libs/ardour/audioengine.cc25
-rw-r--r--libs/backends/jack/jack_audiobackend.cc82
-rw-r--r--libs/backends/jack/jack_audiobackend.h1
-rw-r--r--libs/backends/jack/jack_connection.cc14
-rw-r--r--libs/backends/jack/jack_connection.h5
6 files changed, 108 insertions, 24 deletions
diff --git a/libs/ardour/ardour/audio_backend.h b/libs/ardour/ardour/audio_backend.h
index 4d57f0b43d..9052acd530 100644
--- a/libs/ardour/ardour/audio_backend.h
+++ b/libs/ardour/ardour/audio_backend.h
@@ -223,6 +223,11 @@ class AudioBackend : public PortEngine {
virtual uint32_t systemic_input_latency () const = 0;
virtual uint32_t systemic_output_latency () const = 0;
+ /** override this if this implementation returns true from
+ * requires_driver_selection()
+ */
+ virtual std::string driver_name() const { return std::string(); }
+
/** Return the name of a control application for the
* selected/in-use device. If no such application exists,
* or if no device has been selected or is in-use,
diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc
index 567f3c7671..465f88de56 100644
--- a/libs/ardour/audioengine.cc
+++ b/libs/ardour/audioengine.cc
@@ -1039,12 +1039,22 @@ AudioEngine::start_latency_detection ()
delete _mtdm;
_mtdm = 0;
+ /* find the ports we will connect to */
+
+ PortEngine::PortHandle* out = pe.get_port_by_name (_latency_output_name);
+ PortEngine::PortHandle* in = pe.get_port_by_name (_latency_input_name);
+
+ if (!out || !in) {
+ return;
+ }
+
/* create the ports we will use to read/write data */
if ((_latency_output_port = pe.register_port ("latency_out", DataType::AUDIO, IsOutput)) == 0) {
return;
}
if (pe.connect (_latency_output_port, _latency_output_name)) {
+ pe.unregister_port (_latency_output_port);
return;
}
@@ -1060,9 +1070,9 @@ AudioEngine::start_latency_detection ()
LatencyRange lr;
_latency_signal_latency = 0;
- lr = pe.get_latency_range (_latency_input_port, false);
+ lr = pe.get_latency_range (in, false);
_latency_signal_latency = lr.max;
- lr = pe.get_latency_range (_latency_output_port, true);
+ lr = pe.get_latency_range (out, true);
_latency_signal_latency += lr.max;
/* all created and connected, lets go */
@@ -1078,9 +1088,14 @@ AudioEngine::stop_latency_detection ()
{
_measuring_latency = false;
- port_engine().unregister_port (_latency_output_port);
- port_engine().unregister_port (_latency_input_port);
-
+ if (_latency_output_port) {
+ port_engine().unregister_port (_latency_output_port);
+ _latency_output_port = 0;
+ }
+ if (_latency_input_port) {
+ port_engine().unregister_port (_latency_input_port);
+ _latency_input_port = 0;
+ }
if (_started_for_latency) {
stop ();
}
diff --git a/libs/backends/jack/jack_audiobackend.cc b/libs/backends/jack/jack_audiobackend.cc
index b3dbdcae71..1e7cb9d8d5 100644
--- a/libs/backends/jack/jack_audiobackend.cc
+++ b/libs/backends/jack/jack_audiobackend.cc
@@ -57,8 +57,8 @@ JACKAudioBackend::JACKAudioBackend (AudioEngine& e, boost::shared_ptr<JackConnec
, _target_buffer_size (1024)
, _target_sample_format (FormatFloat)
, _target_interleaved (false)
- , _target_input_channels (-1)
- , _target_output_channels (-1)
+ , _target_input_channels (0)
+ , _target_output_channels (0)
, _target_systemic_input_latency (0)
, _target_systemic_output_latency (0)
, _current_sample_rate (0)
@@ -292,7 +292,10 @@ int
JACKAudioBackend::set_input_channels (uint32_t cnt)
{
if (available()) {
- return -1;
+ if (cnt != 0) {
+ /* can't set a real value for this while JACK runs */
+ return -1;
+ }
}
_target_input_channels = cnt;
@@ -304,7 +307,10 @@ int
JACKAudioBackend::set_output_channels (uint32_t cnt)
{
if (available()) {
- return -1;
+ if (cnt != 0) {
+ /* can't set a real value for this while JACK runs */
+ return -1;
+ }
}
_target_output_channels = cnt;
@@ -316,6 +322,7 @@ int
JACKAudioBackend::set_systemic_input_latency (uint32_t l)
{
if (available()) {
+ /* can't do this while JACK runs */
return -1;
}
@@ -328,6 +335,7 @@ int
JACKAudioBackend::set_systemic_output_latency (uint32_t l)
{
if (available()) {
+ /* can't do this while JACK runs */
return -1;
}
@@ -341,18 +349,34 @@ JACKAudioBackend::set_systemic_output_latency (uint32_t l)
std::string
JACKAudioBackend::device_name () const
{
- if (available()) {
- return "???";
+ if (!_jack_connection->in_control()) {
+ return "???"; // JACK has no way (as of fall 2013) to return
+ // the device name
}
return _target_device;
}
+std::string
+JACKAudioBackend::driver_name() const
+{
+ if (!_jack_connection->in_control()) {
+ return "???"; // JACK has no way (as of fall 2013) to return
+ // the driver name
+ }
+
+ return _target_driver;
+}
+
float
JACKAudioBackend::sample_rate () const
{
- if (available()) {
- return _current_sample_rate;
+ if (!_jack_connection->in_control()) {
+ if (available()) {
+ return _current_sample_rate;
+ } else {
+ return 0;
+ }
}
return _target_sample_rate;
}
@@ -360,8 +384,12 @@ JACKAudioBackend::sample_rate () const
uint32_t
JACKAudioBackend::buffer_size () const
{
- if (available()) {
- return _current_buffer_size;
+ if (!_jack_connection->in_control()) {
+ if (available()) {
+ return _current_buffer_size;
+ } else {
+ return 0;
+ }
}
return _target_buffer_size;
}
@@ -381,19 +409,37 @@ JACKAudioBackend::interleaved () const
uint32_t
JACKAudioBackend::input_channels () const
{
- if (available()) {
- return n_physical (JackPortIsInput).n_audio();
- }
- return _target_input_channels;
+ if (!_jack_connection->in_control()) {
+ if (available()) {
+ return n_physical (JackPortIsInput).n_audio();
+ } else {
+ return 0;
+ }
+ } else {
+ if (available()) {
+ return n_physical (JackPortIsInput).n_audio();
+ } else {
+ return _target_input_channels;
+ }
+ }
}
uint32_t
JACKAudioBackend::output_channels () const
{
- if (available()) {
- return n_physical (JackPortIsOutput).n_audio();
- }
- return _target_output_channels;
+ if (!_jack_connection->in_control()) {
+ if (available()) {
+ return n_physical (JackPortIsOutput).n_audio();
+ } else {
+ return 0;
+ }
+ } else {
+ if (available()) {
+ return n_physical (JackPortIsOutput).n_audio();
+ } else {
+ return _target_output_channels;
+ }
+ }
}
uint32_t
diff --git a/libs/backends/jack/jack_audiobackend.h b/libs/backends/jack/jack_audiobackend.h
index 655c939c51..9ab545f3ee 100644
--- a/libs/backends/jack/jack_audiobackend.h
+++ b/libs/backends/jack/jack_audiobackend.h
@@ -85,6 +85,7 @@ class JACKAudioBackend : public AudioBackend {
uint32_t output_channels () const;
uint32_t systemic_input_latency () const;
uint32_t systemic_output_latency () const;
+ std::string driver_name() const;
std::string control_app_name () const;
void launch_control_app ();
diff --git a/libs/backends/jack/jack_connection.cc b/libs/backends/jack/jack_connection.cc
index 7b3d35efa5..d5d25c747f 100644
--- a/libs/backends/jack/jack_connection.cc
+++ b/libs/backends/jack/jack_connection.cc
@@ -54,6 +54,7 @@ JackConnection::JackConnection (const std::string& arg1, const std::string& arg2
, _client_name (arg1)
, session_uuid (arg2)
{
+ _in_control = !server_running();
}
JackConnection::~JackConnection ()
@@ -105,6 +106,19 @@ JackConnection::open ()
global_epa->restore ();
}
+ /* check to see if the server is already running so that we know if we
+ * are starting it.
+ */
+
+ jack_client_t* c = jack_client_open ("ardourprobe", JackNoStartServer, &status);
+
+ if (status == 0) {
+ _in_control = false;
+ jack_client_close (c);
+ } else {
+ _in_control = true;
+ }
+
/* ensure that PATH or equivalent includes likely locations of the JACK
* server, in case the user's default does not.
*/
diff --git a/libs/backends/jack/jack_connection.h b/libs/backends/jack/jack_connection.h
index cd45f3b9ba..229d9697d9 100644
--- a/libs/backends/jack/jack_connection.h
+++ b/libs/backends/jack/jack_connection.h
@@ -27,12 +27,15 @@ class JackConnection {
void halted_callback ();
void halted_info_callback (jack_status_t, const char*);
- static bool server_running();
+ bool in_control() const { return _in_control; }
+ static bool server_running();
+
private:
jack_client_t* volatile _jack;
std::string _client_name;
std::string session_uuid;
+ bool _in_control;
};
} // namespace