summaryrefslogtreecommitdiff
path: root/apps/playlist.h
diff options
context:
space:
mode:
authorHardeep Sidhu <dyp@pobox.com>2006-02-05 18:17:41 +0000
committerHardeep Sidhu <dyp@pobox.com>2006-02-05 18:17:41 +0000
commit75a60fbf69fb7d7be5839b35efc8253d682a1c7d (patch)
tree219ce4485e7128232090e3cbcdd357addbf09481 /apps/playlist.h
parent987879b958f87a9af7ef9edcf6ae417fe56db788 (diff)
downloadrockbox-75a60fbf69fb7d7be5839b35efc8253d682a1c7d.tar.gz
rockbox-75a60fbf69fb7d7be5839b35efc8253d682a1c7d.zip
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
Diffstat (limited to 'apps/playlist.h')
-rw-r--r--apps/playlist.h66
1 files changed, 46 insertions, 20 deletions
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 @@
25#include "kernel.h" 25#include "kernel.h"
26#include "id3.h" 26#include "id3.h"
27 27
28/* playlist data */ 28#define PLAYLIST_ATTR_QUEUED 0x01
29#define PLAYLIST_ATTR_INSERTED 0x02
30#define PLAYLIST_ATTR_SKIPPED 0x04
31#define PLAYLIST_MAX_CACHE 16
32
33#define DEFAULT_DYNAMIC_PLAYLIST_NAME "/dynamic.m3u"
34
35enum playlist_command {
36 PLAYLIST_COMMAND_PLAYLIST,
37 PLAYLIST_COMMAND_ADD,
38 PLAYLIST_COMMAND_QUEUE,
39 PLAYLIST_COMMAND_DELETE,
40 PLAYLIST_COMMAND_SHUFFLE,
41 PLAYLIST_COMMAND_UNSHUFFLE,
42 PLAYLIST_COMMAND_RESET,
43 PLAYLIST_COMMAND_COMMENT
44};
45
46enum {
47 PLAYLIST_PREPEND = -1,
48 PLAYLIST_INSERT = -2,
49 PLAYLIST_INSERT_LAST = -3,
50 PLAYLIST_INSERT_FIRST = -4,
51 PLAYLIST_INSERT_SHUFFLED = -5
52};
53
54enum {
55 PLAYLIST_DELETE_CURRENT = -1
56};
57
58struct playlist_control_cache {
59 enum playlist_command command;
60 int i1;
61 int i2;
62 const char* s1;
63 const char* s2;
64 void* data;
65};
29 66
30struct playlist_info 67struct playlist_info
31{ 68{
@@ -53,15 +90,15 @@ struct playlist_info
53 inserted tracks? */ 90 inserted tracks? */
54 bool deleted; /* have any tracks been deleted? */ 91 bool deleted; /* have any tracks been deleted? */
55 int num_inserted_tracks; /* number of tracks inserted */ 92 int num_inserted_tracks; /* number of tracks inserted */
56 bool shuffle_flush; /* does shuffle value need to be flushed? */
57 struct mutex control_mutex; /* mutex for control file access */
58};
59 93
60#define PLAYLIST_ATTR_QUEUED 0x01 94 /* cache of playlist control commands waiting to be flushed to
61#define PLAYLIST_ATTR_INSERTED 0x02 95 to disk */
62#define PLAYLIST_ATTR_SKIPPED 0x04 96 struct playlist_control_cache control_cache[PLAYLIST_MAX_CACHE];
97 int num_cached; /* number of cached entries */
98 bool pending_control_sync; /* control file needs to be synced */
63 99
64#define DEFAULT_DYNAMIC_PLAYLIST_NAME "/dynamic.m3u" 100 struct mutex control_mutex; /* mutex for control file access */
101};
65 102
66struct playlist_track_info 103struct playlist_track_info
67{ 104{
@@ -73,6 +110,7 @@ struct playlist_track_info
73 110
74/* Exported functions only for current playlist. */ 111/* Exported functions only for current playlist. */
75void playlist_init(void); 112void playlist_init(void);
113void playlist_shutdown(void);
76int playlist_create(const char *dir, const char *file); 114int playlist_create(const char *dir, const char *file);
77int playlist_resume(void); 115int playlist_resume(void);
78int playlist_add(const char *filename); 116int playlist_add(const char *filename);
@@ -120,16 +158,4 @@ int playlist_get_track_info(struct playlist_info* playlist, int index,
120 struct playlist_track_info* info); 158 struct playlist_track_info* info);
121int playlist_save(struct playlist_info* playlist, char *filename); 159int playlist_save(struct playlist_info* playlist, char *filename);
122 160
123enum {
124 PLAYLIST_PREPEND = -1,
125 PLAYLIST_INSERT = -2,
126 PLAYLIST_INSERT_LAST = -3,
127 PLAYLIST_INSERT_FIRST = -4,
128 PLAYLIST_INSERT_SHUFFLED = -5
129};
130
131enum {
132 PLAYLIST_DELETE_CURRENT = -1
133};
134
135#endif /* __PLAYLIST_H__ */ 161#endif /* __PLAYLIST_H__ */