diff options
author | Christian Soffke <christian.soffke@gmail.com> | 2024-11-09 23:17:09 +0100 |
---|---|---|
committer | Christian Soffke <christian.soffke@gmail.com> | 2024-12-16 00:20:10 +0100 |
commit | 8f5128da16066638a9b381a2fb1ab10c873dbf1b (patch) | |
tree | f71d14cefc0bf04c23ef28c365b77cd830a97a22 | |
parent | 4062a6aefca73b051448eff125b0069fdcc00732 (diff) | |
download | rockbox-8f5128da16.tar.gz rockbox-8f5128da16.zip |
Show Track Info: Support fs tags in Playlist Viewer, Properties, and PictureFlow
Playlist Viewer falls back to splashf if there is not
enough plugin buffer space left for running the
view_text plugin .
Change-Id: I418731018b03f396270b68e5e2d2e69635df1af0
-rw-r--r-- | apps/gui/wps.c | 2 | ||||
-rw-r--r-- | apps/onplay.c | 2 | ||||
-rw-r--r-- | apps/playlist_viewer.c | 49 | ||||
-rw-r--r-- | apps/plugin.h | 5 | ||||
-rw-r--r-- | apps/plugins/CATEGORIES | 2 | ||||
-rw-r--r-- | apps/plugins/SOURCES | 2 | ||||
-rw-r--r-- | apps/plugins/pictureflow/pictureflow.c | 3 | ||||
-rw-r--r-- | apps/plugins/properties.c | 12 | ||||
-rw-r--r-- | apps/plugins/view_text.c | 2 | ||||
-rw-r--r-- | apps/screens.c | 23 | ||||
-rw-r--r-- | apps/screens.h | 6 |
11 files changed, 85 insertions, 23 deletions
diff --git a/apps/gui/wps.c b/apps/gui/wps.c index 51d23f230d..4e0911f7fd 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c @@ -1044,7 +1044,7 @@ long gui_wps_show(void) gwps_leave_wps(true); if (browse_id3(audio_current_track(), playlist_get_display_index(), - playlist_amount(), NULL, 1)) + playlist_amount(), NULL, 1, NULL)) return GO_TO_ROOT; restore = true; } diff --git a/apps/onplay.c b/apps/onplay.c index a259e88c58..5136151c90 100644 --- a/apps/onplay.c +++ b/apps/onplay.c @@ -700,7 +700,7 @@ static int browse_id3_wrapper(void) if (browse_id3(audio_current_track(), playlist_get_display_index(), - playlist_amount(), NULL, 1)) + playlist_amount(), NULL, 1, NULL)) return GO_TO_ROOT; return GO_TO_PREVIOUS; } diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c index a373428639..75efc27ce5 100644 --- a/apps/playlist_viewer.c +++ b/apps/playlist_viewer.c @@ -55,6 +55,13 @@ /* Maximum number of tracks we can have loaded at one time */ #define MAX_PLAYLIST_ENTRIES 200 +/* Maximum amount of space required for the name buffer. For each + entry, we store the file name as well as, possibly, metadata */ +#define MAX_NAME_BUFFER_SZ (MAX_PLAYLIST_ENTRIES * 2 * MAX_PATH) + +/* Over-approximation of view_text plugin size */ +#define VIEW_TEXT_PLUGIN_SZ 5000 + /* The number of items between the selected one and the end/start of * the buffer under which the buffer must reload */ #define MIN_BUFFER_MARGIN (screens[0].getnblines()+1) @@ -116,6 +123,7 @@ struct playlist_viewer { viewer-relative index) of moving track */ struct playlist_buffer buffer; struct mp3entry *id3; + bool allow_view_text_plugin; }; struct playlist_search_data @@ -392,6 +400,28 @@ static bool playlist_viewer_init(struct playlist_viewer * viewer, if (!buffer || buffer_size <= MAX_PATH + id3_size) return false; + /* Index buffer is required, unless playback is stopped or we're + showing the current playlist (i.e. filename == NULL) */ + if (filename && is_playing) + index_buffer_size = playlist_get_index_bufsz(buffer_size - id3_size - (MAX_PATH + 1)); + + /* Check for unused space in the plugin buffer to run + the view_text plugin used by the Track Info screen: + ┌───────┬───────────────────────────────────────────────────────┐ + │ │<----------------- plugin_get_buffer ----------------->│ + │ (TSR ├───────────────┬─────┬──────────────┬───────────────┐ │ + │plugin)│██ view_text ██│ id3 │ index buffer │ name buffer │ │ + └───────┴───────────────┴─────┴──────────────┴───────────────┴──┘ + */ + if (buffer_size >= VIEW_TEXT_PLUGIN_SZ + id3_size + index_buffer_size + MAX_NAME_BUFFER_SZ) + { + buffer += VIEW_TEXT_PLUGIN_SZ; + buffer_size -= VIEW_TEXT_PLUGIN_SZ; + viewer->allow_view_text_plugin = true; + } + else + viewer->allow_view_text_plugin = false; + viewer->id3 = (void *) buffer; buffer += id3_size; buffer_size -= id3_size; @@ -425,8 +455,6 @@ static bool playlist_viewer_init(struct playlist_viewer * viewer, if (is_playing) { index_buffer = buffer; - index_buffer_size = playlist_get_index_bufsz(buffer_size - (MAX_PATH + 1)); - buffer += index_buffer_size; buffer_size -= index_buffer_size; } @@ -577,15 +605,28 @@ static void format_line(struct playlist_entry* track, char* str, } } +/* Fallback for displaying fullscreen tags, in case there is not + * enough plugin buffer space left to call the view_text plugin + * from the Track Info screen + */ +static int view_text(const char *title, const char *text) +{ + splashf(0, "[%s]\n%s", title, text); + action_userabort(TIMEOUT_BLOCK); + return 0; +} + static enum pv_onplay_result show_track_info(const struct playlist_entry *current_track) { bool id3_retrieval_successful = retrieve_id3_tags(current_track->index, current_track->name, viewer.id3, 0); - return id3_retrieval_successful && + return (id3_retrieval_successful && browse_id3_ex(viewer.id3, viewer.playlist, current_track->display_index, - viewer.num_tracks, NULL, 1) ? PV_ONPLAY_USB : PV_ONPLAY_UNCHANGED; + viewer.num_tracks, NULL, 1, + viewer.allow_view_text_plugin ? NULL : &view_text)) ? + PV_ONPLAY_USB : PV_ONPLAY_UNCHANGED; } static void close_playlist_viewer(void) diff --git a/apps/plugin.h b/apps/plugin.h index 0997b73a08..d7b5cff69b 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -174,7 +174,7 @@ int plugin_open(const char *plugin, const char *parameter); * when this happens please take the opportunity to sort in * any new functions "waiting" at the end of the list. */ -#define PLUGIN_API_VERSION 272 +#define PLUGIN_API_VERSION 273 /* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */ @@ -513,7 +513,8 @@ struct plugin_api { void (*add_to_pl_cb)); bool (*browse_id3)(struct mp3entry *id3, int playlist_display_index, int playlist_amount, - struct tm *modified, int track_ct); + struct tm *modified, int track_ct, + int (*view_text)(const char *title, const char *text)); /* talking */ int (*talk_id)(int32_t id, bool enqueue); diff --git a/apps/plugins/CATEGORIES b/apps/plugins/CATEGORIES index 23a7df6fbf..c9b1781a15 100644 --- a/apps/plugins/CATEGORIES +++ b/apps/plugins/CATEGORIES @@ -207,4 +207,4 @@ xobox,games xrick,games xworld,games zxbox,viewers -view_text,viewers
\ No newline at end of file +view_text,viewers diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index 8dbdc436c6..8e263b3ac9 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES @@ -238,4 +238,4 @@ test_touchscreen.c #endif test_usb.c test_viewports.c -#endif /* HAVE_TEST_PLUGINS */
\ No newline at end of file +#endif /* HAVE_TEST_PLUGINS */ diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 726a6bc898..b9a29d2814 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c @@ -33,6 +33,7 @@ #include "lib/grey.h" #include "lib/mylcd.h" #include "lib/feature_wrappers.h" +#include "lib/simple_viewer.h" /******************************* Globals ***********************************/ static fb_data *lcd_fb; @@ -4082,7 +4083,7 @@ static int show_id3_info(const char *selected_file) if (is_multiple_tracks) finalize_id3(&id3); - return rb->browse_id3(&id3, 0, 0, NULL, i) ? PLUGIN_USB_CONNECTED : 0; + return rb->browse_id3(&id3, 0, 0, NULL, i, &view_text) ? PLUGIN_USB_CONNECTED : 0; } diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c index dcd3d89edf..18ce2174c4 100644 --- a/apps/plugins/properties.c +++ b/apps/plugins/properties.c @@ -20,6 +20,7 @@ ****************************************************************************/ #include "plugin.h" #include "lib/mul_id3.h" +#include "lib/simple_viewer.h" #if !defined(ARRAY_SIZE) #define ARRAY_SIZE(x) (sizeof((x)) / sizeof((x)[0])) @@ -339,12 +340,15 @@ enum plugin_status plugin_start(const void* parameter) } } else if (props_type == PROPS_ID3) - ret = rb->browse_id3(&id3, 0, 0, &tm, 1); /* Track Info for single file */ + /* Track Info for single file */ + ret = rb->browse_id3(&id3, 0, 0, &tm, 1, &view_text); else if (props_type == PROPS_MUL_ID3) - ret = rb->browse_id3(&id3, 0, 0, NULL, mul_id3_count); /* database tracks */ + /* database tracks */ + ret = rb->browse_id3(&id3, 0, 0, NULL, mul_id3_count, &view_text); else if ((ret = browse_file_or_dir(&stats)) < 0) - ret = assemble_track_info(file, &stats) ? /* playlist or folder tracks */ - rb->browse_id3(&id3, 0, 0, NULL, mul_id3_count) : + ret = assemble_track_info(file, &stats) ? + /* playlist or folder tracks */ + rb->browse_id3(&id3, 0, 0, NULL, mul_id3_count, &view_text) : (stats.canceled ? 0 : -1); return ret == -1 ? PLUGIN_ERROR : ret == 1 ? PLUGIN_USB_CONNECTED : PLUGIN_OK; diff --git a/apps/plugins/view_text.c b/apps/plugins/view_text.c index 7ce7b5215f..a6ee5f4d0f 100644 --- a/apps/plugins/view_text.c +++ b/apps/plugins/view_text.c @@ -28,7 +28,7 @@ /* this is the plugin entry point */ enum plugin_status plugin_start(const void* parameter) { - + char** title_and_text = (char**)parameter; view_text(title_and_text[0], title_and_text[1]); return PLUGIN_OK; diff --git a/apps/screens.c b/apps/screens.c index 278ac350b7..c1c5b1fde7 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -777,7 +777,8 @@ static int id3_speak_item(int selected_item, void* data) */ bool browse_id3_ex(struct mp3entry *id3, struct playlist_info *playlist, int playlist_display_index, int playlist_amount, - struct tm *modified, int track_ct) + struct tm *modified, int track_ct, + int (*view_text)(const char *title, const char *text)) { struct gui_synclist id3_lists; int key; @@ -824,7 +825,18 @@ refresh_info: char buffer[MAX_PATH]; title_and_text[1] = (char*)id3_get_or_speak_info(id3_lists.selected_item+1,&info, buffer, sizeof(buffer), false); - plugin_load(VIEWERS_DIR"/view_text.rock", title_and_text); + + if (view_text) + { + FOR_NB_SCREENS(i) + viewportmanager_theme_enable(i, false, NULL); + view_text(title_and_text[0], title_and_text[1]); + FOR_NB_SCREENS(i) + viewportmanager_theme_undo(i, false); + } + else + plugin_load(VIEWERS_DIR"/view_text.rock", title_and_text); + gui_synclist_set_title(&id3_lists, str(LANG_TRACK_INFO), NOICON); gui_synclist_draw(&id3_lists); continue; } @@ -839,7 +851,7 @@ refresh_info: ret = true; break; } - } + } else if (is_curr_track_info) { if (!audio_status()) @@ -861,10 +873,11 @@ refresh_info: } bool browse_id3(struct mp3entry *id3, int playlist_display_index, int playlist_amount, - struct tm *modified, int track_ct) + struct tm *modified, int track_ct, + int (*view_text)(const char *title, const char *text)) { return browse_id3_ex(id3, NULL, playlist_display_index, playlist_amount, - modified, track_ct); + modified, track_ct, view_text); } static const char* runtime_get_data(int selected_item, void* data, diff --git a/apps/screens.h b/apps/screens.h index c3925f8ebc..690f89157e 100644 --- a/apps/screens.h +++ b/apps/screens.h @@ -45,10 +45,12 @@ bool set_time_screen(const char* title, struct tm *tm, bool set_date); #ifndef WARBLE bool browse_id3_ex(struct mp3entry *id3, struct playlist_info *playlist, int playlist_display_index, int playlist_amount, - struct tm *modified, int track_ct); + struct tm *modified, int track_ct, + int (*view_text)(const char *title, const char *text)); #endif bool browse_id3(struct mp3entry *id3, int playlist_display_index, int playlist_amount, - struct tm *modified, int track_ct); + struct tm *modified, int track_ct, + int (*view_text)(const char *title, const char *text)); int view_runtime(void); #ifdef HAVE_TOUCHSCREEN |