summaryrefslogtreecommitdiffstats
path: root/apps/playlist.c
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2020-05-19 01:20:39 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2020-05-20 18:41:58 +0200
commit776ceae1198207e639408a8d0fa404f6a1ff7976 (patch)
treec5bde6aa64994e603bebe5c4709937d409c0fd7a /apps/playlist.c
parent0c3380f9efbbcfc3dfdb2551fa51458f7edc5a5c (diff)
downloadrockbox-776ceae1198207e639408a8d0fa404f6a1ff7976.tar.gz
rockbox-776ceae1198207e639408a8d0fa404f6a1ff7976.tar.bz2
rockbox-776ceae1198207e639408a8d0fa404f6a1ff7976.zip
Playlist Viewer Fix FS#13197
While playing a track the playlist viewer may not have a big enough temporary buffer to load and display 'max_files_in_playlist' entries This patch attempts to load as many entries as possible If tracks were already playing (dynamic playlist or otherwise) The original code only gave half the plugin buffer to a playlist loaded from file On some targets half the plugin buffer is not enough to load all entries… Now we attempt to get as many entries possible while at least leaving a small buffer (MAX_PATH) for the name buffer Change-Id: Ic06eaabc4e2550f076d625957d6d073790852743
Diffstat (limited to 'apps/playlist.c')
-rw-r--r--apps/playlist.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index 0b5662b47c..2bdc1f39cc 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -2887,11 +2887,8 @@ int playlist_create_ex(struct playlist_info* playlist,
if (index_buffer)
{
- size_t unit_size = sizeof (*playlist->indices);
-#ifdef HAVE_DIRCACHE
- unit_size += sizeof (*playlist->dcfrefs);
-#endif
- int num_indices = index_buffer_size / unit_size;
+ int num_indices = index_buffer_size /
+ playlist_get_required_bufsz(playlist, false, 1);
if (num_indices > global_settings.max_files_in_playlist)
num_indices = global_settings.max_files_in_playlist;
@@ -3525,6 +3522,26 @@ char *playlist_get_name(const struct playlist_info* playlist, char *buf,
return buf;
}
+/* return size of buffer needed for playlist to initialize num_indices entries */
+size_t playlist_get_required_bufsz(struct playlist_info* playlist,
+ bool include_namebuf,
+ int num_indices)
+{
+ size_t namebuf = 0;
+
+ if (!playlist)
+ playlist = &current_playlist;
+
+ size_t unit_size = sizeof (*playlist->indices);
+ #ifdef HAVE_DIRCACHE
+ unit_size += sizeof (*playlist->dcfrefs);
+ #endif
+ if (include_namebuf)
+ namebuf = AVERAGE_FILENAME_LENGTH * global_settings.max_files_in_dir;
+
+ return (num_indices * unit_size) + namebuf;
+}
+
/* Fills info structure with information about track at specified index.
Returns 0 on success and -1 on failure */
int playlist_get_track_info(struct playlist_info* playlist, int index,