diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-09-18 04:29:53 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-09-18 04:29:53 -0700 |
commit | 71ac281579c8b8b384cfc09d8627b549b1854fcd (patch) | |
tree | b501975bac64ac2cb1be1e30860302ccb3eda67e /src/playlist.c | |
parent | ba4f62f7d241e2837111102a4dda0c917d544c99 (diff) | |
download | mpd-71ac281579c8b8b384cfc09d8627b549b1854fcd.tar.gz mpd-71ac281579c8b8b384cfc09d8627b549b1854fcd.tar.xz mpd-71ac281579c8b8b384cfc09d8627b549b1854fcd.zip |
Move away from fprintf() when writing DB/state_file
I have serious trust issues when using stdio to write to the FS.
So it's best to clean this code out so I can start figuring out
what's wrong with Rasi's box not updating...
None of these writes take place in a performance-critical
setting anyways...
Diffstat (limited to '')
-rw-r--r-- | src/playlist.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/playlist.c b/src/playlist.c index ca79393b0..e62e71583 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -254,35 +254,35 @@ void showPlaylist(int fd) } } -void savePlaylistState(FILE *fp) +void savePlaylistState(int fd) { - fprintf(fp, "%s", PLAYLIST_STATE_FILE_STATE); + fdprintf(fd, PLAYLIST_STATE_FILE_STATE); switch (playlist_state) { case PLAYLIST_STATE_PLAY: switch (ob_get_state()) { case OB_STATE_PAUSE: - fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_STATE_PAUSE); + fdprintf(fd, PLAYLIST_STATE_FILE_STATE_PAUSE "\n"); break; default: - fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_STATE_PLAY); + fdprintf(fd, PLAYLIST_STATE_FILE_STATE_PLAY "\n"); } - fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CURRENT, - playlist.order[playlist.current]); - fprintf(fp, "%s%lu\n", PLAYLIST_STATE_FILE_TIME, - ob_get_elapsed_time()); + fdprintf(fd, PLAYLIST_STATE_FILE_CURRENT "%i\n" + PLAYLIST_STATE_FILE_TIME "%lu\n", + playlist.order[playlist.current], + ob_get_elapsed_time()); break; default: - fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_STATE_STOP); + fdprintf(fd, PLAYLIST_STATE_FILE_STATE_STOP "\n"); break; } - fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_RANDOM, playlist.random); - fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_REPEAT, playlist.repeat); - fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CROSSFADE, - (int)(ob_get_xfade())); - fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_BEGIN); - fflush(fp); - showPlaylist(fileno(fp)); - fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_END); + fdprintf(fd, + PLAYLIST_STATE_FILE_RANDOM "%i\n" + PLAYLIST_STATE_FILE_REPEAT "%i\n" + PLAYLIST_STATE_FILE_CROSSFADE "%i\n" + PLAYLIST_STATE_FILE_PLAYLIST_BEGIN "\n", + playlist.random, playlist.repeat, (int)(ob_get_xfade())); + showPlaylist(fd); + fdprintf(fd, PLAYLIST_STATE_FILE_PLAYLIST_END "\n"); } static void loadPlaylistFromStateFile(FILE *fp, char *buffer, |