diff options
author | Hardeep Sidhu <dyp@pobox.com> | 2003-07-06 16:05:44 +0000 |
---|---|---|
committer | Hardeep Sidhu <dyp@pobox.com> | 2003-07-06 16:05:44 +0000 |
commit | 14078864a02665179fcd673aa1fdd50fafa9c563 (patch) | |
tree | 8cae25116f97e995e9b1666bafc7766833f39de1 /apps | |
parent | 9381f14ff9a2b0ef21b62f524d1ad58e5dacfb47 (diff) | |
download | rockbox-14078864a02665179fcd673aa1fdd50fafa9c563.tar.gz rockbox-14078864a02665179fcd673aa1fdd50fafa9c563.zip |
Allow playing even if we are unable to access the playlist control file (e.g. no .rockbox dir). However, dynamic playlists and resume will not work in this case. Also, there are no playlist options for m3u files when nothing is playing.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3813 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/onplay.c | 2 | ||||
-rw-r--r-- | apps/playlist.c | 63 |
2 files changed, 48 insertions, 17 deletions
diff --git a/apps/onplay.c b/apps/onplay.c index 6c6b2eed0b..67793dffea 100644 --- a/apps/onplay.c +++ b/apps/onplay.c | |||
@@ -490,7 +490,7 @@ int onplay(char* file, int attr) | |||
490 | selected_file_attr = attr; | 490 | selected_file_attr = attr; |
491 | 491 | ||
492 | if ((attr & TREE_ATTR_MPA) || (attr & ATTR_DIRECTORY) || | 492 | if ((attr & TREE_ATTR_MPA) || (attr & ATTR_DIRECTORY) || |
493 | (attr & TREE_ATTR_M3U)) | 493 | ((attr & TREE_ATTR_M3U) && (mpeg_status() & MPEG_STATUS_PLAY))) |
494 | { | 494 | { |
495 | menu[i].desc = str(LANG_PLAYINDICES_PLAYLIST); | 495 | menu[i].desc = str(LANG_PLAYINDICES_PLAYLIST); |
496 | menu[i].function = playlist_options; | 496 | menu[i].function = playlist_options; |
diff --git a/apps/playlist.c b/apps/playlist.c index ec3e3cf79b..35f91e4b81 100644 --- a/apps/playlist.c +++ b/apps/playlist.c | |||
@@ -153,12 +153,12 @@ static void empty_playlist(bool resume) | |||
153 | { | 153 | { |
154 | playlist.filename[0] = '\0'; | 154 | playlist.filename[0] = '\0'; |
155 | 155 | ||
156 | if(-1 != playlist.fd) | 156 | if(playlist.fd >= 0) |
157 | /* If there is an already open playlist, close it. */ | 157 | /* If there is an already open playlist, close it. */ |
158 | close(playlist.fd); | 158 | close(playlist.fd); |
159 | playlist.fd = -1; | 159 | playlist.fd = -1; |
160 | 160 | ||
161 | if(-1 != playlist.control_fd) | 161 | if(playlist.control_fd >= 0) |
162 | close(playlist.control_fd); | 162 | close(playlist.control_fd); |
163 | playlist.control_fd = -1; | 163 | playlist.control_fd = -1; |
164 | 164 | ||
@@ -221,7 +221,7 @@ static int add_indices_to_playlist(void) | |||
221 | 221 | ||
222 | if(-1 == playlist.fd) | 222 | if(-1 == playlist.fd) |
223 | playlist.fd = open(playlist.filename, O_RDONLY); | 223 | playlist.fd = open(playlist.filename, O_RDONLY); |
224 | if(-1 == playlist.fd) | 224 | if(playlist.fd < 0) |
225 | return -1; /* failure */ | 225 | return -1; /* failure */ |
226 | 226 | ||
227 | #ifdef HAVE_LCD_BITMAP | 227 | #ifdef HAVE_LCD_BITMAP |
@@ -963,11 +963,8 @@ int playlist_create(char *dir, char *file) | |||
963 | empty_playlist(false); | 963 | empty_playlist(false); |
964 | 964 | ||
965 | playlist.control_fd = open(PLAYLIST_CONTROL_FILE, O_RDWR); | 965 | playlist.control_fd = open(PLAYLIST_CONTROL_FILE, O_RDWR); |
966 | if (-1 == playlist.control_fd) | 966 | if (playlist.control_fd < 0) |
967 | { | ||
968 | splash(HZ*2, 0, true, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); | 967 | splash(HZ*2, 0, true, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); |
969 | return -1; | ||
970 | } | ||
971 | 968 | ||
972 | if (!file) | 969 | if (!file) |
973 | { | 970 | { |
@@ -981,13 +978,13 @@ int playlist_create(char *dir, char *file) | |||
981 | 978 | ||
982 | update_playlist_filename(dir, file); | 979 | update_playlist_filename(dir, file); |
983 | 980 | ||
984 | if (fprintf(playlist.control_fd, "P:%d:%s:%s\n", | 981 | if (playlist.control_fd > 0) |
985 | PLAYLIST_CONTROL_FILE_VERSION, dir, file) > 0) | ||
986 | fsync(playlist.control_fd); | ||
987 | else | ||
988 | { | 982 | { |
989 | splash(HZ*2, 0, true, str(LANG_PLAYLIST_CONTROL_UPDATE_ERROR)); | 983 | if (fprintf(playlist.control_fd, "P:%d:%s:%s\n", |
990 | return -1; | 984 | PLAYLIST_CONTROL_FILE_VERSION, dir, file) > 0) |
985 | fsync(playlist.control_fd); | ||
986 | else | ||
987 | splash(HZ*2, 0, true, str(LANG_PLAYLIST_CONTROL_UPDATE_ERROR)); | ||
991 | } | 988 | } |
992 | 989 | ||
993 | /* load the playlist file */ | 990 | /* load the playlist file */ |
@@ -1029,7 +1026,7 @@ int playlist_resume(void) | |||
1029 | empty_playlist(true); | 1026 | empty_playlist(true); |
1030 | 1027 | ||
1031 | playlist.control_fd = open(PLAYLIST_CONTROL_FILE, O_RDWR); | 1028 | playlist.control_fd = open(PLAYLIST_CONTROL_FILE, O_RDWR); |
1032 | if (-1 == playlist.control_fd) | 1029 | if (playlist.control_fd < 0) |
1033 | { | 1030 | { |
1034 | splash(HZ*2, 0, true, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); | 1031 | splash(HZ*2, 0, true, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); |
1035 | return -1; | 1032 | return -1; |
@@ -1371,7 +1368,15 @@ int playlist_add(char *filename) | |||
1371 | */ | 1368 | */ |
1372 | int playlist_insert_track(char *filename, int position, bool queue) | 1369 | int playlist_insert_track(char *filename, int position, bool queue) |
1373 | { | 1370 | { |
1374 | int result = add_track_to_playlist(filename, position, queue, -1); | 1371 | int result; |
1372 | |||
1373 | if (playlist.control_fd < 0) | ||
1374 | { | ||
1375 | splash(HZ*2, 0, true, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); | ||
1376 | return -1; | ||
1377 | } | ||
1378 | |||
1379 | result = add_track_to_playlist(filename, position, queue, -1); | ||
1375 | 1380 | ||
1376 | if (result != -1) | 1381 | if (result != -1) |
1377 | { | 1382 | { |
@@ -1392,6 +1397,12 @@ int playlist_insert_directory(char *dirname, int position, bool queue, | |||
1392 | int result; | 1397 | int result; |
1393 | char *count_str; | 1398 | char *count_str; |
1394 | 1399 | ||
1400 | if (playlist.control_fd < 0) | ||
1401 | { | ||
1402 | splash(HZ*2, 0, true, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); | ||
1403 | return -1; | ||
1404 | } | ||
1405 | |||
1395 | if (queue) | 1406 | if (queue) |
1396 | count_str = str(LANG_PLAYLIST_QUEUE_COUNT); | 1407 | count_str = str(LANG_PLAYLIST_QUEUE_COUNT); |
1397 | else | 1408 | else |
@@ -1424,6 +1435,12 @@ int playlist_insert_playlist(char *filename, int position, bool queue) | |||
1424 | int count = 0; | 1435 | int count = 0; |
1425 | int result = 0; | 1436 | int result = 0; |
1426 | 1437 | ||
1438 | if (playlist.control_fd < 0) | ||
1439 | { | ||
1440 | splash(HZ*2, 0, true, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); | ||
1441 | return -1; | ||
1442 | } | ||
1443 | |||
1427 | fd = open(filename, O_RDONLY); | 1444 | fd = open(filename, O_RDONLY); |
1428 | if (fd < 0) | 1445 | if (fd < 0) |
1429 | { | 1446 | { |
@@ -1513,7 +1530,15 @@ int playlist_insert_playlist(char *filename, int position, bool queue) | |||
1513 | /* delete track at specified index */ | 1530 | /* delete track at specified index */ |
1514 | int playlist_delete(int index) | 1531 | int playlist_delete(int index) |
1515 | { | 1532 | { |
1516 | int result = remove_track_from_playlist(index, true); | 1533 | int result; |
1534 | |||
1535 | if (playlist.control_fd < 0) | ||
1536 | { | ||
1537 | splash(HZ*2, 0, true, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); | ||
1538 | return -1; | ||
1539 | } | ||
1540 | |||
1541 | result = remove_track_from_playlist(index, true); | ||
1517 | 1542 | ||
1518 | if (result != -1) | 1543 | if (result != -1) |
1519 | mpeg_flush_and_reload_tracks(); | 1544 | mpeg_flush_and_reload_tracks(); |
@@ -1763,6 +1788,12 @@ int playlist_save(char *filename) | |||
1763 | char tmp_buf[MAX_PATH+1]; | 1788 | char tmp_buf[MAX_PATH+1]; |
1764 | int result = 0; | 1789 | int result = 0; |
1765 | 1790 | ||
1791 | if (playlist.control_fd < 0) | ||
1792 | { | ||
1793 | splash(HZ*2, 0, true, str(LANG_PLAYLIST_CONTROL_ACCESS_ERROR)); | ||
1794 | return -1; | ||
1795 | } | ||
1796 | |||
1766 | if (playlist.amount <= 0) | 1797 | if (playlist.amount <= 0) |
1767 | return -1; | 1798 | return -1; |
1768 | 1799 | ||