diff options
-rw-r--r-- | apps/playlist.c | 40 | ||||
-rw-r--r-- | apps/root_menu.c | 2 |
2 files changed, 35 insertions, 7 deletions
diff --git a/apps/playlist.c b/apps/playlist.c index 503e4a28d1..67d59d1aac 100644 --- a/apps/playlist.c +++ b/apps/playlist.c | |||
@@ -3826,6 +3826,26 @@ error: | |||
3826 | return err; | 3826 | return err; |
3827 | } | 3827 | } |
3828 | 3828 | ||
3829 | static void pl_reverse(struct playlist_info *playlist, int start, int end) | ||
3830 | { | ||
3831 | for (; start < end; start++, end--) | ||
3832 | { | ||
3833 | unsigned long index_swap = playlist->indices[start]; | ||
3834 | playlist->indices[start] = playlist->indices[end]; | ||
3835 | playlist->indices[end] = index_swap; | ||
3836 | |||
3837 | #ifdef HAVE_DIRCACHE | ||
3838 | if (playlist->dcfrefs_handle) | ||
3839 | { | ||
3840 | struct dircache_fileref *dcfrefs = core_get_data(playlist->dcfrefs_handle); | ||
3841 | struct dircache_fileref dcf_swap = dcfrefs[start]; | ||
3842 | dcfrefs[start] = dcfrefs[end]; | ||
3843 | dcfrefs[end] = dcf_swap; | ||
3844 | } | ||
3845 | #endif | ||
3846 | } | ||
3847 | } | ||
3848 | |||
3829 | /* | 3849 | /* |
3830 | * Update the control file after saving the playlist under a new name. | 3850 | * Update the control file after saving the playlist under a new name. |
3831 | * A new control file is generated, containing the new playlist filename. | 3851 | * A new control file is generated, containing the new playlist filename. |
@@ -3838,7 +3858,7 @@ error: | |||
3838 | static int pl_save_update_control(struct playlist_info* playlist, | 3858 | static int pl_save_update_control(struct playlist_info* playlist, |
3839 | char *tmpbuf, size_t tmpsize) | 3859 | char *tmpbuf, size_t tmpsize) |
3840 | { | 3860 | { |
3841 | int old_fd, index; | 3861 | int old_fd; |
3842 | int err; | 3862 | int err; |
3843 | char c; | 3863 | char c; |
3844 | bool any_queued = false; | 3864 | bool any_queued = false; |
@@ -3878,12 +3898,20 @@ static int pl_save_update_control(struct playlist_info* playlist, | |||
3878 | if (err <= 0) | 3898 | if (err <= 0) |
3879 | return -4; | 3899 | return -4; |
3880 | 3900 | ||
3881 | index = playlist->first_index; | 3901 | if (playlist->first_index > 0) |
3882 | for (int i = 0; i < playlist->amount; ++i, ++index) | ||
3883 | { | 3902 | { |
3884 | if (index == playlist->amount) | 3903 | /* rotate indices so they'll be in sync with new control file */ |
3885 | index = 0; | 3904 | pl_reverse(playlist, 0, playlist->amount - 1); |
3905 | pl_reverse(playlist, 0, playlist->amount - playlist->first_index - 1); | ||
3906 | pl_reverse(playlist, playlist->amount - playlist->first_index, playlist->amount - 1); | ||
3886 | 3907 | ||
3908 | playlist->index = rotate_index(playlist, playlist->index); | ||
3909 | playlist->last_insert_pos = rotate_index(playlist, playlist->last_insert_pos); | ||
3910 | playlist->first_index = 0; | ||
3911 | } | ||
3912 | |||
3913 | for (int index = 0; index < playlist->amount; ++index) | ||
3914 | { | ||
3887 | /* We only need to update queued files */ | 3915 | /* We only need to update queued files */ |
3888 | if (!(playlist->indices[index] & PLAYLIST_QUEUED)) | 3916 | if (!(playlist->indices[index] & PLAYLIST_QUEUED)) |
3889 | continue; | 3917 | continue; |
@@ -3895,7 +3923,7 @@ static int pl_save_update_control(struct playlist_info* playlist, | |||
3895 | /* Write it out to the new control file */ | 3923 | /* Write it out to the new control file */ |
3896 | int seekpos; | 3924 | int seekpos; |
3897 | err = update_control_unlocked(playlist, PLAYLIST_COMMAND_QUEUE, | 3925 | err = update_control_unlocked(playlist, PLAYLIST_COMMAND_QUEUE, |
3898 | i, playlist->last_insert_pos, | 3926 | index, playlist->last_insert_pos, |
3899 | tmpbuf, NULL, &seekpos); | 3927 | tmpbuf, NULL, &seekpos); |
3900 | if (err <= 0) | 3928 | if (err <= 0) |
3901 | return -5; | 3929 | return -5; |
diff --git a/apps/root_menu.c b/apps/root_menu.c index 71753f27c4..762f5b2961 100644 --- a/apps/root_menu.c +++ b/apps/root_menu.c | |||
@@ -330,7 +330,7 @@ static int wpsscrn(void* param) | |||
330 | } | 330 | } |
331 | else if ( global_status.resume_index != -1 ) | 331 | else if ( global_status.resume_index != -1 ) |
332 | { | 332 | { |
333 | DEBUGF("Resume index %X crc32 %lX offset %lX\n", | 333 | DEBUGF("Resume index %d crc32 %lX offset %lX\n", |
334 | global_status.resume_index, | 334 | global_status.resume_index, |
335 | (unsigned long)global_status.resume_crc32, | 335 | (unsigned long)global_status.resume_crc32, |
336 | (unsigned long)global_status.resume_offset); | 336 | (unsigned long)global_status.resume_offset); |