(FFmpeg) should now have built-in support for launching movies/music

directly when HAVE_FFMPEG is defined
This commit is contained in:
twinaphex 2015-06-23 06:44:29 +02:00
parent 0944c2de10
commit 38b3b87812
10 changed files with 106 additions and 12 deletions

View File

@ -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);

View File

@ -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,

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -25,6 +25,7 @@
#include <boolean.h>
#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);

View File

@ -22,6 +22,10 @@
#include <errno.h>
#include <boolean.h>
#ifdef HAVE_FFMPEG
#include <rhash.h>
#endif
#ifdef _WIN32
#ifdef _XBOX
#include <xtl.h>
@ -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)

View File

@ -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,