diff options
author | Max Kellermann <max@duempel.org> | 2014-07-30 20:58:14 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-07-30 22:17:01 +0200 |
commit | 9fb351a139a56fc7b1ece549894f8fc31fa887cd (patch) | |
tree | 7c9ce42a1262af587f1b9fede2b24ff39cef93fc /src/queue/PlaylistState.cxx | |
parent | 0d0ccacdf3e154b1cc27a0840fce80ac13f9641c (diff) | |
download | mpd-9fb351a139a56fc7b1ece549894f8fc31fa887cd.tar.gz mpd-9fb351a139a56fc7b1ece549894f8fc31fa887cd.tar.xz mpd-9fb351a139a56fc7b1ece549894f8fc31fa887cd.zip |
*Save, *State: use the OutputStream API instead of FILE*
Diffstat (limited to 'src/queue/PlaylistState.cxx')
-rw-r--r-- | src/queue/PlaylistState.cxx | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/src/queue/PlaylistState.cxx b/src/queue/PlaylistState.cxx index f5c798e3e..56adb2a9b 100644 --- a/src/queue/PlaylistState.cxx +++ b/src/queue/PlaylistState.cxx @@ -28,6 +28,7 @@ #include "Playlist.hxx" #include "queue/QueueSave.hxx" #include "fs/TextFile.hxx" +#include "fs/output/BufferedOutputStream.hxx" #include "PlayerControl.hxx" #include "config/ConfigGlobal.hxx" #include "config/ConfigOption.hxx" @@ -59,47 +60,45 @@ #define PLAYLIST_BUFFER_SIZE 2*MPD_PATH_MAX void -playlist_state_save(FILE *fp, const struct playlist &playlist, +playlist_state_save(BufferedOutputStream &os, const struct playlist &playlist, PlayerControl &pc) { const auto player_status = pc.GetStatus(); - fputs(PLAYLIST_STATE_FILE_STATE, fp); + os.Write(PLAYLIST_STATE_FILE_STATE); if (playlist.playing) { switch (player_status.state) { case PlayerState::PAUSE: - fputs(PLAYLIST_STATE_FILE_STATE_PAUSE "\n", fp); + os.Write(PLAYLIST_STATE_FILE_STATE_PAUSE "\n"); break; default: - fputs(PLAYLIST_STATE_FILE_STATE_PLAY "\n", fp); + os.Write(PLAYLIST_STATE_FILE_STATE_PLAY "\n"); } - fprintf(fp, PLAYLIST_STATE_FILE_CURRENT "%i\n", - playlist.queue.OrderToPosition(playlist.current)); - fprintf(fp, PLAYLIST_STATE_FILE_TIME "%i\n", - (int)player_status.elapsed_time); + os.Format(PLAYLIST_STATE_FILE_CURRENT "%i\n", + playlist.queue.OrderToPosition(playlist.current)); + os.Format(PLAYLIST_STATE_FILE_TIME "%i\n", + (int)player_status.elapsed_time); } else { - fputs(PLAYLIST_STATE_FILE_STATE_STOP "\n", fp); + os.Write(PLAYLIST_STATE_FILE_STATE_STOP "\n"); if (playlist.current >= 0) - fprintf(fp, PLAYLIST_STATE_FILE_CURRENT "%i\n", + os.Format(PLAYLIST_STATE_FILE_CURRENT "%i\n", playlist.queue.OrderToPosition(playlist.current)); } - fprintf(fp, PLAYLIST_STATE_FILE_RANDOM "%i\n", playlist.queue.random); - fprintf(fp, PLAYLIST_STATE_FILE_REPEAT "%i\n", playlist.queue.repeat); - fprintf(fp, PLAYLIST_STATE_FILE_SINGLE "%i\n", playlist.queue.single); - fprintf(fp, PLAYLIST_STATE_FILE_CONSUME "%i\n", - playlist.queue.consume); - fprintf(fp, PLAYLIST_STATE_FILE_CROSSFADE "%i\n", - (int)pc.GetCrossFade()); - fprintf(fp, PLAYLIST_STATE_FILE_MIXRAMPDB "%f\n", - pc.GetMixRampDb()); - fprintf(fp, PLAYLIST_STATE_FILE_MIXRAMPDELAY "%f\n", - pc.GetMixRampDelay()); - fputs(PLAYLIST_STATE_FILE_PLAYLIST_BEGIN "\n", fp); - queue_save(fp, playlist.queue); - fputs(PLAYLIST_STATE_FILE_PLAYLIST_END "\n", fp); + os.Format(PLAYLIST_STATE_FILE_RANDOM "%i\n", playlist.queue.random); + os.Format(PLAYLIST_STATE_FILE_REPEAT "%i\n", playlist.queue.repeat); + os.Format(PLAYLIST_STATE_FILE_SINGLE "%i\n", playlist.queue.single); + os.Format(PLAYLIST_STATE_FILE_CONSUME "%i\n", playlist.queue.consume); + os.Format(PLAYLIST_STATE_FILE_CROSSFADE "%i\n", + (int)pc.GetCrossFade()); + os.Format(PLAYLIST_STATE_FILE_MIXRAMPDB "%f\n", pc.GetMixRampDb()); + os.Format(PLAYLIST_STATE_FILE_MIXRAMPDELAY "%f\n", + pc.GetMixRampDelay()); + os.Write(PLAYLIST_STATE_FILE_PLAYLIST_BEGIN "\n"); + queue_save(os, playlist.queue); + os.Write(PLAYLIST_STATE_FILE_PLAYLIST_END "\n"); } static void |