Index: gtk2_ardour/SConscript =================================================================== --- gtk2_ardour/SConscript (revision 1514) +++ gtk2_ardour/SConscript (working copy) @@ -80,6 +80,10 @@ au_pluginui.cc """) +if gtkardour['LASH']: + gtkardour.Merge ([ libraries['lash']]) + + gtkardour_files=Split(""" about.cc actions.cc Index: gtk2_ardour/main.cc =================================================================== --- gtk2_ardour/main.cc (revision 1514) +++ gtk2_ardour/main.cc (working copy) @@ -296,10 +296,17 @@ maybe_load_session () { /* If no session name is given: we're not loading a session yet, nor creating a new one */ +#ifdef LASH_SUPPORT + if (session_name.length() && !ARDOUR_UI::got_lash()){ +#else if (!session_name.length()) { +#endif ui->hide_splash (); if (!Config->get_no_new_session_dialog()) { - ui->new_session (); +#ifdef LASH_SUPPORT + if (!ARDOUR_UI::got_lash()) +#endif + ui->new_session (); } return true; @@ -439,6 +446,9 @@ try { ARDOUR::init (use_vst, try_hw_optimization); +#ifdef LASH_SUPPORT + ARDOUR_UI::do_init_lash(&argc, &argv); +#endif setup_gtk_ardour_enums (); Config->set_current_owner (ConfigVariableBase::Interface); Index: gtk2_ardour/ardour_ui.cc =================================================================== --- gtk2_ardour/ardour_ui.cc (revision 1514) +++ gtk2_ardour/ardour_ui.cc (working copy) @@ -20,10 +20,12 @@ #include #include #include +#include #include #include #include #include +#include #include @@ -211,7 +213,33 @@ /* have to wait for AudioEngine and Configuration before proceeding */ } +#ifdef LASH_SUPPORT +bool +ARDOUR_UI::got_lash() +{ + if (lash_client) + return true; + else + return false; +} + void +ARDOUR_UI::do_init_lash (int *argcp, char **argvp[]) +{ + lash_client = lash_init(lash_extract_args(argcp, argvp), "ardour", + LASH_Config_Data_Set, LASH_PROTOCOL(2, 0)); + + lash_event_t *lash_event; + if (lash_client) { + Config->set_connect_ports(false); + lash_event = lash_event_new_with_type(LASH_Client_Name); + lash_event_set_string(lash_event, "Ardour"); + lash_send_event(lash_client, lash_event); + } +} +#endif + +void ARDOUR_UI::set_engine (AudioEngine& e) { engine = &e; @@ -277,6 +305,13 @@ update_wall_clock (); Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::update_wall_clock), 60000); +#ifdef LASH_SUPPORT + if (lash_client) { + process_lash_events(); + Glib::signal_timeout().connect (mem_fun(*this, &ARDOUR_UI::process_lash_events), 1000); + } +#endif + update_disk_space (); update_cpu_load (); update_sample_rate (engine->frame_rate()); @@ -654,6 +689,79 @@ } } +#ifdef LASH_SUPPORT +gint +ARDOUR_UI::process_lash_events() { + lash_event_t *lash_event; + lash_config_t *lash_config; + + if (!lash_client) + return TRUE; + + while ((lash_event = lash_get_event(lash_client))) { + char *lash_config_key; + char *lash_config_value; + switch (lash_event_get_type(lash_event)) { + + case LASH_Quit: + Main::quit(); + break; + + case LASH_Save_Data_Set: + /* send LASH our filename */ + if (session) { + save_ardour_state(); + + lash_config = lash_config_new(); + + lash_config_key = (char*) malloc(strlen("session_filename") + 1); + /* 1024 is arbitrarily chosen */ + lash_config_value = (char*) malloc(1024); + + strcpy(lash_config_key, "session_filename"); + strcpy(lash_config_value, + (session->path() + session->name()).c_str()); + + lash_config_set_key(lash_config, lash_config_key); + lash_config_set_value(lash_config, lash_config_value, + strlen((session->path() + session->name()).c_str())+1); + + lash_send_config(lash_client, lash_config); + + /* need to send an acknowledge to LASH */ + lash_event_t *ack = lash_event_new_with_type(LASH_Save_Data_Set); + lash_send_event(lash_client, ack); + + } + break; + + case LASH_Restore_Data_Set: + /* This is incredibly not good and temporary */ + while ((lash_config = lash_get_config(lash_client))) { + if (string(lash_config_get_key(lash_config)) == "session_filename") { + string value = lash_config_get_value_string(lash_config); + load_session(Glib::path_get_dirname(value), Glib::path_get_basename(value)); + lash_jack_client_name(lash_client, engine->client_name().c_str()); + } + lash_config_destroy(lash_config); + } + /* need to send an acknowledge to LASH */ + { + lash_event_t *ack = lash_event_new_with_type(LASH_Restore_Data_Set); + lash_send_event(lash_client, ack); + } + break; + + default: + /* ignore everything else */ + ; + } + lash_event_destroy(lash_event); + } + return TRUE; +} +#endif + void ARDOUR_UI::update_disk_space() { @@ -2670,3 +2778,8 @@ { _id = str; } + +#ifdef LASH_SUPPORT +lash_client_t *ARDOUR_UI::lash_client = 0; +#endif + Index: gtk2_ardour/ardour_ui.h =================================================================== --- gtk2_ardour/ardour_ui.h (revision 1514) +++ gtk2_ardour/ardour_ui.h (working copy) @@ -37,6 +37,10 @@ #include +#ifdef LASH_SUPPORT +#include +#endif + #include #include #include @@ -106,6 +110,11 @@ void show_splash (); void hide_splash (); + +#ifdef LASH_SUPPORT + static void do_init_lash(int *argcp, char **argvp[]); + static bool got_lash(); +#endif int load_session (const string & path, const string & snapshot, string* mix_template = 0); bool session_loaded; @@ -139,7 +148,7 @@ void restore_state (string state_name = ""); static double gain_to_slider_position (ARDOUR::gain_t g); - static ARDOUR::gain_t slider_position_to_gain (double pos); + static ARDOUR::gain_t slider_position_to_gain (double pos); static ARDOUR_UI *instance () { return theArdourUI; } @@ -613,8 +622,15 @@ uint32_t rec_enabled_streams; void count_recenabled_streams (ARDOUR::Route&); + +#ifdef LASH_SUPPORT + static lash_client_t *lash_client; + gint process_lash_events(); +#endif + About* about; bool shown_flag; + /* cleanup */ Gtk::MenuItem *cleanup_item; Index: libs/ardour/ardour/configuration_vars.h =================================================================== --- libs/ardour/ardour/configuration_vars.h (revision 1514) +++ libs/ardour/ardour/configuration_vars.h (working copy) @@ -120,6 +120,8 @@ CONFIG_VARIABLE (uint32_t, saved_history_depth, "save-history-depth", 100) CONFIG_VARIABLE (bool, use_overlap_equivalency, "use-overlap-equivalency", false) +CONFIG_VARIABLE(bool, connect_ports, "connect-ports", true) + /* BWAV */ CONFIG_VARIABLE (string, bwf_country_code, "bwf-country-code", "US") Index: libs/ardour/audioengine.cc =================================================================== --- libs/ardour/audioengine.cc (revision 1514) +++ libs/ardour/audioengine.cc (working copy) @@ -588,12 +588,15 @@ } } + if (!Config->get_connect_ports()) + return 0; + string s = make_port_name_non_relative (source); string d = make_port_name_non_relative (destination); int ret = jack_connect (_jack, s.c_str(), d.c_str()); - if (ret == 0) { + if (ret == 0 || ret == EEXIST) { pair c (s, d); port_connections.push_back (c); } else if (ret == EEXIST) { @@ -621,6 +624,9 @@ } } + if (!Config->get_connect_ports()) + return 0; + string s = make_port_name_non_relative (source); string d = make_port_name_non_relative (destination); @@ -1167,15 +1173,17 @@ /* re-establish connections */ - for (PortConnections::iterator i = port_connections.begin(); i != port_connections.end(); ++i) { - - int err; - - if ((err = jack_connect (_jack, (*i).first.c_str(), (*i).second.c_str())) != 0) { - if (err != EEXIST) { - error << string_compose (_("could not reconnect %1 and %2 (err = %3)"), - (*i).first, (*i).second, err) - << endmsg; + if (Config->get_connect_ports()) { + for (PortConnections::iterator i = port_connections.begin(); i != port_connections.end(); ++i) { + + int err; + + if ((err = jack_connect (_jack, (*i).first.c_str(), (*i).second.c_str())) != 0) { + if (err != EEXIST) { + error << string_compose (_("could not reconnect %1 and %2 (err = %3)"), + (*i).first, (*i).second, err) + << endmsg; + } } } } Index: SConstruct =================================================================== --- SConstruct (revision 1514) +++ SConstruct (working copy) @@ -44,6 +44,7 @@ BoolOption('UNIVERSAL', 'Compile as universal binary. Requires that external libraries are already universal.', 0), BoolOption('VERSIONED', 'Add revision information to ardour/gtk executable name inside the build directory', 0), BoolOption('VST', 'Compile with support for VST', 0), + BoolOption('LASH', 'Compile with support for LASH session handling', 0), BoolOption('TRANZPORT', 'Compile with support for Frontier Designs (if libusb is available)', 0) ) @@ -476,6 +477,9 @@ libraries['jack'] = LibraryInfo() libraries['jack'].ParseConfig('pkg-config --cflags --libs jack') +libraries['lash'] = LibraryInfo() +libraries['lash'].ParseConfig('pkg-config --cflags --libs lash-1.0') + libraries['xml'] = LibraryInfo() libraries['xml'].ParseConfig('pkg-config --cflags --libs libxml-2.0') @@ -632,6 +636,9 @@ print "\nWarning: you are building Ardour with SSE support even though your system does not support these instructions. (This may not be an error, especially if you are a package maintainer)" # end optimization section +if env['LASH']: + env.Append(CCFLAGS="-DLASH_SUPPORT") + # handle x86/x86_64 libdir properly if env['DIST_TARGET'] == 'x86_64':