Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jackdbus: Stop recurrent wakeups when no save is pending #963

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions dbus/controller.c
Expand Up @@ -783,15 +783,15 @@ jack_controller_destroy(
free(controller_ptr);
}

void
bool
jack_controller_run(
void * context)
{
long ut;

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

if ((ut = uptime()) < 0)
Expand All @@ -800,11 +800,12 @@ jack_controller_run(
}
else if (ut < controller_ptr->pending_save + 2) /* delay save by two seconds */
{
return;
return true;
}

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

#undef controller_ptr
Expand Down
4 changes: 3 additions & 1 deletion dbus/controller.h
Expand Up @@ -20,11 +20,13 @@
#ifndef CONTROLLER_H__2CC80B1E_8D5D_45E3_A9D8_9086DDF68BB5__INCLUDED
#define CONTROLLER_H__2CC80B1E_8D5D_45E3_A9D8_9086DDF68BB5__INCLUDED

#include <stdbool.h>

void *
jack_controller_create(
DBusConnection *connection);

void
bool
jack_controller_run(
void *controller_ptr);

Expand Down
6 changes: 4 additions & 2 deletions dbus/jackdbus.c
Expand Up @@ -854,6 +854,7 @@ main (int argc, char **argv)
void *controller_ptr;
struct stat st;
char timestamp_str[26];
bool save_pending;

st.st_mtime = 0;
stat(argv[0], &st);
Expand Down Expand Up @@ -947,9 +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))
save_pending = false;
while (!g_exit_command && dbus_connection_read_write_dispatch (g_connection, (save_pending ? 200 : -1)))
{
jack_controller_run(controller_ptr);
save_pending = jack_controller_run(controller_ptr);
}

jack_controller_destroy(controller_ptr);
Expand Down