From 75a60fbf69fb7d7be5839b35efc8253d682a1c7d Mon Sep 17 00:00:00 2001 From: Hardeep Sidhu Date: Sun, 5 Feb 2006 18:17:41 +0000 Subject: Added a cache for playlist control commands. On non-dircache systems, behaviour should be the same as before (all commands except shuffle flushed immediately). On dircache systems, commands are only flushed when disk is accessed or during shutdown. This especially reduces disk accesses when playing queued files and should fix the problem with gapless playback. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8584 a1c6a512-1295-4272-9138-f99709370657 --- apps/playlist.h | 66 ++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 20 deletions(-) (limited to 'apps/playlist.h') diff --git a/apps/playlist.h b/apps/playlist.h index 286823e0cf..3aa5406a51 100644 --- a/apps/playlist.h +++ b/apps/playlist.h @@ -25,7 +25,44 @@ #include "kernel.h" #include "id3.h" -/* playlist data */ +#define PLAYLIST_ATTR_QUEUED 0x01 +#define PLAYLIST_ATTR_INSERTED 0x02 +#define PLAYLIST_ATTR_SKIPPED 0x04 +#define PLAYLIST_MAX_CACHE 16 + +#define DEFAULT_DYNAMIC_PLAYLIST_NAME "/dynamic.m3u" + +enum playlist_command { + PLAYLIST_COMMAND_PLAYLIST, + PLAYLIST_COMMAND_ADD, + PLAYLIST_COMMAND_QUEUE, + PLAYLIST_COMMAND_DELETE, + PLAYLIST_COMMAND_SHUFFLE, + PLAYLIST_COMMAND_UNSHUFFLE, + PLAYLIST_COMMAND_RESET, + PLAYLIST_COMMAND_COMMENT +}; + +enum { + PLAYLIST_PREPEND = -1, + PLAYLIST_INSERT = -2, + PLAYLIST_INSERT_LAST = -3, + PLAYLIST_INSERT_FIRST = -4, + PLAYLIST_INSERT_SHUFFLED = -5 +}; + +enum { + PLAYLIST_DELETE_CURRENT = -1 +}; + +struct playlist_control_cache { + enum playlist_command command; + int i1; + int i2; + const char* s1; + const char* s2; + void* data; +}; struct playlist_info { @@ -53,15 +90,15 @@ struct playlist_info inserted tracks? */ bool deleted; /* have any tracks been deleted? */ int num_inserted_tracks; /* number of tracks inserted */ - bool shuffle_flush; /* does shuffle value need to be flushed? */ - struct mutex control_mutex; /* mutex for control file access */ -}; -#define PLAYLIST_ATTR_QUEUED 0x01 -#define PLAYLIST_ATTR_INSERTED 0x02 -#define PLAYLIST_ATTR_SKIPPED 0x04 + /* cache of playlist control commands waiting to be flushed to + to disk */ + struct playlist_control_cache control_cache[PLAYLIST_MAX_CACHE]; + int num_cached; /* number of cached entries */ + bool pending_control_sync; /* control file needs to be synced */ -#define DEFAULT_DYNAMIC_PLAYLIST_NAME "/dynamic.m3u" + struct mutex control_mutex; /* mutex for control file access */ +}; struct playlist_track_info { @@ -73,6 +110,7 @@ struct playlist_track_info /* Exported functions only for current playlist. */ void playlist_init(void); +void playlist_shutdown(void); int playlist_create(const char *dir, const char *file); int playlist_resume(void); int playlist_add(const char *filename); @@ -120,16 +158,4 @@ int playlist_get_track_info(struct playlist_info* playlist, int index, struct playlist_track_info* info); int playlist_save(struct playlist_info* playlist, char *filename); -enum { - PLAYLIST_PREPEND = -1, - PLAYLIST_INSERT = -2, - PLAYLIST_INSERT_LAST = -3, - PLAYLIST_INSERT_FIRST = -4, - PLAYLIST_INSERT_SHUFFLED = -5 -}; - -enum { - PLAYLIST_DELETE_CURRENT = -1 -}; - #endif /* __PLAYLIST_H__ */ -- cgit v1.2.3