daemon: handle jack server crashes and unexpected stops
This commit is contained in:
parent
8ea8035efb
commit
cb5a2ef522
|
@ -26,12 +26,14 @@
|
|||
|
||||
#include "cmd.h"
|
||||
#include "studio_internal.h"
|
||||
#include "loader.h"
|
||||
|
||||
#define cmd_ptr ((struct ladish_command *)context)
|
||||
|
||||
static bool run(void * context)
|
||||
{
|
||||
bool jack_server_started;
|
||||
unsigned int app_count;
|
||||
|
||||
switch (cmd_ptr->state)
|
||||
{
|
||||
|
@ -44,6 +46,15 @@ static bool run(void * context)
|
|||
return true;
|
||||
}
|
||||
|
||||
app_count = loader_get_app_count();
|
||||
if (app_count != 0)
|
||||
{
|
||||
log_error("Ignoring start request because there are apps running.");
|
||||
log_error("This could happen when JACK has crashed or when JACK stopped unexpectedly.");
|
||||
log_error("Save your work, then unload and reload the studio.");
|
||||
return false;
|
||||
}
|
||||
|
||||
log_info("Starting JACK server.");
|
||||
|
||||
ladish_graph_dump(g_studio.studio_graph);
|
||||
|
|
|
@ -115,20 +115,6 @@ void emit_studio_stopped()
|
|||
|
||||
void on_event_jack_started(void)
|
||||
{
|
||||
if (g_studio.dbus_object == NULL)
|
||||
{
|
||||
ASSERT(g_studio.name == NULL);
|
||||
if (!studio_name_generate(&g_studio.name))
|
||||
{
|
||||
log_error("studio_name_generate() failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
g_studio.automatic = true;
|
||||
|
||||
studio_publish();
|
||||
}
|
||||
|
||||
if (!studio_fetch_jack_settings())
|
||||
{
|
||||
log_error("studio_fetch_jack_settings() failed.");
|
||||
|
@ -183,7 +169,10 @@ void on_event_jack_stopped(void)
|
|||
graph_proxy_destroy(g_studio.jack_graph_proxy);
|
||||
g_studio.jack_graph_proxy = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void handle_unexpected_jack_server_stop(void)
|
||||
{
|
||||
/* TODO: if user wants, restart jack server and reconnect all jack apps to it */
|
||||
}
|
||||
|
||||
|
@ -203,15 +192,53 @@ void studio_run(void)
|
|||
|
||||
if (state)
|
||||
{
|
||||
/* Automatic studio creation on JACK server start */
|
||||
if (g_studio.dbus_object == NULL)
|
||||
{
|
||||
ASSERT(g_studio.name == NULL);
|
||||
if (!studio_name_generate(&g_studio.name))
|
||||
{
|
||||
log_error("studio_name_generate() failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
g_studio.automatic = true;
|
||||
|
||||
studio_publish();
|
||||
}
|
||||
|
||||
on_event_jack_started();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* JACK stopped but this was not expected. When expected.
|
||||
* the change will be consumed by the run method of the studio stop command */
|
||||
log_error("JACK stopped unexpectedly.");
|
||||
log_error("Save your work, then unload and reload the studio.");
|
||||
on_event_jack_stopped();
|
||||
handle_unexpected_jack_server_stop();
|
||||
}
|
||||
}
|
||||
|
||||
if (ladish_environment_consume_change(&g_studio.env_store, ladish_environment_jack_server_present, &state))
|
||||
{
|
||||
if (g_studio.jack_graph_proxy != NULL)
|
||||
{
|
||||
ladish_cqueue_clear(&g_studio.cmd_queue);
|
||||
|
||||
/* jack was started, this probably means that jackdbus has crashed */
|
||||
log_error("JACK disappeared unexpectedly. Maybe it crashed.");
|
||||
log_error("Save your work, then unload and reload the studio.");
|
||||
ladish_environment_reset_stealth(&g_studio.env_store, ladish_environment_jack_server_started);
|
||||
|
||||
ladish_graph_clear(g_studio.studio_graph, false);
|
||||
ladish_graph_clear(g_studio.jack_graph, true);
|
||||
|
||||
on_event_jack_stopped();
|
||||
handle_unexpected_jack_server_stop();
|
||||
}
|
||||
}
|
||||
|
||||
ladish_environment_ignore(&g_studio.env_store, ladish_environment_jack_server_present);
|
||||
ladish_environment_assert_consumed(&g_studio.env_store);
|
||||
}
|
||||
|
||||
|
@ -325,6 +352,9 @@ void studio_uninit(void)
|
|||
|
||||
ladish_cqueue_clear(&g_studio.cmd_queue);
|
||||
|
||||
ladish_graph_destroy(g_studio.studio_graph, false);
|
||||
ladish_graph_destroy(g_studio.jack_graph, false);
|
||||
|
||||
free(g_studios_dir);
|
||||
|
||||
log_info("studio object destroy");
|
||||
|
|
Loading…
Reference in New Issue