Refactor playlist struct configuration

This commit is contained in:
jdgleaver 2020-06-26 15:39:03 +01:00
parent d243f62a80
commit 0fcfb3deda
21 changed files with 617 additions and 633 deletions

View file

@ -443,7 +443,7 @@ static retro_time_t rcheevos_async_send_rich_presence(
{
if (settings->bools.discord_enable
&& discord_is_ready())
discord_update(DISCORD_PRESENCE_RETROACHIEVEMENTS, false);
discord_update(DISCORD_PRESENCE_RETROACHIEVEMENTS);
}
#endif

View file

@ -1103,8 +1103,7 @@ static bool manual_content_scan_get_playlist_content_label(
void manual_content_scan_add_content_to_playlist(
manual_content_scan_task_config_t *task_config,
playlist_t *playlist, const char *content_path,
int content_type, logiqx_dat_t *dat_file,
bool fuzzy_archive_match)
int content_type, logiqx_dat_t *dat_file)
{
char playlist_content_path[PATH_MAX_LENGTH];
@ -1122,7 +1121,7 @@ void manual_content_scan_add_content_to_playlist(
/* Check whether content is already included
* in playlist */
if (!playlist_entry_exists(playlist, playlist_content_path, fuzzy_archive_match))
if (!playlist_entry_exists(playlist, playlist_content_path))
{
struct playlist_entry entry = {0};
char label[PATH_MAX_LENGTH];
@ -1147,6 +1146,6 @@ void manual_content_scan_add_content_to_playlist(
entry.db_name = task_config->database_name;
/* Add entry to playlist */
playlist_push(playlist, &entry, fuzzy_archive_match);
playlist_push(playlist, &entry);
}
}

View file

@ -238,8 +238,7 @@ struct string_list *manual_content_scan_get_content_list(manual_content_scan_tas
void manual_content_scan_add_content_to_playlist(
manual_content_scan_task_config_t *task_config,
playlist_t *playlist, const char *content_path,
int content_type, logiqx_dat_t *dat_file,
bool fuzzy_archive_match);
int content_type, logiqx_dat_t *dat_file);
RETRO_END_DECLS

View file

@ -378,9 +378,6 @@ static int playlist_association_left(unsigned type, const char *label,
{
char core_filename[PATH_MAX_LENGTH];
size_t i, next, current = 0;
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_t *playlist = playlist_get_cached();
const char *default_core_path = playlist_get_default_core_path(playlist);
bool default_core_set = false;
@ -452,7 +449,7 @@ static int playlist_association_left(unsigned type, const char *label,
/* Update playlist */
playlist_set_default_core_path(playlist, core_info ? core_info->path : "DETECT");
playlist_set_default_core_name(playlist, core_info ? core_info->display_name : "DETECT");
playlist_write_file(playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
return 0;
}
@ -461,10 +458,7 @@ static int playlist_label_display_mode_left(unsigned type, const char *label,
bool wraparound)
{
enum playlist_label_display_mode label_display_mode;
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_t *playlist = playlist_get_cached();
playlist_t *playlist = playlist_get_cached();
if (!playlist)
return -1;
@ -477,8 +471,7 @@ static int playlist_label_display_mode_left(unsigned type, const char *label,
label_display_mode = LABEL_DISPLAY_MODE_KEEP_REGION_AND_DISC_INDEX;
playlist_set_label_display_mode(playlist, label_display_mode);
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
return 0;
}
@ -486,9 +479,6 @@ static int playlist_label_display_mode_left(unsigned type, const char *label,
static void playlist_thumbnail_mode_left(playlist_t *playlist, enum playlist_thumbnail_id thumbnail_id,
bool wraparound)
{
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
enum playlist_thumbnail_mode thumbnail_mode =
playlist_get_thumbnail_mode(playlist, thumbnail_id);
@ -498,8 +488,7 @@ static void playlist_thumbnail_mode_left(playlist_t *playlist, enum playlist_thu
thumbnail_mode = PLAYLIST_THUMBNAIL_MODE_BOXARTS;
playlist_set_thumbnail_mode(playlist, thumbnail_id, thumbnail_mode);
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
}
static int playlist_right_thumbnail_mode_left(unsigned type, const char *label,
@ -532,10 +521,7 @@ static int playlist_sort_mode_left(unsigned type, const char *label,
bool wraparound)
{
enum playlist_sort_mode sort_mode;
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_t *playlist = playlist_get_cached();
playlist_t *playlist = playlist_get_cached();
if (!playlist)
return -1;
@ -548,8 +534,7 @@ static int playlist_sort_mode_left(unsigned type, const char *label,
sort_mode = PLAYLIST_SORT_MODE_OFF;
playlist_set_sort_mode(playlist, sort_mode);
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
return 0;
}

View file

@ -2013,6 +2013,7 @@ error:
static int action_ok_playlist_entry_collection(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
playlist_config_t playlist_config;
char content_path[PATH_MAX_LENGTH];
char content_label[PATH_MAX_LENGTH];
char core_path[PATH_MAX_LENGTH];
@ -2025,14 +2026,17 @@ static int action_ok_playlist_entry_collection(const char *path,
bool core_is_builtin = false;
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
bool playlist_sort_alphabetical = settings->bools.playlist_sort_alphabetical;
const char *path_content_history = settings->paths.path_content_history;
const char *path_content_music_history = settings->paths.path_content_music_history;
const char *path_content_video_history = settings->paths.path_content_video_history;
const char *path_content_image_history = settings->paths.path_content_image_history;
playlist_config.capacity = COLLECTION_SIZE;
playlist_config.old_format = settings->bools.playlist_use_old_format;
playlist_config.compress = settings->bools.playlist_compression;
playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
content_path[0] = '\0';
content_label[0] = '\0';
core_path[0] = '\0';
@ -2057,7 +2061,8 @@ static int action_ok_playlist_entry_collection(const char *path,
string_is_equal(menu->db_playlist_file, path_content_image_history);
enum playlist_sort_mode current_sort_mode;
tmp_playlist = playlist_init(menu->db_playlist_file, COLLECTION_SIZE);
playlist_config_set_path(&playlist_config, menu->db_playlist_file);
tmp_playlist = playlist_init(&playlist_config);
if (!tmp_playlist)
goto error;
@ -2127,9 +2132,7 @@ static int action_ok_playlist_entry_collection(const char *path,
command_playlist_update_write(
playlist,
selection_ptr,
&update_entry,
playlist_use_old_format,
playlist_compression);
&update_entry);
}
else
{
@ -2472,12 +2475,8 @@ static int action_ok_audio_add_to_mixer_and_collection(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
char combined_path[PATH_MAX_LENGTH];
struct playlist_entry entry = {0};
settings_t *settings = config_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr();
bool playlist_fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
struct playlist_entry entry = {0};
menu_handle_t *menu = menu_driver_get_ptr();
combined_path[0] = '\0';
@ -2492,10 +2491,7 @@ static int action_ok_audio_add_to_mixer_and_collection(const char *path,
entry.core_path = (char*)"builtin";
entry.core_name = (char*)"musicplayer";
command_playlist_push_write(g_defaults.music_history, &entry,
playlist_fuzzy_archive_match,
playlist_use_old_format,
playlist_compression);
command_playlist_push_write(g_defaults.music_history, &entry);
if (filestream_exists(combined_path))
task_push_audio_mixer_load(combined_path,
@ -2510,12 +2506,8 @@ static int action_ok_audio_add_to_mixer_and_collection_and_play(const char *path
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
char combined_path[PATH_MAX_LENGTH];
struct playlist_entry entry = {0};
menu_handle_t *menu = menu_driver_get_ptr();
settings_t *settings = config_get_ptr();
bool playlist_fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
struct playlist_entry entry = {0};
menu_handle_t *menu = menu_driver_get_ptr();
combined_path[0] = '\0';
@ -2530,10 +2522,7 @@ static int action_ok_audio_add_to_mixer_and_collection_and_play(const char *path
entry.core_path = (char*)"builtin";
entry.core_name = (char*)"musicplayer";
command_playlist_push_write(g_defaults.music_history, &entry,
playlist_fuzzy_archive_match,
playlist_use_old_format,
playlist_compression);
command_playlist_push_write(g_defaults.music_history, &entry);
if (filestream_exists(combined_path))
task_push_audio_mixer_load_and_play(combined_path,
@ -2593,9 +2582,6 @@ static void menu_input_wifi_cb(void *userdata, const char *passphrase)
static void menu_input_st_string_cb_rename_entry(void *userdata,
const char *str)
{
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
if (str && *str)
{
const char *label = menu_input_dialog_get_buffer();
@ -2610,9 +2596,7 @@ static void menu_input_st_string_cb_rename_entry(void *userdata,
command_playlist_update_write(NULL,
menu_input_dialog_get_kb_idx(),
&entry,
playlist_use_old_format,
playlist_compression);
&entry);
}
}
@ -3188,8 +3172,6 @@ static int action_ok_core_deferred_set(const char *new_core_path,
const char *path_libretro_info = settings->paths.path_libretro_info;
const char *path_dir_libretro = settings->paths.directory_libretro;
bool show_hidden_files = settings->bools.show_hidden_files;
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
ext_name[0] = '\0';
core_display_name[0] = '\0';
@ -3221,9 +3203,7 @@ static int action_ok_core_deferred_set(const char *new_core_path,
command_playlist_update_write(
NULL,
menu->scratchpad.unsigned_var,
&entry,
playlist_use_old_format,
playlist_compression);
&entry);
/* Provide visual feedback */
strlcpy(msg, msg_hash_to_str(MSG_SET_CORE_ASSOCIATION), sizeof(msg));
@ -4743,9 +4723,6 @@ static int action_ok_delete_entry(const char *path,
char *def_conf_img_path = NULL;
#endif
char *def_conf_fav_path = NULL;
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_t *playlist = playlist_get_cached();
menu_handle_t *menu = menu_driver_get_ptr();
@ -4781,8 +4758,7 @@ static int action_ok_delete_entry(const char *path,
if (playlist)
{
playlist_delete_index(playlist, menu->rpl_entry_selection_ptr);
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
}
new_selection_ptr = menu_navigation_get_selection();
@ -5639,9 +5615,6 @@ static int action_ok_push_dropdown_item_playlist_default_core(const char *path,
core_info_list_t *core_info_list = NULL;
playlist_t *playlist = playlist_get_cached();
const char* core_name = path;
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
/* Get core list */
core_info_get_list(&core_info_list);
@ -5691,8 +5664,7 @@ static int action_ok_push_dropdown_item_playlist_default_core(const char *path,
}
/* In all cases, update file on disk */
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
@ -5702,34 +5674,26 @@ static int action_ok_push_dropdown_item_playlist_label_display_mode(
const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
settings_t *settings = config_get_ptr();
playlist_t *playlist = playlist_get_cached();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_t *playlist = playlist_get_cached();
playlist_set_label_display_mode(playlist, (enum playlist_label_display_mode)idx);
/* In all cases, update file on disk */
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
static int generic_set_thumbnail_mode(enum playlist_thumbnail_id thumbnail_id, size_t idx)
{
settings_t *settings = config_get_ptr();
playlist_t *playlist = playlist_get_cached();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_t *playlist = playlist_get_cached();
if (!playlist)
return -1;
playlist_set_thumbnail_mode(playlist, thumbnail_id,
(enum playlist_thumbnail_mode)idx);
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
@ -5750,14 +5714,10 @@ static int action_ok_push_dropdown_item_playlist_sort_mode(
const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
settings_t *settings = config_get_ptr();
playlist_t *playlist = playlist_get_cached();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_t *playlist = playlist_get_cached();
playlist_set_sort_mode(playlist, (enum playlist_sort_mode)idx);
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
return action_cancel_pop_default(NULL, NULL, 0, 0);
}
@ -6201,7 +6161,18 @@ static int action_ok_disk_image_append(const char *path,
static int action_ok_manual_content_scan_start(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
task_push_manual_content_scan();
playlist_config_t playlist_config;
settings_t *settings = config_get_ptr();
const char *directory_playlist = settings->paths.directory_playlist;
/* Note: playlist_config.path will set by the
* task itself */
playlist_config.capacity = COLLECTION_SIZE;
playlist_config.old_format = settings->bools.playlist_use_old_format;
playlist_config.compress = settings->bools.playlist_compression;
playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
task_push_manual_content_scan(&playlist_config, directory_playlist);
return 0;
}
@ -6534,24 +6505,31 @@ static int action_ok_pl_content_thumbnails(const char *path,
{
#ifdef HAVE_NETWORKING
settings_t *settings = config_get_ptr();
char playlist_path[PATH_MAX_LENGTH];
playlist_path[0] = '\0';
if (settings)
{
const char *path_dir_playlist = settings->paths.directory_playlist;
const char *path_dir_thumbnails = settings->paths.directory_thumbnails;
playlist_config_t playlist_config;
const char *path_dir_playlist = settings->paths.directory_playlist;
const char *path_dir_thumbnails = settings->paths.directory_thumbnails;
playlist_config.capacity = COLLECTION_SIZE;
playlist_config.old_format = settings->bools.playlist_use_old_format;
playlist_config.compress = settings->bools.playlist_compression;
playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
if (!string_is_empty(path_dir_playlist))
{
fill_pathname_join(
playlist_path,
path_dir_playlist, label,
sizeof(playlist_path));
char playlist_path[PATH_MAX_LENGTH];
playlist_path[0] = '\0';
task_push_pl_thumbnail_download(path, playlist_path,
fill_pathname_join(
playlist_path, path_dir_playlist, label,
sizeof(playlist_path));
playlist_config_set_path(&playlist_config, playlist_path);
task_push_pl_thumbnail_download(path, &playlist_config,
path_dir_thumbnails);
return 0;
}
}
@ -6588,18 +6566,18 @@ static int action_ok_pl_entry_content_thumbnails(const char *path,
static int action_ok_playlist_reset_cores(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
playlist_t *playlist = playlist_get_cached();
const char *playlist_path = NULL;
playlist_t *playlist = playlist_get_cached();
playlist_config_t *playlist_config = NULL;
if (!playlist)
return -1;
playlist_path = playlist_get_conf_path(playlist);
playlist_config = playlist_get_config(playlist);
if (string_is_empty(playlist_path))
if (!playlist_config || string_is_empty(playlist_config->path))
return -1;
task_push_pl_manager_reset_cores(playlist_path);
task_push_pl_manager_reset_cores(playlist_config);
return 0;
}
@ -6607,18 +6585,18 @@ static int action_ok_playlist_reset_cores(const char *path,
static int action_ok_playlist_clean(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
playlist_t *playlist = playlist_get_cached();
const char *playlist_path = NULL;
playlist_t *playlist = playlist_get_cached();
playlist_config_t *playlist_config = NULL;
if (!playlist)
return -1;
playlist_path = playlist_get_conf_path(playlist);
playlist_config = playlist_get_config(playlist);
if (string_is_empty(playlist_path))
if (!playlist_config || string_is_empty(playlist_config->path))
return -1;
task_push_pl_manager_clean_playlist(playlist_path);
task_push_pl_manager_clean_playlist(playlist_config);
return 0;
}

View file

@ -481,12 +481,9 @@ static int playlist_association_right(unsigned type, const char *label,
size_t i, next, current = 0;
core_info_list_t *core_info_list = NULL;
core_info_t *core_info = NULL;
settings_t *settings = config_get_ptr();
playlist_t *playlist = playlist_get_cached();
const char *default_core_path = playlist_get_default_core_path(playlist);
bool default_core_set = false;
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
core_filename[0] = '\0';
@ -556,7 +553,7 @@ static int playlist_association_right(unsigned type, const char *label,
/* Update playlist */
playlist_set_default_core_path(playlist, core_info ? core_info->path : "DETECT");
playlist_set_default_core_name(playlist, core_info ? core_info->display_name : "DETECT");
playlist_write_file(playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
return 0;
}
@ -565,10 +562,7 @@ static int playlist_label_display_mode_right(unsigned type, const char *label,
bool wraparound)
{
enum playlist_label_display_mode label_display_mode;
settings_t *settings = config_get_ptr();
playlist_t *playlist = playlist_get_cached();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
if (!playlist)
return -1;
@ -581,8 +575,7 @@ static int playlist_label_display_mode_right(unsigned type, const char *label,
label_display_mode = LABEL_DISPLAY_MODE_DEFAULT;
playlist_set_label_display_mode(playlist, label_display_mode);
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
return 0;
}
@ -590,9 +583,6 @@ static int playlist_label_display_mode_right(unsigned type, const char *label,
static void playlist_thumbnail_mode_right(playlist_t *playlist, enum playlist_thumbnail_id thumbnail_id,
bool wraparound)
{
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
enum playlist_thumbnail_mode thumbnail_mode =
playlist_get_thumbnail_mode(playlist, thumbnail_id);
@ -602,8 +592,7 @@ static void playlist_thumbnail_mode_right(playlist_t *playlist, enum playlist_th
thumbnail_mode = PLAYLIST_THUMBNAIL_MODE_DEFAULT;
playlist_set_thumbnail_mode(playlist, thumbnail_id, thumbnail_mode);
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
}
static int playlist_right_thumbnail_mode_right(unsigned type, const char *label,
@ -636,10 +625,7 @@ static int playlist_sort_mode_right(unsigned type, const char *label,
bool wraparound)
{
enum playlist_sort_mode sort_mode;
settings_t *settings = config_get_ptr();
playlist_t *playlist = playlist_get_cached();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_t *playlist = playlist_get_cached();
if (!playlist)
return -1;
@ -652,8 +638,7 @@ static int playlist_sort_mode_right(unsigned type, const char *label,
sort_mode = PLAYLIST_SORT_MODE_DEFAULT;
playlist_set_sort_mode(playlist, sort_mode);
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
return 0;
}

View file

@ -310,10 +310,7 @@ static int action_start_playlist_association(
const char *path, const char *label,
unsigned type, size_t idx, size_t entry_idx)
{
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_t *playlist = playlist_get_cached();
playlist_t *playlist = playlist_get_cached();
if (!playlist)
return -1;
@ -321,8 +318,7 @@ static int action_start_playlist_association(
/* Set default core path + name to DETECT */
playlist_set_default_core_path(playlist, file_path_str(FILE_PATH_DETECT));
playlist_set_default_core_name(playlist, file_path_str(FILE_PATH_DETECT));
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
return 0;
}
@ -331,18 +327,14 @@ static int action_start_playlist_label_display_mode(
const char *path, const char *label,
unsigned type, size_t idx, size_t entry_idx)
{
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_t *playlist = playlist_get_cached();
playlist_t *playlist = playlist_get_cached();
if (!playlist)
return -1;
/* Set label display mode to the default */
playlist_set_label_display_mode(playlist, LABEL_DISPLAY_MODE_DEFAULT);
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
return 0;
}
@ -351,18 +343,14 @@ static int action_start_playlist_right_thumbnail_mode(
const char *path, const char *label,
unsigned type, size_t idx, size_t entry_idx)
{
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_t *playlist = playlist_get_cached();
playlist_t *playlist = playlist_get_cached();
if (!playlist)
return -1;
/* Set thumbnail_mode to default value */
playlist_set_thumbnail_mode(playlist, PLAYLIST_THUMBNAIL_RIGHT, PLAYLIST_THUMBNAIL_MODE_DEFAULT);
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
return 0;
}
@ -371,18 +359,14 @@ static int action_start_playlist_left_thumbnail_mode(
const char *path, const char *label,
unsigned type, size_t idx, size_t entry_idx)
{
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_t *playlist = playlist_get_cached();
playlist_t *playlist = playlist_get_cached();
if (!playlist)
return -1;
/* Set thumbnail_mode to default value */
playlist_set_thumbnail_mode(playlist, PLAYLIST_THUMBNAIL_LEFT, PLAYLIST_THUMBNAIL_MODE_DEFAULT);
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
return 0;
}
@ -391,18 +375,14 @@ static int action_start_playlist_sort_mode(
const char *path, const char *label,
unsigned type, size_t idx, size_t entry_idx)
{
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_t *playlist = playlist_get_cached();
playlist_t *playlist = playlist_get_cached();
if (!playlist)
return -1;
/* Set sort mode to the default */
playlist_set_sort_mode(playlist, PLAYLIST_SORT_MODE_DEFAULT);
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
return 0;
}

View file

@ -1361,6 +1361,7 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
char path_playlist[PATH_MAX_LENGTH];
char path_base[PATH_MAX_LENGTH];
char query[PATH_MAX_LENGTH];
playlist_config_t playlist_config;
playlist_t *playlist = NULL;
database_info_list_t *db_info = NULL;
settings_t *settings = config_get_ptr();
@ -1368,6 +1369,11 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
const char *dir_playlist = settings->paths.directory_playlist;
const char *menu_driver = menu_driver_ident();
playlist_config.capacity = COLLECTION_SIZE;
playlist_config.old_format = settings->bools.playlist_use_old_format;
playlist_config.compress = settings->bools.playlist_compression;
playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
path_playlist[0] = path_base[0] = query[0] = '\0';
database_info_build_query_enum(query, sizeof(query),
@ -1387,7 +1393,8 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu,
fill_pathname_join(path_playlist, dir_playlist, path_base,
sizeof(path_playlist));
playlist = playlist_init(path_playlist, COLLECTION_SIZE);
playlist_config_set_path(&playlist_config, path_playlist);
playlist = playlist_init(&playlist_config);
if (playlist)
strlcpy(menu->db_playlist_file, path_playlist,
@ -1973,14 +1980,18 @@ end:
static void menu_displaylist_set_new_playlist(
menu_handle_t *menu, const char *path, bool sort_enabled)
{
unsigned playlist_size = COLLECTION_SIZE;
const char *playlist_file_name = path_basename(path);
settings_t *settings = config_get_ptr();
int content_favorites_size = settings->ints.content_favorites_size;
unsigned content_history_size = settings->uints.content_history_size;
bool playlist_sort_alphabetical = settings->bools.playlist_sort_alphabetical;
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_config_t playlist_config;
const char *playlist_file_name = path_basename(path);
settings_t *settings = config_get_ptr();
int content_favorites_size = settings->ints.content_favorites_size;
unsigned content_history_size = settings->uints.content_history_size;
bool playlist_sort_alphabetical = settings->bools.playlist_sort_alphabetical;
playlist_config_set_path(&playlist_config, path);
playlist_config.capacity = COLLECTION_SIZE;
playlist_config.old_format = settings->bools.playlist_use_old_format;
playlist_config.compress = settings->bools.playlist_compression;
playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
menu->db_playlist_file[0] = '\0';
@ -1990,17 +2001,16 @@ static void menu_displaylist_set_new_playlist(
/* Get proper playlist capacity */
if (!string_is_empty(playlist_file_name))
{
if (string_ends_with_size(path, "_history.lpl",
strlen(path), STRLEN_CONST("_history.lpl")))
playlist_size = content_history_size;
else if (string_is_equal(playlist_file_name, file_path_str(FILE_PATH_CONTENT_FAVORITES)))
if (content_favorites_size >= 0)
playlist_size = (unsigned)content_favorites_size;
if (string_ends_with_size(playlist_file_name, "_history.lpl",
strlen(playlist_file_name), STRLEN_CONST("_history.lpl")))
playlist_config.capacity = content_history_size;
else if (string_is_equal(playlist_file_name,
file_path_str(FILE_PATH_CONTENT_FAVORITES)) &&
(content_favorites_size >= 0))
playlist_config.capacity = (unsigned)content_favorites_size;
}
if (playlist_init_cached(
path, playlist_size,
playlist_use_old_format, playlist_compression))
if (playlist_init_cached(&playlist_config))
{
playlist_t *playlist = playlist_get_cached();
enum playlist_sort_mode current_sort_mode = playlist_get_sort_mode(playlist);

View file

@ -42,9 +42,7 @@ typedef struct discord_userdata
enum discord_presence status;
} discord_userdata_t;
void discord_update(
enum discord_presence presence,
bool fuzzy_archive_match);
void discord_update(enum discord_presence presence);
bool discord_is_ready(void);

View file

@ -51,12 +51,12 @@ struct content_playlist
enum playlist_sort_mode sort_mode;
size_t size;
size_t cap;
char *conf_path;
char *default_core_path;
char *default_core_name;
struct playlist_entry *entries;
playlist_config_t config;
};
typedef struct
@ -92,6 +92,47 @@ typedef int (playlist_sort_fun_t)(
const struct playlist_entry *a,
const struct playlist_entry *b);
/* Convenience function: copies specified playlist
* path to specified playlist configuration object */
void playlist_config_set_path(playlist_config_t *config, const char *path)
{
if (!config)
return;
if (string_is_empty(path))
config->path[0] = '\0';
else
strlcpy(config->path, path, sizeof(config->path));
}
/* Creates a copy of the specified playlist configuration.
* Returns false in the event of an error */
bool playlist_config_copy(const playlist_config_t *src, playlist_config_t *dst)
{
if (!src || !dst)
return false;
strlcpy(dst->path, src->path, sizeof(dst->path));
dst->capacity = src->capacity;
dst->old_format = src->old_format;
dst->compress = src->compress;
dst->fuzzy_archive_match = src->fuzzy_archive_match;
return true;
}
/* Returns internal playlist configuration object
* of specified playlist.
* Returns NULL it the event of an error. */
playlist_config_t *playlist_get_config(playlist_t *playlist)
{
if (!playlist)
return NULL;
return &playlist->config;
}
/**
* playlist_path_equal:
* @real_path : 'Real' search path, generated by path_resolve_realpath()
@ -102,7 +143,7 @@ typedef int (playlist_sort_fun_t)(
* filesystems, 'incomplete' archive paths)
**/
static bool playlist_path_equal(const char *real_path,
const char *entry_path, bool fuzzy_archive_match)
const char *entry_path, const playlist_config_t *config)
{
bool real_path_is_compressed;
bool entry_real_path_is_compressed;
@ -111,7 +152,9 @@ static bool playlist_path_equal(const char *real_path,
entry_real_path[0] = '\0';
/* Sanity check */
if (string_is_empty(real_path) || string_is_empty(entry_path))
if (string_is_empty(real_path) ||
string_is_empty(entry_path) ||
!config)
return false;
/* Get entry 'real' path */
@ -133,7 +176,7 @@ static bool playlist_path_equal(const char *real_path,
#ifdef RARCH_INTERNAL
/* If fuzzy matching is disabled, we can give up now */
if (!fuzzy_archive_match)
if (!config->fuzzy_archive_match)
return false;
#endif
@ -234,7 +277,7 @@ char *playlist_get_conf_path(playlist_t *playlist)
{
if (!playlist)
return NULL;
return playlist->conf_path;
return playlist->config.path;
}
/**
@ -355,8 +398,7 @@ void playlist_delete_index(playlist_t *playlist,
* matching 'search_path'
**/
void playlist_delete_by_path(playlist_t *playlist,
const char *search_path,
bool fuzzy_archive_match)
const char *search_path)
{
size_t i = 0;
char real_search_path[PATH_MAX_LENGTH];
@ -373,7 +415,7 @@ void playlist_delete_by_path(playlist_t *playlist,
while (i < playlist->size)
{
if (!playlist_path_equal(real_search_path, playlist->entries[i].path,
fuzzy_archive_match))
&playlist->config))
{
i++;
continue;
@ -389,8 +431,7 @@ void playlist_delete_by_path(playlist_t *playlist,
void playlist_get_index_by_path(playlist_t *playlist,
const char *search_path,
const struct playlist_entry **entry,
bool fuzzy_archive_match)
const struct playlist_entry **entry)
{
size_t i;
char real_search_path[PATH_MAX_LENGTH];
@ -407,7 +448,7 @@ void playlist_get_index_by_path(playlist_t *playlist,
for (i = 0; i < playlist->size; i++)
{
if (!playlist_path_equal(real_search_path, playlist->entries[i].path,
fuzzy_archive_match))
&playlist->config))
continue;
*entry = &playlist->entries[i];
@ -417,7 +458,7 @@ void playlist_get_index_by_path(playlist_t *playlist,
}
bool playlist_entry_exists(playlist_t *playlist,
const char *path, bool fuzzy_archive_match)
const char *path)
{
size_t i;
char real_search_path[PATH_MAX_LENGTH];
@ -433,7 +474,7 @@ bool playlist_entry_exists(playlist_t *playlist,
for (i = 0; i < playlist->size; i++)
if (playlist_path_equal(real_search_path, playlist->entries[i].path,
fuzzy_archive_match))
&playlist->config))
return true;
return false;
@ -608,8 +649,7 @@ void playlist_update_runtime(playlist_t *playlist, size_t idx,
}
bool playlist_push_runtime(playlist_t *playlist,
const struct playlist_entry *entry,
bool fuzzy_archive_match)
const struct playlist_entry *entry)
{
size_t i;
char real_path[PATH_MAX_LENGTH];
@ -652,7 +692,7 @@ bool playlist_push_runtime(playlist_t *playlist,
const char *entry_path = playlist->entries[i].path;
bool equal_path =
(string_is_empty(real_path) && string_is_empty(entry_path)) ||
playlist_path_equal(real_path, entry_path, fuzzy_archive_match);
playlist_path_equal(real_path, entry_path, &playlist->config);
/* Core name can have changed while still being the same core.
* Differentiate based on the core path only. */
@ -676,9 +716,9 @@ bool playlist_push_runtime(playlist_t *playlist,
goto success;
}
if (playlist->size == playlist->cap)
if (playlist->size == playlist->config.capacity)
{
struct playlist_entry *last_entry = &playlist->entries[playlist->cap - 1];
struct playlist_entry *last_entry = &playlist->entries[playlist->config.capacity - 1];
if (last_entry)
playlist_free_entry(last_entry);
@ -688,7 +728,7 @@ bool playlist_push_runtime(playlist_t *playlist,
if (playlist->entries)
{
memmove(playlist->entries + 1, playlist->entries,
(playlist->cap - 1) * sizeof(struct playlist_entry));
(playlist->config.capacity - 1) * sizeof(struct playlist_entry));
playlist->entries[0].path = NULL;
playlist->entries[0].core_path = NULL;
@ -739,7 +779,7 @@ success:
* install (iOS)
**/
void playlist_resolve_path(enum playlist_file_mode mode,
char *path, size_t size)
char *path, size_t len)
{
#ifdef HAVE_COCOATOUCH
char tmp[PATH_MAX_LENGTH];
@ -747,7 +787,7 @@ void playlist_resolve_path(enum playlist_file_mode mode,
if (mode == PLAYLIST_LOAD)
{
fill_pathname_expand_special(tmp, path, sizeof(tmp));
strlcpy(path, tmp, size);
strlcpy(path, tmp, len);
}
else
{
@ -760,13 +800,13 @@ void playlist_resolve_path(enum playlist_file_mode mode,
char tmp2[PATH_MAX_LENGTH];
fill_pathname_expand_special(tmp, path, sizeof(tmp));
realpath(tmp, tmp2);
fill_pathname_abbreviate_special(path, tmp2, size);
fill_pathname_abbreviate_special(path, tmp2, len);
}
#else
if (mode == PLAYLIST_LOAD)
return;
path_resolve_realpath(path, size, true);
path_resolve_realpath(path, len, true);
#endif
}
@ -777,8 +817,7 @@ void playlist_resolve_path(enum playlist_file_mode mode,
* Push entry to top of playlist.
**/
bool playlist_push(playlist_t *playlist,
const struct playlist_entry *entry,
bool fuzzy_archive_match)
const struct playlist_entry *entry)
{
size_t i;
char real_path[PATH_MAX_LENGTH];
@ -836,7 +875,7 @@ bool playlist_push(playlist_t *playlist,
const char *entry_path = playlist->entries[i].path;
bool equal_path =
(string_is_empty(real_path) && string_is_empty(entry_path)) ||
playlist_path_equal(real_path, entry_path, fuzzy_archive_match);
playlist_path_equal(real_path, entry_path, &playlist->config);
/* Core name can have changed while still being the same core.
* Differentiate based on the core path only. */
@ -894,7 +933,7 @@ bool playlist_push(playlist_t *playlist,
}
if (!playlist_path_equal(real_rom_path, roms->elems[j].data,
fuzzy_archive_match))
&playlist->config))
{
unequal = true;
break;
@ -944,10 +983,10 @@ bool playlist_push(playlist_t *playlist,
goto success;
}
if (playlist->size == playlist->cap)
if (playlist->size == playlist->config.capacity)
{
struct playlist_entry *last_entry =
&playlist->entries[playlist->cap - 1];
&playlist->entries[playlist->config.capacity - 1];
if (last_entry)
playlist_free_entry(last_entry);
@ -957,7 +996,7 @@ bool playlist_push(playlist_t *playlist,
if (playlist->entries)
{
memmove(playlist->entries + 1, playlist->entries,
(playlist->cap - 1) * sizeof(struct playlist_entry));
(playlist->config.capacity - 1) * sizeof(struct playlist_entry));
playlist->entries[0].path = NULL;
playlist->entries[0].label = NULL;
@ -1053,12 +1092,12 @@ void playlist_write_runtime_file(playlist_t *playlist)
if (!playlist || !playlist->modified)
return;
file = intfstream_open_file(playlist->conf_path,
file = intfstream_open_file(playlist->config.path,
RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE);
if (!file)
{
RARCH_ERR("Failed to write to playlist file: %s\n", playlist->conf_path);
RARCH_ERR("Failed to write to playlist file: %s\n", playlist->config.path);
return;
}
@ -1272,7 +1311,7 @@ void playlist_write_runtime_file(playlist_t *playlist)
playlist->old_format = false;
playlist->compressed = false;
RARCH_LOG("[Playlist]: Written to playlist file: %s\n", playlist->conf_path);
RARCH_LOG("[Playlist]: Written to playlist file: %s\n", playlist->config.path);
end:
intfstream_close(file);
free(file);
@ -1290,12 +1329,7 @@ static JSON_Status JSON_CALL JSON_Writer_WriteSpace_NULL(JSON_Writer writer, siz
return JSON_Success;
}
static JSON_Status (JSON_CALL *json_write_new_line)(JSON_Writer writer) = JSON_Writer_WriteNewLine;
static JSON_Status (JSON_CALL *json_write_space)(JSON_Writer writer, size_t numberOfSpaces) = JSON_Writer_WriteSpace;
void playlist_write_file(
playlist_t *playlist,
bool use_old_format, bool compress)
void playlist_write_file(playlist_t *playlist)
{
size_t i;
intfstream_t *file = NULL;
@ -1311,24 +1345,24 @@ void playlist_write_file(
if (!playlist ||
!(playlist->modified ||
#if defined(HAVE_ZLIB)
(playlist->compressed != compress) ||
(playlist->compressed != playlist->config.compress) ||
#endif
(playlist->old_format != use_old_format)))
(playlist->old_format != playlist->config.old_format)))
return;
#if defined(HAVE_ZLIB)
if (compress)
file = intfstream_open_rzip_file(playlist->conf_path,
if (playlist->config.compress)
file = intfstream_open_rzip_file(playlist->config.path,
RETRO_VFS_FILE_ACCESS_WRITE);
else
#endif
file = intfstream_open_file(playlist->conf_path,
file = intfstream_open_file(playlist->config.path,
RETRO_VFS_FILE_ACCESS_WRITE,
RETRO_VFS_FILE_ACCESS_HINT_NONE);
if (!file)
{
RARCH_ERR("Failed to write to playlist file: %s\n", playlist->conf_path);
RARCH_ERR("Failed to write to playlist file: %s\n", playlist->config.path);
return;
}
@ -1336,7 +1370,7 @@ void playlist_write_file(
compressed = intfstream_is_compressed(file);
#ifdef RARCH_INTERNAL
if (use_old_format)
if (playlist->config.old_format)
{
for (i = 0; i < playlist->size; i++)
intfstream_printf(file, "%s\n%s\n%s\n%s\n%s\n%s\n",
@ -1372,8 +1406,24 @@ void playlist_write_file(
{
char uint_str[4];
JSONContext context = {0};
context.writer = JSON_Writer_Create(NULL);
context.file = file;
/* Assign JSON whitespace functions
* > When compressing playlists, human readability
* is not a factor - can skip all indentation
* and new line characters
* > Create these function pointers locally to
* ensure thread safety */
JSON_Status (JSON_CALL *json_write_new_line)(JSON_Writer writer) =
compressed ?
JSON_Writer_WriteNewLine_NULL :
JSON_Writer_WriteNewLine;
JSON_Status (JSON_CALL *json_write_space)(JSON_Writer writer, size_t numberOfSpaces) =
compressed ?
JSON_Writer_WriteSpace_NULL :
JSON_Writer_WriteSpace;
context.writer = JSON_Writer_Create(NULL);
context.file = file;
if (!context.writer)
{
@ -1381,17 +1431,6 @@ void playlist_write_file(
goto end;
}
/* Assign JSON whitespace functions
* > When compressing playlists, human readability
* is not a factor - can skip all indentation
* and new line characters */
json_write_new_line = compressed ?
JSON_Writer_WriteNewLine_NULL :
JSON_Writer_WriteNewLine;
json_write_space = compressed ?
JSON_Writer_WriteSpace_NULL :
JSON_Writer_WriteSpace;
JSON_Writer_SetOutputEncoding(context.writer, JSON_UTF8);
JSON_Writer_SetOutputHandler(context.writer, &JSONOutputHandler);
JSON_Writer_SetUserData(context.writer, &context);
@ -1693,7 +1732,7 @@ void playlist_write_file(
playlist->modified = false;
playlist->compressed = compressed;
RARCH_LOG("[Playlist]: Written to playlist file: %s\n", playlist->conf_path);
RARCH_LOG("[Playlist]: Written to playlist file: %s\n", playlist->config.path);
end:
intfstream_close(file);
free(file);
@ -1712,10 +1751,6 @@ void playlist_free(playlist_t *playlist)
if (!playlist)
return;
if (playlist->conf_path != NULL)
free(playlist->conf_path);
playlist->conf_path = NULL;
if (playlist->default_core_path != NULL)
free(playlist->default_core_path);
playlist->default_core_path = NULL;
@ -1785,7 +1820,7 @@ size_t playlist_capacity(playlist_t *playlist)
{
if (!playlist)
return 0;
return playlist->cap;
return playlist->config.capacity;
}
static JSON_Parser_HandlerResult JSONStartArrayHandler(JSON_Parser parser)
@ -1851,7 +1886,7 @@ static JSON_Parser_HandlerResult JSONStartObjectHandler(JSON_Parser parser)
{
if ((pCtx->array_depth == 1) && !pCtx->capacity_exceeded)
{
if (pCtx->playlist->size < pCtx->playlist->cap)
if (pCtx->playlist->size < pCtx->playlist->config.capacity)
pCtx->current_entry = &pCtx->playlist->entries[pCtx->playlist->size];
else
{
@ -2132,8 +2167,7 @@ static void get_old_format_metadata_value(
strlcpy(value, start, len);
}
static bool playlist_read_file(
playlist_t *playlist, const char *path)
static bool playlist_read_file(playlist_t *playlist)
{
unsigned i;
int test_char;
@ -2141,21 +2175,23 @@ static bool playlist_read_file(
/* Always use RZIP interface when reading playlists
* > this will automatically handle uncompressed
* data */
intfstream_t *file = intfstream_open_rzip_file(path,
RETRO_VFS_FILE_ACCESS_READ);
intfstream_t *file = intfstream_open_rzip_file(
playlist->config.path,
RETRO_VFS_FILE_ACCESS_READ);
#else
intfstream_t *file = intfstream_open_file(path,
RETRO_VFS_FILE_ACCESS_READ,
RETRO_VFS_FILE_ACCESS_HINT_NONE);
intfstream_t *file = intfstream_open_file(
playlist->config.path,
RETRO_VFS_FILE_ACCESS_READ,
RETRO_VFS_FILE_ACCESS_HINT_NONE);
#endif
playlist->compressed = intfstream_is_compressed(file);
/* If playlist file does not exist,
* create an empty playlist instead */
if (!file)
return true;
playlist->compressed = intfstream_is_compressed(file);
/* Detect format of playlist
* > Read file until we find the first printable
* non-whitespace ASCII character */
@ -2279,7 +2315,7 @@ json_cleanup:
/* Read playlist entries */
playlist->size = 0;
while (playlist->size < playlist->cap)
while (playlist->size < playlist->config.capacity)
{
size_t i;
size_t lines_read = 0;
@ -2480,11 +2516,9 @@ playlist_t *playlist_get_cached(void)
return NULL;
}
bool playlist_init_cached(
const char *path, size_t size,
bool use_old_format, bool compress)
bool playlist_init_cached(const playlist_config_t *config)
{
playlist_t *playlist = playlist_init(path, size);
playlist_t *playlist = playlist_init(config);
if (!playlist)
return false;
@ -2493,10 +2527,10 @@ bool playlist_init_cached(
* file on disk immediately */
if (
#if defined(HAVE_ZLIB)
(playlist->compressed != compress) ||
(playlist->compressed != playlist->config.compress) ||
#endif
(playlist->old_format != use_old_format))
playlist_write_file(playlist, use_old_format, compress);
(playlist->old_format != playlist->config.old_format))
playlist_write_file(playlist);
playlist_cached = playlist;
return true;
@ -2504,33 +2538,33 @@ bool playlist_init_cached(
/**
* playlist_init:
* @path : Path to playlist contents file.
* @size : Maximum capacity of playlist size.
* @config : Playlist configuration object.
*
* Creates and initializes a playlist.
*
* Returns: handle to new playlist if successful, otherwise NULL
**/
playlist_t *playlist_init(const char *path, size_t size)
playlist_t *playlist_init(const playlist_config_t *config)
{
struct playlist_entry *entries = NULL;
playlist_t *playlist = (playlist_t*)malloc(sizeof(*playlist));
if (!playlist)
return NULL;
entries = (struct playlist_entry*)calloc(size, sizeof(*entries));
/* Cache configuration parameters */
if (!playlist || !playlist_config_copy(config, &playlist->config))
goto error;
/* Create entries array */
entries = (struct playlist_entry*)calloc(
playlist->config.capacity, sizeof(*entries));
if (!entries)
{
free(playlist);
return NULL;
}
goto error;
/* Set initial values */
playlist->modified = false;
playlist->old_format = false;
playlist->compressed = false;
playlist->size = 0;
playlist->cap = size;
playlist->conf_path = strdup(path);
playlist->default_core_name = NULL;
playlist->default_core_path = NULL;
playlist->entries = entries;
@ -2539,9 +2573,16 @@ playlist_t *playlist_init(const char *path, size_t size)
playlist->left_thumbnail_mode = PLAYLIST_THUMBNAIL_MODE_DEFAULT;
playlist->sort_mode = PLAYLIST_SORT_MODE_DEFAULT;
playlist_read_file(playlist, path);
/* Attempt to read any existing playlist file */
playlist_read_file(playlist);
return playlist;
error:
if (playlist)
free(playlist);
return NULL;
}
static int playlist_qsort_func(const struct playlist_entry *a,
@ -2638,24 +2679,19 @@ void playlist_qsort(playlist_t *playlist)
void command_playlist_push_write(
playlist_t *playlist,
const struct playlist_entry *entry,
bool fuzzy_archive_match,
bool use_old_format,
bool compress)
const struct playlist_entry *entry)
{
if (!playlist)
return;
if (playlist_push(playlist, entry, fuzzy_archive_match))
playlist_write_file(playlist, use_old_format, compress);
if (playlist_push(playlist, entry))
playlist_write_file(playlist);
}
void command_playlist_update_write(
playlist_t *plist,
size_t idx,
const struct playlist_entry *entry,
bool use_old_format,
bool compress)
const struct playlist_entry *entry)
{
playlist_t *playlist = plist ? plist : playlist_get_cached();
@ -2667,7 +2703,7 @@ void command_playlist_update_write(
idx,
entry);
playlist_write_file(playlist, use_old_format, compress);
playlist_write_file(playlist);
}
bool playlist_index_is_valid(playlist_t *playlist, size_t idx,
@ -2686,7 +2722,7 @@ bool playlist_index_is_valid(playlist_t *playlist, size_t idx,
bool playlist_entries_are_equal(
const struct playlist_entry *entry_a,
const struct playlist_entry *entry_b,
bool fuzzy_archive_match)
const playlist_config_t *config)
{
char real_path_a[PATH_MAX_LENGTH];
char real_core_path_a[PATH_MAX_LENGTH];
@ -2695,7 +2731,7 @@ bool playlist_entries_are_equal(
real_core_path_a[0] = '\0';
/* Sanity check */
if (!entry_a || !entry_b)
if (!entry_a || !entry_b || !config)
return false;
if (string_is_empty(entry_a->path) &&
@ -2712,7 +2748,7 @@ bool playlist_entries_are_equal(
}
if (!playlist_path_equal(
real_path_a, entry_b->path, fuzzy_archive_match))
real_path_a, entry_b->path, config))
return false;
/* Check core paths */
@ -2749,16 +2785,16 @@ void playlist_get_db_name(playlist_t *playlist, size_t idx,
*db_name = playlist->entries[idx].db_name;
else
{
const char *conf_path_basename = path_basename(playlist->conf_path);
const char *conf_path_basename = path_basename(playlist->config.path);
/* Only use file basename if this is a 'collection' playlist
* (i.e. ignore history/favourites) */
if (
!string_is_empty(conf_path_basename)
&& !string_ends_with_size(playlist->conf_path, "_history.lpl",
strlen(playlist->conf_path), STRLEN_CONST("_history.lpl"))
&& !string_ends_with_size(conf_path_basename, "_history.lpl",
strlen(conf_path_basename), STRLEN_CONST("_history.lpl"))
&& !string_is_equal(conf_path_basename,
file_path_str(FILE_PATH_CONTENT_FAVORITES))
file_path_str(FILE_PATH_CONTENT_FAVORITES))
)
*db_name = conf_path_basename;
}

View file

@ -114,16 +114,39 @@ struct playlist_entry
unsigned last_played_second;
};
/* Holds all configuration parameters required
* when initialising/saving playlists */
typedef struct
{
char path[PATH_MAX_LENGTH];
size_t capacity;
bool old_format;
bool compress;
bool fuzzy_archive_match;
} playlist_config_t;
/* Convenience function: copies specified playlist
* path to specified playlist configuration object */
void playlist_config_set_path(playlist_config_t *config, const char *path);
/* Creates a copy of the specified playlist configuration.
* Returns false in the event of an error */
bool playlist_config_copy(const playlist_config_t *src, playlist_config_t *dst);
/* Returns internal playlist configuration object
* of specified playlist.
* Returns NULL it the event of an error. */
playlist_config_t *playlist_get_config(playlist_t *playlist);
/**
* playlist_init:
* @path : Path to playlist contents file.
* @size : Maximum capacity of playlist size.
* @config : Playlist configuration object.
*
* Creates and initializes a playlist.
*
* Returns: handle to new playlist if successful, otherwise NULL
**/
playlist_t *playlist_init(const char *path, size_t size);
playlist_t *playlist_init(const playlist_config_t *config);
/**
* playlist_free:
@ -189,8 +212,7 @@ void playlist_delete_index(playlist_t *playlist,
* matching 'search_path'
**/
void playlist_delete_by_path(playlist_t *playlist,
const char *search_path,
bool fuzzy_archive_match);
const char *search_path);
/**
* playlist_resolve_path:
@ -205,24 +227,19 @@ void playlist_delete_by_path(playlist_t *playlist,
* install (iOS)
**/
void playlist_resolve_path(enum playlist_file_mode mode,
char *path, size_t size);
char *path, size_t len);
/**
* playlist_push:
* @playlist : Playlist handle.
* @path : Path of new playlist entry.
* @core_path : Core path of new playlist entry.
* @core_name : Core name of new playlist entry.
*
* Push entry to top of playlist.
**/
bool playlist_push(playlist_t *playlist,
const struct playlist_entry *entry,
bool fuzzy_archive_match);
const struct playlist_entry *entry);
bool playlist_push_runtime(playlist_t *playlist,
const struct playlist_entry *entry,
bool fuzzy_archive_match);
const struct playlist_entry *entry);
void playlist_update(playlist_t *playlist, size_t idx,
const struct playlist_entry *update_entry);
@ -238,19 +255,16 @@ void playlist_update_runtime(playlist_t *playlist, size_t idx,
void playlist_get_index_by_path(playlist_t *playlist,
const char *search_path,
const struct playlist_entry **entry,
bool fuzzy_archive_match);
const struct playlist_entry **entry);
bool playlist_entry_exists(playlist_t *playlist,
const char *path, bool fuzzy_archive_match);
const char *path);
char *playlist_get_conf_path(playlist_t *playlist);
uint32_t playlist_get_size(playlist_t *playlist);
void playlist_write_file(
playlist_t *playlist,
bool use_old_format, bool compress);
void playlist_write_file(playlist_t *playlist);
void playlist_write_runtime_file(playlist_t *playlist);
@ -261,30 +275,23 @@ void playlist_free_cached(void);
playlist_t *playlist_get_cached(void);
/* If current on-disk playlist file referenced
* by 'path' does not match requested 'old format'
* or 'compression' state, file will be updated
* automatically
* by 'config->path' does not match requested
* 'old format' or 'compression' state, file will
* be updated automatically
* > Since this function is called whenever a
* playlist is browsed via the menu, this is
* a simple method for ensuring that files
* are always kept synced with user settings */
bool playlist_init_cached(
const char *path, size_t size,
bool use_old_format, bool compress);
bool playlist_init_cached(const playlist_config_t *config);
void command_playlist_push_write(
playlist_t *playlist,
const struct playlist_entry *entry,
bool fuzzy_archive_match,
bool use_old_format,
bool compress);
const struct playlist_entry *entry);
void command_playlist_update_write(
playlist_t *playlist,
size_t idx,
const struct playlist_entry *entry,
bool use_old_format,
bool compress);
const struct playlist_entry *entry);
/* Returns true if specified playlist index matches
* specified content/core paths */
@ -296,7 +303,7 @@ bool playlist_index_is_valid(playlist_t *playlist, size_t idx,
bool playlist_entries_are_equal(
const struct playlist_entry *entry_a,
const struct playlist_entry *entry_b,
bool fuzzy_archive_match);
const playlist_config_t *config);
void playlist_get_crc32(playlist_t *playlist, size_t idx,
const char **crc32);

View file

@ -7990,7 +7990,7 @@ static void handle_discord_join_cb(retro_task_t *task,
room->gamename, join_hostname, room->corename, room->subsystem_name);
discord_st->connecting = true;
if (discord_st->ready)
discord_update(DISCORD_PRESENCE_NETPLAY_CLIENT, false);
discord_update(DISCORD_PRESENCE_NETPLAY_CLIENT);
}
finish:
@ -8088,7 +8088,7 @@ static void handle_discord_join_request(const DiscordUser* request)
#endif
}
void discord_update(enum discord_presence presence, bool fuzzy_archive_match)
void discord_update(enum discord_presence presence)
{
struct rarch_state *p_rarch = &rarch_st;
discord_state_t *discord_st = &p_rarch->discord_st;
@ -8147,8 +8147,7 @@ void discord_update(enum discord_presence presence, bool fuzzy_archive_match)
playlist_get_index_by_path(
current_playlist,
path_get(RARCH_PATH_CONTENT),
&entry,
fuzzy_archive_match);
&entry);
if (entry && !string_is_empty(entry->label))
label = entry->label;
@ -13271,7 +13270,6 @@ static bool run_translation_service(
struct scaler_ctx *scaler = (struct scaler_ctx*)
calloc(1, sizeof(struct scaler_ctx));
bool error = false;
bool playlist_fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
uint8_t *bmp_buffer = NULL;
uint64_t buffer_bytes = 0;
@ -13327,8 +13325,7 @@ static bool run_translation_service(
if (current_playlist)
{
playlist_get_index_by_path(
current_playlist, path_get(RARCH_PATH_CONTENT), &entry,
playlist_fuzzy_archive_match);
current_playlist, path_get(RARCH_PATH_CONTENT), &entry);
if (entry && !string_is_empty(entry->label))
label = entry->label;
@ -15411,20 +15408,14 @@ bool command_event(enum event_command cmd, void *data)
case CMD_EVENT_HISTORY_DEINIT:
if (g_defaults.content_history)
{
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_write_file(g_defaults.content_history,
playlist_use_old_format, playlist_compression);
playlist_write_file(g_defaults.content_history);
playlist_free(g_defaults.content_history);
}
g_defaults.content_history = NULL;
if (g_defaults.music_history)
{
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_write_file(g_defaults.music_history,
playlist_use_old_format, playlist_compression);
playlist_write_file(g_defaults.music_history);
playlist_free(g_defaults.music_history);
}
g_defaults.music_history = NULL;
@ -15432,10 +15423,7 @@ bool command_event(enum event_command cmd, void *data)
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV)
if (g_defaults.video_history)
{
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_write_file(g_defaults.video_history,
playlist_use_old_format, playlist_compression);
playlist_write_file(g_defaults.video_history);
playlist_free(g_defaults.video_history);
}
g_defaults.video_history = NULL;
@ -15444,10 +15432,7 @@ bool command_event(enum event_command cmd, void *data)
#ifdef HAVE_IMAGEVIEWER
if (g_defaults.image_history)
{
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_write_file(g_defaults.image_history,
playlist_use_old_format, playlist_compression);
playlist_write_file(g_defaults.image_history);
playlist_free(g_defaults.image_history);
}
g_defaults.image_history = NULL;
@ -15455,9 +15440,9 @@ bool command_event(enum event_command cmd, void *data)
break;
case CMD_EVENT_HISTORY_INIT:
{
unsigned content_history_size = settings->uints.content_history_size;
bool history_list_enable = settings->bools.history_list_enable;
const char *path_content_history = settings->paths.path_content_history;
playlist_config_t playlist_config;
bool history_list_enable = settings->bools.history_list_enable;
const char *path_content_history = settings->paths.path_content_history;
const char *path_content_music_history = settings->paths.path_content_music_history;
#if defined(HAVE_FFMPEG) || defined(HAVE_MPV)
const char *path_content_video_history = settings->paths.path_content_video_history;
@ -15465,6 +15450,10 @@ bool command_event(enum event_command cmd, void *data)
#ifdef HAVE_IMAGEVIEWER
const char *path_content_image_history = settings->paths.path_content_image_history;
#endif
playlist_config.capacity = settings->uints.content_history_size;
playlist_config.old_format = settings->bools.playlist_use_old_format;
playlist_config.compress = settings->bools.playlist_compression;
playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
command_event(CMD_EVENT_HISTORY_DEINIT, NULL);
@ -15473,22 +15462,19 @@ bool command_event(enum event_command cmd, void *data)
/* Note: Sorting is disabled by default for
* all content history playlists */
RARCH_LOG("[Playlist]: %s: [%s].\n",
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
path_content_history);
g_defaults.content_history = playlist_init(
path_content_history,
content_history_size);
playlist_config_set_path(&playlist_config, path_content_history);
g_defaults.content_history = playlist_init(&playlist_config);
playlist_set_sort_mode(
g_defaults.content_history, PLAYLIST_SORT_MODE_OFF);
RARCH_LOG("[Playlist]: %s: [%s].\n",
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
path_content_music_history);
g_defaults.music_history = playlist_init(
path_content_music_history,
content_history_size);
playlist_config_set_path(&playlist_config, path_content_music_history);
g_defaults.music_history = playlist_init(&playlist_config);
playlist_set_sort_mode(
g_defaults.music_history, PLAYLIST_SORT_MODE_OFF);
@ -15496,9 +15482,8 @@ bool command_event(enum event_command cmd, void *data)
RARCH_LOG("[Playlist]: %s: [%s].\n",
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
path_content_video_history);
g_defaults.video_history = playlist_init(
path_content_video_history,
content_history_size);
playlist_config_set_path(&playlist_config, path_content_video_history);
g_defaults.video_history = playlist_init(&playlist_config);
playlist_set_sort_mode(
g_defaults.video_history, PLAYLIST_SORT_MODE_OFF);
#endif
@ -15507,9 +15492,8 @@ bool command_event(enum event_command cmd, void *data)
RARCH_LOG("[Playlist]: %s: [%s].\n",
msg_hash_to_str(MSG_LOADING_HISTORY_FILE),
path_content_image_history);
g_defaults.image_history = playlist_init(
path_content_image_history,
content_history_size);
playlist_config_set_path(&playlist_config, path_content_image_history);
g_defaults.image_history = playlist_init(&playlist_config);
playlist_set_sort_mode(
g_defaults.image_history, PLAYLIST_SORT_MODE_OFF);
#endif
@ -15662,11 +15646,8 @@ bool command_event(enum event_command cmd, void *data)
{
if (str_list->size >= 6)
{
struct playlist_entry entry = {0};
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
bool playlist_sort_alphabetical = settings->bools.playlist_sort_alphabetical;
bool playlist_fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
struct playlist_entry entry = {0};
bool playlist_sort_alphabetical = settings->bools.playlist_sort_alphabetical;
entry.path = str_list->elems[0].data; /* content_path */
entry.label = str_list->elems[1].data; /* content_label */
@ -15676,8 +15657,7 @@ bool command_event(enum event_command cmd, void *data)
entry.db_name = str_list->elems[5].data; /* db_name */
/* Write playlist entry */
if (playlist_push(g_defaults.content_favorites, &entry,
playlist_fuzzy_archive_match))
if (playlist_push(g_defaults.content_favorites, &entry))
{
enum playlist_sort_mode current_sort_mode =
playlist_get_sort_mode(g_defaults.content_favorites);
@ -15687,8 +15667,7 @@ bool command_event(enum event_command cmd, void *data)
(current_sort_mode == PLAYLIST_SORT_MODE_ALPHABETICAL))
playlist_qsort(g_defaults.content_favorites);
playlist_write_file(g_defaults.content_favorites,
playlist_use_old_format, playlist_compression);
playlist_write_file(g_defaults.content_favorites);
runloop_msg_queue_push(msg_hash_to_str(MSG_ADDED_TO_FAVORITES), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
}
}
@ -15702,8 +15681,6 @@ bool command_event(enum event_command cmd, void *data)
const char *core_path = "DETECT";
size_t *playlist_index = (size_t*)data;
struct playlist_entry entry = {0};
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
/* the update function reads our entry as const,
* so these casts are safe */
@ -15711,11 +15688,7 @@ bool command_event(enum event_command cmd, void *data)
entry.core_name = (char*)core_name;
command_playlist_update_write(
NULL,
*playlist_index,
&entry,
playlist_use_old_format,
playlist_compression);
NULL, *playlist_index, &entry);
runloop_msg_queue_push(msg_hash_to_str(MSG_RESET_CORE_ASSOCIATION), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
break;
@ -16301,15 +16274,14 @@ bool command_event(enum event_command cmd, void *data)
case CMD_EVENT_DISCORD_UPDATE:
{
#ifdef HAVE_DISCORD
discord_state_t *discord_st = &p_rarch->discord_st;
discord_state_t *discord_st = &p_rarch->discord_st;
if (!data || !discord_st->ready)
return false;
bool playlist_fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
discord_userdata_t *userdata = (discord_userdata_t*)data;
discord_userdata_t *userdata = (discord_userdata_t*)data;
if (discord_st->ready)
discord_update(userdata->status, playlist_fuzzy_archive_match);
discord_update(userdata->status);
#endif
}
break;
@ -38223,8 +38195,7 @@ int runloop_iterate(void)
#ifdef HAVE_DISCORD
if (discord_is_inited && discord_st->ready)
discord_update(DISCORD_PRESENCE_GAME,
settings->bools.playlist_fuzzy_archive_match);
discord_update(DISCORD_PRESENCE_GAME);
#endif
for (i = 0; i < max_users; i++)
@ -38447,27 +38418,32 @@ enum retro_language rarch_get_language_from_iso(const char *iso639)
void rarch_favorites_init(void)
{
struct rarch_state *p_rarch = &rarch_st;
settings_t *settings = p_rarch->configuration_settings;
int content_favorites_size = settings ? settings->ints.content_favorites_size : 0;
const char *path_content_favorites = settings ? settings->paths.path_content_favorites : NULL;
bool playlist_sort_alphabetical = settings ? settings->bools.playlist_sort_alphabetical : false;
struct rarch_state *p_rarch = &rarch_st;
settings_t *settings = p_rarch->configuration_settings;
int content_favorites_size = settings ? settings->ints.content_favorites_size : 0;
const char *path_content_favorites = settings ? settings->paths.path_content_favorites : NULL;
bool playlist_sort_alphabetical = settings ? settings->bools.playlist_sort_alphabetical : false;
playlist_config_t playlist_config;
enum playlist_sort_mode current_sort_mode;
playlist_config.capacity = COLLECTION_SIZE;
playlist_config.old_format = settings ? settings->bools.playlist_use_old_format : false;
playlist_config.compress = settings ? settings->bools.playlist_compression : false;
playlist_config.fuzzy_archive_match = settings ? settings->bools.playlist_fuzzy_archive_match : false;
if (!settings)
return;
if (content_favorites_size < 0)
content_favorites_size = COLLECTION_SIZE;
if (content_favorites_size >= 0)
playlist_config.capacity = (size_t)content_favorites_size;
rarch_favorites_deinit();
RARCH_LOG("[Playlist]: %s: [%s].\n",
msg_hash_to_str(MSG_LOADING_FAVORITES_FILE),
path_content_favorites);
g_defaults.content_favorites = playlist_init(
path_content_favorites,
(unsigned)content_favorites_size);
playlist_config_set_path(&playlist_config, path_content_favorites);
g_defaults.content_favorites = playlist_init(&playlist_config);
/* Get current per-playlist sort mode */
current_sort_mode = playlist_get_sort_mode(g_defaults.content_favorites);
@ -38483,13 +38459,7 @@ void rarch_favorites_deinit(void)
{
if (g_defaults.content_favorites)
{
struct rarch_state *p_rarch = &rarch_st;
settings_t *settings = p_rarch->configuration_settings;
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_write_file(g_defaults.content_favorites,
playlist_use_old_format, playlist_compression);
playlist_write_file(g_defaults.content_favorites);
playlist_free(g_defaults.content_favorites);
g_defaults.content_favorites = NULL;
}

View file

@ -1419,11 +1419,7 @@ static void task_push_to_history_list(
entry.subsystem_name = (char*)subsystem_name;
entry.subsystem_roms = (struct string_list*)path_get_subsystem_list();
command_playlist_push_write(
playlist_hist, &entry,
settings->bools.playlist_fuzzy_archive_match,
settings->bools.playlist_use_old_format,
settings->bools.playlist_compression);
command_playlist_push_write(playlist_hist, &entry);
}
}

View file

@ -58,9 +58,7 @@ typedef struct database_state_handle
typedef struct db_handle
{
bool pl_fuzzy_archive_match;
bool pl_use_old_format;
bool pl_compression;
playlist_config_t playlist_config;
bool is_directory;
bool scan_started;
bool scan_without_core_match;
@ -762,7 +760,8 @@ static int database_info_list_iterate_found_match(
fill_pathname_join(db_playlist_path, _db->playlist_directory,
db_playlist_base_str, PATH_MAX_LENGTH * sizeof(char));
playlist = playlist_init(db_playlist_path, COLLECTION_SIZE);
playlist_config_set_path(&_db->playlist_config, db_playlist_path);
playlist = playlist_init(&_db->playlist_config);
snprintf(db_crc, PATH_MAX_LENGTH * sizeof(char),
"%08X|crc", db_info_entry->crc32);
@ -804,8 +803,7 @@ static int database_info_list_iterate_found_match(
fprintf(stderr, "entry path str: %s\n", entry_path_str);
#endif
if (!playlist_entry_exists(playlist, entry_path_str,
_db->pl_fuzzy_archive_match))
if (!playlist_entry_exists(playlist, entry_path_str))
{
struct playlist_entry entry;
@ -830,11 +828,10 @@ static int database_info_list_iterate_found_match(
entry.last_played_minute= 0;
entry.last_played_second= 0;
playlist_push(playlist, &entry, _db->pl_fuzzy_archive_match);
playlist_push(playlist, &entry);
}
playlist_write_file(
playlist, _db->pl_use_old_format, _db->pl_compression);
playlist_write_file(playlist);
playlist_free(playlist);
database_info_list_free(db_state->info);
@ -993,12 +990,12 @@ static int task_database_iterate_playlist_lutro(
"Lutro.lpl",
PATH_MAX_LENGTH * sizeof(char));
playlist = playlist_init(db_playlist_path, COLLECTION_SIZE);
playlist_config_set_path(&_db->playlist_config, db_playlist_path);
playlist = playlist_init(&_db->playlist_config);
free(db_playlist_path);
if (!playlist_entry_exists(playlist, path,
_db->pl_fuzzy_archive_match))
if (!playlist_entry_exists(playlist, path))
{
struct playlist_entry entry;
char *game_title = (char*)
@ -1030,13 +1027,12 @@ static int task_database_iterate_playlist_lutro(
entry.last_played_minute = 0;
entry.last_played_second = 0;
playlist_push(playlist, &entry, _db->pl_fuzzy_archive_match);
playlist_push(playlist, &entry);
free(game_title);
}
playlist_write_file(
playlist, _db->pl_use_old_format, _db->pl_compression);
playlist_write_file(playlist);
playlist_free(playlist);
return 0;
@ -1349,38 +1345,40 @@ bool task_push_dbscan(
bool db_dir_show_hidden_files,
retro_task_callback_t cb)
{
retro_task_t *t = task_init();
retro_task_t *t = task_init();
#ifdef RARCH_INTERNAL
settings_t *settings = config_get_ptr();
settings_t *settings = config_get_ptr();
#endif
db_handle_t *db = (db_handle_t*)calloc(1, sizeof(db_handle_t));
db_handle_t *db = (db_handle_t*)calloc(1, sizeof(db_handle_t));
if (!t || !db)
goto error;
t->handler = task_database_handler;
t->state = db;
t->callback = cb;
t->title = strdup(msg_hash_to_str(
t->handler = task_database_handler;
t->state = db;
t->callback = cb;
t->title = strdup(msg_hash_to_str(
MSG_PREPARING_FOR_CONTENT_SCAN));
t->alternative_look = true;
t->alternative_look = true;
#ifdef RARCH_INTERNAL
t->progress_cb = task_database_progress_cb;
db->scan_without_core_match = settings->bools.scan_without_core_match;
db->pl_fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
db->pl_use_old_format = settings->bools.playlist_use_old_format;
db->pl_compression = settings->bools.playlist_compression;
t->progress_cb = task_database_progress_cb;
db->scan_without_core_match = settings->bools.scan_without_core_match;
db->playlist_config.capacity = COLLECTION_SIZE;
db->playlist_config.old_format = settings->bools.playlist_use_old_format;
db->playlist_config.compress = settings->bools.playlist_compression;
db->playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
#else
db->pl_fuzzy_archive_match = false;
db->pl_use_old_format = false;
db->pl_compression = false;
db->playlist_config.capacity = COLLECTION_SIZE;
db->playlist_config.old_format = false;
db->playlist_config.compress = false;
db->playlist_config.fuzzy_archive_match = false;
#endif
db->show_hidden_files = db_dir_show_hidden_files;
db->is_directory = directory;
db->fullpath = strdup(fullpath);
db->playlist_directory = strdup(playlist_directory);
db->content_database_path = strdup(content_database);
db->show_hidden_files = db_dir_show_hidden_files;
db->is_directory = directory;
db->fullpath = strdup(fullpath);
db->playlist_directory = strdup(playlist_directory);
db->content_database_path = strdup(content_database);
task_queue_push(t);

View file

@ -53,6 +53,7 @@ enum manual_scan_status
typedef struct manual_scan_handle
{
manual_content_scan_task_config_t *task_config;
playlist_config_t playlist_config;
playlist_t *playlist;
struct string_list *content_list;
logiqx_dat_t *dat_file;
@ -61,9 +62,6 @@ typedef struct manual_scan_handle
struct string_list *m3u_list;
size_t m3u_index;
enum manual_scan_status status;
bool fuzzy_archive_match;
bool use_old_format;
bool compress;
} manual_scan_handle_t;
/* Frees task handle + all constituent objects */
@ -139,13 +137,23 @@ static void cb_task_manual_content_scan(
if (cached_playlist)
{
if (string_is_equal(
manual_scan->task_config->playlist_file,
manual_scan->playlist_config.path,
playlist_get_conf_path(cached_playlist)))
{
playlist_free_cached();
playlist_init_cached(
manual_scan->task_config->playlist_file, COLLECTION_SIZE,
manual_scan->use_old_format, manual_scan->compress);
playlist_config_t playlist_config;
/* Copy configuration of cached playlist
* (could use manual_scan->playlist_config,
* but doing it this way guarantees that
* the cached playlist is preserved in
* its original state) */
if (playlist_config_copy(
playlist_get_config(cached_playlist),
&playlist_config))
{
playlist_free_cached();
playlist_init_cached(&playlist_config);
}
}
}
@ -223,8 +231,7 @@ static void task_manual_content_scan_handler(retro_task_t *task)
}
/* Open playlist */
manual_scan->playlist = playlist_init(
manual_scan->task_config->playlist_file, COLLECTION_SIZE);
manual_scan->playlist = playlist_init(&manual_scan->playlist_config);
if (!manual_scan->playlist)
goto task_finished;
@ -276,8 +283,7 @@ static void task_manual_content_scan_handler(retro_task_t *task)
/* Add content to playlist */
manual_content_scan_add_content_to_playlist(
manual_scan->task_config, manual_scan->playlist,
content_path, content_type, manual_scan->dat_file,
manual_scan->fuzzy_archive_match);
content_path, content_type, manual_scan->dat_file);
/* If this is an M3U file, add it to the
* M3U list for later processing */
@ -348,9 +354,7 @@ static void task_manual_content_scan_handler(retro_task_t *task)
* content path of the M3U entry */
if (m3u_file_get_entry(m3u_file, i, &m3u_entry))
playlist_delete_by_path(
manual_scan->playlist,
m3u_entry->full_path,
manual_scan->fuzzy_archive_match);
manual_scan->playlist, m3u_entry->full_path);
}
m3u_file_free(m3u_file);
@ -375,10 +379,7 @@ static void task_manual_content_scan_handler(retro_task_t *task)
playlist_qsort(manual_scan->playlist);
/* Save playlist changes to disk */
playlist_write_file(
manual_scan->playlist,
manual_scan->use_old_format,
manual_scan->compress);
playlist_write_file(manual_scan->playlist);
/* Update progress display */
task_free_title(task);
@ -420,22 +421,25 @@ static bool task_manual_content_scan_finder(retro_task_t *task, void *user_data)
return false;
return string_is_equal(
(const char*)user_data, manual_scan->task_config->playlist_file);
(const char*)user_data, manual_scan->playlist_config.path);
}
bool task_push_manual_content_scan(void)
bool task_push_manual_content_scan(
const playlist_config_t *playlist_config,
const char *playlist_directory)
{
task_finder_data_t find_data;
char task_title[PATH_MAX_LENGTH];
retro_task_t *task = NULL;
settings_t *settings = config_get_ptr();
manual_scan_handle_t *manual_scan = (manual_scan_handle_t*)
calloc(1, sizeof(manual_scan_handle_t));
task_title[0] = '\0';
/* Sanity check */
if (!manual_scan)
if (!playlist_config ||
string_is_empty(playlist_directory) ||
!manual_scan)
goto error;
/* Configure handle */
@ -448,9 +452,6 @@ bool task_push_manual_content_scan(void)
manual_scan->m3u_list = string_list_new();
manual_scan->m3u_index = 0;
manual_scan->status = MANUAL_SCAN_BEGIN;
manual_scan->fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
manual_scan->use_old_format = settings->bools.playlist_use_old_format;
manual_scan->compress = settings->bools.playlist_compression;
if (!manual_scan->m3u_list)
goto error;
@ -463,9 +464,7 @@ bool task_push_manual_content_scan(void)
goto error;
if (!manual_content_scan_get_task_config(
manual_scan->task_config,
settings->paths.directory_playlist
))
manual_scan->task_config, playlist_directory))
{
runloop_msg_queue_push(
msg_hash_to_str(MSG_MANUAL_CONTENT_SCAN_INVALID_CONFIG),
@ -474,10 +473,19 @@ bool task_push_manual_content_scan(void)
goto error;
}
/* > Cache playlist configuration */
if (!playlist_config_copy(playlist_config,
&manual_scan->playlist_config))
goto error;
playlist_config_set_path(
&manual_scan->playlist_config,
manual_scan->task_config->playlist_file);
/* Concurrent scanning of content to the same
* playlist is not allowed */
find_data.func = task_manual_content_scan_finder;
find_data.userdata = (void*)manual_scan->task_config->playlist_file;
find_data.userdata = (void*)manual_scan->playlist_config.path;
if (task_queue_find(&find_data))
goto error;

View file

@ -52,6 +52,7 @@ typedef struct
bool current;
bool contentless;
struct string_list *lpl_list;
playlist_config_t playlist_config;
} netplay_crc_handle_t;
static void netplay_crc_scan_callback(retro_task_t *task,
@ -272,7 +273,8 @@ 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, COLLECTION_SIZE);
playlist_config_set_path(&state->playlist_config, lpl_path);
playlist = playlist_init(&state->playlist_config);
playlist_size = playlist_get_size(playlist);
for (j = 0; j < playlist_size; j++)
@ -348,7 +350,8 @@ static void task_netplay_crc_scan_handler(retro_task_t *task)
continue;
RARCH_LOG("[Lobby]: Searching content %d/%d (%s) in playlist: %s\n", i + 1, game_list->size, game_list->elems[i].data, lpl_path);
playlist = playlist_init(lpl_path, COLLECTION_SIZE);
playlist_config_set_path(&state->playlist_config, lpl_path);
playlist = playlist_init(&state->playlist_config);
playlist_size = playlist_get_size(playlist);
for (k = 0; k < playlist_size && !found[i]; k++)
@ -430,6 +433,11 @@ bool task_push_netplay_crc_scan(uint32_t crc, char* name,
if (!task || !state)
goto error;
state->playlist_config.capacity = COLLECTION_SIZE;
state->playlist_config.old_format = settings->bools.playlist_use_old_format;
state->playlist_config.compress = settings->bools.playlist_compression;
state->playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
state->content_crc[0] = '\0';
state->content_path[0] = '\0';
state->hostname[0] = '\0';

View file

@ -65,6 +65,7 @@ typedef struct pl_thumb_handle
char *playlist_path;
char *dir_thumbnails;
playlist_t *playlist;
playlist_config_t playlist_config;
gfx_thumbnail_path_data_t *thumbnail_path_data;
retro_task_t *http_task;
} pl_thumb_handle_t;
@ -344,10 +345,10 @@ static void task_pl_thumbnail_download_handler(retro_task_t *task)
case PL_THUMB_BEGIN:
{
/* Load playlist */
if (!path_is_valid(pl_thumb->playlist_path))
if (!path_is_valid(pl_thumb->playlist_config.path))
goto task_finished;
pl_thumb->playlist = playlist_init(pl_thumb->playlist_path, COLLECTION_SIZE);
pl_thumb->playlist = playlist_init(&pl_thumb->playlist_config);
if (!pl_thumb->playlist)
goto task_finished;
@ -468,32 +469,37 @@ static bool task_pl_thumbnail_finder(retro_task_t *task, void *user_data)
if (!pl_thumb)
return false;
return string_is_equal((const char*)user_data, pl_thumb->playlist_path);
return string_is_equal((const char*)user_data, pl_thumb->playlist_config.path);
}
bool task_push_pl_thumbnail_download(
const char *system, const char *playlist_path,
const char *system,
const playlist_config_t *playlist_config,
const char *dir_thumbnails)
{
task_finder_data_t find_data;
retro_task_t *task = task_init();
pl_thumb_handle_t *pl_thumb = (pl_thumb_handle_t*)calloc(1, sizeof(pl_thumb_handle_t));
const char *playlist_file = path_basename(playlist_path);
const char *playlist_file = NULL;
/* Sanity check */
if (!task || !pl_thumb)
if (!playlist_config || !task || !pl_thumb)
goto error;
if (string_is_empty(system) ||
string_is_empty(playlist_path) ||
string_is_empty(playlist_file) ||
string_is_empty(playlist_config->path) ||
string_is_empty(dir_thumbnails))
goto error;
playlist_file = path_basename(playlist_config->path);
if (string_is_empty(playlist_file))
goto error;
/* Only parse supported playlist types */
if (
string_ends_with_size(playlist_path, "_history.lpl",
strlen(playlist_path),
string_ends_with_size(playlist_file, "_history.lpl",
strlen(playlist_file),
STRLEN_CONST("_history.lpl")
)
|| string_is_equal(playlist_file,
@ -505,21 +511,17 @@ bool task_push_pl_thumbnail_download(
/* Concurrent download of thumbnails for the same
* playlist is not allowed */
find_data.func = task_pl_thumbnail_finder;
find_data.userdata = (void*)playlist_path;
find_data.userdata = (void*)playlist_config->path;
if (task_queue_find(&find_data))
goto error;
/* Configure task */
task->handler = task_pl_thumbnail_download_handler;
task->state = pl_thumb;
task->title = strdup(system);
task->alternative_look = true;
task->progress = 0;
/* Configure handle */
if (!playlist_config_copy(playlist_config, &pl_thumb->playlist_config))
goto error;
pl_thumb->system = strdup(system);
pl_thumb->playlist_path = strdup(playlist_path);
pl_thumb->playlist_path = NULL;
pl_thumb->dir_thumbnails = strdup(dir_thumbnails);
pl_thumb->playlist = NULL;
pl_thumb->thumbnail_path_data = NULL;
@ -531,6 +533,13 @@ bool task_push_pl_thumbnail_download(
pl_thumb->overwrite = false;
pl_thumb->status = PL_THUMB_BEGIN;
/* Configure task */
task->handler = task_pl_thumbnail_download_handler;
task->state = pl_thumb;
task->title = strdup(system);
task->alternative_look = true;
task->progress = 0;
task_queue_push(task);
return true;
@ -764,7 +773,7 @@ static bool task_pl_entry_thumbnail_finder(retro_task_t *task, void *user_data)
return false;
return (entry_id->idx == pl_thumb->list_index) &&
string_is_equal(entry_id->playlist_path, pl_thumb->playlist_path);
string_is_equal(entry_id->playlist_path, pl_thumb->playlist_path);
}
bool task_push_pl_entry_thumbnail_download(
@ -839,17 +848,8 @@ bool task_push_pl_entry_thumbnail_download(
thumbnail_path_data, playlist, idx))
goto error;
/* Configure task */
task->handler = task_pl_entry_thumbnail_download_handler;
task->state = pl_thumb;
task->title = strdup(system);
task->alternative_look = true;
task->mute = mute;
task->progress = 0;
task->callback = cb_task_pl_entry_thumbnail_refresh_menu;
task->cleanup = task_pl_entry_thumbnail_free;
/* Configure handle */
/* Configure handle
* > Note: playlist_config is unused by this task */
pl_thumb->system = NULL;
pl_thumb->playlist_path = playlist_path;
pl_thumb->dir_thumbnails = strdup(dir_thumbnails);
@ -863,6 +863,16 @@ bool task_push_pl_entry_thumbnail_download(
pl_thumb->overwrite = overwrite;
pl_thumb->status = PL_THUMB_BEGIN;
/* Configure task */
task->handler = task_pl_entry_thumbnail_download_handler;
task->state = pl_thumb;
task->title = strdup(system);
task->alternative_look = true;
task->mute = mute;
task->progress = 0;
task->callback = cb_task_pl_entry_thumbnail_refresh_menu;
task->cleanup = task_pl_entry_thumbnail_free;
task_queue_push(task);
return true;

View file

@ -49,16 +49,13 @@ enum pl_manager_status
typedef struct pl_manager_handle
{
bool use_old_format;
bool compress;
bool fuzzy_archive_match;
enum pl_manager_status status;
size_t list_size;
size_t list_index;
struct string_list *m3u_list;
size_t m3u_index;
char *playlist_path;
char *playlist_name;
playlist_config_t playlist_config;
playlist_t *playlist;
} pl_manager_handle_t;
@ -77,12 +74,6 @@ static void free_pl_manager_handle(pl_manager_handle_t *pl_manager)
pl_manager->m3u_list = NULL;
}
if (!string_is_empty(pl_manager->playlist_path))
{
free(pl_manager->playlist_path);
pl_manager->playlist_path = NULL;
}
if (!string_is_empty(pl_manager->playlist_name))
{
free(pl_manager->playlist_name);
@ -121,13 +112,23 @@ static void cb_task_pl_manager(
* (otherwise changes will be lost if the currently
* cached playlist is saved to disk for any reason...) */
if (string_is_equal(
pl_manager->playlist_path,
pl_manager->playlist_config.path,
playlist_get_conf_path(cached_playlist)))
{
playlist_free_cached();
playlist_init_cached(
pl_manager->playlist_path, COLLECTION_SIZE,
pl_manager->use_old_format, pl_manager->compress);
playlist_config_t playlist_config;
/* Copy configuration of cached playlist
* (could use pl_manager->playlist_config,
* but doing it this way guarantees that
* the cached playlist is preserved in
* its original state) */
if (playlist_config_copy(
playlist_get_config(cached_playlist),
&playlist_config))
{
playlist_free_cached();
playlist_init_cached(&playlist_config);
}
}
}
@ -167,10 +168,10 @@ static void task_pl_manager_reset_cores_handler(retro_task_t *task)
case PL_MANAGER_BEGIN:
{
/* Load playlist */
if (!path_is_valid(pl_manager->playlist_path))
if (!path_is_valid(pl_manager->playlist_config.path))
goto task_finished;
pl_manager->playlist = playlist_init(pl_manager->playlist_path, COLLECTION_SIZE);
pl_manager->playlist = playlist_init(&pl_manager->playlist_config);
if (!pl_manager->playlist)
goto task_finished;
@ -243,10 +244,7 @@ static void task_pl_manager_reset_cores_handler(retro_task_t *task)
task_title[0] = '\0';
/* Save playlist changes to disk */
playlist_write_file(
pl_manager->playlist,
pl_manager->use_old_format,
pl_manager->compress);
playlist_write_file(pl_manager->playlist);
/* Update progress display */
task_free_title(task);
@ -286,15 +284,14 @@ static bool task_pl_manager_reset_cores_finder(retro_task_t *task, void *user_da
if (!pl_manager)
return false;
return string_is_equal((const char*)user_data, pl_manager->playlist_path);
return string_is_equal((const char*)user_data, pl_manager->playlist_config.path);
}
bool task_push_pl_manager_reset_cores(const char *playlist_path)
bool task_push_pl_manager_reset_cores(const playlist_config_t *playlist_config)
{
task_finder_data_t find_data;
char playlist_name[PATH_MAX_LENGTH];
char task_title[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
retro_task_t *task = task_init();
pl_manager_handle_t *pl_manager = (pl_manager_handle_t*)calloc(1, sizeof(pl_manager_handle_t));
@ -302,13 +299,13 @@ bool task_push_pl_manager_reset_cores(const char *playlist_path)
task_title[0] = '\0';
/* Sanity check */
if (!task || !pl_manager || !settings)
if (!playlist_config || !task || !pl_manager)
goto error;
if (string_is_empty(playlist_path))
if (string_is_empty(playlist_config->path))
goto error;
fill_pathname_base_noext(playlist_name, playlist_path, sizeof(playlist_name));
fill_pathname_base_noext(playlist_name, playlist_config->path, sizeof(playlist_name));
if (string_is_empty(playlist_name))
goto error;
@ -316,11 +313,23 @@ bool task_push_pl_manager_reset_cores(const char *playlist_path)
/* Concurrent management of the same playlist
* is not allowed */
find_data.func = task_pl_manager_reset_cores_finder;
find_data.userdata = (void*)playlist_path;
find_data.userdata = (void*)playlist_config->path;
if (task_queue_find(&find_data))
goto error;
/* Configure handle */
if (!playlist_config_copy(playlist_config, &pl_manager->playlist_config))
goto error;
pl_manager->playlist_name = strdup(playlist_name);
pl_manager->playlist = NULL;
pl_manager->list_size = 0;
pl_manager->list_index = 0;
pl_manager->m3u_list = NULL;
pl_manager->m3u_index = 0;
pl_manager->status = PL_MANAGER_BEGIN;
/* Configure task */
strlcpy(
task_title, msg_hash_to_str(MSG_PLAYLIST_MANAGER_RESETTING_CORES),
@ -335,19 +344,6 @@ bool task_push_pl_manager_reset_cores(const char *playlist_path)
task->callback = cb_task_pl_manager;
task->cleanup = task_pl_manager_free;
/* Configure handle */
pl_manager->playlist_path = strdup(playlist_path);
pl_manager->playlist_name = strdup(playlist_name);
pl_manager->playlist = NULL;
pl_manager->list_size = 0;
pl_manager->list_index = 0;
pl_manager->m3u_list = NULL;
pl_manager->m3u_index = 0;
pl_manager->status = PL_MANAGER_BEGIN;
pl_manager->use_old_format = settings->bools.playlist_use_old_format;
pl_manager->compress = settings->bools.playlist_compression;
pl_manager->fuzzy_archive_match = false; /* Not relevant here */
task_queue_push(task);
return true;
@ -534,10 +530,10 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task)
case PL_MANAGER_BEGIN:
{
/* Load playlist */
if (!path_is_valid(pl_manager->playlist_path))
if (!path_is_valid(pl_manager->playlist_config.path))
goto task_finished;
pl_manager->playlist = playlist_init(pl_manager->playlist_path, COLLECTION_SIZE);
pl_manager->playlist = playlist_init(&pl_manager->playlist_config);
if (!pl_manager->playlist)
goto task_finished;
@ -639,7 +635,7 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task)
continue;
if (playlist_entries_are_equal(
entry, next_entry, pl_manager->fuzzy_archive_match))
entry, next_entry, &pl_manager->playlist_config))
{
/* Duplicate found - delete entry */
playlist_delete_index(pl_manager->playlist, pl_manager->list_index);
@ -748,9 +744,7 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task)
* content path of the M3U entry */
if (m3u_file_get_entry(m3u_file, i, &m3u_entry))
playlist_delete_by_path(
pl_manager->playlist,
m3u_entry->full_path,
pl_manager->fuzzy_archive_match);
pl_manager->playlist, m3u_entry->full_path);
}
m3u_file_free(m3u_file);
@ -770,10 +764,7 @@ static void task_pl_manager_clean_playlist_handler(retro_task_t *task)
task_title[0] = '\0';
/* Save playlist changes to disk */
playlist_write_file(
pl_manager->playlist,
pl_manager->use_old_format,
pl_manager->compress);
playlist_write_file(pl_manager->playlist);
/* Update progress display */
task_free_title(task);
@ -813,15 +804,14 @@ static bool task_pl_manager_clean_playlist_finder(retro_task_t *task, void *user
if (!pl_manager)
return false;
return string_is_equal((const char*)user_data, pl_manager->playlist_path);
return string_is_equal((const char*)user_data, pl_manager->playlist_config.path);
}
bool task_push_pl_manager_clean_playlist(const char *playlist_path)
bool task_push_pl_manager_clean_playlist(const playlist_config_t *playlist_config)
{
task_finder_data_t find_data;
char playlist_name[PATH_MAX_LENGTH];
char task_title[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
retro_task_t *task = task_init();
pl_manager_handle_t *pl_manager = (pl_manager_handle_t*)calloc(1, sizeof(pl_manager_handle_t));
@ -829,13 +819,13 @@ bool task_push_pl_manager_clean_playlist(const char *playlist_path)
task_title[0] = '\0';
/* Sanity check */
if (!task || !pl_manager || !settings)
if (!playlist_config || !task || !pl_manager)
goto error;
if (string_is_empty(playlist_path))
if (string_is_empty(playlist_config->path))
goto error;
fill_pathname_base_noext(playlist_name, playlist_path, sizeof(playlist_name));
fill_pathname_base_noext(playlist_name, playlist_config->path, sizeof(playlist_name));
if (string_is_empty(playlist_name))
goto error;
@ -843,11 +833,26 @@ bool task_push_pl_manager_clean_playlist(const char *playlist_path)
/* Concurrent management of the same playlist
* is not allowed */
find_data.func = task_pl_manager_clean_playlist_finder;
find_data.userdata = (void*)playlist_path;
find_data.userdata = (void*)playlist_config->path;
if (task_queue_find(&find_data))
goto error;
/* Configure handle */
if (!playlist_config_copy(playlist_config, &pl_manager->playlist_config))
goto error;
pl_manager->playlist_name = strdup(playlist_name);
pl_manager->playlist = NULL;
pl_manager->list_size = 0;
pl_manager->list_index = 0;
pl_manager->m3u_list = string_list_new();
pl_manager->m3u_index = 0;
pl_manager->status = PL_MANAGER_BEGIN;
if (!pl_manager->m3u_list)
goto error;
/* Configure task */
strlcpy(
task_title, msg_hash_to_str(MSG_PLAYLIST_MANAGER_CLEANING_PLAYLIST),
@ -862,22 +867,6 @@ bool task_push_pl_manager_clean_playlist(const char *playlist_path)
task->callback = cb_task_pl_manager;
task->cleanup = task_pl_manager_free;
/* Configure handle */
pl_manager->playlist_path = strdup(playlist_path);
pl_manager->playlist_name = strdup(playlist_name);
pl_manager->playlist = NULL;
pl_manager->list_size = 0;
pl_manager->list_index = 0;
pl_manager->m3u_list = string_list_new();
pl_manager->m3u_index = 0;
pl_manager->status = PL_MANAGER_BEGIN;
pl_manager->use_old_format = settings->bools.playlist_use_old_format;
pl_manager->compress = settings->bools.playlist_compression;
pl_manager->fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
if (!pl_manager->m3u_list)
goto error;
task_queue_push(task);
return true;

View file

@ -66,9 +66,6 @@ struct screenshot_task_state
bool is_idle;
bool is_paused;
bool history_list_enable;
bool pl_fuzzy_archive_match;
bool pl_use_old_format;
bool pl_compression;
bool widgets_ready;
int pitch;
@ -180,10 +177,7 @@ static void task_screenshot_handler(retro_task_t *task)
entry.core_path = (char*)"builtin";
entry.core_name = (char*)"imageviewer";
command_playlist_push_write(g_defaults.image_history, &entry,
state->pl_fuzzy_archive_match,
state->pl_use_old_format,
state->pl_compression);
command_playlist_push_write(g_defaults.image_history, &entry);
}
#endif
@ -284,9 +278,6 @@ static bool screenshot_dump(
if (fullpath)
strlcpy(state->filename, name_base, sizeof(state->filename));
state->pl_fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
state->pl_use_old_format = settings->bools.playlist_use_old_format;
state->pl_compression = settings->bools.playlist_compression;
state->is_idle = is_idle;
state->is_paused = is_paused;
state->bgr24 = bgr24;

View file

@ -121,7 +121,8 @@ bool task_push_pl_entry_thumbnail_download(
#ifdef HAVE_MENU
bool task_push_pl_thumbnail_download(
const char *system, const char *playlist_path,
const char *system,
const playlist_config_t *playlist_config,
const char *dir_thumbnails);
#endif
@ -147,8 +148,8 @@ bool task_push_core_restore(const char *backup_path,
const char *dir_libretro,
bool *core_loaded);
bool task_push_pl_manager_reset_cores(const char *playlist_path);
bool task_push_pl_manager_clean_playlist(const char *playlist_path);
bool task_push_pl_manager_reset_cores(const playlist_config_t *playlist_config);
bool task_push_pl_manager_clean_playlist(const playlist_config_t *playlist_config);
bool task_push_image_load(const char *fullpath,
bool supports_rgba, unsigned upscale_threshold,
@ -163,7 +164,9 @@ bool task_push_dbscan(
retro_task_callback_t cb);
#endif
bool task_push_manual_content_scan(void);
bool task_push_manual_content_scan(
const playlist_config_t *playlist_config,
const char *playlist_directory);
#ifdef HAVE_OVERLAY
bool task_push_overlay_load_default(

View file

@ -380,13 +380,17 @@ void MainWindow::addFilesToPlaylist(QStringList files)
QString selectedName;
QString selectedPath;
QStringList selectedExtensions;
playlist_config_t playlist_config;
QListWidgetItem *currentItem = m_listWidget->currentItem();
PlaylistEntryDialog *playlistDialog = playlistEntryDialog();
const char *currentPlaylistData = NULL;
playlist_t *playlist = NULL;
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_config.capacity = COLLECTION_SIZE;
playlist_config.old_format = settings->bools.playlist_use_old_format;
playlist_config.compress = settings->bools.playlist_compression;
playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
/* Assume a blank list means we will manually enter in all fields. */
if (files.isEmpty())
@ -523,7 +527,8 @@ void MainWindow::addFilesToPlaylist(QStringList files)
MENU_ENUM_LABEL_VALUE_QT_ADDING_FILES_TO_PLAYLIST));
dialog->setMaximum(list.count());
playlist = playlist_init(currentPlaylistData, COLLECTION_SIZE);
playlist_config_set_path(&playlist_config, currentPlaylistData);
playlist = playlist_init(&playlist_config);
for (i = 0; i < list.count(); i++)
{
@ -638,7 +643,6 @@ void MainWindow::addFilesToPlaylist(QStringList files)
{
struct playlist_entry entry = {0};
bool fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
/* the push function reads our entry as const,
* so these casts are safe */
@ -649,12 +653,11 @@ void MainWindow::addFilesToPlaylist(QStringList files)
entry.crc32 = const_cast<char*>("00000000|crc");
entry.db_name = const_cast<char*>(databaseData);
playlist_push(playlist, &entry, fuzzy_archive_match);
playlist_push(playlist, &entry);
}
}
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
playlist_free(playlist);
reloadPlaylists();
@ -676,6 +679,7 @@ bool MainWindow::updateCurrentPlaylistEntry(
QByteArray coreNameArray;
QByteArray dbNameArray;
QByteArray crc32Array;
playlist_config_t playlist_config;
QString playlistPath = getCurrentPlaylistPath();
const char *playlistPathData = NULL;
const char *pathData = NULL;
@ -688,8 +692,11 @@ bool MainWindow::updateCurrentPlaylistEntry(
unsigned index = 0;
bool ok = false;
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_config.capacity = COLLECTION_SIZE;
playlist_config.old_format = settings->bools.playlist_use_old_format;
playlist_config.compress = settings->bools.playlist_compression;
playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
if ( playlistPath.isEmpty() ||
contentHash.isEmpty() ||
@ -756,7 +763,8 @@ bool MainWindow::updateCurrentPlaylistEntry(
}
}
playlist = playlist_init(playlistPathData, COLLECTION_SIZE);
playlist_config_set_path(&playlist_config, playlistPathData);
playlist = playlist_init(&playlist_config);
{
struct playlist_entry entry = {0};
@ -772,8 +780,7 @@ bool MainWindow::updateCurrentPlaylistEntry(
playlist_update(playlist, index, &entry);
}
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
playlist_free(playlist);
reloadPlaylists();
@ -800,11 +807,10 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
QScopedPointer<QAction> downloadAllThumbnailsEntireSystemAction;
QScopedPointer<QAction> downloadAllThumbnailsThisPlaylistAction;
QPointer<QAction> selectedAction;
playlist_config_t playlist_config;
QPoint cursorPos = QCursor::pos();
settings_t *settings = config_get_ptr();
const char *path_dir_playlist = settings->paths.directory_playlist;
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
QDir playlistDir(path_dir_playlist);
QListWidgetItem *selectedItem = m_listWidget->itemAt(
m_listWidget->viewport()->mapFromGlobal(cursorPos));
@ -815,6 +821,11 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
bool specialPlaylist = false;
bool foundHiddenPlaylist = false;
playlist_config.capacity = COLLECTION_SIZE;
playlist_config.old_format = settings->bools.playlist_use_old_format;
playlist_config.compress = settings->bools.playlist_compression;
playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
if (selectedItem)
{
currentPlaylistPath = selectedItem->data(Qt::UserRole).toString();
@ -980,7 +991,10 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
}
if (loadPlaylist)
playlist = playlist_init(currentPlaylistPathCString, COLLECTION_SIZE);
{
playlist_config_set_path(&playlist_config, currentPlaylistPathCString);
playlist = playlist_init(&playlist_config);
}
if (playlist)
{
@ -1001,8 +1015,7 @@ void MainWindow::onPlaylistWidgetContextMenuRequested(const QPoint&)
}
/* Write changes to disk */
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
/* Free playlist, if required */
if (loadPlaylist)
@ -1340,6 +1353,7 @@ bool MainWindow::currentPlaylistIsAll()
void MainWindow::deleteCurrentPlaylistItem()
{
QByteArray playlistArray;
playlist_config_t playlist_config;
QString playlistPath = getCurrentPlaylistPath();
QHash<QString, QString> contentHash = getCurrentContentHash();
playlist_t *playlist = NULL;
@ -1348,8 +1362,11 @@ void MainWindow::deleteCurrentPlaylistItem()
bool ok = false;
bool isAllPlaylist = currentPlaylistIsAll();
settings_t *settings = config_get_ptr();
bool playlist_use_old_format = settings->bools.playlist_use_old_format;
bool playlist_compression = settings->bools.playlist_compression;
playlist_config.capacity = COLLECTION_SIZE;
playlist_config.old_format = settings->bools.playlist_use_old_format;
playlist_config.compress = settings->bools.playlist_compression;
playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
if (isAllPlaylist)
return;
@ -1371,11 +1388,11 @@ void MainWindow::deleteCurrentPlaylistItem()
if (!showMessageBox(QString(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_QT_CONFIRM_DELETE_PLAYLIST_ITEM)).arg(contentHash["label"]), MainWindow::MSGBOX_TYPE_QUESTION_YESNO, Qt::ApplicationModal, false))
return;
playlist = playlist_init(playlistData, COLLECTION_SIZE);
playlist_config_set_path(&playlist_config, playlistData);
playlist = playlist_init(&playlist_config);
playlist_delete_index(playlist, index);
playlist_write_file(
playlist, playlist_use_old_format, playlist_compression);
playlist_write_file(playlist);
playlist_free(playlist);
reloadPlaylists();
@ -1383,14 +1400,20 @@ void MainWindow::deleteCurrentPlaylistItem()
QString MainWindow::getPlaylistDefaultCore(QString dbName)
{
playlist_config_t playlist_config;
char playlistPath[PATH_MAX_LENGTH];
settings_t *settings = config_get_ptr();
QByteArray dbNameByteArray = dbName.toUtf8();
const char *dbNameCString = dbNameByteArray.data();
playlist_t *cachedPlaylist = playlist_get_cached();
playlist_t *playlist = NULL;
bool loadPlaylist = true;
QString corePath = QString();
QByteArray dbNameByteArray = dbName.toUtf8();
const char *dbNameCString = dbNameByteArray.data();
playlist_t *cachedPlaylist = playlist_get_cached();
playlist_t *playlist = NULL;
bool loadPlaylist = true;
QString corePath = QString();
settings_t *settings = config_get_ptr();
playlist_config.capacity = COLLECTION_SIZE;
playlist_config.old_format = settings->bools.playlist_use_old_format;
playlist_config.compress = settings->bools.playlist_compression;
playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
playlistPath[0] = '\0';
@ -1415,7 +1438,10 @@ QString MainWindow::getPlaylistDefaultCore(QString dbName)
}
if (loadPlaylist)
playlist = playlist_init(playlistPath, COLLECTION_SIZE);
{
playlist_config_set_path(&playlist_config, playlistPath);
playlist = playlist_init(&playlist_config);
}
if (playlist)
{
@ -1445,15 +1471,23 @@ void MainWindow::getPlaylistFiles()
void PlaylistModel::getPlaylistItems(QString path)
{
QByteArray pathArray;
playlist_config_t playlist_config;
const char *pathData = NULL;
playlist_t *playlist = NULL;
unsigned playlistSize = 0;
unsigned i = 0;
settings_t *settings = config_get_ptr();
playlist_config.capacity = COLLECTION_SIZE;
playlist_config.old_format = settings->bools.playlist_use_old_format;
playlist_config.compress = settings->bools.playlist_compression;
playlist_config.fuzzy_archive_match = settings->bools.playlist_fuzzy_archive_match;
pathArray.append(path);
pathData = pathArray.constData();
playlist = playlist_init(pathData, COLLECTION_SIZE);
playlist_config_set_path(&playlist_config, pathData);
playlist = playlist_init(&playlist_config);
playlistSize = playlist_get_size(playlist);
for (i = 0; i < playlistSize; i++)