diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2004-12-07 14:20:37 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2004-12-07 14:20:37 +0000 |
commit | 8f032aed52c08a22f238e91bbcafd12a637c3326 (patch) | |
tree | 0150e6977769b4c122b9ac20222f5f825d4089c2 /apps | |
parent | dc96fcfb0e8690216638bc781da2bf4ae21fe374 (diff) | |
download | rockbox-8f032aed52c08a22f238e91bbcafd12a637c3326.tar.gz rockbox-8f032aed52c08a22f238e91bbcafd12a637c3326.zip |
Patch #911756 by Steve Cundari, bookmark follows repositioned MP3 file
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5481 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/bookmark.c | 48 | ||||
-rw-r--r-- | apps/bookmark.h | 3 | ||||
-rw-r--r-- | apps/tree.c | 23 |
3 files changed, 48 insertions, 26 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c index 785a8cf2d9..969371eeeb 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c | |||
@@ -73,8 +73,7 @@ static bool parse_bookmark(const char *bookmark, | |||
73 | int* ms, | 73 | int* ms, |
74 | int * repeat_mode, | 74 | int * repeat_mode, |
75 | bool *shuffle, | 75 | bool *shuffle, |
76 | char* file_name, | 76 | char* file_name); |
77 | unsigned int max_file_name_size); | ||
78 | static char* select_bookmark(const char* bookmark_file_name); | 77 | static char* select_bookmark(const char* bookmark_file_name); |
79 | static bool system_check(void); | 78 | static bool system_check(void); |
80 | static bool write_bookmark(bool create_bookmark_file); | 79 | static bool write_bookmark(bool create_bookmark_file); |
@@ -84,6 +83,7 @@ static char global_temp_buffer[MAX_PATH+1]; | |||
84 | static char global_bookmark_file_name[MAX_PATH]; | 83 | static char global_bookmark_file_name[MAX_PATH]; |
85 | static char global_read_buffer[MAX_BOOKMARK_SIZE]; | 84 | static char global_read_buffer[MAX_BOOKMARK_SIZE]; |
86 | static char global_bookmark[MAX_BOOKMARK_SIZE]; | 85 | static char global_bookmark[MAX_BOOKMARK_SIZE]; |
86 | static char global_filename[MAX_PATH]; | ||
87 | 87 | ||
88 | /* ----------------------------------------------------------------------- */ | 88 | /* ----------------------------------------------------------------------- */ |
89 | /* Displays the bookmark menu options for the user to decide. This is an */ | 89 | /* Displays the bookmark menu options for the user to decide. This is an */ |
@@ -162,7 +162,7 @@ static bool bookmark_load_menu(void) | |||
162 | NULL, | 162 | NULL, |
163 | &global_settings.repeat_mode, | 163 | &global_settings.repeat_mode, |
164 | &global_settings.playlist_shuffle, | 164 | &global_settings.playlist_shuffle, |
165 | NULL, 0); | 165 | global_filename); |
166 | } | 166 | } |
167 | else | 167 | else |
168 | { | 168 | { |
@@ -171,7 +171,8 @@ static bool bookmark_load_menu(void) | |||
171 | } | 171 | } |
172 | 172 | ||
173 | if (success) | 173 | if (success) |
174 | bookmark_play(global_temp_buffer, index, offset, seed); | 174 | bookmark_play(global_temp_buffer, index, offset, seed, |
175 | global_filename); | ||
175 | } | 176 | } |
176 | 177 | ||
177 | return success; | 178 | return success; |
@@ -203,10 +204,11 @@ bool bookmark_mrb_load() | |||
203 | NULL, | 204 | NULL, |
204 | &global_settings.repeat_mode, | 205 | &global_settings.repeat_mode, |
205 | &global_settings.playlist_shuffle, | 206 | &global_settings.playlist_shuffle, |
206 | NULL, 0); | 207 | global_filename); |
207 | 208 | ||
208 | if (success) | 209 | if (success) |
209 | bookmark_play(global_temp_buffer, index, offset, seed); | 210 | bookmark_play(global_temp_buffer, index, offset, seed, |
211 | global_filename); | ||
210 | 212 | ||
211 | return success; | 213 | return success; |
212 | } | 214 | } |
@@ -442,7 +444,7 @@ static bool check_bookmark(const char* bookmark) | |||
442 | return parse_bookmark(bookmark, | 444 | return parse_bookmark(bookmark, |
443 | NULL,NULL,NULL, NULL, | 445 | NULL,NULL,NULL, NULL, |
444 | NULL,0,NULL,NULL, | 446 | NULL,0,NULL,NULL, |
445 | NULL, NULL, 0); | 447 | NULL, NULL); |
446 | } | 448 | } |
447 | 449 | ||
448 | /* ----------------------------------------------------------------------- */ | 450 | /* ----------------------------------------------------------------------- */ |
@@ -566,12 +568,13 @@ bool bookmark_load(const char* file, bool autoload) | |||
566 | NULL, | 568 | NULL, |
567 | &global_settings.repeat_mode, | 569 | &global_settings.repeat_mode, |
568 | &global_settings.playlist_shuffle, | 570 | &global_settings.playlist_shuffle, |
569 | NULL, 0); | 571 | global_filename); |
570 | 572 | ||
571 | } | 573 | } |
572 | 574 | ||
573 | if(success) | 575 | if(success) |
574 | bookmark_play(global_temp_buffer,index,offset,seed); | 576 | bookmark_play(global_temp_buffer, index, offset, seed, |
577 | global_filename); | ||
575 | 578 | ||
576 | return success; | 579 | return success; |
577 | } | 580 | } |
@@ -778,7 +781,6 @@ static void display_bookmark(const char* bookmark, | |||
778 | int ms = 0; | 781 | int ms = 0; |
779 | int repeat_mode = 0; | 782 | int repeat_mode = 0; |
780 | bool playlist_shuffle = false; | 783 | bool playlist_shuffle = false; |
781 | char MP3_file_name[45]; | ||
782 | int len; | 784 | int len; |
783 | char *dot; | 785 | char *dot; |
784 | 786 | ||
@@ -786,7 +788,7 @@ static void display_bookmark(const char* bookmark, | |||
786 | parse_bookmark(bookmark, | 788 | parse_bookmark(bookmark, |
787 | &resume_index, NULL, NULL, NULL, NULL, 0, | 789 | &resume_index, NULL, NULL, NULL, NULL, 0, |
788 | &ms, &repeat_mode, &playlist_shuffle, | 790 | &ms, &repeat_mode, &playlist_shuffle, |
789 | MP3_file_name, sizeof(MP3_file_name)); | 791 | global_filename); |
790 | 792 | ||
791 | lcd_clear_display(); | 793 | lcd_clear_display(); |
792 | lcd_stop_scroll(); | 794 | lcd_stop_scroll(); |
@@ -807,14 +809,14 @@ static void display_bookmark(const char* bookmark, | |||
807 | statusbar_icon_shuffle(); | 809 | statusbar_icon_shuffle(); |
808 | 810 | ||
809 | /* File Name */ | 811 | /* File Name */ |
810 | len=strlen(MP3_file_name); | 812 | len=strlen(global_filename); |
811 | if (len>3) | 813 | if (len>3) |
812 | dot=strrchr(MP3_file_name + len - 4, '.'); | 814 | dot=strrchr(global_filename + len - 4, '.'); |
813 | else | 815 | else |
814 | dot=NULL; | 816 | dot=NULL; |
815 | if (dot) | 817 | if (dot) |
816 | *dot='\0'; | 818 | *dot='\0'; |
817 | lcd_puts_scroll(0, 0, MP3_file_name); | 819 | lcd_puts_scroll(0, 0, global_filename); |
818 | if (dot) | 820 | if (dot) |
819 | *dot='.'; | 821 | *dot='.'; |
820 | 822 | ||
@@ -854,9 +856,9 @@ static void display_bookmark(const char* bookmark, | |||
854 | lcd_puts_scroll(0, 6, str(LANG_BOOKMARK_SELECT_DELETE)); | 856 | lcd_puts_scroll(0, 6, str(LANG_BOOKMARK_SELECT_DELETE)); |
855 | #else | 857 | #else |
856 | (void)bookmark_id; | 858 | (void)bookmark_id; |
857 | len=strlen(MP3_file_name); | 859 | len=strlen(global_filename); |
858 | if (len>3) | 860 | if (len>3) |
859 | dot=strrchr(MP3_file_name+len-4,'.'); | 861 | dot=strrchr(global_filename+len-4,'.'); |
860 | else | 862 | else |
861 | dot=NULL; | 863 | dot=NULL; |
862 | if (dot) | 864 | if (dot) |
@@ -868,7 +870,7 @@ static void display_bookmark(const char* bookmark, | |||
868 | (bookmark_count+1), | 870 | (bookmark_count+1), |
869 | ms / 60000, | 871 | ms / 60000, |
870 | ms % 60000 / 1000, | 872 | ms % 60000 / 1000, |
871 | MP3_file_name); | 873 | global_filename); |
872 | } | 874 | } |
873 | else | 875 | else |
874 | { | 876 | { |
@@ -878,7 +880,7 @@ static void display_bookmark(const char* bookmark, | |||
878 | ms / 60000, | 880 | ms / 60000, |
879 | ms % 3600000 / 60000, | 881 | ms % 3600000 / 60000, |
880 | ms % 60000 / 1000, | 882 | ms % 60000 / 1000, |
881 | MP3_file_name); | 883 | global_filename); |
882 | } | 884 | } |
883 | 885 | ||
884 | status_draw(false); | 886 | status_draw(false); |
@@ -907,7 +909,7 @@ static void say_bookmark(const char* bookmark, | |||
907 | NULL, NULL, NULL, | 909 | NULL, NULL, NULL, |
908 | dir, sizeof(dir), | 910 | dir, sizeof(dir), |
909 | &ms, NULL, NULL, | 911 | &ms, NULL, NULL, |
910 | NULL, 0); | 912 | NULL); |
911 | /* disabled, because transition between talkbox and voice UI clip is not nice */ | 913 | /* disabled, because transition between talkbox and voice UI clip is not nice */ |
912 | #if 0 | 914 | #if 0 |
913 | if (global_settings.talk_dir >= 3) | 915 | if (global_settings.talk_dir >= 3) |
@@ -987,8 +989,7 @@ static bool parse_bookmark(const char *bookmark, | |||
987 | unsigned int resume_file_size, | 989 | unsigned int resume_file_size, |
988 | int* ms, | 990 | int* ms, |
989 | int * repeat_mode, bool *shuffle, | 991 | int * repeat_mode, bool *shuffle, |
990 | char* file_name, | 992 | char* file_name) |
991 | unsigned int max_file_name_size) | ||
992 | { | 993 | { |
993 | /* First check to see if a valid line was passed in. */ | 994 | /* First check to see if a valid line was passed in. */ |
994 | int bookmark_len = strlen(bookmark); | 995 | int bookmark_len = strlen(bookmark); |
@@ -1097,9 +1098,8 @@ static bool parse_bookmark(const char *bookmark, | |||
1097 | 1098 | ||
1098 | if (file_name && local_file_name) | 1099 | if (file_name && local_file_name) |
1099 | { | 1100 | { |
1100 | strncpy(file_name, local_file_name, | 1101 | strncpy(file_name, local_file_name,MAX_PATH-1); |
1101 | MIN(strlen(local_file_name),max_file_name_size-1)); | 1102 | file_name[MAX_PATH-1] = 0; |
1102 | file_name[MIN(strlen(local_file_name),max_file_name_size-1)]=0; | ||
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | return true; | 1105 | return true; |
diff --git a/apps/bookmark.h b/apps/bookmark.h index 2f8b58af7e..c5fe6fe7ba 100644 --- a/apps/bookmark.h +++ b/apps/bookmark.h | |||
@@ -27,7 +27,8 @@ bool bookmark_create_menu(void); | |||
27 | bool bookmark_mrb_load(void); | 27 | bool bookmark_mrb_load(void); |
28 | bool bookmark_autoload(const char* file); | 28 | bool bookmark_autoload(const char* file); |
29 | bool bookmark_load(const char* file, bool autoload); | 29 | bool bookmark_load(const char* file, bool autoload); |
30 | void bookmark_play(char* resume_file, int index, int offset, int seed); | 30 | void bookmark_play(char* resume_file, int index, int offset, int seed, |
31 | char *filename); | ||
31 | 32 | ||
32 | #endif /* __BOOKMARK_H__ */ | 33 | #endif /* __BOOKMARK_H__ */ |
33 | 34 | ||
diff --git a/apps/tree.c b/apps/tree.c index cf12c4abc2..87a039223e 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -1795,12 +1795,15 @@ void tree_init(void) | |||
1795 | dircache = buffer_alloc(max_files_in_dir * sizeof(struct entry)); | 1795 | dircache = buffer_alloc(max_files_in_dir * sizeof(struct entry)); |
1796 | } | 1796 | } |
1797 | 1797 | ||
1798 | void bookmark_play(char *resume_file, int index, int offset, int seed) | 1798 | void bookmark_play(char *resume_file, int index, int offset, int seed, |
1799 | char *filename) | ||
1799 | { | 1800 | { |
1801 | int i; | ||
1800 | int len=strlen(resume_file); | 1802 | int len=strlen(resume_file); |
1801 | 1803 | ||
1802 | if (!strcasecmp(&resume_file[len-4], ".m3u")) | 1804 | if (!strcasecmp(&resume_file[len-4], ".m3u")) |
1803 | { | 1805 | { |
1806 | /* Playlist playback */ | ||
1804 | char* slash; | 1807 | char* slash; |
1805 | // check that the file exists | 1808 | // check that the file exists |
1806 | int fd = open(resume_file, O_RDONLY); | 1809 | int fd = open(resume_file, O_RDONLY); |
@@ -1829,12 +1832,30 @@ void bookmark_play(char *resume_file, int index, int offset, int seed) | |||
1829 | } | 1832 | } |
1830 | else | 1833 | else |
1831 | { | 1834 | { |
1835 | /* Directory playback */ | ||
1832 | lastdir[0]='\0'; | 1836 | lastdir[0]='\0'; |
1833 | if (playlist_create(resume_file, NULL) != -1) | 1837 | if (playlist_create(resume_file, NULL) != -1) |
1834 | { | 1838 | { |
1835 | resume_directory(resume_file); | 1839 | resume_directory(resume_file); |
1836 | if (global_settings.playlist_shuffle) | 1840 | if (global_settings.playlist_shuffle) |
1837 | playlist_shuffle(seed, -1); | 1841 | playlist_shuffle(seed, -1); |
1842 | |||
1843 | /* Check if the file is at the same spot in the directory, | ||
1844 | else search for it */ | ||
1845 | if ((strcmp(strrchr(playlist_peek(index) + 1,'/') + 1, | ||
1846 | filename))) | ||
1847 | { | ||
1848 | for ( i=0; i < playlist_amount(); i++ ) | ||
1849 | { | ||
1850 | if ((strcmp(strrchr(playlist_peek(i) + 1,'/') + 1, | ||
1851 | filename)) == 0) | ||
1852 | break; | ||
1853 | } | ||
1854 | if (i < playlist_amount()) | ||
1855 | index = i; | ||
1856 | else | ||
1857 | return; | ||
1858 | } | ||
1838 | playlist_start(index,offset); | 1859 | playlist_start(index,offset); |
1839 | } | 1860 | } |
1840 | } | 1861 | } |