diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-09-17 21:09:13 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-09-17 21:09:13 -0400 |
commit | f51537b71d869904c5053853ff5456faae0a3b15 (patch) | |
tree | 11b164a07daa2d35ee80a23a4092659e56a262db /libs/backends | |
parent | 7eda429155d5eac0ea0737a87850263c526aeb5a (diff) |
substantive changes to allow the audio/MIDI setup dialog to change settings as intended
So far only tested with JACK backend, but expected to be more correct for other backends too
Diffstat (limited to 'libs/backends')
-rw-r--r-- | libs/backends/jack/jack_audiobackend.cc | 82 | ||||
-rw-r--r-- | libs/backends/jack/jack_audiobackend.h | 1 | ||||
-rw-r--r-- | libs/backends/jack/jack_connection.cc | 14 | ||||
-rw-r--r-- | libs/backends/jack/jack_connection.h | 5 |
4 files changed, 83 insertions, 19 deletions
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 |