1
0
Fork 0
forked from len0rd/rockbox

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
This commit is contained in:
Christian Soffke 2024-11-09 23:17:09 +01:00
parent 4062a6aefc
commit 8f5128da16
11 changed files with 85 additions and 23 deletions

View file

@ -1044,7 +1044,7 @@ long gui_wps_show(void)
gwps_leave_wps(true); gwps_leave_wps(true);
if (browse_id3(audio_current_track(), if (browse_id3(audio_current_track(),
playlist_get_display_index(), playlist_get_display_index(),
playlist_amount(), NULL, 1)) playlist_amount(), NULL, 1, NULL))
return GO_TO_ROOT; return GO_TO_ROOT;
restore = true; restore = true;
} }

View file

@ -700,7 +700,7 @@ static int browse_id3_wrapper(void)
if (browse_id3(audio_current_track(), if (browse_id3(audio_current_track(),
playlist_get_display_index(), playlist_get_display_index(),
playlist_amount(), NULL, 1)) playlist_amount(), NULL, 1, NULL))
return GO_TO_ROOT; return GO_TO_ROOT;
return GO_TO_PREVIOUS; return GO_TO_PREVIOUS;
} }

View file

@ -55,6 +55,13 @@
/* Maximum number of tracks we can have loaded at one time */ /* Maximum number of tracks we can have loaded at one time */
#define MAX_PLAYLIST_ENTRIES 200 #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 number of items between the selected one and the end/start of
* the buffer under which the buffer must reload */ * the buffer under which the buffer must reload */
#define MIN_BUFFER_MARGIN (screens[0].getnblines()+1) #define MIN_BUFFER_MARGIN (screens[0].getnblines()+1)
@ -116,6 +123,7 @@ struct playlist_viewer {
viewer-relative index) of moving track */ viewer-relative index) of moving track */
struct playlist_buffer buffer; struct playlist_buffer buffer;
struct mp3entry *id3; struct mp3entry *id3;
bool allow_view_text_plugin;
}; };
struct playlist_search_data 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) if (!buffer || buffer_size <= MAX_PATH + id3_size)
return false; 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; viewer->id3 = (void *) buffer;
buffer += id3_size; buffer += id3_size;
buffer_size -= id3_size; buffer_size -= id3_size;
@ -425,8 +455,6 @@ static bool playlist_viewer_init(struct playlist_viewer * viewer,
if (is_playing) if (is_playing)
{ {
index_buffer = buffer; index_buffer = buffer;
index_buffer_size = playlist_get_index_bufsz(buffer_size - (MAX_PATH + 1));
buffer += index_buffer_size; buffer += index_buffer_size;
buffer_size -= 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) static enum pv_onplay_result show_track_info(const struct playlist_entry *current_track)
{ {
bool id3_retrieval_successful = retrieve_id3_tags(current_track->index, bool id3_retrieval_successful = retrieve_id3_tags(current_track->index,
current_track->name, current_track->name,
viewer.id3, 0); viewer.id3, 0);
return id3_retrieval_successful && return (id3_retrieval_successful &&
browse_id3_ex(viewer.id3, viewer.playlist, current_track->display_index, 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) static void close_playlist_viewer(void)

View file

@ -174,7 +174,7 @@ int plugin_open(const char *plugin, const char *parameter);
* when this happens please take the opportunity to sort in * when this happens please take the opportunity to sort in
* any new functions "waiting" at the end of the list. * 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 */ /* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */
@ -513,7 +513,8 @@ struct plugin_api {
void (*add_to_pl_cb)); void (*add_to_pl_cb));
bool (*browse_id3)(struct mp3entry *id3, bool (*browse_id3)(struct mp3entry *id3,
int playlist_display_index, int playlist_amount, 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 */ /* talking */
int (*talk_id)(int32_t id, bool enqueue); int (*talk_id)(int32_t id, bool enqueue);

View file

@ -33,6 +33,7 @@
#include "lib/grey.h" #include "lib/grey.h"
#include "lib/mylcd.h" #include "lib/mylcd.h"
#include "lib/feature_wrappers.h" #include "lib/feature_wrappers.h"
#include "lib/simple_viewer.h"
/******************************* Globals ***********************************/ /******************************* Globals ***********************************/
static fb_data *lcd_fb; static fb_data *lcd_fb;
@ -4082,7 +4083,7 @@ static int show_id3_info(const char *selected_file)
if (is_multiple_tracks) if (is_multiple_tracks)
finalize_id3(&id3); 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;
} }

View file

@ -20,6 +20,7 @@
****************************************************************************/ ****************************************************************************/
#include "plugin.h" #include "plugin.h"
#include "lib/mul_id3.h" #include "lib/mul_id3.h"
#include "lib/simple_viewer.h"
#if !defined(ARRAY_SIZE) #if !defined(ARRAY_SIZE)
#define ARRAY_SIZE(x) (sizeof((x)) / sizeof((x)[0])) #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) 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) 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) else if ((ret = browse_file_or_dir(&stats)) < 0)
ret = assemble_track_info(file, &stats) ? /* playlist or folder tracks */ ret = assemble_track_info(file, &stats) ?
rb->browse_id3(&id3, 0, 0, NULL, mul_id3_count) : /* playlist or folder tracks */
rb->browse_id3(&id3, 0, 0, NULL, mul_id3_count, &view_text) :
(stats.canceled ? 0 : -1); (stats.canceled ? 0 : -1);
return ret == -1 ? PLUGIN_ERROR : ret == 1 ? PLUGIN_USB_CONNECTED : PLUGIN_OK; return ret == -1 ? PLUGIN_ERROR : ret == 1 ? PLUGIN_USB_CONNECTED : PLUGIN_OK;

View file

@ -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, bool browse_id3_ex(struct mp3entry *id3, struct playlist_info *playlist,
int playlist_display_index, int playlist_amount, 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; struct gui_synclist id3_lists;
int key; int key;
@ -824,7 +825,18 @@ refresh_info:
char buffer[MAX_PATH]; char buffer[MAX_PATH];
title_and_text[1] = (char*)id3_get_or_speak_info(id3_lists.selected_item+1,&info, buffer, sizeof(buffer), false); title_and_text[1] = (char*)id3_get_or_speak_info(id3_lists.selected_item+1,&info, buffer, sizeof(buffer), false);
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); 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); gui_synclist_draw(&id3_lists);
continue; continue;
} }
@ -861,10 +873,11 @@ refresh_info:
} }
bool browse_id3(struct mp3entry *id3, int playlist_display_index, int playlist_amount, 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, 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, static const char* runtime_get_data(int selected_item, void* data,

View file

@ -45,10 +45,12 @@ bool set_time_screen(const char* title, struct tm *tm, bool set_date);
#ifndef WARBLE #ifndef WARBLE
bool browse_id3_ex(struct mp3entry *id3, struct playlist_info *playlist, bool browse_id3_ex(struct mp3entry *id3, struct playlist_info *playlist,
int playlist_display_index, int playlist_amount, 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 #endif
bool browse_id3(struct mp3entry *id3, int playlist_display_index, int playlist_amount, 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); int view_runtime(void);
#ifdef HAVE_TOUCHSCREEN #ifdef HAVE_TOUCHSCREEN