aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-07-14 21:15:12 +0200
committerMax Kellermann <max@duempel.org>2009-07-14 21:15:12 +0200
commit9206f549798ee68d1768f418405bbb8b041b71ee (patch)
treec57914477213e723252b8290c03f3d9f9bb8ae55
parent75c0a33ec5fcce72358c1d5625885890114d1889 (diff)
downloadmpd-9206f549798ee68d1768f418405bbb8b041b71ee.tar.gz
mpd-9206f549798ee68d1768f418405bbb8b041b71ee.tar.xz
mpd-9206f549798ee68d1768f418405bbb8b041b71ee.zip
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.
Diffstat (limited to '')
-rw-r--r--src/state_file.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/src/state_file.c b/src/state_file.c
index 9c6475cc8..8080f80fc 100644
--- a/src/state_file.c
+++ b/src/state_file.c
@@ -30,15 +30,6 @@
#undef G_LOG_DOMAIN
#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;
/** the GLib source id for the save timer */
@@ -47,7 +38,6 @@ static guint save_state_source_id;
static void
state_file_write(void)
{
- unsigned int i;
FILE *fp;
if (state_file_path == NULL)
@@ -60,8 +50,9 @@ state_file_write(void)
return;
}
- for (i = 0; i < G_N_ELEMENTS(sf_callbacks); i++)
- sf_callbacks[i].writer(fp);
+ save_sw_volume_state(fp);
+ saveAudioDevicesState(fp);
+ savePlaylistState(fp);
while(fclose(fp) && errno == EINTR) /* nothing */;
}
@@ -69,7 +60,6 @@ state_file_write(void)
static void
state_file_read(void)
{
- unsigned int i;
FILE *fp;
assert(state_file_path != NULL);
@@ -82,10 +72,12 @@ state_file_read(void)
state_file_path, strerror(errno));
return;
}
- for (i = 0; i < G_N_ELEMENTS(sf_callbacks); i++) {
- sf_callbacks[i].reader(fp);
- rewind(fp);
- }
+
+ read_sw_volume_state(fp);
+ rewind(fp);
+ readAudioDevicesState(fp);
+ rewind(fp);
+ readPlaylistState(fp);
while(fclose(fp) && errno == EINTR) /* nothing */;
}