playlist: added playlist_save()
The shared code in showPlaylist() isn't worth it, because we aim to remove fdprintf(). Duplicate this small function, and enable stdio buffering for saved playlists.
This commit is contained in:
parent
438b56f0ba
commit
709ec6fa39
@ -229,6 +229,16 @@ void showPlaylist(int fd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void playlist_save(FILE *fp)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
char path_max_tmp[MPD_PATH_MAX];
|
||||||
|
|
||||||
|
for (i = 0; i < playlist.length; i++)
|
||||||
|
fprintf(fp, "%i:%s\n", i,
|
||||||
|
get_song_url(path_max_tmp, playlist.songs[i]));
|
||||||
|
}
|
||||||
|
|
||||||
void savePlaylistState(FILE *fp)
|
void savePlaylistState(FILE *fp)
|
||||||
{
|
{
|
||||||
fprintf(fp, "%s", PLAYLIST_STATE_FILE_STATE);
|
fprintf(fp, "%s", PLAYLIST_STATE_FILE_STATE);
|
||||||
@ -255,8 +265,7 @@ void savePlaylistState(FILE *fp)
|
|||||||
fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CROSSFADE,
|
fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CROSSFADE,
|
||||||
(int)(getPlayerCrossFade()));
|
(int)(getPlayerCrossFade()));
|
||||||
fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_BEGIN);
|
fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_BEGIN);
|
||||||
fflush(fp);
|
playlist_save(fp);
|
||||||
showPlaylist(fileno(fp));
|
|
||||||
fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_END);
|
fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_PLAYLIST_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user