diff --git a/playlist.c b/playlist.c index 5a58b2b0fa..eef820e12a 100644 --- a/playlist.c +++ b/playlist.c @@ -220,7 +220,7 @@ void playlist_update(playlist_t *playlist, size_t idx, * * Push entry to top of playlist. **/ -void playlist_push(playlist_t *playlist, +bool playlist_push(playlist_t *playlist, const char *path, const char *label, const char *core_path, const char *core_name, const char *crc32, @@ -229,7 +229,7 @@ void playlist_push(playlist_t *playlist, size_t i; if (!playlist) - return; + return false; if (string_is_empty(core_path) || string_is_empty(core_name)) { @@ -247,7 +247,7 @@ void playlist_push(playlist_t *playlist, if (string_is_empty(core_path) || string_is_empty(core_name)) { RARCH_ERR("cannot push NULL or empty core name into the playlist.\n"); - return; + return false; } } @@ -272,7 +272,7 @@ void playlist_push(playlist_t *playlist, /* If top entry, we don't want to push a new entry since * the top and the entry to be pushed are the same. */ if (i == 0) - return; + return false; /* Seen it before, bump to top. */ tmp = playlist->entries[i]; @@ -280,7 +280,7 @@ void playlist_push(playlist_t *playlist, i * sizeof(playlist_entry_t)); playlist->entries[0] = tmp; - return; + return true; } if (playlist->size == playlist->cap) @@ -312,6 +312,8 @@ void playlist_push(playlist_t *playlist, playlist->entries[0].crc32 = strdup(crc32); playlist->size++; + + return true; } void playlist_write_file(playlist_t *playlist) diff --git a/playlist.h b/playlist.h index 1df6751b57..ec9d34f8f7 100644 --- a/playlist.h +++ b/playlist.h @@ -21,6 +21,7 @@ #include #include +#include RETRO_BEGIN_DECLS @@ -96,7 +97,7 @@ void playlist_get_index(playlist_t *playlist, * * Push entry to top of playlist. **/ -void playlist_push(playlist_t *playlist, +bool playlist_push(playlist_t *playlist, const char *path, const char *label, const char *core_path, const char *core_name, const char *db_name, diff --git a/tasks/task_content.c b/tasks/task_content.c index a241ef176d..9e263dd67e 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -793,21 +793,38 @@ static void check_default_dirs(void) check_defaults_dir_create_dir(g_defaults.dir.thumbnails); } -static void content_push_to_history_playlist(bool do_push, - const char *path, void *data) +static bool content_push_to_history_playlist( + playlist_t *playlist, + const char *path, void *data, + enum content_mode_load mode) { settings_t *settings = config_get_ptr(); struct retro_system_info *info = (struct retro_system_info*)data; - /* If the history list is not enabled, early return. */ - if (!settings->history_list_enable) - return; - if (!g_defaults.history) - return; - if (!do_push) - return; + switch (mode) + { + case CONTENT_MODE_LOAD_CONTENT_WITH_FFMPEG_CORE_FROM_MENU: +#ifdef HAVE_FFMPEG + break; +#else + return false; +#endif + case CONTENT_MODE_LOAD_CONTENT_WITH_IMAGEVIEWER_CORE_FROM_MENU: +#ifdef HAVE_IMAGEVIEWER + break; +#else + return false; +#endif + default: + /* If the history list is not enabled, early return. */ + if (!settings->history_list_enable) + return false; + if (!playlist) + return false; + break; + } - playlist_push(g_defaults.history, + return playlist_push(playlist, path, NULL, config_get_active_core_path(), @@ -1650,9 +1667,10 @@ static bool task_load_content(content_ctx_info_t *content_info, if (info && *tmp) { - content_push_to_history_playlist( - true, tmp, info); - playlist_write_file(g_defaults.history); + playlist_t *playlist_tmp = g_defaults.history; + + if (content_push_to_history_playlist(playlist_tmp, tmp, info, mode)) + playlist_write_file(playlist_tmp); } }