mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-14 23:52:26 -05:00
Search In Playlist
* Add a title to the list of search results. * Fix drawing of the statusbar. * Avoid splashing in every iteration of the search loop if no new hits, gives about 10x speedup on h300 when searching for a string that gives 30 hits in a playlist of 3000 tracks. * Boost cpu when searching, ~doubles the search speed. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18764 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
bea3abb5c3
commit
da01219ca2
2 changed files with 40 additions and 15 deletions
|
|
@ -12095,3 +12095,17 @@
|
||||||
recording_swcodec: "Mono mode"
|
recording_swcodec: "Mono mode"
|
||||||
</voice>
|
</voice>
|
||||||
</phrase>
|
</phrase>
|
||||||
|
<phrase>
|
||||||
|
id: LANG_SEARCH_RESULTS
|
||||||
|
desc: in sound_settings
|
||||||
|
user:
|
||||||
|
<source>
|
||||||
|
*: "Search Results"
|
||||||
|
</source>
|
||||||
|
<dest>
|
||||||
|
*: "Search Results"
|
||||||
|
</dest>
|
||||||
|
<voice>
|
||||||
|
*: "Search Results"
|
||||||
|
</voice>
|
||||||
|
</phrase>
|
||||||
|
|
|
||||||
|
|
@ -782,48 +782,60 @@ bool search_playlist(void)
|
||||||
char search_str[32] = "";
|
char search_str[32] = "";
|
||||||
bool ret = false, exit = false;
|
bool ret = false, exit = false;
|
||||||
int i, playlist_count;
|
int i, playlist_count;
|
||||||
int found_indicies[MAX_PLAYLIST_ENTRIES],found_indicies_count = 0;
|
int found_indicies[MAX_PLAYLIST_ENTRIES];
|
||||||
|
int found_indicies_count = 0, last_found_count = -1;
|
||||||
int button;
|
int button;
|
||||||
struct gui_synclist playlist_lists;
|
struct gui_synclist playlist_lists;
|
||||||
struct playlist_track_info track;
|
struct playlist_track_info track;
|
||||||
|
|
||||||
if (!playlist_viewer_init(&viewer, 0, false))
|
if (!playlist_viewer_init(&viewer, 0, false))
|
||||||
return ret;
|
return ret;
|
||||||
if (kbd_input(search_str,sizeof(search_str)) == -1)
|
if (kbd_input(search_str, sizeof(search_str)) == -1)
|
||||||
return ret;
|
return ret;
|
||||||
lcd_clear_display();
|
lcd_clear_display();
|
||||||
playlist_count = playlist_amount_ex(viewer.playlist);
|
playlist_count = playlist_amount_ex(viewer.playlist);
|
||||||
for (i=0;(i<playlist_count)&&(found_indicies_count<MAX_PLAYLIST_ENTRIES);i++)
|
|
||||||
|
cpu_boost(true);
|
||||||
|
|
||||||
|
for (i=0; (i<playlist_count)&&(found_indicies_count<MAX_PLAYLIST_ENTRIES); i++)
|
||||||
{
|
{
|
||||||
splashf(0, str(LANG_PLAYLIST_SEARCH_MSG), found_indicies_count,
|
if (found_indicies_count != last_found_count)
|
||||||
str(LANG_OFF_ABORT));
|
{
|
||||||
|
splashf(0, str(LANG_PLAYLIST_SEARCH_MSG), found_indicies_count,
|
||||||
|
str(LANG_OFF_ABORT));
|
||||||
|
last_found_count = found_indicies_count;
|
||||||
|
}
|
||||||
|
|
||||||
if (action_userabort(TIMEOUT_NOBLOCK))
|
if (action_userabort(TIMEOUT_NOBLOCK))
|
||||||
{
|
|
||||||
if (!found_indicies_count)
|
|
||||||
return ret;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
playlist_get_track_info(viewer.playlist,i,&track);
|
playlist_get_track_info(viewer.playlist, i, &track);
|
||||||
|
|
||||||
if (strcasestr(track.filename,search_str))
|
if (strcasestr(track.filename,search_str))
|
||||||
{
|
|
||||||
found_indicies[found_indicies_count++] = track.index;
|
found_indicies[found_indicies_count++] = track.index;
|
||||||
}
|
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cpu_boost(false);
|
||||||
|
|
||||||
if (!found_indicies_count)
|
if (!found_indicies_count)
|
||||||
{
|
{
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
backlight_on();
|
backlight_on();
|
||||||
|
|
||||||
gui_synclist_init(&playlist_lists, playlist_search_callback_name,
|
gui_synclist_init(&playlist_lists, playlist_search_callback_name,
|
||||||
found_indicies, false, 1, NULL);
|
found_indicies, false, 1, NULL);
|
||||||
|
gui_synclist_set_title(&playlist_lists, str(LANG_SEARCH_RESULTS), NOICON);
|
||||||
gui_synclist_set_icon_callback(&playlist_lists, NULL);
|
gui_synclist_set_icon_callback(&playlist_lists, NULL);
|
||||||
gui_synclist_set_nb_items(&playlist_lists, found_indicies_count);
|
gui_synclist_set_nb_items(&playlist_lists, found_indicies_count);
|
||||||
gui_synclist_select_item(&playlist_lists, 0);
|
gui_synclist_select_item(&playlist_lists, 0);
|
||||||
gui_synclist_draw(&playlist_lists);
|
gui_synclist_draw(&playlist_lists);
|
||||||
while (!exit)
|
while (!exit)
|
||||||
{
|
{
|
||||||
button = get_action(CONTEXT_LIST,TIMEOUT_BLOCK);
|
gui_syncstatusbar_draw(&statusbars, false);
|
||||||
|
button = get_action(CONTEXT_LIST, HZ/4);
|
||||||
if (gui_synclist_do_button(&playlist_lists, &button, LIST_WRAP_UNLESS_HELD))
|
if (gui_synclist_do_button(&playlist_lists, &button, LIST_WRAP_UNLESS_HELD))
|
||||||
continue;
|
continue;
|
||||||
switch (button)
|
switch (button)
|
||||||
|
|
@ -838,8 +850,7 @@ bool search_playlist(void)
|
||||||
,0);
|
,0);
|
||||||
exit = 1;
|
exit = 1;
|
||||||
break;
|
break;
|
||||||
case ACTION_NONE:
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
if(default_event_handler(button) == SYS_USB_CONNECTED)
|
if(default_event_handler(button) == SYS_USB_CONNECTED)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue