diff --git a/command_event.c b/command_event.c index 6187bf73fd..2cbb4ff927 100644 --- a/command_event.c +++ b/command_event.c @@ -976,6 +976,11 @@ bool event_command(enum event_command cmd) #endif rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT); break; +#ifdef HAVE_FFMPEG + case EVENT_CMD_LOAD_CONTENT_FFMPEG: + rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT_FFMPEG); + break; +#endif case EVENT_CMD_LOAD_CONTENT: #ifdef HAVE_DYNAMIC event_command(EVENT_CMD_LOAD_CONTENT_PERSIST); diff --git a/command_event.h b/command_event.h index cf55cfb5af..968211756f 100644 --- a/command_event.h +++ b/command_event.h @@ -30,6 +30,9 @@ enum event_command /* Loads content file. */ EVENT_CMD_LOAD_CONTENT, EVENT_CMD_LOAD_CONTENT_PERSIST, +#ifdef HAVE_FFMPEG + EVENT_CMD_LOAD_CONTENT_FFMPEG, +#endif /* Loads core. */ EVENT_CMD_LOAD_CORE_DEINIT, EVENT_CMD_LOAD_CORE, diff --git a/menu/cbs/menu_cbs_iterate.c b/menu/cbs/menu_cbs_iterate.c index 22d39d7f7b..8f7d89cf75 100644 --- a/menu/cbs/menu_cbs_iterate.c +++ b/menu/cbs/menu_cbs_iterate.c @@ -110,7 +110,7 @@ static int archive_load(void) { case -1: event_command(EVENT_CMD_LOAD_CORE); - menu_common_load_content(false); + menu_common_load_content(false, CORE_TYPE_PLAIN); break; case 0: info.list = menu_list->menu_stack; diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 781ae03b28..64a1bc93ba 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -451,6 +451,8 @@ static int menu_cbs_init_bind_left_compare_type(menu_file_list_cbs_t *cbs, case MENU_FILE_DOWNLOAD_CORE: case MENU_FILE_CHEAT: case MENU_FILE_REMAP: + case MENU_FILE_MOVIE: + case MENU_FILE_MUSIC: case MENU_FILE_PLAYLIST_COLLECTION: case MENU_SETTING_GROUP: switch (menu_label_hash) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 5de49e1768..e7442e3adc 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -88,7 +88,7 @@ static int rarch_defer_core_wrapper(menu_displaylist_info_t *info, break; default: event_command(EVENT_CMD_LOAD_CORE); - menu_common_load_content(false); + menu_common_load_content(false, CORE_TYPE_PLAIN); ret = -1; break; } @@ -150,7 +150,7 @@ static int action_ok_file_load_detect_core(const char *path, strlcpy(global->fullpath, detect_content_path, sizeof(global->fullpath)); strlcpy(settings->libretro, path, sizeof(settings->libretro)); event_command(EVENT_CMD_LOAD_CORE); - menu_common_load_content(false); + menu_common_load_content(false, CORE_TYPE_PLAIN); return -1; } @@ -860,7 +860,7 @@ static int action_ok_core_load_deferred(const char *path, strlcpy(global->fullpath, menu->deferred_path, sizeof(global->fullpath)); - menu_common_load_content(false); + menu_common_load_content(false, CORE_TYPE_PLAIN); return -1; } @@ -926,7 +926,7 @@ static int action_ok_core_load(const char *path, { *global->fullpath = '\0'; - menu_common_load_content(false); + menu_common_load_content(false, CORE_TYPE_PLAIN); return -1; } @@ -1087,6 +1087,28 @@ static int action_ok_disk_image_append(const char *path, return -1; } +#ifdef HAVE_FFMPEG +static int action_ok_file_load_ffmpeg(const char *path, + const char *label, unsigned type, size_t idx, size_t entry_idx) +{ + const char *menu_path = NULL; + global_t *global = global_get_ptr(); + menu_list_t *menu_list = menu_list_get_ptr(); + + if (!menu_list) + return -1; + + menu_list_get_last(menu_list->menu_stack, + &menu_path, NULL, NULL, NULL); + + fill_pathname_join(global->fullpath, menu_path, path, + sizeof(global->fullpath)); + + menu_common_load_content(true, CORE_TYPE_FFMPEG); + + return 0; +} +#endif static int action_ok_file_load(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) @@ -1119,7 +1141,7 @@ static int action_ok_file_load(const char *path, fill_pathname_join(global->fullpath, menu_path, path, sizeof(global->fullpath)); - menu_common_load_content(true); + menu_common_load_content(true, CORE_TYPE_PLAIN); return -1; } @@ -1745,6 +1767,12 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, break; } break; + case MENU_FILE_MOVIE: + case MENU_FILE_MUSIC: +#ifdef HAVE_FFMPEG + cbs->action_ok = action_ok_file_load_ffmpeg; +#endif + break; case MENU_SETTINGS_CUSTOM_VIEWPORT: cbs->action_ok = action_ok_custom_viewport; break; diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index eae250302e..e04b610b44 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -385,6 +385,8 @@ static int menu_cbs_init_bind_right_compare_type(menu_file_list_cbs_t *cbs, case MENU_FILE_DOWNLOAD_CORE: case MENU_FILE_CHEAT: case MENU_FILE_REMAP: + case MENU_FILE_MOVIE: + case MENU_FILE_MUSIC: case MENU_FILE_PLAYLIST_COLLECTION: case MENU_SETTING_GROUP: switch (menu_label_hash) diff --git a/menu/menu.c b/menu/menu.c index 0fa2d44378..6d7d0aec7e 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -87,7 +87,7 @@ static void menu_push_to_history_playlist(void) * * Returns: true (1) if successful, otherwise false (0). **/ -bool menu_load_content(void) +bool menu_load_content(enum rarch_core_type type) { menu_handle_t *menu = menu_driver_get_ptr(); menu_display_t *disp = menu_display_get_ptr(); @@ -131,14 +131,25 @@ bool menu_load_content(void) return true; } -void menu_common_load_content(bool persist) +void menu_common_load_content(bool persist, enum rarch_core_type type) { menu_display_t *disp = menu_display_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return; - event_command(persist ? EVENT_CMD_LOAD_CONTENT_PERSIST : EVENT_CMD_LOAD_CONTENT); + switch (type) + { + case CORE_TYPE_PLAIN: + case CORE_TYPE_DUMMY: + event_command(persist ? EVENT_CMD_LOAD_CONTENT_PERSIST : EVENT_CMD_LOAD_CONTENT); + break; +#ifdef HAVE_FFMPEG + case CORE_TYPE_FFMPEG: + event_command(EVENT_CMD_LOAD_CONTENT_FFMPEG); + break; +#endif + } menu_list_flush_stack(menu_list, NULL, MENU_SETTINGS); disp->msg_force = true; diff --git a/menu/menu.h b/menu/menu.h index 2245a5edc3..0ee06bf5f8 100644 --- a/menu/menu.h +++ b/menu/menu.h @@ -25,6 +25,7 @@ #include #include "../driver.h" +#include "../dynamic.h" #if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL) #ifndef HAVE_SHADER_MANAGER @@ -180,15 +181,16 @@ void menu_free(menu_handle_t *menu); /** * menu_load_content: + * type : Type of content to load. * * Loads content into currently selected core. * Will also optionally push the content entry to the history playlist. * * Returns: true (1) if successful, otherwise false (0). **/ -bool menu_load_content(void); +bool menu_load_content(enum rarch_core_type type); -void menu_common_load_content(bool persist); +void menu_common_load_content(bool persist, enum rarch_core_type type); void menu_update_system_info(menu_handle_t *menu, bool *load_no_content); diff --git a/retroarch.c b/retroarch.c index 9bd1da89d4..9bf6393b8d 100644 --- a/retroarch.c +++ b/retroarch.c @@ -22,6 +22,10 @@ #include #include +#ifdef HAVE_FFMPEG +#include +#endif + #ifdef _WIN32 #ifdef _XBOX #include @@ -841,6 +845,31 @@ static void parse_input(int argc, char *argv[]) else global->libretro_no_content = true; +#ifdef HAVE_FFMPEG + { + uint32_t hash_ext = djb2_calculate(path_get_extension(global->fullpath)); + + switch (hash_ext) + { + case MENU_VALUE_FILE_OGM: + case MENU_VALUE_FILE_MKV: + case MENU_VALUE_FILE_AVI: + case MENU_VALUE_FILE_MP4: + case MENU_VALUE_FILE_FLV: + case MENU_VALUE_FILE_3GP: + case MENU_VALUE_FILE_F4F: + case MENU_VALUE_FILE_F4V: + case MENU_VALUE_FILE_MP3: + case MENU_VALUE_FILE_M4A: + case MENU_VALUE_FILE_OGG: + case MENU_VALUE_FILE_FLAC: + case MENU_VALUE_FILE_WAV: + global->core_type = CORE_TYPE_FFMPEG; + break; + } + } +#endif + /* Copy SRM/state dirs used, so they can be reused on reentrancy. */ if (global->has_set_save_path && path_is_directory(global->savefile_name)) @@ -1337,7 +1366,16 @@ void rarch_main_set_state(unsigned cmd) case RARCH_ACTION_STATE_LOAD_CONTENT: #ifdef HAVE_MENU /* If content loading fails, we go back to menu. */ - if (!menu_load_content()) + if (!menu_load_content(CORE_TYPE_PLAIN)) + rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING); +#endif + if (driver->frontend_ctx && driver->frontend_ctx->content_loaded) + driver->frontend_ctx->content_loaded(); + break; + case RARCH_ACTION_STATE_LOAD_CONTENT_FFMPEG: +#ifdef HAVE_MENU + /* If content loading fails, we go back to menu. */ + if (!menu_load_content(CORE_TYPE_FFMPEG)) rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING); #endif if (driver->frontend_ctx && driver->frontend_ctx->content_loaded) diff --git a/retroarch.h b/retroarch.h index 7f85993f0c..b0ca9f5108 100644 --- a/retroarch.h +++ b/retroarch.h @@ -31,6 +31,9 @@ enum action_state { RARCH_ACTION_STATE_NONE = 0, RARCH_ACTION_STATE_LOAD_CONTENT, +#ifdef HAVE_FFMPEG + RARCH_ACTION_STATE_LOAD_CONTENT_FFMPEG, +#endif RARCH_ACTION_STATE_MENU_RUNNING, RARCH_ACTION_STATE_MENU_RUNNING_FINISHED, RARCH_ACTION_STATE_QUIT,