summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2023-01-08 09:44:57 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2023-01-08 09:52:23 -0500
commit282a54b23c6cad011be1d046ed76bc1b1d85ea33 (patch)
treeabca409551c684883f79613aaa288f2e1fe12c21
parent593103cd8bdae024e28932c94ce5441283161393 (diff)
downloadrockbox-282a54b23c6cad011be1d046ed76bc1b1d85ea33.tar.gz
rockbox-282a54b23c6cad011be1d046ed76bc1b1d85ea33.zip
[Feature] filetree fallback to loading a playlist from disk
give user option to load playlist from disk when namebuffer is too small -- max_playlist size still limits the total entries but filename length won't stop them from playing the directory Change-Id: I1787689417661ea670a211f575f2c52e84465869
-rw-r--r--apps/filetree.c21
-rw-r--r--apps/playlist.c9
2 files changed, 26 insertions, 4 deletions
diff --git a/apps/filetree.c b/apps/filetree.c
index 107163add5..2d4416df5a 100644
--- a/apps/filetree.c
+++ b/apps/filetree.c
@@ -72,6 +72,7 @@ static int strnatcasecmp_n(const char *a, const char *b, size_t n)
int ft_build_playlist(struct tree_context* c, int start_index)
{
int i;
+ int res = 0;
int start=start_index;
tree_lock_cache(c);
@@ -81,7 +82,8 @@ int ft_build_playlist(struct tree_context* c, int start_index)
{
if((entries[i].attr & FILE_ATTR_MASK) == FILE_ATTR_AUDIO)
{
- if (playlist_add(entries[i].name) < 0)
+ res = playlist_add(entries[i].name);
+ if (res < 0)
break;
}
else
@@ -92,7 +94,22 @@ int ft_build_playlist(struct tree_context* c, int start_index)
}
}
- tree_unlock_cache(c);
+ if (res == -2) /* name buffer is full store to disk? */
+ {
+ if (yesno_pop(ID2P(LANG_CATALOG_ADD_TO_NEW)))
+ {
+ char playlist_dir[MAX_PATH];
+ strmemccpy(playlist_dir, c->currdir, sizeof(playlist_dir));
+ tree_unlock_cache(c);
+ if (playlist_create(playlist_dir, "dynamic.m3u8") >= 0)
+ {
+ playlist_insert_directory(NULL, playlist_dir,
+ PLAYLIST_REPLACE, false, false);
+ }
+ }
+ }
+ else
+ tree_unlock_cache(c);
return start_index;
}
diff --git a/apps/playlist.c b/apps/playlist.c
index b349799269..4e4e3ed42a 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -2082,8 +2082,13 @@ int playlist_add(const char *filename)
struct playlist_info* playlist = &current_playlist;
int len = strlen(filename);
- if((len+1 > playlist->buffer_size - playlist->buffer_end_pos) ||
- (playlist->amount >= playlist->max_playlist_size))
+ if(len+1 > playlist->buffer_size - playlist->buffer_end_pos)
+ {
+ notify_buffer_full();
+ return -2;
+ }
+
+ if(playlist->amount >= playlist->max_playlist_size)
{
notify_buffer_full();
return -1;