summaryrefslogtreecommitdiff
path: root/apps/playlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/playlist.c')
-rwxr-xr-xapps/playlist.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index c5e2e83462..35b7e35baa 100755
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -2514,6 +2514,44 @@ int playlist_shuffle(int random_seed, int start_index)
2514 return playlist->index; 2514 return playlist->index;
2515} 2515}
2516 2516
2517/* returns the crc32 of the filename of the track at the specified index */
2518unsigned int playlist_get_filename_crc32(struct playlist_info *playlist,
2519 int index)
2520{
2521 struct playlist_track_info track_info;
2522 if (playlist_get_track_info(playlist, index, &track_info) == -1)
2523 return -1;
2524
2525 return crc_32(track_info.filename, strlen(track_info.filename), -1);
2526}
2527
2528/* resume a playlist track with the given crc_32 of the track name. */
2529void playlist_resume_track(int start_index, unsigned int crc, int offset)
2530{
2531 int i;
2532 unsigned int tmp_crc;
2533 struct playlist_info* playlist = &current_playlist;
2534 tmp_crc = playlist_get_filename_crc32(playlist, start_index);
2535 if (tmp_crc == crc)
2536 {
2537 playlist_start(start_index, offset);
2538 return;
2539 }
2540
2541 for (i = 0 ; i < playlist->amount; i++)
2542 {
2543 tmp_crc = playlist_get_filename_crc32(playlist, i);
2544 if (tmp_crc == crc)
2545 {
2546 playlist_start(i, offset);
2547 return;
2548 }
2549 }
2550
2551 /* If we got here the file wasnt found, so start from the beginning */
2552 playlist_start(0,0);
2553}
2554
2517/* start playing current playlist at specified index/offset */ 2555/* start playing current playlist at specified index/offset */
2518void playlist_start(int start_index, int offset) 2556void playlist_start(int start_index, int offset)
2519{ 2557{
@@ -2726,7 +2764,9 @@ int playlist_update_resume_info(const struct mp3entry* id3)
2726 if (global_status.resume_index != playlist->index || 2764 if (global_status.resume_index != playlist->index ||
2727 global_status.resume_offset != id3->offset) 2765 global_status.resume_offset != id3->offset)
2728 { 2766 {
2767 unsigned int crc = crc_32(id3->path, strlen(id3->path), -1);
2729 global_status.resume_index = playlist->index; 2768 global_status.resume_index = playlist->index;
2769 global_status.resume_crc32 = crc;
2730 global_status.resume_offset = id3->offset; 2770 global_status.resume_offset = id3->offset;
2731 status_save(); 2771 status_save();
2732 } 2772 }
@@ -2734,6 +2774,7 @@ int playlist_update_resume_info(const struct mp3entry* id3)
2734 else 2774 else
2735 { 2775 {
2736 global_status.resume_index = -1; 2776 global_status.resume_index = -1;
2777 global_status.resume_crc32 = -1;
2737 global_status.resume_offset = -1; 2778 global_status.resume_offset = -1;
2738 status_save(); 2779 status_save();
2739 } 2780 }