mpd/src/SongSave.hxx
datasone d4f3dd49b4 db/SimpleDatabasePlugin: store in_playlist value of songs into database
Fixes hide_playlist_targets not working after server restart

Currently, `hide_playlists_targets` works by skipping songs with
`in_playlist` value set to true in
[`Directory::Walk`](a57bcd0238/src/db/plugins/simple/Directory.cxx (L237)). But
`in_playlist` is not stored and only updated in
[`UpdateWalk::PurgeDanglingFromPlaylists`](a57bcd0238/src/db/update/Playlist.cxx (L139)),
which will only be executed while updating DB.

This causes the problem that playlist target songs are correctly
hidden after database update, but will remain visible after mpd server
restarted. This pr solves the problem by storing `in_playlist` value
of songs into the `SimpleDatabase` file.
2023-05-21 20:51:47 +02:00

34 lines
671 B
C++

// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright The Music Player Daemon Project
#ifndef MPD_SONG_SAVE_HXX
#define MPD_SONG_SAVE_HXX
#include <memory>
#define SONG_BEGIN "song_begin: "
struct Song;
struct AudioFormat;
class DetachedSong;
class BufferedOutputStream;
class LineReader;
void
song_save(BufferedOutputStream &os, const Song &song);
void
song_save(BufferedOutputStream &os, const DetachedSong &song);
/**
* Loads a song from the input file. Reading stops after the
* "song_end" line.
*
* Throws on error.
*/
DetachedSong
song_load(LineReader &file, const char *uri,
std::string *target_r=nullptr, bool *in_playlist_r=nullptr);
#endif