summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Soffke <christian.soffke@gmail.com>2021-02-15 15:05:56 +0100
committerSolomon Peachy <pizza@shaftnet.org>2021-02-17 11:34:59 +0000
commit436e64e09eee2b83daa0c91835305fec2eec1a3f (patch)
treec4a250f4324cccee60dc7c35201bcd2fc93d9bec
parentabebc6b9acdbed87edd3bb40a9f76626a5180bc4 (diff)
downloadrockbox-436e64e09eee2b83daa0c91835305fec2eec1a3f.tar.gz
rockbox-436e64e09eee2b83daa0c91835305fec2eec1a3f.zip
Fix playback queue bug when "Insert Next" is used with multiple songs at once
After using “Insert Next” to insert multiple songs at once (e.g. an album from the database browser or folder from the file browser), subsequent Insert operations will incorrectly insert items after the first song of all items that were previously inserted, instead of after the last song of the previously inserted items. A bug fix was originally written by Costas Calamvokis for the file browser only. I adopted the original fix and added code analogous to it so that it works from the database browser as well. See FS#7898, FS#7363 or this forum post for more info: https://forums.rockbox.org/index.php/topic,53741.0.html Change-Id: Ie2718e136df0b340000f7a171e9e806cf23a27b4
-rw-r--r--apps/playlist.c26
-rw-r--r--apps/tagtree.c20
2 files changed, 21 insertions, 25 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index c64fc229b5..3eb0949cc2 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -855,14 +855,14 @@ static int directory_search_callback(char* filename, void* context)
855 855
856 if (insert_pos < 0) 856 if (insert_pos < 0)
857 return -1; 857 return -1;
858 858
859 (c->count)++; 859 (c->count)++;
860 860
861 /* Make sure tracks are inserted in correct order if user requests 861 /* After first INSERT_FIRST switch to INSERT so that all the
862 INSERT_FIRST */ 862 rest of the tracks get inserted one after the other */
863 if (c->position == PLAYLIST_INSERT_FIRST || c->position >= 0) 863 if (c->position == PLAYLIST_INSERT_FIRST)
864 c->position = insert_pos + 1; 864 c->position = PLAYLIST_INSERT;
865 865
866 if (((c->count)%PLAYLIST_DISPLAY_COUNT) == 0) 866 if (((c->count)%PLAYLIST_DISPLAY_COUNT) == 0)
867 { 867 {
868 unsigned char* count_str; 868 unsigned char* count_str;
@@ -3179,7 +3179,7 @@ int playlist_insert_playlist(struct playlist_info* playlist, const char *filenam
3179 result = -1; 3179 result = -1;
3180 break; 3180 break;
3181 } 3181 }
3182 3182
3183 insert_pos = add_track_to_playlist(playlist, trackname, position, 3183 insert_pos = add_track_to_playlist(playlist, trackname, position,
3184 queue, -1); 3184 queue, -1);
3185 3185
@@ -3189,13 +3189,13 @@ int playlist_insert_playlist(struct playlist_info* playlist, const char *filenam
3189 break; 3189 break;
3190 } 3190 }
3191 3191
3192 /* Make sure tracks are inserted in correct order if user 3192 /* After first INSERT_FIRST switch to INSERT so that all the
3193 requests INSERT_FIRST */ 3193 rest of the tracks get inserted one after the other */
3194 if (position == PLAYLIST_INSERT_FIRST || position >= 0) 3194 if (position == PLAYLIST_INSERT_FIRST)
3195 position = insert_pos + 1; 3195 position = PLAYLIST_INSERT;
3196 3196
3197 count++; 3197 count++;
3198 3198
3199 if ((count%PLAYLIST_DISPLAY_COUNT) == 0) 3199 if ((count%PLAYLIST_DISPLAY_COUNT) == 0)
3200 { 3200 {
3201 display_playlist_count(count, count_str, false); 3201 display_playlist_count(count, count_str, false);
diff --git a/apps/tagtree.c b/apps/tagtree.c
index f006baa581..97e0c67b62 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -2018,18 +2018,9 @@ static bool insert_all_playlist(struct tree_context *c, int position, bool queue
2018 } 2018 }
2019 } 2019 }
2020 2020
2021 if (position == PLAYLIST_INSERT_FIRST) 2021 from = 0;
2022 { 2022 to = c->filesindir;
2023 from = c->filesindir - 1; 2023 direction = 1;
2024 to = -1;
2025 direction = -1;
2026 }
2027 else
2028 {
2029 from = 0;
2030 to = c->filesindir;
2031 direction = 1;
2032 }
2033 2024
2034 for (i = from; i != to; i += direction) 2025 for (i = from; i != to; i += direction)
2035 { 2026 {
@@ -2049,6 +2040,11 @@ static bool insert_all_playlist(struct tree_context *c, int position, bool queue
2049 break; 2040 break;
2050 } 2041 }
2051 yield(); 2042 yield();
2043
2044 if (position == PLAYLIST_INSERT_FIRST)
2045 {
2046 position = PLAYLIST_INSERT;
2047 }
2052 } 2048 }
2053 playlist_sync(NULL); 2049 playlist_sync(NULL);
2054 tagcache_search_finish(&tcs); 2050 tagcache_search_finish(&tcs);