summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/test/wavey/README.playlists84
1 files changed, 84 insertions, 0 deletions
diff --git a/firmware/test/wavey/README.playlists b/firmware/test/wavey/README.playlists
new file mode 100644
index 0000000000..fa28fd47a0
--- /dev/null
+++ b/firmware/test/wavey/README.playlists
@@ -0,0 +1,84 @@
1
2 Playlists on the Rockbox
3
41. Demand-loading of Playlist Filenames from Disk
5
6A playlist is simply a list of track names. These lists can either be
7created dynamically by the user, or they can be predefined and placed
8into a text file with an .m3u extension.
9
10The 2048 KB of RAM is the reason we need to get this right. If an average
11track name (i.e. \music\cure\disintegration\01-pictures_of_you.mp3)
12is assumed to be 50 characters long, then:
13
14A playlist of 15 tracks is 15 * 50 ~= 750 bytes
15A playlist of 100 tracks is 100 * 50 ~= 5 kilobytes
16A playlist of 3500 tracks is 3500 * 50 ~= 175 kilobytes
17A playlist of 10000 tracks is 10000 * 50 ~= 1/4 megabyte
18
19From these figures, it can be seen that for large playlists, storing
20the entire list of track names in memory significantly reduces the
21capacity available to the audio data buffer, which in turn has a negative
22impact on the performance of the system.
23
24One method of reducing the total memory consumption of a playlist is
25to delay bringing the actual filenames into memory until needed. Instead,
26the playlist text file can be scanned, and an in-memory array constructed
27with one element for each track present in the text file. Progressing
28through the playlist entails getting the appropriate entry from the array,
29and using that to perform a lookup of the corresponding filename entry
30from the playlist text file.
31
32With this method, and given that an integer on the Rockbox's CPU is 4 bytes:
33
34A playlist of 15 tracks is 15 * 4 ~= 60 bytes
35A playlist of 100 tracks is 100 * 4 ~= 400 bytes
36A playlist of 3500 tracks is 3500 * 4 ~= 13 kilobytes
37A playlist of 10000 tracks is 10000 * 4 ~= 39 kilobytes
38
39It is clear that these are substantial savings, albeit at the cost of
40increased complexity and disk i/o. Prefetch strategies could improve
41performance compared to demand-loading a single entry.
42
432. Implementation Options
44
45Keeping the track names in a file on disk is easy enough for a predefined
46m3u playlist, but for dynamically created playlists, where the user
47browses the filesystem and adds tracks or entire directory hierarchies
48at will, we will need to store the playlist track names in a dedicated
49file. This will be called the Anonymous Playlist, the location of which
50can be set by the user, but will default to \anonymous.m3u or somesuch.
51The current contents of the Anonymous Playlist can be named and saved at
52any time.
53
54The data structure to support playlists would therefore be:
55
56typedef struct
57{
58 char filename[256] ; /* path name of m3u playlist on disk */
59 int *indices; /* array of indices into the playlist */
60 int index; /* index of current track within playlist */
61} playlist_info_t;
62
63So far, so good: we read from an existing m3u file, or we create an
64anonymous one. But what do we do if we start with an existing m3u file,
65and then the user wants to dynamically add tracks to it? A few options
66exist:
67
68a) we disallow playlist modification of existing m3u files, offering
69 instead to replace the current playlist with the new one.
70
71b) we give the user the option of appending the new tracks to the
72 existing m3u file.
73
74c) we copy the contents of the existing m3u playlist to the anonymous one,
75 and then append the new tracks to that. If the m3u playlist is large,
76 this could be wasteful and potentially time-consuming. However, choosing
77 this option would provide the facility to insert or append entire
78 existing m3u playlists 'into' one another, a feature missng from the
79 commercial firmware.
80
81
82
83
84