summaryrefslogtreecommitdiff
path: root/apps/playlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/playlist.c')
-rw-r--r--apps/playlist.c102
1 files changed, 60 insertions, 42 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index caf5856ae8..873db30a7d 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -181,7 +181,8 @@ static int get_previous_directory(char *dir);
181static int check_subdir_for_music(char *dir, char *subdir); 181static int check_subdir_for_music(char *dir, char *subdir);
182static int format_track_path(char *dest, char *src, int buf_length, int max, 182static int format_track_path(char *dest, char *src, int buf_length, int max,
183 char *dir); 183 char *dir);
184static void display_playlist_count(int count, const unsigned char *fmt); 184static void display_playlist_count(int count, const unsigned char *fmt,
185 bool final);
185static void display_buffer_full(void); 186static void display_buffer_full(void);
186static int flush_cached_control(struct playlist_info* playlist); 187static int flush_cached_control(struct playlist_info* playlist);
187static int update_control(struct playlist_info* playlist, 188static int update_control(struct playlist_info* playlist,
@@ -288,6 +289,7 @@ static void create_control(struct playlist_info* playlist)
288 { 289 {
289 if (check_rockboxdir()) 290 if (check_rockboxdir())
290 { 291 {
292 cond_talk_ids_fq(LANG_PLAYLIST_CONTROL_ACCESS_ERROR);
291 gui_syncsplash(HZ*2, (unsigned char *)"%s (%d)", 293 gui_syncsplash(HZ*2, (unsigned char *)"%s (%d)",
292 str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR), 294 str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR),
293 playlist->control_fd); 295 playlist->control_fd);
@@ -483,8 +485,7 @@ static int add_indices_to_playlist(struct playlist_info* playlist,
483 else 485 else
484 lcd_setmargins(0, 0); 486 lcd_setmargins(0, 0);
485#endif 487#endif
486 488 gui_syncsplash(0, ID2P(LANG_WAIT));
487 gui_syncsplash(0, str(LANG_WAIT));
488 489
489 if (!buffer) 490 if (!buffer)
490 { 491 {
@@ -770,11 +771,11 @@ static int directory_search_callback(char* filename, void* context)
770 unsigned char* count_str; 771 unsigned char* count_str;
771 772
772 if (c->queue) 773 if (c->queue)
773 count_str = str(LANG_PLAYLIST_QUEUE_COUNT); 774 count_str = ID2P(LANG_PLAYLIST_QUEUE_COUNT);
774 else 775 else
775 count_str = str(LANG_PLAYLIST_INSERT_COUNT); 776 count_str = ID2P(LANG_PLAYLIST_INSERT_COUNT);
776 777
777 display_playlist_count(c->count, count_str); 778 display_playlist_count(c->count, count_str, false);
778 779
779 if ((c->count) == PLAYLIST_DISPLAY_COUNT && 780 if ((c->count) == PLAYLIST_DISPLAY_COUNT &&
780 (audio_status() & AUDIO_STATUS_PLAY) && 781 (audio_status() & AUDIO_STATUS_PLAY) &&
@@ -1350,9 +1351,9 @@ static int get_filename(struct playlist_info* playlist, int index, int seek,
1350 if (max < 0) 1351 if (max < 0)
1351 { 1352 {
1352 if (control_file) 1353 if (control_file)
1353 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); 1354 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_CONTROL_ACCESS_ERROR));
1354 else 1355 else
1355 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_ACCESS_ERROR)); 1356 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_ACCESS_ERROR));
1356 1357
1357 return max; 1358 return max;
1358 } 1359 }
@@ -1445,7 +1446,7 @@ static int get_next_dir(char *dir, bool is_forward, bool recursion)
1445 1446
1446 if (ft_load(tc, (dir[0]=='\0')?"/":dir) < 0) 1447 if (ft_load(tc, (dir[0]=='\0')?"/":dir) < 0)
1447 { 1448 {
1448 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_DIRECTORY_ACCESS_ERROR)); 1449 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_DIRECTORY_ACCESS_ERROR));
1449 exit = true; 1450 exit = true;
1450 result = -1; 1451 result = -1;
1451 break; 1452 break;
@@ -1530,7 +1531,7 @@ static int check_subdir_for_music(char *dir, char *subdir)
1530 1531
1531 if (ft_load(tc, dir) < 0) 1532 if (ft_load(tc, dir) < 0)
1532 { 1533 {
1533 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_DIRECTORY_ACCESS_ERROR)); 1534 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_DIRECTORY_ACCESS_ERROR));
1534 return -2; 1535 return -2;
1535 } 1536 }
1536 1537
@@ -1584,7 +1585,7 @@ static int check_subdir_for_music(char *dir, char *subdir)
1584 /* we now need to reload our current directory */ 1585 /* we now need to reload our current directory */
1585 if(ft_load(tc, dir) < 0) 1586 if(ft_load(tc, dir) < 0)
1586 gui_syncsplash(HZ*2, 1587 gui_syncsplash(HZ*2,
1587 str(LANG_PLAYLIST_DIRECTORY_ACCESS_ERROR)); 1588 ID2P(LANG_PLAYLIST_DIRECTORY_ACCESS_ERROR));
1588 } 1589 }
1589 1590
1590 return result; 1591 return result;
@@ -1657,8 +1658,23 @@ static int format_track_path(char *dest, char *src, int buf_length, int max,
1657 * Display splash message showing progress of playlist/directory insertion or 1658 * Display splash message showing progress of playlist/directory insertion or
1658 * save. 1659 * save.
1659 */ 1660 */
1660static void display_playlist_count(int count, const unsigned char *fmt) 1661static void display_playlist_count(int count, const unsigned char *fmt,
1662 bool final)
1661{ 1663{
1664 static long talked_tick = 0;
1665 long id = P2ID(fmt);
1666 if(talk_menus_enabled() && id>=0)
1667 {
1668 if(final || (count && (talked_tick == 0
1669 || TIME_AFTER(current_tick, talked_tick+5*HZ))))
1670 {
1671 talked_tick = current_tick;
1672 talk_number(count, false);
1673 talk_id(id, true);
1674 }
1675 }
1676 fmt = P2STR(fmt);
1677
1662 lcd_clear_display(); 1678 lcd_clear_display();
1663 1679
1664#ifdef HAVE_LCD_BITMAP 1680#ifdef HAVE_LCD_BITMAP
@@ -1676,7 +1692,7 @@ static void display_playlist_count(int count, const unsigned char *fmt)
1676 */ 1692 */
1677static void display_buffer_full(void) 1693static void display_buffer_full(void)
1678{ 1694{
1679 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_BUFFER_FULL)); 1695 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_BUFFER_FULL));
1680} 1696}
1681 1697
1682/* 1698/*
@@ -1755,7 +1771,7 @@ static int flush_cached_control(struct playlist_info* playlist)
1755 else 1771 else
1756 { 1772 {
1757 result = -1; 1773 result = -1;
1758 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_CONTROL_UPDATE_ERROR)); 1774 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_CONTROL_UPDATE_ERROR));
1759 } 1775 }
1760 1776
1761 return result; 1777 return result;
@@ -1942,11 +1958,11 @@ int playlist_resume(void)
1942 1958
1943 empty_playlist(playlist, true); 1959 empty_playlist(playlist, true);
1944 1960
1945 gui_syncsplash(0, str(LANG_WAIT)); 1961 gui_syncsplash(0, ID2P(LANG_WAIT));
1946 playlist->control_fd = open(playlist->control_filename, O_RDWR); 1962 playlist->control_fd = open(playlist->control_filename, O_RDWR);
1947 if (playlist->control_fd < 0) 1963 if (playlist->control_fd < 0)
1948 { 1964 {
1949 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); 1965 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_CONTROL_ACCESS_ERROR));
1950 return -1; 1966 return -1;
1951 } 1967 }
1952 playlist->control_created = true; 1968 playlist->control_created = true;
@@ -1954,7 +1970,7 @@ int playlist_resume(void)
1954 control_file_size = filesize(playlist->control_fd); 1970 control_file_size = filesize(playlist->control_fd);
1955 if (control_file_size <= 0) 1971 if (control_file_size <= 0)
1956 { 1972 {
1957 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); 1973 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_CONTROL_ACCESS_ERROR));
1958 return -1; 1974 return -1;
1959 } 1975 }
1960 1976
@@ -1963,7 +1979,7 @@ int playlist_resume(void)
1963 PLAYLIST_COMMAND_SIZE<buflen?PLAYLIST_COMMAND_SIZE:buflen); 1979 PLAYLIST_COMMAND_SIZE<buflen?PLAYLIST_COMMAND_SIZE:buflen);
1964 if(nread <= 0) 1980 if(nread <= 0)
1965 { 1981 {
1966 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); 1982 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_CONTROL_ACCESS_ERROR));
1967 return -1; 1983 return -1;
1968 } 1984 }
1969 1985
@@ -2258,7 +2274,7 @@ int playlist_resume(void)
2258 2274
2259 if (result < 0) 2275 if (result < 0)
2260 { 2276 {
2261 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_CONTROL_INVALID)); 2277 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_CONTROL_INVALID));
2262 return result; 2278 return result;
2263 } 2279 }
2264 2280
@@ -2267,7 +2283,7 @@ int playlist_resume(void)
2267 if ((total_read + count) >= control_file_size) 2283 if ((total_read + count) >= control_file_size)
2268 { 2284 {
2269 /* no newline at end of control file */ 2285 /* no newline at end of control file */
2270 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_CONTROL_INVALID)); 2286 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_CONTROL_INVALID));
2271 return -1; 2287 return -1;
2272 } 2288 }
2273 2289
@@ -2361,6 +2377,7 @@ int playlist_shuffle(int random_seed, int start_index)
2361 start_current = true; 2377 start_current = true;
2362 } 2378 }
2363 2379
2380 cond_talk_ids(LANG_WAIT);
2364 gui_syncsplash(0, str(LANG_PLAYLIST_SHUFFLE)); 2381 gui_syncsplash(0, str(LANG_PLAYLIST_SHUFFLE));
2365 2382
2366 randomise_playlist(playlist, random_seed, start_current, true); 2383 randomise_playlist(playlist, random_seed, start_current, true);
@@ -2853,7 +2870,7 @@ int playlist_insert_track(struct playlist_info* playlist, const char *filename,
2853 2870
2854 if (check_control(playlist) < 0) 2871 if (check_control(playlist) < 0)
2855 { 2872 {
2856 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); 2873 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_CONTROL_ACCESS_ERROR));
2857 return -1; 2874 return -1;
2858 } 2875 }
2859 2876
@@ -2884,7 +2901,7 @@ int playlist_insert_directory(struct playlist_info* playlist,
2884 2901
2885 if (check_control(playlist) < 0) 2902 if (check_control(playlist) < 0)
2886 { 2903 {
2887 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); 2904 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_CONTROL_ACCESS_ERROR));
2888 return -1; 2905 return -1;
2889 } 2906 }
2890 2907
@@ -2897,11 +2914,11 @@ int playlist_insert_directory(struct playlist_info* playlist,
2897 } 2914 }
2898 2915
2899 if (queue) 2916 if (queue)
2900 count_str = str(LANG_PLAYLIST_QUEUE_COUNT); 2917 count_str = ID2P(LANG_PLAYLIST_QUEUE_COUNT);
2901 else 2918 else
2902 count_str = str(LANG_PLAYLIST_INSERT_COUNT); 2919 count_str = ID2P(LANG_PLAYLIST_INSERT_COUNT);
2903 2920
2904 display_playlist_count(0, count_str); 2921 display_playlist_count(0, count_str, false);
2905 2922
2906 context.playlist = playlist; 2923 context.playlist = playlist;
2907 context.position = position; 2924 context.position = position;
@@ -2917,7 +2934,7 @@ int playlist_insert_directory(struct playlist_info* playlist,
2917 2934
2918 cpu_boost(false); 2935 cpu_boost(false);
2919 2936
2920 display_playlist_count(context.count, count_str); 2937 display_playlist_count(context.count, count_str, true);
2921 2938
2922 if ((audio_status() & AUDIO_STATUS_PLAY) && playlist->started) 2939 if ((audio_status() & AUDIO_STATUS_PLAY) && playlist->started)
2923 audio_flush_and_reload_tracks(); 2940 audio_flush_and_reload_tracks();
@@ -2950,14 +2967,14 @@ int playlist_insert_playlist(struct playlist_info* playlist, char *filename,
2950 2967
2951 if (check_control(playlist) < 0) 2968 if (check_control(playlist) < 0)
2952 { 2969 {
2953 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); 2970 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_CONTROL_ACCESS_ERROR));
2954 return -1; 2971 return -1;
2955 } 2972 }
2956 2973
2957 fd = open(filename, O_RDONLY); 2974 fd = open(filename, O_RDONLY);
2958 if (fd < 0) 2975 if (fd < 0)
2959 { 2976 {
2960 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_ACCESS_ERROR)); 2977 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_ACCESS_ERROR));
2961 return -1; 2978 return -1;
2962 } 2979 }
2963 2980
@@ -2971,11 +2988,11 @@ int playlist_insert_playlist(struct playlist_info* playlist, char *filename,
2971 dir = "/"; 2988 dir = "/";
2972 2989
2973 if (queue) 2990 if (queue)
2974 count_str = str(LANG_PLAYLIST_QUEUE_COUNT); 2991 count_str = ID2P(LANG_PLAYLIST_QUEUE_COUNT);
2975 else 2992 else
2976 count_str = str(LANG_PLAYLIST_INSERT_COUNT); 2993 count_str = ID2P(LANG_PLAYLIST_INSERT_COUNT);
2977 2994
2978 display_playlist_count(count, count_str); 2995 display_playlist_count(count, count_str, false);
2979 2996
2980 if (position == PLAYLIST_REPLACE) 2997 if (position == PLAYLIST_REPLACE)
2981 { 2998 {
@@ -3023,7 +3040,7 @@ int playlist_insert_playlist(struct playlist_info* playlist, char *filename,
3023 3040
3024 if ((count%PLAYLIST_DISPLAY_COUNT) == 0) 3041 if ((count%PLAYLIST_DISPLAY_COUNT) == 0)
3025 { 3042 {
3026 display_playlist_count(count, count_str); 3043 display_playlist_count(count, count_str, false);
3027 3044
3028 if (count == PLAYLIST_DISPLAY_COUNT && 3045 if (count == PLAYLIST_DISPLAY_COUNT &&
3029 (audio_status() & AUDIO_STATUS_PLAY) && 3046 (audio_status() & AUDIO_STATUS_PLAY) &&
@@ -3045,7 +3062,7 @@ int playlist_insert_playlist(struct playlist_info* playlist, char *filename,
3045 3062
3046 cpu_boost(false); 3063 cpu_boost(false);
3047 3064
3048 display_playlist_count(count, count_str); 3065 display_playlist_count(count, count_str, true);
3049 3066
3050 if ((audio_status() & AUDIO_STATUS_PLAY) && playlist->started) 3067 if ((audio_status() & AUDIO_STATUS_PLAY) && playlist->started)
3051 audio_flush_and_reload_tracks(); 3068 audio_flush_and_reload_tracks();
@@ -3070,7 +3087,7 @@ int playlist_delete(struct playlist_info* playlist, int index)
3070 3087
3071 if (check_control(playlist) < 0) 3088 if (check_control(playlist) < 0)
3072 { 3089 {
3073 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); 3090 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_CONTROL_ACCESS_ERROR));
3074 return -1; 3091 return -1;
3075 } 3092 }
3076 3093
@@ -3105,7 +3122,7 @@ int playlist_move(struct playlist_info* playlist, int index, int new_index)
3105 3122
3106 if (check_control(playlist) < 0) 3123 if (check_control(playlist) < 0)
3107 { 3124 {
3108 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); 3125 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_CONTROL_ACCESS_ERROR));
3109 return -1; 3126 return -1;
3110 } 3127 }
3111 3128
@@ -3368,7 +3385,7 @@ int playlist_save(struct playlist_info* playlist, char *filename)
3368 if (playlist->buffer_size < (int)(playlist->amount * sizeof(int))) 3385 if (playlist->buffer_size < (int)(playlist->amount * sizeof(int)))
3369 { 3386 {
3370 /* not enough buffer space to store updated indices */ 3387 /* not enough buffer space to store updated indices */
3371 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_ACCESS_ERROR)); 3388 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_ACCESS_ERROR));
3372 return -1; 3389 return -1;
3373 } 3390 }
3374 3391
@@ -3384,11 +3401,11 @@ int playlist_save(struct playlist_info* playlist, char *filename)
3384 fd = open(path, O_CREAT|O_WRONLY|O_TRUNC); 3401 fd = open(path, O_CREAT|O_WRONLY|O_TRUNC);
3385 if (fd < 0) 3402 if (fd < 0)
3386 { 3403 {
3387 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_ACCESS_ERROR)); 3404 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_ACCESS_ERROR));
3388 return -1; 3405 return -1;
3389 } 3406 }
3390 3407
3391 display_playlist_count(count, str(LANG_PLAYLIST_SAVE_COUNT)); 3408 display_playlist_count(count, ID2P(LANG_PLAYLIST_SAVE_COUNT), false);
3392 3409
3393 cpu_boost(true); 3410 cpu_boost(true);
3394 3411
@@ -3425,7 +3442,7 @@ int playlist_save(struct playlist_info* playlist, char *filename)
3425 3442
3426 if (fdprintf(fd, "%s\n", tmp_buf) < 0) 3443 if (fdprintf(fd, "%s\n", tmp_buf) < 0)
3427 { 3444 {
3428 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_ACCESS_ERROR)); 3445 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_ACCESS_ERROR));
3429 result = -1; 3446 result = -1;
3430 break; 3447 break;
3431 } 3448 }
@@ -3433,7 +3450,8 @@ int playlist_save(struct playlist_info* playlist, char *filename)
3433 count++; 3450 count++;
3434 3451
3435 if ((count % PLAYLIST_DISPLAY_COUNT) == 0) 3452 if ((count % PLAYLIST_DISPLAY_COUNT) == 0)
3436 display_playlist_count(count, str(LANG_PLAYLIST_SAVE_COUNT)); 3453 display_playlist_count(count, ID2P(LANG_PLAYLIST_SAVE_COUNT),
3454 false);
3437 3455
3438 yield(); 3456 yield();
3439 } 3457 }
@@ -3441,7 +3459,7 @@ int playlist_save(struct playlist_info* playlist, char *filename)
3441 index = (index+1)%playlist->amount; 3459 index = (index+1)%playlist->amount;
3442 } 3460 }
3443 3461
3444 display_playlist_count(count, str(LANG_PLAYLIST_SAVE_COUNT)); 3462 display_playlist_count(count, ID2P(LANG_PLAYLIST_SAVE_COUNT), true);
3445 3463
3446 close(fd); 3464 close(fd);
3447 3465
@@ -3512,7 +3530,7 @@ int playlist_directory_tracksearch(const char* dirname, bool recurse,
3512 3530
3513 if (ft_load(tc, dirname) < 0) 3531 if (ft_load(tc, dirname) < 0)
3514 { 3532 {
3515 gui_syncsplash(HZ*2, str(LANG_PLAYLIST_DIRECTORY_ACCESS_ERROR)); 3533 gui_syncsplash(HZ*2, ID2P(LANG_PLAYLIST_DIRECTORY_ACCESS_ERROR));
3516 *(tc->dirfilter) = old_dirfilter; 3534 *(tc->dirfilter) = old_dirfilter;
3517 return -1; 3535 return -1;
3518 } 3536 }