diff options
author | Stéphane Doyon <s.doyon@videotron.ca> | 2008-07-15 16:10:15 +0000 |
---|---|---|
committer | Stéphane Doyon <s.doyon@videotron.ca> | 2008-07-15 16:10:15 +0000 |
commit | bd06769ba2cde7875cc06fb73a3d167f4c0bea04 (patch) | |
tree | d654e7d44c0f945b385c2540da2085fbf6f761c6 /apps | |
parent | 91bfc4ca9589d324e5ead72c1fbf641151527e33 (diff) | |
download | rockbox-bd06769ba2cde7875cc06fb73a3d167f4c0bea04.tar.gz rockbox-bd06769ba2cde7875cc06fb73a3d167f4c0bea04.zip |
Improved voice feedback in bookmark selection.
Accept FS#6240 (with minor changes).
Speak directory or playlist name in recent bookmarks. Speak shuffle status,
and filename.
Simplify the button loop by using a voice list callback.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18051 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/bookmark.c | 112 |
1 files changed, 70 insertions, 42 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c index f968c5e1e8..0ab78cd83f 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c | |||
@@ -68,7 +68,7 @@ static bool check_bookmark(const char* bookmark); | |||
68 | static char* create_bookmark(void); | 68 | static char* create_bookmark(void); |
69 | static bool delete_bookmark(const char* bookmark_file_name, int bookmark_id); | 69 | static bool delete_bookmark(const char* bookmark_file_name, int bookmark_id); |
70 | static void say_bookmark(const char* bookmark, | 70 | static void say_bookmark(const char* bookmark, |
71 | int bookmark_id); | 71 | int bookmark_id, bool show_playlist_name); |
72 | static bool play_bookmark(const char* bookmark); | 72 | static bool play_bookmark(const char* bookmark); |
73 | static bool generate_bookmark_file_name(const char *in); | 73 | static bool generate_bookmark_file_name(const char *in); |
74 | static const char* skip_token(const char* s); | 74 | static const char* skip_token(const char* s); |
@@ -634,6 +634,22 @@ static char* get_bookmark_info(int list_index, | |||
634 | } | 634 | } |
635 | } | 635 | } |
636 | 636 | ||
637 | static int bookmark_list_voice_cb(int list_index, void* data) | ||
638 | { | ||
639 | struct bookmark_list* bookmarks = (struct bookmark_list*) data; | ||
640 | int index = list_index / 2; | ||
641 | |||
642 | if (bookmarks->show_dont_resume) | ||
643 | { | ||
644 | if (index == 0) | ||
645 | return talk_id(LANG_BOOKMARK_DONT_RESUME, false); | ||
646 | index--; | ||
647 | } | ||
648 | say_bookmark(bookmarks->items[index - bookmarks->start], index, | ||
649 | bookmarks->show_playlist_name); | ||
650 | return 0; | ||
651 | } | ||
652 | |||
637 | /* ----------------------------------------------------------------------- */ | 653 | /* ----------------------------------------------------------------------- */ |
638 | /* This displays a the bookmarks in a file and allows the user to */ | 654 | /* This displays a the bookmarks in a file and allows the user to */ |
639 | /* select one to play. */ | 655 | /* select one to play. */ |
@@ -642,7 +658,6 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu | |||
642 | { | 658 | { |
643 | struct bookmark_list* bookmarks; | 659 | struct bookmark_list* bookmarks; |
644 | struct gui_synclist list; | 660 | struct gui_synclist list; |
645 | int last_item = -2; | ||
646 | int item = 0; | 661 | int item = 0; |
647 | int action; | 662 | int action; |
648 | size_t size; | 663 | size_t size; |
@@ -657,6 +672,8 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu | |||
657 | bookmarks->show_playlist_name | 672 | bookmarks->show_playlist_name |
658 | = strcmp(bookmark_file_name, RECENT_BOOKMARK_FILE) == 0; | 673 | = strcmp(bookmark_file_name, RECENT_BOOKMARK_FILE) == 0; |
659 | gui_synclist_init(&list, &get_bookmark_info, (void*) bookmarks, false, 2, NULL); | 674 | gui_synclist_init(&list, &get_bookmark_info, (void*) bookmarks, false, 2, NULL); |
675 | if(global_settings.talk_menu) | ||
676 | gui_synclist_set_voice_callback(&list, bookmark_list_voice_cb); | ||
660 | gui_synclist_set_title(&list, str(LANG_BOOKMARK_SELECT_BOOKMARK), | 677 | gui_synclist_set_title(&list, str(LANG_BOOKMARK_SELECT_BOOKMARK), |
661 | Icon_Bookmark); | 678 | Icon_Bookmark); |
662 | gui_syncstatusbar_draw(&statusbars, true); | 679 | gui_syncstatusbar_draw(&statusbars, true); |
@@ -695,32 +712,20 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu | |||
695 | 712 | ||
696 | buffer_bookmarks(bookmarks, bookmarks->start); | 713 | buffer_bookmarks(bookmarks, bookmarks->start); |
697 | gui_synclist_draw(&list); | 714 | gui_synclist_draw(&list); |
715 | cond_talk_ids_fq(VOICE_EXT_BMARK); | ||
716 | gui_synclist_speak_item(&list); | ||
698 | refresh = false; | 717 | refresh = false; |
699 | } | 718 | } |
700 | 719 | ||
701 | action = get_action(CONTEXT_BOOKMARKSCREEN, HZ / 2); | 720 | list_do_action(CONTEXT_BOOKMARKSCREEN, HZ / 2, |
702 | gui_synclist_do_button(&list, &action, LIST_WRAP_UNLESS_HELD); | 721 | &list, &action, LIST_WRAP_UNLESS_HELD); |
703 | item = gui_synclist_get_sel_pos(&list) / 2; | 722 | item = gui_synclist_get_sel_pos(&list) / 2; |
704 | 723 | ||
705 | if (bookmarks->show_dont_resume) | 724 | if (bookmarks->show_dont_resume) |
706 | { | 725 | { |
707 | item--; | 726 | item--; |
708 | } | 727 | } |
709 | 728 | ||
710 | if (item != last_item && global_settings.talk_menu) | ||
711 | { | ||
712 | last_item = item; | ||
713 | |||
714 | if (item == -1) | ||
715 | { | ||
716 | talk_id(LANG_BOOKMARK_DONT_RESUME, true); | ||
717 | } | ||
718 | else | ||
719 | { | ||
720 | say_bookmark(bookmarks->items[item - bookmarks->start], item); | ||
721 | } | ||
722 | } | ||
723 | |||
724 | if (action == ACTION_STD_CONTEXT) | 729 | if (action == ACTION_STD_CONTEXT) |
725 | { | 730 | { |
726 | MENUITEM_STRINGLIST(menu_items, ID2P(LANG_BOOKMARK_CONTEXT_MENU), | 731 | MENUITEM_STRINGLIST(menu_items, ID2P(LANG_BOOKMARK_CONTEXT_MENU), |
@@ -746,6 +751,7 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu | |||
746 | case ACTION_STD_OK: | 751 | case ACTION_STD_OK: |
747 | if (item >= 0) | 752 | if (item >= 0) |
748 | { | 753 | { |
754 | talk_shutup(); | ||
749 | return bookmarks->items[item - bookmarks->start]; | 755 | return bookmarks->items[item - bookmarks->start]; |
750 | } | 756 | } |
751 | 757 | ||
@@ -762,7 +768,6 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu | |||
762 | delete_bookmark(bookmark_file_name, item); | 768 | delete_bookmark(bookmark_file_name, item); |
763 | bookmarks->reload = true; | 769 | bookmarks->reload = true; |
764 | refresh = true; | 770 | refresh = true; |
765 | last_item = -2; | ||
766 | } | 771 | } |
767 | break; | 772 | break; |
768 | 773 | ||
@@ -776,6 +781,7 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu | |||
776 | } | 781 | } |
777 | } | 782 | } |
778 | 783 | ||
784 | talk_shutup(); | ||
779 | return NULL; | 785 | return NULL; |
780 | } | 786 | } |
781 | 787 | ||
@@ -827,41 +833,63 @@ static bool delete_bookmark(const char* bookmark_file_name, int bookmark_id) | |||
827 | /* This function parses a bookmark, says the voice UI part of it. */ | 833 | /* This function parses a bookmark, says the voice UI part of it. */ |
828 | /* ------------------------------------------------------------------------*/ | 834 | /* ------------------------------------------------------------------------*/ |
829 | static void say_bookmark(const char* bookmark, | 835 | static void say_bookmark(const char* bookmark, |
830 | int bookmark_id) | 836 | int bookmark_id, bool show_playlist_name) |
831 | { | 837 | { |
832 | int resume_index; | 838 | int resume_index; |
833 | long ms; | 839 | long ms; |
834 | bool enqueue = false; /* only the first voice is not queued */ | 840 | bool playlist_shuffle = false; |
841 | bool is_dir; | ||
835 | 842 | ||
836 | if (!parse_bookmark(bookmark, &resume_index, NULL, NULL, NULL, | 843 | if (!parse_bookmark(bookmark, &resume_index, NULL, NULL, NULL, |
837 | global_temp_buffer, sizeof(global_temp_buffer), &ms, NULL, NULL, NULL)) | 844 | global_temp_buffer,sizeof(global_temp_buffer), |
845 | &ms, NULL, &playlist_shuffle, | ||
846 | global_filename)) | ||
838 | { | 847 | { |
839 | talk_id(LANG_BOOKMARK_INVALID, true); | 848 | talk_id(LANG_BOOKMARK_INVALID, false); |
840 | return; | 849 | return; |
841 | } | 850 | } |
842 | 851 | ||
843 | /* disabled, because transition between talkbox and voice UI clip is not nice */ | 852 | talk_number(bookmark_id + 1, false); |
844 | #if 0 | 853 | |
845 | if (global_settings.talk_dir >= 3) | 854 | is_dir = (global_temp_buffer[0] |
846 | { /* "talkbox" enabled */ | 855 | && global_temp_buffer[strlen(global_temp_buffer)-1] == '/'); |
847 | char* last = strrchr(global_temp_buffer, '/'); | 856 | #if CONFIG_CODEC == SWCODEC |
848 | if (last) | 857 | /* HWCODEC cannot enqueue voice file entries and .talk thumbnails |
849 | { /* compose filename for talkbox */ | 858 | together, because there is no guarantee that the same mp3 |
850 | strncpy(last + 1, dir_thumbnail_name, | 859 | parameters are used. */ |
851 | sizeof(global_temp_buffer) - (last - global_temp_buffer) - 1); | 860 | if(show_playlist_name) |
852 | talk_file(global_temp_buffer, enqueue); | 861 | { /* It's useful to know which playlist this is */ |
853 | enqueue = true; | 862 | if(is_dir) |
854 | } | 863 | talk_dir_or_spell(global_temp_buffer, |
864 | TALK_IDARRAY(VOICE_DIR), true); | ||
865 | else talk_file_or_spell(NULL, global_temp_buffer, | ||
866 | TALK_IDARRAY(LANG_PLAYLIST), true); | ||
855 | } | 867 | } |
868 | #else | ||
869 | (void)show_playlist_name; | ||
856 | #endif | 870 | #endif |
857 | talk_id(VOICE_EXT_BMARK, enqueue); | 871 | |
858 | talk_number(bookmark_id + 1, true); | 872 | if(playlist_shuffle) |
873 | talk_id(LANG_SHUFFLE, true); | ||
874 | |||
859 | talk_id(VOICE_BOOKMARK_SELECT_INDEX_TEXT, true); | 875 | talk_id(VOICE_BOOKMARK_SELECT_INDEX_TEXT, true); |
860 | talk_number(resume_index + 1, true); | 876 | talk_number(resume_index + 1, true); |
861 | talk_id(LANG_TIME, true); | 877 | talk_id(LANG_TIME, true); |
862 | if (ms / 60000) | 878 | talk_value(ms / 1000, UNIT_TIME, true); |
863 | talk_value(ms / 60000, UNIT_MIN, true); | 879 | |
864 | talk_value((ms % 60000) / 1000, UNIT_SEC, true); | 880 | #if CONFIG_CODEC == SWCODEC |
881 | /* Track filename */ | ||
882 | if(is_dir) | ||
883 | talk_file_or_spell(global_temp_buffer, global_filename, | ||
884 | TALK_IDARRAY(VOICE_FILE), true); | ||
885 | else | ||
886 | { /* Unfortunately if this is a playlist, we do not know in which | ||
887 | directory the file is and therefore cannot find the track's | ||
888 | .talk file. */ | ||
889 | talk_id(VOICE_FILE, true); | ||
890 | talk_spell(global_filename, true); | ||
891 | } | ||
892 | #endif | ||
865 | } | 893 | } |
866 | 894 | ||
867 | /* ----------------------------------------------------------------------- */ | 895 | /* ----------------------------------------------------------------------- */ |