From 7ccbd705f43553ff358d6713c8d6ac7cc9e3c343 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Wed, 29 Mar 2023 10:58:30 +0100 Subject: playlist: Rework playlist modified detection and dirplay The modified state is now an explicit flag that has to be set whenever a user-triggered modification occurs. This is recorded in the control file to ensure it doesn't get lost after resume. There may be some places I missed where the modified flag should be set/cleared, but it seems to work well enough right now. Change-Id: I3bdba358fc495b4ca84e389ac6e7bcbef820c219 --- apps/playlist.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'apps/playlist.h') diff --git a/apps/playlist.h b/apps/playlist.h index 6d86270bc4..4c8800e594 100644 --- a/apps/playlist.h +++ b/apps/playlist.h @@ -38,6 +38,9 @@ #define DEFAULT_DYNAMIC_PLAYLIST_NAME "/dynamic.m3u8" +#define PLAYLIST_FLAG_MODIFIED (1u << 0) /* playlist was manually modified */ +#define PLAYLIST_FLAG_DIRPLAY (1u << 1) /* enable directory skipping */ + enum playlist_command { PLAYLIST_COMMAND_PLAYLIST, PLAYLIST_COMMAND_ADD, @@ -47,6 +50,7 @@ enum playlist_command { PLAYLIST_COMMAND_UNSHUFFLE, PLAYLIST_COMMAND_RESET, PLAYLIST_COMMAND_CLEAR, + PLAYLIST_COMMAND_FLAGS, PLAYLIST_COMMAND_COMMENT }; @@ -64,8 +68,7 @@ struct playlist_info { bool utf8; /* playlist is in .m3u8 format */ bool control_created; /* has control file been created? */ - bool modified; /* has playlist been modified by the user? */ - bool dirplay; /* are we playing a directory directly? */ + unsigned int flags; /* flags for misc. state */ int fd; /* descriptor of the open playlist file */ int control_fd; /* descriptor of the open control file */ int max_playlist_size; /* Max number of files in playlist. Mirror of @@ -161,6 +164,7 @@ int playlist_randomise(struct playlist_info* playlist, unsigned int seed, int playlist_sort(struct playlist_info* playlist, bool start_current); bool playlist_modified(const struct playlist_info* playlist); void playlist_set_modified(struct playlist_info* playlist, bool modified); +bool playlist_allow_dirplay(const struct playlist_info* playlist); int playlist_get_first_index(const struct playlist_info* playlist); int playlist_get_seed(const struct playlist_info* playlist); int playlist_amount_ex(const struct playlist_info* playlist); -- cgit v1.2.3