#include "jack_audiobackend.h"
#include "jack_connection.h"
-#include "jack_portengine.h"
#include "jack_utils.h"
#include "i18n.h"
, _current_sample_rate (0)
, _current_buffer_size (0)
{
+ _jack_connection->Connected.connect_same_thread (jack_connection_connection, boost::bind (&JACKAudioBackend::when_connected_to_jack, this));
_jack_connection->Disconnected.connect_same_thread (disconnect_connection, boost::bind (&JACKAudioBackend::disconnected, this, _1));
}
}
bool
-JACKAudioBackend::connected() const
+JACKAudioBackend::available() const
{
return (private_handle() != 0);
}
{
vector<float> f;
- if (connected()) {
+ if (available()) {
f.push_back (sample_rate());
return f;
}
{
vector<uint32_t> s;
- if (connected()) {
+ if (available()) {
s.push_back (buffer_size());
return s;
}
int
JACKAudioBackend::set_device_name (const string& dev)
{
- if (connected()) {
+ if (available()) {
/* need to stop and restart JACK for this to work, at present */
return -1;
}
int
JACKAudioBackend::set_sample_rate (float sr)
{
- if (!connected()) {
+ if (!available()) {
_target_sample_rate = sr;
return 0;
}
int
JACKAudioBackend::set_buffer_size (uint32_t nframes)
{
- if (!connected()) {
+ if (!available()) {
_target_buffer_size = nframes;
return 0;
}
int
JACKAudioBackend::set_input_channels (uint32_t cnt)
{
- if (connected()) {
+ if (available()) {
return -1;
}
int
JACKAudioBackend::set_output_channels (uint32_t cnt)
{
- if (connected()) {
+ if (available()) {
return -1;
}
int
JACKAudioBackend::set_systemic_input_latency (uint32_t l)
{
- if (connected()) {
+ if (available()) {
return -1;
}
int
JACKAudioBackend::set_systemic_output_latency (uint32_t l)
{
- if (connected()) {
+ if (available()) {
return -1;
}
std::string
JACKAudioBackend::device_name () const
{
- if (connected()) {
+ if (available()) {
return "???";
}
float
JACKAudioBackend::sample_rate () const
{
- if (connected()) {
+ if (available()) {
return _current_sample_rate;
}
return _target_sample_rate;
uint32_t
JACKAudioBackend::buffer_size () const
{
- if (connected()) {
+ if (available()) {
return _current_buffer_size;
}
return _target_buffer_size;
uint32_t
JACKAudioBackend::input_channels () const
{
- if (connected()) {
+ if (available()) {
return n_physical (JackPortIsInput).n_audio();
}
return _target_input_channels;
uint32_t
JACKAudioBackend::output_channels () const
{
- if (connected()) {
+ if (available()) {
return n_physical (JackPortIsOutput).n_audio();
}
return _target_output_channels;
int
JACKAudioBackend::start ()
{
- if (!connected()) {
+ if (!available()) {
if (!_jack_connection->server_running()) {
setup_jack_startup_command ();
int
JACKAudioBackend::_xrun_callback (void *arg)
{
- JACKAudioBackend* ae = static_cast<JACKAudioBackend*> (arg);
- if (ae->connected()) {
- ae->engine.Xrun (); /* EMIT SIGNAL */
+ JACKAudioBackend* jab = static_cast<JACKAudioBackend*> (arg);
+ if (jab->available()) {
+ jab->engine.Xrun (); /* EMIT SIGNAL */
}
return 0;
}
void
JACKAudioBackend::_session_callback (jack_session_event_t *event, void *arg)
{
- JACKAudioBackend* ae = static_cast<JACKAudioBackend*> (arg);
- ARDOUR::Session* session = ae->engine.session();
+ JACKAudioBackend* jab = static_cast<JACKAudioBackend*> (arg);
+ ARDOUR::Session* session = jab->engine.session();
if (session) {
session->jack_session_event (event);
if (ports) {
for (uint32_t i = 0; ports[i]; ++i) {
if (!strstr (ports[i], "Midi-Through")) {
- DataType t (jack_port_type (jack_port_by_name (_priv_jack, ports[i])));
- c.set (t, c.get (t) + 1);
+ DataType t = port_data_type (jack_port_by_name (_priv_jack, ports[i]));
+ if (t != DataType::NIL) {
+ c.set (t, c.get (t) + 1);
+ }
}
}