Add NSM ':switch:' capability

This allows to switch from one Ardour session to another without
application restart.

This also include some minor related NSM fixes.
This commit is contained in:
Houston4444 2021-12-02 14:34:58 +01:00 committed by Robin Gareus
parent 6eb1559f79
commit 692aa7bbb8
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
5 changed files with 16 additions and 8 deletions

View File

@ -369,6 +369,7 @@ ARDOUR_UI::ARDOUR_UI (int *argcp, char **argvp[], const char* localedir)
, prefs_visibility_button (S_("Window|Prefs"))
, recorder_visibility_button (S_("Window|Rec"))
, trigger_page_visibility_button (S_("Window|Trig"))
, nsm_first_session_opened (false)
{
Gtkmm2ext::init (localedir);

View File

@ -238,7 +238,7 @@ public:
int load_session_from_startup_fsm ();
/// @return true if session was successfully unloaded.
int unload_session (bool hide_stuff = false);
int unload_session (bool hide_stuff = false, bool force_unload = false);
void close_session();
int save_state_canfail (std::string state_name = "", bool switch_to_it = false);
@ -927,6 +927,7 @@ private:
void action_script_changed (int i, const std::string&);
void ask_about_scratch_deletion ();
bool nsm_first_session_opened;
};
#endif /* __ardour_gui_h__ */

View File

@ -287,7 +287,7 @@ ARDOUR_UI::set_session (Session *s)
}
int
ARDOUR_UI::unload_session (bool hide_stuff)
ARDOUR_UI::unload_session (bool hide_stuff, bool force_unload)
{
if (_session) {
ARDOUR_UI::instance()->video_timeline->sync_session_state();
@ -303,7 +303,7 @@ ARDOUR_UI::unload_session (bool hide_stuff)
save_ardour_state ();
}
if (_session && _session->dirty()) {
if (!force_unload && _session && _session->dirty()) {
std::vector<std::string> actions;
actions.push_back (_("Don't close"));
if (_session->unnamed()) {

View File

@ -428,7 +428,7 @@ ARDOUR_UI::nsm_init ()
* The wrapper startup script should set the environment variable 'ARDOUR_SELF'
*/
const char *process_name = g_getenv ("ARDOUR_SELF");
nsm->announce (PROGRAM_NAME, ":dirty:", process_name ? process_name : "ardour6");
nsm->announce (PROGRAM_NAME, ":dirty:switch:", process_name ? process_name : "ardour7");
unsigned int i = 0;
// wait for announce reply from nsm server
@ -751,7 +751,9 @@ ARDOUR_UI::load_from_application_api (const std::string& path)
}
if (nsm) {
if (!AudioEngine::instance()->set_backend("JACK", "", "")) {
unload_session(false, true);
if (!AudioEngine::instance()->set_backend("JACK", ARDOUR_COMMAND_LINE::backend_client_name, "")) {
error << _("NSM: The JACK backend is mandatory and can not be loaded.") << endmsg;
return;
}
@ -775,10 +777,13 @@ ARDOUR_UI::load_from_application_api (const std::string& path)
}
}
PluginScanDialog psd (true, false);
psd.start ();
if (!nsm_first_session_opened) {
PluginScanDialog psd (true, false);
psd.start ();
post_engine ();
post_engine ();
nsm_first_session_opened = true;
}
}
/* the mechanisms that can result is this being called are only

View File

@ -50,6 +50,7 @@ NSM_Client::command_open(const char* name,
int r = ERR_OK;
ARDOUR_COMMAND_LINE::backend_client_name = client_id;
ARDOUR_COMMAND_LINE::session_name = "";
/* this appears asynchronous, but almost certainly is
* synchronous. However, there's no return value available.