Merge branch 'master' into windows
This commit is contained in:
commit
4861eca974
|
@ -388,25 +388,8 @@ ARDOUR_UI::create_global_port_matrix (ARDOUR::DataType type)
|
|||
void
|
||||
ARDOUR_UI::attach_to_engine ()
|
||||
{
|
||||
AudioEngine::instance()->Stopped.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_stopped, this), gui_context());
|
||||
AudioEngine::instance()->Running.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_running, this), gui_context());
|
||||
AudioEngine::instance()->SampleRateChanged.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::update_sample_rate, this, _1), gui_context());
|
||||
|
||||
AudioEngine::instance()->Halted.connect_same_thread (halt_connection, boost::bind (&ARDOUR_UI::engine_halted, this, _1, false));
|
||||
|
||||
ARDOUR::Port::set_connecting_blocked (ARDOUR_COMMAND_LINE::no_connect_ports);
|
||||
|
||||
/* if there is only one audio/midi backend, and it does not require setup, get our use of it underway
|
||||
* right here (we need to know the client name and potential session ID
|
||||
* to do this, which is why this is here, rather than in, say,
|
||||
* ARDOUR::init().
|
||||
*/
|
||||
|
||||
if (!AudioEngine::instance()->setup_required()) {
|
||||
const AudioBackendInfo* backend = AudioEngine::instance()->available_backends().front();
|
||||
AudioEngine::instance()->set_backend (backend->name, ARDOUR_COMMAND_LINE::backend_client_name, ARDOUR_COMMAND_LINE::backend_session_uuid);
|
||||
AudioEngine::instance()->start ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -528,6 +511,12 @@ ARDOUR_UI::post_engine ()
|
|||
*/
|
||||
|
||||
ARDOUR::init_post_engine ();
|
||||
|
||||
/* connect to important signals */
|
||||
|
||||
AudioEngine::instance()->Stopped.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::engine_stopped, this), gui_context());
|
||||
AudioEngine::instance()->SampleRateChanged.connect (forever_connections, MISSING_INVALIDATOR, boost::bind (&ARDOUR_UI::update_sample_rate, this, _1), gui_context());
|
||||
AudioEngine::instance()->Halted.connect_same_thread (halt_connection, boost::bind (&ARDOUR_UI::engine_halted, this, _1, false));
|
||||
|
||||
_tooltips.enable();
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ Editor::export_video ()
|
|||
break;
|
||||
}
|
||||
}
|
||||
ExportVideoDialog dialog (*this, _session);
|
||||
ExportVideoDialog dialog (_session, get_selection().time);
|
||||
Gtk::ResponseType r = (Gtk::ResponseType) dialog.run();
|
||||
dialog.hide();
|
||||
#if 0
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "pbd/error.h"
|
||||
#include "pbd/xml++.h"
|
||||
#include "pbd/unwind.h"
|
||||
|
||||
#include <gtkmm/stock.h>
|
||||
#include <gtkmm/notebook.h>
|
||||
|
@ -95,15 +96,6 @@ EngineControl::EngineControl ()
|
|||
if (audio_setup) {
|
||||
set_state (*audio_setup);
|
||||
}
|
||||
|
||||
ARDOUR::AudioEngine::instance()->Stopped.connect (*this, MISSING_INVALIDATOR, boost::bind (&EngineControl::disable_latency_tab, this), gui_context());
|
||||
|
||||
if (!ARDOUR::AudioEngine::instance()->connected()) {
|
||||
ARDOUR::AudioEngine::instance()->Running.connect (*this, MISSING_INVALIDATOR, boost::bind (&EngineControl::enable_latency_tab, this), gui_context());
|
||||
disable_latency_tab ();
|
||||
} else {
|
||||
enable_latency_tab ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -281,9 +273,18 @@ and microphone.\n\n\
|
|||
driver_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::driver_changed));
|
||||
sample_rate_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::sample_rate_changed));
|
||||
buffer_size_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::buffer_size_changed));
|
||||
device_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::device_changed));
|
||||
|
||||
input_latency.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
|
||||
output_latency.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
|
||||
input_channels.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
|
||||
output_channels.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::parameter_changed));
|
||||
|
||||
|
||||
input_channels.signal_output().connect (sigc::bind (sigc::ptr_fun (&EngineControl::print_channel_count), &input_channels));
|
||||
output_channels.signal_output().connect (sigc::bind (sigc::ptr_fun (&EngineControl::print_channel_count), &output_channels));
|
||||
device_combo.signal_changed().connect (sigc::mem_fun (*this, &EngineControl::device_changed));
|
||||
|
||||
notebook.signal_switch_page().connect (sigc::mem_fun (*this, &EngineControl::on_switch_page));
|
||||
}
|
||||
|
||||
EngineControl::~EngineControl ()
|
||||
|
@ -297,6 +298,8 @@ EngineControl::disable_latency_tab ()
|
|||
vector<string> empty;
|
||||
set_popdown_strings (lm_output_channel_combo, empty);
|
||||
set_popdown_strings (lm_input_channel_combo, empty);
|
||||
lm_measure_button.set_sensitive (false);
|
||||
lm_use_button.set_sensitive (false);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -311,6 +314,9 @@ EngineControl::enable_latency_tab ()
|
|||
ARDOUR::AudioEngine::instance()->get_physical_inputs (ARDOUR::DataType::AUDIO, inputs);
|
||||
set_popdown_strings (lm_input_channel_combo, inputs);
|
||||
lm_input_channel_combo.set_active_text (inputs.front());
|
||||
|
||||
lm_measure_button.set_sensitive (true);
|
||||
lm_use_button.set_sensitive (true);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -384,10 +390,26 @@ EngineControl::list_devices ()
|
|||
set_popdown_strings (device_combo, available_devices);
|
||||
|
||||
if (!available_devices.empty()) {
|
||||
sample_rate_combo.set_sensitive (true);
|
||||
buffer_size_combo.set_sensitive (true);
|
||||
input_latency.set_sensitive (true);
|
||||
output_latency.set_sensitive (true);
|
||||
input_channels.set_sensitive (true);
|
||||
output_channels.set_sensitive (true);
|
||||
|
||||
/* changing the text in the combo will trigger device_changed()
|
||||
which should populate the parameter controls
|
||||
*/
|
||||
|
||||
device_combo.set_active_text (available_devices.front());
|
||||
} else {
|
||||
sample_rate_combo.set_sensitive (true);
|
||||
buffer_size_combo.set_sensitive (true);
|
||||
input_latency.set_sensitive (true);
|
||||
output_latency.set_sensitive (true);
|
||||
input_channels.set_sensitive (true);
|
||||
output_channels.set_sensitive (true);
|
||||
}
|
||||
|
||||
device_changed ();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -468,7 +490,13 @@ EngineControl::device_changed ()
|
|||
|
||||
ignore_changes--;
|
||||
|
||||
/* pick up any saved state for this device */
|
||||
|
||||
maybe_display_saved_state ();
|
||||
|
||||
/* and push it to the backend */
|
||||
|
||||
push_state_to_backend (false);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -483,6 +511,7 @@ EngineControl::sample_rate_changed ()
|
|||
*/
|
||||
|
||||
show_buffer_duration ();
|
||||
push_state_to_backend (false);
|
||||
save_state ();
|
||||
|
||||
}
|
||||
|
@ -495,6 +524,7 @@ EngineControl::buffer_size_changed ()
|
|||
}
|
||||
|
||||
show_buffer_duration ();
|
||||
push_state_to_backend (false);
|
||||
save_state ();
|
||||
}
|
||||
|
||||
|
@ -522,6 +552,14 @@ EngineControl::show_buffer_duration ()
|
|||
buffer_size_duration_label.set_text (buf);
|
||||
}
|
||||
|
||||
void
|
||||
EngineControl::parameter_changed ()
|
||||
{
|
||||
if (!ignore_changes) {
|
||||
save_state ();
|
||||
}
|
||||
}
|
||||
|
||||
EngineControl::State*
|
||||
EngineControl::get_matching_state (const string& backend,
|
||||
const string& driver,
|
||||
|
@ -538,7 +576,7 @@ EngineControl::get_matching_state (const string& backend,
|
|||
}
|
||||
|
||||
EngineControl::State*
|
||||
EngineControl::get_current_state ()
|
||||
EngineControl::get_saved_state_for_currently_displayed_backend_and_device ()
|
||||
{
|
||||
boost::shared_ptr<ARDOUR::AudioBackend> backend = ARDOUR::AudioEngine::instance()->current_backend();
|
||||
|
||||
|
@ -554,11 +592,11 @@ EngineControl::get_current_state ()
|
|||
device_combo.get_active_text());
|
||||
}
|
||||
|
||||
void
|
||||
EngineControl::State*
|
||||
EngineControl::save_state ()
|
||||
{
|
||||
bool existing = true;
|
||||
State* state = get_current_state ();
|
||||
State* state = get_saved_state_for_currently_displayed_backend_and_device ();
|
||||
|
||||
if (!state) {
|
||||
existing = false;
|
||||
|
@ -578,12 +616,14 @@ EngineControl::save_state ()
|
|||
if (!existing) {
|
||||
states.push_back (*state);
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
void
|
||||
EngineControl::maybe_display_saved_state ()
|
||||
{
|
||||
State* state = get_current_state ();
|
||||
State* state = get_saved_state_for_currently_displayed_backend_and_device ();
|
||||
|
||||
if (state) {
|
||||
ignore_changes++;
|
||||
|
@ -792,11 +832,10 @@ EngineControl::push_state_to_backend (bool start)
|
|||
* necessary
|
||||
*/
|
||||
|
||||
State* state = get_current_state ();
|
||||
State* state = get_saved_state_for_currently_displayed_backend_and_device ();
|
||||
|
||||
if (!state) {
|
||||
save_state ();
|
||||
state = get_current_state ();
|
||||
state = save_state ();
|
||||
assert (state);
|
||||
}
|
||||
|
||||
|
@ -926,23 +965,47 @@ EngineControl::set_desired_sample_rate (uint32_t sr)
|
|||
device_changed ();
|
||||
}
|
||||
|
||||
/* latency measurement */
|
||||
|
||||
void
|
||||
EngineControl::update_latency_display ()
|
||||
EngineControl::on_switch_page (GtkNotebookPage*, guint page_num)
|
||||
{
|
||||
ARDOUR::framecnt_t const sample_rate = ARDOUR::AudioEngine::instance()->sample_rate();
|
||||
if (sample_rate == 0) {
|
||||
lm_results.set_text (_("Disconnected from audio engine"));
|
||||
} else {
|
||||
char buf[64];
|
||||
//snprintf (buf, sizeof (buf), "%10.3lf frames %10.3lf ms",
|
||||
//(float)_pi->latency(), (float)_pi->latency() * 1000.0f/sample_rate);
|
||||
strcpy (buf, "got something");
|
||||
lm_results.set_text(buf);
|
||||
}
|
||||
if (page_num == 2) {
|
||||
/* latency tab */
|
||||
|
||||
if (!ARDOUR::AudioEngine::instance()->running()) {
|
||||
|
||||
PBD::Unwinder<uint32_t> protect_ignore_changes (ignore_changes, ignore_changes + 1);
|
||||
|
||||
/* save any existing latency values */
|
||||
|
||||
uint32_t il = (uint32_t) input_latency.get_value ();
|
||||
uint32_t ol = (uint32_t) input_latency.get_value ();
|
||||
|
||||
/* reset to zero so that our new test instance of JACK
|
||||
will be clean of any existing latency measures.
|
||||
*/
|
||||
|
||||
input_latency.set_value (0);
|
||||
output_latency.set_value (0);
|
||||
|
||||
push_state_to_backend (false);
|
||||
|
||||
/* reset control */
|
||||
|
||||
input_latency.set_value (il);
|
||||
output_latency.set_value (ol);
|
||||
}
|
||||
|
||||
if (ARDOUR::AudioEngine::instance()->prepare_for_latency_measurement()) {
|
||||
disable_latency_tab ();
|
||||
}
|
||||
enable_latency_tab ();
|
||||
} else {
|
||||
ARDOUR::AudioEngine::instance()->stop_latency_detection();
|
||||
}
|
||||
}
|
||||
|
||||
/* latency measurement */
|
||||
|
||||
bool
|
||||
EngineControl::check_latency_measurement ()
|
||||
{
|
||||
|
@ -974,6 +1037,7 @@ EngineControl::check_latency_measurement ()
|
|||
}
|
||||
|
||||
uint32_t frames_total = mtdm->del();
|
||||
cerr << "total = " << frames_total << " delay = " << ARDOUR::AudioEngine::instance()->latency_signal_delay() << endl;
|
||||
uint32_t extra = frames_total - ARDOUR::AudioEngine::instance()->latency_signal_delay();
|
||||
|
||||
snprintf (buf, sizeof (buf), "%u samples %10.3lf ms", extra, extra * 1000.0f/sample_rate);
|
||||
|
@ -991,7 +1055,6 @@ EngineControl::check_latency_measurement ()
|
|||
}
|
||||
|
||||
if (solid) {
|
||||
// _pi->set_measured_latency (rint (mtdm->del()));
|
||||
lm_measure_button.set_active (false);
|
||||
lm_use_button.set_sensitive (true);
|
||||
strcat (buf, " (set)");
|
||||
|
@ -1009,7 +1072,6 @@ EngineControl::latency_button_toggled ()
|
|||
|
||||
ARDOUR::AudioEngine::instance()->set_latency_input_port (lm_input_channel_combo.get_active_text());
|
||||
ARDOUR::AudioEngine::instance()->set_latency_output_port (lm_output_channel_combo.get_active_text());
|
||||
cerr << "latency detection on " << lm_input_channel_combo.get_active_text() << " => " << lm_output_channel_combo.get_active_text() << endl;
|
||||
ARDOUR::AudioEngine::instance()->start_latency_detection ();
|
||||
lm_results.set_text (_("Detecting ..."));
|
||||
latency_timeout = Glib::signal_timeout().connect (mem_fun (*this, &EngineControl::check_latency_measurement), 250);
|
||||
|
@ -1017,7 +1079,6 @@ EngineControl::latency_button_toggled ()
|
|||
} else {
|
||||
ARDOUR::AudioEngine::instance()->stop_latency_detection ();
|
||||
latency_timeout.disconnect ();
|
||||
update_latency_display ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,6 +118,7 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
|
|||
void backend_changed ();
|
||||
void sample_rate_changed ();
|
||||
void buffer_size_changed ();
|
||||
void parameter_changed ();
|
||||
|
||||
uint32_t get_rate() const;
|
||||
uint32_t get_buffer_size() const;
|
||||
|
@ -154,9 +155,9 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
|
|||
State* get_matching_state (const std::string& backend,
|
||||
const std::string& driver,
|
||||
const std::string& device);
|
||||
State* get_current_state ();
|
||||
State* get_saved_state_for_currently_displayed_backend_and_device ();
|
||||
void maybe_display_saved_state ();
|
||||
void save_state ();
|
||||
State* save_state ();
|
||||
|
||||
static bool print_channel_count (Gtk::SpinButton*);
|
||||
|
||||
|
@ -172,10 +173,11 @@ class EngineControl : public ArdourDialog, public PBD::ScopedConnectionList {
|
|||
/* latency measurement */
|
||||
void latency_button_toggled ();
|
||||
bool check_latency_measurement ();
|
||||
void update_latency_display ();
|
||||
sigc::connection latency_timeout;
|
||||
void enable_latency_tab ();
|
||||
void disable_latency_tab ();
|
||||
|
||||
void on_switch_page (GtkNotebookPage*, guint page_num);
|
||||
};
|
||||
|
||||
#endif /* __gtk2_ardour_engine_dialog_h__ */
|
||||
|
|
|
@ -64,9 +64,9 @@ using namespace PBD;
|
|||
using namespace ARDOUR;
|
||||
using namespace VideoUtils;
|
||||
|
||||
ExportVideoDialog::ExportVideoDialog (PublicEditor& ed, Session* s)
|
||||
ExportVideoDialog::ExportVideoDialog (Session* s, TimeSelection &tme)
|
||||
: ArdourDialog (_("Export Video File "))
|
||||
, editor (ed)
|
||||
, export_range (tme)
|
||||
, outfn_path_label (_("File:"), Gtk::ALIGN_LEFT)
|
||||
, outfn_browse_button (_("Browse"))
|
||||
, invid_path_label (_("Video:"), Gtk::ALIGN_LEFT)
|
||||
|
@ -152,6 +152,9 @@ ExportVideoDialog::ExportVideoDialog (PublicEditor& ed, Session* s)
|
|||
} else {
|
||||
insnd_combo.append_text (_("from the video's start to the video's end"));
|
||||
}
|
||||
if (!export_range.empty()) {
|
||||
insnd_combo.append_text (_("Selected range")); // TODO show export_range.start() -> export_range.end_frame()
|
||||
}
|
||||
insnd_combo.set_active(0);
|
||||
|
||||
outfn_path_entry.set_width_chars(38);
|
||||
|
@ -509,6 +512,11 @@ ExportVideoDialog::launch_export ()
|
|||
}
|
||||
end += av_offset;
|
||||
}
|
||||
else if (insnd_combo.get_active_row_number() == 2) {
|
||||
// TODO quantize to video-frame ?!
|
||||
start = export_range.start();
|
||||
end = export_range.end_frame();
|
||||
}
|
||||
if (end <= 0) {
|
||||
start = _session->current_start_frame();
|
||||
end = _session->current_end_frame();
|
||||
|
@ -696,9 +704,14 @@ ExportVideoDialog::encode_pass (int pass)
|
|||
double duration_s = 0;
|
||||
|
||||
if (insnd_combo.get_active_row_number() == 0) {
|
||||
/* session start to session end */
|
||||
framecnt_t duration_f = _session->current_end_frame() - _session->current_start_frame();
|
||||
duration_s = (double)duration_f / (double)_session->nominal_frame_rate();
|
||||
} else if (insnd_combo.get_active_row_number() == 2) {
|
||||
/* selected range */
|
||||
duration_s = export_range.length() / (double)_session->nominal_frame_rate();
|
||||
} else {
|
||||
/* video start to end */
|
||||
framecnt_t duration_f = ARDOUR_UI::instance()->video_timeline->get_duration();
|
||||
if (av_offset < 0 ) {
|
||||
duration_f += av_offset;
|
||||
|
@ -714,10 +727,16 @@ ExportVideoDialog::encode_pass (int pass)
|
|||
transcoder->set_duration(duration_s * transcoder->get_fps());
|
||||
}
|
||||
|
||||
if (insnd_combo.get_active_row_number() == 0) {
|
||||
const framepos_t start = _session->current_start_frame();
|
||||
const framepos_t snend = _session->current_end_frame();
|
||||
if (insnd_combo.get_active_row_number() == 0 || insnd_combo.get_active_row_number() == 2) {
|
||||
framepos_t start, snend;
|
||||
const frameoffset_t vid_duration = ARDOUR_UI::instance()->video_timeline->get_duration();
|
||||
if (insnd_combo.get_active_row_number() == 0) {
|
||||
start = _session->current_start_frame();
|
||||
snend = _session->current_end_frame();
|
||||
} else {
|
||||
start = export_range.start();
|
||||
snend = export_range.end_frame();
|
||||
}
|
||||
|
||||
#if 0 /* DEBUG */
|
||||
printf("AV offset: %lld Vid-len: %lld Vid-end: %lld || start:%lld || end:%lld\n",
|
||||
|
@ -732,9 +751,17 @@ ExportVideoDialog::encode_pass (int pass)
|
|||
} else if (av_offset + vid_duration < snend) {
|
||||
transcoder->set_leadinout(0, (snend - (av_offset + vid_duration)) / (double)_session->nominal_frame_rate());
|
||||
transcoder->set_avoffset((av_offset - start) / (double)_session->nominal_frame_rate());
|
||||
} else {
|
||||
}
|
||||
#if 0
|
||||
else if (start > av_offset) {
|
||||
std::ostringstream osstream; osstream << ((start - av_offset) / (double)_session->nominal_frame_rate());
|
||||
ffs["-ss"] = osstream.str();
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
transcoder->set_avoffset((av_offset - start) / (double)_session->nominal_frame_rate());
|
||||
}
|
||||
|
||||
} else if (av_offset < 0) {
|
||||
/* from 00:00:00:00 to video-end */
|
||||
transcoder->set_avoffset(av_offset / (double)_session->nominal_frame_rate());
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "ardour/template_utils.h"
|
||||
#include "ardour_dialog.h"
|
||||
|
||||
#include "time_selection.h"
|
||||
#include "transcode_ffmpeg.h"
|
||||
|
||||
/** @class ExportVideoDialog
|
||||
|
@ -40,13 +41,13 @@
|
|||
class ExportVideoDialog : public ArdourDialog , public PBD::ScopedConnectionList
|
||||
{
|
||||
public:
|
||||
ExportVideoDialog (PublicEditor&, ARDOUR::Session*);
|
||||
ExportVideoDialog (ARDOUR::Session*, TimeSelection &tme);
|
||||
~ExportVideoDialog ();
|
||||
|
||||
std::string get_exported_filename () { return outfn_path_entry.get_text(); }
|
||||
|
||||
private:
|
||||
PublicEditor& editor;
|
||||
TimeSelection &export_range;
|
||||
|
||||
void on_show ();
|
||||
void abort_clicked ();
|
||||
|
|
|
@ -277,16 +277,19 @@ GainMeterBase::setup_meters (int len)
|
|||
|
||||
switch (_width) {
|
||||
case Wide:
|
||||
meter_ticks1_area.show();
|
||||
meter_ticks2_area.show();
|
||||
//meter_ticks1_area.show();
|
||||
//meter_ticks2_area.show();
|
||||
meter_metric_area.show();
|
||||
if (_route && _route->shared_peak_meter()->input_streams().n_total() == 1) {
|
||||
meter_width = 10;
|
||||
}
|
||||
break;
|
||||
case Narrow:
|
||||
meter_ticks1_area.hide();
|
||||
meter_ticks2_area.hide();
|
||||
if (_route && _route->shared_peak_meter()->input_streams().n_total() > 1) {
|
||||
meter_width = 4;
|
||||
}
|
||||
//meter_ticks1_area.hide();
|
||||
//meter_ticks2_area.hide();
|
||||
meter_metric_area.hide();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -363,8 +363,15 @@ set_color (Gdk::Color& c, int rgb)
|
|||
bool
|
||||
relay_key_press (GdkEventKey* ev, Gtk::Window* win)
|
||||
{
|
||||
PublicEditor& ed (PublicEditor::instance());
|
||||
|
||||
if (&ed == 0) {
|
||||
/* early key press in pre-main-window-dialogs, no editor yet */
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!key_press_focus_accelerator_handler (*win, ev)) {
|
||||
return PublicEditor::instance().on_key_press_event(ev);
|
||||
return ed.on_key_press_event(ev);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -29,17 +29,15 @@
|
|||
#include <boost/function.hpp>
|
||||
|
||||
#include "ardour/types.h"
|
||||
#include "ardour/audioengine.h"
|
||||
#include "ardour/port_engine.h"
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
class AudioEngine;
|
||||
class PortEngine;
|
||||
class PortManager;
|
||||
|
||||
class AudioBackend {
|
||||
class AudioBackend : public PortEngine {
|
||||
public:
|
||||
|
||||
AudioBackend (AudioEngine& e) : engine (e){}
|
||||
AudioBackend (AudioEngine& e) : PortEngine (e), engine (e) {}
|
||||
virtual ~AudioBackend () {}
|
||||
|
||||
/** Return the name of this backend.
|
||||
|
@ -49,17 +47,6 @@ class AudioBackend {
|
|||
*/
|
||||
virtual std::string name() const = 0;
|
||||
|
||||
/** Return a private, type-free pointer to any data
|
||||
* that might be useful to a concrete implementation
|
||||
*/
|
||||
virtual void* private_handle() const = 0;
|
||||
|
||||
/** Return true if the underlying mechanism/API is still available
|
||||
* for us to utilize. return false if some or all of the AudioBackend
|
||||
* API can no longer be effectively used.
|
||||
*/
|
||||
virtual bool connected() const = 0;
|
||||
|
||||
/** Return true if the callback from the underlying mechanism/API
|
||||
* (CoreAudio, JACK, ASIO etc.) occurs in a thread subject to realtime
|
||||
* constraints. Return false otherwise.
|
||||
|
@ -416,11 +403,22 @@ class AudioBackend {
|
|||
struct AudioBackendInfo {
|
||||
const char* name;
|
||||
|
||||
/** Using arg1 and arg2, initialize this audiobackend.
|
||||
*
|
||||
* Returns zero on success, non-zero otherwise.
|
||||
*/
|
||||
int (*instantiate) (const std::string& arg1, const std::string& arg2);
|
||||
|
||||
/** Release all resources associated with this audiobackend
|
||||
*/
|
||||
int (*deinstantiate) (void);
|
||||
|
||||
boost::shared_ptr<AudioBackend> (*backend_factory) (AudioEngine&);
|
||||
boost::shared_ptr<PortEngine> (*portengine_factory) (PortManager&);
|
||||
/** Factory method to create an AudioBackend-derived class.
|
||||
*
|
||||
* Returns a valid shared_ptr to the object if successfull,
|
||||
* or a "null" shared_ptr otherwise.
|
||||
*/
|
||||
boost::shared_ptr<AudioBackend> (*factory) (AudioEngine&);
|
||||
|
||||
/** Return true if the underlying mechanism/API has been
|
||||
* configured and does not need (re)configuration in order
|
||||
|
|
|
@ -188,6 +188,7 @@ public:
|
|||
/* latency measurement */
|
||||
|
||||
MTDM* mtdm();
|
||||
int prepare_for_latency_measurement ();
|
||||
void start_latency_detection ();
|
||||
void stop_latency_detection ();
|
||||
void set_latency_input_port (const std::string&);
|
||||
|
@ -199,8 +200,6 @@ public:
|
|||
|
||||
static AudioEngine* _instance;
|
||||
|
||||
boost::shared_ptr<AudioBackend> _backend;
|
||||
|
||||
Glib::Threads::Mutex _process_lock;
|
||||
Glib::Threads::Cond session_removed;
|
||||
bool session_remove_pending;
|
||||
|
@ -225,6 +224,7 @@ public:
|
|||
std::string _latency_input_name;
|
||||
std::string _latency_output_name;
|
||||
framecnt_t _latency_signal_latency;
|
||||
bool _started_for_latency;
|
||||
|
||||
void meter_thread ();
|
||||
void start_metering_thread ();
|
||||
|
|
|
@ -79,6 +79,11 @@ class PortEngine {
|
|||
PortEngine (PortManager& pm) : manager (pm) {}
|
||||
virtual ~PortEngine() {}
|
||||
|
||||
/** Return a private, type-free pointer to any data
|
||||
* that might be useful to a concrete implementation
|
||||
*/
|
||||
virtual void* private_handle() const = 0;
|
||||
|
||||
/* We use void* here so that the API can be defined for any implementation.
|
||||
*
|
||||
* We could theoretically use a template (PortEngine<T>) and define
|
||||
|
@ -89,21 +94,16 @@ class PortEngine {
|
|||
|
||||
typedef void* PortHandle;
|
||||
|
||||
/** Return a typeless pointer to an object that may be of interest
|
||||
* that understands the internals of a particular PortEngine
|
||||
* implementation.
|
||||
*
|
||||
* XXX the existence of this method is a band-aid over some design
|
||||
* issues and will it will be removed in the future
|
||||
*/
|
||||
virtual void* private_handle() const = 0;
|
||||
|
||||
virtual bool connected() const = 0;
|
||||
|
||||
/** Return the name of this process as used by the port manager
|
||||
* when naming ports.
|
||||
*/
|
||||
virtual const std::string& my_name() const = 0;
|
||||
|
||||
/** Return true if the underlying mechanism/API is still available
|
||||
* for us to utilize. return false if some or all of the AudioBackend
|
||||
* API can no longer be effectively used.
|
||||
*/
|
||||
virtual bool available() const = 0;
|
||||
|
||||
/** Return the maximum size of a port name
|
||||
*/
|
||||
|
|
|
@ -34,10 +34,12 @@
|
|||
#include "ardour/chan_count.h"
|
||||
#include "ardour/midiport_manager.h"
|
||||
#include "ardour/port.h"
|
||||
#include "ardour/port_engine.h"
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
class PortEngine;
|
||||
class AudioBackend;
|
||||
|
||||
class PortManager
|
||||
{
|
||||
public:
|
||||
|
@ -47,8 +49,7 @@ class PortManager
|
|||
PortManager ();
|
||||
virtual ~PortManager() {}
|
||||
|
||||
void set_port_engine (PortEngine& pe);
|
||||
PortEngine& port_engine() { return *_impl; }
|
||||
PortEngine& port_engine();
|
||||
|
||||
uint32_t port_name_size() const;
|
||||
std::string my_name() const;
|
||||
|
@ -134,7 +135,7 @@ class PortManager
|
|||
PBD::Signal5<void, boost::weak_ptr<Port>, std::string, boost::weak_ptr<Port>, std::string, bool> PortConnectedOrDisconnected;
|
||||
|
||||
protected:
|
||||
boost::shared_ptr<PortEngine> _impl;
|
||||
boost::shared_ptr<AudioBackend> _backend;
|
||||
SerializedRCUManager<Ports> ports;
|
||||
bool _port_remove_in_progress;
|
||||
|
||||
|
|
|
@ -1624,6 +1624,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
|
|||
void setup_ltc ();
|
||||
void setup_click ();
|
||||
void setup_bundles ();
|
||||
int ensure_engine (uint32_t desired_sample_rate);
|
||||
};
|
||||
|
||||
} // namespace ARDOUR
|
||||
|
|
|
@ -78,6 +78,7 @@ AudioEngine::AudioEngine ()
|
|||
, _latency_output_port (0)
|
||||
, _latency_flush_frames (0)
|
||||
, _latency_signal_latency (0)
|
||||
, _started_for_latency (false)
|
||||
{
|
||||
g_atomic_int_set (&m_meter_exit, 0);
|
||||
discover_backends ();
|
||||
|
@ -200,6 +201,13 @@ AudioEngine::process_callback (pframes_t nframes)
|
|||
bool return_after_remove_check = false;
|
||||
|
||||
if (_measuring_latency && _mtdm) {
|
||||
/* run a normal cycle from the perspective of the PortManager
|
||||
so that we get silence on all registered ports.
|
||||
|
||||
we overwrite the silence on the two ports used for latency
|
||||
measurement.
|
||||
*/
|
||||
|
||||
PortManager::cycle_start (nframes);
|
||||
PortManager::silence (nframes);
|
||||
|
||||
|
@ -415,8 +423,6 @@ AudioEngine::remove_session ()
|
|||
|
||||
if (_running) {
|
||||
|
||||
stop_metering_thread ();
|
||||
|
||||
if (_session) {
|
||||
session_remove_pending = true;
|
||||
session_removal_countdown = 0;
|
||||
|
@ -564,8 +570,7 @@ AudioEngine::set_backend (const std::string& name, const std::string& arg1, cons
|
|||
throw failed_constructor ();
|
||||
}
|
||||
|
||||
_backend = b->second->backend_factory (*this);
|
||||
_impl = b->second->portengine_factory (*this);
|
||||
_backend = b->second->factory (*this);
|
||||
|
||||
} catch (exception& e) {
|
||||
error << string_compose (_("Could not create backend for %1: %2"), name, e.what()) << endmsg;
|
||||
|
@ -607,7 +612,9 @@ AudioEngine::start ()
|
|||
|
||||
start_metering_thread ();
|
||||
|
||||
Running(); /* EMIT SIGNAL */
|
||||
if (!_started_for_latency) {
|
||||
Running(); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -630,6 +637,7 @@ AudioEngine::stop ()
|
|||
_measuring_latency = false;
|
||||
_latency_output_port = 0;
|
||||
_latency_input_port = 0;
|
||||
_started_for_latency = false;
|
||||
stop_metering_thread ();
|
||||
|
||||
Port::PortDrop ();
|
||||
|
@ -693,7 +701,7 @@ AudioEngine::connected() const
|
|||
return false;
|
||||
}
|
||||
|
||||
return _backend->connected();
|
||||
return _backend->available();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -980,6 +988,13 @@ AudioEngine::halted_callback (const char* why)
|
|||
bool
|
||||
AudioEngine::setup_required () const
|
||||
{
|
||||
/* If there is only a single backend and it claims to be configured
|
||||
* already there is no setup to be done.
|
||||
*
|
||||
* Primarily for a case where there is only a JACK backend and
|
||||
* JACK is already running.
|
||||
*/
|
||||
|
||||
if (_backends.size() == 1 && _backends.begin()->second->already_configured()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -993,9 +1008,28 @@ AudioEngine::mtdm()
|
|||
return _mtdm;
|
||||
}
|
||||
|
||||
int
|
||||
AudioEngine::prepare_for_latency_measurement ()
|
||||
{
|
||||
if (!running()) {
|
||||
_started_for_latency = true;
|
||||
|
||||
if (start()) {
|
||||
_started_for_latency = false;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
AudioEngine::start_latency_detection ()
|
||||
{
|
||||
if (prepare_for_latency_measurement ()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PortEngine& pe (port_engine());
|
||||
|
||||
delete _mtdm;
|
||||
|
@ -1027,23 +1061,25 @@ AudioEngine::start_latency_detection ()
|
|||
lr = pe.get_latency_range (_latency_output_port, true);
|
||||
_latency_signal_latency += lr.max;
|
||||
|
||||
cerr << "latency signal pathway = " << _latency_signal_latency << endl;
|
||||
|
||||
/* all created and connected, lets go */
|
||||
|
||||
_mtdm = new MTDM (sample_rate());
|
||||
_measuring_latency = true;
|
||||
_latency_flush_frames = samples_per_cycle();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
AudioEngine::stop_latency_detection ()
|
||||
{
|
||||
_measuring_latency = false;
|
||||
|
||||
port_engine().unregister_port (_latency_output_port);
|
||||
port_engine().unregister_port (_latency_input_port);
|
||||
_measuring_latency = false;
|
||||
|
||||
if (_started_for_latency) {
|
||||
stop ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -124,7 +124,7 @@ Port::disconnect_all ()
|
|||
bool
|
||||
Port::connected_to (std::string const & o) const
|
||||
{
|
||||
if (!port_engine.connected()) {
|
||||
if (!port_engine.available()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ Port::connected_to (std::string const & o) const
|
|||
int
|
||||
Port::get_connections (std::vector<std::string> & c) const
|
||||
{
|
||||
if (!port_engine.connected()) {
|
||||
if (!port_engine.available()) {
|
||||
c.insert (c.end(), _connections.begin(), _connections.end());
|
||||
return c.size();
|
||||
}
|
||||
|
|
|
@ -20,11 +20,12 @@
|
|||
#include "pbd/error.h"
|
||||
|
||||
#include "ardour/async_midi_port.h"
|
||||
#include "ardour/debug.h"
|
||||
#include "ardour/port_manager.h"
|
||||
#include "ardour/audio_backend.h"
|
||||
#include "ardour/audio_port.h"
|
||||
#include "ardour/debug.h"
|
||||
#include "ardour/midi_port.h"
|
||||
#include "ardour/midiport_manager.h"
|
||||
#include "ardour/port_manager.h"
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
|
@ -68,13 +69,13 @@ PortManager::remove_all_ports ()
|
|||
string
|
||||
PortManager::make_port_name_relative (const string& portname) const
|
||||
{
|
||||
if (!_impl) {
|
||||
if (!_backend) {
|
||||
return portname;
|
||||
}
|
||||
|
||||
string::size_type len;
|
||||
string::size_type n;
|
||||
string self = _impl->my_name();
|
||||
string self = _backend->my_name();
|
||||
|
||||
len = portname.length();
|
||||
|
||||
|
@ -100,7 +101,7 @@ PortManager::make_port_name_non_relative (const string& portname) const
|
|||
return portname;
|
||||
}
|
||||
|
||||
str = _impl->my_name();
|
||||
str = _backend->my_name();
|
||||
str += ':';
|
||||
str += portname;
|
||||
|
||||
|
@ -110,11 +111,11 @@ PortManager::make_port_name_non_relative (const string& portname) const
|
|||
bool
|
||||
PortManager::port_is_mine (const string& portname) const
|
||||
{
|
||||
if (!_impl) {
|
||||
if (!_backend) {
|
||||
return true;
|
||||
}
|
||||
|
||||
string self = _impl->my_name();
|
||||
string self = _backend->my_name();
|
||||
|
||||
if (portname.find_first_of (':') != string::npos) {
|
||||
if (portname.substr (0, self.length ()) != self) {
|
||||
|
@ -128,54 +129,54 @@ PortManager::port_is_mine (const string& portname) const
|
|||
bool
|
||||
PortManager::port_is_physical (const std::string& portname) const
|
||||
{
|
||||
if (!_impl) {
|
||||
if (!_backend) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PortEngine::PortHandle ph = _impl->get_port_by_name (portname);
|
||||
PortEngine::PortHandle ph = _backend->get_port_by_name (portname);
|
||||
if (!ph) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return _impl->port_is_physical (ph);
|
||||
return _backend->port_is_physical (ph);
|
||||
}
|
||||
|
||||
void
|
||||
PortManager::get_physical_outputs (DataType type, std::vector<std::string>& s)
|
||||
{
|
||||
if (!_impl) {
|
||||
if (!_backend) {
|
||||
return;
|
||||
}
|
||||
_impl->get_physical_outputs (type, s);
|
||||
_backend->get_physical_outputs (type, s);
|
||||
}
|
||||
|
||||
void
|
||||
PortManager::get_physical_inputs (DataType type, std::vector<std::string>& s)
|
||||
{
|
||||
if (!_impl) {
|
||||
if (!_backend) {
|
||||
return;
|
||||
}
|
||||
|
||||
_impl->get_physical_inputs (type, s);
|
||||
_backend->get_physical_inputs (type, s);
|
||||
}
|
||||
|
||||
ChanCount
|
||||
PortManager::n_physical_outputs () const
|
||||
{
|
||||
if (!_impl) {
|
||||
if (!_backend) {
|
||||
return ChanCount::ZERO;
|
||||
}
|
||||
|
||||
return _impl->n_physical_outputs ();
|
||||
return _backend->n_physical_outputs ();
|
||||
}
|
||||
|
||||
ChanCount
|
||||
PortManager::n_physical_inputs () const
|
||||
{
|
||||
if (!_impl) {
|
||||
if (!_backend) {
|
||||
return ChanCount::ZERO;
|
||||
}
|
||||
return _impl->n_physical_inputs ();
|
||||
return _backend->n_physical_inputs ();
|
||||
}
|
||||
|
||||
/** @param name Full or short name of port
|
||||
|
@ -185,7 +186,7 @@ PortManager::n_physical_inputs () const
|
|||
boost::shared_ptr<Port>
|
||||
PortManager::get_port_by_name (const string& portname)
|
||||
{
|
||||
if (!_impl) {
|
||||
if (!_backend) {
|
||||
return boost::shared_ptr<Port>();
|
||||
}
|
||||
|
||||
|
@ -204,7 +205,7 @@ PortManager::get_port_by_name (const string& portname)
|
|||
and cheap), and if so, rename the port (which will alter
|
||||
the port map as a side effect).
|
||||
*/
|
||||
const std::string check = make_port_name_relative (_impl->get_port_name (x->second->port_handle()));
|
||||
const std::string check = make_port_name_relative (_backend->get_port_name (x->second->port_handle()));
|
||||
if (check != rel) {
|
||||
x->second->set_name (check);
|
||||
}
|
||||
|
@ -243,26 +244,26 @@ PortManager::get_ports (DataType type, PortList& pl)
|
|||
int
|
||||
PortManager::get_ports (const string& port_name_pattern, DataType type, PortFlags flags, vector<string>& s)
|
||||
{
|
||||
if (!_impl) {
|
||||
if (!_backend) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return _impl->get_ports (port_name_pattern, type, flags, s);
|
||||
return _backend->get_ports (port_name_pattern, type, flags, s);
|
||||
}
|
||||
|
||||
void
|
||||
PortManager::port_registration_failure (const std::string& portname)
|
||||
{
|
||||
if (!_impl) {
|
||||
if (!_backend) {
|
||||
return;
|
||||
}
|
||||
|
||||
string full_portname = _impl->my_name();
|
||||
string full_portname = _backend->my_name();
|
||||
full_portname += ':';
|
||||
full_portname += portname;
|
||||
|
||||
|
||||
PortEngine::PortHandle p = _impl->get_port_by_name (full_portname);
|
||||
PortEngine::PortHandle p = _backend->get_port_by_name (full_portname);
|
||||
string reason;
|
||||
|
||||
if (p) {
|
||||
|
@ -356,17 +357,17 @@ PortManager::unregister_port (boost::shared_ptr<Port> port)
|
|||
bool
|
||||
PortManager::connected (const string& port_name)
|
||||
{
|
||||
if (!_impl) {
|
||||
if (!_backend) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PortEngine::PortHandle handle = _impl->get_port_by_name (port_name);
|
||||
PortEngine::PortHandle handle = _backend->get_port_by_name (port_name);
|
||||
|
||||
if (!handle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return _impl->connected (handle);
|
||||
return _backend->connected (handle);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -387,8 +388,8 @@ PortManager::connect (const string& source, const string& destination)
|
|||
} else {
|
||||
/* neither port is known to us ...hand-off to the PortEngine
|
||||
*/
|
||||
if (_impl) {
|
||||
ret = _impl->connect (s, d);
|
||||
if (_backend) {
|
||||
ret = _backend->connect (s, d);
|
||||
} else {
|
||||
ret = -1;
|
||||
}
|
||||
|
@ -423,8 +424,8 @@ PortManager::disconnect (const string& source, const string& destination)
|
|||
} else {
|
||||
/* neither port is known to us ...hand-off to the PortEngine
|
||||
*/
|
||||
if (_impl) {
|
||||
ret = _impl->disconnect (s, d);
|
||||
if (_backend) {
|
||||
ret = _backend->disconnect (s, d);
|
||||
} else {
|
||||
ret = -1;
|
||||
}
|
||||
|
@ -516,59 +517,59 @@ PortManager::registration_callback ()
|
|||
bool
|
||||
PortManager::can_request_input_monitoring () const
|
||||
{
|
||||
if (!_impl) {
|
||||
if (!_backend) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return _impl->can_monitor_input ();
|
||||
return _backend->can_monitor_input ();
|
||||
}
|
||||
|
||||
void
|
||||
PortManager::request_input_monitoring (const string& name, bool yn) const
|
||||
{
|
||||
if (!_impl) {
|
||||
if (!_backend) {
|
||||
return;
|
||||
}
|
||||
|
||||
PortEngine::PortHandle ph = _impl->get_port_by_name (name);
|
||||
PortEngine::PortHandle ph = _backend->get_port_by_name (name);
|
||||
|
||||
if (ph) {
|
||||
_impl->request_input_monitoring (ph, yn);
|
||||
_backend->request_input_monitoring (ph, yn);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PortManager::ensure_input_monitoring (const string& name, bool yn) const
|
||||
{
|
||||
if (!_impl) {
|
||||
if (!_backend) {
|
||||
return;
|
||||
}
|
||||
|
||||
PortEngine::PortHandle ph = _impl->get_port_by_name (name);
|
||||
PortEngine::PortHandle ph = _backend->get_port_by_name (name);
|
||||
|
||||
if (ph) {
|
||||
_impl->ensure_input_monitoring (ph, yn);
|
||||
_backend->ensure_input_monitoring (ph, yn);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t
|
||||
PortManager::port_name_size() const
|
||||
{
|
||||
if (!_impl) {
|
||||
if (!_backend) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return _impl->port_name_size ();
|
||||
return _backend->port_name_size ();
|
||||
}
|
||||
|
||||
string
|
||||
PortManager::my_name() const
|
||||
{
|
||||
if (!_impl) {
|
||||
if (!_backend) {
|
||||
return string();
|
||||
}
|
||||
|
||||
return _impl->my_name();
|
||||
return _backend->my_name();
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -657,3 +658,10 @@ PortManager::fade_out (gain_t base_gain, gain_t gain_step, pframes_t nframes)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
PortEngine&
|
||||
PortManager::port_engine()
|
||||
{
|
||||
assert (_backend);
|
||||
return *_backend;
|
||||
}
|
||||
|
|
|
@ -285,23 +285,10 @@ Session::Session (AudioEngine &eng,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_engine.current_backend() == 0 || _engine.setup_required()) {
|
||||
boost::optional<int> r = AudioEngineSetupRequired (sr);
|
||||
if (r.get_value_or (-1) != 0) {
|
||||
destroy ();
|
||||
throw failed_constructor();
|
||||
}
|
||||
}
|
||||
|
||||
/* at this point the engine should be connected (i.e. interacting
|
||||
with a backend device (or psuedo-device) and available to us
|
||||
for determinining sample rates and other settings.
|
||||
*/
|
||||
|
||||
if (!_engine.connected()) {
|
||||
if (ensure_engine (sr)) {
|
||||
destroy ();
|
||||
throw failed_constructor();
|
||||
throw failed_constructor ();
|
||||
}
|
||||
|
||||
if (post_engine_init ()) {
|
||||
|
@ -346,6 +333,37 @@ Session::~Session ()
|
|||
destroy ();
|
||||
}
|
||||
|
||||
int
|
||||
Session::ensure_engine (uint32_t desired_sample_rate)
|
||||
{
|
||||
if (_engine.current_backend() == 0) {
|
||||
/* backend is unknown ... */
|
||||
boost::optional<int> r = AudioEngineSetupRequired (desired_sample_rate);
|
||||
if (r.get_value_or (-1) != 0) {
|
||||
return -1;
|
||||
}
|
||||
} else if (_engine.setup_required()) {
|
||||
/* backend is known, but setup is needed */
|
||||
boost::optional<int> r = AudioEngineSetupRequired (desired_sample_rate);
|
||||
if (r.get_value_or (-1) != 0) {
|
||||
return -1;
|
||||
}
|
||||
} else if (!_engine.running()) {
|
||||
if (_engine.start()) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* at this point the engine should be running
|
||||
*/
|
||||
|
||||
if (!_engine.running()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
Session::destroy ()
|
||||
{
|
||||
|
|
|
@ -309,6 +309,8 @@ Session::post_engine_init ()
|
|||
|
||||
_state_of_the_state = Clean;
|
||||
|
||||
Port::set_connecting_blocked (false);
|
||||
|
||||
DirtyChanged (); /* EMIT SIGNAL */
|
||||
|
||||
if (_is_new) {
|
||||
|
|
|
@ -19,12 +19,10 @@
|
|||
|
||||
#include "jack_connection.h"
|
||||
#include "jack_audiobackend.h"
|
||||
#include "jack_portengine.h"
|
||||
|
||||
using namespace ARDOUR;
|
||||
|
||||
static boost::shared_ptr<JACKAudioBackend> backend;
|
||||
static boost::shared_ptr<JACKPortEngine> port_engine;
|
||||
static boost::shared_ptr<JackConnection> jack_connection;
|
||||
|
||||
static boost::shared_ptr<AudioBackend>
|
||||
|
@ -41,20 +39,6 @@ backend_factory (AudioEngine& ae)
|
|||
return backend;
|
||||
}
|
||||
|
||||
static boost::shared_ptr<PortEngine>
|
||||
portengine_factory (PortManager& pm)
|
||||
{
|
||||
if (!jack_connection) {
|
||||
return boost::shared_ptr<PortEngine>();
|
||||
}
|
||||
|
||||
if (!port_engine) {
|
||||
port_engine.reset (new JACKPortEngine (pm, jack_connection));
|
||||
}
|
||||
|
||||
return port_engine;
|
||||
}
|
||||
|
||||
static int
|
||||
instantiate (const std::string& arg1, const std::string& arg2)
|
||||
{
|
||||
|
@ -70,7 +54,6 @@ instantiate (const std::string& arg1, const std::string& arg2)
|
|||
static int
|
||||
deinstantiate ()
|
||||
{
|
||||
port_engine.reset ();
|
||||
backend.reset ();
|
||||
jack_connection.reset ();
|
||||
|
||||
|
@ -95,7 +78,6 @@ extern "C" {
|
|||
instantiate,
|
||||
deinstantiate,
|
||||
backend_factory,
|
||||
portengine_factory,
|
||||
already_configured,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
|
||||
#include "jack_audiobackend.h"
|
||||
#include "jack_connection.h"
|
||||
#include "jack_portengine.h"
|
||||
#include "jack_utils.h"
|
||||
|
||||
#include "i18n.h"
|
||||
|
@ -67,6 +66,7 @@ JACKAudioBackend::JACKAudioBackend (AudioEngine& e, boost::shared_ptr<JackConnec
|
|||
, _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));
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ JACKAudioBackend::private_handle() const
|
|||
}
|
||||
|
||||
bool
|
||||
JACKAudioBackend::connected() const
|
||||
JACKAudioBackend::available() const
|
||||
{
|
||||
return (private_handle() != 0);
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ JACKAudioBackend::available_sample_rates (const string& /*device*/) const
|
|||
{
|
||||
vector<float> f;
|
||||
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
f.push_back (sample_rate());
|
||||
return f;
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ JACKAudioBackend::available_buffer_sizes (const string& /*device*/) const
|
|||
{
|
||||
vector<uint32_t> s;
|
||||
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
s.push_back (buffer_size());
|
||||
return s;
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ JACKAudioBackend::available_output_channel_count (const string& /*device*/) cons
|
|||
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;
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ JACKAudioBackend::set_device_name (const string& dev)
|
|||
int
|
||||
JACKAudioBackend::set_sample_rate (float sr)
|
||||
{
|
||||
if (!connected()) {
|
||||
if (!available()) {
|
||||
_target_sample_rate = sr;
|
||||
return 0;
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ JACKAudioBackend::set_sample_rate (float sr)
|
|||
int
|
||||
JACKAudioBackend::set_buffer_size (uint32_t nframes)
|
||||
{
|
||||
if (!connected()) {
|
||||
if (!available()) {
|
||||
_target_buffer_size = nframes;
|
||||
return 0;
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ JACKAudioBackend::set_interleaved (bool yn)
|
|||
int
|
||||
JACKAudioBackend::set_input_channels (uint32_t cnt)
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ JACKAudioBackend::set_input_channels (uint32_t cnt)
|
|||
int
|
||||
JACKAudioBackend::set_output_channels (uint32_t cnt)
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -317,7 +317,7 @@ JACKAudioBackend::set_output_channels (uint32_t cnt)
|
|||
int
|
||||
JACKAudioBackend::set_systemic_input_latency (uint32_t l)
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ JACKAudioBackend::set_systemic_input_latency (uint32_t l)
|
|||
int
|
||||
JACKAudioBackend::set_systemic_output_latency (uint32_t l)
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,7 @@ JACKAudioBackend::set_systemic_output_latency (uint32_t l)
|
|||
std::string
|
||||
JACKAudioBackend::device_name () const
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return "???";
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,7 @@ JACKAudioBackend::device_name () const
|
|||
float
|
||||
JACKAudioBackend::sample_rate () const
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return _current_sample_rate;
|
||||
}
|
||||
return _target_sample_rate;
|
||||
|
@ -362,7 +362,7 @@ JACKAudioBackend::sample_rate () const
|
|||
uint32_t
|
||||
JACKAudioBackend::buffer_size () const
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return _current_buffer_size;
|
||||
}
|
||||
return _target_buffer_size;
|
||||
|
@ -383,7 +383,7 @@ JACKAudioBackend::interleaved () const
|
|||
uint32_t
|
||||
JACKAudioBackend::input_channels () const
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return n_physical (JackPortIsInput).n_audio();
|
||||
}
|
||||
return _target_input_channels;
|
||||
|
@ -392,7 +392,7 @@ JACKAudioBackend::input_channels () const
|
|||
uint32_t
|
||||
JACKAudioBackend::output_channels () const
|
||||
{
|
||||
if (connected()) {
|
||||
if (available()) {
|
||||
return n_physical (JackPortIsOutput).n_audio();
|
||||
}
|
||||
return _target_output_channels;
|
||||
|
@ -451,7 +451,9 @@ JACKAudioBackend::setup_jack_startup_command ()
|
|||
string cmdline;
|
||||
|
||||
if (!get_jack_command_line_string (options, cmdline)) {
|
||||
/* error, somehow */
|
||||
/* error, somehow - we will still try to start JACK
|
||||
* automatically but it will be without our preferred options
|
||||
*/
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -465,7 +467,7 @@ JACKAudioBackend::setup_jack_startup_command ()
|
|||
int
|
||||
JACKAudioBackend::start ()
|
||||
{
|
||||
if (!connected()) {
|
||||
if (!available()) {
|
||||
|
||||
if (!_jack_connection->server_running()) {
|
||||
setup_jack_startup_command ();
|
||||
|
@ -736,9 +738,9 @@ JACKAudioBackend::jack_sync_callback (jack_transport_state_t state, jack_positio
|
|||
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;
|
||||
}
|
||||
|
@ -747,8 +749,8 @@ JACKAudioBackend::_xrun_callback (void *arg)
|
|||
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);
|
||||
|
@ -940,8 +942,10 @@ JACKAudioBackend::n_physical (unsigned long flags) const
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,10 +44,12 @@ class JACKAudioBackend : public AudioBackend {
|
|||
public:
|
||||
JACKAudioBackend (AudioEngine& e, boost::shared_ptr<JackConnection>);
|
||||
~JACKAudioBackend ();
|
||||
|
||||
/* AUDIOBACKEND API */
|
||||
|
||||
std::string name() const;
|
||||
void* private_handle() const;
|
||||
bool connected() const;
|
||||
bool available() const;
|
||||
bool is_realtime () const;
|
||||
|
||||
bool requires_driver_selection() const;
|
||||
|
@ -115,9 +117,68 @@ class JACKAudioBackend : public AudioBackend {
|
|||
void update_latencies ();
|
||||
|
||||
static bool already_configured();
|
||||
|
||||
/* PORTENGINE API */
|
||||
|
||||
const std::string& my_name() 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);
|
||||
|
||||
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);
|
||||
int connect (PortHandle, const std::string&);
|
||||
|
||||
int disconnect (PortHandle, const std::string&);
|
||||
int disconnect_all (PortHandle);
|
||||
int connect (const std::string& src, const std::string& dst);
|
||||
int disconnect (const std::string& src, const std::string& dst);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* 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:
|
||||
boost::shared_ptr<JackConnection> _jack_connection; //< shared with JACKPortEngine
|
||||
boost::shared_ptr<JackConnection> _jack_connection;
|
||||
bool _running;
|
||||
bool _freewheeling;
|
||||
std::map<DataType,size_t> _raw_buffer_sizes;
|
||||
|
@ -158,8 +219,6 @@ class JACKAudioBackend : public AudioBackend {
|
|||
void* process_thread ();
|
||||
static void* _start_process_thread (void*);
|
||||
|
||||
ChanCount n_physical (unsigned long) const;
|
||||
|
||||
void setup_jack_startup_command ();
|
||||
|
||||
/* pffooo */
|
||||
|
@ -183,6 +242,20 @@ class JACKAudioBackend : public AudioBackend {
|
|||
mutable DriverDeviceMap all_devices;
|
||||
|
||||
PBD::ScopedConnection disconnect_connection;
|
||||
|
||||
/* PORTENGINE RELATED */
|
||||
|
||||
static int _graph_order_callback (void *arg);
|
||||
static void _registration_callback (jack_port_id_t, int, void *);
|
||||
static void _connect_callback (jack_port_id_t, jack_port_id_t, int, void *);
|
||||
|
||||
void connect_callback (jack_port_id_t, jack_port_id_t, int);
|
||||
|
||||
ChanCount n_physical (unsigned long flags) const;
|
||||
void get_physical (DataType type, unsigned long flags, std::vector<std::string>& phy) const;
|
||||
|
||||
void when_connected_to_jack ();
|
||||
PBD::ScopedConnection jack_connection_connection;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -22,8 +22,9 @@
|
|||
|
||||
#include "pbd/error.h"
|
||||
|
||||
#include "jack_portengine.h"
|
||||
#include "jack_audiobackend.h"
|
||||
#include "jack_connection.h"
|
||||
#include "jack/midiport.h"
|
||||
|
||||
#include "ardour/port_manager.h"
|
||||
|
||||
|
@ -85,24 +86,8 @@ ardour_data_type_to_jack_port_type (DataType d)
|
|||
return "";
|
||||
}
|
||||
|
||||
JACKPortEngine::JACKPortEngine (PortManager& pm, boost::shared_ptr<JackConnection> jc)
|
||||
: PortEngine (pm)
|
||||
, _jack_connection (jc)
|
||||
{
|
||||
_jack_connection->Connected.connect_same_thread (jack_connection_connection, boost::bind (&JACKPortEngine::connected_to_jack, this));
|
||||
}
|
||||
|
||||
JACKPortEngine::~JACKPortEngine ()
|
||||
{
|
||||
/* a default destructor would do this, and so would this one,
|
||||
but we'll make it explicit in case we ever need to debug
|
||||
the lifetime of the JACKConnection
|
||||
*/
|
||||
_jack_connection.reset ();
|
||||
}
|
||||
|
||||
void
|
||||
JACKPortEngine::connected_to_jack ()
|
||||
JACKAudioBackend::when_connected_to_jack ()
|
||||
{
|
||||
/* register callbacks for stuff that is our responsibility */
|
||||
|
||||
|
@ -119,57 +104,45 @@ JACKPortEngine::connected_to_jack ()
|
|||
jack_set_graph_order_callback (client, _graph_order_callback, this);
|
||||
}
|
||||
|
||||
void*
|
||||
JACKPortEngine::private_handle() const
|
||||
{
|
||||
return _jack_connection->jack();
|
||||
}
|
||||
|
||||
bool
|
||||
JACKPortEngine::connected() const
|
||||
{
|
||||
return _jack_connection->connected();
|
||||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::set_port_name (PortHandle port, const std::string& name)
|
||||
JACKAudioBackend::set_port_name (PortHandle port, const std::string& name)
|
||||
{
|
||||
return jack_port_set_name ((jack_port_t*) port, name.c_str());
|
||||
}
|
||||
|
||||
string
|
||||
JACKPortEngine::get_port_name (PortHandle port) const
|
||||
JACKAudioBackend::get_port_name (PortHandle port) const
|
||||
{
|
||||
return jack_port_name ((jack_port_t*) port);
|
||||
}
|
||||
|
||||
PortEngine::PortHandle*
|
||||
JACKPortEngine:: get_port_by_name (const std::string& name) const
|
||||
JACKAudioBackend:: get_port_by_name (const std::string& name) const
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, 0);
|
||||
return (PortHandle*) jack_port_by_name (_priv_jack, name.c_str());
|
||||
}
|
||||
|
||||
void
|
||||
JACKPortEngine::_registration_callback (jack_port_id_t /*id*/, int /*reg*/, void* arg)
|
||||
JACKAudioBackend::_registration_callback (jack_port_id_t /*id*/, int /*reg*/, void* arg)
|
||||
{
|
||||
static_cast<JACKPortEngine*> (arg)->manager.registration_callback ();
|
||||
static_cast<JACKAudioBackend*> (arg)->manager.registration_callback ();
|
||||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::_graph_order_callback (void *arg)
|
||||
JACKAudioBackend::_graph_order_callback (void *arg)
|
||||
{
|
||||
return static_cast<JACKPortEngine*> (arg)->manager.graph_order_callback ();
|
||||
return static_cast<JACKAudioBackend*> (arg)->manager.graph_order_callback ();
|
||||
}
|
||||
|
||||
void
|
||||
JACKPortEngine::_connect_callback (jack_port_id_t id_a, jack_port_id_t id_b, int conn, void* arg)
|
||||
JACKAudioBackend::_connect_callback (jack_port_id_t id_a, jack_port_id_t id_b, int conn, void* arg)
|
||||
{
|
||||
static_cast<JACKPortEngine*> (arg)->connect_callback (id_a, id_b, conn);
|
||||
static_cast<JACKAudioBackend*> (arg)->connect_callback (id_a, id_b, conn);
|
||||
}
|
||||
|
||||
void
|
||||
JACKPortEngine::connect_callback (jack_port_id_t id_a, jack_port_id_t id_b, int conn)
|
||||
JACKAudioBackend::connect_callback (jack_port_id_t id_a, jack_port_id_t id_b, int conn)
|
||||
{
|
||||
if (manager.port_remove_in_progress()) {
|
||||
return;
|
||||
|
@ -184,7 +157,7 @@ JACKPortEngine::connect_callback (jack_port_id_t id_a, jack_port_id_t id_b, int
|
|||
}
|
||||
|
||||
bool
|
||||
JACKPortEngine::connected (PortHandle port, bool process_callback_safe)
|
||||
JACKAudioBackend::connected (PortHandle port, bool process_callback_safe)
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
|
@ -207,7 +180,7 @@ JACKPortEngine::connected (PortHandle port, bool process_callback_safe)
|
|||
}
|
||||
|
||||
bool
|
||||
JACKPortEngine::connected_to (PortHandle port, const std::string& other, bool process_callback_safe)
|
||||
JACKAudioBackend::connected_to (PortHandle port, const std::string& other, bool process_callback_safe)
|
||||
{
|
||||
bool ret = false;
|
||||
const char** ports;
|
||||
|
@ -232,7 +205,7 @@ JACKPortEngine::connected_to (PortHandle port, const std::string& other, bool pr
|
|||
}
|
||||
|
||||
bool
|
||||
JACKPortEngine::physically_connected (PortHandle p, bool process_callback_safe)
|
||||
JACKAudioBackend::physically_connected (PortHandle p, bool process_callback_safe)
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, false);
|
||||
jack_port_t* port = (jack_port_t*) p;
|
||||
|
@ -262,7 +235,7 @@ JACKPortEngine::physically_connected (PortHandle p, bool process_callback_safe)
|
|||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::get_connections (PortHandle port, vector<string>& s, bool process_callback_safe)
|
||||
JACKAudioBackend::get_connections (PortHandle port, vector<string>& s, bool process_callback_safe)
|
||||
{
|
||||
const char** ports;
|
||||
|
||||
|
@ -284,19 +257,19 @@ JACKPortEngine::get_connections (PortHandle port, vector<string>& s, bool proces
|
|||
}
|
||||
|
||||
DataType
|
||||
JACKPortEngine::port_data_type (PortHandle p) const
|
||||
JACKAudioBackend::port_data_type (PortHandle p) const
|
||||
{
|
||||
return jack_port_type_to_ardour_data_type (jack_port_type ((jack_port_t*) p));
|
||||
}
|
||||
|
||||
const string&
|
||||
JACKPortEngine::my_name() const
|
||||
JACKAudioBackend::my_name() const
|
||||
{
|
||||
return _jack_connection->client_name();
|
||||
}
|
||||
|
||||
bool
|
||||
JACKPortEngine::port_is_physical (PortHandle ph) const
|
||||
JACKAudioBackend::port_is_physical (PortHandle ph) const
|
||||
{
|
||||
if (!ph) {
|
||||
return false;
|
||||
|
@ -306,7 +279,7 @@ JACKPortEngine::port_is_physical (PortHandle ph) const
|
|||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::get_ports (const string& port_name_pattern, DataType type, PortFlags flags, vector<string>& s) const
|
||||
JACKAudioBackend::get_ports (const string& port_name_pattern, DataType type, PortFlags flags, vector<string>& s) const
|
||||
{
|
||||
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack,0);
|
||||
|
@ -329,44 +302,19 @@ JACKPortEngine::get_ports (const string& port_name_pattern, DataType type, PortF
|
|||
}
|
||||
|
||||
ChanCount
|
||||
JACKPortEngine::n_physical (unsigned long flags) const
|
||||
{
|
||||
ChanCount c;
|
||||
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, c);
|
||||
|
||||
const char ** ports = jack_get_ports (_priv_jack, NULL, NULL, JackPortIsPhysical | flags);
|
||||
|
||||
if (ports) {
|
||||
for (uint32_t i = 0; ports[i]; ++i) {
|
||||
if (!strstr (ports[i], "Midi-Through")) {
|
||||
DataType t = port_data_type (jack_port_by_name (_priv_jack, ports[i]));
|
||||
if (t != DataType::NIL) {
|
||||
c.set (t, c.get (t) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jack_free (ports);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
ChanCount
|
||||
JACKPortEngine::n_physical_inputs () const
|
||||
JACKAudioBackend::n_physical_inputs () const
|
||||
{
|
||||
return n_physical (JackPortIsInput);
|
||||
}
|
||||
|
||||
ChanCount
|
||||
JACKPortEngine::n_physical_outputs () const
|
||||
JACKAudioBackend::n_physical_outputs () const
|
||||
{
|
||||
return n_physical (JackPortIsOutput);
|
||||
}
|
||||
|
||||
void
|
||||
JACKPortEngine::get_physical (DataType type, unsigned long flags, vector<string>& phy) const
|
||||
JACKAudioBackend::get_physical (DataType type, unsigned long flags, vector<string>& phy) const
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER (_priv_jack);
|
||||
const char ** ports;
|
||||
|
@ -390,7 +338,7 @@ JACKPortEngine::get_physical (DataType type, unsigned long flags, vector<string>
|
|||
* a physical input connector.
|
||||
*/
|
||||
void
|
||||
JACKPortEngine::get_physical_inputs (DataType type, vector<string>& ins)
|
||||
JACKAudioBackend::get_physical_inputs (DataType type, vector<string>& ins)
|
||||
{
|
||||
get_physical (type, JackPortIsOutput, ins);
|
||||
}
|
||||
|
@ -399,14 +347,14 @@ JACKPortEngine::get_physical_inputs (DataType type, vector<string>& ins)
|
|||
* a physical output connector.
|
||||
*/
|
||||
void
|
||||
JACKPortEngine::get_physical_outputs (DataType type, vector<string>& outs)
|
||||
JACKAudioBackend::get_physical_outputs (DataType type, vector<string>& outs)
|
||||
{
|
||||
get_physical (type, JackPortIsInput, outs);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
JACKPortEngine::can_monitor_input () const
|
||||
JACKAudioBackend::can_monitor_input () const
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack,false);
|
||||
const char ** ports;
|
||||
|
@ -421,32 +369,23 @@ JACKPortEngine::can_monitor_input () const
|
|||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::request_input_monitoring (PortHandle port, bool yn)
|
||||
JACKAudioBackend::request_input_monitoring (PortHandle port, bool yn)
|
||||
{
|
||||
return jack_port_request_monitor ((jack_port_t*) port, yn);
|
||||
}
|
||||
int
|
||||
JACKPortEngine::ensure_input_monitoring (PortHandle port, bool yn)
|
||||
JACKAudioBackend::ensure_input_monitoring (PortHandle port, bool yn)
|
||||
{
|
||||
return jack_port_ensure_monitor ((jack_port_t*) port, yn);
|
||||
}
|
||||
bool
|
||||
JACKPortEngine::monitoring_input (PortHandle port)
|
||||
JACKAudioBackend::monitoring_input (PortHandle port)
|
||||
{
|
||||
return jack_port_monitoring_input ((jack_port_t*) port);
|
||||
}
|
||||
|
||||
|
||||
pframes_t
|
||||
JACKPortEngine::sample_time_at_cycle_start ()
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, 0);
|
||||
return jack_last_frame_time (_priv_jack);
|
||||
}
|
||||
|
||||
|
||||
PortEngine::PortHandle
|
||||
JACKPortEngine::register_port (const std::string& shortname, ARDOUR::DataType type, ARDOUR::PortFlags flags)
|
||||
JACKAudioBackend::register_port (const std::string& shortname, ARDOUR::DataType type, ARDOUR::PortFlags flags)
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, 0);
|
||||
return jack_port_register (_priv_jack, shortname.c_str(),
|
||||
|
@ -456,20 +395,20 @@ JACKPortEngine::register_port (const std::string& shortname, ARDOUR::DataType ty
|
|||
}
|
||||
|
||||
void
|
||||
JACKPortEngine::unregister_port (PortHandle port)
|
||||
JACKAudioBackend::unregister_port (PortHandle port)
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER (_priv_jack);
|
||||
(void) jack_port_unregister (_priv_jack, (jack_port_t*) port);
|
||||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::connect (PortHandle port, const std::string& other)
|
||||
JACKAudioBackend::connect (PortHandle port, const std::string& other)
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1);
|
||||
return jack_connect (_priv_jack, jack_port_name ((jack_port_t*) port), other.c_str());
|
||||
}
|
||||
int
|
||||
JACKPortEngine::connect (const std::string& src, const std::string& dst)
|
||||
JACKAudioBackend::connect (const std::string& src, const std::string& dst)
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1);
|
||||
|
||||
|
@ -478,28 +417,28 @@ JACKPortEngine::connect (const std::string& src, const std::string& dst)
|
|||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::disconnect (PortHandle port, const std::string& other)
|
||||
JACKAudioBackend::disconnect (PortHandle port, const std::string& other)
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1);
|
||||
return jack_disconnect (_priv_jack, jack_port_name ((jack_port_t*) port), other.c_str());
|
||||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::disconnect (const std::string& src, const std::string& dst)
|
||||
JACKAudioBackend::disconnect (const std::string& src, const std::string& dst)
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1);
|
||||
return jack_disconnect (_priv_jack, src.c_str(), dst.c_str());
|
||||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::disconnect_all (PortHandle port)
|
||||
JACKAudioBackend::disconnect_all (PortHandle port)
|
||||
{
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, -1);
|
||||
return jack_port_disconnect (_priv_jack, (jack_port_t*) port);
|
||||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** buf, void* port_buffer, uint32_t event_index)
|
||||
JACKAudioBackend::midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** buf, void* port_buffer, uint32_t event_index)
|
||||
{
|
||||
jack_midi_event_t ev;
|
||||
int ret;
|
||||
|
@ -514,25 +453,25 @@ JACKPortEngine::midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** bu
|
|||
}
|
||||
|
||||
int
|
||||
JACKPortEngine::midi_event_put (void* port_buffer, pframes_t timestamp, const uint8_t* buffer, size_t size)
|
||||
JACKAudioBackend::midi_event_put (void* port_buffer, pframes_t timestamp, const uint8_t* buffer, size_t size)
|
||||
{
|
||||
return jack_midi_event_write (port_buffer, timestamp, buffer, size);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
JACKPortEngine::get_midi_event_count (void* port_buffer)
|
||||
JACKAudioBackend::get_midi_event_count (void* port_buffer)
|
||||
{
|
||||
return jack_midi_get_event_count (port_buffer);
|
||||
}
|
||||
|
||||
void
|
||||
JACKPortEngine::midi_clear (void* port_buffer)
|
||||
JACKAudioBackend::midi_clear (void* port_buffer)
|
||||
{
|
||||
jack_midi_clear_buffer (port_buffer);
|
||||
}
|
||||
|
||||
void
|
||||
JACKPortEngine::set_latency_range (PortHandle port, bool for_playback, LatencyRange r)
|
||||
JACKAudioBackend::set_latency_range (PortHandle port, bool for_playback, LatencyRange r)
|
||||
{
|
||||
jack_latency_range_t range;
|
||||
|
||||
|
@ -543,7 +482,7 @@ JACKPortEngine::set_latency_range (PortHandle port, bool for_playback, LatencyRa
|
|||
}
|
||||
|
||||
LatencyRange
|
||||
JACKPortEngine::get_latency_range (PortHandle port, bool for_playback)
|
||||
JACKAudioBackend::get_latency_range (PortHandle port, bool for_playback)
|
||||
{
|
||||
jack_latency_range_t range;
|
||||
LatencyRange ret;
|
||||
|
@ -557,13 +496,13 @@ JACKPortEngine::get_latency_range (PortHandle port, bool for_playback)
|
|||
}
|
||||
|
||||
void*
|
||||
JACKPortEngine::get_buffer (PortHandle port, pframes_t nframes)
|
||||
JACKAudioBackend::get_buffer (PortHandle port, pframes_t nframes)
|
||||
{
|
||||
return jack_port_get_buffer ((jack_port_t*) port, nframes);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
JACKPortEngine::port_name_size() const
|
||||
JACKAudioBackend::port_name_size() const
|
||||
{
|
||||
return jack_port_name_size ();
|
||||
}
|
||||
|
|
|
@ -1,132 +0,0 @@
|
|||
/*
|
||||
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 __libardour_jack_portengine_h__
|
||||
#define __libardour_jack_portengine_h__
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <jack/types.h>
|
||||
#include <jack/midiport.h>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "pbd/signals.h"
|
||||
|
||||
#include "ardour/port_engine.h"
|
||||
#include "ardour/types.h"
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
class JackConnection;
|
||||
|
||||
class JACKPortEngine : public PortEngine
|
||||
{
|
||||
public:
|
||||
JACKPortEngine (PortManager&, boost::shared_ptr<JackConnection>);
|
||||
~JACKPortEngine();
|
||||
|
||||
void* private_handle() const;
|
||||
bool connected() const;
|
||||
|
||||
const std::string& my_name() 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);
|
||||
|
||||
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);
|
||||
int connect (PortHandle, const std::string&);
|
||||
|
||||
int disconnect (PortHandle, const std::string&);
|
||||
int disconnect_all (PortHandle);
|
||||
int connect (const std::string& src, const std::string& dst);
|
||||
int disconnect (const std::string& src, const std::string& dst);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* Miscellany */
|
||||
|
||||
pframes_t sample_time_at_cycle_start ();
|
||||
|
||||
private:
|
||||
boost::shared_ptr<JackConnection> _jack_connection;
|
||||
|
||||
static int _graph_order_callback (void *arg);
|
||||
static void _registration_callback (jack_port_id_t, int, void *);
|
||||
static void _connect_callback (jack_port_id_t, jack_port_id_t, int, void *);
|
||||
|
||||
void connect_callback (jack_port_id_t, jack_port_id_t, int);
|
||||
|
||||
ChanCount n_physical (unsigned long flags) const;
|
||||
void get_physical (DataType type, unsigned long flags, std::vector<std::string>& phy) const;
|
||||
|
||||
PBD::ScopedConnection jack_connection_connection;
|
||||
void connected_to_jack ();
|
||||
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif /* __libardour_jack_portengine_h__ */
|
Loading…
Reference in New Issue