Browse Source

jackdbus: group batch of saves into one

When a parameter is set, jackdbus used to save immediately.
This was quite annoying and ineffective when configuring
lot of parameters without delay. It caused log line to appear
for each parameter set and xml file serialization as well.

This changeset implements delayed save. Parameters are saved
two seconds after last parameter set.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4583 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/1.9.8
nedko 12 years ago
parent
commit
7bbe5971bf
6 changed files with 64 additions and 5 deletions
  1. +46
    -0
      dbus/controller.c
  2. +4
    -0
      dbus/controller.h
  3. +2
    -2
      dbus/controller_iface_configure.c
  4. +2
    -2
      dbus/controller_iface_control.c
  5. +6
    -0
      dbus/controller_internal.h
  6. +4
    -1
      dbus/jackdbus.c

+ 46
- 0
dbus/controller.c View File

@@ -27,6 +27,8 @@
#include <dbus/dbus.h>
#include <assert.h>
#include <unistd.h>
#include <sys/sysinfo.h>
#include <errno.h>

#include "controller.h"
#include "controller_internal.h"
@@ -560,6 +562,8 @@ jack_controller_create(
controller_ptr->client = NULL;
controller_ptr->started = false;

controller_ptr->pending_save = 0;

INIT_LIST_HEAD(&controller_ptr->slave_drivers);
controller_ptr->slave_drivers_set = false;
controller_ptr->slave_drivers_vparam_value.str[0] = 0;
@@ -776,3 +780,45 @@ jack_controller_destroy(
free(controller_ptr);
}

void
jack_controller_run(
void * context)
{
struct sysinfo si;

if (controller_ptr->pending_save == 0)
{
return;
}

if (sysinfo(&si) != 0)
{
jack_error("sysinfo() failed with %d", errno);
}
else if (si.uptime < controller_ptr->pending_save + 2) /* delay save by two seconds */
{
return;
}

controller_ptr->pending_save = 0;
jack_controller_settings_save_auto(controller_ptr);
}

#undef controller_ptr

void
jack_controller_pending_save(
struct jack_controller * controller_ptr)
{
struct sysinfo si;

if (sysinfo(&si) != 0)
{
jack_error("sysinfo() failed with %d.", errno);
controller_ptr->pending_save = 0;
jack_controller_settings_save_auto(controller_ptr);
return;
}

controller_ptr->pending_save = si.uptime;
}

+ 4
- 0
dbus/controller.h View File

@@ -24,6 +24,10 @@ void *
jack_controller_create(
DBusConnection *connection);

void
jack_controller_run(
void *controller_ptr);

void
jack_controller_destroy(
void *controller_ptr);


+ 2
- 2
dbus/controller_iface_configure.c View File

@@ -903,7 +903,7 @@ jack_controller_dbus_set_parameter_value(

param_ptr->vtable.set_value(param_ptr->obj, &value);

jack_controller_settings_save_auto(controller_ptr);
jack_controller_pending_save(controller_ptr);

jack_dbus_construct_method_return_empty(call);

@@ -945,7 +945,7 @@ jack_controller_dbus_reset_parameter_value(

param_ptr->vtable.reset(param_ptr->obj);

jack_controller_settings_save_auto(controller_ptr);
jack_controller_pending_save(controller_ptr);

jack_dbus_construct_method_return_empty(call);
}


+ 2
- 2
dbus/controller_iface_control.c View File

@@ -261,7 +261,7 @@ jack_control_run_method(
}
else
{
jack_controller_settings_save_auto(controller_ptr);
jack_controller_pending_save(controller_ptr);
}
}
else if (strcmp (call->method_name, "RemoveSlaveDriver") == 0)
@@ -290,7 +290,7 @@ jack_control_run_method(
}
else
{
jack_controller_settings_save_auto(controller_ptr);
jack_controller_pending_save(controller_ptr);
}
}
else if (strcmp (call->method_name, "UnloadInternal") == 0)


+ 6
- 0
dbus/controller_internal.h View File

@@ -68,6 +68,8 @@ struct jack_controller

pthread_mutex_t lock;
struct list_head session_pending_commands;

long pending_save; /* uptime seconds */
};

#define DEFAULT_DRIVER "dummy"
@@ -77,6 +79,10 @@ struct jack_controller
"You probably don't want to edit this because\n" \
"it will be overwritten next time jackdbus saves.\n"

void
jack_controller_pending_save(
struct jack_controller *controller_ptr);

bool
jack_controller_start_server(
struct jack_controller *controller_ptr,


+ 4
- 1
dbus/jackdbus.c View File

@@ -948,7 +948,10 @@ main (int argc, char **argv)
jack_info("Listening for D-Bus messages");

g_exit_command = FALSE;
while (!g_exit_command && dbus_connection_read_write_dispatch (g_connection, 200));
while (!g_exit_command && dbus_connection_read_write_dispatch (g_connection, 200))
{
jack_controller_run(controller_ptr);
}

jack_controller_destroy(controller_ptr);



Loading…
Cancel
Save