Commit 9206f549 authored by Max Kellermann's avatar Max Kellermann

state_file: eliminated the sf_callbacks array

There are very few callbacks, and they are not meant to be pluggable. Let's eliminate the array and call the load/save functions manually.
parent 75c0a33e
...@@ -30,15 +30,6 @@ ...@@ -30,15 +30,6 @@
#undef G_LOG_DOMAIN #undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "state_file" #define G_LOG_DOMAIN "state_file"
static struct _sf_cb {
void (*reader)(FILE *);
void (*writer)(FILE *);
} sf_callbacks [] = {
{ read_sw_volume_state, save_sw_volume_state },
{ readAudioDevicesState, saveAudioDevicesState },
{ readPlaylistState, savePlaylistState },
};
static char *state_file_path; static char *state_file_path;
/** the GLib source id for the save timer */ /** the GLib source id for the save timer */
...@@ -47,7 +38,6 @@ static guint save_state_source_id; ...@@ -47,7 +38,6 @@ static guint save_state_source_id;
static void static void
state_file_write(void) state_file_write(void)
{ {
unsigned int i;
FILE *fp; FILE *fp;
if (state_file_path == NULL) if (state_file_path == NULL)
...@@ -60,8 +50,9 @@ state_file_write(void) ...@@ -60,8 +50,9 @@ state_file_write(void)
return; return;
} }
for (i = 0; i < G_N_ELEMENTS(sf_callbacks); i++) save_sw_volume_state(fp);
sf_callbacks[i].writer(fp); saveAudioDevicesState(fp);
savePlaylistState(fp);
while(fclose(fp) && errno == EINTR) /* nothing */; while(fclose(fp) && errno == EINTR) /* nothing */;
} }
...@@ -69,7 +60,6 @@ state_file_write(void) ...@@ -69,7 +60,6 @@ state_file_write(void)
static void static void
state_file_read(void) state_file_read(void)
{ {
unsigned int i;
FILE *fp; FILE *fp;
assert(state_file_path != NULL); assert(state_file_path != NULL);
...@@ -82,10 +72,12 @@ state_file_read(void) ...@@ -82,10 +72,12 @@ state_file_read(void)
state_file_path, strerror(errno)); state_file_path, strerror(errno));
return; return;
} }
for (i = 0; i < G_N_ELEMENTS(sf_callbacks); i++) {
sf_callbacks[i].reader(fp); read_sw_volume_state(fp);
rewind(fp); rewind(fp);
} readAudioDevicesState(fp);
rewind(fp);
readPlaylistState(fp);
while(fclose(fp) && errno == EINTR) /* nothing */; while(fclose(fp) && errno == EINTR) /* nothing */;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment