mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 10:07:38 -04:00
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:
parent
4062a6aefc
commit
8f5128da16
11 changed files with 85 additions and 23 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -207,4 +207,4 @@ xobox,games
|
|||
xrick,games
|
||||
xworld,games
|
||||
zxbox,viewers
|
||||
view_text,viewers
|
||||
view_text,viewers
|
||||
|
|
|
@ -238,4 +238,4 @@ test_touchscreen.c
|
|||
#endif
|
||||
test_usb.c
|
||||
test_viewports.c
|
||||
#endif /* HAVE_TEST_PLUGINS */
|
||||
#endif /* HAVE_TEST_PLUGINS */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue