diff --git a/dbus/controller.c b/dbus/controller.c index 033fb65e..ce0f1ec9 100644 --- a/dbus/controller.c +++ b/dbus/controller.c @@ -330,15 +330,17 @@ jack_controller_switch_master( struct jack_controller * controller_ptr, void *dbus_call_context_ptr) { + assert(controller_ptr->started); /* should be ensured by caller */ + if (!jackctl_server_switch_master( controller_ptr->server, jack_params_get_driver(controller_ptr->params))) { jack_dbus_error(dbus_call_context_ptr, JACK_DBUS_ERROR_GENERIC, "Failed to switch master"); + controller_ptr->started = false; return FALSE; } - return TRUE; } @@ -390,10 +392,10 @@ on_device_release(const char * device_name) // Look for corresponding reserved device for (i = 0; i < DEVICE_MAX; i++) { - if (strcmp(g_reserved_device[i].device_name, device_name) == 0) + if (strcmp(g_reserved_device[i].device_name, device_name) == 0) break; } - + if (i < DEVICE_MAX) { jack_info("Released audio card %s", device_name); rd_release(g_reserved_device[i].reserved_device); diff --git a/dbus/controller_iface_control.c b/dbus/controller_iface_control.c index a82cbcd7..c1e18956 100644 --- a/dbus/controller_iface_control.c +++ b/dbus/controller_iface_control.c @@ -122,11 +122,18 @@ jack_control_run_method( } else if (strcmp (call->method_name, "SwitchMaster") == 0) { - if (!jack_controller_switch_master(controller_ptr, call)) + if (!controller_ptr->started) { - /* the reply is set by the failed function */ - assert(call->reply != NULL); - return true; + goto not_started; + } + else + { + if (!jack_controller_switch_master(controller_ptr, call)) + { + /* the reply is set by the failed function */ + assert(call->reply != NULL); + return true; + } } } else if (strcmp (call->method_name, "GetLoad") == 0) @@ -220,7 +227,7 @@ jack_control_run_method( */ goto exit; } - + if (!jack_controller_load_internal(controller_ptr, internal_name)) { jack_dbus_error( call, @@ -244,7 +251,7 @@ jack_control_run_method( */ goto exit; } - + if (!jack_controller_add_slave_driver(controller_ptr, driver_name)) { jack_dbus_error( @@ -273,7 +280,7 @@ jack_control_run_method( */ goto exit; } - + if (!jack_controller_remove_slave_driver(controller_ptr, driver_name)) { jack_dbus_error( @@ -297,7 +304,7 @@ jack_control_run_method( */ goto exit; } - + if (!jack_controller_unload_internal(controller_ptr, internal_name)) { jack_dbus_error( call,