mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
Add independent 'favourites' playlist size setting
This commit is contained in:
parent
3b1ec7d30e
commit
5220dc9084
@ -106,6 +106,10 @@ enum event_command
|
||||
CMD_EVENT_HISTORY_DEINIT,
|
||||
/* Initializes history playlist. */
|
||||
CMD_EVENT_HISTORY_INIT,
|
||||
/* Deinitializes favourties playlist. */
|
||||
CMD_EVENT_FAVORITES_DEINIT,
|
||||
/* Initializes favourties playlist. */
|
||||
CMD_EVENT_FAVORITES_INIT,
|
||||
/* Deinitializes core information. */
|
||||
CMD_EVENT_CORE_INFO_DEINIT,
|
||||
/* Initializes core information. */
|
||||
|
@ -792,6 +792,10 @@ static const bool network_on_demand_thumbnails = false;
|
||||
/* Number of entries that will be kept in content history playlist file. */
|
||||
static const unsigned default_content_history_size = 100;
|
||||
|
||||
/* Number of entries that will be kept in content favorites playlist file.
|
||||
* -1 == 'unlimited' (99999) */
|
||||
static const int default_content_favorites_size = 100;
|
||||
|
||||
/* Sort all playlists (apart from histories) alphabetically */
|
||||
static const bool playlist_sort_alphabetical = true;
|
||||
|
||||
|
@ -1881,6 +1881,7 @@ static struct config_int_setting *populate_settings_int(settings_t *settings, in
|
||||
#ifdef HAVE_D3D12
|
||||
SETTING_INT("d3d12_gpu_index", &settings->ints.d3d12_gpu_index, true, DEFAULT_D3D12_GPU_INDEX, false);
|
||||
#endif
|
||||
SETTING_INT("content_favorites_size", &settings->ints.content_favorites_size, true, default_content_favorites_size, false);
|
||||
|
||||
*size = count;
|
||||
|
||||
@ -3126,6 +3127,21 @@ static bool config_load_file(const char *path, settings_t *settings)
|
||||
if (!config_entry_exists(conf, "user_language"))
|
||||
msg_hash_set_uint(MSG_HASH_USER_LANGUAGE, frontend_driver_get_user_language());
|
||||
|
||||
/* If this is the first run of an existing installation
|
||||
* after the independent favourites playlist size limit was
|
||||
* added, set the favourites limit according to the current
|
||||
* history playlist size limit. (Have to do this, otherwise
|
||||
* users with large custom history size limits may lose
|
||||
* favourites entries when updating RetroArch...) */
|
||||
if ( config_entry_exists(conf, "content_history_size") &&
|
||||
!config_entry_exists(conf, "content_favorites_size"))
|
||||
{
|
||||
if (settings->uints.content_history_size > 999)
|
||||
settings->ints.content_favorites_size = -1;
|
||||
else
|
||||
settings->ints.content_favorites_size = (int)settings->uints.content_history_size;
|
||||
}
|
||||
|
||||
ret = true;
|
||||
end:
|
||||
if (conf)
|
||||
|
@ -401,6 +401,7 @@ typedef struct settings
|
||||
#ifdef HAVE_D3D12
|
||||
int d3d12_gpu_index;
|
||||
#endif
|
||||
int content_favorites_size;
|
||||
} ints;
|
||||
|
||||
struct
|
||||
|
@ -201,6 +201,8 @@ MSG_HASH(MENU_ENUM_LABEL_CONTENT_DATABASE_DIRECTORY,
|
||||
"content_database_path")
|
||||
MSG_HASH(MENU_ENUM_LABEL_CONTENT_HISTORY_SIZE,
|
||||
"content_history_size")
|
||||
MSG_HASH(MENU_ENUM_LABEL_CONTENT_FAVORITES_SIZE,
|
||||
"content_favorites_size")
|
||||
MSG_HASH(MENU_ENUM_LABEL_PLAYLIST_ENTRY_REMOVE,
|
||||
"playlist_entry_remove_enable")
|
||||
MSG_HASH(MENU_ENUM_LABEL_CONTENT_SETTINGS,
|
||||
|
@ -605,6 +605,14 @@ MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_CONTENT_HISTORY_SIZE,
|
||||
"History List Size"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_CONTENT_FAVORITES_SIZE,
|
||||
"Favorites List Size"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_CONTENT_FAVORITES_SIZE,
|
||||
"Limit the number of entries in the favorites playlist. Once limit is reached, new additions will be prevented until old entries are removed. Setting a value of -1 allows 'unlimited' (99999) entries. WARNING: Reducing the value will delete existing entries!"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_ENTRY_REMOVE,
|
||||
"Allow to remove entries"
|
||||
@ -4379,6 +4387,10 @@ MSG_HASH(
|
||||
MSG_ADDED_TO_FAVORITES,
|
||||
"Added to favorites"
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_ADD_TO_FAVORITES_FAILED,
|
||||
"Failed to add favorite: playlist full"
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_SET_CORE_ASSOCIATION,
|
||||
"Core set: "
|
||||
@ -4887,6 +4899,10 @@ MSG_HASH(
|
||||
MSG_LOADING_HISTORY_FILE,
|
||||
"Loading history file"
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_LOADING_FAVORITES_FILE,
|
||||
"Loading favorites file"
|
||||
)
|
||||
MSG_HASH(
|
||||
MSG_LOADING_STATE,
|
||||
"Loading state"
|
||||
|
@ -4332,6 +4332,7 @@ static int action_ok_delete_entry(const char *path,
|
||||
#ifdef HAVE_IMAGEVIEWER
|
||||
char *def_conf_img_path = NULL;
|
||||
#endif
|
||||
char *def_conf_fav_path = NULL;
|
||||
menu_handle_t *menu = NULL;
|
||||
playlist_t *playlist = playlist_get_cached();
|
||||
|
||||
@ -4347,6 +4348,7 @@ static int action_ok_delete_entry(const char *path,
|
||||
#ifdef HAVE_IMAGEVIEWER
|
||||
def_conf_img_path = playlist_get_conf_path(g_defaults.image_history);
|
||||
#endif
|
||||
def_conf_fav_path = playlist_get_conf_path(g_defaults.content_favorites);
|
||||
|
||||
if (string_is_equal(conf_path, def_conf_path))
|
||||
playlist = g_defaults.content_history;
|
||||
@ -4360,6 +4362,8 @@ static int action_ok_delete_entry(const char *path,
|
||||
else if (string_is_equal(conf_path, def_conf_img_path))
|
||||
playlist = g_defaults.image_history;
|
||||
#endif
|
||||
else if (string_is_equal(conf_path, def_conf_fav_path))
|
||||
playlist = g_defaults.content_favorites;
|
||||
|
||||
if (playlist)
|
||||
{
|
||||
|
@ -234,6 +234,7 @@ default_sublabel_macro(action_bind_sublabel_video_disable_composition, MENU_
|
||||
default_sublabel_macro(action_bind_sublabel_video_smooth, MENU_ENUM_SUBLABEL_VIDEO_SMOOTH)
|
||||
default_sublabel_macro(action_bind_sublabel_history_list_enable, MENU_ENUM_SUBLABEL_HISTORY_LIST_ENABLE)
|
||||
default_sublabel_macro(action_bind_sublabel_content_history_size, MENU_ENUM_SUBLABEL_CONTENT_HISTORY_SIZE)
|
||||
default_sublabel_macro(action_bind_sublabel_content_favorites_size, MENU_ENUM_SUBLABEL_CONTENT_FAVORITES_SIZE)
|
||||
default_sublabel_macro(action_bind_sublabel_menu_input_unified_controls, MENU_ENUM_SUBLABEL_INPUT_UNIFIED_MENU_CONTROLS)
|
||||
default_sublabel_macro(action_bind_sublabel_quit_press_twice, MENU_ENUM_SUBLABEL_QUIT_PRESS_TWICE)
|
||||
default_sublabel_macro(action_bind_sublabel_onscreen_notifications_enable, MENU_ENUM_SUBLABEL_VIDEO_FONT_ENABLE)
|
||||
@ -2544,6 +2545,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
|
||||
case MENU_ENUM_LABEL_CONTENT_HISTORY_SIZE:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_content_history_size);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_CONTENT_FAVORITES_SIZE:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_content_favorites_size);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_NETPLAY_USE_MITM_SERVER:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_netplay_use_mitm_server);
|
||||
break;
|
||||
|
@ -1669,12 +1669,29 @@ end:
|
||||
static void menu_displaylist_set_new_playlist(
|
||||
menu_handle_t *menu, const char *path)
|
||||
{
|
||||
menu->db_playlist_file[0] = '\0';
|
||||
unsigned playlist_size = COLLECTION_SIZE;
|
||||
const char *playlist_file_name = path_basename(path);
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
menu->db_playlist_file[0] = '\0';
|
||||
|
||||
if (playlist_get_cached())
|
||||
playlist_free_cached();
|
||||
|
||||
if (playlist_init_cached(path, COLLECTION_SIZE))
|
||||
/* Get proper playlist capacity */
|
||||
if (settings && !string_is_empty(playlist_file_name))
|
||||
{
|
||||
if (string_is_equal(playlist_file_name, file_path_str(FILE_PATH_CONTENT_HISTORY)) ||
|
||||
string_is_equal(playlist_file_name, file_path_str(FILE_PATH_CONTENT_MUSIC_HISTORY)) ||
|
||||
string_is_equal(playlist_file_name, file_path_str(FILE_PATH_CONTENT_VIDEO_HISTORY)) ||
|
||||
string_is_equal(playlist_file_name, file_path_str(FILE_PATH_CONTENT_IMAGE_HISTORY)))
|
||||
playlist_size = settings->uints.content_history_size;
|
||||
else if (string_is_equal(playlist_file_name, file_path_str(FILE_PATH_CONTENT_FAVORITES)))
|
||||
if (settings->ints.content_favorites_size >= 0)
|
||||
playlist_size = (unsigned)settings->ints.content_favorites_size;
|
||||
}
|
||||
|
||||
if (playlist_init_cached(path, playlist_size))
|
||||
strlcpy(
|
||||
menu->db_playlist_file,
|
||||
path,
|
||||
@ -6493,6 +6510,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
|
||||
menu_displaylist_build_info_t build_list[] = {
|
||||
{MENU_ENUM_LABEL_HISTORY_LIST_ENABLE, PARSE_ONLY_BOOL},
|
||||
{MENU_ENUM_LABEL_CONTENT_HISTORY_SIZE, PARSE_ONLY_UINT},
|
||||
{MENU_ENUM_LABEL_CONTENT_FAVORITES_SIZE, PARSE_ONLY_INT },
|
||||
{MENU_ENUM_LABEL_PLAYLIST_ENTRY_RENAME, PARSE_ONLY_BOOL},
|
||||
{MENU_ENUM_LABEL_PLAYLIST_ENTRY_REMOVE, PARSE_ONLY_UINT},
|
||||
{MENU_ENUM_LABEL_PLAYLIST_SORT_ALPHABETICAL, PARSE_ONLY_BOOL},
|
||||
@ -8541,12 +8559,11 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
|
||||
setting->get_string_representation(setting,
|
||||
val_s, sizeof(val_s));
|
||||
snprintf(val_d, sizeof(val_d), "%d", setting->enum_idx);
|
||||
if (menu_entries_append_enum(info->list,
|
||||
menu_entries_append_enum(info->list,
|
||||
val_s,
|
||||
val_d,
|
||||
MENU_ENUM_LABEL_NO_ITEMS,
|
||||
setting_type, val, 0))
|
||||
count++;
|
||||
setting_type, val, 0);
|
||||
|
||||
if (!checked_found && val == orig_value)
|
||||
{
|
||||
|
@ -26,10 +26,6 @@
|
||||
#include "../msg_hash.h"
|
||||
#include "../setting_list.h"
|
||||
|
||||
#ifndef COLLECTION_SIZE
|
||||
#define COLLECTION_SIZE 99999
|
||||
#endif
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
/* NOTE: Order matters - only add new entries at
|
||||
|
@ -2465,6 +2465,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||
menu_entries_ctl(MENU_ENTRIES_CTL_DEINIT, NULL);
|
||||
|
||||
command_event(CMD_EVENT_HISTORY_DEINIT, NULL);
|
||||
command_event(CMD_EVENT_FAVORITES_DEINIT, NULL);
|
||||
|
||||
menu_dialog_reset();
|
||||
|
||||
|
@ -91,6 +91,7 @@
|
||||
#include "../gfx/video_display_server.h"
|
||||
#include "../managers/cheat_manager.h"
|
||||
#include "../verbosity.h"
|
||||
#include "../playlist.h"
|
||||
|
||||
#include "../tasks/tasks_internal.h"
|
||||
|
||||
@ -6029,6 +6030,32 @@ void general_write_handler(rarch_setting_t *setting)
|
||||
|
||||
}
|
||||
break;
|
||||
case MENU_ENUM_LABEL_CONTENT_FAVORITES_SIZE:
|
||||
{
|
||||
unsigned new_capacity;
|
||||
|
||||
/* Get new size */
|
||||
if (settings->ints.content_favorites_size < 0)
|
||||
new_capacity = COLLECTION_SIZE;
|
||||
else
|
||||
new_capacity = (unsigned)settings->ints.content_favorites_size;
|
||||
|
||||
/* Check whether capacity has changed */
|
||||
if (new_capacity != playlist_capacity(g_defaults.content_favorites))
|
||||
{
|
||||
/* Remove excess entries, if required */
|
||||
while (playlist_size(g_defaults.content_favorites) > new_capacity)
|
||||
playlist_delete_index(
|
||||
g_defaults.content_favorites,
|
||||
playlist_size(g_defaults.content_favorites) - 1);
|
||||
|
||||
/* In all cases, need to close and reopen
|
||||
* playlist file (to update maximum capacity) */
|
||||
command_event(CMD_EVENT_FAVORITES_DEINIT, NULL);
|
||||
command_event(CMD_EVENT_FAVORITES_INIT, NULL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -13287,12 +13314,31 @@ static bool setting_append_list(
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
|
||||
menu_settings_list_current_add_range(list, list_info, 0, 0, 1.0, true, false);
|
||||
menu_settings_list_current_add_range(list, list_info, 0.0f, (float)COLLECTION_SIZE, 1.0f, true, false);
|
||||
|
||||
END_SUB_GROUP(list, list_info, parent_group);
|
||||
|
||||
START_SUB_GROUP(list, list_info, "Playlist", &group_info, &subgroup_info, parent_group);
|
||||
|
||||
/* Favourites size is traditionally associtated with
|
||||
* history size, but they are in fact unrelated. We
|
||||
* therefore place this entry outside the "History"
|
||||
* sub group. */
|
||||
CONFIG_INT(
|
||||
list, list_info,
|
||||
&settings->ints.content_favorites_size,
|
||||
MENU_ENUM_LABEL_CONTENT_FAVORITES_SIZE,
|
||||
MENU_ENUM_LABEL_VALUE_CONTENT_FAVORITES_SIZE,
|
||||
default_content_favorites_size,
|
||||
&group_info,
|
||||
&subgroup_info,
|
||||
parent_group,
|
||||
general_write_handler,
|
||||
general_read_handler);
|
||||
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
|
||||
(*list)[list_info->index - 1].offset_by = -1;
|
||||
menu_settings_list_current_add_range(list, list_info, -1.0f, 999.0f, 1.0f, true, true);
|
||||
|
||||
CONFIG_BOOL(
|
||||
list, list_info,
|
||||
&settings->bools.playlist_entry_rename,
|
||||
|
@ -201,6 +201,7 @@ enum msg_hash_enums
|
||||
MSG_RESAMPLER_QUALITY_HIGHEST,
|
||||
MSG_DISCORD_CONNECTION_REQUEST,
|
||||
MSG_ADDED_TO_FAVORITES,
|
||||
MSG_ADD_TO_FAVORITES_FAILED,
|
||||
MSG_SET_CORE_ASSOCIATION,
|
||||
MSG_RESET_CORE_ASSOCIATION,
|
||||
MSG_CORE_ASSOCIATION_RESET,
|
||||
@ -287,6 +288,7 @@ enum msg_hash_enums
|
||||
MSG_FRAMES,
|
||||
MSG_FOUND_SHADER,
|
||||
MSG_LOADING_HISTORY_FILE,
|
||||
MSG_LOADING_FAVORITES_FILE,
|
||||
MSG_COULD_NOT_READ_STATE_FROM_MOVIE,
|
||||
MSG_MOVIE_FILE_IS_NOT_A_VALID_BSV1_FILE,
|
||||
MSG_OVERRIDES_SAVED_SUCCESSFULLY,
|
||||
@ -1031,6 +1033,7 @@ enum msg_hash_enums
|
||||
/* Playlists */
|
||||
MENU_LABEL(HISTORY_LIST_ENABLE),
|
||||
MENU_LABEL(CONTENT_HISTORY_SIZE),
|
||||
MENU_LABEL(CONTENT_FAVORITES_SIZE),
|
||||
MENU_LABEL(PLAYLIST_ENTRY_REMOVE),
|
||||
MENU_LABEL(PLAYLIST_ENTRY_RENAME),
|
||||
MENU_LABEL(GOTO_FAVORITES),
|
||||
|
240
playlist.c
240
playlist.c
@ -70,6 +70,7 @@ typedef struct
|
||||
char *current_items_string;
|
||||
bool in_items;
|
||||
bool in_subsystem_roms;
|
||||
bool capacity_exceeded;
|
||||
} JSONContext;
|
||||
|
||||
static playlist_t *playlist_cached = NULL;
|
||||
@ -244,6 +245,57 @@ void playlist_get_index(playlist_t *playlist,
|
||||
*entry = &playlist->entries[idx];
|
||||
}
|
||||
|
||||
/**
|
||||
* playlist_free_entry:
|
||||
* @entry : Playlist entry handle.
|
||||
*
|
||||
* Frees playlist entry.
|
||||
**/
|
||||
static void playlist_free_entry(struct playlist_entry *entry)
|
||||
{
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
if (entry->path != NULL)
|
||||
free(entry->path);
|
||||
if (entry->label != NULL)
|
||||
free(entry->label);
|
||||
if (entry->core_path != NULL)
|
||||
free(entry->core_path);
|
||||
if (entry->core_name != NULL)
|
||||
free(entry->core_name);
|
||||
if (entry->db_name != NULL)
|
||||
free(entry->db_name);
|
||||
if (entry->crc32 != NULL)
|
||||
free(entry->crc32);
|
||||
if (entry->subsystem_ident != NULL)
|
||||
free(entry->subsystem_ident);
|
||||
if (entry->subsystem_name != NULL)
|
||||
free(entry->subsystem_name);
|
||||
if (entry->subsystem_roms != NULL)
|
||||
string_list_free(entry->subsystem_roms);
|
||||
|
||||
entry->path = NULL;
|
||||
entry->label = NULL;
|
||||
entry->core_path = NULL;
|
||||
entry->core_name = NULL;
|
||||
entry->db_name = NULL;
|
||||
entry->crc32 = NULL;
|
||||
entry->subsystem_ident = NULL;
|
||||
entry->subsystem_name = NULL;
|
||||
entry->subsystem_roms = NULL;
|
||||
entry->runtime_status = PLAYLIST_RUNTIME_UNKNOWN;
|
||||
entry->runtime_hours = 0;
|
||||
entry->runtime_minutes = 0;
|
||||
entry->runtime_seconds = 0;
|
||||
entry->last_played_year = 0;
|
||||
entry->last_played_month = 0;
|
||||
entry->last_played_day = 0;
|
||||
entry->last_played_hour = 0;
|
||||
entry->last_played_minute = 0;
|
||||
entry->last_played_second = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* playlist_delete_index:
|
||||
* @playlist : Playlist handle.
|
||||
@ -254,11 +306,22 @@ void playlist_get_index(playlist_t *playlist,
|
||||
void playlist_delete_index(playlist_t *playlist,
|
||||
size_t idx)
|
||||
{
|
||||
struct playlist_entry *entry_to_delete = NULL;
|
||||
|
||||
if (!playlist)
|
||||
return;
|
||||
|
||||
if (idx >= playlist->size)
|
||||
return;
|
||||
|
||||
playlist->size = playlist->size - 1;
|
||||
|
||||
/* Free unwanted entry */
|
||||
entry_to_delete = (struct playlist_entry *)(playlist->entries + idx);
|
||||
if (entry_to_delete)
|
||||
playlist_free_entry(entry_to_delete);
|
||||
|
||||
/* Shift remaining entries to fill the gap */
|
||||
memmove(playlist->entries + idx, playlist->entries + idx + 1,
|
||||
(playlist->size - idx) * sizeof(struct playlist_entry));
|
||||
|
||||
@ -315,57 +378,6 @@ bool playlist_entry_exists(playlist_t *playlist,
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* playlist_free_entry:
|
||||
* @entry : Playlist entry handle.
|
||||
*
|
||||
* Frees playlist entry.
|
||||
**/
|
||||
static void playlist_free_entry(struct playlist_entry *entry)
|
||||
{
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
if (entry->path != NULL)
|
||||
free(entry->path);
|
||||
if (entry->label != NULL)
|
||||
free(entry->label);
|
||||
if (entry->core_path != NULL)
|
||||
free(entry->core_path);
|
||||
if (entry->core_name != NULL)
|
||||
free(entry->core_name);
|
||||
if (entry->db_name != NULL)
|
||||
free(entry->db_name);
|
||||
if (entry->crc32 != NULL)
|
||||
free(entry->crc32);
|
||||
if (entry->subsystem_ident != NULL)
|
||||
free(entry->subsystem_ident);
|
||||
if (entry->subsystem_name != NULL)
|
||||
free(entry->subsystem_name);
|
||||
if (entry->subsystem_roms != NULL)
|
||||
string_list_free(entry->subsystem_roms);
|
||||
|
||||
entry->path = NULL;
|
||||
entry->label = NULL;
|
||||
entry->core_path = NULL;
|
||||
entry->core_name = NULL;
|
||||
entry->db_name = NULL;
|
||||
entry->crc32 = NULL;
|
||||
entry->subsystem_ident = NULL;
|
||||
entry->subsystem_name = NULL;
|
||||
entry->subsystem_roms = NULL;
|
||||
entry->runtime_status = PLAYLIST_RUNTIME_UNKNOWN;
|
||||
entry->runtime_hours = 0;
|
||||
entry->runtime_minutes = 0;
|
||||
entry->runtime_seconds = 0;
|
||||
entry->last_played_year = 0;
|
||||
entry->last_played_month = 0;
|
||||
entry->last_played_day = 0;
|
||||
entry->last_played_hour = 0;
|
||||
entry->last_played_minute = 0;
|
||||
entry->last_played_second = 0;
|
||||
}
|
||||
|
||||
void playlist_update(playlist_t *playlist, size_t idx,
|
||||
const struct playlist_entry *update_entry)
|
||||
{
|
||||
@ -1538,6 +1550,20 @@ size_t playlist_size(playlist_t *playlist)
|
||||
return playlist->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* playlist_capacity:
|
||||
* @playlist : Playlist handle.
|
||||
*
|
||||
* Gets maximum capacity of playlist.
|
||||
* Returns: maximum capacity of playlist.
|
||||
**/
|
||||
size_t playlist_capacity(playlist_t *playlist)
|
||||
{
|
||||
if (!playlist)
|
||||
return 0;
|
||||
return playlist->cap;
|
||||
}
|
||||
|
||||
static JSON_Parser_HandlerResult JSONStartArrayHandler(JSON_Parser parser)
|
||||
{
|
||||
JSONContext *pCtx = (JSONContext*)JSON_Parser_GetUserData(parser);
|
||||
@ -1601,13 +1627,24 @@ static JSON_Parser_HandlerResult JSONStartObjectHandler(JSON_Parser parser)
|
||||
|
||||
if (pCtx->in_items && pCtx->object_depth == 2)
|
||||
{
|
||||
if (pCtx->array_depth == 1)
|
||||
if ((pCtx->array_depth == 1) && !pCtx->capacity_exceeded)
|
||||
{
|
||||
if (pCtx->playlist->size < pCtx->playlist->cap)
|
||||
pCtx->current_entry = &pCtx->playlist->entries[pCtx->playlist->size];
|
||||
else
|
||||
/* hit max item limit */
|
||||
return JSON_Parser_Abort;
|
||||
{
|
||||
/* Hit max item limit.
|
||||
* Note: We can't just abort here, since there may
|
||||
* be more metadata to read at the end of the file... */
|
||||
RARCH_WARN("JSON file contains more entries than current playlist capacity. Excess entries will be discarded.\n");
|
||||
pCtx->capacity_exceeded = true;
|
||||
pCtx->current_entry = NULL;
|
||||
/* In addition, since we are discarding excess entries,
|
||||
* the playlist must be flagged as being modified
|
||||
* (i.e. the playlist is not the same as when it was
|
||||
* last saved to disk...) */
|
||||
pCtx->playlist->modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1620,7 +1657,7 @@ static JSON_Parser_HandlerResult JSONEndObjectHandler(JSON_Parser parser)
|
||||
|
||||
if (pCtx->in_items && pCtx->object_depth == 2)
|
||||
{
|
||||
if (pCtx->array_depth == 1)
|
||||
if ((pCtx->array_depth == 1) && !pCtx->capacity_exceeded)
|
||||
pCtx->playlist->size++;
|
||||
}
|
||||
|
||||
@ -1656,7 +1693,6 @@ static JSON_Parser_HandlerResult JSONStringHandler(JSON_Parser parser, char *pVa
|
||||
{
|
||||
if (*pCtx->current_entry_val)
|
||||
free(*pCtx->current_entry_val);
|
||||
|
||||
*pCtx->current_entry_val = strdup(pValue);
|
||||
}
|
||||
else
|
||||
@ -1756,45 +1792,54 @@ static JSON_Parser_HandlerResult JSONObjectMemberHandler(JSON_Parser parser, cha
|
||||
pCtx->current_items_string = strdup(pValue);
|
||||
}
|
||||
|
||||
if (string_is_equal(pValue, "path"))
|
||||
pCtx->current_entry_val = &pCtx->current_entry->path;
|
||||
else if (string_is_equal(pValue, "label"))
|
||||
pCtx->current_entry_val = &pCtx->current_entry->label;
|
||||
else if (string_is_equal(pValue, "core_path"))
|
||||
pCtx->current_entry_val = &pCtx->current_entry->core_path;
|
||||
else if (string_is_equal(pValue, "core_name"))
|
||||
pCtx->current_entry_val = &pCtx->current_entry->core_name;
|
||||
else if (string_is_equal(pValue, "crc32"))
|
||||
pCtx->current_entry_val = &pCtx->current_entry->crc32;
|
||||
else if (string_is_equal(pValue, "db_name"))
|
||||
pCtx->current_entry_val = &pCtx->current_entry->db_name;
|
||||
else if (string_is_equal(pValue, "subsystem_ident"))
|
||||
pCtx->current_entry_val = &pCtx->current_entry->subsystem_ident;
|
||||
else if (string_is_equal(pValue, "subsystem_name"))
|
||||
pCtx->current_entry_val = &pCtx->current_entry->subsystem_name;
|
||||
else if (string_is_equal(pValue, "subsystem_roms"))
|
||||
pCtx->current_entry_string_list_val = &pCtx->current_entry->subsystem_roms;
|
||||
else if (string_is_equal(pValue, "runtime_hours"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->runtime_hours;
|
||||
else if (string_is_equal(pValue, "runtime_minutes"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->runtime_minutes;
|
||||
else if (string_is_equal(pValue, "runtime_seconds"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->runtime_seconds;
|
||||
else if (string_is_equal(pValue, "last_played_year"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_year;
|
||||
else if (string_is_equal(pValue, "last_played_month"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_month;
|
||||
else if (string_is_equal(pValue, "last_played_day"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_day;
|
||||
else if (string_is_equal(pValue, "last_played_hour"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_hour;
|
||||
else if (string_is_equal(pValue, "last_played_minute"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_minute;
|
||||
else if (string_is_equal(pValue, "last_played_second"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_second;
|
||||
if (!pCtx->capacity_exceeded)
|
||||
{
|
||||
if (string_is_equal(pValue, "path"))
|
||||
pCtx->current_entry_val = &pCtx->current_entry->path;
|
||||
else if (string_is_equal(pValue, "label"))
|
||||
pCtx->current_entry_val = &pCtx->current_entry->label;
|
||||
else if (string_is_equal(pValue, "core_path"))
|
||||
pCtx->current_entry_val = &pCtx->current_entry->core_path;
|
||||
else if (string_is_equal(pValue, "core_name"))
|
||||
pCtx->current_entry_val = &pCtx->current_entry->core_name;
|
||||
else if (string_is_equal(pValue, "crc32"))
|
||||
pCtx->current_entry_val = &pCtx->current_entry->crc32;
|
||||
else if (string_is_equal(pValue, "db_name"))
|
||||
pCtx->current_entry_val = &pCtx->current_entry->db_name;
|
||||
else if (string_is_equal(pValue, "subsystem_ident"))
|
||||
pCtx->current_entry_val = &pCtx->current_entry->subsystem_ident;
|
||||
else if (string_is_equal(pValue, "subsystem_name"))
|
||||
pCtx->current_entry_val = &pCtx->current_entry->subsystem_name;
|
||||
else if (string_is_equal(pValue, "subsystem_roms"))
|
||||
pCtx->current_entry_string_list_val = &pCtx->current_entry->subsystem_roms;
|
||||
else if (string_is_equal(pValue, "runtime_hours"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->runtime_hours;
|
||||
else if (string_is_equal(pValue, "runtime_minutes"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->runtime_minutes;
|
||||
else if (string_is_equal(pValue, "runtime_seconds"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->runtime_seconds;
|
||||
else if (string_is_equal(pValue, "last_played_year"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_year;
|
||||
else if (string_is_equal(pValue, "last_played_month"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_month;
|
||||
else if (string_is_equal(pValue, "last_played_day"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_day;
|
||||
else if (string_is_equal(pValue, "last_played_hour"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_hour;
|
||||
else if (string_is_equal(pValue, "last_played_minute"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_minute;
|
||||
else if (string_is_equal(pValue, "last_played_second"))
|
||||
pCtx->current_entry_uint_val = &pCtx->current_entry->last_played_second;
|
||||
else
|
||||
{
|
||||
/* ignore unknown members */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* ignore unknown members */
|
||||
pCtx->current_entry_val = NULL;
|
||||
pCtx->current_entry_uint_val = NULL;
|
||||
pCtx->current_entry_string_list_val = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1950,7 +1995,14 @@ static bool playlist_read_file(
|
||||
|
||||
if (!JSON_Parser_Parse(context.parser, chunk, length, JSON_False))
|
||||
{
|
||||
RARCH_WARN("Error parsing chunk:\n---snip---\n%s\n---snip---\n", chunk);
|
||||
/* Note: Chunk may not be null-terminated.
|
||||
* It is therefore dangerous to print its contents.
|
||||
* Setting a size limit here mitigates the issue, but
|
||||
* in general this is not good practice...
|
||||
* Addendum: RARCH_WARN() actually limits the printed
|
||||
* buffer size anyway, so this warning message is most
|
||||
* likely worthless... */
|
||||
RARCH_WARN("Error parsing chunk:\n---snip---\n%.*s\n---snip---\n", 4096, chunk);
|
||||
JSONLogError(&context);
|
||||
goto json_cleanup;
|
||||
}
|
||||
|
12
playlist.h
12
playlist.h
@ -26,6 +26,9 @@
|
||||
|
||||
RETRO_BEGIN_DECLS
|
||||
|
||||
/* Default maximum playlist size */
|
||||
#define COLLECTION_SIZE 99999
|
||||
|
||||
typedef struct content_playlist playlist_t;
|
||||
|
||||
enum playlist_runtime_status
|
||||
@ -103,6 +106,15 @@ void playlist_clear(playlist_t *playlist);
|
||||
**/
|
||||
size_t playlist_size(playlist_t *playlist);
|
||||
|
||||
/**
|
||||
* playlist_capacity:
|
||||
* @playlist : Playlist handle.
|
||||
*
|
||||
* Gets maximum capacity of playlist.
|
||||
* Returns: maximum capacity of playlist.
|
||||
**/
|
||||
size_t playlist_capacity(playlist_t *playlist);
|
||||
|
||||
/**
|
||||
* playlist_get_index:
|
||||
* @playlist : Playlist handle.
|
||||
|
53
retroarch.c
53
retroarch.c
@ -4141,13 +4141,6 @@ TODO: Add a setting for these tweaks */
|
||||
}
|
||||
g_defaults.content_history = NULL;
|
||||
|
||||
if (g_defaults.content_favorites)
|
||||
{
|
||||
playlist_write_file(g_defaults.content_favorites);
|
||||
playlist_free(g_defaults.content_favorites);
|
||||
}
|
||||
g_defaults.content_favorites = NULL;
|
||||
|
||||
if (g_defaults.music_history)
|
||||
{
|
||||
playlist_write_file(g_defaults.music_history);
|
||||
@ -4191,13 +4184,6 @@ TODO: Add a setting for these tweaks */
|
||||
settings->paths.path_content_history,
|
||||
content_history_size);
|
||||
|
||||
RARCH_LOG("%s: [%s].\n",
|
||||
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
|
||||
settings->paths.path_content_favorites);
|
||||
g_defaults.content_favorites = playlist_init(
|
||||
settings->paths.path_content_favorites,
|
||||
content_history_size);
|
||||
|
||||
RARCH_LOG("%s: [%s].\n",
|
||||
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
|
||||
settings->paths.path_content_music_history);
|
||||
@ -4224,6 +4210,34 @@ TODO: Add a setting for these tweaks */
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case CMD_EVENT_FAVORITES_DEINIT:
|
||||
if (g_defaults.content_favorites)
|
||||
{
|
||||
playlist_write_file(g_defaults.content_favorites);
|
||||
playlist_free(g_defaults.content_favorites);
|
||||
g_defaults.content_favorites = NULL;
|
||||
}
|
||||
break;
|
||||
case CMD_EVENT_FAVORITES_INIT:
|
||||
{
|
||||
settings_t *settings = configuration_settings;
|
||||
unsigned content_favorites_size;
|
||||
|
||||
if (settings->ints.content_favorites_size < 0)
|
||||
content_favorites_size = COLLECTION_SIZE;
|
||||
else
|
||||
content_favorites_size = (unsigned)settings->ints.content_favorites_size;
|
||||
|
||||
command_event(CMD_EVENT_FAVORITES_DEINIT, NULL);
|
||||
|
||||
RARCH_LOG("%s: [%s].\n",
|
||||
msg_hash_to_str(MSG_LOADING_FAVORITES_FILE),
|
||||
settings->paths.path_content_favorites);
|
||||
g_defaults.content_favorites = playlist_init(
|
||||
settings->paths.path_content_favorites,
|
||||
content_favorites_size);
|
||||
}
|
||||
break;
|
||||
case CMD_EVENT_CORE_INFO_DEINIT:
|
||||
core_info_deinit_list();
|
||||
core_info_free_current_core();
|
||||
@ -4322,6 +4336,16 @@ TODO: Add a setting for these tweaks */
|
||||
{
|
||||
struct string_list *str_list = (struct string_list*)data;
|
||||
|
||||
/* Check whether favourties playlist is at capacity */
|
||||
if (playlist_size(g_defaults.content_favorites) >=
|
||||
playlist_capacity(g_defaults.content_favorites))
|
||||
{
|
||||
runloop_msg_queue_push(
|
||||
msg_hash_to_str(MSG_ADD_TO_FAVORITES_FAILED), 1, 180, true, NULL,
|
||||
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (str_list)
|
||||
{
|
||||
if (str_list->size >= 6)
|
||||
@ -5150,6 +5174,7 @@ int rarch_main(int argc, char *argv[], void *data)
|
||||
|
||||
libretro_free_system_info(&runloop_system.info);
|
||||
command_event(CMD_EVENT_HISTORY_DEINIT, NULL);
|
||||
command_event(CMD_EVENT_FAVORITES_DEINIT, NULL);
|
||||
|
||||
configuration_settings = (settings_t*)calloc(1, sizeof(settings_t));
|
||||
|
||||
|
@ -658,6 +658,7 @@ static bool content_load(content_ctx_info_t *info)
|
||||
#endif
|
||||
|
||||
command_event(CMD_EVENT_HISTORY_INIT, NULL);
|
||||
command_event(CMD_EVENT_FAVORITES_INIT, NULL);
|
||||
command_event(CMD_EVENT_RESUME, NULL);
|
||||
command_event(CMD_EVENT_VIDEO_SET_ASPECT_RATIO, NULL);
|
||||
|
||||
|
@ -42,9 +42,6 @@
|
||||
#include "../gfx/video_display_server.h"
|
||||
#endif
|
||||
#include "../verbosity.h"
|
||||
#ifndef COLLECTION_SIZE
|
||||
#define COLLECTION_SIZE 99999
|
||||
#endif
|
||||
|
||||
typedef struct database_state_handle
|
||||
{
|
||||
|
@ -270,7 +270,7 @@ static void task_netplay_crc_scan_handler(retro_task_t *task)
|
||||
continue;
|
||||
|
||||
RARCH_LOG("[lobby] searching playlist: %s\n", lpl_path);
|
||||
playlist = playlist_init(lpl_path, 99999);
|
||||
playlist = playlist_init(lpl_path, COLLECTION_SIZE);
|
||||
playlist_size = playlist_get_size(playlist);
|
||||
|
||||
for (j = 0; j < playlist_size; j++)
|
||||
@ -344,7 +344,7 @@ static void task_netplay_crc_scan_handler(retro_task_t *task)
|
||||
continue;
|
||||
|
||||
RARCH_LOG("[lobby] searching rom %d/%d (%s) in playlist: %s\n", i + 1, game_list->size, game_list->elems[i].data, lpl_path);
|
||||
playlist = playlist_init(lpl_path, 99999);
|
||||
playlist = playlist_init(lpl_path, COLLECTION_SIZE);
|
||||
playlist_size = playlist_get_size(playlist);
|
||||
|
||||
for (k = 0; k < playlist_size && !found[i]; k++)
|
||||
|
@ -39,10 +39,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef COLLECTION_SIZE
|
||||
#define COLLECTION_SIZE 99999
|
||||
#endif
|
||||
|
||||
enum pl_thumb_status
|
||||
{
|
||||
PL_THUMB_BEGIN = 0,
|
||||
|
@ -29,10 +29,6 @@
|
||||
#include "../file_path_special.h"
|
||||
#include "../playlist.h"
|
||||
|
||||
#ifndef COLLECTION_SIZE
|
||||
#define COLLECTION_SIZE 99999
|
||||
#endif
|
||||
|
||||
enum pl_manager_status
|
||||
{
|
||||
PL_MANAGER_BEGIN = 0,
|
||||
|
@ -95,10 +95,6 @@ extern "C" {
|
||||
#define TIMER_MSEC 1000 /* periodic timer for gathering statistics */
|
||||
#define STATUS_MSG_THROTTLE_MSEC 250
|
||||
|
||||
#ifndef COLLECTION_SIZE
|
||||
#define COLLECTION_SIZE 99999
|
||||
#endif
|
||||
|
||||
#define GENERIC_FOLDER_ICON "/xmb/dot-art/png/folder.png"
|
||||
#define HIRAGANA_START 0x3041U
|
||||
#define HIRAGANA_END 0x3096U
|
||||
|
Loading…
x
Reference in New Issue
Block a user